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();

Errors

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

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

Last updated