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

Reserve

Reserve is the wrapper to call all methods related to managing a reserve. It required a provider and the addresses of reserve contract, conversionRates contract and optionally, SanityRates contract

Constructor Summary

Public Constructor
public

constructor(web3: object, addresses: Addresses)

Member Summary

Public Members
public
public

reserve: *

public
public

web3: *

Method Summary

Public Methods
public

addToken(adminccount: object, token: string, tokenControlInfo: TokenControlInfo, gasPrice: number): object

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

public

approveWithdrawAddress(adminAddress: object, tokenAddress: string, withdrawAddress: string, gasPrice: number): object

approve withdraw address for a token on reserve.

public

approvedWithdrawAddresses(address: object, tokenAddress: string): boolean

check for approval status of a token address to a particular address

public

conversionRatesContract return the address of conversion rates of this reserve

public

disableTrade(alerterAddress: object, gasPrice: number): object

disableTrade stop the reserve from trading

public

disapproveWithdrawAddress(adminAddress: object, tokenAddress: string, withdrawAddress: string, gasPrice: number): object

disapprove withdraw address for a token on reserve.

public

enableTrade(adminAddress: object, gasPrice: number): object

enableTrade allow the reserve to continue trading

public

Return balance of given token.

public

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

Return the buying ETH based rate.

public

Return the sanity Rate of a pair of token

public

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

Return the buying ETH based rate.

public

kyberNetwork return the address of kyberNetwork contract of this reserve

public

resonableDiffInBps return the list of reasonableDiffs in basis points (bps)

public

sanityRatesContract return the address of sanity rates of this reserve

public

setContracts(adminAddress: object, network: string, conversion: string, sanity: string, gasPrice: number): object

set Contract addresses for reserve contract.

public

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

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

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

Set the buying rate for given token.

public

setReasonableDiff(adminAddress: object, addresses: string[], diffs: uint[], gasPrice: number): object

setResonableDiff Set reasonable conversion rate difference in percentage (any conversion rate outside of this range is considered unreasonable).

public

setSanityRates(operatorAddress: object, srcs: string[], rates: uint[], gasPrice: number): object

Set Sanity Rate for the sanity Ratescontract

public

setTokenWallet(adminAddress: object, tokenAddress: string, walletAddress: object, gasPrice: number): *

set different token wallet per token.

public

tradeEnabled return true if the reserve is tradeEnabled, false otherwise

public

updateTokenControlInfo(adminccount: object, token: string, tokenControlInfo: TokenControlInfo, gasPrice: number): object

Add tokenControlInfo

public

withdraw(adminAddress: object, tokenAddress: string, amount: object, toAddress: string, gasPrice: number): object

withdraw an amount of token to specified account

Public Constructors

public constructor(web3: object, addresses: Addresses) source

Params:

NameTypeAttributeDescription
web3 object

Web3 instance

addresses Addresses

addresses of the contracts

Public Members

public conversionRates: * source

public reserve: * source

public sanityRates: * source

public web3: * source

Public Methods

public addToken(adminccount: object, token: string, tokenControlInfo: TokenControlInfo, gasPrice: number): object source

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

Params:

NameTypeAttributeDescription
adminccount object

address of admin account

token string

ERC20 token address

tokenControlInfo TokenControlInfo

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

gasPrice number

(optional) - the gasPrice desired for the tx

Return:

object

the tx object of send() command from this contract method

public approveWithdrawAddress(adminAddress: object, tokenAddress: string, withdrawAddress: string, gasPrice: number): object source

approve withdraw address for a token on reserve.

Params:

NameTypeAttributeDescription
adminAddress object

address of admin account.

tokenAddress string

contract address of the modifying token.

withdrawAddress string

address for withdrawal.

gasPrice number
  • optional
  • default: undefined

the gasPrice desired for the tx

Return:

object

the tx object of send() command from this contract method

public approvedWithdrawAddresses(address: object, tokenAddress: string): boolean source

check for approval status of a token address to a particular address

Params:

NameTypeAttributeDescription
address object

address to withdraw the token to

tokenAddress string

address of the token's smart contract. Must be deployed already.

Return:

boolean

true for approved, false otherwise

public conversionRatesContract(): string source

conversionRatesContract return the address of conversion rates of this reserve

Return:

string

address of conversion rates contract

public disableTrade(alerterAddress: object, gasPrice: number): object source

disableTrade stop the reserve from trading

Params:

NameTypeAttributeDescription
alerterAddress object

address of Alerter account

gasPrice number

(optional) - the gasPrice desired for the tx

Return:

object

the tx object of send() command from this contract method

public disapproveWithdrawAddress(adminAddress: object, tokenAddress: string, withdrawAddress: string, gasPrice: number): object source

disapprove withdraw address for a token on reserve.

Params:

