@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
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SunioRoute } from '../types';
|
|
2
|
+
type EstimateSunioNetworkFeeArgs = {
|
|
3
|
+
rpcUrl: string;
|
|
4
|
+
apiKey: string;
|
|
5
|
+
route: SunioRoute;
|
|
6
|
+
sellAmountCryptoBaseUnit: string;
|
|
7
|
+
isSellingNativeTrx: boolean;
|
|
8
|
+
address: string | undefined;
|
|
9
|
+
slippageTolerancePercentageDecimal: string | undefined;
|
|
10
|
+
};
|
|
11
|
+
export declare const estimateSunioNetworkFeeCryptoBaseUnit: ({ rpcUrl, apiKey, route, sellAmountCryptoBaseUnit, isSellingNativeTrx, address, slippageTolerancePercentageDecimal, }: EstimateSunioNetworkFeeArgs) => Promise<string>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.estimateSunioNetworkFeeCryptoBaseUnit = void 0;
|
|
4
|
+
const utils_1 = require("@shapeshiftoss/utils");
|
|
5
|
+
const tronweb_1 = require("tronweb");
|
|
6
|
+
const buildSwapContractCall_1 = require("./buildSwapContractCall");
|
|
7
|
+
const buildSwapRouteParameters_1 = require("./buildSwapRouteParameters");
|
|
8
|
+
const constants_1 = require("./constants");
|
|
9
|
+
// Estimates the network fee (in TRX base units) for a Sun.io swap. The router sponsors only ~1%
|
|
10
|
+
// of energy (origin_energy_usage); the user pays the rest, so we simulate the real swapExactInput
|
|
11
|
+
// call when we have an address to estimate from. The simulation reverts before approval for TRC20
|
|
12
|
+
// sells (and when the account lacks the sell balance), so we fall back to a conservative per-sell-
|
|
13
|
+
// type constant. Used both at quote time and re-run at confirm time, where a now-granted allowance
|
|
14
|
+
// lets the simulation produce the true cost.
|
|
15
|
+
const estimateSunioNetworkFeeCryptoBaseUnit = async ({ rpcUrl, apiKey, route, sellAmountCryptoBaseUnit, isSellingNativeTrx, address, slippageTolerancePercentageDecimal, }) => {
|
|
16
|
+
const tronGridHeaders = apiKey ? { 'TRON-PRO-API-KEY': apiKey } : {};
|
|
17
|
+
const tronWeb = new tronweb_1.TronWeb({ fullHost: rpcUrl, headers: tronGridHeaders });
|
|
18
|
+
// Live network prices, defaulting if the node is unavailable so we still produce a fee
|
|
19
|
+
const { bandwidthPrice, energyPrice } = await (async () => {
|
|
20
|
+
try {
|
|
21
|
+
const params = await tronWeb.trx.getChainParameters();
|
|
22
|
+
return {
|
|
23
|
+
bandwidthPrice: params.find(p => p.key === 'getTransactionFee')?.value ?? 1000,
|
|
24
|
+
energyPrice: params.find(p => p.key === 'getEnergyFee')?.value ?? 100,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return { bandwidthPrice: 1000, energyPrice: 100 };
|
|
29
|
+
}
|
|
30
|
+
})();
|
|
31
|
+
// Account activation (1 TRX) is only charged when the recipient receives native TRX, mirroring
|
|
32
|
+
// the chain adapter. A TRC20 buy doesn't incur the flat activation fee (its account-creation
|
|
33
|
+
// cost is folded into energy). Only checkable with an address.
|
|
34
|
+
const isBuyingNativeTrx = route.tokens[route.tokens.length - 1] === constants_1.SUNIO_TRON_NATIVE_ADDRESS;
|
|
35
|
+
const accountActivationFee = await (async () => {
|
|
36
|
+
if (!address || !isBuyingNativeTrx)
|
|
37
|
+
return 0;
|
|
38
|
+
try {
|
|
39
|
+
const recipientInfoResponse = await fetch(`${rpcUrl}/wallet/getaccount`, {
|
|
40
|
+
method: 'POST',
|
|
41
|
+
headers: { 'Content-Type': 'application/json', ...tronGridHeaders },
|
|
42
|
+
body: JSON.stringify({ address, visible: true }),
|
|
43
|
+
});
|
|
44
|
+
const recipientInfo = await recipientInfoResponse.json();
|
|
45
|
+
const recipientExists = recipientInfo && Object.keys(recipientInfo).length > 1;
|
|
46
|
+
return recipientExists ? 0 : 1_000_000; // 1 TRX
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return 0;
|
|
50
|
+
}
|
|
51
|
+
})();
|
|
52
|
+
const energyUsed = await (async () => {
|
|
53
|
+
// TRC20 sells cost far more energy than native sells (the extra transferFrom token pull)
|
|
54
|
+
const fallbackEnergy = isSellingNativeTrx
|
|
55
|
+
? constants_1.SUNIO_FALLBACK_SWAP_ENERGY_NATIVE
|
|
56
|
+
: constants_1.SUNIO_FALLBACK_SWAP_ENERGY_TRC20;
|
|
57
|
+
if (!address)
|
|
58
|
+
return fallbackEnergy;
|
|
59
|
+
try {
|
|
60
|
+
const routeParams = (0, buildSwapRouteParameters_1.buildSwapRouteParameters)(route, sellAmountCryptoBaseUnit, '0', address, slippageTolerancePercentageDecimal ?? constants_1.DEFAULT_SLIPPAGE_PERCENTAGE);
|
|
61
|
+
const callValue = isSellingNativeTrx ? Number(sellAmountCryptoBaseUnit) : 0;
|
|
62
|
+
const result = await tronWeb.transactionBuilder.triggerConstantContract(constants_1.SUNIO_SMART_ROUTER_CONTRACT, buildSwapContractCall_1.SUNIO_SWAP_EXACT_INPUT_SELECTOR, { callValue }, (0, buildSwapContractCall_1.buildSwapExactInputParameters)(routeParams), address);
|
|
63
|
+
// A reverted simulation (e.g. TRC20 sell pre-approval) can still return a small energy_used;
|
|
64
|
+
// only trust it when the call actually succeeded, otherwise use the conservative fallback.
|
|
65
|
+
if (result?.result?.result !== true || result.energy_used == null)
|
|
66
|
+
return fallbackEnergy;
|
|
67
|
+
return result.energy_used;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return fallbackEnergy;
|
|
71
|
+
}
|
|
72
|
+
})();
|
|
73
|
+
// 1.2x safety margin for energy price/usage variance between estimate and execution
|
|
74
|
+
const energyFee = Math.ceil(energyUsed * energyPrice * 1.2);
|
|
75
|
+
const bandwidthFee = 1100 * bandwidthPrice;
|
|
76
|
+
return (0, utils_1.bn)(energyFee).plus(bandwidthFee).plus(accountActivationFee).toFixed(0);
|
|
77
|
+
};
|
|
78
|
+
exports.estimateSunioNetworkFeeCryptoBaseUnit = estimateSunioNetworkFeeCryptoBaseUnit;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getQuoteOrRate =
|
|
3
|
+
exports.getQuoteOrRate = void 0;
|
|
4
4
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
5
5
|
const utils_1 = require("@shapeshiftoss/utils");
|
|
6
6
|
const monads_1 = require("@sniptt/monads");
|
|
7
|
-
const tronweb_1 = require("tronweb");
|
|
8
7
|
const types_1 = require("../../../types");
|
|
9
8
|
const utils_2 = require("../../../utils");
|
|
10
9
|
const affiliateFee_1 = require("../../utils/affiliateFee");
|
|
11
10
|
const constants_1 = require("./constants");
|
|
11
|
+
const estimateSunioNetworkFee_1 = require("./estimateSunioNetworkFee");
|
|
12
12
|
const fetchFromSunio_1 = require("./fetchFromSunio");
|
|
13
13
|
const helpers_1 = require("./helpers/helpers");
|
|
14
14
|
const sunioService_1 = require("./sunioService");
|
|
@@ -60,83 +60,25 @@ async function getQuoteOrRate(input, deps) {
|
|
|
60
60
|
code: types_1.TradeQuoteError.InternalError,
|
|
61
61
|
}));
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
let networkFeeCryptoBaseUnit = undefined;
|
|
65
|
-
// Estimate fees when we have an address to estimate from
|
|
66
|
-
if (receiveAddress) {
|
|
63
|
+
const networkFeeCryptoBaseUnit = await (async () => {
|
|
67
64
|
try {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
try {
|
|
78
|
-
const recipientInfoResponse = await fetch(`${deps.config.VITE_TRON_NODE_URL}/wallet/getaccount`, {
|
|
79
|
-
method: 'POST',
|
|
80
|
-
headers: { 'Content-Type': 'application/json' },
|
|
81
|
-
body: JSON.stringify({ address: receiveAddress, visible: true }),
|
|
82
|
-
});
|
|
83
|
-
const recipientInfo = await recipientInfoResponse.json();
|
|
84
|
-
const recipientExists = recipientInfo && Object.keys(recipientInfo).length > 1;
|
|
85
|
-
if (!recipientExists) {
|
|
86
|
-
accountActivationFee = 1_000_000; // 1 TRX
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
catch {
|
|
90
|
-
// Ignore activation check errors
|
|
91
|
-
}
|
|
92
|
-
// For native TRX swaps, Sun.io uses a contract call with value
|
|
93
|
-
// We need to estimate energy for the swap contract, not just bandwidth
|
|
94
|
-
if (isSellingNativeTrx) {
|
|
95
|
-
try {
|
|
96
|
-
// Sun.io contract owner provides most energy (~117k), users only pay ~2k
|
|
97
|
-
// Use fixed 2k energy estimate instead of querying (which returns total 120k)
|
|
98
|
-
const energyUsed = 2000; // User pays ~2k energy, contract covers the rest
|
|
99
|
-
const energyFee = energyUsed * energyPrice; // No multiplier - contract provides energy
|
|
100
|
-
// Estimate bandwidth for contract call (much larger than simple transfer)
|
|
101
|
-
const bandwidthFee = 1100 * bandwidthPrice; // ~1100 bytes for contract call (with safety buffer)
|
|
102
|
-
networkFeeCryptoBaseUnit = (0, utils_1.bn)(energyFee)
|
|
103
|
-
.plus(bandwidthFee)
|
|
104
|
-
.plus(accountActivationFee)
|
|
105
|
-
.toFixed(0);
|
|
106
|
-
}
|
|
107
|
-
catch (estimationError) {
|
|
108
|
-
// Fallback estimate: ~2k energy + ~1100 bytes bandwidth + activation fee
|
|
109
|
-
const fallbackEnergyFee = 2000 * energyPrice;
|
|
110
|
-
const fallbackBandwidthFee = 1100 * bandwidthPrice;
|
|
111
|
-
networkFeeCryptoBaseUnit = (0, utils_1.bn)(fallbackEnergyFee)
|
|
112
|
-
.plus(fallbackBandwidthFee)
|
|
113
|
-
.plus(accountActivationFee)
|
|
114
|
-
.toFixed(0);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
// For TRC-20 swaps through Sun.io router
|
|
119
|
-
// Same as TRX: contract owner provides most energy, user pays ~2k
|
|
120
|
-
// Sun.io provides ~217k energy, user pays ~2k
|
|
121
|
-
const energyFee = 2000 * energyPrice;
|
|
122
|
-
const bandwidthFee = 1100 * bandwidthPrice;
|
|
123
|
-
networkFeeCryptoBaseUnit = (0, utils_1.bn)(energyFee)
|
|
124
|
-
.plus(bandwidthFee)
|
|
125
|
-
.plus(accountActivationFee)
|
|
126
|
-
.toFixed(0);
|
|
127
|
-
}
|
|
65
|
+
return await (0, estimateSunioNetworkFee_1.estimateSunioNetworkFeeCryptoBaseUnit)({
|
|
66
|
+
rpcUrl: deps.config.VITE_TRON_NODE_URL,
|
|
67
|
+
apiKey: deps.config.VITE_TRON_GRID_API_KEY,
|
|
68
|
+
route: bestRoute,
|
|
69
|
+
sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
70
|
+
isSellingNativeTrx: !(0, utils_1.contractAddressOrUndefined)(sellAsset.assetId),
|
|
71
|
+
address: receiveAddress,
|
|
72
|
+
slippageTolerancePercentageDecimal,
|
|
73
|
+
});
|
|
128
74
|
}
|
|
129
75
|
catch (error) {
|
|
130
|
-
// For rates, fall back to '0' on
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
throw error;
|
|
137
|
-
}
|
|
76
|
+
// For rates, fall back to '0' on unexpected failure; quotes require an accurate fee
|
|
77
|
+
if (!isQuote)
|
|
78
|
+
return '0';
|
|
79
|
+
throw error;
|
|
138
80
|
}
|
|
139
|
-
}
|
|
81
|
+
})();
|
|
140
82
|
const buyAmountCryptoBaseUnit = utils_1.BigAmount.fromPrecision({
|
|
141
83
|
value: bestRoute.amountOut,
|
|
142
84
|
precision: buyAsset.precision,
|
|
@@ -211,3 +153,4 @@ async function getQuoteOrRate(input, deps) {
|
|
|
211
153
|
}));
|
|
212
154
|
}
|
|
213
155
|
}
|
|
156
|
+
exports.getQuoteOrRate = getQuoteOrRate;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSunioTransactionFees = void 0;
|
|
4
|
+
const caip_1 = require("@shapeshiftoss/caip");
|
|
5
|
+
const utils_1 = require("../../../utils");
|
|
6
|
+
const estimateSunioNetworkFee_1 = require("./estimateSunioNetworkFee");
|
|
7
|
+
const getSunioTransactionFees = async ({ tradeQuote, stepIndex, from, slippageTolerancePercentageDecimal, assertGetTronChainAdapter, config, }) => {
|
|
8
|
+
if (!(0, utils_1.isExecutableTradeQuote)(tradeQuote))
|
|
9
|
+
throw new Error('Unable to execute a trade rate quote');
|
|
10
|
+
const step = (0, utils_1.getExecutableTradeStep)(tradeQuote, stepIndex);
|
|
11
|
+
const storedNetworkFeeCryptoBaseUnit = step.feeData.networkFeeCryptoBaseUnit;
|
|
12
|
+
const route = step.sunioTransactionMetadata?.route;
|
|
13
|
+
if (!route) {
|
|
14
|
+
if (!storedNetworkFeeCryptoBaseUnit)
|
|
15
|
+
throw new Error('Missing network fee in quote');
|
|
16
|
+
return storedNetworkFeeCryptoBaseUnit;
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const adapter = assertGetTronChainAdapter(caip_1.tronChainId);
|
|
20
|
+
return await (0, estimateSunioNetworkFee_1.estimateSunioNetworkFeeCryptoBaseUnit)({
|
|
21
|
+
rpcUrl: adapter.httpProvider.getRpcUrl(),
|
|
22
|
+
apiKey: config.VITE_TRON_GRID_API_KEY,
|
|
23
|
+
route,
|
|
24
|
+
sellAmountCryptoBaseUnit: step.sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
25
|
+
isSellingNativeTrx: step.sellAsset.assetId === caip_1.tronAssetId,
|
|
26
|
+
address: from,
|
|
27
|
+
slippageTolerancePercentageDecimal,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
if (!storedNetworkFeeCryptoBaseUnit)
|
|
32
|
+
throw new Error('Missing network fee in quote');
|
|
33
|
+
return storedNetworkFeeCryptoBaseUnit;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
exports.getSunioTransactionFees = getSunioTransactionFees;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { AssetId } from '@shapeshiftoss/caip';
|
|
2
|
-
import { tronChainId } from '@shapeshiftoss/caip';
|
|
3
2
|
export declare const isSupportedChainId: (chainId: string) => boolean;
|
|
4
3
|
export declare const assetIdToTronToken: (assetId: AssetId) => string;
|
|
5
|
-
export declare const isTronChainId: (chainId: string) => chainId is
|
|
4
|
+
export declare const isTronChainId: (chainId: string) => chainId is import("@shapeshiftoss/caip").ChainId;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const sunioServiceFactory: () => {
|
|
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
|
};
|
|
6
6
|
export type SunioService = ReturnType<typeof sunioServiceFactory>;
|
|
@@ -78,6 +78,11 @@ const expectedQuoteResponse = [
|
|
|
78
78
|
thorchainSpecific: {
|
|
79
79
|
maxStreamingQuantity: undefined,
|
|
80
80
|
},
|
|
81
|
+
thorchainTransactionMetadata: {
|
|
82
|
+
to: '0x3624525075b88B24ecc29CE226b0CEc1fFcB6976',
|
|
83
|
+
data: '0x',
|
|
84
|
+
value: '0',
|
|
85
|
+
},
|
|
81
86
|
},
|
|
82
87
|
],
|
|
83
88
|
},
|
|
@@ -121,6 +126,11 @@ const expectedQuoteResponse = [
|
|
|
121
126
|
thorchainSpecific: {
|
|
122
127
|
maxStreamingQuantity: undefined,
|
|
123
128
|
},
|
|
129
|
+
thorchainTransactionMetadata: {
|
|
130
|
+
to: '0x3624525075b88B24ecc29CE226b0CEc1fFcB6976',
|
|
131
|
+
data: '0x',
|
|
132
|
+
value: '0',
|
|
133
|
+
},
|
|
124
134
|
},
|
|
125
135
|
],
|
|
126
136
|
},
|
|
@@ -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.getL1ToLongtailQuote = void 0;
|
|
37
27
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
@@ -137,7 +127,7 @@ const getL1ToLongtailQuote = async (input, deps, streamingInterval, swapperName)
|
|
|
137
127
|
// This is wrong, we should get the get the value before fees or display ETH value received after the thorchain bridge
|
|
138
128
|
buyAmountBeforeFeesCryptoBaseUnit: quotedAmountOut.toString(),
|
|
139
129
|
allowanceContract: contracts_1.TS_AGGREGATOR_TOKEN_TRANSFER_PROXY_CONTRACT_MAINNET,
|
|
140
|
-
})),
|
|
130
|
+
})),
|
|
141
131
|
isLongtail: true,
|
|
142
132
|
longtailData: {
|
|
143
133
|
L1ToLongtailExpectedAmountOut: quotedAmountOut.toString(),
|
|
@@ -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.getL1ToLongtailRate = void 0;
|
|
37
27
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
@@ -125,7 +115,7 @@ const getL1ToLongtailRate = async (input, deps, streamingInterval, swapperName)
|
|
|
125
115
|
// This is wrong, we should get the get the value before fees or display ETH value received after the thorchain bridge
|
|
126
116
|
buyAmountBeforeFeesCryptoBaseUnit: quotedAmountOut.toString(),
|
|
127
117
|
allowanceContract: contracts_1.TS_AGGREGATOR_TOKEN_TRANSFER_PROXY_CONTRACT_MAINNET,
|
|
128
|
-
})),
|
|
118
|
+
})),
|
|
129
119
|
isLongtail: true,
|
|
130
120
|
longtailData: {
|
|
131
121
|
L1ToLongtailExpectedAmountOut: quotedAmountOut.toString(),
|
|
@@ -61,7 +61,7 @@ const getLongtailToL1Quote = async (input, deps, streamingInterval, swapperName)
|
|
|
61
61
|
sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
62
62
|
sellAsset,
|
|
63
63
|
allowanceContract: contracts_1.TS_AGGREGATOR_TOKEN_TRANSFER_PROXY_CONTRACT_MAINNET,
|
|
64
|
-
})),
|
|
64
|
+
})),
|
|
65
65
|
isLongtail: true,
|
|
66
66
|
longtailData: {
|
|
67
67
|
longtailToL1ExpectedAmountOut: quotedAmountOut.toString(),
|
|
@@ -61,7 +61,7 @@ const getLongtailToL1Rate = async (input, deps, streamingInterval, swapperName)
|
|
|
61
61
|
sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
62
62
|
sellAsset,
|
|
63
63
|
allowanceContract: contracts_1.TS_AGGREGATOR_TOKEN_TRANSFER_PROXY_CONTRACT_MAINNET,
|
|
64
|
-
})),
|
|
64
|
+
})),
|
|
65
65
|
isLongtail: true,
|
|
66
66
|
longtailData: {
|
|
67
67
|
longtailToL1ExpectedAmountOut: quotedAmountOut.toString(),
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.shortenedNativeAssetNameByNativeAssetName = exports.selectBestRate = exports.getQuotedAmountOutByPool = exports.getContractDataByPool = exports.generateV3PoolAddressesAcrossFeeRange = exports.feeAmountToContractMap = exports.contractToFeeAmountMap = exports.AggregatorContract = exports.getTokenFromAsset = exports.getWrappedToken = void 0;
|
|
4
|
-
exports.getTradeType = getTradeType;
|
|
3
|
+
exports.shortenedNativeAssetNameByNativeAssetName = exports.selectBestRate = exports.getQuotedAmountOutByPool = exports.getContractDataByPool = exports.generateV3PoolAddressesAcrossFeeRange = exports.feeAmountToContractMap = exports.contractToFeeAmountMap = exports.AggregatorContract = exports.getTradeType = exports.getTokenFromAsset = exports.getWrappedToken = void 0;
|
|
5
4
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
6
5
|
const contracts_1 = require("@shapeshiftoss/contracts");
|
|
7
6
|
const sdk_core_1 = require("@uniswap/sdk-core");
|
|
@@ -47,6 +46,7 @@ function getTradeType(sellAssetPool, buyAssetPool, sellPoolId, buyPoolId) {
|
|
|
47
46
|
return undefined;
|
|
48
47
|
}
|
|
49
48
|
}
|
|
49
|
+
exports.getTradeType = getTradeType;
|
|
50
50
|
// TODO: we need to fetch these contracts dynamically, as the whitelist can change
|
|
51
51
|
var AggregatorContract;
|
|
52
52
|
(function (AggregatorContract) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getZrxTradeQuote =
|
|
3
|
+
exports.getZrxTradeQuote = void 0;
|
|
4
4
|
const chain_adapters_1 = require("@shapeshiftoss/chain-adapters");
|
|
5
5
|
const contracts_1 = require("@shapeshiftoss/contracts");
|
|
6
6
|
const utils_1 = require("@shapeshiftoss/utils");
|
|
@@ -122,3 +122,4 @@ async function getZrxTradeQuote(input, assertGetEvmChainAdapter, assetsById, zrx
|
|
|
122
122
|
}));
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
+
exports.getZrxTradeQuote = getZrxTradeQuote;
|
|
@@ -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
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
37
27
|
const types_1 = require("@shapeshiftoss/types");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getZrxTradeRate =
|
|
3
|
+
exports.getZrxTradeRate = void 0;
|
|
4
4
|
const contracts_1 = require("@shapeshiftoss/contracts");
|
|
5
5
|
const monads_1 = require("@sniptt/monads");
|
|
6
6
|
const uuid_1 = require("uuid");
|
|
@@ -78,3 +78,4 @@ async function getZrxTradeRate(input, assetsById, zrxBaseUrl) {
|
|
|
78
78
|
],
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
|
+
exports.getZrxTradeRate = getZrxTradeRate;
|
|
@@ -27,9 +27,9 @@ const fetchFromZrx = async ({ quoteOrRate, buyAsset, sellAsset, sellAmountInclud
|
|
|
27
27
|
sellAmount: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
28
28
|
taker: sellAddress,
|
|
29
29
|
swapFeeBps: (0, utils_1.bn)(affiliateBps).toNumber(),
|
|
30
|
-
swapFeeToken: (0, helpers_2.assetIdToZrxToken)(buyAsset.assetId),
|
|
30
|
+
swapFeeToken: (0, helpers_2.assetIdToZrxToken)(buyAsset.assetId),
|
|
31
31
|
slippageBps: (0, utils_1.convertDecimalPercentageToBasisPoints)(slippageTolerancePercentageDecimal).toNumber(),
|
|
32
|
-
swapFeeRecipient: maybeTreasuryAddress,
|
|
32
|
+
swapFeeRecipient: maybeTreasuryAddress,
|
|
33
33
|
feeRecipientTradeSurplus: maybeTreasuryAddress, // Where trade surplus is sent
|
|
34
34
|
},
|
|
35
35
|
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { AssetId, ChainId } from '@shapeshiftoss/caip';
|
|
2
2
|
import type { Asset, AssetsByIdPartial } from '@shapeshiftoss/types';
|
|
3
|
-
import
|
|
3
|
+
import { KnownChainIds } from '@shapeshiftoss/types';
|
|
4
|
+
import type { ZrxFees } from '../../types';
|
|
4
5
|
export declare const assetIdToZrxToken: (assetId: AssetId) => string;
|
|
5
6
|
export declare const zrxTokenToAssetId: (token: string, chainId: ChainId) => AssetId;
|
|
6
|
-
export declare const isSupportedChainId: (chainId: ChainId) => chainId is
|
|
7
|
+
export declare const isSupportedChainId: (chainId: ChainId) => chainId is KnownChainIds.EthereumMainnet | KnownChainIds.AvalancheMainnet | KnownChainIds.OptimismMainnet | KnownChainIds.BnbSmartChainMainnet | KnownChainIds.PolygonMainnet | KnownChainIds.ArbitrumMainnet | KnownChainIds.BaseMainnet;
|
|
7
8
|
export declare const assertValidTrade: ({ buyAsset, sellAsset, }: {
|
|
8
9
|
buyAsset: Asset;
|
|
9
10
|
sellAsset: Asset;
|
|
@@ -4,6 +4,6 @@ import type { MonadicSwapperAxiosService } from '../../../types';
|
|
|
4
4
|
type AxiosInstanceHoF = (instance: AxiosInstance, options?: Omit<RetryConfig, 'instance'>) => AxiosInstance;
|
|
5
5
|
export declare const zrxServiceFactory: ({ baseUrl, wrapper, }: {
|
|
6
6
|
baseUrl: string;
|
|
7
|
-
wrapper?: AxiosInstanceHoF;
|
|
7
|
+
wrapper?: AxiosInstanceHoF | undefined;
|
|
8
8
|
}) => MonadicSwapperAxiosService;
|
|
9
9
|
export {};
|
|
@@ -49,6 +49,7 @@ const DAO_TREASURY_BY_CHAIN_ID = {
|
|
|
49
49
|
[types_1.KnownChainIds.TonMainnet]: utils_1.DAO_TREASURY_TON,
|
|
50
50
|
[types_1.KnownChainIds.MonadMainnet]: utils_1.DAO_TREASURY_MONAD,
|
|
51
51
|
[types_1.KnownChainIds.HyperEvmMainnet]: utils_1.DAO_TREASURY_HYPEREVM,
|
|
52
|
+
[types_1.KnownChainIds.BobMainnet]: utils_1.DAO_TREASURY_BOB,
|
|
52
53
|
};
|
|
53
54
|
const getTreasuryAddressFromChainId = (chainId) => {
|
|
54
55
|
const maybeTreasuryChainId = (0, utils_1.isTreasuryChainId)(chainId) ? chainId : undefined;
|
|
@@ -1,39 +1,5 @@
|
|
|
1
|
-
import { AVAX, BSC, BTC, ETH, FOX_GNOSIS, FOX_MAINNET, OPTIMISM, RUNE, USDC_GNOSIS, USDC_MAINNET, WBTC, WETH } from './assets';
|
|
2
1
|
export declare const marketDataByAssetIdUsd: {
|
|
3
|
-
[
|
|
4
|
-
price: string;
|
|
5
|
-
};
|
|
6
|
-
[FOX_GNOSIS.assetId]: {
|
|
7
|
-
price: string;
|
|
8
|
-
};
|
|
9
|
-
[ETH.assetId]: {
|
|
10
|
-
price: string;
|
|
11
|
-
};
|
|
12
|
-
[AVAX.assetId]: {
|
|
13
|
-
price: string;
|
|
14
|
-
};
|
|
15
|
-
[BSC.assetId]: {
|
|
16
|
-
price: string;
|
|
17
|
-
};
|
|
18
|
-
[BTC.assetId]: {
|
|
19
|
-
price: string;
|
|
20
|
-
};
|
|
21
|
-
[RUNE.assetId]: {
|
|
22
|
-
price: string;
|
|
23
|
-
};
|
|
24
|
-
[OPTIMISM.assetId]: {
|
|
25
|
-
price: string;
|
|
26
|
-
};
|
|
27
|
-
[USDC_MAINNET.assetId]: {
|
|
28
|
-
price: string;
|
|
29
|
-
};
|
|
30
|
-
[USDC_GNOSIS.assetId]: {
|
|
31
|
-
price: string;
|
|
32
|
-
};
|
|
33
|
-
[WBTC.assetId]: {
|
|
34
|
-
price: string;
|
|
35
|
-
};
|
|
36
|
-
[WETH.assetId]: {
|
|
2
|
+
[x: string]: {
|
|
37
3
|
price: string;
|
|
38
4
|
};
|
|
39
5
|
};
|
|
@@ -68,7 +68,14 @@ const checkTradeStatus = async ({ txHash, chainId, address, fetchIsSmartContract
|
|
|
68
68
|
return { buyTxHash, status: unchained_client_1.TxStatus.Pending, message };
|
|
69
69
|
}
|
|
70
70
|
catch (e) {
|
|
71
|
-
|
|
71
|
+
const message = (() => {
|
|
72
|
+
if (axios_1.default.isAxiosError(e))
|
|
73
|
+
return e.response?.data?.message ?? e.message;
|
|
74
|
+
if (e instanceof Error)
|
|
75
|
+
return e.message;
|
|
76
|
+
return String(e);
|
|
77
|
+
})();
|
|
78
|
+
console.error(`checkTradeStatus(${nativeChain}, ${txHash}): ${message}`);
|
|
72
79
|
return { buyTxHash: undefined, status: unchained_client_1.TxStatus.Unknown, message: undefined };
|
|
73
80
|
}
|
|
74
81
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Asset } from '@shapeshiftoss/types';
|
|
2
|
+
import type { SwapperConfig, SwapperName } from '../../types';
|
|
3
|
+
type GetThorTxDataArgs = {
|
|
4
|
+
sellAsset: Asset;
|
|
5
|
+
config: SwapperConfig;
|
|
6
|
+
swapperName: SwapperName;
|
|
7
|
+
};
|
|
8
|
+
type GetThorTxDataReturn = {
|
|
9
|
+
vault: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const getThorTxData: ({ sellAsset, config, swapperName, }: GetThorTxDataArgs) => Promise<GetThorTxDataReturn>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getThorTxData = void 0;
|
|
4
|
+
const getInboundAddressDataForChain_1 = require("../getInboundAddressDataForChain");
|
|
5
|
+
const index_1 = require("../index");
|
|
6
|
+
const getThorTxData = async ({ sellAsset, config, swapperName, }) => {
|
|
7
|
+
// Native assets on the swapper's own chain (RUNE on THORChain, CACAO on MAYAChain)
|
|
8
|
+
// deposit via MsgDeposit and have no recipient address.
|
|
9
|
+
if (sellAsset.chainId === (0, index_1.getChainIdBySwapper)(swapperName))
|
|
10
|
+
return { vault: '' };
|
|
11
|
+
// Everything else (e.g. ATOM via THORChain, RUNE via MAYAChain) sends via MsgSend
|
|
12
|
+
// to the swapper's inbound vault on that chain.
|
|
13
|
+
const daemonUrl = (0, index_1.getDaemonUrl)(config, swapperName);
|
|
14
|
+
const res = await (0, getInboundAddressDataForChain_1.getInboundAddressDataForChain)(daemonUrl, sellAsset.assetId, true, swapperName);
|
|
15
|
+
if (res.isErr())
|
|
16
|
+
throw res.unwrapErr();
|
|
17
|
+
return { vault: res.unwrap().address };
|
|
18
|
+
};
|
|
19
|
+
exports.getThorTxData = getThorTxData;
|