Contract storage
Market Storage is a crucial component of our contract that serves as a central repository for all data related to the contract's mathematical operations.
Data Structures
Market Configuration
The MarketConfiguration
entity is used to store the market configuration for each individual market. This object contains information such as the token that can be supplied and borrowed, details about the pricing, interest rates, rewards, and more.
Market configuration has the following fields:
base_token
(AssetId): The asset that can be supplied and borrowed.base_token_decimals
(u32): The decimal of the base token.base_token_price_feed_id
(b256): The address of the price oracle contract where you can check the base token's market price in USD.supply_kink
(u256): Above this point the supply interest rate increases more rapidly.borrow_kink
(u256): above this point the borrow interest rate increases more rapidly.supply_per_second_interest_rate_slope_low
(u256): The coefficient of dependence of the deposit rate on utilization every second if utilization is below optimal.supply_per_second_interest_rate_slope_high
(u256): The coefficient of dependence of the deposit rate on utilization every second if utilization is higher than optimal.supply_per_second_interest_rate_base
(u256): The minimum monthly supply rate.borrow_per_second_interest_rate_slope_low
(u256): The coefficient of dependence of the borrow rate on utilization every second if utilization is below optimal.borrow_per_second_interest_rate_slope_high
(u256): The coefficient of dependence of the borrow rate on utilization every second if utilization is higher than optimal.borrow_per_second_interest_rate_base
(u256): The minimum monthly borrow rate.store_front_price_factor
(u256): The share of the elimination of the penalty that the liquidator receives (and the rest remains on the score sheet as a protective reserve).base_tracking_index_scale
(u256): The index scale that determines how much rewards are being accrued.base_tracking_supply_speed
(u256): The amount of rewards (liquidity mining) we accrue per second for the entire supply.base_tracking_borrow_speed
(u256): The amount of rewards (liquidity mining) we charge per second for the entire borrow.base_min_for_rewards
(u256): The minimum amount at which rewards are accrued, with the same decimal as the base asset.base_borrow_min
(u256): The minimal value of the base borrow amount, with the same decimal as the base asset.target_reserves
(u256): The maximum number of protective reserves at which the sale of collateral occurs during liquidation.
Collateral Configuration
The CollateralConfiguration
entity is used to store the configuration values for each collateral asset in the market. It contains the following fields:
asset_id
(AssetId): The asset that can be used as collateral.price_feed_id
(b256): The price feed id of the price oracle contract where you can check the token's market price in USD.decimals
(u32): The decimal of the token.borrow_collateral_factor
(u256): The amount you can borrow relative to the dollar value of the collateral asset.liquidate_collateral_factor
(u256): The ratio of the dollar value of the underlying asset to the dollar value of the collateral asset at which the debt will be liquidated.liquidation_penalty
(u256): The amount of collateral that will be retained upon liquidation.supply_cap
(u64): The maximum number of supply tokens per protocol.paused
(bool): Whether this collateral asset is currently active.
Pause Configuration
The PauseConfiguration
entity has the following fields:
supply_paused
(bool)withdraw_paused
(bool)absorb_paused
(bool)buy_pause
(bool)
Each field in the PauseConfiguration
represents whether a particular contract action (supply, withdraw, absorb, or buy) is currently paused or not.
User Basic
The UserBasic
entity stores the position information of each user. It has the following fields:
principal
(i256): the user's balance at the time of market initialization, which can be used to calculate the current supply balance by multiplying it with sRate / bRate.base_tracking_index
(u256): this value determines how much rewards the user is eligible to receive.base_tracking_accrued
(u256): the total rewards accrued for the user.
Market Basics
The MarketBasics
entity stores the market-wide values. It has the following fields:
base_supply_index
(u256): the supply rate.base_borrow_index
(u256): the borrowing rate.tracking_supply_index
(u256): the supply rate for rewards.tracking_borrow_index
(u256): the borrowing rate for rewards.total_supply_base
(u256): the total supply of the underlying asset in the market.total_borrow_base
(u256): the total borrow of the underlying asset in the market.last_accrual_time
(u256): the last time when interest was accrued.
Structure of the Contract Storage
Market contract's storage has the following fields:
market_configuration: MarketConfiguration
collateral_configurations: StorageMap<AssetId, CollateralConfiguration>
collateral_configuration_keys: StorageVec<AssetId>
pause_config: PauseConfiguration
totals_collateral: StorageMap<AssetId, u64>
user_collateral: StorageMap<(Identity, AssetId), u64>
user_basic: StorageMap<Identity, UserBasic>
market_basic: MarketBasics
pyth_contract_id: ContractId
Last updated