repay

params of yAssetParams -> (list(op), storage upd)

Return amount of debt, in underlying token of yToken token by tokenId.

circle-info

Underlying token must be approved before calling this operation for an amount.

If amount is 0n than all user borrow set as repay value.

circle-exclamation

Types

type yAssetParams       is [@layout:comb] record [
  tokenId                 : nat; // yToken token Id
  amount                  : nat; // amount tokens to repay
]
Parameter
Type
Description

tokenId

nat

yToken identifier

amount

nat

amount of underlying tokens to repay

Usage

const tokenId = 0; // or new BigNumber(0) or "0"
const amount = 10_000_000; // amount of underlying tokens.
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.repay(tokenId, amount).toTransferParams(),
      },
    ];
const batch = await tezos.wallet.batch(batchArray);
const operation = await batch.send();
await operation.confirmation();

Errors

circle-info

burnAmount = amount * token.totalSupply / token.liquidity

  • yToken/cant-repay-more-than-borrowed - when user wants to repay more than nedeed.

  • underflow/totalBorrowsF - total borrows less than amount.

  • token/cant-get-contract-token - FA12 token contract address does not contain transfer entrypoint from FA12 interface.

  • token/cant-get-contract-fa2-token - FA2 token contract address does not contain transfer entrypoint from FA2 interface.

  • yToken/exceeds-allowable-redeem - raised when outstanding borrow value greater than max collateral value.

  • ceil-div-error - division of two numbers fails.

  • 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