@fleupold/dex-contracts
Version:
Contracts for dFusion multi-token batch auction exchange
26 lines (25 loc) • 1.67 kB
TypeScript
import BN from "bn.js";
import type Web3 from "web3";
import type { BatchExchangeInstance } from "../types/truffle-typings";
/**
* Retrieves user's token balance as stored in the "balance" entry of the private exchange mapping balanceStates
* Value is directly read from storage relying on Solidity's layout of storage variables
* See https://solidity.readthedocs.io/en/develop/internals/layout_in_storage.html
* @param userAddress - address of the user
* @param tokenAddress - address of the token
* @param batchExchangeAddress - address of the batch exchange
* @param web3Provider - provider of Ethereum JavaScript API
* @returns balance of the token for the given user as stored in balanceStates[userAddress][tokenAddress].balance
*/
export declare function getBalanceState(userAddress: string, tokenAddress: string, batchExchangeAddress: string, web3Provider?: Web3): Promise<BN>;
/**
* Computes amount of a token that a user can immediately withdraw from the exchange
* It not only checks whether a withdrawal is pending, but also considers the balance available to the user,
* pending deposits, and whether there were recent trades that would make withdrawing fail.
* @param userAddress - address of the user
* @param tokenAddress - address of the token
* @param batchExchange - object representing the batch exchange smart contract
* @param web3Provider - provider of Ethereum JavaScript API
* @returns amount of token that the user would receive by calling batchExchange.withdraw
*/
export declare function getWithdrawableAmount(userAddress: string, tokenAddress: string, batchExchange: BatchExchangeInstance, web3Provider?: Web3): Promise<BN>;