UNPKG

rubic-sdk-next

Version:
49 lines 2.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SymbiosisCcrTonTrade = void 0; const cross_chain_trade_type_1 = require("../../../models/cross-chain-trade-type"); const bridge_type_1 = require("../../common/models/bridge-type"); const ton_cross_chain_trade_1 = require("../../common/ton-cross-chain-trade/ton-cross-chain-trade"); const symbiosis_utils_1 = require("../symbiosis-utils"); /** * Calculated Symbiosis cross-chain trade. */ class SymbiosisCcrTonTrade extends ton_cross_chain_trade_1.TonCrossChainTrade { get fromContractAddress() { throw new Error('Not implemented'); } get methodName() { throw new Error('Not implemented'); } constructor(crossChainTrade, providerAddress, routePath, apiQuote, apiResponse) { super(providerAddress, routePath, apiQuote, apiResponse); this.type = cross_chain_trade_type_1.CROSS_CHAIN_TRADE_TYPE.SYMBIOSIS; this.isAggregator = false; this.bridgeType = bridge_type_1.BRIDGE_TYPE.SYMBIOSIS; this.from = crossChainTrade.from; this.to = crossChainTrade.to; this.swappingParams = crossChainTrade.swapParams; this.gasData = crossChainTrade.gasData; this.priceImpact = crossChainTrade.priceImpact; this.toTokenAmountMin = this.to.tokenAmount.multipliedBy(1 - crossChainTrade.slippage); this.feeInfo = crossChainTrade.feeInfo; this.slippage = crossChainTrade.slippage; this.transitAmount = crossChainTrade.transitAmount; this.onChainSubtype = symbiosis_utils_1.SymbiosisUtils.getSubtype(crossChainTrade.tradeType, crossChainTrade.to.blockchain); this.promotions = crossChainTrade?.promotions || []; } getTradeAmountRatio(fromUsd) { return fromUsd.dividedBy(this.to.tokenAmount); } getTradeInfo() { return { estimatedGas: null, feeInfo: this.feeInfo, priceImpact: this.priceImpact ?? null, slippage: this.slippage * 100, routePath: this.routePath }; } } exports.SymbiosisCcrTonTrade = SymbiosisCcrTonTrade; //# sourceMappingURL=symbiosis-ccr-ton-trade.js.map