@shapeshiftoss/swapper 17.7.2 → 17.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/constants.js +35 -26
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +8 -17
- package/dist/cjs/swappers/AcrossSwapper/utils/acrossService.d.ts +3 -3
- package/dist/cjs/swappers/AcrossSwapper/utils/getTrade.js +2 -1
- package/dist/cjs/swappers/ArbitrumBridgeSwapper/endpoints.d.ts +3 -3
- package/dist/cjs/swappers/ArbitrumBridgeSwapper/getTradeQuote/getTradeQuote.js +2 -2
- package/dist/cjs/swappers/ArbitrumBridgeSwapper/getTradeQuote/getTradeQuote.test.js +12 -4
- package/dist/cjs/swappers/ArbitrumBridgeSwapper/getTradeRate/getTradeRate.js +2 -1
- package/dist/cjs/swappers/ArbitrumBridgeSwapper/utils/fetchArbitrumBridgeSwap.d.ts +2 -2
- package/dist/cjs/swappers/AvnuSwapper/endpoints.js +2 -2
- package/dist/cjs/swappers/AvnuSwapper/utils/constants.d.ts +1 -1
- package/dist/cjs/swappers/BebopSwapper/getBebopSolanaTradeQuote/getBebopSolanaTradeQuote.js +2 -1
- package/dist/cjs/swappers/BebopSwapper/getBebopSolanaTradeRate/getBebopSolanaTradeRate.js +11 -6
- package/dist/cjs/swappers/BebopSwapper/getBebopTradeQuote/getBebopTradeQuote.js +4 -11
- package/dist/cjs/swappers/BebopSwapper/getBebopTradeRate/getBebopTradeRate.js +12 -15
- package/dist/cjs/swappers/BebopSwapper/types.d.ts +65 -79
- package/dist/cjs/swappers/BebopSwapper/utils/bebopService.d.ts +1 -1
- package/dist/cjs/swappers/BebopSwapper/utils/fetchFromBebop.d.ts +2 -18
- package/dist/cjs/swappers/BebopSwapper/utils/fetchFromBebop.js +49 -82
- package/dist/cjs/swappers/BebopSwapper/utils/helpers/helpers.d.ts +1 -2
- package/dist/cjs/swappers/BobGatewaySwapper/BobGatewaySwapper.d.ts +2 -0
- package/dist/cjs/swappers/BobGatewaySwapper/BobGatewaySwapper.js +8 -0
- package/dist/cjs/swappers/BobGatewaySwapper/endpoints.d.ts +2 -0
- package/dist/cjs/swappers/BobGatewaySwapper/endpoints.js +143 -0
- package/dist/cjs/swappers/BobGatewaySwapper/index.d.ts +3 -0
- package/dist/cjs/swappers/BobGatewaySwapper/index.js +22 -0
- package/dist/cjs/swappers/BobGatewaySwapper/swapperApi/getTradeQuote.d.ts +3 -0
- package/dist/cjs/swappers/BobGatewaySwapper/swapperApi/getTradeQuote.js +90 -0
- package/dist/cjs/swappers/BobGatewaySwapper/swapperApi/getTradeRate.d.ts +3 -0
- package/dist/cjs/swappers/BobGatewaySwapper/swapperApi/getTradeRate.js +73 -0
- package/dist/cjs/swappers/BobGatewaySwapper/types.d.ts +20 -0
- package/dist/cjs/swappers/BobGatewaySwapper/types.js +2 -0
- package/dist/cjs/swappers/BobGatewaySwapper/utils/constants.d.ts +13 -0
- package/dist/cjs/swappers/BobGatewaySwapper/utils/constants.js +31 -0
- package/dist/cjs/swappers/BobGatewaySwapper/utils/helpers.d.ts +49 -0
- package/dist/cjs/swappers/BobGatewaySwapper/utils/helpers.js +314 -0
- package/dist/cjs/swappers/ButterSwap/swapperApi/checkTradeStatus.test.js +9 -19
- package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeQuote.js +1 -1
- package/dist/cjs/swappers/ButterSwap/test-data/routeQuote.js +4 -4
- package/dist/cjs/swappers/ButterSwap/utils/butterSwapHistoryService.d.ts +3 -3
- package/dist/cjs/swappers/ButterSwap/utils/butterSwapService.d.ts +3 -3
- package/dist/cjs/swappers/ButterSwap/xhr.js +4 -4
- package/dist/cjs/swappers/CetusSwapper/utils/constants.d.ts +1 -1
- package/dist/cjs/swappers/ChainflipSwapper/ChainflipSwapper.js +1 -0
- package/dist/cjs/swappers/ChainflipSwapper/constants.d.ts +1 -1
- package/dist/cjs/swappers/ChainflipSwapper/constants.js +3 -0
- package/dist/cjs/swappers/ChainflipSwapper/endpoints.js +20 -0
- package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasQuoteBoostQuote.js +5 -4
- package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasQuoteEstimatedDurationsSeconds.js +5 -4
- package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasQuoteQuote.js +5 -5
- package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasQuoteQuoteFee.js +5 -5
- package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasStatusChunkInfo.js +5 -4
- package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasStatusDca.js +5 -4
- package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasStatusEgress.js +5 -4
- package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasStatusSwap.js +5 -4
- package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasSwapDepositAddress.js +5 -4
- package/dist/cjs/swappers/ChainflipSwapper/types.d.ts +2 -1
- package/dist/cjs/swappers/ChainflipSwapper/types.js +1 -0
- package/dist/cjs/swappers/ChainflipSwapper/utils/chainflipService.d.ts +3 -3
- package/dist/cjs/swappers/ChainflipSwapper/utils/getQuoteOrRate.js +25 -5
- package/dist/cjs/swappers/ChainflipSwapper/utils/getUtxoTxFees.d.ts +1 -1
- package/dist/cjs/swappers/ChainflipSwapper/utils/helpers.d.ts +2 -3
- package/dist/cjs/swappers/ChainflipSwapper/utils/helpers.js +2 -1
- package/dist/cjs/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.js +3 -2
- package/dist/cjs/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.test.js +8 -8
- package/dist/cjs/swappers/CowSwapper/getCowSwapTradeRate/getCowSwapTradeRate.js +3 -2
- package/dist/cjs/swappers/CowSwapper/utils/cowService.d.ts +3 -3
- package/dist/cjs/swappers/CowSwapper/utils/helpers/helpers.test.js +3 -3
- package/dist/cjs/swappers/DebridgeSwapper/utils/debridgeService.d.ts +3 -3
- package/dist/cjs/swappers/DebridgeSwapper/utils/getTrade.js +2 -1
- package/dist/cjs/swappers/NearIntentsSwapper/constants.d.ts +1 -0
- package/dist/cjs/swappers/NearIntentsSwapper/constants.js +2 -1
- package/dist/cjs/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.js +5 -2
- package/dist/cjs/swappers/NearIntentsSwapper/utils/helpers/helpers.d.ts +2 -2
- package/dist/cjs/swappers/NearIntentsSwapper/utils/helpers/helpers.js +5 -1
- package/dist/cjs/swappers/PortalsSwapper/getPortalsTradeQuote/getPortalsTradeQuote.js +2 -1
- package/dist/cjs/swappers/PortalsSwapper/getPortalsTradeRate/getPortalsTradeRate.js +4 -3
- package/dist/cjs/swappers/PortalsSwapper/utils/helpers.d.ts +1 -1
- package/dist/cjs/swappers/RelaySwapper/constant.d.ts +1 -39
- package/dist/cjs/swappers/RelaySwapper/constant.js +1 -1
- package/dist/cjs/swappers/RelaySwapper/utils/fetchRelayTrade.d.ts +1 -1
- package/dist/cjs/swappers/RelaySwapper/utils/getRelayPsbtRelayer.js +7 -17
- package/dist/cjs/swappers/RelaySwapper/utils/getTrade.js +2 -1
- package/dist/cjs/swappers/RelaySwapper/utils/relayService.d.ts +3 -3
- package/dist/cjs/swappers/SunioSwapper/endpoints.js +19 -36
- package/dist/cjs/swappers/SunioSwapper/utils/buildSwapContractCall.d.ts +6 -0
- package/dist/cjs/swappers/SunioSwapper/utils/buildSwapContractCall.js +33 -0
- package/dist/cjs/swappers/SunioSwapper/utils/buildSwapRouteParameters.js +6 -6
- package/dist/cjs/swappers/SunioSwapper/utils/constants.d.ts +2 -0
- package/dist/cjs/swappers/SunioSwapper/utils/constants.js +7 -1
- package/dist/cjs/swappers/SunioSwapper/utils/estimateSunioNetworkFee.d.ts +12 -0
- package/dist/cjs/swappers/SunioSwapper/utils/estimateSunioNetworkFee.js +78 -0
- package/dist/cjs/swappers/SunioSwapper/utils/getQuoteOrRate.js +18 -75
- package/dist/cjs/swappers/SunioSwapper/utils/getSunioTransactionFees.d.ts +2 -0
- package/dist/cjs/swappers/SunioSwapper/utils/getSunioTransactionFees.js +36 -0
- package/dist/cjs/swappers/SunioSwapper/utils/helpers/helpers.d.ts +1 -2
- package/dist/cjs/swappers/SunioSwapper/utils/sunioService.d.ts +3 -3
- package/dist/cjs/swappers/ThorchainSwapper/getTradeQuote/getTradeQuote.test.js +10 -0
- package/dist/cjs/swappers/ThorchainSwapper/utils/getL1ToLongtailQuote.js +8 -18
- package/dist/cjs/swappers/ThorchainSwapper/utils/getL1ToLongtailRate.js +8 -18
- package/dist/cjs/swappers/ThorchainSwapper/utils/getLongtailQuote.js +1 -1
- package/dist/cjs/swappers/ThorchainSwapper/utils/getLongtailRate.js +1 -1
- package/dist/cjs/swappers/ThorchainSwapper/utils/longTailHelpers.js +2 -2
- package/dist/cjs/swappers/ZrxSwapper/getZrxTradeQuote/getZrxTradeQuote.js +2 -1
- package/dist/cjs/swappers/ZrxSwapper/getZrxTradeQuote/getZrxTradeQuote.test.js +7 -17
- package/dist/cjs/swappers/ZrxSwapper/getZrxTradeRate/getZrxTradeRate.js +2 -1
- package/dist/cjs/swappers/ZrxSwapper/utils/fetchFromZrx.js +2 -2
- package/dist/cjs/swappers/ZrxSwapper/utils/helpers/helpers.d.ts +3 -2
- package/dist/cjs/swappers/ZrxSwapper/utils/zrxService.d.ts +1 -1
- package/dist/cjs/swappers/utils/helpers/helpers.js +1 -0
- package/dist/cjs/swappers/utils/test-data/cryptoMarketDataById.d.ts +1 -35
- package/dist/cjs/thorchain-utils/checkTradeStatus.js +8 -1
- package/dist/cjs/thorchain-utils/cosmossdk/getThorTxData.d.ts +12 -0
- package/dist/cjs/thorchain-utils/cosmossdk/getThorTxData.js +19 -0
- package/dist/cjs/thorchain-utils/cosmossdk/index.d.ts +1 -0
- package/dist/cjs/thorchain-utils/cosmossdk/index.js +1 -0
- package/dist/cjs/thorchain-utils/getCallDataFromQuote.d.ts +1 -1
- package/dist/cjs/thorchain-utils/getL1RateOrQuote.js +51 -33
- package/dist/cjs/thorchain-utils/getQuote.js +27 -29
- package/dist/cjs/thorchain-utils/index.d.ts +1 -0
- package/dist/cjs/thorchain-utils/index.js +19 -18
- package/dist/cjs/thorchain-utils/parseBuyTxHash.d.ts +1 -1
- package/dist/cjs/thorchain-utils/service.d.ts +3 -3
- package/dist/cjs/thorchain-utils/tron/getTronTransactionFees.js +8 -5
- package/dist/cjs/thorchain-utils/types.d.ts +1 -1
- package/dist/cjs/tron-utils/getTronTransactionFees.d.ts +1 -1
- package/dist/cjs/types.d.ts +16 -3
- package/dist/cjs/types.js +5 -0
- package/dist/cjs/utils/tenderly/storageSlots.js +20 -20
- package/dist/cjs/utils.d.ts +4 -4
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/constants.js +9 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/swappers/AcrossSwapper/utils/acrossService.d.ts +3 -3
- package/dist/esm/swappers/ArbitrumBridgeSwapper/endpoints.d.ts +3 -3
- package/dist/esm/swappers/ArbitrumBridgeSwapper/getTradeQuote/getTradeQuote.test.js +12 -4
- package/dist/esm/swappers/ArbitrumBridgeSwapper/utils/fetchArbitrumBridgeSwap.d.ts +2 -2
- package/dist/esm/swappers/AvnuSwapper/endpoints.js +2 -2
- package/dist/esm/swappers/AvnuSwapper/utils/constants.d.ts +1 -1
- package/dist/esm/swappers/BebopSwapper/getBebopSolanaTradeRate/getBebopSolanaTradeRate.js +10 -6
- package/dist/esm/swappers/BebopSwapper/getBebopTradeQuote/getBebopTradeQuote.js +2 -10
- package/dist/esm/swappers/BebopSwapper/getBebopTradeRate/getBebopTradeRate.js +11 -15
- package/dist/esm/swappers/BebopSwapper/types.d.ts +65 -79
- package/dist/esm/swappers/BebopSwapper/utils/bebopService.d.ts +1 -1
- package/dist/esm/swappers/BebopSwapper/utils/fetchFromBebop.d.ts +2 -18
- package/dist/esm/swappers/BebopSwapper/utils/fetchFromBebop.js +45 -76
- package/dist/esm/swappers/BebopSwapper/utils/helpers/helpers.d.ts +1 -2
- package/dist/esm/swappers/BobGatewaySwapper/BobGatewaySwapper.d.ts +2 -0
- package/dist/esm/swappers/BobGatewaySwapper/BobGatewaySwapper.js +5 -0
- package/dist/esm/swappers/BobGatewaySwapper/endpoints.d.ts +2 -0
- package/dist/esm/swappers/BobGatewaySwapper/endpoints.js +140 -0
- package/dist/esm/swappers/BobGatewaySwapper/index.d.ts +3 -0
- package/dist/esm/swappers/BobGatewaySwapper/index.js +3 -0
- package/dist/esm/swappers/BobGatewaySwapper/swapperApi/getTradeQuote.d.ts +3 -0
- package/dist/esm/swappers/BobGatewaySwapper/swapperApi/getTradeQuote.js +86 -0
- package/dist/esm/swappers/BobGatewaySwapper/swapperApi/getTradeRate.d.ts +3 -0
- package/dist/esm/swappers/BobGatewaySwapper/swapperApi/getTradeRate.js +69 -0
- package/dist/esm/swappers/BobGatewaySwapper/types.d.ts +20 -0
- package/dist/esm/swappers/BobGatewaySwapper/utils/constants.d.ts +13 -0
- package/dist/esm/swappers/BobGatewaySwapper/utils/constants.js +27 -0
- package/dist/esm/swappers/BobGatewaySwapper/utils/helpers.d.ts +49 -0
- package/dist/esm/swappers/BobGatewaySwapper/utils/helpers.js +299 -0
- package/dist/esm/swappers/ButterSwap/swapperApi/checkTradeStatus.test.js +2 -2
- package/dist/esm/swappers/ButterSwap/swapperApi/getTradeQuote.js +1 -1
- package/dist/esm/swappers/ButterSwap/test-data/routeQuote.js +4 -4
- package/dist/esm/swappers/ButterSwap/utils/butterSwapHistoryService.d.ts +3 -3
- package/dist/esm/swappers/ButterSwap/utils/butterSwapService.d.ts +3 -3
- package/dist/esm/swappers/CetusSwapper/utils/constants.d.ts +1 -1
- package/dist/esm/swappers/ChainflipSwapper/ChainflipSwapper.js +2 -1
- package/dist/esm/swappers/ChainflipSwapper/constants.d.ts +1 -1
- package/dist/esm/swappers/ChainflipSwapper/constants.js +4 -1
- package/dist/esm/swappers/ChainflipSwapper/endpoints.js +20 -0
- package/dist/esm/swappers/ChainflipSwapper/types.d.ts +2 -1
- package/dist/esm/swappers/ChainflipSwapper/types.js +1 -0
- package/dist/esm/swappers/ChainflipSwapper/utils/chainflipService.d.ts +3 -3
- package/dist/esm/swappers/ChainflipSwapper/utils/getQuoteOrRate.js +26 -6
- package/dist/esm/swappers/ChainflipSwapper/utils/getUtxoTxFees.d.ts +1 -1
- package/dist/esm/swappers/ChainflipSwapper/utils/helpers.d.ts +2 -3
- package/dist/esm/swappers/ChainflipSwapper/utils/helpers.js +2 -1
- package/dist/esm/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.js +1 -1
- package/dist/esm/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.test.js +8 -8
- package/dist/esm/swappers/CowSwapper/getCowSwapTradeRate/getCowSwapTradeRate.js +1 -1
- package/dist/esm/swappers/CowSwapper/utils/cowService.d.ts +3 -3
- package/dist/esm/swappers/CowSwapper/utils/helpers/helpers.test.js +3 -3
- package/dist/esm/swappers/DebridgeSwapper/utils/debridgeService.d.ts +3 -3
- package/dist/esm/swappers/NearIntentsSwapper/constants.d.ts +1 -0
- package/dist/esm/swappers/NearIntentsSwapper/constants.js +1 -0
- package/dist/esm/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.js +7 -4
- package/dist/esm/swappers/NearIntentsSwapper/utils/helpers/helpers.d.ts +2 -2
- package/dist/esm/swappers/NearIntentsSwapper/utils/helpers/helpers.js +5 -1
- package/dist/esm/swappers/PortalsSwapper/getPortalsTradeRate/getPortalsTradeRate.js +2 -2
- package/dist/esm/swappers/PortalsSwapper/utils/helpers.d.ts +1 -1
- package/dist/esm/swappers/RelaySwapper/constant.d.ts +1 -39
- package/dist/esm/swappers/RelaySwapper/constant.js +1 -1
- package/dist/esm/swappers/RelaySwapper/utils/fetchRelayTrade.d.ts +1 -1
- package/dist/esm/swappers/RelaySwapper/utils/relayService.d.ts +3 -3
- package/dist/esm/swappers/SunioSwapper/endpoints.js +19 -36
- package/dist/esm/swappers/SunioSwapper/utils/buildSwapContractCall.d.ts +6 -0
- package/dist/esm/swappers/SunioSwapper/utils/buildSwapContractCall.js +29 -0
- package/dist/esm/swappers/SunioSwapper/utils/buildSwapRouteParameters.js +6 -6
- package/dist/esm/swappers/SunioSwapper/utils/constants.d.ts +2 -0
- package/dist/esm/swappers/SunioSwapper/utils/constants.js +6 -0
- package/dist/esm/swappers/SunioSwapper/utils/estimateSunioNetworkFee.d.ts +12 -0
- package/dist/esm/swappers/SunioSwapper/utils/estimateSunioNetworkFee.js +74 -0
- package/dist/esm/swappers/SunioSwapper/utils/getQuoteOrRate.js +16 -74
- package/dist/esm/swappers/SunioSwapper/utils/getSunioTransactionFees.d.ts +2 -0
- package/dist/esm/swappers/SunioSwapper/utils/getSunioTransactionFees.js +32 -0
- package/dist/esm/swappers/SunioSwapper/utils/helpers/helpers.d.ts +1 -2
- package/dist/esm/swappers/SunioSwapper/utils/sunioService.d.ts +3 -3
- package/dist/esm/swappers/ThorchainSwapper/getTradeQuote/getTradeQuote.test.js +10 -0
- package/dist/esm/swappers/ThorchainSwapper/utils/getL1ToLongtailQuote.js +1 -1
- package/dist/esm/swappers/ThorchainSwapper/utils/getL1ToLongtailRate.js +1 -1
- package/dist/esm/swappers/ThorchainSwapper/utils/getLongtailQuote.js +1 -1
- package/dist/esm/swappers/ThorchainSwapper/utils/getLongtailRate.js +1 -1
- package/dist/esm/swappers/ZrxSwapper/utils/fetchFromZrx.js +2 -2
- package/dist/esm/swappers/ZrxSwapper/utils/helpers/helpers.d.ts +3 -2
- package/dist/esm/swappers/ZrxSwapper/utils/zrxService.d.ts +1 -1
- package/dist/esm/swappers/utils/helpers/helpers.js +2 -1
- package/dist/esm/swappers/utils/test-data/cryptoMarketDataById.d.ts +1 -35
- package/dist/esm/thorchain-utils/checkTradeStatus.js +8 -1
- package/dist/esm/thorchain-utils/cosmossdk/getThorTxData.d.ts +12 -0
- package/dist/esm/thorchain-utils/cosmossdk/getThorTxData.js +15 -0
- package/dist/esm/thorchain-utils/cosmossdk/index.d.ts +1 -0
- package/dist/esm/thorchain-utils/cosmossdk/index.js +1 -0
- package/dist/esm/thorchain-utils/getCallDataFromQuote.d.ts +1 -1
- package/dist/esm/thorchain-utils/getL1RateOrQuote.js +44 -16
- package/dist/esm/thorchain-utils/getQuote.js +27 -29
- package/dist/esm/thorchain-utils/index.d.ts +1 -0
- package/dist/esm/thorchain-utils/index.js +11 -1
- package/dist/esm/thorchain-utils/parseBuyTxHash.d.ts +1 -1
- package/dist/esm/thorchain-utils/service.d.ts +3 -3
- package/dist/esm/thorchain-utils/tron/getTronTransactionFees.js +8 -5
- package/dist/esm/thorchain-utils/types.d.ts +1 -1
- package/dist/esm/tron-utils/getTronTransactionFees.d.ts +1 -1
- package/dist/esm/types.d.ts +16 -3
- package/dist/esm/types.js +5 -0
- package/dist/esm/utils/tenderly/storageSlots.js +20 -20
- package/dist/esm/utils.d.ts +4 -4
- package/package.json +8 -7
- package/dist/cjs/swappers/SunioSwapper/utils/buildSwapTransaction.d.ts +0 -11
- package/dist/cjs/swappers/SunioSwapper/utils/buildSwapTransaction.js +0 -57
- package/dist/cjs/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.d.ts +0 -11
- package/dist/cjs/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.js +0 -40
- package/dist/cjs/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.test.js +0 -94
- package/dist/esm/swappers/SunioSwapper/utils/buildSwapTransaction.d.ts +0 -11
- package/dist/esm/swappers/SunioSwapper/utils/buildSwapTransaction.js +0 -53
- package/dist/esm/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.d.ts +0 -11
- package/dist/esm/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.js +0 -34
- package/dist/esm/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.test.d.ts +0 -1
- package/dist/esm/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.test.js +0 -92
- /package/dist/{cjs/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.test.d.ts → esm/swappers/BobGatewaySwapper/types.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Asset } from '@shapeshiftoss/types';
|
|
2
2
|
import type { SwapperConfig, SwapperName } from '../types';
|
|
3
3
|
import type { ThorEvmTradeQuote } from './types';
|
|
4
|
-
export declare const getCallDataFromQuote: ({ tradeType, data, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, memo: tcMemo, expiry, config, longtailData, slippageTolerancePercentageDecimal, vault, swapperName, }: Pick<ThorEvmTradeQuote, "
|
|
4
|
+
export declare const getCallDataFromQuote: ({ tradeType, data, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, memo: tcMemo, expiry, config, longtailData, slippageTolerancePercentageDecimal, vault, swapperName, }: Pick<ThorEvmTradeQuote, "data" | "slippageTolerancePercentageDecimal" | "memo" | "expiry" | "tradeType" | "aggregator" | "vault" | "longtailData"> & {
|
|
5
5
|
sellAmountIncludingProtocolFeesCryptoBaseUnit: string;
|
|
6
6
|
config: SwapperConfig;
|
|
7
7
|
sellAsset: Asset;
|
|
@@ -15,23 +15,13 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) ||
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
35
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
26
|
exports.getL1RateOrQuote = void 0;
|
|
37
27
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
@@ -43,8 +33,10 @@ const tronweb_1 = require("tronweb");
|
|
|
43
33
|
const uuid_1 = require("uuid");
|
|
44
34
|
const index_1 = require("../index");
|
|
45
35
|
const affiliateFee_1 = require("../swappers/utils/affiliateFee");
|
|
36
|
+
const helpers_1 = require("../swappers/utils/helpers/helpers");
|
|
46
37
|
const types_1 = require("../types");
|
|
47
38
|
const utils_2 = require("../utils");
|
|
39
|
+
const cosmossdk = __importStar(require("./cosmossdk"));
|
|
48
40
|
const evm = __importStar(require("./evm"));
|
|
49
41
|
const getLimitWithManualSlippage_1 = require("./getLimitWithManualSlippage/getLimitWithManualSlippage");
|
|
50
42
|
const getQuote_1 = require("./getQuote");
|
|
@@ -138,7 +130,7 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
138
130
|
const protocolFees = {};
|
|
139
131
|
if (!buyAssetTradeFeeBuyAssetCryptoBaseUnit.isZero()) {
|
|
140
132
|
protocolFees[buyAsset.assetId] = {
|
|
141
|
-
amountCryptoBaseUnit: buyAssetTradeFeeBuyAssetCryptoBaseUnit.
|
|
133
|
+
amountCryptoBaseUnit: buyAssetTradeFeeBuyAssetCryptoBaseUnit.toFixed(0),
|
|
142
134
|
requiresBalance: false,
|
|
143
135
|
asset: buyAsset,
|
|
144
136
|
};
|
|
@@ -164,12 +156,12 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
164
156
|
affilate: (0, index_2.getAffiliate)(swapperName),
|
|
165
157
|
});
|
|
166
158
|
};
|
|
167
|
-
const makeThorTradeRateOrQuote = ({ route, memo, allowanceContract, feeData, data, router, vault, }) => {
|
|
159
|
+
const makeThorTradeRateOrQuote = ({ route, memo, allowanceContract, feeData, data, router, vault, thorchainTransactionMetadata, }) => {
|
|
168
160
|
const buyAmountAfterFeesCryptoBaseUnit = (0, utils_1.convertPrecision)({
|
|
169
161
|
value: route.expectedAmountOutThorBaseUnit,
|
|
170
162
|
inputExponent: buyAssetNativePrecision,
|
|
171
163
|
outputExponent: buyAsset.precision,
|
|
172
|
-
}).toFixed();
|
|
164
|
+
}).toFixed(0);
|
|
173
165
|
const rate = (0, utils_2.getInputOutputRate)({
|
|
174
166
|
sellAmountCryptoBaseUnit,
|
|
175
167
|
buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
|
|
@@ -218,6 +210,7 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
218
210
|
thorchainSpecific: {
|
|
219
211
|
maxStreamingQuantity: route.quote.max_streaming_quantity,
|
|
220
212
|
},
|
|
213
|
+
thorchainTransactionMetadata,
|
|
221
214
|
},
|
|
222
215
|
],
|
|
223
216
|
};
|
|
@@ -249,6 +242,11 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
249
242
|
data,
|
|
250
243
|
router,
|
|
251
244
|
vault,
|
|
245
|
+
thorchainTransactionMetadata: {
|
|
246
|
+
to: router,
|
|
247
|
+
data,
|
|
248
|
+
value: (0, helpers_1.isNativeEvmAsset)(sellAsset.assetId) ? sellAmountCryptoBaseUnit : '0',
|
|
249
|
+
},
|
|
252
250
|
feeData: {
|
|
253
251
|
protocolFees: getProtocolFees(route.quote),
|
|
254
252
|
networkFeeCryptoBaseUnit,
|
|
@@ -294,8 +292,13 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
294
292
|
})();
|
|
295
293
|
return makeThorTradeRateOrQuote({
|
|
296
294
|
route,
|
|
297
|
-
allowanceContract: '0x0',
|
|
295
|
+
allowanceContract: '0x0',
|
|
298
296
|
memo,
|
|
297
|
+
thorchainTransactionMetadata: {
|
|
298
|
+
to: vault,
|
|
299
|
+
memo,
|
|
300
|
+
value: sellAmountCryptoBaseUnit,
|
|
301
|
+
},
|
|
299
302
|
feeData,
|
|
300
303
|
});
|
|
301
304
|
}));
|
|
@@ -311,11 +314,18 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
311
314
|
case caip_1.CHAIN_NAMESPACE.CosmosSdk: {
|
|
312
315
|
const cosmosChainAdapter = assertGetCosmosSdkChainAdapter(sellAsset.chainId);
|
|
313
316
|
const { fast } = await cosmosChainAdapter.getFeeData({});
|
|
317
|
+
const { vault } = await cosmossdk.getThorTxData({ sellAsset, config, swapperName });
|
|
314
318
|
return (0, monads_1.Ok)(perRouteValues.map((route) => {
|
|
319
|
+
const memo = getMemo(route);
|
|
315
320
|
return makeThorTradeRateOrQuote({
|
|
316
321
|
route,
|
|
317
|
-
memo
|
|
318
|
-
allowanceContract: '0x0',
|
|
322
|
+
memo,
|
|
323
|
+
allowanceContract: '0x0',
|
|
324
|
+
thorchainTransactionMetadata: {
|
|
325
|
+
to: vault,
|
|
326
|
+
memo,
|
|
327
|
+
value: sellAmountCryptoBaseUnit,
|
|
328
|
+
},
|
|
319
329
|
feeData: {
|
|
320
330
|
networkFeeCryptoBaseUnit: fast.txFee,
|
|
321
331
|
protocolFees: getProtocolFees(route.quote),
|
|
@@ -329,13 +339,13 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
329
339
|
case caip_1.CHAIN_NAMESPACE.Solana: {
|
|
330
340
|
const adapter = assertGetSolanaChainAdapter(sellAsset.chainId);
|
|
331
341
|
const sendAddress = input.sendAddress;
|
|
342
|
+
const { vault } = await solana.getThorTxData({ sellAsset, config, swapperName });
|
|
332
343
|
const maybeRoutes = await Promise.allSettled(perRouteValues.map(async (route) => {
|
|
333
344
|
const memo = getMemo(route);
|
|
334
345
|
const protocolFees = getProtocolFees(route.quote);
|
|
335
346
|
const feeData = await (async () => {
|
|
336
347
|
if (!sendAddress)
|
|
337
348
|
return { networkFeeCryptoBaseUnit: undefined, protocolFees };
|
|
338
|
-
const { vault } = await solana.getThorTxData({ sellAsset, config, swapperName });
|
|
339
349
|
const memoInstruction = new web3_js_1.TransactionInstruction({
|
|
340
350
|
keys: [],
|
|
341
351
|
programId: new web3_js_1.PublicKey(SOLANA_MEMO_PROGRAM_ID),
|
|
@@ -361,6 +371,11 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
361
371
|
route,
|
|
362
372
|
allowanceContract: '0x0',
|
|
363
373
|
memo,
|
|
374
|
+
thorchainTransactionMetadata: {
|
|
375
|
+
to: vault,
|
|
376
|
+
memo,
|
|
377
|
+
value: sellAmountCryptoBaseUnit,
|
|
378
|
+
},
|
|
364
379
|
feeData,
|
|
365
380
|
});
|
|
366
381
|
}));
|
|
@@ -374,23 +389,21 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
374
389
|
return (0, monads_1.Ok)(routes);
|
|
375
390
|
}
|
|
376
391
|
case caip_1.CHAIN_NAMESPACE.Tron: {
|
|
392
|
+
const { vault } = await tron.getThorTxData({ sellAsset, config, swapperName });
|
|
377
393
|
const maybeRoutes = await Promise.allSettled(perRouteValues.map(async (route) => {
|
|
378
394
|
const memo = getMemo(route);
|
|
379
395
|
let networkFeeCryptoBaseUnit = undefined;
|
|
380
396
|
// Calculate fees for rates when we have a receive address (wallet connected)
|
|
381
|
-
if (input.quoteOrRate === 'rate' && input.receiveAddress) {
|
|
397
|
+
if (input.quoteOrRate === 'rate' && input.receiveAddress && vault) {
|
|
382
398
|
try {
|
|
383
399
|
const { sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit } = input;
|
|
384
400
|
const contractAddress = (0, utils_1.contractAddressOrUndefined)(sellAsset.assetId);
|
|
385
|
-
// Get vault address
|
|
386
|
-
const { vault } = await tron.getThorTxData({
|
|
387
|
-
sellAsset,
|
|
388
|
-
config,
|
|
389
|
-
swapperName,
|
|
390
|
-
});
|
|
391
401
|
// Estimate fees using the receive address for accurate energy calculation
|
|
392
402
|
const tronWeb = new tronweb_1.TronWeb({
|
|
393
403
|
fullHost: deps.config.VITE_TRON_NODE_URL,
|
|
404
|
+
headers: deps.config.VITE_TRON_GRID_API_KEY
|
|
405
|
+
? { 'TRON-PRO-API-KEY': deps.config.VITE_TRON_GRID_API_KEY }
|
|
406
|
+
: {},
|
|
394
407
|
});
|
|
395
408
|
const params = await tronWeb.trx.getChainParameters();
|
|
396
409
|
const bandwidthPrice = params.find(p => p.key === 'getTransactionFee')?.value ?? 1000;
|
|
@@ -400,7 +413,7 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
400
413
|
// TRC20: Estimate energy with actual recipient
|
|
401
414
|
try {
|
|
402
415
|
const result = await tronWeb.transactionBuilder.triggerConstantContract(contractAddress, 'transfer(address,uint256)', {}, [
|
|
403
|
-
{ type: 'address', value: vault },
|
|
416
|
+
{ type: 'address', value: vault },
|
|
404
417
|
{
|
|
405
418
|
type: 'uint256',
|
|
406
419
|
value: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
@@ -434,8 +447,13 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
434
447
|
// For quotes, fees will be calculated in getTronTransactionFees when executing
|
|
435
448
|
return Promise.resolve(makeThorTradeRateOrQuote({
|
|
436
449
|
route,
|
|
437
|
-
allowanceContract: '0x0',
|
|
450
|
+
allowanceContract: '0x0',
|
|
438
451
|
memo,
|
|
452
|
+
thorchainTransactionMetadata: {
|
|
453
|
+
to: vault,
|
|
454
|
+
memo,
|
|
455
|
+
value: sellAmountCryptoBaseUnit,
|
|
456
|
+
},
|
|
439
457
|
feeData: {
|
|
440
458
|
networkFeeCryptoBaseUnit,
|
|
441
459
|
protocolFees: getProtocolFees(route.quote),
|
|
@@ -10,19 +10,10 @@ const monads_1 = require("@sniptt/monads");
|
|
|
10
10
|
const qs_1 = __importDefault(require("qs"));
|
|
11
11
|
const types_1 = require("../types");
|
|
12
12
|
const utils_2 = require("../utils");
|
|
13
|
-
const getThresholdedAffiliateBps_1 = require("./getThresholdedAffiliateBps/getThresholdedAffiliateBps");
|
|
14
13
|
const index_1 = require("./index");
|
|
15
14
|
const service_1 = require("./service");
|
|
16
15
|
const getQuote = async (input, deps) => {
|
|
17
16
|
const { buyAssetId, receiveAddress, sellAsset, sellAmountCryptoBaseUnit, streaming, streamingInterval, affiliateBps, swapperName, } = input;
|
|
18
|
-
// don't apply an affiliate fee if it's below the outbound fee for the inbound pool
|
|
19
|
-
const thresholdedAffiliateBps = await (0, getThresholdedAffiliateBps_1.getThresholdedAffiliateBps)({
|
|
20
|
-
sellAsset,
|
|
21
|
-
sellAmountCryptoBaseUnit,
|
|
22
|
-
affiliateBps,
|
|
23
|
-
config: deps.config,
|
|
24
|
-
swapperName,
|
|
25
|
-
});
|
|
26
17
|
const buyPoolId = (0, index_1.getPoolAssetId)({ assetId: buyAssetId, swapperName });
|
|
27
18
|
const sellPoolId = (0, index_1.getPoolAssetId)({ assetId: sellAsset.assetId, swapperName });
|
|
28
19
|
const sellAmountCryptoPrecision = utils_1.BigAmount.fromBaseUnit({
|
|
@@ -43,34 +34,41 @@ const getQuote = async (input, deps) => {
|
|
|
43
34
|
from_asset: sellPoolId,
|
|
44
35
|
to_asset: buyPoolId,
|
|
45
36
|
destination: parsedReceiveAddress,
|
|
46
|
-
affiliate_bps:
|
|
37
|
+
affiliate_bps: affiliateBps,
|
|
47
38
|
affiliate: (0, index_1.getAffiliate)(swapperName),
|
|
48
39
|
...(streaming && { streaming_interval: streamingInterval }),
|
|
49
40
|
});
|
|
50
41
|
const daemonUrl = (0, index_1.getDaemonUrl)(deps.config, swapperName);
|
|
51
42
|
const res = await service_1.thorService.get(`${daemonUrl}/quote/swap?${queryString}`);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
43
|
+
// Thornode returns errors as `{ error: string }` in both the 2xx body and the 4xx body.
|
|
44
|
+
// On 4xx axios rejects, so the body lands on `cause.response.data` instead of in the success data.
|
|
45
|
+
const errorMessage = (() => {
|
|
46
|
+
if (res.isErr()) {
|
|
47
|
+
const cause = res.unwrapErr().cause;
|
|
48
|
+
return cause?.response?.data?.error;
|
|
49
|
+
}
|
|
50
|
+
const { data } = res.unwrap();
|
|
51
|
+
return 'error' in data ? data.error : undefined;
|
|
52
|
+
})();
|
|
53
|
+
if (errorMessage) {
|
|
54
|
+
if (/not enough fee/i.test(errorMessage) ||
|
|
55
|
+
/not enough to pay transaction fee/i.test(errorMessage)) {
|
|
56
|
+
return (0, monads_1.Err)((0, utils_2.createTradeAmountTooSmallErr)());
|
|
57
|
+
}
|
|
58
|
+
if (/trading is halted/i.test(errorMessage)) {
|
|
59
|
+
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
60
|
+
message: `[getQuote]: Trading is halted, cannot process swap`,
|
|
61
|
+
code: types_1.TradeQuoteError.TradingHalted,
|
|
62
|
+
details: { sellAssetId: sellAsset.assetId, buyAssetId },
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
69
65
|
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
70
|
-
message:
|
|
66
|
+
message: errorMessage,
|
|
71
67
|
code: types_1.TradeQuoteError.UnknownError,
|
|
72
68
|
}));
|
|
73
69
|
}
|
|
74
|
-
|
|
70
|
+
if (res.isErr())
|
|
71
|
+
return (0, monads_1.Err)(res.unwrapErr());
|
|
72
|
+
return (0, monads_1.Ok)(res.unwrap().data);
|
|
75
73
|
};
|
|
76
74
|
exports.getQuote = getQuote;
|
|
@@ -23,6 +23,7 @@ export declare const getDaemonUrl: (config: SwapperConfig, swapperName: SwapperN
|
|
|
23
23
|
export declare const getMidgardUrl: (config: SwapperConfig, swapperName: SwapperName) => string;
|
|
24
24
|
export declare const isNativeAsset: (assetId: AssetId, swapperName: SwapperName) => boolean;
|
|
25
25
|
export declare const getNativePrecision: (assetId: AssetId, swapperName: SwapperName) => 8 | 10;
|
|
26
|
+
export declare const getSwapperNativeAssetId: (swapperName: SwapperName) => AssetId;
|
|
26
27
|
export declare const getNativeFee: (swapperName: SwapperName) => "2000000" | "2000000000";
|
|
27
28
|
export declare const getAffiliate: (swapperName: SwapperName) => "ss" | "ssmaya";
|
|
28
29
|
export declare const getPoolAssetId: ({ assetId, swapperName, }: {
|
|
@@ -15,28 +15,18 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) ||
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
35
25
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
27
|
};
|
|
38
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.getSwapSource = exports.getPoolAssetId = exports.getAffiliate = exports.getNativeFee = exports.getNativePrecision = exports.isNativeAsset = exports.getMidgardUrl = exports.getDaemonUrl = exports.isThorTradeQuote = exports.isThorTradeRate = exports.getChainIdBySwapper = exports.utxo = exports.tron = exports.solana = exports.evm = exports.cosmossdk = void 0;
|
|
29
|
+
exports.getSwapSource = exports.getPoolAssetId = exports.getAffiliate = exports.getNativeFee = exports.getSwapperNativeAssetId = exports.getNativePrecision = exports.isNativeAsset = exports.getMidgardUrl = exports.getDaemonUrl = exports.isThorTradeQuote = exports.isThorTradeRate = exports.getChainIdBySwapper = exports.utxo = exports.tron = exports.solana = exports.evm = exports.cosmossdk = void 0;
|
|
40
30
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
41
31
|
const adapters = __importStar(require("@shapeshiftoss/chain-adapters"));
|
|
42
32
|
const MayachainSwapper_1 = require("../swappers/MayachainSwapper");
|
|
@@ -115,6 +105,17 @@ const getNativePrecision = (assetId, swapperName) => {
|
|
|
115
105
|
}
|
|
116
106
|
};
|
|
117
107
|
exports.getNativePrecision = getNativePrecision;
|
|
108
|
+
const getSwapperNativeAssetId = (swapperName) => {
|
|
109
|
+
switch (swapperName) {
|
|
110
|
+
case types_1.SwapperName.Thorchain:
|
|
111
|
+
return caip_1.thorchainAssetId;
|
|
112
|
+
case types_1.SwapperName.Mayachain:
|
|
113
|
+
return caip_1.mayachainAssetId;
|
|
114
|
+
default:
|
|
115
|
+
throw new Error(`Invalid swapper: ${swapperName}`);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
exports.getSwapperNativeAssetId = getSwapperNativeAssetId;
|
|
118
119
|
const getNativeFee = (swapperName) => {
|
|
119
120
|
switch (swapperName) {
|
|
120
121
|
case types_1.SwapperName.Thorchain:
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ThorNodeTxSchema } from './types';
|
|
2
|
-
export declare const parseThorBuyTxHash: (sellTxId: string, latestOutTx: ThorNodeTxSchema | undefined, nativeChain:
|
|
2
|
+
export declare const parseThorBuyTxHash: (sellTxId: string, latestOutTx: ThorNodeTxSchema | undefined, nativeChain: 'THOR' | 'MAYA') => string | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const thorService: {
|
|
2
|
-
get: <T = any>(url: string, config?: import("axios").AxiosRequestConfig<any>) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T>, import("..").SwapErrorRight>>;
|
|
3
|
-
post: <
|
|
4
|
-
delete: <
|
|
2
|
+
get: <T = any>(url: string, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T, any, {}>, import("..").SwapErrorRight>>;
|
|
3
|
+
post: <T_1 = any>(url: string, data: any, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T_1, any, {}>, import("..").SwapErrorRight>>;
|
|
4
|
+
delete: <T_2 = any>(url: string, data: any, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T_2, any, {}>, import("..").SwapErrorRight>>;
|
|
5
5
|
};
|
|
@@ -5,9 +5,9 @@ const utils_1 = require("@shapeshiftoss/utils");
|
|
|
5
5
|
const tronweb_1 = require("tronweb");
|
|
6
6
|
const utils_2 = require("../../utils");
|
|
7
7
|
const getThorTxData_1 = require("./getThorTxData");
|
|
8
|
-
const getChainPrices = async (rpcUrl) => {
|
|
8
|
+
const getChainPrices = async (rpcUrl, headers) => {
|
|
9
9
|
try {
|
|
10
|
-
const tronWeb = new tronweb_1.TronWeb({ fullHost: rpcUrl });
|
|
10
|
+
const tronWeb = new tronweb_1.TronWeb({ fullHost: rpcUrl, headers });
|
|
11
11
|
const params = await tronWeb.trx.getChainParameters();
|
|
12
12
|
const bandwidthPrice = params.find(p => p.key === 'getTransactionFee')?.value ?? 1000;
|
|
13
13
|
const energyPrice = params.find(p => p.key === 'getEnergyFee')?.value ?? 420;
|
|
@@ -29,11 +29,14 @@ const getTronTransactionFees = async (args, swapperName) => {
|
|
|
29
29
|
const { vault } = await (0, getThorTxData_1.getThorTxData)({ sellAsset, config, swapperName });
|
|
30
30
|
const contractAddress = (0, utils_1.contractAddressOrUndefined)(sellAsset.assetId);
|
|
31
31
|
const rpcUrl = config.VITE_TRON_NODE_URL;
|
|
32
|
+
const tronGridHeaders = config.VITE_TRON_GRID_API_KEY
|
|
33
|
+
? { 'TRON-PRO-API-KEY': config.VITE_TRON_GRID_API_KEY }
|
|
34
|
+
: {};
|
|
32
35
|
try {
|
|
33
|
-
const tronWeb = new tronweb_1.TronWeb({ fullHost: rpcUrl });
|
|
36
|
+
const tronWeb = new tronweb_1.TronWeb({ fullHost: rpcUrl, headers: tronGridHeaders });
|
|
34
37
|
if (contractAddress) {
|
|
35
38
|
// TRC20 transfer - estimate energy cost
|
|
36
|
-
const { energyPrice } = await getChainPrices(rpcUrl);
|
|
39
|
+
const { energyPrice } = await getChainPrices(rpcUrl, tronGridHeaders);
|
|
37
40
|
const result = await tronWeb.transactionBuilder.triggerConstantContract(contractAddress, 'transfer(address,uint256)', {}, [
|
|
38
41
|
{ type: 'address', value: vault },
|
|
39
42
|
{ type: 'uint256', value: sellAmountIncludingProtocolFeesCryptoBaseUnit },
|
|
@@ -44,7 +47,7 @@ const getTronTransactionFees = async (args, swapperName) => {
|
|
|
44
47
|
}
|
|
45
48
|
else {
|
|
46
49
|
// TRX transfer with memo - build transaction to get accurate size
|
|
47
|
-
const { bandwidthPrice } = await getChainPrices(rpcUrl);
|
|
50
|
+
const { bandwidthPrice } = await getChainPrices(rpcUrl, tronGridHeaders);
|
|
48
51
|
let tx = await tronWeb.transactionBuilder.sendTrx(vault, (0, utils_1.bnOrZero)(sellAmountIncludingProtocolFeesCryptoBaseUnit).toNumber(), from);
|
|
49
52
|
// Add memo to get accurate size with memo overhead
|
|
50
53
|
const txWithMemo = await tronWeb.transactionBuilder.addUpdateData(tx, memo, 'utf8');
|
|
@@ -71,7 +71,7 @@ export type ThornodeQuoteResponseSuccess = {
|
|
|
71
71
|
total_swap_seconds?: number;
|
|
72
72
|
warning: string;
|
|
73
73
|
};
|
|
74
|
-
type ThornodeResponseError = {
|
|
74
|
+
export type ThornodeResponseError = {
|
|
75
75
|
error: string;
|
|
76
76
|
};
|
|
77
77
|
export type ThornodeQuoteResponse = ThornodeQuoteResponseSuccess | ThornodeResponseError;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { GetUnsignedTronTransactionArgs } from '../types';
|
|
2
|
-
export declare const getTronTransactionFees: ({ tradeQuote, stepIndex, }: Pick<GetUnsignedTronTransactionArgs,
|
|
2
|
+
export declare const getTronTransactionFees: ({ tradeQuote, stepIndex, }: Pick<GetUnsignedTronTransactionArgs, 'tradeQuote' | 'stepIndex'>) => Promise<string>;
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type Polyglot from 'node-polyglot';
|
|
|
11
11
|
import type { InterpolationOptions } from 'node-polyglot';
|
|
12
12
|
import type { Address, Hex } from 'viem';
|
|
13
13
|
import type { AcrossTransactionMetadata } from './swappers/AcrossSwapper/utils/types';
|
|
14
|
+
import type { BobGatewayMetadata } from './swappers/BobGatewaySwapper/types';
|
|
14
15
|
import type { CowMessageToSign } from './swappers/CowSwapper/types';
|
|
15
16
|
import type { DebridgeTransactionMetadata } from './swappers/DebridgeSwapper/utils/types';
|
|
16
17
|
import type { RelayTransactionMetadata } from './swappers/RelaySwapper/utils/types';
|
|
@@ -22,6 +23,7 @@ export type SwapperConfig = {
|
|
|
22
23
|
VITE_THORCHAIN_NODE_URL: string;
|
|
23
24
|
VITE_MAYACHAIN_NODE_URL: string;
|
|
24
25
|
VITE_TRON_NODE_URL: string;
|
|
26
|
+
VITE_TRON_GRID_API_KEY: string;
|
|
25
27
|
VITE_FEATURE_THORCHAINSWAP_LONGTAIL: boolean;
|
|
26
28
|
VITE_FEATURE_THORCHAINSWAP_L1_TO_LONGTAIL: boolean;
|
|
27
29
|
VITE_THORCHAIN_MIDGARD_URL: string;
|
|
@@ -50,6 +52,7 @@ export type SwapperConfig = {
|
|
|
50
52
|
VITE_ACROSS_API_URL: string;
|
|
51
53
|
VITE_ACROSS_INTEGRATOR_ID: string;
|
|
52
54
|
VITE_DEBRIDGE_API_URL: string;
|
|
55
|
+
VITE_BOB_GATEWAY_API_KEY: string;
|
|
53
56
|
};
|
|
54
57
|
export declare enum SwapperName {
|
|
55
58
|
Thorchain = "THORChain",
|
|
@@ -69,7 +72,8 @@ export declare enum SwapperName {
|
|
|
69
72
|
Avnu = "AVNU",
|
|
70
73
|
Stonfi = "STON.fi",
|
|
71
74
|
Across = "Across",
|
|
72
|
-
Debridge = "deBridge"
|
|
75
|
+
Debridge = "deBridge",
|
|
76
|
+
BobGateway = "BOB Gateway"
|
|
73
77
|
}
|
|
74
78
|
export type SwapSource = SwapperName | `${SwapperName} • ${string}`;
|
|
75
79
|
export type SwapErrorRight = {
|
|
@@ -95,7 +99,9 @@ export declare enum TradeQuoteError {
|
|
|
95
99
|
FinalQuoteMaxSlippageExceeded = "FinalQuoteMaxSlippageExceeded",
|
|
96
100
|
FinalQuoteExecutionReverted = "FinalQuoteExecutionReverted",
|
|
97
101
|
Timeout = "Timeout",
|
|
98
|
-
UnknownError = "UnknownError"
|
|
102
|
+
UnknownError = "UnknownError",
|
|
103
|
+
InsufficientFunds = "InsufficientFunds",
|
|
104
|
+
InsufficientFundsUnconfirmed = "InsufficientFundsUnconfirmed"
|
|
99
105
|
}
|
|
100
106
|
export type UtxoFeeData = {
|
|
101
107
|
satsPerByte: string;
|
|
@@ -133,7 +139,6 @@ type CommonTradeInputBase = {
|
|
|
133
139
|
buyAsset: Asset;
|
|
134
140
|
sellAmountIncludingProtocolFeesCryptoBaseUnit: string;
|
|
135
141
|
affiliateBps: string;
|
|
136
|
-
affiliateAddress?: string;
|
|
137
142
|
allowMultiHop: boolean;
|
|
138
143
|
slippageTolerancePercentageDecimal?: string;
|
|
139
144
|
};
|
|
@@ -327,6 +332,12 @@ export type TradeQuoteStep = {
|
|
|
327
332
|
thorchainSpecific?: {
|
|
328
333
|
maxStreamingQuantity?: number;
|
|
329
334
|
};
|
|
335
|
+
thorchainTransactionMetadata?: {
|
|
336
|
+
to: string;
|
|
337
|
+
data?: string;
|
|
338
|
+
value?: string;
|
|
339
|
+
memo?: string;
|
|
340
|
+
};
|
|
330
341
|
relayTransactionMetadata?: RelayTransactionMetadata;
|
|
331
342
|
butterSwapTransactionMetadata?: {
|
|
332
343
|
to: string;
|
|
@@ -396,6 +407,7 @@ export type TradeQuoteStep = {
|
|
|
396
407
|
};
|
|
397
408
|
acrossTransactionMetadata?: AcrossTransactionMetadata;
|
|
398
409
|
debridgeTransactionMetadata?: DebridgeTransactionMetadata;
|
|
410
|
+
bobSpecific?: BobGatewayMetadata;
|
|
399
411
|
affiliateFee?: AffiliateFee;
|
|
400
412
|
};
|
|
401
413
|
export type TradeRateStep = Omit<TradeQuoteStep, 'accountNumber'> & {
|
|
@@ -452,6 +464,7 @@ export type SwapperSpecificMetadata = {
|
|
|
452
464
|
relayTransactionMetadata: RelayTransactionMetadata | undefined;
|
|
453
465
|
acrossTransactionMetadata: AcrossTransactionMetadata | undefined;
|
|
454
466
|
debridgeTransactionMetadata: DebridgeTransactionMetadata | undefined;
|
|
467
|
+
bobSpecific?: BobGatewayMetadata;
|
|
455
468
|
relayerExplorerTxLink: string | undefined;
|
|
456
469
|
relayerTxHash: string | undefined;
|
|
457
470
|
stepIndex: SupportedTradeQuoteStepIndex;
|
package/dist/cjs/types.js
CHANGED
|
@@ -21,6 +21,7 @@ var SwapperName;
|
|
|
21
21
|
SwapperName["Stonfi"] = "STON.fi";
|
|
22
22
|
SwapperName["Across"] = "Across";
|
|
23
23
|
SwapperName["Debridge"] = "deBridge";
|
|
24
|
+
SwapperName["BobGateway"] = "BOB Gateway";
|
|
24
25
|
})(SwapperName || (exports.SwapperName = SwapperName = {}));
|
|
25
26
|
var TradeQuoteError;
|
|
26
27
|
(function (TradeQuoteError) {
|
|
@@ -56,6 +57,10 @@ var TradeQuoteError;
|
|
|
56
57
|
TradeQuoteError["Timeout"] = "Timeout";
|
|
57
58
|
// catch-all for unknown issues
|
|
58
59
|
TradeQuoteError["UnknownError"] = "UnknownError";
|
|
60
|
+
// the swapper performed on chain balance checks and determined the user didn't have the funds to perform the swap
|
|
61
|
+
TradeQuoteError["InsufficientFunds"] = "InsufficientFunds";
|
|
62
|
+
// the user's confirmed balance is insufficient — funds may exist but are still confirming on chain (e.g. unconfirmed UTXO deposits)
|
|
63
|
+
TradeQuoteError["InsufficientFundsUnconfirmed"] = "InsufficientFundsUnconfirmed";
|
|
59
64
|
})(TradeQuoteError || (exports.TradeQuoteError = TradeQuoteError = {}));
|
|
60
65
|
var TransactionExecutionState;
|
|
61
66
|
(function (TransactionExecutionState) {
|
|
@@ -28,39 +28,39 @@ exports.getAllowanceStorageSlot = getAllowanceStorageSlot;
|
|
|
28
28
|
// USDC (BEP20 - BSC): balance at slot 1, allowance at slot 2
|
|
29
29
|
exports.KNOWN_BALANCE_SLOTS = {
|
|
30
30
|
// USDT - Native Tether deployment (custom slot 2)
|
|
31
|
-
'0xdac17f958d2ee523a2206206994597c13d831ec7': 2,
|
|
31
|
+
'0xdac17f958d2ee523a2206206994597c13d831ec7': 2,
|
|
32
32
|
// Slot 51 pattern (L2GatewayToken + ERC20Upgradeable + storage gaps)
|
|
33
33
|
// Various L2 tokens use this pattern with different implementations
|
|
34
|
-
'0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9': 51,
|
|
35
|
-
'0x912ce59144191c1204e64559fe8253a0e49e6548': 51,
|
|
36
|
-
'0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7': 51,
|
|
37
|
-
'0x01bff41798a0bcf287b996046ca68b395dbc1071': 51,
|
|
34
|
+
'0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9': 51,
|
|
35
|
+
'0x912ce59144191c1204e64559fe8253a0e49e6548': 51,
|
|
36
|
+
'0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7': 51,
|
|
37
|
+
'0x01bff41798a0bcf287b996046ca68b395dbc1071': 51,
|
|
38
38
|
// Wormhole bridge pattern (slot 5)
|
|
39
|
-
'0xca7dec8550f43a5e46e3dfb95801f64280e75b27': 5,
|
|
39
|
+
'0xca7dec8550f43a5e46e3dfb95801f64280e75b27': 5,
|
|
40
40
|
// USDT - BEP20 pattern (slot 1 - Binance-Peg token)
|
|
41
|
-
'0x55d398326f99059ff775485246999027b3197955': 1,
|
|
41
|
+
'0x55d398326f99059ff775485246999027b3197955': 1,
|
|
42
42
|
// USDT - xDai bridge pattern (slot 3)
|
|
43
|
-
'0x4ecaba5870353805a9f068101a40e0f32ed605c6': 3,
|
|
43
|
+
'0x4ecaba5870353805a9f068101a40e0f32ed605c6': 3,
|
|
44
44
|
// USDT - Standard ERC20 deployments (slot 0)
|
|
45
45
|
// Polygon confirmed, Optimism bridged USDT (0x94b008aa...) also uses slot 0
|
|
46
46
|
// USDC (Circle native deployments - all use slot 9)
|
|
47
|
-
'0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48': 9,
|
|
48
|
-
'0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e': 9,
|
|
49
|
-
'0x0b2c639c533813f4aa9d7837caf62653d097ff85': 9,
|
|
50
|
-
'0x3c499c542cef5e3811e1192ce70d8cc03d5c3359': 9,
|
|
51
|
-
'0xaf88d065e77c8cc2239327c5edb3a432268e5831': 9,
|
|
52
|
-
'0x833589fcd6edb6e08f4c7c32d4f71b54bda02913': 9,
|
|
47
|
+
'0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48': 9,
|
|
48
|
+
'0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e': 9,
|
|
49
|
+
'0x0b2c639c533813f4aa9d7837caf62653d097ff85': 9,
|
|
50
|
+
'0x3c499c542cef5e3811e1192ce70d8cc03d5c3359': 9,
|
|
51
|
+
'0xaf88d065e77c8cc2239327c5edb3a432268e5831': 9,
|
|
52
|
+
'0x833589fcd6edb6e08f4c7c32d4f71b54bda02913': 9,
|
|
53
53
|
// USDC (BEP20 pattern on BSC - slot 1)
|
|
54
54
|
'0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d': 1, // USDC BSC (BEP20)
|
|
55
55
|
};
|
|
56
56
|
exports.KNOWN_ALLOWANCE_SLOTS = {
|
|
57
57
|
// USDT allowance slots (explicit mapping for all non-standard implementations)
|
|
58
|
-
'0xdac17f958d2ee523a2206206994597c13d831ec7': 5,
|
|
59
|
-
'0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9': 52,
|
|
60
|
-
'0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7': 52,
|
|
61
|
-
'0x01bff41798a0bcf287b996046ca68b395dbc1071': 52,
|
|
62
|
-
'0x55d398326f99059ff775485246999027b3197955': 2,
|
|
63
|
-
'0x4ecaba5870353805a9f068101a40e0f32ed605c6': 4,
|
|
58
|
+
'0xdac17f958d2ee523a2206206994597c13d831ec7': 5,
|
|
59
|
+
'0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9': 52,
|
|
60
|
+
'0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7': 52,
|
|
61
|
+
'0x01bff41798a0bcf287b996046ca68b395dbc1071': 52,
|
|
62
|
+
'0x55d398326f99059ff775485246999027b3197955': 2,
|
|
63
|
+
'0x4ecaba5870353805a9f068101a40e0f32ed605c6': 4,
|
|
64
64
|
// Note: Polygon and Optimism standard bridged USDT (0x94b008aa...) use slot 1 (fallback)
|
|
65
65
|
// Note: SWEAT (slot 5) allowance auto-inferred to slot 6 via Wormhole pattern
|
|
66
66
|
// USDC allowance slots (BSC uses BEP20 pattern, not Circle FiatToken)
|
package/dist/cjs/utils.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare const makeSwapErrorRight: ({ details, cause, code, message, }: {
|
|
|
12
12
|
message: string;
|
|
13
13
|
details?: unknown;
|
|
14
14
|
cause?: unknown;
|
|
15
|
-
code?: TradeQuoteError;
|
|
15
|
+
code?: TradeQuoteError | undefined;
|
|
16
16
|
}) => SwapErrorRight;
|
|
17
17
|
export declare const createTradeAmountTooSmallErr: (details?: {
|
|
18
18
|
minAmountCryptoBaseUnit: string;
|
|
@@ -21,9 +21,9 @@ export declare const createTradeAmountTooSmallErr: (details?: {
|
|
|
21
21
|
export declare const createCache: (maxAge: number, cachedUrls: string[], axiosConfig: AxiosRequestConfig) => AxiosInstance;
|
|
22
22
|
export declare const AsyncResultOf: <T>(promise: Promise<T>) => Promise<Result<T, Error>>;
|
|
23
23
|
export declare const makeSwapperAxiosServiceMonadic: (service: AxiosInstance) => {
|
|
24
|
-
get: <T = any>(url: string, config?: AxiosRequestConfig<any>) => Promise<Result<AxiosResponse<T>, SwapErrorRight>>;
|
|
25
|
-
post: <
|
|
26
|
-
delete: <
|
|
24
|
+
get: <T = any>(url: string, config?: AxiosRequestConfig<any>) => Promise<Result<AxiosResponse<T, any, {}>, SwapErrorRight>>;
|
|
25
|
+
post: <T_1 = any>(url: string, data: any, config?: AxiosRequestConfig<any>) => Promise<Result<AxiosResponse<T_1, any, {}>, SwapErrorRight>>;
|
|
26
|
+
delete: <T_2 = any>(url: string, data: any, config?: AxiosRequestConfig<any>) => Promise<Result<AxiosResponse<T_2, any, {}>, SwapErrorRight>>;
|
|
27
27
|
};
|
|
28
28
|
export declare const getHopByIndex: (quote: TradeQuote | TradeRate | undefined, index: SupportedTradeQuoteStepIndex) => TradeQuoteStep | undefined;
|
|
29
29
|
export declare const executeEvmTransaction: (txToSign: SignTx<EvmChainId>, callbacks: EvmTransactionExecutionProps) => Promise<string>;
|