Protocol Interaction Practical
mint
Mints fTokens in the market of ID market_id to the caller. The amount depends on the current exchange rate and the underlying_amount specified. Returns:
#Ok: the total balance in underlying (fToken converted to underlying amount) the user has in the market.
#Err: Insufficient Balance, if the user does not have enough underlying in the protocol.
redeem
Converts fTokens in the market of ID market_id to the underlying asset, and stores it in the book. The amount depends on the current exchange rate and the amount specified. Returns:
#Ok: The current amount owned by the user, still in the market, as the underlying asset.
#Err: Unauthorized, if a user tries to redeem while using the fTokens as collateral for a borrow.
declare token as collateral
Locks the value the user has in the market of ID market_id as collateral for a borrow. This allows us to offer users the ability to borrow against certain assets instead of risking their entire portfolio.
Returns:
NULL type
remove token as collateral
Removes the user balance of market_id to be used as collateral. Will fail if user has a borrow open.
Returns:
NULL type
borrow
Note: If you have any amount of lent balance open for this borrow, you will not be able to borrow any additional amount.
Opens a borrow position in market_id of the size amount. Returns:
#Ok: The total borrow balance the user has in market of ID '_token'
repay
Repays a borrow of the size underlying_token_amount in the market _token. Can partially repay an open borrow. Returns:
#Ok: Remaining borrow balance.
#Err: Insufficient Balance, if a user tries to repay with not enough book balance/borrow balance.
liquidate
Liquidates _borrower and gives the collateral to the caller.
#Ok: Remaining fToke balance.
#Err: Insufficient Balance - Token Not Found - Principal Not Found (wrong borrower ID)
redeem_liquidator
Last updated