Oracle

Oracle

network name:kovan chain id: 42

Interface

pragma solidity ^0.6.7;
interface Oracle {
    function getBandPrice(string symbol) external view returns (uint256);
    function getChainLinkPrice(string symbol) external view returns (uint256);
    function getTokenPrice(string symbol) external view returns (uint256);
    function getCirculSupplys(string symbol) external view returns (uint256);
}

The Oracle contract connects to two oracle platforms, BandProcotal, ChainLink. GetTokenPrice takes the average price of the three platforms in a 1:2 ratio.

Events

const { ethers } = require('ethers');
const provider = new ethers.providers.InfuraProvider('kovan');
let contract = new ethers.Contract(contract_address, abi, provider);

Methods(Read Contract)

1. Get Band Price

function getBandPrice(string sybmol) public view returns (uint256);

Get bandprotocol price

param
type
description

sybmol

string

ERC20 token name,like ETH

return
type
description

_prices

uint256

price

function getChainLinkPrice(string sybmol) public view returns (uint256)

Get ChainLink Price

param
type
description

sybmol

string

ERC20 token name,like ETH

return
type
description

_prices

uint256

price

3. Get Token Price

function getTokenPrice(string sybmol) external view returns (uint256 _price, uint8 _decimals)

Get two oracle prices at the same time and calculate the final price

param
type
description

sybmol

string

ERC20 token name,like ETH

return
type
description

prices

uint256

price

4. Get Circul Supplys

function getCirculSupplys(string sybmol) external view returns (uint256)

**Get the number of token issues, and the number of issues for contract record, which is not real-time **

param
type
description

sybmol

string

ERC20 token name,like ETH

return
type
description

amount

uint256

amount

Methods(Write Contract)

1. Set Weight

function setWeight( uint8 _chainLinkWeight, uint8 _bandWeight, uint8 _uniswapv3Weight) external;

Set oracle weight

param
type
description

_chainLinkWeight

uint8

chainlink weight

_bandWeight

uint8

band protocol weight

_uniswapv3Weight

uint8

uniswapv3 weight

Last updated