Home Reference Source
import ConversionRatesContract from 'kyber-fpr-sdk/src/conversion_rates_contract.js'
public class | source

ConversionRatesContract

Extends:

BaseContract → ConversionRatesContract

ConversionRatesContract represents the KyberNetwork conversion rates smart contract.

Constructor Summary

Public Constructor
public

constructor(provider: object, address: string)

Create new ConversionRatesContract instance.

Member Summary

Public Members
public
public

getTokenIndices returns the index of given Token to use in setCompact data call.

public

web3: *

Method Summary

Public Methods
public

async addToken(adminAccount: object, token: string, tokenControlInfo: TokenControlInfo, gasPrice: number): *

Add a ERC20 token and its pricing configurations to reserve contract and enable it for trading.

public

getBuyRates(token: string, qty: number, currentBlockNumber: number): number

Return the buying ETH based rate.

public

getSellRates(token: string, qty: number, currentBlockNumber: number): *

Return the buying ETH based rate.

public

async setImbalanceStepFunction(operatorAddress: object, token: string, buy: StepFunctionDataPoint[], sell: StepFunctionDataPoint[], gasPrice: number): *

Set adjustments for tokens' buy and sell rates depending on the net traded amounts. Only operator can invoke.

public

async setQtyStepFunction(operatorAddress: object, token: string, buy: StepFunctionDataPoint[], sell: StepFunctionDataPoint[], gasPrice: number): *

Set adjustments for tokens' buy and sell rates depending on the size of a buy / sell order. Only operator can invoke.

public

async setRate(operatorAddress: object, rates: RateSetting[], currentBlockNumber: number, gasPrice: number): *

Set the buying rate for given token.

public

async updateTokenControlInfo(adminAccount: object, token: string, tokenControlInfo: TokenControlInfo, gasPrice: number): *

Add a ERC20 token and its pricing configurations to reserve contract and enable it for trading.

Inherited Summary

From class BaseContract
public
public

web3: *

public

async addAlerter(adminAddress: object, address: string, gasPrice: number): *

Add new address to alerters list.

public

async addOperator(adminAddress: object, address: string, gasPrice: number): *

Add given address from operators list.

public

Return the current admin address of contract.

public

async claimAdmin(newAccount: object, gasPrice: number): *

Claim admin privilege.

public

getAlerters(): array

Return alerter addresses of contract.

public

getOperators(): array

Return operator addresses of contract.

public

Return the pending admin address of contract.

public

async removeAlerter(adminAddress: object, address: string, gasPrice: number): *

Remove address from alerters list.

public

async removeOperator(adminAddress: object, address: string, gasPrice: number): *

Remove given address from operators list.

public

async transferAdmin(adminAddress: object, address: string, gasPrice: number): *

transfer admin privilege to given address.

Public Constructors

public constructor(provider: object, address: string) source

Create new ConversionRatesContract instance.

Override:

BaseContract#constructor

Params:

NameTypeAttributeDescription
provider object

Web3 provider

address string

address of smart contract.

Public Members

public contract: * source

Override:

BaseContract#contract

public getTokenIndices(token: string): number: * source

getTokenIndices returns the index of given Token to use in setCompact data call.

Return:

number

index ot compact data

public web3: * source

Override:

BaseContract#web3

Public Methods

public async addToken(adminAccount: object, token: string, tokenControlInfo: TokenControlInfo, gasPrice: number): * source

Add a ERC20 token and its pricing configurations to reserve contract and enable it for trading.

Params:

NameTypeAttributeDescription
adminAccount object

admin account address

token string

ERC20 token address

tokenControlInfo TokenControlInfo

https://developer.kyber.network/docs/VolumeImbalanceRecorder#settokencontrolinfo

gasPrice number

(optional) - the gasPrice desired for the tx

Return:

*

public getBuyRates(token: string, qty: number, currentBlockNumber: number): number source

Return the buying ETH based rate. The rate might be vary with different quantity.

Params:

NameTypeAttributeDescription
token string

token address

qty number

quantity of token

currentBlockNumber number
  • optional
  • default: 0

current block number, default to use latest known block number.

Return:

number

buy rate

public getSellRates(token: string, qty: number, currentBlockNumber: number): * source

Return the buying ETH based rate. The rate might be vary with different quantity.

Params:

NameTypeAttributeDescription
token string

token address

qty number

quantity of token

currentBlockNumber number
  • optional
  • default: 0

current block number known block number.

Return:

*

public async setImbalanceStepFunction(operatorAddress: object, token: string, buy: StepFunctionDataPoint[], sell: StepFunctionDataPoint[], gasPrice: number): * source

Set adjustments for tokens' buy and sell rates depending on the net traded amounts. Only operator can invoke.

Params:

NameTypeAttributeDescription
operatorAddress object

address of the operator account

token string

ERC20 token address

buy StepFunctionDataPoint[]

array of buy step function configurations

sell StepFunctionDataPoint[]

array of sell step function configurations

gasPrice number
  • optional
  • default: undefined

the gasPrice desired for the tx

Return:

*

public async setQtyStepFunction(operatorAddress: object, token: string, buy: StepFunctionDataPoint[], sell: StepFunctionDataPoint[], gasPrice: number): * source

Set adjustments for tokens' buy and sell rates depending on the size of a buy / sell order. Only operator can invoke.

Params:

NameTypeAttributeDescription
operatorAddress object

address of the operator account

token string

ERC20 token address

buy StepFunctionDataPoint[]

array of buy step function configurations

sell StepFunctionDataPoint[]

array of sell step function configurations

gasPrice number

(optional) - the gasPrice desired for the tx

Return:

*

public async setRate(operatorAddress: object, rates: RateSetting[], currentBlockNumber: number, gasPrice: number): * source

Set the buying rate for given token.

Params:

NameTypeAttributeDescription
operatorAddress object

address of the operator account

rates RateSetting[]

token address

currentBlockNumber number
  • optional
  • default: 0

current block number

gasPrice number

(optional) - the gasPrice desired for the tx

Return:

*

public async updateTokenControlInfo(adminAccount: object, token: string, tokenControlInfo: TokenControlInfo, gasPrice: number): * source

Add a ERC20 token and its pricing configurations to reserve contract and enable it for trading.

Params:

NameTypeAttributeDescription
adminAccount object

admin account address

token string

ERC20 token address

tokenControlInfo TokenControlInfo

https://developer.kyber.network/docs/VolumeImbalanceRecorder#settokencontrolinfo

gasPrice number

(optional) - the gasPrice desired for the tx

Return:

*