๐Ÿ“–
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
  • Types
  • Usage
  • Errors
  1. Developer space
  2. yToken contract methods
  3. Admin methods
  4. Manage entrypoints

setTokenFactors

params of setTokenParams -> storage with [ tokens[tokenId] ] upd

PrevioussetGlobalFactorsNextupdateMetadata

Last updated 3 years ago

Updates token-related factors of the protocol by tokenId of yToken.

The yToken contract expects that underlying token info of tokenId is updated by calling and in the same block before this call.

Types

type setTokenParams     is [@layout:comb] record [
  tokenId               : nat;
  collateralFactorF     : nat;
  reserveFactorF        : nat;
  interestRateModel     : address;
  maxBorrowRate         : nat;
  threshold             : nat;
  liquidReserveRateF    : nat;
]

Parameter
Type
Description

tokenId

nat

token identifier

collateralFactorF

nat

collateral factor

as float number multiplied by precision= 1000000000000000000n; (1e+18)

reserveFactorF

nat

reserve factor

as float number multiplied by precision= 1000000000000000000n; (1e+18)

interestRateModel

address

priceFeed proxy contract instance

maxBorrowRate

nat

threshold

nat

liquidReserveRateF

nat

Usage

const tokenId = 0; // or new BigNumber(0) or "0"
const yupana = await tezos.contract.at(yTokenAddress);
const batchArray = [
      {
        kind: "transaction",
        ...yupana.methods.updateInterest(tokenId).toTransferParams(),
      },
      {
        kind: "transaction",
        ...proxy.methods.getPrice([tokenId]).toTransferParams(),
      },
      {
        kind: "transaction",
        ...yupana.methods.setTokenFactors(
          tokenId,
          650000000000000000,
          200000000000000000,
          "KT1...",
          5000000000000,
          550000000000000000
        ).toTransferParams(),
      },
    ];
const batch = await tezos.wallet.batch(batchArray);
const operation = await batch.send();
await operation.confirmation();
token_id = 0
PRECISION = pow(10, 18)
config = {
  "collateral_factor": 0.5,
  "reserve_factor": 0.5,
  "threshold": 0.8
}
yupana = ContractInterface.from_michelson(code) # or client.contract(contract_address)...
proxy = ContractInterface.from_michelson(prx_code) # or client.contract(prx_contract_address)...proxy = ContractInterface.from_michelson(code) # or client.contract(contract_address)...
call = pytezos.bulk(
        yupana.updateInterest(token_id),
        proxy.getPrice([token_id]),
        yupana.setTokenFactors(
             tokenId = token_id, 
             collateralFactorF = int(config["collateral_factor"] * PRECISION),
             reserveFactorF = int(config["reserve_factor"]  * PRECISION),
             interestRateModel = "KT1...",
             maxBorrowRate = 1_000_000  * PRECISION,
             threshold = int(config["threshold"] * PRECISION)
        )
    ).autofill().sign()
opg = call.inject()

Errors

  • yToken/not-admin - sender is not contract admin.

  • yToken/need-update - token price and interest not updated (see warning above)

โš™๏ธ
๐Ÿ›‘
๐Ÿคน
PriceFeed.getPrice
updateInterest