Deposit

To borrow assets on Tonka, users deposit their tokens as collateral before borrowing. Tonka supports various assets for collateral. After depositing tokens, the user receives tToken, for example, ORDI to TORDI. tToken represents the user's ownership of underlying tokens and interest accrued on a block basis. The quantity of tToken received is based on the current exchange rate and the supplied underlying assets amount. The initial exchange rate between tokens and tTokens is 1:50. Each tToken is convertible into an ever increasing quantity of the underlying token, as interest accrues in the market.

When users wish to redeem their tToken for underlying tokens, they can do so based on the exchange rate.

The exchange rate between a tToken and the underlying asset is calculated as follows:

Here, "total cash" represents the total amount of cash available in the contracts, "total borrows" represents the total amount of borrowed tokens, "total reserves" represents the reserved tokens, and "total supply" represents the total supply of tTokens.

TErc20

function mint(uint mintAmount) returns (uint) msg.sender: The account which shall supply the asset, and own the minted cTokens.mintAmount: The amount of the asset to be supplied, in units of the underlying asset.RETURN: 0 on success. Before supplying an asset, users must first approve the tToken to access their token balance.

Tether

function mint() payable msg.value: The amount of ether to be supplied, in wei.msg.sender: The account which shall supply the ether, and own the minted tTokens.RETURN: No return, reverts on error.

Solidity

// Instantiate an instance of the ERC20 token contract with the specified addressIErc20 token = IErc20(0xToken...); // Instantiate an instance of the tToken contract with the specified addressITErc20 tToken = ITErc20(0xTToken...); // Approve the tToken contract to spend a specific amount of tokens on behalf of the usertoken.approve(address(tToken), mintAmount); // Mint tTokens by depositing a specified amount of tokens into the tToken contracttToken.mint(mintAmount); // Mint tEther tokens, representing the user's ownership of Ether, into the tEther contracttEther.mint();

Web3 1.0

const tEther = TEther.at(0xTEther...);await tEther.methods.mint().send({from: myAccount, value: mintAmount}; const tToken = TErc20.at(0xTToken...);await tToken.methods.mint(mintAmount).send({from: myAccount});

Last updated