UNPKG

rubic-sdk

Version:
39 lines 2.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SymbiosisOnChainTrade = void 0; const errors_1 = require("../../../../../../common/errors"); const symbiosis_api_service_1 = require("../../../../../common/providers/symbiosis/services/symbiosis-api-service"); const symbiosis_parser_1 = require("../../../../../common/providers/symbiosis/services/symbiosis-parser"); const rubic_proxy_contract_address_1 = require("../../../../../cross-chain/calculation-manager/providers/common/constants/rubic-proxy-contract-address"); const on_chain_trade_type_1 = require("../../common/models/on-chain-trade-type"); const aggregator_evm_on_chain_trade_abstract_1 = require("../../common/on-chain-aggregator/aggregator-evm-on-chain-trade-abstract"); class SymbiosisOnChainTrade extends aggregator_evm_on_chain_trade_abstract_1.AggregatorEvmOnChainTrade { get spenderAddress() { return this.useProxy ? rubic_proxy_contract_address_1.rubicProxyContractAddress[this.from.blockchain].gateway : this.providerGateway; } get dexContractAddress() { throw new errors_1.RubicSdkError('Dex address is unknown before swap is started'); } constructor(tradeStruct, providerAddress, providerGateway) { super(tradeStruct, providerAddress); this.type = on_chain_trade_type_1.ON_CHAIN_TRADE_TYPE.SYMBIOSIS_SWAP; this.providerGateway = providerGateway; } //@TODO - CHECK IF we need to pass fromAddress with proxy or remove it after listing async getTransactionConfigAndAmount(options) { const requestBody = await symbiosis_parser_1.SymbiosisParser.getSwapRequestBody(this.from, this.to, { receiverAddress: options.receiverAddress, fromAddress: this.walletAddress, slippage: this.slippageTolerance }); const { tx, tokenAmountOut } = await symbiosis_api_service_1.SymbiosisApiService.getOnChainSwapTx(requestBody); return { tx, toAmount: tokenAmountOut.amount }; } } exports.SymbiosisOnChainTrade = SymbiosisOnChainTrade; //# sourceMappingURL=symbiosis-on-chain-trade.js.map