๐Ÿ“–
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

addMarket

params of newMarketParams -> storage upd

Creates new token lending market.

Types

type assetType          is
| FA12 of address
| FA2  of (address * nat)

type newMetadataParams is map(string, bytes)

type newMarketParams    is [@layout:comb] record [
  interestRateModel     : address;
  asset                 : assetType;
  collateralFactorF     : nat;
  reserveFactorF        : nat;
  maxBorrowRate         : nat;
  token_metadata        : newMetadataParams;
  threshold             : nat;
  liquidReserveRateF    : nat;
]
Parameter
Type
Description

interestRateModel

address

interestRate contract instance

asset

assetType

FA12 or FA2 token

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)

maxBorrowRate

nat

token_metadata

map(string, bytes)

token metadata packed to bytes

threshold

nat

liquidReserveRateF

nat

Usage

const fa2TokenId = 3;
const tokenMetadata = MichelsonMap.fromLiteral({
  symbol: Buffer.from("TST").toString("hex"),
  name: Buffer.from("TEST").toString("hex"),
  decimals: Buffer.from("6").toString("hex"),
  icon: Buffer.from("someURL").toString("hex"),
});
const yupana = await tezos.contract.at(yTokenAddress);
const operation = await yupana.methodsObject.addMarket(
      {
      interestRateModel: "KT1...",
      asset: { fa12: "KT1..." } or { fa2: { 0: "KT1...", 1: fa2TokenId } },
      collateralFactorF: 650000000000000000,
      reserveFactorF: 200000000000000000,
      maxBorrowRate: 5000000000000,
      token_metadata: tokenMetadata,
      threshold: 550000000000000000
).send();
await operation.confirmation();
PRECISION = pow(10, 18)
config = {
  "collateral_factor": 0.5,
  "reserve_factor": 0.5,
  "threshold": 0.8
}
token = { "fA12": token_address } # or { "fA2": (token_address, token_id) }
yupana = ContractInterface.from_michelson(code) # or client.contract(contract_address)...
call = yupana.addMarket(
                interestRateModel = "KT1...",
                asset = token,
                collateralFactorF = int(config["collateral_factor"] * PRECISION),
                reserveFactorF = int(config["reserve_factor"]  * PRECISION),
                maxBorrowRate = 1_000_000  * PRECISION,
                token_metadata = {"": ""},
                threshold = int(config["threshold"] * PRECISION)
            )
opg = call.inject()

Errors

  • yToken/token-has-already-been-added -this token has been added to the market already.

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

PreviousManage entrypointsNextsetAdmin

Last updated 3 years ago

โš™๏ธ
๐Ÿ›‘
๐Ÿคน