UNPKG

rubic-sdk

Version:
52 lines 2.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CelerAlgebraTrade = 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"); const algebra_quoter_controller_1 = require("../../../../../../../on-chain/calculation-manager/providers/dexes/common/algebra/algebra-quoter-controller"); const swap_router_contract_data_1 = require("../../../../../../../on-chain/calculation-manager/providers/dexes/polygon/algebra/constants/swap-router-contract-data"); class CelerAlgebraTrade { constructor(algebraTrade) { this.algebraTrade = algebraTrade; this.defaultDeadline = 999999999999999; } getFirstPath() { return algebra_quoter_controller_1.AlgebraQuoterController.getEncodedPath(Array.from(this.algebraTrade.path)); } getSecondPath() { return this.algebraTrade.wrappedPath.map(token => evm_web3_pure_1.EvmWeb3Pure.addressToBytes32(token.address)); } async modifyArgumentsForProvider(methodArguments) { const exactTokensForTokens = true; if (!methodArguments?.[0]) { throw new errors_1.RubicSdkError('Method arguments array must not be empty'); } methodArguments[0].push(exactTokensForTokens); } getCelerSourceObject() { const dex = swap_router_contract_data_1.ALGEBRA_SWAP_ROUTER_CONTRACT_ADDRESS; const path = this.getFirstPath(); const amountOutMinimum = this.algebraTrade.toTokenAmountMin.stringWeiAmount; return { dex, path, deadline: this.defaultDeadline, amountOutMinimum }; } getCelerDestinationObject(integratorAddress, receiverAddress) { const dex = swap_router_contract_data_1.ALGEBRA_SWAP_ROUTER_CONTRACT_ADDRESS; const pathV3 = this.getFirstPath(); const deadline = this.defaultDeadline; const amountOutMinimum = this.algebraTrade.toTokenAmountMin.stringWeiAmount; return { dex, nativeOut: this.algebraTrade.to.isNative, receiverEOA: receiverAddress, integrator: integratorAddress, version: provider_type_enum_1.SwapVersion.V3, path: [evm_web3_pure_1.EvmWeb3Pure.EMPTY_ADDRESS], pathV3, deadline, amountOutMinimum }; } } exports.CelerAlgebraTrade = CelerAlgebraTrade; //# sourceMappingURL=celer-algebra-trade.js.map