Clear Developer Guide
  • Clear Developer Guide
  • Deploy Contract
    • Quick start
    • Configure Contract
    • Contract Upgrade
    • Contract Address
  • Configure contract parameters
    • Configure Contract Parameters
  • Interact with the contract
    • OPTION
      • Market Maker
      • User
    • NOTE
      • Fund Manager
      • LP User
  • Contract reference
    • Oracle
    • Index Contract
    • Option Contract
    • Market Maker Contract
    • Note Contract
  • APIs
    • Configure
    • Price
    • User
    • Market Maker
    • Index
    • Option parameter configuration
    • Faucet
Powered by GitBook
On this page
  • Index contract
  • ​code​
  • ​abi​
  • Interface
  • Events
  • Methods(Read Contract)
  1. Contract reference

Index Contract

PreviousOracleNextOption Contract

Last updated 3 years ago

Index contract

​​

​​

Interface

pragma solidity ^0.6.7;
interface Index {
  event AddIndex(uint256 _indexNo, bool _isOpen, uint256 _initIndexPrice);
  event UpdateIndex(uint256 _indexNo, bool _isOpen);
  event ExecuteOracleTimeClock(address new_oracle);
  event SetOracleTimeClock(address _newOracleAddr, uint256 oracleUpdateAt);
  function batchIndexPrice(uint256[] calldata _indexNoArr) external view returns (uint256[] memory _prices);
  function getIndexPrice(uint256 _indexNo) public view returns (uint256 _indexPrice);
  function indexLength() external view returns (uint256);
  function getIndex(uint256 _indexNo) external view
    returns (address[] memory tokens,uint8[] memory weights,uint256[] memory circleSupply,uint256 k,bool isOpen);
  function isIndexOpen(uint256 _indexNo) external view returns (bool);
}

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 orcale,and it can be enabled after 7 days.

  • ExecuteOracleTimeClock(address new_oracle) Switch to the new oracle.

Methods(Read Contract)

1. Batch Index Price

function batchIndexPrice(uint256[] calldata _indexNoArr) external view returns (uint256[] memory _prices)

batch get index price

param
type
description

_indexNoArr

uint256[]

indexNo array

return
type
description

_prices

uint256[]

price array

2. Get Index Price

function getIndexPrice(uint256 _indexNo) public view returns (uint256 _indexPrice)

Get index price

return
type
description

_price

uint256

price

3. Index Length

function indexLength() external view returns (uint256)

Get index array length

param
type
description

length

uint256

index length

4. Is Index Open

function isIndexOpen(uint256 _indexNo) external view returns (bool)

isset index is open

param
type
description

indexNo

uint256

indexNo

return
type
description

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

param
type
description

indexNo

uint256

indexNo

return
type
description

tokens

address[]

index tokens

weights

uint256[]

weight of tokens

circleSupply

uint256[]

circly supply of tokens

isOpen

bool

index open status

code
abi