Structure of Smart Contract
Explore the structure of smart contracts, including the types of accounts involved, their derivation, and nesting.
A smart contract represents a structure of connected accounts (you can think of this as separate database tables) where each is derived through a specific algorithm based on parameters such as the smart contract’s address, seed (a unique specifier of account type), int_seed (a unique specifier for a specific branch of the smart contract), and in some cases, the client’s public key. Thus, accounts can be divided into two large groups: those specific to the smart contract and those specific to the client. All accounts specific to the smart contract can be ‘unveiled’ from the tree of accounts, where the root account will be the root-account. Client-specific accounts are constructed from the client’s wallet address.
Nesting of Accounts Structure
Types of Accounts
Accounts are divided into two major groups based on the key from which they are derived (PDA):
Client-Specific (derived from the client’s public key):
- ClientAccount: The main account of the client, containing information about the pools in which the client participates, purchased options, trading volume, and so forth.
- PayoffLogAccount: Information about all the payoffs for a specific client.
Smart Contract-Specific (derived from the smart contract address):
Nesting is similar in smart contract.
-
RootAccount: The root account, containing addresses of underlying principal accounts.
-
OraclesAccount: Information about oracles (prices of BTC, ETH, etc. in USDC or other currencies) used on the platform.
-
MintsAccount: Information about the base currencies supported by the platform.
- MintLogAccount: Historical information about currency changes on the platform.
-
WorkerAccount: An entity that manages the trading pool, stores the distribution of strikes, their changing prices, range boundaries, and more.
- PoolsLogAccount: Information about transactions in the current pool (expiries), a ring buffer that contains a limited number of the most recent transactions.
- PoolsTraceAccount: Historical information about pools, including the settlement price at which they were completed.
- TasksLogAccount: Information about the settings of the current pool (expiries), a ring buffer that contains a limited number of the most recent transactions.
- TasksTraceAccount: Historical information about settings of pools.
-
InstrumentsAccount: Information about currency pairs that can be traded on the platform.
-