UNPKG

rubic-sdk

Version:
50 lines 2.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CelerUniswapV2Trade = void 0; const errors_1 = require("../../../../../../../../common/errors"); const evm_web3_pure_1 = require("../../../../../../../../core/blockchain/web3-pure/typed-web3-pure/evm-web3-pure/evm-web3-pure"); const provider_type_enum_1 = require("../../models/provider-type.enum"); class CelerUniswapV2Trade { constructor(uniswapV2Trade) { this.uniswapV2Trade = uniswapV2Trade; this.defaultDeadline = 999999999999999; } getFirstPath() { return this.uniswapV2Trade.wrappedPath.map(token => token.address); } getSecondPath() { return this.uniswapV2Trade.wrappedPath.map(token => evm_web3_pure_1.EvmWeb3Pure.addressToBytes32(token.address)); } async modifyArgumentsForProvider(methodArguments, _walletAddress, swapTokenWithFee = false) { const exactTokensForTokens = true; if (!methodArguments?.[0]) { throw new errors_1.RubicSdkError('Method arguments must not be empty'); } methodArguments[0].push(exactTokensForTokens); methodArguments[0].push(swapTokenWithFee); } getCelerSourceObject() { const path = this.getFirstPath(); const amountOutMinimum = this.uniswapV2Trade.toTokenAmountMin.stringWeiAmount; const dex = this.uniswapV2Trade.contractAddress; return { dex, path, deadline: this.defaultDeadline, amountOutMinimum }; } getCelerDestinationObject(integratorAddress, receiverAddress) { const dex = this.uniswapV2Trade.contractAddress; const deadline = this.defaultDeadline; const amountOutMinimum = this.uniswapV2Trade.toTokenAmountMin.stringWeiAmount; return { dex, nativeOut: this.uniswapV2Trade.to.isNative, receiverEOA: receiverAddress, integrator: integratorAddress, version: provider_type_enum_1.SwapVersion.V2, path: this.getFirstPath(), pathV3: '0x', deadline, amountOutMinimum }; } } exports.CelerUniswapV2Trade = CelerUniswapV2Trade; //# sourceMappingURL=celer-uniswap-v2-trade.js.map