Methods

Allowance

getAllowance

Get the amount of tokens at params.tokenAddress granted to withdraw by params.spenderAddress from params.ownerAddress.
1
getAllowance(params: {
2
tokenAddress: string;
3
ownerAddress: string;
4
spenderAddress: string;
5
}): Promise<BigNumber>;
Copied!
Arguments
params.tokenAddress ERC20 contract address of the token
params.ownerAddress address of the owner of the tokens - wallet who grants right to withdraw tokens
params.spenderAddress address of the spender of the tokens - wallet who gets right to withdraw tokens
Returns
BigNumber value indicating tokens amount allowed to withdraw

setAllowance

Allow params.spenderAddress to withdraw tokens at params.tokenAddress from params.ownerAddress, multiple times, up to the params.amountInBaseUnits amount.
1
setAllowance(params: {
2
tokenAddress: string;
3
ownerAddress: string;
4
spenderAddress: string;
5
amountInBaseUnits: BigNumber | string;
6
getObject: boolean;
7
txOpts: Tx;
8
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.tokenAddress ERC20 contract address of the token
params.ownerAddress address of the owner of the tokens - wallet who grants right to use tokens
params.spenderAddress address of the spender of the tokens - wallet who gets right to use tokens
params.amountInBaseUnits amount of tokens that are allowed to use
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

setAllowanceUnlimited

Allow params.spenderAddress to withdraw tokens from params.ownerAddress, multiple times, without the limit.
1
setAllowanceUnlimited(params: {
2
tokenAddress: string;
3
ownerAddress: string;
4
spenderAddress: string;
5
getObject: boolean;
6
txOpts: Tx;
7
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.tokenAddress ERC20 contract address of the token
params.ownerAddress address of the owner of the tokens - wallet who grants right to use tokens
params.spenderAddress address of the spender of the tokens - wallet who gets right to use tokens
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

resetAllowance

Disallow params.spenderAddress to withdraw tokens from params.ownerAddress.
1
resetAllowance(params: {
2
tokenAddress: string;
3
ownerAddress: string;
4
spenderAddress: string;
5
getObject: boolean;
6
txOpts: Tx;
7
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.tokenAddress ERC20 contract address of the token
params.ownerAddress address of the owner of the tokens - wallet who grants right to use tokens
params.spenderAddress address of the spender of the tokens - wallet who gets right to use tokens
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

Hash

getLoanOrderHashHex

Calculate Keccak-256 hash of loan order with specified parameters.
1
getLoanOrderHashHex(order: ILoanOrderFillRequest): string;
Copied!
Arguments
order loan order
Returns
Hash value string

getLoanOrderHashAsync

Calculate Keccak-256 hash of order with specified parameters.
1
getLoanOrderHashAsync(order: ILoanOrderFillRequest): Promise<string>;
Copied!
Arguments
order loan order
Returns
Promise for hash value string

Signature

signOrderHashAsync

Sign loan order and returns the signature string.
1
signOrderHashAsync(
2
orderHash: string,
3
signerAddress: string,
4
shouldAddPersonalMessagePrefix: boolean
5
): Promise<string>;
Copied!
Arguments
orderHash loan order hash
signerAddress address of a wallet signing the loan order hash
shouldAddPersonalMessagePrefix indicates whether or not personal message prefix should be added
Returns
Promise for string containing order hash signature

isValidSignature

Check order hash signature validity.
1
static isValidSignature(params: {
2
account: string;
3
orderHash: string;
4
signature: string;
5
}): boolean;
Copied!
Arguments
params.account account who signed the loan order hash
params.orderHash loan order hash
params.signature loan order signature
Returns
boolean value indicating if the signature is valid

isValidSignatureAsync

Check order hash signature validity.
1
isValidSignatureAsync(params: {
2
account: string;
3
orderHash: string;
4
signature: string;
5
}): Promise<boolean>;
Copied!
Arguments
params.account account who signed the loan order hash
params.orderHash loan order hash
params.signature loan order signature
Returns
Promise for boolean value indicating if the signature is valid

Exchange

getTokenList

Provide metadata for all registered tokens.
1
getTokenList(): Promise<ITokenDescription[]>;
Copied!
Arguments
None
Returns
Promise for an array of ITokenDescription

getOracleList

Provide metadata for all registered oracles.
1
getOracleList(): Promise<IOracleDescription[]>;
Copied!
Arguments
None
Returns
Promise for an array of IOracleDescription

isTradeSupported

Check if specified params.oracleAddress supports exchange operation of provided tokens.
1
isTradeSupported(params: {
2
sourceTokenAddress: string;
3
sourceTokenAmount: string;
4
destTokenAddress: string;
5
oracleAddress: string;
6
}): Promise<boolean>;
Copied!
Arguments
sourceTokenAddress address of source token's ERC20 contract
sourceTokenAmount amount of source tokens to exchange
destTokenAddress address of destination token's ERC20 contract
oracleAddress address of the oracle to check tokens pair support
Returns
Promise for boolean value indicating if oracle is able to make exchange operation between tokens

getConversionData

Get terms of exchange operation between tokens in the specific amount using selected oracle.
1
getConversionData(params: {
2
sourceTokenAddress: string;
3
sourceTokenAmount: string;
4
destTokenAddress: string;
5
oracleAddress: string;
6
}): Promise<IConversionData>;
Copied!
Arguments
sourceTokenAddress address of source token's ERC20 contract
sourceTokenAmount amount of source tokens to exchange
destTokenAddress address of destination token's ERC20 contract
oracleAddress address of oracle to check tokens pair support
Returns
Promise for IConversionData value containing exchange rate and available amount of tokens for exchange

Loan orders

getSingleOrder

Get single loan order by it's params.loanOrderHash.
1
getSingleOrder(params: {
2
loanOrderHash: string;
3
}): Promise<ILoanOrderFillable>;
Copied!
Arguments
params.loanOrderHash a unique hash representing the loan order
Returns
Promise for ILoanOrderFillable which represents the current fill state of specified loan order

getOrdersFillable

Get the list of loan orders that are available for taking.
1
getOrdersFillable(params: {
2
start: number;
3
count: number;
4
oracleFilter?: string;
5
}): Promise<ILoanOrderFillable[]>;
Copied!
Arguments
params.start starting number of the loan order in the list of orders that are available for taking
params.count maximum number of loan orders to return
params.oracleFilter oracleAddress to filter list of loan orders
Returns
Promise for an array of ILoanOrderFillable every item of which represents the current fill state of specified loan order

getOrdersForUser

Return the list of loan orders filtered by specified params.loanPartyAddress.
1
getOrdersForUser(params: {
2
loanPartyAddress: string;
3
start: number;
4
count: number;
5
oracleFilter?: string;
6
}): Promise<ILoanOrderFillable[]>;
Copied!
Arguments
params.loanPartyAddress the address of the lender/trader in the loan order
params.start starting number of the loan order in the list of orders
params.count maximum number of loan orders to return
params.oracleFilter oracleAddress to filter list of loan orders
Returns
Promise for an array of ILoanOrderFillable every item of which represents the current fill state of specified loan order

takeLoanOrderAsTrader

Take loan order created and signed by the lender and push it on-chain.
1
takeLoanOrderAsTrader(params: {
2
order: ILoanOrderFillRequest;
3
oracleData: any;
4
collateralTokenAddress: string;
5
loanTokenAmountFilled: BigNumber;
6
tradeTokenToFillAddress: string;
7
withdrawOnOpen: string;
8
getObject: boolean;
9
txOpts: Tx;
10
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.order signed loan order ILoanOrderFillRequest
params.oracleData information specific for selected oracle. for bZxOracle it should be empty string, for augur oracle this should be augur oracle market.
params.collateralTokenAddress desired address of the collateral the trader wants to use
params.loanTokenAmountFilled desired amount of loanToken the trader wants to borrow
params.tradeTokenToFillAddress if "0" then nothing happens, if non-zero, than a trade is made with the oracle once the loan is opened
params.withdrawOnOpen if true, then over-collateralize (initial margin + 100% of loan value), and withdraw the loan token to the trader's wallet if false, that normal margin loan (initial margin collateral only) NOTE: if true, than params.tradeTokenToFillAddress is ignored and assumed to be equal to "0
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

takeLoanOrderAsLender

Take loan order created and signed by the trader and push it on-chain.
1
takeLoanOrderAsLender(params: {
2
order: ILoanOrderFillRequest;
3
oracleData: any;
4
getObject: boolean;
5
txOpts: Tx;
6
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.order signed loan order ILoanOrderFillRequest
params.oracleData information specific for selected oracle. for bZxOracle it should be empty string, for augur oracle this should be augur oracle market.
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

pushLoanOrderOnChain

Push signed loan order on-chain.
1
pushLoanOrderOnChain(params: {
2
order: ILoanOrderFillRequest;
3
oracleData: any;
4
getObject: boolean;
5
txOpts: Tx;
6
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.order signed loan order ILoanOrderFillRequest
params.oracleData information specific for selected oracle. for bZxOracle it should be empty string, for augur oracle this should be augur oracle market.
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

takeLoanOrderOnChainAsTrader

Take loan order created and signed by the lender and already located on-chain (partially filled).
1
takeLoanOrderOnChainAsTrader(params: {
2
loanOrderHash: string;
3
collateralTokenAddress: string;
4
loanTokenAmountFilled: BigNumber;
5
tradeTokenToFillAddress: string;
6
withdrawOnOpen: string;
7
getObject: boolean;
8
txOpts: Tx;
9
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.loanOrderHash a unique hash representing the loan order
params.collateralTokenAddress desired address of the collateral the trader wants to use
params.loanTokenAmountFilled desired amount of loanToken the trader wants to borrow
params.tradeTokenToFillAddress if "0" then nothing happens, if non-zero, than a trade is made with the oracle once the loan is opened
params.withdrawOnOpen if true, then over-collateralize (initial margin + 100% of loan value), and withdraw the loan token to the trader's wallet if false, that normal margin loan (initial margin collateral only) NOTE: if true, than params.tradeTokenToFillAddress is ignored and assumed to be equal to "0
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

takeLoanOrderOnChainAsLender

Take loan order created and signed by the trader and already located on-chain (partially filled).
1
takeLoanOrderOnChainAsLender(params: {
2
loanOrderHash: string;
3
getObject: boolean;
4
txOpts: Tx;
5
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.loanOrderHash a unique hash representing the loan order
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

getSingleLoan

Get the loan order current execution state.
1
getSingleLoan(params: {
2
loanOrderHash: string;
3
trader: string
4
}): Promise<ILoanPositionState>;
Copied!
Arguments
params.loanOrderHash a unique hash representing the loan order
params.trader the address of the lender/trader in the loan order
Returns
Promise for ILoanPositionState which represents the current state of specified loan order

getLoansForLender

Get the list of loan orders with current execution state filtered by lender params.address.
1
getLoansForLender(params: {
2
address: string;
3
count: number;
4
activeOnly: boolean
5
}): Promise<ILoanPositionState[]>;
Copied!
Arguments
params.address the address of the lender in the loan order
params.count maximum number of loan orders to return
params.activeOnly should this function return loan orders in active only (true) or in any state (false)
Returns
Promise for an array of ILoanPositionState every item of which represents the current state of related loan order

getLoansForTrader

Get the list of loan orders with current execution state filtered by trader params.address.
1
getLoansForTrader(params: {
2
address: string;
3
count: number;
4
activeOnly: boolean
5
}): Promise<ILoanPositionState[]>;
Copied!
Arguments
params.address the address of the trader in the loan order
params.count maximum number of loan orders to return
params.activeOnly should this function return loan orders in active only (true) or in any state (false)
Returns
Promise for an array of ILoanPositionState every item of which represents the current state of related loan order

getActiveLoans

Get the paginated list of active loan orders.
1
getActiveLoans(params: {
2
start: number;
3
count: number
4
}): Promise<ILoanOrderActive[]>;
Copied!
Arguments
params.start starting number of the loan order in the list of active orders
params.count maximum number of loan orders to return
Returns
Promise for an array of ILoanOrderActive every item of which contains a unique hash representing the loan order, trader and expiration timestamp of the loan order

getMarginLevels

Get current margin data for the loan order.
1
getMarginLevels(params: {
2
loanOrderHash: string;
3
trader: string;
4
}): Promise<IMarginLevel>;
Copied!
Arguments
params.loanOrderHash a unique hash representing the loan order
params.trader the address of the trader in the loan order
Returns
Promise for IMarginLevel which represents current state of margin of the loan order

getPositionOffset

Get the current profit/loss data of the position.
1
getPositionOffset(params: {
2
loanOrderHash: string;
3
trader: string;
4
}): Promise<IProfitStatus>;
Copied!
Arguments
params.loanOrderHash a unique hash representing the loan order
params.trader the address of the trader in the loan order
Returns
Promise for IProfitStatus which represents current state of profits/losses of the loan order

withdrawPosition

Allows the trader to withdraw any amount in excess of their loan principal. The trader will only be able to withdraw an amount the keeps the loan at or above initial margin.
1
withdrawPosition(params: {
2
loanOrderHash: string;
3
withdrawAmount: string;
4
getObject: boolean;
5
txOpts: Tx;
6
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.loanOrderHash a unique hash representing the loan order
params.withdrawAmount amount of the token to withdraw
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

depositPosition

Allows the trader to return the position/loan token to increase their escrowed balance. This should be used by the trader if they've withdraw an overcollateralized loan. If depositTokenAddress does not match the current position, it will traded with the oracle.
1
depositPosition(params: {
2
loanOrderHash: string;
3
depositTokenAddress: string;
4
depositAmount: string;
5
getObject: boolean;
6
txOpts: Tx;
7
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.loanOrderHash a unique hash representing the loan order
params.depositTokenAddress the address of the token being returned
params.depositAmount amount of the token to deposit
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

getInterest

Get current interest data for the loan order.
1
getInterest(params: {
2
loanOrderHash: string;
3
trader: string;
4
}): Promise<IInterestStatus>;
Copied!
Arguments
params.loanOrderHash a unique hash representing the loan order
params.trader the address of the trader in the loan order
Returns
Promise for IInterestStatus which represents current state of interests of the loan order

payInterest

Pay the lender of a loan the total amount of interest accrued for a loan.
1
payInterest(params: {
2
loanOrderHash: string;
3
trader: string;
4
getObject: boolean;
5
txOpts: Tx;
6
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.loanOrderHash a unique hash representing the loan order
params.trader the address of the trader in the loan order
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

cancelLoanOrder

Cancels remaining (untaken) loan.
1
cancelLoanOrder(params: {
2
order: ILoanOrderFillRequest;
3
oracleData: any;
4
cancelLoanTokenAmount: string;
5
getObject: boolean;
6
txOpts: Tx;
7
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.order signed loan order ILoanOrderFillRequest
params.oracleData information specific for selected oracle. for bZxOracle it should be empty string, for augur oracle this should be augur oracle market.
params.cancelLoanTokenAmount the amount of remaining unloaned token to cancel
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

cancelLoanOrderWithHash

Cancels remaining (untaken) loan.
1
cancelLoanOrderWithHash(params: {
2
loanOrderHash: string;
3
cancelLoanTokenAmount: string;
4
getObject: boolean;
5
txOpts: Tx;
6
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.loanOrderHash a unique hash representing the loan order
params.cancelLoanTokenAmount the amount of remaining unloaned token to cancel
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

orderFilledAmount

Returns amount of tokens filled in the loan order
1
orderFilledAmount(
2
loanOrderHash: string
3
): Promise<string>;
Copied!
Arguments
loanOrderHash the collateral token used by the trader
Returns
Promise for string containing the cancelled amount

orderCancelledAmount

Returns amount of tokens canceled in the loan order
1
orderCancelledAmount(
2
loanOrderHash: string
3
): Promise<string>;
Copied!
Arguments
loanOrderHash the collateral token used by the trader
Returns
Promise for string containing the cancelled amount

closeLoanPartially

Called by the trader to close part of their loan early.
1
closeLoanPartially(params: {
2
loanOrderHash: string;
3
closeAmount: string;
4
getObject: boolean;
5
txOpts: Tx;
6
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.loanOrderHash a unique hash representing the loan order
params.closeAmount the amount of the loan token to return to the lender
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

closeLoan

Called by the trader to close their loan early.
1
closeLoan(params: {
2
loanOrderHash: string;
3
getObject: boolean;
4
txOpts: Tx;
5
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.loanOrderHash a unique hash representing the loan order
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

liquidateLoan

Checks that a position meets the conditions for liquidation, then closes the position and loan.
If called by params.trader himself, calls closeLoan.
1
liquidateLoan(params: {
2
loanOrderHash: string;
3
trader: string;
4
getObject: boolean;
5
txOpts: Tx;
6
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.loanOrderHash a unique hash representing the loan order
params.trader the trader of the position
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

Collateral

getInitialCollateralRequired

Calculates the initial collateral required to open the loan.
1
getInitialCollateralRequired(
2
loanTokenAddress: string,
3
collateralTokenAddress: string,
4
oracleAddress: string,
5
loanTokenAmountFilled: string,
6
initialMarginAmount: string
7
): Promise<string>;
Copied!
Arguments
loanTokenAddress the collateral token used by the trader
collateralTokenAddress desired address of the collateral the trader wants to use
oracleAddress the oracle address specified in the loan order
loanTokenAmountFilled the amount of loan token borrowed
initialMarginAmount the initial margin percentage amount (i.e. 50 == 50%)
Returns
Promise for string containing the minimum collateral requirement to open the loan

changeCollateral

Change the collateral token being used for a loan.
This function will transfer in the initial margin requirement of the new token and the old token will be refunded to the trader.
1
changeCollateral(params: {
2
loanOrderHash: string;
3
collateralTokenFilled: string;
4
getObject: boolean;
5
txOpts: Tx;
6
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.loanOrderHash a unique hash representing the loan order
params.collateralTokenFilled the address of the collateral token used
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

depositCollateral

Increase the collateral for a loan. If depositTokenAddress does not match the current collateral token, it will traded with the oracle.
1
depositCollateral(params: {
2
loanOrderHash: string;
3
depositTokenAddress: string;
4
depositAmount: string;
5
getObject: boolean;
6
txOpts: Tx;
7
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.loanOrderHash a unique hash representing the loan order
params.depositTokenAddress the address of the collateral token used
params.depositAmount the amount of additional collateral token to deposit.
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

withdrawCollateral

Allows the trader to withdraw excess collateral for a loan.
Excess collateral is any amount above the initial margin.
1
withdrawCollateral(params: {
2
loanOrderHash: string;
3
collateralTokenFilled: string;
4
withdrawAmount: string;
5
getObject: boolean;
6
txOpts: Tx;
7
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.loanOrderHash a unique hash representing the loan order
params.collateralTokenFilled the address of the collateral token used
params.withdrawAmount the amount of excess collateral token to withdraw
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

Trade

tradePositionWith0x

Execute a 0x trade using loaned funds.
1
tradePositionWith0x(params: {
2
order0x: IZeroExTradeRequest;
3
orderHashBZx: string;
4
getObject: boolean;
5
txOpts: Tx;
6
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.order0x ZeroEx (c) trade order description
params.orderHashBZx a unique hash representing the loan order
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

tradePositionWith0xV2

Execute a 0x trade using loaned funds on 0x V2 protocol network.
1
tradePositionWith0xV2(params: {
2
order0x: IZeroExV2TradeRequest;
3
orderHashBZx: string;
4
getObject: boolean;
5
txOpts: Tx;
6
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.order0x ZeroEx (c) trade order description
params.orderHashBZx a unique hash representing the loan order
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

tradePositionWithOracle

Execute a market order trade using the oracle contract specified in the loan referenced by params.orderHash.
1
tradePositionWithOracle(params: {
2
orderHash: string;
3
tradeTokenAddress: string;
4
getObject: boolean;
5
txOpts: Tx;
6
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.orderHash a unique hash representing the loan order
params.tradeTokenAddress ERC20 contract address of the token to buy in the trade
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

ETH/WETH

wrapEth

Converts ETH to WETH Tokens.
1
wrapEth(params: {
2
amount: string;
3
getObject: boolean;
4
txOpts: Tx;
5
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.amount amount of ETH to convert to WETH
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

unwrapEth

Converts ETH to WETH Tokens.
1
unwrapEth(params: {
2
amount: string;
3
getObject: boolean;
4
txOpts: Tx;
5
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.amount amount of WETH to convert to ETH
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

Utils

generatePseudoRandomSalt

Static method that generates a pseudo-random UINT256 number.
1
static generatePseudoRandomSalt(): BigNumber;
Copied!
Arguments
None
Returns
BigNumber instance

getBalance

Get balance of specific ERC20 token at params.ownerAddress
1
getBalance(params: { tokenAddress: string; ownerAddress: string }): Promise<BigNumber>;
Copied!
Arguments
tokenAddress address of token ERC20 contract ownerAddress address tokens' owner
Returns
Promise for BigNumber instance

noop

Static method that does nothing. Just an empty function.
1
static noop(): void;
Copied!
Arguments
None
Returns
Nothing

requestFaucetToken

Request test token transfer params.receiverAddress.
1
requestFaucetToken(params: {
2
tokenAddress: string;
3
receiverAddress: string;
4
getObject: boolean;
5
txOpts: Tx;
6
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.tokenAddress an address of token ERC20 contract
params.receiverAddress recipient wallet address
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>

toChecksumAddress

Will convert an upper or lowercase Ethereum address to a checksum address.
1
static toChecksumAddress(address: string): string;
Copied!
Arguments
address an address string
Returns
The checksum address string

transferToken

Transfers specified amount of tokens to to address.
1
transferToken(params: {
2
tokenAddress: string;
3
to: string;
4
amount: BigNumber;
5
getObject: boolean;
6
txOpts: Tx;
7
}): Promise<TransactionReceipt> | TransactionObject<TransactionReceipt>;
Copied!
Arguments
params.tokenAddress an address of token ERC20 contract
params.to recipient wallet address
params.amount amount of tokens to transfer
params.getObject should this function return Promise<TransactionReceipt> (false) or TransactionObject<TransactionReceipt> (true)
params.txOpts web3 transaction options object (from, gasPrice, gas etc.)
Returns
Promise<TransactionReceipt> or TransactionObject<TransactionReceipt>
Last modified 2yr ago