UNPKG

@dolomite-exchange/dolomite-margin

Version:

Ethereum Smart Contracts and TypeScript library used for the DolomiteMargin trading protocol

346 lines (345 loc) 8.43 kB
import BigNumber from 'bignumber.js'; import { Tx } from 'web3/eth/types'; import { EventLog, Log, TransactionReceipt } from 'web3/types'; import { OracleSentinel } from './modules/OracleSentinel'; export declare type address = string; export declare type Integer = BigNumber; export declare type Decimal = BigNumber; export declare type BigNumberable = BigNumber | string | number; export declare enum ConfirmationType { Hash = 0, Confirmed = 1, Both = 2, Simulate = 3 } export declare enum BalanceCheckFlag { Both = 0, From = 1, To = 2, None = 3 } export declare const MarketId: { WETH: BigNumber; DAI: BigNumber; USDC: BigNumber; LINK: BigNumber; WBTC: BigNumber; USDT: BigNumber; ETH: BigNumber; }; export declare enum Networks { ARBITRUM_ONE = 42161, BASE = 8453, BERACHAIN = 80094, MANTLE = 5000, POLYGON_ZK_EVM = 1101, X_LAYER = 196 } export declare enum ProxyType { None = "None", Payable = "Payable", Signed = "Sender" } export declare enum SigningMethod { Compatibility = "Compatibility", UnsafeHash = "UnsafeHash", Hash = "Hash", TypedData = "TypedData", MetaMask = "MetaMask", MetaMaskLatest = "MetaMaskLatest", CoinbaseWallet = "CoinbaseWallet" } export interface DolomiteMarginOptions { defaultAccount?: address; confirmationType?: ConfirmationType; defaultConfirmations?: number; autoGasMultiplier?: number; testing?: boolean; defaultGas?: number | string; defaultGasPrice?: number | string; blockGasLimit?: number; accounts?: EthereumAccount[]; apiEndpoint?: string; apiTimeout?: number; ethereumNodeTimeout?: number; wsOrigin?: string; wsEndpoint?: string; wsTimeout?: number; } export interface EthereumAccount { address?: string; privateKey: string; } export interface ContractCallOptions extends Tx { confirmations?: number; confirmationType?: ConfirmationType; autoGasMultiplier?: number; } export interface ContractConstantCallOptions extends Tx { blockNumber?: number; } export interface AccountOperationOptions { proxy?: ProxyType; sendEthTo?: address; } export interface LogParsingOptions { skipOperationLogs?: boolean; skipAdminLogs?: boolean; skipPermissionLogs?: boolean; skipSignedOperationProxyLogs?: boolean; skipExpiryLogs?: boolean; skipEventEmitterRegistry?: boolean; } export interface TxResult { transactionHash?: string; transactionIndex?: number; blockHash?: string; blockNumber?: number; from?: string; to?: string; contractAddress?: string; cumulativeGasUsed?: number; gasUsed?: number; logs?: Log[]; events?: { [eventName: string]: EventLog; }; status?: boolean; confirmation?: Promise<TransactionReceipt>; gasEstimate?: number; gas?: number; } export declare enum AmountDenomination { Actual = 0, Principal = 1, Wei = 0, Par = 1 } export declare enum AmountReference { Delta = 0, Target = 1 } export declare enum ActionType { Deposit = 0, Withdraw = 1, Transfer = 2, Buy = 3, Sell = 4, Trade = 5, Liquidate = 6, Vaporize = 7, Call = 8 } export declare enum AccountStatus { Normal = 0, Liquidating = 1, Vaporizing = 2 } export interface Amount { value: Integer; denomination: AmountDenomination; reference: AmountReference; } export interface AccountAction { primaryAccountOwner: address; primaryAccountId: Integer; } interface ExternalTransfer extends AccountAction { marketId: Integer; amount: Amount; } export interface Deposit extends ExternalTransfer { from: address; } export interface Withdraw extends ExternalTransfer { to: address; } export interface Transfer extends AccountAction { marketId: Integer; toAccountOwner: address; toAccountId: Integer; amount: Amount; } export declare enum OrderType { } export interface Order { type: OrderType | string; exchangeWrapperAddress: string; } export interface Exchange extends AccountAction { takerMarketId: Integer; makerMarketId: Integer; order: Order; amount: Amount; } export interface Buy extends Exchange { } export interface Sell extends Exchange { } export interface Trade extends AccountAction { calculateAmountWithMakerAccount: boolean; autoTrader: address; inputMarketId: Integer; outputMarketId: Integer; otherAccountOwner: address; otherAccountId: Integer; amount: Amount; data: (string | number[])[]; } export interface Liquidate extends AccountAction { liquidMarketId: Integer; payoutMarketId: Integer; liquidAccountOwner: address; liquidAccountId: Integer; amount: Amount; } export interface Vaporize extends AccountAction { vaporMarketId: Integer; payoutMarketId: Integer; vaporAccountOwner: address; vaporAccountId: Integer; amount: Amount; } export interface ExpiryArg { accountOwner: address; accountId: Integer; marketId: Integer; timeDelta: Integer; forceUpdate: boolean; } export interface SetExpiry extends AccountAction { expiryArgs: ExpiryArg[]; } export interface Call extends AccountAction { callee: address; data: (string | number[])[]; } export interface AccountInfo { owner: string; number: number | string; } export interface ActionArgs { actionType: number | string; accountId: number | string; amount: { sign: boolean; denomination: number | string; ref: number | string; value: number | string; }; primaryMarketId: number | string; secondaryMarketId: number | string; otherAddress: string; otherAccountId: number | string; data: (string | number[])[]; } export interface Index { borrow: Decimal; supply: Decimal; lastUpdate: Integer; } export interface TotalPar { borrow: Integer; supply: Integer; } export interface TotalWei { borrow: Integer; supply: Integer; } export interface Market { token: address; totalPar: TotalPar; index: Index; priceOracle: address; interestSetter: address; marginPremium: Decimal; liquidationSpreadPremium: Decimal; maxSupplyWei: Integer; maxBorrowWei: Integer; earningsRateOverride: Decimal; isClosing: boolean; } export interface MarketWithInfo { market: Market; currentIndex: Index; currentPrice: Integer; currentInterestRate: Decimal; } export interface RiskLimits { marginRatioMax: Decimal; liquidationSpreadMax: Decimal; earningsRateMax: Decimal; marginPremiumMax: Decimal; liquidationSpreadPremiumMax: Decimal; minBorrowedValueMax: Integer; interestRateMax: Integer; } export interface RiskParams { marginRatio: Decimal; liquidationSpread: Decimal; earningsRate: Decimal; minBorrowedValue: Integer; accountMaxNumberOfMarketsWithBalances: Integer; oracleSentinel: OracleSentinel; callbackGasLimit: Integer; } export interface Balance { marketId: Integer; tokenAddress: address; par: Integer; wei: Integer; } export interface Values { supply: Integer; borrow: Integer; } export interface BalanceUpdate { deltaWei: Integer; newPar: Integer; } export interface SetApprovalForExpiry extends AccountAction { sender: address; minTimeDelta: Integer; } export declare enum ExpiryCallFunctionType { SetExpiry = 0, SetApproval = 1 } export interface OperationAuthorization { startIndex: Integer; numActions: Integer; expiration: Integer; salt: Integer; sender: address; signer: address; typedSignature: string; } export interface AssetAmount { sign: boolean; denomination: AmountDenomination; ref: AmountReference; value: Integer; } export interface Action { actionType: ActionType; primaryAccountOwner: address; primaryAccountNumber: Integer; secondaryAccountOwner: address; secondaryAccountNumber: Integer; primaryMarketId: Integer; secondaryMarketId: Integer; amount: AssetAmount; otherAddress: address; data: string; } export interface Operation { actions: Action[]; expiration: Integer; salt: Integer; sender: address; signer: address; } export interface SignedOperation extends Operation { typedSignature: string; } export {};