yToken contract methods

Core lending contract

Yupana Protocol is a decentralized lending protocol for individuals and protocols to access financial services. The protocol is permissionless, transparent, and non-custodial.

This section describes the methods of the main protocol contract. We call it yToken.

yToken - Core contract that manages all markets and implements FA2 interface for yToken for each collateral provided.

Deployed contracts

Hangzhou

Main contracts

Market contracts

Market 0 (fa12) tokenId = 0n

Market 1 (fa2) tokenId = 1n

Glossary

Underlying asset is the real asset that is provided to the lending protocol.

yToken token is the single token with the specific token id inside of the core Yupana FA2; represents specific underlying asset locked in the protocol.

Collateral is the yToken token that can be used as the collateral to take the loan.

Borrow is the amount of the underlying asset borrowed by the user (loan).

Cash is the amount of the underlying asset present on the contract (not borrowed).

Reserves value is the amount of the underlying asset stored in the protocol.

Collateral Factor is the rate represents by which the borrow limit increases if the yToken is minted.

Close Factor is the max portion of the loan that can be liquidated per single transaction.

Reserve Factor is the rate that represents what part of the interest goes to the protocol reserves.

Liquidation discount is the rate that the liquidator will earn if liquidate the asset.

User experience

All usage examples use JS/TS and Python example calls with Taquito and PyTezos libraries.

As lending protocol

User of protocol allowed to perform actions:

  • mint - add a token as a collateral. It allows you to add a token to our system.

  • redeem - designed to withdraw tokens from the platform.

  • borrow - for borrowing a token. Implemented the logic of freezing collateral tokens when borrowing a token.

  • repay - designed to repay debt.

  • liquidate - allows another user to liquidate someone's debt.

  • enterMarket - allows you to designate that this token will be used as collateral.

  • exitMarket - allows you to indicate that this token is no longer used as collateral.

Before any of the methods would be called, should be executed updateInterest and PriceFeed.getPrice methods in the same block.

More detailed explanation of calling and using methods is described in the linked section.

As FA2 Token

Contract serves FA2 token for each underlying asset by token_id. So, the contract should implement TZIP-12 proposal about FA2 token standard.

FA2 token inteface consist of this entrypoints:

  • transfer - for sending tokens.

  • update_operators -for allowing other user or contract to be "operator" of sender tokens.

  • balance_of - on-chain view to get balance by owner and token_id of a requested token.

  • get_total_supply - on-chain view to get balance of all token supply by token_id.

More about FA2 contract described in corresponding section.

Contract management

yToken contract is managed by admin address.

Admin is responsible for the initial setup of the contract, especially setting lambda functions, that contains the main codebase of the contract.

Also, admin adds new markets, adjust lending factors, pauses borrows, updates meta, etc.

admin abilities are explained in the related section.

Last updated