UNPKG

@dolomite-exchange/dolomite-margin

Version:

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

44 lines 2.94 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LiquidatorProxyV4WithGenericTrader = void 0; const GenericTraderProxyV1_1 = require("./GenericTraderProxyV1"); class LiquidatorProxyV4WithGenericTrader { constructor(contracts) { this.contracts = contracts; } get address() { return this.contracts.liquidatorProxyV4WithGenericTrader.options.address; } // ============ State-Changing Functions ============ /** * Liquidate liquidAccount using solidAccount. This contract and the msg.sender to this contract * must both be operators for the solidAccount. * * @param solidOwner The address of the account that will do the liquidating * @param solidNumber The index of the account that will do the liquidating * @param liquidOwner The address of the account that will be liquidated * @param liquidNumber The index of account that will be liquidated * @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 tradersPath 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 expiry The time at which the position expires, if this liquidation is for closing an expired * position. Else, 0. * @param options Additional options to be passed through to the web3 call. */ async liquidate(solidOwner, solidNumber, liquidOwner, liquidNumber, marketIdsPath, inputAmountWei, minOutputAmountWei, tradersPath, makerAccounts, expiry, options = {}) { return this.contracts.callContractFunction(this.contracts.liquidatorProxyV4WithGenericTrader.methods.liquidate({ owner: solidOwner, number: solidNumber.toFixed(0), }, { owner: liquidOwner, number: liquidNumber.toFixed(0), }, marketIdsPath.map(marketId => marketId.toFixed(0)), inputAmountWei.toFixed(), minOutputAmountWei.toFixed(), GenericTraderProxyV1_1.GenericTraderProxyV1.genericTraderParamsToCalldata(tradersPath), makerAccounts, expiry ? expiry.toFixed(0) : '0'), options); } } exports.LiquidatorProxyV4WithGenericTrader = LiquidatorProxyV4WithGenericTrader; //# sourceMappingURL=LiquidatorProxyV4WithGenericTrader.js.map