NameTypeAttributeDescription
adminAddress object

address of admin account.

tokenAddress string

contract address of the modifying token.

withdrawAddress string

address for withdrawal.

gasPrice number
  • optional
  • default: undefined

the gasPrice desired for the tx

Return:

object

the tx object of send() command from this contract method

public enableTrade(adminAddress: object, gasPrice: number): object source

enableTrade allow the reserve to continue trading

Params:

NameTypeAttributeDescription
adminAddress object

address of Admin account

gasPrice number

(optional) - the gasPrice desired for the tx

Return:

object

the tx object of send() command from this contract method

public getBalance(token: string): number source

Return balance of given token.

Params:

NameTypeAttributeDescription
token string

address of token to check balance.

Return:

number

balance of given token

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 getSanityRate(src: string, dest: string): string source

Return the sanity Rate of a pair of token

Params:

NameTypeAttributeDescription
src string

ERC20 token contract address of source token

dest string

ERC20 token contract address of destination token

Return:

string

the uint rate in strings format.

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 kyberNetwork(): string source

kyberNetwork return the address of kyberNetwork contract of this reserve

Return:

string

address of kyberNetwork contract

public reasonableDiffInBps(address: string): string source

resonableDiffInBps return the list of reasonableDiffs in basis points (bps)

Params:

NameTypeAttributeDescription
address string

ERC20 token contract address to query

Return:

string

the uint reasonable diff in string format.

public sanityRatesContract(): string source

sanityRatesContract return the address of sanity rates of this reserve

Return:

string

address of sanity rates contract

public setContracts(adminAddress: object, network: string, conversion: string, sanity: string, gasPrice: number): object source

set Contract addresses for reserve contract.

Params:

NameTypeAttributeDescription
adminAddress object

address of admin account.

network string

address of kyber network smart contract.

conversion string

address of kyber network smart contract.

sanity string

(optional) - address of sanity rates contract.

gasPrice number
  • optional
  • default: undefined

the gasPrice desired for the tx

Return:

object

the tx object of send() command from this contract method

public 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 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 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 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 setRate(operatorAddress: object, rates: RateSetting[], currentBlockNumber: number, gasPrice: number): * source

Set the buying rate for given token.

Params:

NameTypeAttributeDescription
operatorAddress object

address of 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 setReasonableDiff(adminAddress: object, addresses: string[], diffs: uint[], gasPrice: number): object source

setResonableDiff Set reasonable conversion rate difference in percentage (any conversion rate outside of this range is considered unreasonable).

Params:

NameTypeAttributeDescription
adminAddress object

address of admin account

addresses string[]

list of ERC20 token contract to set

diffs uint[]

list of diffs in bps (1 bps = 0.01%)

gasPrice number

(optional) - the gasPrice desired for the tx

Return:

object

the tx object of send() command from this contract method

public setSanityRates(operatorAddress: object, srcs: string[], rates: uint[], gasPrice: number): object source

Set Sanity Rate for the sanity Ratescontract

Params:

NameTypeAttributeDescription
operatorAddress object

address of operator account

srcs string[]

list of source ERC20 token contract addresses

rates uint[]

list of Rates in ETH weit

gasPrice number

(optional) - the gasPrice desired for the tx

Return:

object

the tx object of send() command from this contract method

public setTokenWallet(adminAddress: object, tokenAddress: string, walletAddress: object, gasPrice: number): * source

set different token wallet per token.

Params:

NameTypeAttributeDescription
adminAddress object

address of admin account.

tokenAddress string

address of the token's smart contract.

walletAddress object

address of wallet in which tokens are present.

gasPrice number

(optional) - the gasPrice desired for the tx

Return:

*

public tradeEnabled(): boolean source

tradeEnabled return true if the reserve is tradeEnabled, false otherwise

Return:

boolean

tradeEnabled status of the reserve

public updateTokenControlInfo(adminccount: object, token: string, tokenControlInfo: TokenControlInfo, gasPrice: number): object source

Add tokenControlInfo

Params:

NameTypeAttributeDescription
adminccount object

address of admin account

token string

ERC20 token address

tokenControlInfo TokenControlInfo

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

gasPrice number

(optional) - the gasPrice desired for the tx

Return:

object

the tx object of send() command from this contract method

public withdraw(adminAddress: object, tokenAddress: string, amount: object, toAddress: string, gasPrice: number): object source

withdraw an amount of token to specified account

Params:

NameTypeAttributeDescription
adminAddress object

address of admin account.

tokenAddress string

address of the token's smart contract. Must be deployed already.

amount object

amount to withdraw (BN|String|int), must be in wei.

toAddress string

address for withdrawal. Must be approved already.

gasPrice number
  • optional
  • default: undefined

the gasPrice desired for the tx

Return:

object

the tx object of send() command from this contract method