MarketCapSqrtController.sol
MarketCapSqrtController
MarketCapSqrtController
This contract implements the market cap square root index management strategy.
Categories are periodically sorted, ranking their tokens in descending order by market cap.
Index pools have a defined size which is used to select the top tokens from the pool's category. Every 2 weeks, pools are either re-weighed or re-indexed. They are re-indexed once for every three re-weighs.
Re-indexing involves selecting the top tokens from the pool's category and weighing them by the square root of their market caps. Re-weighing involves weighing the tokens which are already indexed by the pool by the square root of their market caps. When a pool is re-weighed, only the tokens with a desired weight above 0 are included.
constructor
constructor
Deploy the controller and configure the addresses of the related contracts.
Controls
setOwner
setOwner
Set the address of the ndx contract. After deployment this will likely never change, but it is useful to have some small window during which things can be initialized before governance is fully in place.
setDefaultSellerPremium
setDefaultSellerPremium
Sets the default premium rate for token seller contracts.
emergencyExecuteSwapTokensForExactTokens
emergencyExecuteSwapTokensForExactTokens
Emergency function that allows the dao to force a token sale through UniSwap. This exists in case of an emergency which demands immediate removal of a token.
Pool Deployment
prepareIndexPool
prepareIndexPool
Deploys an index pool and a pool initializer. The initializer contract is a pool with specific token balance targets which gives pool tokens in the finished pool to users who provide the underlying tokens needed to initialize it.
finishPreparedIndexPool
finishPreparedIndexPool
Initializes a pool which has been deployed but not initialized and transfers the underlying tokens from the initialization pool to the actual pool.
Pool Management
updateSellerPremiumToDefault
updateSellerPremiumToDefault
Update the premium rate on sellerAddress
with the current default rate.
updateSellerPremiumToDefault
updateSellerPremiumToDefault
Update the premium rate on each unbound token seller in sellerAddresses
with the current default rate.
setSwapFee
setSwapFee
Sets the swap fee on an index pool.
pausePublicTrading
pausePublicTrading
Freezes public trading and liquidity providing on an index pool.
resumePublicTrading
resumePublicTrading
Resumes public trading and liquidity providing on an index pool.
removeTokenFromPool
removeTokenFromPool
Forcibly removes a token from a pool. This should only be used as a last resort if a token is experiencing a sudden crash or major vulnerability. Otherwise, tokens should only be removed gradually through re-indexing events.
Category Management
createCategory
createCategory
Create a new token category.
addToken
addToken
Adds a new token to a category. Note: A token can only be assigned to one category at a time.
addTokens
addTokens
Add tokens to a category.
orderCategoryTokensByMarketCap
orderCategoryTokensByMarketCap
Sorts a category's tokens in descending order by market cap. Verifies the order of the provided array by querying the market caps.
Pool Rebalancing
reindexPool
reindexPool
Re-indexes a pool by setting the underlying assets to the top tokens in its category by market cap.
reweighPool
reweighPool
Reweighs the assets in a pool by market cap and sets the desired new weights, which will be adjusted over time.
setMinimumBalance
setMinimumBalance
Updates the minimum balance of an uninitialized token, which is useful when the token's price on the pool is too low relative to external prices for people to trade it in.
Pool Queries
defaultSellerPremium
defaultSellerPremium
Default premium percent for index pool's unbound token sellers.
computeInitializerAddress
computeInitializerAddress
Compute the create2 address for a pool initializer.
computePoolAddress
computePoolAddress
Compute the create2 address for a pool.
getInitialTokenWeightsAndBalances
getInitialTokenWeightsAndBalances
Queries the top indexSize
tokens in a category from the market _oracle, computes their relative weights by market cap square root and determines the weighted balance of each token to meet a specified total value in weth.
getInitialTokensAndBalances
getInitialTokensAndBalances
Queries the top indexSize
tokens in a category from the market _oracle, computes their relative weights by market cap square root and determines the weighted balance of each token to meet a specified total value.
Market Cap Queries
computeAverageMarketCap
computeAverageMarketCap
Compute the average market cap of a token in WETH. Queries the average amount of ether that the total supply is worth using the recent moving average.
computeAverageMarketCaps
computeAverageMarketCaps
Returns the average market cap for each token.
Category Queries
categoryIndex
categoryIndex
Number of categories in the oracle.
hasCategory
hasCategory
Returns a boolean stating whether a category exists.
getCategoryTokens
getCategoryTokens
Returns the array of tokens in a category.
getCategoryMarketCaps
getCategoryMarketCaps
Returns the market capitalization rates for the tokens in a category.
getTopCategoryTokens
getTopCategoryTokens
Get the top num
tokens in a category. Note: The category must have been sorted by market cap in the last MAX_SORT_DELAY
seconds.
Last updated