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

repay

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

PreviousredeemNextFA2 Token entrypoints

Last updated 3 years ago

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

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

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

The yToken contract expects that underlying token info of tokenId and all borrowed by user before tokenIds are updated by calling and in the same block before this contract method

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();
token_id = 0
amount = 10_000_000 # amount of underlying tokens.
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.repay(token_id, amount)
    ).autofill().sign()
opg = call.inject()

Errors

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.

โš™๏ธ
๐Ÿ”ต
PriceFeed.getPrice
updateInterest