๐Ÿ“„Storage overview

Storage fields and types

Base types

type tokenId is nat

type assetType          is
| FA12 of address // TZIP-007 compatible token
| FA2  of (address * nat) // TZIP-012 compatible token

type token_metadata_info is [@layout:comb] record [
  token_id              : tokenId;
  token_info            : map(string, bytes);
] // token metadata by TZIP-016 for each TZIP-012 token

Account type

Field
Type
Description

allowances

set(address)

allowances (operators) - set of address allowed to transfer on account's behalf

borrow

nat

amount of borrowed tokens

lastBorrowIndex

nat

account's last borrow index to apply interest to borrowed tokens

type account            is [@layout:comb] record [
  allowances            : set(address);
  borrow                : nat;
  lastBorrowIndex       : nat;
]

yToken type (market)

Field
Type
Hint
Description

mainToken

assetType

FA12/FA2

underlying asset

interestRateModel

address

KT1....

Interest rate contract

interestUpdateTime

timestamp

last time when interest of token updated

priceUpdateTime

timestamp

last time when price of token updated

totalBorrowsF

nat

float value multiplied by 1e+18

total amount of borrowed tokens

totalLiquidF

nat

float value multiplied by 1e+18

total liquidity locked at market

totalSupplyF

nat

float value multiplied by 1e+18

total supply of yToken

totalReservesF

nat

float value multiplied by 1e+18

"subsidiary" reserves of protocol

borrowIndex

nat

index collecting interest

maxBorrowRate

nat

float value multiplied by 1e+18

collateralFactorF

nat

float value multiplied by 1e+18

Rate represents by which the borrow limit increases if the yToken is minted

liquidReserveRateF

nat

float value multiplied by 1e+18

Percent of liquidate collateral amount that goes to reserves

reserveFactorF

nat

float value multiplied by 1e+18

Rate that represents what part of the interest goes to the protocol reserves

lastPrice

nat

last price of underlying token to XTZ

borrowPause

bool

isInterestUpdating

bool

threshold

nat

float value multiplied by 1e+18

threshold of collateral borrow rate

type tokenType          is [@layout:comb] record [
  mainToken             : assetType;
  interestRateModel     : address;
  interestUpdateTime    : timestamp;
  priceUpdateTime       : timestamp;
  totalBorrowsF         : nat;
  totalLiquidF          : nat;
  totalSupplyF          : nat;
  totalReservesF        : nat;
  borrowIndex           : nat;
  maxBorrowRate         : nat;
  collateralFactorF     : nat;
  liquidReserveRateF    : nat;
  reserveFactorF        : nat;
  lastPrice             : nat;
  borrowPause           : bool;
  isInterestUpdating    : bool;
  threshold             : nat;
]

yStorage - main Yupana storage values

Field
Type
Hint
Description

admin

address

tz/KT....

contract administrator

ledger

big_map(

(address * tokenId), nat

)

storage of token balances

accounts

big_map(

(address * tokenId), account

)

tokens

map(tokenId, tokenType)

lastTokenId

nat

counter, size of tokens

tokenId of last created market

priceFeedProxy

address

KT1...

closeFactorF

nat

float value multiplied by 1e+18

max portion of the loan that can be liquidated per single transaction

liqIncentiveF

nat

float value multiplied by 1e+18

Rate that the liquidator will earn if liquidate the asset

markets

big_map(

address, set(tokenId)

)

size of set is limited by maxMarkets value

mapping of entered as collateral user markets

borrows

big_map(

address, set(tokenId)

)

size of set is limited by maxMarkets value

mapping of borrowed tokens of user markets

maxMarkets

nat

max markets allowed to enter as collateral or borrow

assets

big_map(

assetType, tokenId

)

mapping underlying asset (FA12/FA2) to corresponding tokenId of yToken market

type yStorage is [@layout:comb] record [
  admin: address; 
  ledger: big_map((address * tokenId), nat); 
  accounts: big_map((address * tokenId), account); 
  tokens                : map(tokenId, tokenType);
  lastTokenId           : nat;
  priceFeedProxy        : address;
  closeFactorF          : nat;
  liqIncentiveF         : nat;
  markets               : big_map(address, set(tokenId));
  borrows               : big_map(address, set(tokenId));
  maxMarkets            : nat;
  assets                : big_map(assetType, tokenId);
]

fullStorage - contract storage root

Field
Type
Description

storage

yStorage

metadata

big_map(string, bytes)

token_metadata

big_map(tokenId, token_metadata_info)

tokenLambdas

big_map(nat, bytes)

FA2 lambda-methods storage

useLambdas

big_map(nat, bytes)

Yupana protocol lambda-methods storage

type fullStorage   is record [
  storage               : yStorage;
  metadata              : big_map(string, bytes);
  token_metadata        : big_map(tokenId, token_metadata_info);
  tokenLambdas          : big_map(nat, bytes);
  useLambdas            : big_map(nat, bytes);
]

Last updated