๐Ÿ“–
Yupana Document Portal
  • Introduction
    • What is Yupana.Finance?
    • Participants
    • FAQ
  • Lending
    • Supplying assets
      • General
    • Borrowing assets
      • General
  • Liquidation
  • Liquidity Risk
    • Yupana Interest Rate
  • โš™๏ธDeveloper space
    • yToken contract methods
      • ๐Ÿ“„Storage overview
      • accrueInterest
      • priceCallback
      • updateInterest
      • ๐Ÿ”ตLending methods
        • borrow
        • enterMarket
        • exitMarket
        • liquidate
        • mint
        • redeem
        • repay
      • ๐Ÿ”ตFA2 Token entrypoints
        • balance_of
        • get_total_supply
        • transfer
        • update_operators
      • ๐Ÿ›‘Admin methods
        • ๐Ÿ“ฅSetup entrypionts
          • setTokenAction
          • setUseAction
        • ๐ŸคนManage entrypoints
          • addMarket
          • setAdmin
          • setBorrowPause
          • setGlobalFactors
          • setTokenFactors
          • updateMetadata
          • withdrawReserve
    • InterestRate contract
      • ๐Ÿ”ตOn-chain views
        • getBorrowRate
        • getSupplyRate
        • getUtilizationRate
      • ๐Ÿ›‘Admin methods
        • setCoefficients
        • updateAdmin
    • PriceFeed contract
      • getPrice
      • receivePrice
      • ๐Ÿ›‘Admin methods
        • setProxyAdmin
        • updateOracle
        • updatePair
        • updateYToken
  • Agreements
    • Terms of Service
    • Privacy Policy
    • Cookie Policy
Powered by GitBook
On this page
  • Base types
  • Account type
  • yToken type (market)
  • yStorage - main Yupana storage values
  • fullStorage - contract storage root
  1. Developer space
  2. yToken contract methods

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);
]
PreviousyToken contract methodsNextaccrueInterest

Last updated 3 years ago

called with tokenId of this token.

called with tokenId of this token.

limit of borrow rate response. Used to verify borrow rate in

flag if borrowing paused for token

flag of waiting response from

storage

storage

address

contract metadata by

mapping each token metadata by

โš™๏ธ
๐Ÿ“„
token.borrowIndexโˆ—(borrowRateโˆ—blockDeltaprecision+1)token.borrowIndex *(\textstyle\frac{borrowRate * blockDelta}{ precision} + 1)token.borrowIndexโˆ—(precisionborrowRateโˆ—blockDeltaโ€‹+1)
updateInterest
accrueInterest
setBorrowPause
InterestRate contract
PriceFeed contract
Account type
yToken type (market)
yStorage - main Yupana storage values
PriceFeed.getPrice
TZIP-016
TZIP-012