Skip to main content

Accounting

At the core of Luna is double entry ledger system. With first class integration into the Luna contract language this allows complex position keeping for any financial instrument or portfolio.

Balance Sheets

Balance Sheets are position keeping tools that are created either by Contract actions or via the API, and they are owned by Participants.

A Participant can have multiple Balance Sheets for each unit of value (where value in this instance takes the form of any fungible asset e.g. USD, GBP, BTC), but each Balance Sheet, and their associated objects, can be used across multiple Contracts;

The only stipulation to using a Balance Sheet is that the Participant that owns the Balance Sheet must be attached to a Role on the Contract.

Every Balance Sheet will have a set of associated Balance Sheet Accounts (BSAs) that will hold details of the ledger entries created as part of Clause actions within a Contract e.g. the transfer of funds from one Participant to another, and the Balance Sheet will hold the financial summary across accounts.

Every BSA will have the following attributes:

  • Account Type
  • Chart Code
  • Name
  • Total Balance

Each BSA on a Balance Sheet must have a unique combination of Account Type and Chart Code, where the type must be one of either Asset, Liability or Equity, and the Chart Code can then be used to further define the accounting structure that will direct where Balance Sheet Entries are placed:

  • Contracts create Balanace Sheet Entries onto BSAs
  • Balanace Sheet Entries are contained within Balance Sheet Events
  • Balance Sheet Events reference the relevant Contract Audit

There are two ways a Balance Sheet Account can be attributed to a Contract:

  1. As a Parameter:

    1. A Balance Sheet Account can be defined as a Parameter with type_ BalanceSheetAccount. The ID of required Balance Sheet Account can then be passed in as a Parameter during contract creation.
  2. As a Variable:

    1. A Balance Sheet Account can be defined as a Variable. The default value will be None which can then be redefined within a Clause during the runtime of a Contract as desired.

Functions on a Contract will be used to create Balance Sheet Events and Balance Sheet Entries, where any entry must be attached to a corresponding event.

Please refer to the Step by Step Guide for examples on how built-in Functions can be used within a Contract to create Balance Sheet Accounts and then applied to payment transfer Clauses defined within the Template.