@dolomite-exchange/dolomite-margin
Version:
Ethereum Smart Contracts and TypeScript library used for the DolomiteMargin trading protocol
107 lines (106 loc) • 5.94 kB
TypeScript
import { Contracts } from '../lib/Contracts';
import { AccountInfo, address, ContractCallOptions, ContractConstantCallOptions, Integer, TxResult } from '../types';
export declare enum GenericTraderType {
ExternalLiquidity = 0,
InternalLiquidity = 1,
IsolationModeUnwrapper = 2,
IsolationModeWrapper = 3
}
export interface GenericTraderParam {
traderType: GenericTraderType;
makerAccountIndex: number;
trader: address;
tradeData: string;
}
export interface GenericTransferCollateralParam {
fromAccountNumber: Integer;
toAccountNumber: Integer;
transferAmounts: GenericTransferCollateralAmounts[];
}
export interface GenericTransferCollateralAmounts {
marketId: Integer;
amountWei: Integer;
}
export interface GenericExpiryParam {
marketId: Integer;
expiryTimeDelta: Integer;
}
export declare enum GenericEventEmissionType {
None = 0,
BorrowPosition = 1,
MarginPosition = 2
}
export interface GenericUserConfig {
deadline: number | string;
balanceCheckFlag: number | string;
eventType: GenericEventEmissionType;
}
interface GenericTraderCalldata {
traderType: number | string;
makerAccountIndex: number;
trader: string;
tradeData: (string | number[])[];
}
interface GenericTransferCollateralAmountParamCalldata {
marketId: number | string;
amountWei: number | string;
}
interface GenericTransferCollateralParamCalldata {
fromAccountNumber: number | string;
toAccountNumber: number | string;
transferAmounts: GenericTransferCollateralAmountParamCalldata[];
}
interface GenericExpiryParamCalldata {
marketId: number | string;
expiryTimeDelta: number | string;
}
export declare class GenericTraderProxyV1 {
private contracts;
constructor(contracts: Contracts);
get address(): address;
static genericTraderParamsToCalldata(traderParams: GenericTraderParam[]): GenericTraderCalldata[];
static genericTransferParamToCalldata(transferParam: GenericTransferCollateralParam): GenericTransferCollateralParamCalldata;
static genericExpiryToCalldata(expiryParam: GenericExpiryParam): GenericExpiryParamCalldata;
ownerSetEventEmitterRegistry(eventEmitter: address, options?: ContractCallOptions): Promise<TxResult>;
/**
* Executes a trade using the path of markets provided and the provided traders.
*
* @param tradeAccountNumber The account number `msg.sender` will trade from
* @param marketIdsPath The market IDs that will be traded, in order. The first marketId is the input and the
* last is the output.
* @param inputAmountWei The amount of the input token to be traded, in wei.
* @param minOutputAmountWei The minimum amount of the output token to be received, in wei.
* @param traderParams The traders to be used for each action. The length should be `marketIdsPath.length - 1`.
* @param makerAccounts The accounts that will be used as makers for each trade of type
* `TradeType.InternalLiquidity`. The length should be equal to the number of unique maker
* accounts needed to execute the trade with the provided `tradersPath`.
* @param userConfig The user config to be used for the trade.
* @param options Additional options to be passed through to the web3 call.
*/
swapExactInputForOutput(tradeAccountNumber: Integer, marketIdsPath: Integer[], inputAmountWei: Integer, minOutputAmountWei: Integer, traderParams: GenericTraderParam[], makerAccounts: AccountInfo[], userConfig: GenericUserConfig, options?: ContractCallOptions): Promise<TxResult>;
/**
* Executes a trade using the path of markets provided and the provided traders. After the trades are executed (and
* within the same operation) the transfers and expirations are executed.
*
* @param tradeAccountNumber The account number msg.sender will trade from
* @param marketIdsPath The market IDs that will be traded, in order. The first marketId is the input and
* the last is the output.
* @param inputAmountWei The amount of the input token to be traded, in wei.
* @param minOutputAmountWei The minimum amount of the output token to be received, in wei.
* @param traderParams The traders to be used for each action. The length should be
* `marketIdsPath.length - 1`.
* @param makerAccounts The accounts that will be used as makers for each trade of type
* `TradeType.InternalLiquidity`. The length should be equal to the number of unique
* maker accounts needed to execute the trade with the provided `tradersPath`.
* @param transferCollateralParam The transfers to be executed after the trades. The length of the amounts should be
* non-zero.
* @param expiryParam The expirations to be executed after the trades. Expirations can only be set on
* negative amounts (debt).
* @param userConfig
* @param options Additional options to be passed through to the web3 call.
*/
swapExactInputForOutputAndModifyPosition(tradeAccountNumber: Integer, marketIdsPath: Integer[], inputAmountWei: Integer, minOutputAmountWei: Integer, traderParams: GenericTraderParam[], makerAccounts: AccountInfo[], transferCollateralParam: GenericTransferCollateralParam, expiryParam: GenericExpiryParam, userConfig: GenericUserConfig, options?: ContractCallOptions): Promise<TxResult>;
eventEmitterRegistry(options?: ContractConstantCallOptions): Promise<string>;
isIsolationModeMarket(marketId: Integer, options?: ContractConstantCallOptions): Promise<boolean>;
}
export {};