UNPKG

rubic-sdk-next

Version:
49 lines 2.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RouterBitcoinCrossChainTrade = void 0; const bitcoin_cross_chain_trade_1 = require("../../common/bitcoin-cross-chain-trade/bitcoin-cross-chain-trade"); const cross_chain_trade_type_1 = require("../../../models/cross-chain-trade-type"); const rubic_proxy_contract_address_1 = require("../../common/constants/rubic-proxy-contract-address"); const bridge_type_1 = require("../../common/models/bridge-type"); class RouterBitcoinCrossChainTrade extends bitcoin_cross_chain_trade_1.BitcoinCrossChainTrade { get fromBlockchain() { return this.from.blockchain; } get fromContractAddress() { return this.useProxy ? rubic_proxy_contract_address_1.rubicProxyContractAddress[this.fromBlockchain].gateway : this.routerQuoteConfig.allowanceTo; } get methodName() { return 'startBridgeTokensViaGenericCrossChain'; } constructor(params) { const { providerAddress, routePath, crossChainTrade, apiQuote, apiResponse } = params; super(providerAddress, routePath, apiQuote, apiResponse); this.type = cross_chain_trade_type_1.CROSS_CHAIN_TRADE_TYPE.ROUTER; this.onChainSubtype = { from: undefined, to: undefined }; this.bridgeType = bridge_type_1.BRIDGE_TYPE.ROUTER; this.isAggregator = false; this.memo = ''; this.needProvidePubKey = false; this.from = crossChainTrade.from; this.to = crossChainTrade.to; this.feeInfo = crossChainTrade.feeInfo; this.gasData = crossChainTrade.gasData; this.priceImpact = crossChainTrade.priceImpact; this.routerQuoteConfig = crossChainTrade.routerQuoteConfig; this.slippage = crossChainTrade.slippage; this.toTokenAmountMin = this.to.tokenAmount.multipliedBy(1 - this.slippage); } getTradeInfo() { return { estimatedGas: this.estimatedGas, feeInfo: this.feeInfo, priceImpact: this.priceImpact, slippage: this.slippage * 100, routePath: this.routePath }; } } exports.RouterBitcoinCrossChainTrade = RouterBitcoinCrossChainTrade; //# sourceMappingURL=router-bitcoin-cross-chain-trade.js.map