@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
|
@@ -3,91 +3,77 @@ import type { Address, Hex } from 'viem';
|
|
|
3
3
|
export declare const bebopSupportedEvmChainIds: readonly [KnownChainIds.EthereumMainnet, KnownChainIds.PolygonMainnet, KnownChainIds.ArbitrumMainnet, KnownChainIds.BaseMainnet, KnownChainIds.AvalancheMainnet, KnownChainIds.OptimismMainnet, KnownChainIds.BnbSmartChainMainnet];
|
|
4
4
|
export declare const bebopSupportedChainIds: readonly [KnownChainIds.EthereumMainnet, KnownChainIds.PolygonMainnet, KnownChainIds.ArbitrumMainnet, KnownChainIds.BaseMainnet, KnownChainIds.AvalancheMainnet, KnownChainIds.OptimismMainnet, KnownChainIds.BnbSmartChainMainnet, KnownChainIds.SolanaMainnet];
|
|
5
5
|
export type BebopSupportedChainId = (typeof bebopSupportedChainIds)[number];
|
|
6
|
-
export type
|
|
6
|
+
export type BebopQuoteResponse = {
|
|
7
|
+
requestId: string;
|
|
7
8
|
type: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
status: string;
|
|
10
|
+
quoteId: string;
|
|
11
|
+
chainId: number;
|
|
12
|
+
approvalType: 'Standard' | 'Permit' | 'Permit2';
|
|
13
|
+
nativeToken: string;
|
|
14
|
+
taker: Address;
|
|
15
|
+
receiver: Address;
|
|
16
|
+
expiry: number;
|
|
17
|
+
slippage: number;
|
|
18
|
+
gasFee: {
|
|
19
|
+
native: string;
|
|
20
|
+
usd: number;
|
|
21
|
+
};
|
|
22
|
+
buyTokens: Record<Address, {
|
|
23
|
+
amount: string;
|
|
24
|
+
decimals: number;
|
|
25
|
+
priceUsd: number;
|
|
26
|
+
symbol: string;
|
|
27
|
+
minimumAmount: string;
|
|
28
|
+
price: number;
|
|
29
|
+
priceBeforeFee: number;
|
|
30
|
+
amountBeforeFee: string;
|
|
31
|
+
deltaFromExpected: number;
|
|
32
|
+
}>;
|
|
33
|
+
sellTokens: Record<Address, {
|
|
34
|
+
amount: string;
|
|
35
|
+
decimals: number;
|
|
36
|
+
priceUsd: number;
|
|
37
|
+
symbol: string;
|
|
38
|
+
price: number;
|
|
39
|
+
priceBeforeFee: number;
|
|
40
|
+
}>;
|
|
41
|
+
settlementAddress: Address;
|
|
42
|
+
approvalTarget: Address;
|
|
43
|
+
requiredSignatures: string[];
|
|
44
|
+
priceImpact: number;
|
|
45
|
+
warnings: string[];
|
|
46
|
+
toSign: {
|
|
47
|
+
partner_id: number;
|
|
18
48
|
expiry: number;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
symbol: string;
|
|
29
|
-
minimumAmount: string;
|
|
30
|
-
price: number;
|
|
31
|
-
priceBeforeFee: number;
|
|
32
|
-
amountBeforeFee: string;
|
|
33
|
-
deltaFromExpected: number;
|
|
34
|
-
}>;
|
|
35
|
-
sellTokens: Record<Address, {
|
|
36
|
-
amount: string;
|
|
37
|
-
decimals: number;
|
|
38
|
-
priceUsd: number;
|
|
39
|
-
symbol: string;
|
|
40
|
-
price: number;
|
|
41
|
-
priceBeforeFee: number;
|
|
42
|
-
}>;
|
|
43
|
-
settlementAddress: Address;
|
|
44
|
-
approvalTarget: Address;
|
|
45
|
-
requiredSignatures: string[];
|
|
46
|
-
priceImpact: number;
|
|
47
|
-
warnings: string[];
|
|
48
|
-
toSign: {
|
|
49
|
-
partner_id: number;
|
|
50
|
-
expiry: number;
|
|
51
|
-
taker_address: Address;
|
|
52
|
-
maker_address: Address;
|
|
53
|
-
maker_nonce: string;
|
|
54
|
-
taker_token: Address;
|
|
55
|
-
maker_token: Address;
|
|
56
|
-
taker_amount: string;
|
|
57
|
-
maker_amount: string;
|
|
58
|
-
receiver: Address;
|
|
59
|
-
packed_commands: string;
|
|
60
|
-
};
|
|
61
|
-
onchainOrderType?: string;
|
|
62
|
-
solver?: string;
|
|
63
|
-
makers?: string[];
|
|
64
|
-
partialFillOffset?: number;
|
|
65
|
-
tx: {
|
|
66
|
-
to: Address;
|
|
67
|
-
from: Address;
|
|
68
|
-
data: Hex;
|
|
69
|
-
value: Hex;
|
|
70
|
-
gas?: number;
|
|
71
|
-
gasPrice?: number;
|
|
72
|
-
};
|
|
73
|
-
partnerFee?: Record<Address, string>;
|
|
74
|
-
protocolFee?: Record<Address, string>;
|
|
49
|
+
taker_address: Address;
|
|
50
|
+
maker_address: Address;
|
|
51
|
+
maker_nonce: string;
|
|
52
|
+
taker_token: Address;
|
|
53
|
+
maker_token: Address;
|
|
54
|
+
taker_amount: string;
|
|
55
|
+
maker_amount: string;
|
|
56
|
+
receiver: Address;
|
|
57
|
+
packed_commands: string;
|
|
75
58
|
};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
59
|
+
onchainOrderType?: string;
|
|
60
|
+
solver?: string;
|
|
61
|
+
makers?: string[];
|
|
62
|
+
partialFillOffset?: number;
|
|
63
|
+
tx: {
|
|
64
|
+
to: Address;
|
|
65
|
+
from: Address;
|
|
66
|
+
data: Hex;
|
|
67
|
+
value: Hex;
|
|
68
|
+
gas?: number;
|
|
69
|
+
gasPrice?: number;
|
|
70
|
+
};
|
|
71
|
+
partnerFee?: Record<Address, string>;
|
|
72
|
+
protocolFee?: Record<Address, string>;
|
|
87
73
|
};
|
|
88
74
|
export declare const chainIdToBebopChain: Record<BebopSupportedChainId, string>;
|
|
89
75
|
export declare const BEBOP_NATIVE_MARKER = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
90
|
-
export declare const BEBOP_DUMMY_ADDRESS:
|
|
76
|
+
export declare const BEBOP_DUMMY_ADDRESS: `0x${string}`;
|
|
91
77
|
export declare const BEBOP_SOLANA_DUMMY_ADDRESS = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
92
78
|
export type BebopSolanaQuoteResponse = {
|
|
93
79
|
requestId: string;
|
|
@@ -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 bebopServiceFactory: ({ apiKey, wrapper, }: {
|
|
6
6
|
apiKey: string;
|
|
7
|
-
wrapper?: AxiosInstanceHoF;
|
|
7
|
+
wrapper?: AxiosInstanceHoF | undefined;
|
|
8
8
|
}) => MonadicSwapperAxiosService;
|
|
9
9
|
export {};
|
|
@@ -10,15 +10,7 @@ export declare const fetchBebopQuote: ({ buyAsset, sellAsset, sellAmountIncludin
|
|
|
10
10
|
takerAddress: Address;
|
|
11
11
|
receiverAddress: Address;
|
|
12
12
|
slippageTolerancePercentageDecimal: string;
|
|
13
|
-
affiliateBps?: string;
|
|
14
|
-
apiKey: string;
|
|
15
|
-
}) => Promise<Result<BebopQuoteResponse, SwapErrorRight>>;
|
|
16
|
-
export declare const fetchBebopPrice: ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, receiveAddress, affiliateBps, apiKey, }: {
|
|
17
|
-
buyAsset: Asset;
|
|
18
|
-
sellAsset: Asset;
|
|
19
|
-
sellAmountIncludingProtocolFeesCryptoBaseUnit: string;
|
|
20
|
-
receiveAddress: string | undefined;
|
|
21
|
-
affiliateBps?: string;
|
|
13
|
+
affiliateBps?: string | undefined;
|
|
22
14
|
apiKey: string;
|
|
23
15
|
}) => Promise<Result<BebopQuoteResponse, SwapErrorRight>>;
|
|
24
16
|
export declare const fetchBebopSolanaQuote: ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal, affiliateBps, apiKey, }: {
|
|
@@ -28,14 +20,6 @@ export declare const fetchBebopSolanaQuote: ({ buyAsset, sellAsset, sellAmountIn
|
|
|
28
20
|
takerAddress: string;
|
|
29
21
|
receiverAddress: string;
|
|
30
22
|
slippageTolerancePercentageDecimal: string;
|
|
31
|
-
affiliateBps?: string;
|
|
32
|
-
apiKey: string;
|
|
33
|
-
}) => Promise<Result<BebopSolanaQuoteResponse, SwapErrorRight>>;
|
|
34
|
-
export declare const fetchBebopSolanaPrice: ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, receiveAddress, affiliateBps, apiKey, }: {
|
|
35
|
-
buyAsset: Asset;
|
|
36
|
-
sellAsset: Asset;
|
|
37
|
-
sellAmountIncludingProtocolFeesCryptoBaseUnit: string;
|
|
38
|
-
receiveAddress: string | undefined;
|
|
39
|
-
affiliateBps?: string;
|
|
23
|
+
affiliateBps?: string | undefined;
|
|
40
24
|
apiKey: string;
|
|
41
25
|
}) => Promise<Result<BebopSolanaQuoteResponse, SwapErrorRight>>;
|
|
@@ -1,30 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.fetchBebopSolanaQuote = exports.fetchBebopQuote = void 0;
|
|
4
|
+
const caip_1 = require("@shapeshiftoss/caip");
|
|
4
5
|
const utils_1 = require("@shapeshiftoss/utils");
|
|
5
6
|
const monads_1 = require("@sniptt/monads");
|
|
6
7
|
const viem_1 = require("viem");
|
|
7
8
|
const types_1 = require("../../../types");
|
|
8
9
|
const utils_2 = require("../../../utils");
|
|
10
|
+
const helpers_1 = require("../../utils/helpers/helpers");
|
|
9
11
|
const types_2 = require("../types");
|
|
10
12
|
const bebopService_1 = require("./bebopService");
|
|
11
|
-
const
|
|
13
|
+
const helpers_2 = require("./helpers/helpers");
|
|
12
14
|
const fetchBebopQuote = async ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal, affiliateBps, apiKey, }) => {
|
|
13
15
|
try {
|
|
14
|
-
const sellToken = (0,
|
|
15
|
-
const buyToken = (0,
|
|
16
|
+
const sellToken = (0, helpers_2.assetIdToBebopToken)(sellAsset.assetId);
|
|
17
|
+
const buyToken = (0, helpers_2.assetIdToBebopToken)(buyAsset.assetId);
|
|
16
18
|
const checksummedTakerAddress = (0, viem_1.getAddress)(takerAddress);
|
|
17
19
|
const checksummedReceiverAddress = (0, viem_1.getAddress)(receiverAddress);
|
|
18
20
|
const chainName = types_2.chainIdToBebopChain[sellAsset.chainId];
|
|
19
21
|
const sellAmountFormatted = (0, utils_1.bn)(sellAmountIncludingProtocolFeesCryptoBaseUnit).toFixed(0);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
// See: https://api.bebop.xyz/pmm/ethereum/docs#/v3/quote_v3_quote_get
|
|
23
|
-
const slippagePercentage = (0, utils_1.bn)(slippageTolerancePercentageDecimal ?? 0.003)
|
|
24
|
-
.times(100)
|
|
25
|
-
.toNumber();
|
|
26
|
-
const url = `https://api.bebop.xyz/router/${chainName}/v1/quote`;
|
|
27
|
-
const params = new URLSearchParams({
|
|
22
|
+
const slippagePercentage = (0, utils_1.bn)(slippageTolerancePercentageDecimal).times(100).toNumber();
|
|
23
|
+
const baseParams = {
|
|
28
24
|
sell_tokens: sellToken,
|
|
29
25
|
buy_tokens: buyToken,
|
|
30
26
|
sell_amounts: sellAmountFormatted,
|
|
@@ -35,38 +31,46 @@ const fetchBebopQuote = async ({ buyAsset, sellAsset, sellAmountIncludingProtoco
|
|
|
35
31
|
skip_validation: 'true',
|
|
36
32
|
gasless: 'false',
|
|
37
33
|
source: 'shapeshift',
|
|
38
|
-
}
|
|
34
|
+
};
|
|
35
|
+
const jamParams = new URLSearchParams(baseParams);
|
|
36
|
+
const pmmParams = new URLSearchParams(baseParams);
|
|
39
37
|
if (affiliateBps && affiliateBps !== '0') {
|
|
40
|
-
|
|
38
|
+
// JAM collects the fee on-chain and requires a recipient
|
|
39
|
+
jamParams.set('fee', affiliateBps);
|
|
40
|
+
jamParams.set('fee_recipient', (0, viem_1.getAddress)((0, helpers_1.getTreasuryAddressFromChainId)(buyAsset.chainId)));
|
|
41
|
+
// PMM attributes the fee off-chain via source
|
|
42
|
+
pmmParams.set('fee', affiliateBps);
|
|
41
43
|
}
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
|
|
44
|
+
const service = (0, bebopService_1.bebopServiceFactory)({ apiKey });
|
|
45
|
+
const [maybeJam, maybePmm] = await Promise.all([
|
|
46
|
+
service.get(`https://api.bebop.xyz/jam/${chainName}/v2/quote`, {
|
|
47
|
+
params: jamParams,
|
|
48
|
+
}),
|
|
49
|
+
service.get(`https://api.bebop.xyz/pmm/${chainName}/v3/quote`, {
|
|
50
|
+
params: pmmParams,
|
|
51
|
+
}),
|
|
52
|
+
]);
|
|
53
|
+
const maybeResponses = [maybeJam, maybePmm];
|
|
54
|
+
if (maybeResponses.every(maybeResponse => maybeResponse.isErr())) {
|
|
45
55
|
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
46
56
|
message: 'Failed to fetch quote from Bebop',
|
|
47
|
-
cause:
|
|
57
|
+
cause: maybeResponses[0].unwrapErr().cause,
|
|
48
58
|
code: types_1.TradeQuoteError.QueryFailed,
|
|
49
59
|
}));
|
|
50
60
|
}
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
// Validate response has routes - only fail if there are NO valid routes
|
|
57
|
-
if (!response.data.routes || response.data.routes.length === 0) {
|
|
61
|
+
const quotes = maybeResponses
|
|
62
|
+
.filter(maybeResponse => maybeResponse.isOk())
|
|
63
|
+
.map(maybeResponse => maybeResponse.unwrap().data)
|
|
64
|
+
.filter(quote => Boolean(quote.tx?.data));
|
|
65
|
+
if (!quotes.length) {
|
|
58
66
|
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
59
|
-
message: 'No
|
|
67
|
+
message: 'No route available',
|
|
60
68
|
code: types_1.TradeQuoteError.NoRouteFound,
|
|
61
69
|
}));
|
|
62
70
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
code: types_1.TradeQuoteError.InvalidResponse,
|
|
67
|
-
}));
|
|
68
|
-
}
|
|
69
|
-
return (0, monads_1.Ok)(response.data);
|
|
71
|
+
const getBuyAmount = (quote) => (0, utils_1.bnOrZero)(Object.values(quote.buyTokens)[0]?.amount);
|
|
72
|
+
const bestQuote = quotes.reduce((best, quote) => getBuyAmount(quote).gt(getBuyAmount(best)) ? quote : best);
|
|
73
|
+
return (0, monads_1.Ok)(bestQuote);
|
|
70
74
|
}
|
|
71
75
|
catch (error) {
|
|
72
76
|
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
@@ -77,29 +81,20 @@ const fetchBebopQuote = async ({ buyAsset, sellAsset, sellAmountIncludingProtoco
|
|
|
77
81
|
}
|
|
78
82
|
};
|
|
79
83
|
exports.fetchBebopQuote = fetchBebopQuote;
|
|
80
|
-
const fetchBebopPrice = ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, receiveAddress, affiliateBps, apiKey, }) => {
|
|
81
|
-
const address = receiveAddress || types_2.BEBOP_DUMMY_ADDRESS;
|
|
82
|
-
return (0, exports.fetchBebopQuote)({
|
|
83
|
-
buyAsset,
|
|
84
|
-
sellAsset,
|
|
85
|
-
sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
86
|
-
takerAddress: address,
|
|
87
|
-
receiverAddress: address,
|
|
88
|
-
slippageTolerancePercentageDecimal: '0.01',
|
|
89
|
-
affiliateBps,
|
|
90
|
-
apiKey,
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
exports.fetchBebopPrice = fetchBebopPrice;
|
|
94
84
|
const fetchBebopSolanaQuote = async ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal, affiliateBps, apiKey, }) => {
|
|
95
85
|
try {
|
|
96
|
-
|
|
97
|
-
|
|
86
|
+
// Bebop's Solana routes don't wrap native SOL on the input side, so selling native SOL
|
|
87
|
+
// always fails on-chain. Reject up front instead of returning an unexecutable quote.
|
|
88
|
+
if (sellAsset.assetId === caip_1.solAssetId) {
|
|
89
|
+
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
90
|
+
message: 'Bebop Solana cannot sell native SOL',
|
|
91
|
+
code: types_1.TradeQuoteError.NoRouteFound,
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
const sellToken = (0, helpers_2.assetIdToBebopSolanaToken)(sellAsset.assetId);
|
|
95
|
+
const buyToken = (0, helpers_2.assetIdToBebopSolanaToken)(buyAsset.assetId);
|
|
98
96
|
const sellAmountFormatted = (0, utils_1.bn)(sellAmountIncludingProtocolFeesCryptoBaseUnit).toFixed(0);
|
|
99
|
-
const slippagePercentage = (0, utils_1.bn)(slippageTolerancePercentageDecimal
|
|
100
|
-
.times(100)
|
|
101
|
-
.toNumber();
|
|
102
|
-
const url = 'https://api.bebop.xyz/pmm/solana/v3/quote';
|
|
97
|
+
const slippagePercentage = (0, utils_1.bn)(slippageTolerancePercentageDecimal).times(100).toNumber();
|
|
103
98
|
const params = new URLSearchParams({
|
|
104
99
|
sell_tokens: sellToken,
|
|
105
100
|
buy_tokens: buyToken,
|
|
@@ -115,8 +110,7 @@ const fetchBebopSolanaQuote = async ({ buyAsset, sellAsset, sellAmountIncludingP
|
|
|
115
110
|
if (affiliateBps && affiliateBps !== '0') {
|
|
116
111
|
params.set('fee', affiliateBps);
|
|
117
112
|
}
|
|
118
|
-
const
|
|
119
|
-
const maybeResponse = await bebopService.get(`${url}?${params}`);
|
|
113
|
+
const maybeResponse = await (0, bebopService_1.bebopServiceFactory)({ apiKey }).get('https://api.bebop.xyz/pmm/solana/v3/quote', { params });
|
|
120
114
|
if (maybeResponse.isErr()) {
|
|
121
115
|
const err = maybeResponse.unwrapErr();
|
|
122
116
|
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
@@ -138,19 +132,6 @@ const fetchBebopSolanaQuote = async ({ buyAsset, sellAsset, sellAmountIncludingP
|
|
|
138
132
|
code: types_1.TradeQuoteError.InvalidResponse,
|
|
139
133
|
}));
|
|
140
134
|
}
|
|
141
|
-
// Reject routes containing ANY AMM/CLMM makers - these produce malformed txs
|
|
142
|
-
// (wrong signature count in wire format) and require pre-existing ATAs that
|
|
143
|
-
// Bebop's gasless co-signed flow can't create. This includes mixed routes
|
|
144
|
-
// like ["raydium clmm-rfqm", "🦊"] where Bebop serializes the tx with fewer
|
|
145
|
-
// signature slots than the message header requires.
|
|
146
|
-
// When rejected, other swappers like Jupiter will handle these pairs instead.
|
|
147
|
-
const hasAmmRoute = response.data.makers.some(maker => maker.toLowerCase().includes('clmm') || maker.toLowerCase().includes('amm'));
|
|
148
|
-
if (hasAmmRoute) {
|
|
149
|
-
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
150
|
-
message: `Bebop Solana quote contains AMM routing (${response.data.makers.join(', ')}), which produces malformed txs`,
|
|
151
|
-
code: types_1.TradeQuoteError.NoRouteFound,
|
|
152
|
-
}));
|
|
153
|
-
}
|
|
154
135
|
return (0, monads_1.Ok)(response.data);
|
|
155
136
|
}
|
|
156
137
|
catch (error) {
|
|
@@ -162,17 +143,3 @@ const fetchBebopSolanaQuote = async ({ buyAsset, sellAsset, sellAmountIncludingP
|
|
|
162
143
|
}
|
|
163
144
|
};
|
|
164
145
|
exports.fetchBebopSolanaQuote = fetchBebopSolanaQuote;
|
|
165
|
-
const fetchBebopSolanaPrice = ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, receiveAddress, affiliateBps, apiKey, }) => {
|
|
166
|
-
const address = receiveAddress || types_2.BEBOP_SOLANA_DUMMY_ADDRESS;
|
|
167
|
-
return (0, exports.fetchBebopSolanaQuote)({
|
|
168
|
-
buyAsset,
|
|
169
|
-
sellAsset,
|
|
170
|
-
sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
171
|
-
takerAddress: address,
|
|
172
|
-
receiverAddress: address,
|
|
173
|
-
slippageTolerancePercentageDecimal: '0.01',
|
|
174
|
-
affiliateBps,
|
|
175
|
-
apiKey,
|
|
176
|
-
});
|
|
177
|
-
};
|
|
178
|
-
exports.fetchBebopSolanaPrice = fetchBebopSolanaPrice;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { AssetId, ChainId } from '@shapeshiftoss/caip';
|
|
2
2
|
import type { Asset } from '@shapeshiftoss/types';
|
|
3
|
-
import type { BebopSupportedChainId } from '../../types';
|
|
4
3
|
export declare const isSolanaChainId: (chainId: ChainId) => boolean;
|
|
5
4
|
export declare const assetIdToBebopToken: (assetId: AssetId) => string;
|
|
6
5
|
export declare const assetIdToBebopSolanaToken: (assetId: AssetId) => string;
|
|
7
|
-
export declare const isSupportedChainId: (chainId: ChainId) => chainId is
|
|
6
|
+
export declare const isSupportedChainId: (chainId: ChainId) => chainId is import("@shapeshiftoss/types").KnownChainIds.EthereumMainnet | import("@shapeshiftoss/types").KnownChainIds.AvalancheMainnet | import("@shapeshiftoss/types").KnownChainIds.OptimismMainnet | import("@shapeshiftoss/types").KnownChainIds.BnbSmartChainMainnet | import("@shapeshiftoss/types").KnownChainIds.PolygonMainnet | import("@shapeshiftoss/types").KnownChainIds.ArbitrumMainnet | import("@shapeshiftoss/types").KnownChainIds.BaseMainnet | import("@shapeshiftoss/types").KnownChainIds.SolanaMainnet;
|
|
8
7
|
export declare const assertValidTrade: ({ buyAsset, sellAsset, }: {
|
|
9
8
|
buyAsset: Asset;
|
|
10
9
|
sellAsset: Asset;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bobGatewaySwapper = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
exports.bobGatewaySwapper = {
|
|
6
|
+
executeEvmTransaction: utils_1.executeEvmTransaction,
|
|
7
|
+
executeUtxoTransaction: (txToSign, { signAndBroadcastTransaction }) => signAndBroadcastTransaction(txToSign),
|
|
8
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bobGatewayApi = void 0;
|
|
4
|
+
const bob_sdk_1 = require("@gobob/bob-sdk");
|
|
5
|
+
const chain_adapters_1 = require("@shapeshiftoss/chain-adapters");
|
|
6
|
+
const unchained_client_1 = require("@shapeshiftoss/unchained-client");
|
|
7
|
+
const utils_1 = require("@shapeshiftoss/utils");
|
|
8
|
+
const utils_2 = require("../../utils");
|
|
9
|
+
const getTradeQuote_1 = require("./swapperApi/getTradeQuote");
|
|
10
|
+
const getTradeRate_1 = require("./swapperApi/getTradeRate");
|
|
11
|
+
const helpers_1 = require("./utils/helpers");
|
|
12
|
+
const registeredSwapIds = new Set();
|
|
13
|
+
exports.bobGatewayApi = {
|
|
14
|
+
getTradeRate: async (input, deps) => {
|
|
15
|
+
return (await (0, getTradeRate_1.getBobGatewayTradeRate)(input, deps)).map(tradeRate => [tradeRate]);
|
|
16
|
+
},
|
|
17
|
+
getTradeQuote: async (input, deps) => {
|
|
18
|
+
return (await (0, getTradeQuote_1.getBobGatewayTradeQuote)(input, deps)).map(tradeQuote => [tradeQuote]);
|
|
19
|
+
},
|
|
20
|
+
getUnsignedUtxoTransaction: ({ stepIndex, tradeQuote, xpub, accountType, assertGetUtxoChainAdapter, }) => {
|
|
21
|
+
if (!(0, utils_2.isExecutableTradeQuote)(tradeQuote)) {
|
|
22
|
+
throw new Error('[BobGateway] unable to execute a trade rate');
|
|
23
|
+
}
|
|
24
|
+
const step = (0, utils_2.getExecutableTradeStep)(tradeQuote, stepIndex);
|
|
25
|
+
const { bobSpecific, sellAsset } = step;
|
|
26
|
+
const adapter = assertGetUtxoChainAdapter(sellAsset.chainId);
|
|
27
|
+
if (!bobSpecific?.utxoTx)
|
|
28
|
+
throw new Error('[BobGateway] invalid utxo transaction');
|
|
29
|
+
const { depositAddress, opReturnData } = bobSpecific.utxoTx;
|
|
30
|
+
return adapter.buildSendApiTransaction({
|
|
31
|
+
value: step.sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
32
|
+
xpub,
|
|
33
|
+
to: depositAddress,
|
|
34
|
+
accountNumber: step.accountNumber,
|
|
35
|
+
skipToAddressValidation: true,
|
|
36
|
+
chainSpecific: {
|
|
37
|
+
accountType,
|
|
38
|
+
opReturnData,
|
|
39
|
+
satoshiPerByte: step.feeData.chainSpecific.satsPerByte,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
getUtxoTransactionFees: async ({ stepIndex, tradeQuote, xpub, assertGetUtxoChainAdapter }) => {
|
|
44
|
+
if (!(0, utils_2.isExecutableTradeQuote)(tradeQuote)) {
|
|
45
|
+
throw new Error('[BobGateway] unable to execute a trade rate');
|
|
46
|
+
}
|
|
47
|
+
const step = (0, utils_2.getExecutableTradeStep)(tradeQuote, stepIndex);
|
|
48
|
+
const { bobSpecific, sellAsset } = step;
|
|
49
|
+
const adapter = assertGetUtxoChainAdapter(sellAsset.chainId);
|
|
50
|
+
if (!bobSpecific?.utxoTx)
|
|
51
|
+
throw new Error('[BobGateway] invalid utxo transaction');
|
|
52
|
+
const { depositAddress, opReturnData } = bobSpecific.utxoTx;
|
|
53
|
+
const { fast } = await adapter.getFeeData({
|
|
54
|
+
to: depositAddress,
|
|
55
|
+
value: step.sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
56
|
+
chainSpecific: { pubkey: xpub, opReturnData },
|
|
57
|
+
sendMax: false,
|
|
58
|
+
});
|
|
59
|
+
return fast.txFee;
|
|
60
|
+
},
|
|
61
|
+
getUnsignedEvmTransaction: async ({ from, stepIndex, tradeQuote, assertGetEvmChainAdapter, supportsEIP1559, }) => {
|
|
62
|
+
if (!(0, utils_2.isExecutableTradeQuote)(tradeQuote)) {
|
|
63
|
+
throw new Error('[BobGateway] unable to execute a trade rate');
|
|
64
|
+
}
|
|
65
|
+
const step = (0, utils_2.getExecutableTradeStep)(tradeQuote, stepIndex);
|
|
66
|
+
const { accountNumber, bobSpecific, sellAsset } = step;
|
|
67
|
+
const adapter = assertGetEvmChainAdapter(sellAsset.chainId);
|
|
68
|
+
if (!bobSpecific?.evmTx)
|
|
69
|
+
throw new Error('[BobGateway] invalid evm transaction');
|
|
70
|
+
const { to, data, value } = bobSpecific.evmTx;
|
|
71
|
+
const feeData = await chain_adapters_1.evm.getFees({ adapter, data, to, value, from, supportsEIP1559 });
|
|
72
|
+
// Pad the gas limit of the tx we actually broadcast to reduce the risk of out-of-gas reverts.
|
|
73
|
+
const gasLimit = (0, utils_1.bnOrZero)(feeData.gasLimit).times(1.2).toFixed(0);
|
|
74
|
+
return adapter.buildCustomApiTx({
|
|
75
|
+
accountNumber,
|
|
76
|
+
from,
|
|
77
|
+
to,
|
|
78
|
+
value,
|
|
79
|
+
data,
|
|
80
|
+
...feeData,
|
|
81
|
+
gasLimit,
|
|
82
|
+
});
|
|
83
|
+
},
|
|
84
|
+
getEvmTransactionFees: async ({ from, stepIndex, tradeQuote, supportsEIP1559, assertGetEvmChainAdapter, }) => {
|
|
85
|
+
if (!(0, utils_2.isExecutableTradeQuote)(tradeQuote)) {
|
|
86
|
+
throw new Error('[BobGateway] unable to execute a trade rate');
|
|
87
|
+
}
|
|
88
|
+
const step = (0, utils_2.getExecutableTradeStep)(tradeQuote, stepIndex);
|
|
89
|
+
const { bobSpecific, sellAsset } = step;
|
|
90
|
+
const adapter = assertGetEvmChainAdapter(sellAsset.chainId);
|
|
91
|
+
if (!bobSpecific?.evmTx)
|
|
92
|
+
throw new Error('[BobGateway] invalid evm transaction');
|
|
93
|
+
const { to, data, value } = bobSpecific.evmTx;
|
|
94
|
+
const feeData = await chain_adapters_1.evm.getFees({ adapter, data, to, value, from, supportsEIP1559 });
|
|
95
|
+
return feeData.networkFeeCryptoBaseUnit;
|
|
96
|
+
},
|
|
97
|
+
checkTradeStatus: async ({ swap, config, txHash }) => {
|
|
98
|
+
if (!swap)
|
|
99
|
+
throw new Error('[BobGateway] swap is required for status check');
|
|
100
|
+
const orderId = swap.metadata.bobSpecific?.orderId;
|
|
101
|
+
if (!orderId)
|
|
102
|
+
throw new Error('[BobGateway] orderId is required for status check');
|
|
103
|
+
if (txHash && !registeredSwapIds.has(swap.id)) {
|
|
104
|
+
try {
|
|
105
|
+
await (0, helpers_1.registerBobGatewayTx)({
|
|
106
|
+
config,
|
|
107
|
+
orderId,
|
|
108
|
+
txHash,
|
|
109
|
+
sellAsset: swap.sellAsset,
|
|
110
|
+
buyAsset: swap.buyAsset,
|
|
111
|
+
});
|
|
112
|
+
registeredSwapIds.add(swap.id);
|
|
113
|
+
}
|
|
114
|
+
catch { }
|
|
115
|
+
}
|
|
116
|
+
let orderInfo;
|
|
117
|
+
try {
|
|
118
|
+
orderInfo = await (0, helpers_1.getBobGatewayClient)(config).getOrder(orderId);
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
if ((0, bob_sdk_1.isGatewayError)(err)) {
|
|
122
|
+
if (err.code === 'ORDER_NOT_FOUND') {
|
|
123
|
+
return {
|
|
124
|
+
buyTxHash: undefined,
|
|
125
|
+
status: unchained_client_1.TxStatus.Unknown,
|
|
126
|
+
message: 'Waiting for deposit...',
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
throw err;
|
|
131
|
+
}
|
|
132
|
+
const status = (0, helpers_1.mapBobGatewayOrderStatusToTxStatus)(orderInfo.status);
|
|
133
|
+
const buyTxHash = 'success' in orderInfo.status ? orderInfo.status.success.receivedTokens[0]?.txHash : undefined;
|
|
134
|
+
const refundTxHash = 'refunded' in orderInfo.status
|
|
135
|
+
? orderInfo.status.refunded.refundedTokens[0]?.txHash
|
|
136
|
+
: undefined;
|
|
137
|
+
return {
|
|
138
|
+
status,
|
|
139
|
+
buyTxHash,
|
|
140
|
+
message: refundTxHash ? 'Trade refunded' : undefined,
|
|
141
|
+
};
|
|
142
|
+
},
|
|
143
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.bobGatewaySwapper = exports.bobGatewayApi = void 0;
|
|
18
|
+
var endpoints_1 = require("./endpoints");
|
|
19
|
+
Object.defineProperty(exports, "bobGatewayApi", { enumerable: true, get: function () { return endpoints_1.bobGatewayApi; } });
|
|
20
|
+
var BobGatewaySwapper_1 = require("./BobGatewaySwapper");
|
|
21
|
+
Object.defineProperty(exports, "bobGatewaySwapper", { enumerable: true, get: function () { return BobGatewaySwapper_1.bobGatewaySwapper; } });
|
|
22
|
+
__exportStar(require("./utils/constants"), exports);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Result } from '@sniptt/monads';
|
|
2
|
+
import type { CommonTradeQuoteInput, SwapErrorRight, SwapperDeps, TradeQuote } from '../../../types';
|
|
3
|
+
export declare const getBobGatewayTradeQuote: (input: CommonTradeQuoteInput, deps: SwapperDeps) => Promise<Result<TradeQuote, SwapErrorRight>>;
|