Index Contract
Index Contract
interface
Index price is calculated by the price and liquidity of multiple coins, and the price formula is =(Token0 price* Token0 circle supply + Token1 price* Token 1 circle supply)/K The value of K is determined when the index is generated and remains unchanged after it is generated. After the index is generated, the liquidity of each token remains unchanged, except that the token price fluctuates. The price of a single token is get from the oracle, and different oracle are connected to ensure the accuracy of the price.
events
UpdateIndex(uint256 _indexNo, bool _isOpen)
The index status is on or off.AddIndex(uint256 _indexNo, bool _isOpen,uint256 _initIndexPrice)
add new index.SetOracleTimeClock(address _newOracleAddr, uint256 oracleUpdateAt)
Execute the new oracle,and it can be enabled after 7 days.ExecuteOracleTimeClock(address new_oracle)
Switch to the new oracle.
Methods(Read Contract)
1. batchIndexPrice
function batchIndexPrice(uint256[] calldata _indexNoArr) external view returns (uint256[] memory _prices)
batch get index price
_indexNoArr
uint256[]
indexNo array
_prices
uint256[]
price array
2. getIndexPrice
function getIndexPrice(uint256 _indexNo) public view returns (uint256 _indexPrice)
get index price
_indexNo
uint256
indexNo
_price
uint256
price
3. indexLength
function indexLength() external view returns (uint256)
get index array length
length
uint256
index length
4. isIndexOpen
function isIndexOpen(uint256 _indexNo) external view returns (bool)
isset index is open
indexNo
uint256
indexNo
isOpen
bool
index is open
5. getIndex
function getIndex(uint256 _indexNo) external view returns ( address[] memory tokens, uint8[] memory weights, uint256[] memory circleSupply, uint256 k, bool isOpen )
** get Index tokens and weight,circleSupply **
indexNo
uint256
indexNo
tokens
address[]
index tokens
weights
uint256[]
weight of tokens
circleSupply
uint256[]
circly supply of tokens
isOpen
bool
index open status
Last updated