@fleupold/dex-contracts
Version:
Contracts for dFusion multi-token batch auction exchange
582 lines (517 loc) • 20 kB
TypeScript
/* Generated by ts-generator ver. 0.0.8 */
/* tslint:disable */
import BN from "bn.js";
import { ContractOptions } from "web3-eth-contract";
import { EventLog } from "web3-core";
import { EventEmitter } from "events";
import {
Callback,
PayableTransactionObject,
NonPayableTransactionObject,
BlockType,
ContractEventLog,
BaseContract
} from "./types";
interface EventOptions {
filter?: object;
fromBlock?: BlockType;
topics?: string[];
}
export type OrderPlacement = ContractEventLog<{
owner: string;
index: string;
buyToken: string;
sellToken: string;
validFrom: string;
validUntil: string;
priceNumerator: string;
priceDenominator: string;
0: string;
1: string;
2: string;
3: string;
4: string;
5: string;
6: string;
7: string;
}>;
export type TokenListing = ContractEventLog<{
token: string;
id: string;
0: string;
1: string;
}>;
export type OrderCancellation = ContractEventLog<{
owner: string;
id: string;
0: string;
1: string;
}>;
export type OrderDeletion = ContractEventLog<{
owner: string;
id: string;
0: string;
1: string;
}>;
export type Trade = ContractEventLog<{
owner: string;
orderId: string;
sellToken: string;
buyToken: string;
executedSellAmount: string;
executedBuyAmount: string;
0: string;
1: string;
2: string;
3: string;
4: string;
5: string;
}>;
export type TradeReversion = ContractEventLog<{
owner: string;
orderId: string;
sellToken: string;
buyToken: string;
executedSellAmount: string;
executedBuyAmount: string;
0: string;
1: string;
2: string;
3: string;
4: string;
5: string;
}>;
export type SolutionSubmission = ContractEventLog<{
submitter: string;
utility: string;
disregardedUtility: string;
burntFees: string;
lastAuctionBurntFees: string;
prices: string[];
tokenIdsForPrice: string[];
0: string;
1: string;
2: string;
3: string;
4: string;
5: string[];
6: string[];
}>;
export type Deposit = ContractEventLog<{
user: string;
token: string;
amount: string;
batchId: string;
0: string;
1: string;
2: string;
3: string;
}>;
export type WithdrawRequest = ContractEventLog<{
user: string;
token: string;
amount: string;
batchId: string;
0: string;
1: string;
2: string;
3: string;
}>;
export type Withdraw = ContractEventLog<{
user: string;
token: string;
amount: string;
0: string;
1: string;
2: string;
}>;
export interface BatchExchange extends BaseContract {
constructor(
jsonInterface: any[],
address?: string,
options?: ContractOptions
): BatchExchange;
clone(): BatchExchange;
methods: {
IMPROVEMENT_DENOMINATOR(): NonPayableTransactionObject<string>;
/**
* used to determine how much time is left in a batch return seconds remaining in current batch
*/
getSecondsRemainingInBatch(): NonPayableTransactionObject<string>;
/**
* Signals and initiates user's intent to withdraw.
* @param amount number of token(s) to be withdrawn * Emits an {WithdrawRequest} event with relevent request information.
* @param token address of token to be withdrawn
*/
requestWithdraw(
token: string,
amount: number | string
): NonPayableTransactionObject<void>;
FEE_FOR_LISTING_TOKEN_IN_OWL(): NonPayableTransactionObject<string>;
/**
* credits user with deposit amount on next epoch (given by getCurrentBatchId)
* @param amount number of token(s) to be credited to user's account * Emits an {Deposit} event with relevent deposit information. * Requirements: - token transfer to contract is successfull
* @param token address of token to be deposited
*/
deposit(
token: string,
amount: number | string
): NonPayableTransactionObject<void>;
AMOUNT_MINIMUM(): NonPayableTransactionObject<string>;
feeToken(): NonPayableTransactionObject<string>;
currentPrices(arg0: number | string): NonPayableTransactionObject<string>;
orders(
arg0: string,
arg1: number | string
): NonPayableTransactionObject<{
buyToken: string;
sellToken: string;
validFrom: string;
validUntil: string;
priceNumerator: string;
priceDenominator: string;
usedAmount: string;
0: string;
1: string;
2: string;
3: string;
4: string;
5: string;
6: string;
}>;
UNLIMITED_ORDER_AMOUNT(): NonPayableTransactionObject<string>;
numTokens(): NonPayableTransactionObject<string>;
lastCreditBatchId(
arg0: string,
arg1: string
): NonPayableTransactionObject<string>;
latestSolution(): NonPayableTransactionObject<{
batchId: string;
solutionSubmitter: string;
feeReward: string;
objectiveValue: string;
0: string;
1: string;
2: string;
3: string;
}>;
/**
* getter function used to display pending deposit
* @param token address of ERC20 token return amount and batchId of deposit's transfer if any (else 0)
* @param user address of user
*/
getPendingDeposit(
user: string,
token: string
): NonPayableTransactionObject<{
0: string;
1: string;
}>;
/**
* getter function used to display pending withdraw
* @param token address of ERC20 token return amount and batchId when withdraw was requested if any (else 0)
* @param user address of user
*/
getPendingWithdraw(
user: string,
token: string
): NonPayableTransactionObject<{
0: string;
1: string;
}>;
/**
* fetches and returns user's balance
* @param token address of ERC20 token return Current `token` balance of `user`'s account
* @param user address of user
*/
getBalance(
user: string,
token: string
): NonPayableTransactionObject<string>;
FEE_DENOMINATOR(): NonPayableTransactionObject<string>;
ENCODED_AUCTION_ELEMENT_WIDTH(): NonPayableTransactionObject<string>;
BATCH_TIME(): NonPayableTransactionObject<string>;
/**
* getter function to determine current auction id. return current batchId
*/
getCurrentBatchId(): NonPayableTransactionObject<string>;
/**
* Signals and initiates user's intent to withdraw.
* @param amount number of token(s) to be withdrawn
* @param batchId state index at which request is to be made. * Emits an {WithdrawRequest} event with relevent request information.
* @param token address of token to be withdrawn
*/
requestFutureWithdraw(
token: string,
amount: number | string,
batchId: number | string
): NonPayableTransactionObject<void>;
/**
* Used to determine if user has a valid pending withdraw request of specific token
* @param token address of ERC20 token return true if `user` has valid withdraw request for `token`, otherwise false
* @param user address of user
*/
hasValidWithdrawRequest(
user: string,
token: string
): NonPayableTransactionObject<boolean>;
MAX_TOKENS(): NonPayableTransactionObject<string>;
/**
* Claims pending withdraw - can be called on behalf of others
* @param token address of token to be withdrawn
* @param user address of user who withdraw is being claimed. * Emits an {Withdraw} event stating that `user` withdrew `amount` of `token` * Requirements: - withdraw was requested in previous epoch - token was received from exchange in current auction batch
*/
withdraw(user: string, token: string): NonPayableTransactionObject<void>;
MAX_TOUCHED_ORDERS(): NonPayableTransactionObject<string>;
/**
* Used to list a new token on the contract: Hence, making it available for exchange in an auction.
* @param token ERC20 token to be listed. * Requirements: - `maxTokens` has not already been reached - `token` has not already been added
*/
addToken(token: string): NonPayableTransactionObject<void>;
/**
* A user facing function used to place limit sell orders in auction with expiry defined by batchId
* @param buyAmount relative minimum amount of requested buy amount
* @param buyToken id of token to be bought
* @param sellAmount maximum amount of sell token to be exchanged
* @param sellToken id of token to be sold
* @param validUntil batchId representing order's expiry
* @returns orderId defined as the index in user's order array * Emits an {OrderPlacement} event with all relevant order details.
*/
placeOrder(
buyToken: number | string,
sellToken: number | string,
validUntil: number | string,
buyAmount: number | string,
sellAmount: number | string
): NonPayableTransactionObject<string>;
/**
* A user facing function used to place limit sell orders in auction with expiry defined by batchId Note that parameters are passed as arrays and the indices correspond to each order.
* @param buyAmounts relative minimum amount of requested buy amounts
* @param buyTokens ids of tokens to be bought
* @param sellAmounts maximum amounts of sell token to be exchanged
* @param sellTokens ids of tokens to be sold
* @param validFroms batchIds representing order's validity start time
* @param validUntils batchIds representing order's expiry
* @returns `orderIds` an array of indices in which `msg.sender`'s orders are included * Emits an {OrderPlacement} event with all relevant order details.
*/
placeValidFromOrders(
buyTokens: (number | string)[],
sellTokens: (number | string)[],
validFroms: (number | string)[],
validUntils: (number | string)[],
buyAmounts: (number | string)[],
sellAmounts: (number | string)[]
): NonPayableTransactionObject<string[]>;
/**
* a user facing function used to cancel orders. If the order is valid for the batch that is currently being solved, it sets order expiry to that batchId. Otherwise it removes it from storage. Can be called multiple times (e.g. to eventually free storage once order is expired).
* @param orderIds referencing the indices of user's orders to be cancelled * Emits an {OrderCancellation} or {OrderDeletion} with sender's address and orderId
*/
cancelOrders(
orderIds: (number | string)[]
): NonPayableTransactionObject<void>;
/**
* A user facing wrapper to cancel and place new orders in the same transaction.
* @param buyAmounts relative minimum amount of requested buy amounts in new orders
* @param buyTokens ids of tokens to be bought in new orders
* @param cancellations indices of orders to be cancelled
* @param sellAmounts maximum amounts of sell token to be exchanged in new orders
* @param sellTokens ids of tokens to be sold in new orders
* @param validFroms batchIds representing order's validity start time in new orders
* @param validUntils batchIds represnnting order's expiry in new orders
* @returns an array of indices in which `msg.sender`'s new orders are included * Emits {OrderCancellation} events for all cancelled orders and {OrderPlacement} events with relevant new order details.
*/
replaceOrders(
cancellations: (number | string)[],
buyTokens: (number | string)[],
sellTokens: (number | string)[],
validFroms: (number | string)[],
validUntils: (number | string)[],
buyAmounts: (number | string)[],
sellAmounts: (number | string)[]
): NonPayableTransactionObject<string[]>;
/**
* a solver facing function called for auction settlement
* @param batchId index of auction solution is referring to
* @param buyVolumes executed buy amounts for each order identified by index of owner-orderId arrays
* @param orderIds array of order indices used in parallel with owners to identify touched order
* @param owners array of addresses corresponding to touched orders
* @param prices list of prices for touched tokens indexed by next parameter
* @param tokenIdsForPrice price[i] is the price for the token with tokenID tokenIdsForPrice[i]
* @returns the computed objective value of the solution * Requirements: - Solutions for this `batchId` are currently being accepted. - Claimed objetive value is a great enough improvement on the current winning solution - Fee Token price is non-zero - `tokenIdsForPrice` is sorted. - Number of touched orders does not exceed `MAX_TOUCHED_ORDERS`. - Each touched order is valid at current `batchId`. - Each touched order's `executedSellAmount` does not exceed its remaining amount. - Limit Price of each touched order is respected. - Solution's objective evaluation must be positive. * Sub Requirements: Those nested within other functions - checkAndOverrideObjectiveValue; Objetive value is a great enough improvement on the current winning solution - checkTokenConservation; for all, non-fee, tokens total amount sold == total amount bought
*/
submitSolution(
batchId: number | string,
claimedObjectiveValue: number | string,
owners: string[],
orderIds: (number | string)[],
buyVolumes: (number | string)[],
prices: (number | string)[],
tokenIdsForPrice: (number | string)[]
): NonPayableTransactionObject<string>;
/**
* View returning ID of listed tokens
* @param addr address of listed token.
* @returns tokenId as stored within the contract.
*/
tokenAddressToIdMap(addr: string): NonPayableTransactionObject<string>;
/**
* View returning address of listed token by ID
* @param id tokenId as stored, via BiMap, within the contract.
* @returns address of (listed) token
*/
tokenIdToAddressMap(
id: number | string
): NonPayableTransactionObject<string>;
/**
* View returning a bool attesting whether token was already added
* @param addr address of the token to be checked
* @returns bool attesting whether token was already added
*/
hasToken(addr: string): NonPayableTransactionObject<boolean>;
/**
* View returning all byte-encoded sell orders for specified user
* @param offset uint determining the starting orderIndex
* @param pageSize uint determining the count of elements to be viewed
* @param user address of user whose orders are being queried
* @returns encoded bytes representing all orders
*/
getEncodedUserOrdersPaginated(
user: string,
offset: number | string,
pageSize: number | string
): NonPayableTransactionObject<string>;
/**
* View returning all byte-encoded users in paginated form
* @param pageSize uint determining the count of users to be returned per page
* @param previousPageUser address of last user received in last pages (address(0) for first page)
* @returns encoded packed bytes of user addresses
*/
getUsersPaginated(
previousPageUser: string,
pageSize: number | string
): NonPayableTransactionObject<string>;
/**
* View returning all byte-encoded sell orders for specified user
* @param user address of user whose orders are being queried
* @returns encoded bytes representing all orders
*/
getEncodedUserOrders(user: string): NonPayableTransactionObject<string>;
/**
* View returning byte-encoded sell orders in paginated form
* @param pageSize uint determining the count of orders to be returned per page
* @param previousPageUser address of last user received in the previous page (address(0) for first page)
* @param previousPageUserOffset the number of orders received for the last user on the previous page (0 for first page).
* @returns encoded bytes representing a page of orders ordered by (user, index)
*/
getEncodedUsersPaginated(
previousPageUser: string,
previousPageUserOffset: number | string,
pageSize: number | string
): NonPayableTransactionObject<string>;
/**
* View returning all byte-encoded sell orders
* @returns encoded bytes representing all orders ordered by (user, index)
*/
getEncodedOrders(): NonPayableTransactionObject<string>;
acceptingSolutions(
batchId: number | string
): NonPayableTransactionObject<boolean>;
/**
* gets the objective value of currently winning solution.
* @returns objective function evaluation of the currently winning solution, or zero if no solution proposed.
*/
getCurrentObjectiveValue(): NonPayableTransactionObject<string>;
};
events: {
OrderPlacement(cb?: Callback<OrderPlacement>): EventEmitter;
OrderPlacement(
options?: EventOptions,
cb?: Callback<OrderPlacement>
): EventEmitter;
TokenListing(cb?: Callback<TokenListing>): EventEmitter;
TokenListing(
options?: EventOptions,
cb?: Callback<TokenListing>
): EventEmitter;
OrderCancellation(cb?: Callback<OrderCancellation>): EventEmitter;
OrderCancellation(
options?: EventOptions,
cb?: Callback<OrderCancellation>
): EventEmitter;
OrderDeletion(cb?: Callback<OrderDeletion>): EventEmitter;
OrderDeletion(
options?: EventOptions,
cb?: Callback<OrderDeletion>
): EventEmitter;
Trade(cb?: Callback<Trade>): EventEmitter;
Trade(options?: EventOptions, cb?: Callback<Trade>): EventEmitter;
TradeReversion(cb?: Callback<TradeReversion>): EventEmitter;
TradeReversion(
options?: EventOptions,
cb?: Callback<TradeReversion>
): EventEmitter;
SolutionSubmission(cb?: Callback<SolutionSubmission>): EventEmitter;
SolutionSubmission(
options?: EventOptions,
cb?: Callback<SolutionSubmission>
): EventEmitter;
Deposit(cb?: Callback<Deposit>): EventEmitter;
Deposit(options?: EventOptions, cb?: Callback<Deposit>): EventEmitter;
WithdrawRequest(cb?: Callback<WithdrawRequest>): EventEmitter;
WithdrawRequest(
options?: EventOptions,
cb?: Callback<WithdrawRequest>
): EventEmitter;
Withdraw(cb?: Callback<Withdraw>): EventEmitter;
Withdraw(options?: EventOptions, cb?: Callback<Withdraw>): EventEmitter;
allEvents(options?: EventOptions, cb?: Callback<EventLog>): EventEmitter;
};
once(event: "OrderPlacement", cb: Callback<OrderPlacement>): void;
once(
event: "OrderPlacement",
options: EventOptions,
cb: Callback<OrderPlacement>
): void;
once(event: "TokenListing", cb: Callback<TokenListing>): void;
once(
event: "TokenListing",
options: EventOptions,
cb: Callback<TokenListing>
): void;
once(event: "OrderCancellation", cb: Callback<OrderCancellation>): void;
once(
event: "OrderCancellation",
options: EventOptions,
cb: Callback<OrderCancellation>
): void;
once(event: "OrderDeletion", cb: Callback<OrderDeletion>): void;
once(
event: "OrderDeletion",
options: EventOptions,
cb: Callback<OrderDeletion>
): void;
once(event: "Trade", cb: Callback<Trade>): void;
once(event: "Trade", options: EventOptions, cb: Callback<Trade>): void;
once(event: "TradeReversion", cb: Callback<TradeReversion>): void;
once(
event: "TradeReversion",
options: EventOptions,
cb: Callback<TradeReversion>
): void;
once(event: "SolutionSubmission", cb: Callback<SolutionSubmission>): void;
once(
event: "SolutionSubmission",
options: EventOptions,
cb: Callback<SolutionSubmission>
): void;
once(event: "Deposit", cb: Callback<Deposit>): void;
once(event: "Deposit", options: EventOptions, cb: Callback<Deposit>): void;
once(event: "WithdrawRequest", cb: Callback<WithdrawRequest>): void;
once(
event: "WithdrawRequest",
options: EventOptions,
cb: Callback<WithdrawRequest>
): void;
once(event: "Withdraw", cb: Callback<Withdraw>): void;
once(event: "Withdraw", options: EventOptions, cb: Callback<Withdraw>): void;
}