Borrow
Last updated
Last updated
After depositing tokens as collateral, users have ability to borrow other tokens. However, here is an upper limit to the user's borrowing capacity. This limit is calculated using the following formula:
The borrow limit is determined by summing the values of the deposited tokens, multiplied by their corresponding token collateral factors.
Collateral factors range from 0 to 0.9 based on the tokens' price volatility and liquidity status, and the price for calculating Collateral Value comes from exchanges' TWAP(Time-weighted average price).
Besides, each token has a borrow cap, which represents the maximum amount users are allowed to borrow for that specific token. The borrow cap ensures a controlled borrowing environment and is designed to manage risk and maintain protocol stability. The specific borrow cap for each asset may vary based on factors such as price volatility, liquidity status, or governance decisions.
function borrow(uint borrowAmount) returns (uint)
msg.sender:
The account to which borrowed funds shall be transferred.
borrowAmount:
The amount of the underlying asset to be borrowed.
RETURN
: 0 on success.
// Instantiate an instance of the tToken contract with the specified addressITErc20 tToken = ITErc20(0xTToken...);
// Borrow a specified amount of tokens using the tToken contracttToken.borrow(borrowAmount);
const tEther = TEther.at(0xTEther);await tEther.methods.borrow(borrowAmount).send({from: myAccount});
const tToken = TErc20.at(0xTToken...);await tToken.methods.borrow(borrowAmount).send({from: myAccount});