setTokenFactors
params of setTokenParams -> storage with [ tokens[tokenId] ] upd
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 PriceFeed.getPrice and updateInterest 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;
]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-senderis not contract admin.yToken/need-update- token price and interest not updated (see warning above)
Last updated