yxTokens allow users to earn interests on DAI and USDc via DyDx protocol in an easy and composable way. The contract is used to create ERC20 representing lending positions on DyDx protocol. When you lend assets you will receive yxTokens representing your share of the contract balance in DyDx protocol.
When you redeem funds you will burn yxTokens and unlock your assets + interest accrued.
The yxToken amount when minting is determined by a price taken directly from DyDx (usinggetMarketCurrentIndex
method), the price of each yxToken should always increase because it represents the deposited notional + interest accrued.
You can find the source code here.
CONTRACT
interface yxToken {// Get current yxToken price in underlying (eg. DAI)function price() public view returns (uint256)// Get address of the underlying token usedfunction underlying() public view returns (address)// Get DyDx available liquidity for underlyingfunction availableLiquidity() external view returns (uint256)// Get balance in underlying of an addressfunction balanceInUnderlying(address who) external view returns (uint256)// Lend funds on DyDx and get back yxTokens.// User should approve this contract to spend `underluing` before calling thisfunction mint(uint256 _amount) external returns (uint256 newTokens)// Redeem funds from DyDx by burning yxTokensfunction redeem(uint256 _amount, address _account) external returns (uint256 tokens)}