IdeaTokenExchange
The IdeaTokenExchange handles the exchange (buy and sell) of IdeaTokens using a bonding curve for pricing. NewIdeaTokens are minted on buy and existing IdeaTokens are burned on sell. The exchange also handles the distribution of generated interest aswell as trading and platform fees.
buyTokens: BuysIdeaTokensin exchange forDai. The cost for the purchase is determined using the bonding curveaddress ideaToken: The address of the IdeaToken to be boughtuint amount: The amount of IdeaTokens to buyuint fallbackAmount: The amount ofIdeaTokensto buy if the cost to buyamountexceedscost(slippage). This can happen if the price changes between submitting the transaction and it being executeduint cost: The maximum cost inDaithe buyer is willing to payaddress recipient: The recipient of the boughtIdeaTokens
sellTokens: SellsIdeaTokensin exchange forDai. The price is determined using the bonding curveaddress ideaToken: The address of theIdeaTokento be solduint amount: The amount ofIdeaTokensto selluint minPrice: The minimum price inDaithe seller wants for selling thisamountofIdeaTokens(slippage)address recipient: The recipient of theDai
When tokens are bought the spent Dai are invested into an interest generating protocol using the InterestManager. Currently this is InterestManagerCompound which invests Dai into Compound. Trading and platform fees are also collected according to the parameters set in the IdeaTokenFactory.
When allInterestToPlatform = false then the interest which is generated by an IdeaToken can be withdrawn by the owner of the token using the withdrawTokenInterest method. The token owner must be previously set using setTokenOwner which is admin-only. If the owner is the zero address, i.e. an owner has not been set, a special account called the authorizer is allowed to initially set the token owner address. This allows for automated token owner verification without having to go through the timelock. Once the owner has been set the authorizer is not allowed to change the address anymore. Only the token owner and the admin (with timelock) can change it from now on.
When allInterestToPlatform = true then all interest generated by the tokens in a market can be withdrawn by the platform owner using withdrawPlatformInterest. The platform owner must be previously set using setPlatformOwner which is admin-only. The same logic regarding the authorizer account applies as for withdrawTokenInterest.
The collected platform fee can be withdrawn using withdrawPlatformFee. Again the platform owner must be set using setPlatformOwner.
The collected trading fee can be withdrawn using withdrawTradingFee. This method is not protected and can be called by anyone as it will always send the trading fee to the tradingFeeRecipient which is passed to the contract during initialization.
setTokenFeeKillswitch can be used to disable all trading and platform fee collection for a single IdeaToken.
Last updated
Was this helpful?