Indexed Finance
Search…
PoolInitializer.sol

PoolInitializer

Contract that acquires the initial balances for an index pool.
This uses a short-term UniSwap price oracle to determine the ether value of tokens sent to the contract. When users contribute tokens they are credited for the moving average ether value of said tokens.
When all the tokens needed are acquired, the index pool will be initialized and this contract will receive the initial token supply (100).
Once the contract receives the index pool tokens, users can claim their share of the tokens proportional to their credited contribution value.

Start and Finish

initialize

1
function initialize(
2
address poolAddress,
3
address[] tokens,
4
uint256[] amounts
5
)
Copied!
Sets the initializer's pool address and desired token amount.

finish

1
function finish()
Copied!
Finishes the pool initializer and triggers pool initialization.
Notes
The desired amounts of all tokens must be 0.

Token Claims

claimTokens

1
function claimTokens()
Copied!
Claims the tokens owed to msg.sender based on their proportion of the total credits.

claimTokens

1
function claimTokens(address account)
Copied!
Claims the tokens owed to account based on their proportion of the total credits.

claimTokens

1
function claimTokens(address[] accounts)
Copied!
Claims the tokens owed to account based on their proportion of the total credits.

Token Contribution

contributeTokens

1
function contributeTokens(
2
address token,
3
uint256 amountIn,
4
uint256 minimumCredit
5
) returns (uint256 credit)
Copied!
Contribute up to amountIn of token to the pool for credit.
The caller will be credited for the average weth value of the provided tokens.
Notes
Caller must receive at least minimumCredit to not revert. If amountIn is greater than the desired amount of token, the desired amount will be used instead.

contributeTokens

1
function contributeTokens(
2
address[] tokens,
3
uint256[] amountsIn,
4
uint256 minimumCredit
5
) returns (uint256 credit)
Copied!
Contribute maximum values from amountsIn of the corresponding tokens in tokens to the pool for credit.
The caller will be credited for the average weth value of the provided tokens.
Caller must receive at least minimumCredit to not revert. If any input amount is greater than the desired amount of the corresponding token, the desired amount will be used instead.

Price Updates

updatePrices

1
function updatePrices()
Copied!
Updates the prices of all desired tokens on the price oracle.

Status Queries

isFinished

1
function isFinished() returns (bool)
Copied!
Returns whether the pool has been initialized.

Credit Queries

getTotalCredit

1
function getTotalCredit() returns (uint256)
Copied!
Returns the total value credited for token contributions.

getCreditOf

1
function getCreditOf(address account) returns (uint256)
Copied!
Returns the amount of credit owed to account.

Token Queries

getDesiredTokens

1
function getDesiredTokens() returns (address[] tokens)
Copied!
Returns the array of desired tokens.

getDesiredAmount

1
function getDesiredAmount(address token) returns (uint256)
Copied!
Returns the remaining amount of token the pool needs.

getCreditForTokens

1
function getCreditForTokens(
2
address token,
3
uint256 amountIn
4
) returns (uint144 amountOut)
Copied!
Returns the amount of WETH the contract will credit a user for providing amountIn of token.
Notes
If amountIn is greater than the desired amount of token, this will calculate the output using the desired amount instead of amountIn.
Last modified 1yr ago