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 |
sanityRates: * |
|
| 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 |
getBalance(token: string): number Return balance of given token. |
|
| public |
getBuyRates(token: string, qty: number, currentBlockNumber: number): number Return the buying ETH based rate. |
|
| public |
getSanityRate(src: string, dest: string): string 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 |
reasonableDiffInBps(address: string): string 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 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:
| Name | Type | Attribute | Description |
| 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 |
public approveWithdrawAddress(adminAddress: object, tokenAddress: string, withdrawAddress: string, gasPrice: number): object source
approve withdraw address for a token on reserve.
public approvedWithdrawAddresses(address: object, tokenAddress: string): boolean source
check for approval status of a token address to a particular address
public conversionRatesContract(): string source
conversionRatesContract return the address of conversion rates of this reserve
public disableTrade(alerterAddress: object, gasPrice: number): object source
disableTrade stop the reserve from trading
public disapproveWithdrawAddress(adminAddress: object, tokenAddress: string, withdrawAddress: string, gasPrice: number): object source
disapprove withdraw address for a token on reserve.
public enableTrade(adminAddress: object, gasPrice: number): object source
enableTrade allow the reserve to continue trading
public getBalance(token: string): number source
Return balance of given token.
Params:
| Name | Type | Attribute | Description |
| token | string | address of token to check balance. |
public getBuyRates(token: string, qty: number, currentBlockNumber: number): number source
Return the buying ETH based rate. The rate might be vary with different quantity.
public getSanityRate(src: string, dest: string): string source
Return the sanity Rate of a pair of token
public getSellRates(token: string, qty: number, currentBlockNumber: number): * source
Return the buying ETH based rate. The rate might be vary with different quantity.
Return:
| * |
public kyberNetwork(): string source
kyberNetwork return the address of kyberNetwork contract of this reserve
public reasonableDiffInBps(address: string): string source
resonableDiffInBps return the list of reasonableDiffs in basis points (bps)
Params:
| Name | Type | Attribute | Description |
| address | string | ERC20 token contract address to query |
public sanityRatesContract(): string source
sanityRatesContract return the address of sanity rates of this reserve
public setContracts(adminAddress: object, network: string, conversion: string, sanity: string, gasPrice: number): object source
set Contract addresses for reserve contract.
Params:
| Name | Type | Attribute | Description |
| 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 |
|
the gasPrice desired for the tx |
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:
| Name | Type | Attribute | Description |
| 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:
| Name | Type | Attribute | Description |
| 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:
| Name | Type | Attribute | Description |
| operatorAddress | object | address of operator account |
|
| rates | RateSetting[] | token address |
|
| currentBlockNumber | number |
|
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).
public setSanityRates(operatorAddress: object, srcs: string[], rates: uint[], gasPrice: number): object source
Set Sanity Rate for the sanity Ratescontract
public setTokenWallet(adminAddress: object, tokenAddress: string, walletAddress: object, gasPrice: number): * source
set different token wallet per token.
Return:
| * |
public tradeEnabled(): boolean source
tradeEnabled return true if the reserve is tradeEnabled, false otherwise
public updateTokenControlInfo(adminccount: object, token: string, tokenControlInfo: TokenControlInfo, gasPrice: number): object source
Add tokenControlInfo
Params:
| Name | Type | Attribute | Description |
| 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 |
public withdraw(adminAddress: object, tokenAddress: string, amount: object, toAddress: string, gasPrice: number): object source
withdraw an amount of token to specified account
Params:
| Name | Type | Attribute | Description |
| 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 |
|
the gasPrice desired for the tx |
