exitMarket
tokenId -> storage upd
Allows user to indicate that underying token is no longer used as collateral by tokenId.
The yToken contract expects that underlying token infos of tokenIdand all borrowed by user before tokenIds are updated by calling PriceFeed.getPrice and updateInterest in the same block before this contract method
Types
type tokenId of nat // yToken tokenId related to marketUsage
const tokenId = 0; // or new BigNumber(0) or "0"
const amount = 10_000_000; // amount of yTokens to burn, pass 0 to burn all.
const yupana = await tezos.contract.at(yTokenAddress);
const proxy = await tezos.contract.at(proxyAddress);
const borrowedTokenIds = [1, 2]; // user borrowed tokens
const updBorrowed = borrowedTokenIds.reduce(
(batch, tokenId) => {
batch.push({
kind: "transaction",
...yupana.methods.updateInterest(tokenId).toTransferParams(),
},
{
kind: "transaction",
...proxy.methods.getPrice([tokenId]).toTransferParams(),
});
return batch;
}
const batchArray = [
...updBorrowed,
{
kind: "transaction",
...yupana.methods.updateInterest(tokenId).toTransferParams(),
},
{
kind: "transaction",
...proxy.methods.getPrice([tokenId]).toTransferParams(),
},
{
kind: "transaction",
...yupana.methods.exitMarket(tokenId).toTransferParams(),
},
];
const batch = await tezos.wallet.batch(batchArray);
const operation = await batch.send();
await operation.confirmation();token_id = 0
amount = 10_000_000 # amount of yTokens to burn, pass 0 to burn all.
yupana = ContractInterface.from_michelson(code) # or client.contract(contract_address)...
proxy = ContractInterface.from_michelson(prx_code) # or client.contract(prx_contract_address)...
borrow_ids = [1, 2] # user borrowed tokens
borrow_updates = [yupana.updateInterest(borrow_token_id) for borrow_token_id in borrow_ids]
borrow_updates.append(proxy.getPrice([borrow_token_id for borrow_token_id in borrow_ids]))
call = pytezos.bulk(
*borrow_updates,
yupana.updateInterest(token_id),
proxy.getPrice([token_id]),
yupana.exitMarket(token_id)
).autofill().sign()
opg = call.inject()Errors
yToken/debt-not-repaid- user has unpaid debt.yToken/need-update- token price and interest not updated (see warning above)yToken/yToken-undefined- token identifier is not assigned to any known yTokens.
Last updated