@shapeshiftoss/swapper 20.2.0 → 20.4.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 +15 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/swappers/ArbitrumBridgeSwapper/getTradeQuote/getTradeQuote.js +0 -2
- package/dist/cjs/swappers/AvnuSwapper/swapperApi/getTradeQuote.js +1 -2
- package/dist/cjs/swappers/BebopSwapper/utils/fetchFromBebop.d.ts +2 -1
- package/dist/cjs/swappers/BebopSwapper/utils/fetchFromBebop.js +21 -15
- package/dist/cjs/swappers/BebopSwapper/utils/getBebopSolanaTradeContext.js +1 -0
- package/dist/cjs/swappers/BobGatewaySwapper/BobGatewaySwapper.js +10 -1
- package/dist/cjs/swappers/BobGatewaySwapper/endpoints.js +2 -33
- package/dist/cjs/swappers/BobGatewaySwapper/swapperApi/getTradeQuote.js +5 -10
- package/dist/cjs/swappers/BobGatewaySwapper/swapperApi/getTradeRate.js +1 -2
- package/dist/cjs/swappers/BobGatewaySwapper/types.d.ts +3 -3
- package/dist/cjs/swappers/BobGatewaySwapper/utils/constants.d.ts +3 -2
- package/dist/cjs/swappers/BobGatewaySwapper/utils/constants.js +8 -5
- package/dist/cjs/swappers/BobGatewaySwapper/utils/getBobGatewayStepData.d.ts +2 -2
- package/dist/cjs/swappers/BobGatewaySwapper/utils/getBobGatewayStepData.js +30 -34
- package/dist/cjs/swappers/BobGatewaySwapper/utils/getBobGatewayStepData.test.d.ts +1 -0
- package/dist/cjs/swappers/BobGatewaySwapper/utils/getBobGatewayStepData.test.js +117 -0
- package/dist/cjs/swappers/BobGatewaySwapper/utils/getBobGatewayTradeContext.js +1 -2
- package/dist/cjs/swappers/BobGatewaySwapper/utils/helpers.d.ts +8 -11
- package/dist/cjs/swappers/BobGatewaySwapper/utils/helpers.js +36 -31
- package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeQuote.js +2 -5
- package/dist/cjs/swappers/ButterSwap/types.d.ts +0 -11
- package/dist/cjs/swappers/ButterSwap/utils/constants.d.ts +2 -0
- package/dist/cjs/swappers/ButterSwap/utils/constants.js +4 -1
- package/dist/cjs/swappers/ButterSwap/utils/getButterSwapStepData.d.ts +2 -3
- package/dist/cjs/swappers/ButterSwap/utils/getButterSwapStepData.js +42 -14
- package/dist/cjs/swappers/ButterSwap/utils/getButterSwapStepData.test.js +120 -17
- package/dist/cjs/swappers/ButterSwap/utils/helpers.js +1 -2
- package/dist/cjs/swappers/ButterSwap/xhr.js +3 -3
- package/dist/cjs/swappers/CetusSwapper/swapperApi/getTradeQuote.js +0 -2
- package/dist/cjs/swappers/ChainflipSwapper/endpoints.js +3 -19
- package/dist/cjs/swappers/ChainflipSwapper/swapperApi/getTradeQuote.js +1 -2
- package/dist/cjs/swappers/ChainflipSwapper/types.d.ts +1 -0
- package/dist/cjs/swappers/ChainflipSwapper/utils/getChainflipStepData.d.ts +1 -1
- package/dist/cjs/swappers/ChainflipSwapper/utils/getChainflipStepData.js +31 -12
- package/dist/cjs/swappers/DebridgeSwapper/getTradeQuote/getTradeQuote.js +0 -2
- package/dist/cjs/swappers/FyndSwapper/FyndSwapper.d.ts +2 -0
- package/dist/cjs/swappers/FyndSwapper/FyndSwapper.js +5 -0
- package/dist/cjs/swappers/FyndSwapper/endpoints.d.ts +2 -0
- package/dist/cjs/swappers/FyndSwapper/endpoints.js +14 -0
- package/dist/cjs/swappers/FyndSwapper/getTradeQuote/getTradeQuote.d.ts +4 -0
- package/dist/cjs/swappers/FyndSwapper/getTradeQuote/getTradeQuote.js +43 -0
- package/dist/cjs/swappers/FyndSwapper/getTradeRate/getTradeRate.d.ts +4 -0
- package/dist/cjs/swappers/FyndSwapper/getTradeRate/getTradeRate.js +34 -0
- package/dist/cjs/swappers/FyndSwapper/index.d.ts +2 -0
- package/dist/cjs/swappers/FyndSwapper/index.js +7 -0
- package/dist/cjs/swappers/FyndSwapper/types.d.ts +41 -0
- package/dist/cjs/swappers/FyndSwapper/types.js +2 -0
- package/dist/cjs/swappers/FyndSwapper/utils/constants.d.ts +33 -0
- package/dist/cjs/swappers/FyndSwapper/utils/constants.js +38 -0
- package/dist/cjs/swappers/FyndSwapper/utils/fetchFromFynd.d.ts +13 -0
- package/dist/cjs/swappers/FyndSwapper/utils/fetchFromFynd.js +42 -0
- package/dist/cjs/swappers/FyndSwapper/utils/fyndService.d.ts +5 -0
- package/dist/cjs/swappers/FyndSwapper/utils/fyndService.js +9 -0
- package/dist/cjs/swappers/FyndSwapper/utils/getFyndStepData.d.ts +25 -0
- package/dist/cjs/swappers/FyndSwapper/utils/getFyndStepData.js +48 -0
- package/dist/cjs/swappers/FyndSwapper/utils/getFyndTradeContext.d.ts +18 -0
- package/dist/cjs/swappers/FyndSwapper/utils/getFyndTradeContext.js +94 -0
- package/dist/cjs/swappers/FyndSwapper/utils/helpers.d.ts +24 -0
- package/dist/cjs/swappers/FyndSwapper/utils/helpers.js +174 -0
- package/dist/cjs/swappers/FyndSwapper/utils/helpers.test.d.ts +1 -0
- package/dist/cjs/swappers/FyndSwapper/utils/helpers.test.js +101 -0
- package/dist/cjs/swappers/MayachainSwapper/generated/generatedTradableAssetMap.json +0 -1
- package/dist/cjs/swappers/NearIntentsSwapper/constants.d.ts +1 -0
- package/dist/cjs/swappers/NearIntentsSwapper/constants.js +3 -1
- package/dist/cjs/swappers/NearIntentsSwapper/utils/getNearIntentsStepData.js +10 -5
- package/dist/cjs/swappers/NearIntentsSwapper/utils/helpers.js +1 -1
- package/dist/cjs/swappers/PortalsSwapper/endpoints.js +4 -1
- package/dist/cjs/swappers/PortalsSwapper/getPortalsTradeQuote/getPortalsTradeQuote.js +1 -1
- package/dist/cjs/swappers/RelaySwapper/constant.d.ts +1 -1
- package/dist/cjs/swappers/RelaySwapper/constant.js +3 -2
- package/dist/cjs/swappers/RelaySwapper/getTradeQuote/getTradeQuote.js +3 -5
- package/dist/cjs/swappers/RelaySwapper/utils/getRelayAssetAddress.js +2 -1
- package/dist/cjs/swappers/RelaySwapper/utils/getRelayStepData.d.ts +2 -3
- package/dist/cjs/swappers/RelaySwapper/utils/getRelayStepData.js +46 -13
- package/dist/cjs/swappers/RelaySwapper/utils/getRelayStepData.test.d.ts +1 -0
- package/dist/cjs/swappers/RelaySwapper/utils/getRelayStepData.test.js +139 -0
- package/dist/cjs/swappers/RelaySwapper/utils/getRelayTradeContext.d.ts +1 -0
- package/dist/cjs/swappers/RelaySwapper/utils/getRelayTradeContext.js +4 -0
- package/dist/cjs/swappers/RelaySwapper/utils/helpers.js +1 -2
- package/dist/cjs/swappers/RelaySwapper/utils/relayStatus.js +3 -3
- package/dist/cjs/swappers/RelaySwapper/utils/relayTokenToAssetId.js +1 -1
- package/dist/cjs/swappers/RelaySwapper/utils/types.d.ts +10 -8
- package/dist/cjs/swappers/SunioSwapper/endpoints.js +3 -63
- package/dist/cjs/swappers/SunioSwapper/getSunioTradeQuote/getSunioTradeQuote.js +3 -4
- package/dist/cjs/swappers/SunioSwapper/getSunioTradeRate/getSunioTradeRate.js +7 -1
- package/dist/cjs/swappers/SunioSwapper/types.d.ts +0 -3
- package/dist/cjs/swappers/SunioSwapper/utils/buildSwapContractCall.d.ts +11 -6
- package/dist/cjs/swappers/SunioSwapper/utils/buildSwapContractCall.js +33 -30
- package/dist/cjs/swappers/SunioSwapper/utils/constants.d.ts +3 -3
- package/dist/cjs/swappers/SunioSwapper/utils/constants.js +5 -9
- package/dist/cjs/swappers/SunioSwapper/utils/getSunioStepData.d.ts +8 -3
- package/dist/cjs/swappers/SunioSwapper/utils/getSunioStepData.js +54 -20
- package/dist/cjs/swappers/SunioSwapper/utils/getSunioStepData.test.d.ts +1 -0
- package/dist/cjs/swappers/SunioSwapper/utils/getSunioStepData.test.js +177 -0
- package/dist/cjs/swappers/SunioSwapper/utils/getSunioTradeContext.js +3 -2
- package/dist/cjs/swappers/SunioSwapper/utils/helpers.js +2 -1
- package/dist/cjs/swappers/SymbiosisSwapper/SymbiosisSwapper.d.ts +2 -0
- package/dist/cjs/swappers/SymbiosisSwapper/SymbiosisSwapper.js +8 -0
- package/dist/cjs/swappers/SymbiosisSwapper/endpoints.d.ts +2 -0
- package/dist/cjs/swappers/SymbiosisSwapper/endpoints.js +66 -0
- package/dist/cjs/swappers/SymbiosisSwapper/getTradeQuote/getTradeQuote.d.ts +4 -0
- package/dist/cjs/swappers/SymbiosisSwapper/getTradeQuote/getTradeQuote.js +42 -0
- package/dist/cjs/swappers/SymbiosisSwapper/getTradeRate/getTradeRate.d.ts +4 -0
- package/dist/cjs/swappers/SymbiosisSwapper/getTradeRate/getTradeRate.js +34 -0
- package/dist/cjs/swappers/SymbiosisSwapper/index.d.ts +2 -0
- package/dist/cjs/swappers/SymbiosisSwapper/index.js +7 -0
- package/dist/cjs/swappers/SymbiosisSwapper/utils/constants.d.ts +19 -0
- package/dist/cjs/swappers/SymbiosisSwapper/utils/constants.js +64 -0
- package/dist/cjs/swappers/SymbiosisSwapper/utils/getSymbiosisStepData.d.ts +26 -0
- package/dist/cjs/swappers/SymbiosisSwapper/utils/getSymbiosisStepData.js +106 -0
- package/dist/cjs/swappers/SymbiosisSwapper/utils/getSymbiosisStepData.test.d.ts +1 -0
- package/dist/cjs/swappers/SymbiosisSwapper/utils/getSymbiosisStepData.test.js +161 -0
- package/dist/cjs/swappers/SymbiosisSwapper/utils/getSymbiosisTradeContext.d.ts +17 -0
- package/dist/cjs/swappers/SymbiosisSwapper/utils/getSymbiosisTradeContext.js +146 -0
- package/dist/cjs/swappers/SymbiosisSwapper/utils/helpers.d.ts +38 -0
- package/dist/cjs/swappers/SymbiosisSwapper/utils/helpers.js +172 -0
- package/dist/cjs/swappers/SymbiosisSwapper/utils/helpers.test.d.ts +1 -0
- package/dist/cjs/swappers/SymbiosisSwapper/utils/helpers.test.js +151 -0
- package/dist/cjs/swappers/SymbiosisSwapper/utils/symbiosisService.d.ts +5 -0
- package/dist/cjs/swappers/SymbiosisSwapper/utils/symbiosisService.js +18 -0
- package/dist/cjs/swappers/SymbiosisSwapper/utils/types.d.ts +83 -0
- package/dist/cjs/swappers/SymbiosisSwapper/utils/types.js +11 -0
- package/dist/cjs/swappers/ThorchainSwapper/endpoints.js +3 -4
- package/dist/cjs/swappers/ThorchainSwapper/generated/generatedThorLongtailTokens.json +1 -0
- package/dist/cjs/swappers/ThorchainSwapper/generated/generatedTradableAssetMap.json +1 -0
- package/dist/cjs/swappers/ThorchainSwapper/utils/addL1ToLongtailPartsToMemo/addL1ToLongtailPartsToMemo.js +6 -1
- package/dist/cjs/swappers/ThorchainSwapper/utils/addL1ToLongtailPartsToMemo/addL1ToLongtailPartsToMemo.test.js +15 -0
- package/dist/cjs/swappers/ThorchainSwapper/utils/assertValidLongtailTrade.js +7 -0
- package/dist/cjs/swappers/ThorchainSwapper/utils/getL1ToLongtailQuote.js +0 -2
- package/dist/cjs/swappers/ThorchainSwapper/utils/getL1ToLongtailRate.js +0 -2
- package/dist/cjs/swappers/ThorchainSwapper/utils/getLongtailQuote.js +1 -1
- package/dist/cjs/swappers/ThorchainSwapper/utils/getUniqueAddressSubstring/getUniqueAddressSubstring.d.ts +1 -1
- package/dist/cjs/swappers/ThorchainSwapper/utils/getUniqueAddressSubstring/getUniqueAddressSubstring.js +17 -20
- package/dist/cjs/swappers/ThorchainSwapper/utils/getUniqueAddressSubstring/getUniqueAddressSubstring.test.js +31 -0
- package/dist/cjs/swappers/ZrxSwapper/getZrxTradeQuote/getZrxTradeQuote.js +24 -1
- package/dist/cjs/swappers/ZrxSwapper/getZrxTradeQuote/getZrxTradeQuote.test.d.ts +1 -0
- package/dist/cjs/swappers/ZrxSwapper/getZrxTradeQuote/getZrxTradeQuote.test.js +110 -0
- package/dist/cjs/swappers/ZrxSwapper/types.d.ts +2 -1
- package/dist/cjs/swappers/ZrxSwapper/utils/getZrxNativeCheckDeadline.d.ts +1 -0
- package/dist/cjs/swappers/ZrxSwapper/utils/getZrxNativeCheckDeadline.js +26 -0
- package/dist/cjs/types.d.ts +15 -13
- package/dist/cjs/types.js +2 -0
- package/dist/cjs/utils/helpers.d.ts +1 -2
- package/dist/cjs/utils/helpers.js +8 -32
- package/dist/cjs/utils/helpers.test.js +6 -2
- package/dist/cjs/utils/thorchain/getThorStepData.js +32 -49
- package/dist/cjs/utils/thorchain/getThorStepData.tron.test.d.ts +1 -0
- package/dist/cjs/utils/thorchain/getThorStepData.tron.test.js +93 -0
- package/dist/cjs/utils/thorchain/index.d.ts +0 -1
- package/dist/cjs/utils/thorchain/index.js +1 -14
- package/dist/cjs/utils/tron/constants.d.ts +1 -0
- package/dist/cjs/utils/tron/constants.js +5 -0
- package/dist/cjs/utils/tron/getTronNetworkFeeCryptoBaseUnit.d.ts +27 -0
- package/dist/cjs/utils/tron/getTronNetworkFeeCryptoBaseUnit.js +64 -0
- package/dist/cjs/utils/tron/getTronNetworkFeeCryptoBaseUnit.test.d.ts +1 -0
- package/dist/cjs/utils/tron/getTronNetworkFeeCryptoBaseUnit.test.js +157 -0
- package/dist/cjs/utils/tron/getUnsignedTronTransaction.d.ts +2 -1
- package/dist/cjs/utils/tron/getUnsignedTronTransaction.js +14 -48
- package/dist/cjs/utils/tron/getUnsignedTronTransaction.test.d.ts +1 -0
- package/dist/cjs/utils/tron/getUnsignedTronTransaction.test.js +76 -0
- package/dist/cjs/utils/tron/index.d.ts +2 -0
- package/dist/cjs/utils/tron/index.js +2 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/constants.js +15 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/swappers/ArbitrumBridgeSwapper/getTradeQuote/getTradeQuote.js +0 -2
- package/dist/esm/swappers/AvnuSwapper/swapperApi/getTradeQuote.js +1 -2
- package/dist/esm/swappers/BebopSwapper/utils/fetchFromBebop.d.ts +2 -1
- package/dist/esm/swappers/BebopSwapper/utils/fetchFromBebop.js +21 -15
- package/dist/esm/swappers/BebopSwapper/utils/getBebopSolanaTradeContext.js +1 -0
- package/dist/esm/swappers/BobGatewaySwapper/BobGatewaySwapper.js +11 -2
- package/dist/esm/swappers/BobGatewaySwapper/endpoints.js +5 -36
- package/dist/esm/swappers/BobGatewaySwapper/swapperApi/getTradeQuote.js +5 -10
- package/dist/esm/swappers/BobGatewaySwapper/swapperApi/getTradeRate.js +1 -2
- package/dist/esm/swappers/BobGatewaySwapper/types.d.ts +3 -3
- package/dist/esm/swappers/BobGatewaySwapper/utils/constants.d.ts +3 -2
- package/dist/esm/swappers/BobGatewaySwapper/utils/constants.js +8 -7
- package/dist/esm/swappers/BobGatewaySwapper/utils/getBobGatewayStepData.d.ts +2 -2
- package/dist/esm/swappers/BobGatewaySwapper/utils/getBobGatewayStepData.js +21 -25
- package/dist/esm/swappers/BobGatewaySwapper/utils/getBobGatewayStepData.test.d.ts +1 -0
- package/dist/esm/swappers/BobGatewaySwapper/utils/getBobGatewayStepData.test.js +115 -0
- package/dist/esm/swappers/BobGatewaySwapper/utils/getBobGatewayTradeContext.js +1 -2
- package/dist/esm/swappers/BobGatewaySwapper/utils/helpers.d.ts +8 -11
- package/dist/esm/swappers/BobGatewaySwapper/utils/helpers.js +13 -30
- package/dist/esm/swappers/ButterSwap/swapperApi/getTradeQuote.js +2 -5
- package/dist/esm/swappers/ButterSwap/types.d.ts +0 -11
- package/dist/esm/swappers/ButterSwap/utils/constants.d.ts +2 -0
- package/dist/esm/swappers/ButterSwap/utils/constants.js +3 -0
- package/dist/esm/swappers/ButterSwap/utils/getButterSwapStepData.d.ts +2 -3
- package/dist/esm/swappers/ButterSwap/utils/getButterSwapStepData.js +42 -14
- package/dist/esm/swappers/ButterSwap/utils/getButterSwapStepData.test.js +120 -17
- package/dist/esm/swappers/ButterSwap/utils/helpers.js +1 -2
- package/dist/esm/swappers/ButterSwap/xhr.js +3 -3
- package/dist/esm/swappers/CetusSwapper/swapperApi/getTradeQuote.js +0 -2
- package/dist/esm/swappers/ChainflipSwapper/endpoints.js +3 -19
- package/dist/esm/swappers/ChainflipSwapper/swapperApi/getTradeQuote.js +1 -2
- package/dist/esm/swappers/ChainflipSwapper/types.d.ts +1 -0
- package/dist/esm/swappers/ChainflipSwapper/utils/getChainflipStepData.d.ts +1 -1
- package/dist/esm/swappers/ChainflipSwapper/utils/getChainflipStepData.js +32 -13
- package/dist/esm/swappers/DebridgeSwapper/getTradeQuote/getTradeQuote.js +0 -2
- package/dist/esm/swappers/FyndSwapper/FyndSwapper.d.ts +2 -0
- package/dist/esm/swappers/FyndSwapper/FyndSwapper.js +2 -0
- package/dist/esm/swappers/FyndSwapper/endpoints.d.ts +2 -0
- package/dist/esm/swappers/FyndSwapper/endpoints.js +11 -0
- package/dist/esm/swappers/FyndSwapper/getTradeQuote/getTradeQuote.d.ts +4 -0
- package/dist/esm/swappers/FyndSwapper/getTradeQuote/getTradeQuote.js +39 -0
- package/dist/esm/swappers/FyndSwapper/getTradeRate/getTradeRate.d.ts +4 -0
- package/dist/esm/swappers/FyndSwapper/getTradeRate/getTradeRate.js +30 -0
- package/dist/esm/swappers/FyndSwapper/index.d.ts +2 -0
- package/dist/esm/swappers/FyndSwapper/index.js +2 -0
- package/dist/esm/swappers/FyndSwapper/types.d.ts +41 -0
- package/dist/esm/swappers/FyndSwapper/types.js +1 -0
- package/dist/esm/swappers/FyndSwapper/utils/constants.d.ts +33 -0
- package/dist/esm/swappers/FyndSwapper/utils/constants.js +35 -0
- package/dist/esm/swappers/FyndSwapper/utils/fetchFromFynd.d.ts +13 -0
- package/dist/esm/swappers/FyndSwapper/utils/fetchFromFynd.js +38 -0
- package/dist/esm/swappers/FyndSwapper/utils/fyndService.d.ts +5 -0
- package/dist/esm/swappers/FyndSwapper/utils/fyndService.js +3 -0
- package/dist/esm/swappers/FyndSwapper/utils/getFyndStepData.d.ts +25 -0
- package/dist/esm/swappers/FyndSwapper/utils/getFyndStepData.js +44 -0
- package/dist/esm/swappers/FyndSwapper/utils/getFyndTradeContext.d.ts +18 -0
- package/dist/esm/swappers/FyndSwapper/utils/getFyndTradeContext.js +90 -0
- package/dist/esm/swappers/FyndSwapper/utils/helpers.d.ts +24 -0
- package/dist/esm/swappers/FyndSwapper/utils/helpers.js +162 -0
- package/dist/esm/swappers/FyndSwapper/utils/helpers.test.d.ts +1 -0
- package/dist/esm/swappers/FyndSwapper/utils/helpers.test.js +99 -0
- package/dist/esm/swappers/MayachainSwapper/generated/generatedTradableAssetMap.json +0 -1
- package/dist/esm/swappers/NearIntentsSwapper/constants.d.ts +1 -0
- package/dist/esm/swappers/NearIntentsSwapper/constants.js +2 -0
- package/dist/esm/swappers/NearIntentsSwapper/utils/getNearIntentsStepData.js +10 -5
- package/dist/esm/swappers/NearIntentsSwapper/utils/helpers.js +2 -2
- package/dist/esm/swappers/PortalsSwapper/endpoints.js +4 -1
- package/dist/esm/swappers/PortalsSwapper/getPortalsTradeQuote/getPortalsTradeQuote.js +2 -2
- package/dist/esm/swappers/RelaySwapper/constant.d.ts +1 -1
- package/dist/esm/swappers/RelaySwapper/constant.js +2 -1
- package/dist/esm/swappers/RelaySwapper/getTradeQuote/getTradeQuote.js +3 -5
- package/dist/esm/swappers/RelaySwapper/utils/getRelayAssetAddress.js +3 -2
- package/dist/esm/swappers/RelaySwapper/utils/getRelayStepData.d.ts +2 -3
- package/dist/esm/swappers/RelaySwapper/utils/getRelayStepData.js +46 -13
- package/dist/esm/swappers/RelaySwapper/utils/getRelayStepData.test.d.ts +1 -0
- package/dist/esm/swappers/RelaySwapper/utils/getRelayStepData.test.js +137 -0
- package/dist/esm/swappers/RelaySwapper/utils/getRelayTradeContext.d.ts +1 -0
- package/dist/esm/swappers/RelaySwapper/utils/getRelayTradeContext.js +5 -1
- package/dist/esm/swappers/RelaySwapper/utils/helpers.js +1 -2
- package/dist/esm/swappers/RelaySwapper/utils/relayStatus.js +3 -3
- package/dist/esm/swappers/RelaySwapper/utils/relayTokenToAssetId.js +3 -3
- package/dist/esm/swappers/RelaySwapper/utils/types.d.ts +10 -8
- package/dist/esm/swappers/SunioSwapper/endpoints.js +5 -65
- package/dist/esm/swappers/SunioSwapper/getSunioTradeQuote/getSunioTradeQuote.js +3 -4
- package/dist/esm/swappers/SunioSwapper/getSunioTradeRate/getSunioTradeRate.js +7 -1
- package/dist/esm/swappers/SunioSwapper/types.d.ts +0 -3
- package/dist/esm/swappers/SunioSwapper/utils/buildSwapContractCall.d.ts +11 -6
- package/dist/esm/swappers/SunioSwapper/utils/buildSwapContractCall.js +31 -28
- package/dist/esm/swappers/SunioSwapper/utils/constants.d.ts +3 -3
- package/dist/esm/swappers/SunioSwapper/utils/constants.js +4 -8
- package/dist/esm/swappers/SunioSwapper/utils/getSunioStepData.d.ts +8 -3
- package/dist/esm/swappers/SunioSwapper/utils/getSunioStepData.js +52 -18
- package/dist/esm/swappers/SunioSwapper/utils/getSunioStepData.test.d.ts +1 -0
- package/dist/esm/swappers/SunioSwapper/utils/getSunioStepData.test.js +175 -0
- package/dist/esm/swappers/SunioSwapper/utils/getSunioTradeContext.js +2 -1
- package/dist/esm/swappers/SunioSwapper/utils/helpers.js +3 -2
- package/dist/esm/swappers/SymbiosisSwapper/SymbiosisSwapper.d.ts +2 -0
- package/dist/esm/swappers/SymbiosisSwapper/SymbiosisSwapper.js +5 -0
- package/dist/esm/swappers/SymbiosisSwapper/endpoints.d.ts +2 -0
- package/dist/esm/swappers/SymbiosisSwapper/endpoints.js +63 -0
- package/dist/esm/swappers/SymbiosisSwapper/getTradeQuote/getTradeQuote.d.ts +4 -0
- package/dist/esm/swappers/SymbiosisSwapper/getTradeQuote/getTradeQuote.js +38 -0
- package/dist/esm/swappers/SymbiosisSwapper/getTradeRate/getTradeRate.d.ts +4 -0
- package/dist/esm/swappers/SymbiosisSwapper/getTradeRate/getTradeRate.js +30 -0
- package/dist/esm/swappers/SymbiosisSwapper/index.d.ts +2 -0
- package/dist/esm/swappers/SymbiosisSwapper/index.js +2 -0
- package/dist/esm/swappers/SymbiosisSwapper/utils/constants.d.ts +19 -0
- package/dist/esm/swappers/SymbiosisSwapper/utils/constants.js +61 -0
- package/dist/esm/swappers/SymbiosisSwapper/utils/getSymbiosisStepData.d.ts +26 -0
- package/dist/esm/swappers/SymbiosisSwapper/utils/getSymbiosisStepData.js +102 -0
- package/dist/esm/swappers/SymbiosisSwapper/utils/getSymbiosisStepData.test.d.ts +1 -0
- package/dist/esm/swappers/SymbiosisSwapper/utils/getSymbiosisStepData.test.js +159 -0
- package/dist/esm/swappers/SymbiosisSwapper/utils/getSymbiosisTradeContext.d.ts +17 -0
- package/dist/esm/swappers/SymbiosisSwapper/utils/getSymbiosisTradeContext.js +139 -0
- package/dist/esm/swappers/SymbiosisSwapper/utils/helpers.d.ts +38 -0
- package/dist/esm/swappers/SymbiosisSwapper/utils/helpers.js +156 -0
- package/dist/esm/swappers/SymbiosisSwapper/utils/helpers.test.d.ts +1 -0
- package/dist/esm/swappers/SymbiosisSwapper/utils/helpers.test.js +149 -0
- package/dist/esm/swappers/SymbiosisSwapper/utils/symbiosisService.d.ts +5 -0
- package/dist/esm/swappers/SymbiosisSwapper/utils/symbiosisService.js +12 -0
- package/dist/esm/swappers/SymbiosisSwapper/utils/types.d.ts +83 -0
- package/dist/esm/swappers/SymbiosisSwapper/utils/types.js +8 -0
- package/dist/esm/swappers/ThorchainSwapper/endpoints.js +4 -5
- package/dist/esm/swappers/ThorchainSwapper/generated/generatedThorLongtailTokens.json +1 -0
- package/dist/esm/swappers/ThorchainSwapper/generated/generatedTradableAssetMap.json +1 -0
- package/dist/esm/swappers/ThorchainSwapper/utils/addL1ToLongtailPartsToMemo/addL1ToLongtailPartsToMemo.js +6 -1
- package/dist/esm/swappers/ThorchainSwapper/utils/addL1ToLongtailPartsToMemo/addL1ToLongtailPartsToMemo.test.js +15 -0
- package/dist/esm/swappers/ThorchainSwapper/utils/assertValidLongtailTrade.js +7 -0
- package/dist/esm/swappers/ThorchainSwapper/utils/getL1ToLongtailQuote.js +0 -2
- package/dist/esm/swappers/ThorchainSwapper/utils/getL1ToLongtailRate.js +0 -2
- package/dist/esm/swappers/ThorchainSwapper/utils/getLongtailQuote.js +1 -1
- package/dist/esm/swappers/ThorchainSwapper/utils/getUniqueAddressSubstring/getUniqueAddressSubstring.d.ts +1 -1
- package/dist/esm/swappers/ThorchainSwapper/utils/getUniqueAddressSubstring/getUniqueAddressSubstring.js +17 -20
- package/dist/esm/swappers/ThorchainSwapper/utils/getUniqueAddressSubstring/getUniqueAddressSubstring.test.js +29 -1
- package/dist/esm/swappers/ZrxSwapper/getZrxTradeQuote/getZrxTradeQuote.js +25 -2
- package/dist/esm/swappers/ZrxSwapper/getZrxTradeQuote/getZrxTradeQuote.test.d.ts +1 -0
- package/dist/esm/swappers/ZrxSwapper/getZrxTradeQuote/getZrxTradeQuote.test.js +108 -0
- package/dist/esm/swappers/ZrxSwapper/types.d.ts +2 -1
- package/dist/esm/swappers/ZrxSwapper/utils/getZrxNativeCheckDeadline.d.ts +1 -0
- package/dist/esm/swappers/ZrxSwapper/utils/getZrxNativeCheckDeadline.js +22 -0
- package/dist/esm/types.d.ts +15 -13
- package/dist/esm/types.js +2 -0
- package/dist/esm/utils/helpers.d.ts +1 -2
- package/dist/esm/utils/helpers.js +9 -33
- package/dist/esm/utils/helpers.test.js +6 -2
- package/dist/esm/utils/thorchain/getThorStepData.js +32 -49
- package/dist/esm/utils/thorchain/getThorStepData.tron.test.d.ts +1 -0
- package/dist/esm/utils/thorchain/getThorStepData.tron.test.js +91 -0
- package/dist/esm/utils/thorchain/index.d.ts +0 -1
- package/dist/esm/utils/thorchain/index.js +0 -1
- package/dist/esm/utils/tron/constants.d.ts +1 -0
- package/dist/esm/utils/tron/constants.js +2 -0
- package/dist/esm/utils/tron/getTronNetworkFeeCryptoBaseUnit.d.ts +27 -0
- package/dist/esm/utils/tron/getTronNetworkFeeCryptoBaseUnit.js +59 -0
- package/dist/esm/utils/tron/getTronNetworkFeeCryptoBaseUnit.test.d.ts +1 -0
- package/dist/esm/utils/tron/getTronNetworkFeeCryptoBaseUnit.test.js +155 -0
- package/dist/esm/utils/tron/getUnsignedTronTransaction.d.ts +2 -1
- package/dist/esm/utils/tron/getUnsignedTronTransaction.js +14 -48
- package/dist/esm/utils/tron/getUnsignedTronTransaction.test.d.ts +1 -0
- package/dist/esm/utils/tron/getUnsignedTronTransaction.test.js +74 -0
- package/dist/esm/utils/tron/index.d.ts +2 -0
- package/dist/esm/utils/tron/index.js +2 -0
- package/package.json +8 -8
- package/dist/cjs/swappers/SunioSwapper/utils/buildSwapRouteParameters.d.ts +0 -14
- package/dist/cjs/swappers/SunioSwapper/utils/buildSwapRouteParameters.js +0 -32
- package/dist/cjs/swappers/SunioSwapper/utils/estimateSunioNetworkFee.d.ts +0 -12
- package/dist/cjs/swappers/SunioSwapper/utils/estimateSunioNetworkFee.js +0 -78
- package/dist/cjs/swappers/SunioSwapper/utils/getSunioTransactionFees.d.ts +0 -2
- package/dist/cjs/swappers/SunioSwapper/utils/getSunioTransactionFees.js +0 -36
- package/dist/cjs/utils/thorchain/tron/getTronTransactionFees.d.ts +0 -2
- package/dist/cjs/utils/thorchain/tron/getTronTransactionFees.js +0 -68
- package/dist/cjs/utils/thorchain/tron/getUnsignedTronTransaction.d.ts +0 -3
- package/dist/cjs/utils/thorchain/tron/getUnsignedTronTransaction.js +0 -35
- package/dist/cjs/utils/thorchain/tron/index.d.ts +0 -2
- package/dist/cjs/utils/thorchain/tron/index.js +0 -18
- package/dist/esm/swappers/SunioSwapper/utils/buildSwapRouteParameters.d.ts +0 -14
- package/dist/esm/swappers/SunioSwapper/utils/buildSwapRouteParameters.js +0 -28
- package/dist/esm/swappers/SunioSwapper/utils/estimateSunioNetworkFee.d.ts +0 -12
- package/dist/esm/swappers/SunioSwapper/utils/estimateSunioNetworkFee.js +0 -74
- package/dist/esm/swappers/SunioSwapper/utils/getSunioTransactionFees.d.ts +0 -2
- package/dist/esm/swappers/SunioSwapper/utils/getSunioTransactionFees.js +0 -32
- package/dist/esm/utils/thorchain/tron/getTronTransactionFees.d.ts +0 -2
- package/dist/esm/utils/thorchain/tron/getTronTransactionFees.js +0 -64
- package/dist/esm/utils/thorchain/tron/getUnsignedTronTransaction.d.ts +0 -3
- package/dist/esm/utils/thorchain/tron/getUnsignedTronTransaction.js +0 -31
- package/dist/esm/utils/thorchain/tron/index.d.ts +0 -2
- package/dist/esm/utils/thorchain/tron/index.js +0 -2
- /package/dist/cjs/swappers/SunioSwapper/utils/{fetchFromSunio.d.ts → fetchSunioQuote.d.ts} +0 -0
- /package/dist/cjs/swappers/SunioSwapper/utils/{fetchFromSunio.js → fetchSunioQuote.js} +0 -0
- /package/dist/esm/swappers/SunioSwapper/utils/{fetchFromSunio.d.ts → fetchSunioQuote.d.ts} +0 -0
- /package/dist/esm/swappers/SunioSwapper/utils/{fetchFromSunio.js → fetchSunioQuote.js} +0 -0
package/dist/esm/constants.js
CHANGED
|
@@ -9,12 +9,14 @@ import { cetusApi, cetusSwapper } from './swappers/CetusSwapper/index.js';
|
|
|
9
9
|
import { chainflipApi, chainflipSwapper } from './swappers/ChainflipSwapper/index.js';
|
|
10
10
|
import { cowApi, cowSwapper } from './swappers/CowSwapper/index.js';
|
|
11
11
|
import { debridgeApi, debridgeSwapper } from './swappers/DebridgeSwapper/index.js';
|
|
12
|
+
import { fyndApi, fyndSwapper } from './swappers/FyndSwapper/index.js';
|
|
12
13
|
import { mayachainApi, mayachainSwapper } from './swappers/MayachainSwapper/index.js';
|
|
13
14
|
import { nearIntentsApi, nearIntentsSwapper } from './swappers/NearIntentsSwapper/index.js';
|
|
14
15
|
import { portalsApi, portalsSwapper } from './swappers/PortalsSwapper/index.js';
|
|
15
16
|
import { relayApi, relaySwapper } from './swappers/RelaySwapper/index.js';
|
|
16
17
|
import { stonfiApi, stonfiSwapper } from './swappers/StonfiSwapper/index.js';
|
|
17
18
|
import { sunioApi, sunioSwapper } from './swappers/SunioSwapper/index.js';
|
|
19
|
+
import { symbiosisApi, symbiosisSwapper } from './swappers/SymbiosisSwapper/index.js';
|
|
18
20
|
import { thorchainApi, thorchainSwapper } from './swappers/ThorchainSwapper/index.js';
|
|
19
21
|
import { zrxApi, zrxSwapper } from './swappers/ZrxSwapper/index.js';
|
|
20
22
|
import { SwapperName, TradeQuoteError } from './types.js';
|
|
@@ -99,6 +101,14 @@ export const swappers = {
|
|
|
99
101
|
...bobGatewaySwapper,
|
|
100
102
|
...bobGatewayApi,
|
|
101
103
|
},
|
|
104
|
+
[SwapperName.Symbiosis]: {
|
|
105
|
+
...symbiosisSwapper,
|
|
106
|
+
...symbiosisApi,
|
|
107
|
+
},
|
|
108
|
+
[SwapperName.Fynd]: {
|
|
109
|
+
...fyndSwapper,
|
|
110
|
+
...fyndApi,
|
|
111
|
+
},
|
|
102
112
|
[SwapperName.Test]: undefined,
|
|
103
113
|
};
|
|
104
114
|
const DEFAULT_SLIPPAGE_DECIMAL_PERCENTAGE = '0.002';
|
|
@@ -118,12 +128,15 @@ const DEFAULT_STONFI_SLIPPAGE_DECIMAL_PERCENTAGE = '0.01';
|
|
|
118
128
|
// deBridge API off-chain simulation overestimates output on some chains (e.g. SEI ~2.4%), so auto slippage (1%) is insufficient
|
|
119
129
|
const DEFAULT_DEBRIDGE_SLIPPAGE_DECIMAL_PERCENTAGE = '0.03';
|
|
120
130
|
const DEFAULT_BOB_GATEWAY_SLIPPAGE_DECIMAL_PERCENTAGE = '0.03';
|
|
131
|
+
// Symbiosis splits the tolerance across up to three legs, and a destination leg over its share pays out the transit token instead of reverting
|
|
132
|
+
const DEFAULT_SYMBIOSIS_SLIPPAGE_DECIMAL_PERCENTAGE = '0.01';
|
|
121
133
|
export const getDefaultSlippageDecimalPercentageForSwapper = (swapperName) => {
|
|
122
134
|
if (swapperName === undefined)
|
|
123
135
|
return DEFAULT_SLIPPAGE_DECIMAL_PERCENTAGE;
|
|
124
136
|
switch (swapperName) {
|
|
125
137
|
case SwapperName.Zrx:
|
|
126
138
|
case SwapperName.Bebop:
|
|
139
|
+
case SwapperName.Fynd:
|
|
127
140
|
case SwapperName.Test:
|
|
128
141
|
return DEFAULT_SLIPPAGE_DECIMAL_PERCENTAGE;
|
|
129
142
|
case SwapperName.CowSwap:
|
|
@@ -158,6 +171,8 @@ export const getDefaultSlippageDecimalPercentageForSwapper = (swapperName) => {
|
|
|
158
171
|
return DEFAULT_STONFI_SLIPPAGE_DECIMAL_PERCENTAGE;
|
|
159
172
|
case SwapperName.BobGateway:
|
|
160
173
|
return DEFAULT_BOB_GATEWAY_SLIPPAGE_DECIMAL_PERCENTAGE;
|
|
174
|
+
case SwapperName.Symbiosis:
|
|
175
|
+
return DEFAULT_SYMBIOSIS_SLIPPAGE_DECIMAL_PERCENTAGE;
|
|
161
176
|
default:
|
|
162
177
|
return assertUnreachable(swapperName);
|
|
163
178
|
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -15,11 +15,13 @@ export * from './swappers/ChainflipSwapper/index.js';
|
|
|
15
15
|
export * from './swappers/SunioSwapper/index.js';
|
|
16
16
|
export * from './swappers/CowSwapper/index.js';
|
|
17
17
|
export * from './swappers/DebridgeSwapper/index.js';
|
|
18
|
+
export * from './swappers/FyndSwapper/index.js';
|
|
18
19
|
export * from './swappers/PortalsSwapper/index.js';
|
|
19
20
|
export * from './swappers/ThorchainSwapper/index.js';
|
|
20
21
|
export * from './swappers/MayachainSwapper/index.js';
|
|
21
22
|
export * from './swappers/ButterSwap/index.js';
|
|
22
23
|
export * from './swappers/RelaySwapper/index.js';
|
|
24
|
+
export * from './swappers/SymbiosisSwapper/index.js';
|
|
23
25
|
export * from './utils/helpers.js';
|
|
24
26
|
export * from './utils/thorchain/index.js';
|
|
25
27
|
export * from './types.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -15,11 +15,13 @@ export * from './swappers/ChainflipSwapper/index.js';
|
|
|
15
15
|
export * from './swappers/SunioSwapper/index.js';
|
|
16
16
|
export * from './swappers/CowSwapper/index.js';
|
|
17
17
|
export * from './swappers/DebridgeSwapper/index.js';
|
|
18
|
+
export * from './swappers/FyndSwapper/index.js';
|
|
18
19
|
export * from './swappers/PortalsSwapper/index.js';
|
|
19
20
|
export * from './swappers/ThorchainSwapper/index.js';
|
|
20
21
|
export * from './swappers/MayachainSwapper/index.js';
|
|
21
22
|
export * from './swappers/ButterSwap/index.js';
|
|
22
23
|
export * from './swappers/RelaySwapper/index.js';
|
|
24
|
+
export * from './swappers/SymbiosisSwapper/index.js';
|
|
23
25
|
export * from './utils/helpers.js';
|
|
24
26
|
export * from './utils/thorchain/index.js';
|
|
25
27
|
export * from './types.js';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { supportsETH } from '@shapeshiftoss/hdwallet-core';
|
|
2
2
|
import { Err, Ok } from '@sniptt/monads';
|
|
3
3
|
import { assertQuoteAddresses } from '../../../utils/index.js';
|
|
4
|
-
import { FALLBACK_QUOTE_DEADLINE_MS } from '../../../utils/helpers.js';
|
|
5
4
|
import { getArbitrumBridgeStepData } from '../utils/getArbitrumBridgeStepData.js';
|
|
6
5
|
import { getArbitrumBridgeTradeContext } from '../utils/getArbitrumBridgeTradeContext.js';
|
|
7
6
|
export const getTradeQuoteWithWallet = async (inputWithWallet, deps) => {
|
|
@@ -33,7 +32,6 @@ export const getTradeQuote = async (input, deps) => {
|
|
|
33
32
|
const tradeQuote = {
|
|
34
33
|
...tradeCommon,
|
|
35
34
|
quoteOrRate: 'quote',
|
|
36
|
-
deadline: Date.now() + FALLBACK_QUOTE_DEADLINE_MS,
|
|
37
35
|
receiveAddress,
|
|
38
36
|
steps: [
|
|
39
37
|
{
|
|
@@ -2,7 +2,6 @@ import { Err, Ok } from '@sniptt/monads';
|
|
|
2
2
|
import { validateAndParseAddress } from 'starknet';
|
|
3
3
|
import { TradeQuoteError } from '../../../types.js';
|
|
4
4
|
import { assertQuoteAddresses, makeSwapErrorRight } from '../../../utils/index.js';
|
|
5
|
-
import { FALLBACK_QUOTE_DEADLINE_MS } from '../../../utils/helpers.js';
|
|
6
5
|
import { getAvnuTradeContext } from '../utils/getAvnuTradeContext.js';
|
|
7
6
|
export const getTradeQuote = async (input, deps) => {
|
|
8
7
|
const { sellAsset, accountNumber } = input;
|
|
@@ -33,7 +32,7 @@ export const getTradeQuote = async (input, deps) => {
|
|
|
33
32
|
...tradeCommon,
|
|
34
33
|
receiveAddress: normalizedReceiveAddress,
|
|
35
34
|
quoteOrRate: 'quote',
|
|
36
|
-
deadline
|
|
35
|
+
deadline,
|
|
37
36
|
steps: [
|
|
38
37
|
{
|
|
39
38
|
...stepCommon,
|
|
@@ -13,12 +13,13 @@ export declare const fetchBebopQuote: ({ buyAsset, sellAsset, sellAmountIncludin
|
|
|
13
13
|
affiliateBps?: string | undefined;
|
|
14
14
|
apiKey: string;
|
|
15
15
|
}) => Promise<Result<BebopQuoteResponse, SwapErrorRight>>;
|
|
16
|
-
export declare const fetchBebopSolanaQuote: ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal, apiKey, }: {
|
|
16
|
+
export declare const fetchBebopSolanaQuote: ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal, affiliateBps, apiKey, }: {
|
|
17
17
|
buyAsset: Asset;
|
|
18
18
|
sellAsset: Asset;
|
|
19
19
|
sellAmountIncludingProtocolFeesCryptoBaseUnit: string;
|
|
20
20
|
takerAddress: string;
|
|
21
21
|
receiverAddress: string;
|
|
22
22
|
slippageTolerancePercentageDecimal: string;
|
|
23
|
+
affiliateBps?: string | undefined;
|
|
23
24
|
apiKey: string;
|
|
24
25
|
}) => Promise<Result<BebopSolanaQuoteResponse, SwapErrorRight>>;
|
|
@@ -8,6 +8,9 @@ import { getTreasuryAddressFromChainId } from '../../../utils/helpers.js';
|
|
|
8
8
|
import { chainIdToBebopChain } from '../types.js';
|
|
9
9
|
import { bebopServiceFactory } from './bebopService.js';
|
|
10
10
|
import { assetIdToBebopSolanaToken, assetIdToBebopToken } from './helpers.js';
|
|
11
|
+
// PMM charges the fee set against our api key, which nets exactly this bps
|
|
12
|
+
const BEBOP_PMM_AFFILIATE_BPS = '60';
|
|
13
|
+
const isPmmEligible = (affiliateBps) => bnOrZero(affiliateBps).eq(BEBOP_PMM_AFFILIATE_BPS);
|
|
11
14
|
export const fetchBebopQuote = async ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal, affiliateBps, apiKey, }) => {
|
|
12
15
|
try {
|
|
13
16
|
const sellToken = assetIdToBebopToken(sellAsset.assetId);
|
|
@@ -27,26 +30,24 @@ export const fetchBebopQuote = async ({ buyAsset, sellAsset, sellAmountIncluding
|
|
|
27
30
|
approval_type: 'Standard',
|
|
28
31
|
skip_validation: 'true',
|
|
29
32
|
gasless: 'false',
|
|
30
|
-
// PMM fees are configured against our api key on Bebop's side, not sent per quote
|
|
31
33
|
source: 'shapeshift',
|
|
32
34
|
};
|
|
33
35
|
const jamParams = new URLSearchParams(baseParams);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
jamParams.set('fee', affiliateBps);
|
|
38
|
-
jamParams.set('fee_recipient', getAddress(getTreasuryAddressFromChainId(buyAsset.chainId)));
|
|
39
|
-
}
|
|
36
|
+
// Without an explicit fee JAM charges our api key's flat fee, so 1 bps is the lowest it can go
|
|
37
|
+
jamParams.set('fee', affiliateBps && bnOrZero(affiliateBps).gt(0) ? affiliateBps : '1');
|
|
38
|
+
jamParams.set('fee_recipient', getAddress(getTreasuryAddressFromChainId(buyAsset.chainId)));
|
|
40
39
|
const service = bebopServiceFactory({ apiKey });
|
|
41
|
-
const
|
|
40
|
+
const requests = [
|
|
42
41
|
service.get(`https://api.bebop.xyz/jam/${chainName}/v2/quote`, {
|
|
43
42
|
params: jamParams,
|
|
44
43
|
}),
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
];
|
|
45
|
+
if (isPmmEligible(affiliateBps)) {
|
|
46
|
+
requests.push(service.get(`https://api.bebop.xyz/pmm/${chainName}/v3/quote`, {
|
|
47
|
+
params: new URLSearchParams(baseParams),
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
const maybeResponses = await Promise.all(requests);
|
|
50
51
|
if (maybeResponses.every(maybeResponse => maybeResponse.isErr())) {
|
|
51
52
|
return Err(makeSwapErrorRight({
|
|
52
53
|
message: 'Failed to fetch quote from Bebop',
|
|
@@ -76,8 +77,14 @@ export const fetchBebopQuote = async ({ buyAsset, sellAsset, sellAmountIncluding
|
|
|
76
77
|
}));
|
|
77
78
|
}
|
|
78
79
|
};
|
|
79
|
-
export const fetchBebopSolanaQuote = async ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal, apiKey, }) => {
|
|
80
|
+
export const fetchBebopSolanaQuote = async ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal, affiliateBps, apiKey, }) => {
|
|
80
81
|
try {
|
|
82
|
+
if (!isPmmEligible(affiliateBps)) {
|
|
83
|
+
return Err(makeSwapErrorRight({
|
|
84
|
+
message: 'Bebop Solana is PMM only and cannot take the requested bps',
|
|
85
|
+
code: TradeQuoteError.NoRouteFound,
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
81
88
|
// Bebop's Solana routes don't wrap native SOL on the input side, so selling native SOL
|
|
82
89
|
// always fails on-chain. Reject up front instead of returning an unexecutable quote.
|
|
83
90
|
if (sellAsset.assetId === solAssetId) {
|
|
@@ -100,7 +107,6 @@ export const fetchBebopSolanaQuote = async ({ buyAsset, sellAsset, sellAmountInc
|
|
|
100
107
|
approval_type: 'Standard',
|
|
101
108
|
skip_validation: 'false',
|
|
102
109
|
gasless: 'true',
|
|
103
|
-
// Solana is PMM only, so its fees are configured against our api key on Bebop's side
|
|
104
110
|
source: 'shapeshift',
|
|
105
111
|
});
|
|
106
112
|
const maybeResponse = await bebopServiceFactory({ apiKey }).get('https://api.bebop.xyz/pmm/solana/v3/quote', { params });
|
|
@@ -19,6 +19,7 @@ export const getBebopSolanaTradeContext = async ({ input, deps, takerAddress, re
|
|
|
19
19
|
takerAddress,
|
|
20
20
|
receiverAddress,
|
|
21
21
|
slippageTolerancePercentageDecimal,
|
|
22
|
+
affiliateBps,
|
|
22
23
|
apiKey: deps.config.VITE_BEBOP_API_KEY,
|
|
23
24
|
});
|
|
24
25
|
if (maybeBebopQuoteResponse.isErr())
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import { executeEvmTransaction, executeTronTransaction } from '../../utils/index.js';
|
|
1
|
+
import { executeEvmTransaction, executeTronTransaction, getSwapMetadata } from '../../utils/index.js';
|
|
2
|
+
import { submitBobGatewayBtcDeposit } from './utils/helpers.js';
|
|
2
3
|
export const bobGatewaySwapper = {
|
|
3
4
|
executeEvmTransaction,
|
|
4
|
-
executeUtxoTransaction: (txToSign, {
|
|
5
|
+
executeUtxoTransaction: async (txToSign, { signTransaction }, context) => {
|
|
6
|
+
if (!signTransaction)
|
|
7
|
+
throw new Error('[BobGateway] signTransaction is required');
|
|
8
|
+
if (!context)
|
|
9
|
+
throw new Error('[BobGateway] execution context is required');
|
|
10
|
+
const { orderId } = getSwapMetadata(context.swapperMetadata, 'bob');
|
|
11
|
+
const bitcoinTxHex = await signTransaction(txToSign);
|
|
12
|
+
return submitBobGatewayBtcDeposit({ config: context.config, orderId, bitcoinTxHex });
|
|
13
|
+
},
|
|
5
14
|
executeTronTransaction,
|
|
6
15
|
};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { isGatewayError } from '@gobob/bob-sdk';
|
|
2
2
|
import { TxStatus } from '@shapeshiftoss/unchained-client';
|
|
3
|
-
import {
|
|
3
|
+
import { getSwapMetadata } from '../../utils/index.js';
|
|
4
4
|
import { getEvmTransactionFees, getUnsignedEvmTransaction } from '../../utils/evm/index.js';
|
|
5
|
-
import { getTronTransactionFees } from '../../utils/tron/index.js';
|
|
5
|
+
import { getTronTransactionFees, getUnsignedTronTransaction } from '../../utils/tron/index.js';
|
|
6
6
|
import { getUnsignedUtxoTransaction, getUtxoTransactionFees } from '../../utils/utxo/index.js';
|
|
7
7
|
import { getBobGatewayTradeQuote } from './swapperApi/getTradeQuote.js';
|
|
8
8
|
import { getBobGatewayTradeRate } from './swapperApi/getTradeRate.js';
|
|
9
|
-
import { getBobGatewayClient, mapBobGatewayOrderStatusToTxStatus
|
|
10
|
-
const registeredSwapIds = new Set();
|
|
9
|
+
import { getBobGatewayClient, mapBobGatewayOrderStatusToTxStatus } from './utils/helpers.js';
|
|
11
10
|
export const bobGatewayApi = {
|
|
12
11
|
getTradeRate: (input, deps) => getBobGatewayTradeRate(input, deps),
|
|
13
12
|
getTradeQuote: (input, deps) => getBobGatewayTradeQuote(input, deps),
|
|
@@ -15,42 +14,12 @@ export const bobGatewayApi = {
|
|
|
15
14
|
getUtxoTransactionFees,
|
|
16
15
|
getUnsignedEvmTransaction,
|
|
17
16
|
getEvmTransactionFees,
|
|
18
|
-
getUnsignedTronTransaction
|
|
19
|
-
if (!isExecutableTradeQuote(tradeQuote)) {
|
|
20
|
-
throw new Error('[BobGateway] unable to execute a trade rate');
|
|
21
|
-
}
|
|
22
|
-
const step = getExecutableTradeStep(tradeQuote, stepIndex);
|
|
23
|
-
const { accountNumber, sellAsset, transactionData } = step;
|
|
24
|
-
if (transactionData?.type !== 'tron')
|
|
25
|
-
throw new Error('[BobGateway] invalid tron transaction');
|
|
26
|
-
const adapter = assertGetTronChainAdapter(sellAsset.chainId);
|
|
27
|
-
const { to, data, value } = transactionData;
|
|
28
|
-
return adapter.buildCustomApiTx({
|
|
29
|
-
accountNumber,
|
|
30
|
-
from,
|
|
31
|
-
to: toTronBase58(to),
|
|
32
|
-
value,
|
|
33
|
-
data,
|
|
34
|
-
});
|
|
35
|
-
},
|
|
17
|
+
getUnsignedTronTransaction,
|
|
36
18
|
getTronTransactionFees,
|
|
37
|
-
checkTradeStatus: async ({ swap, config
|
|
19
|
+
checkTradeStatus: async ({ swap, config }) => {
|
|
38
20
|
if (!swap)
|
|
39
21
|
throw new Error('[BobGateway] swap is required for status check');
|
|
40
22
|
const { orderId } = getSwapMetadata(swap.metadata.swapperMetadata, 'bob');
|
|
41
|
-
if (txHash && !registeredSwapIds.has(swap.id)) {
|
|
42
|
-
try {
|
|
43
|
-
await registerBobGatewayTx({
|
|
44
|
-
config,
|
|
45
|
-
orderId,
|
|
46
|
-
txHash,
|
|
47
|
-
sellAsset: swap.sellAsset,
|
|
48
|
-
buyAsset: swap.buyAsset,
|
|
49
|
-
});
|
|
50
|
-
registeredSwapIds.add(swap.id);
|
|
51
|
-
}
|
|
52
|
-
catch { }
|
|
53
|
-
}
|
|
54
23
|
let orderInfo;
|
|
55
24
|
try {
|
|
56
25
|
orderInfo = await getBobGatewayClient(config).getOrder(orderId);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { btcChainId } from '@shapeshiftoss/caip';
|
|
2
2
|
import { Err, Ok } from '@sniptt/monads';
|
|
3
3
|
import { assertQuoteAddresses } from '../../../utils/index.js';
|
|
4
|
-
import { FALLBACK_QUOTE_DEADLINE_MS } from '../../../utils/helpers.js';
|
|
5
4
|
import { getBobGatewayStepData } from '../utils/getBobGatewayStepData.js';
|
|
6
5
|
import { getBobGatewayTradeContext } from '../utils/getBobGatewayTradeContext.js';
|
|
7
6
|
export const getBobGatewayTradeQuote = async (input, deps) => {
|
|
@@ -10,18 +9,15 @@ export const getBobGatewayTradeQuote = async (input, deps) => {
|
|
|
10
9
|
if (maybeAddresses.isErr())
|
|
11
10
|
return Err(maybeAddresses.unwrapErr());
|
|
12
11
|
const { sendAddress, receiveAddress } = maybeAddresses.unwrap();
|
|
13
|
-
const
|
|
14
|
-
// omit the sender for
|
|
15
|
-
|
|
16
|
-
const sender = isEvmSell ? sendAddress : undefined;
|
|
17
|
-
// utxo deposits are refunded on the sell chain, so refunds go to the sending address
|
|
18
|
-
const refundAddress = isEvmSell ? undefined : sendAddress;
|
|
12
|
+
const isBtcSell = sellAsset.chainId === btcChainId;
|
|
13
|
+
// omit the sender for btc sells so the sdk doesn't build a psbt from a single address
|
|
14
|
+
const sender = isBtcSell ? undefined : sendAddress;
|
|
19
15
|
const maybeContext = await getBobGatewayTradeContext({
|
|
20
16
|
input,
|
|
21
17
|
deps,
|
|
22
18
|
sender,
|
|
23
19
|
recipient: receiveAddress,
|
|
24
|
-
refundAddress,
|
|
20
|
+
refundAddress: sendAddress,
|
|
25
21
|
});
|
|
26
22
|
if (maybeContext.isErr())
|
|
27
23
|
return Err(maybeContext.unwrapErr());
|
|
@@ -38,7 +34,6 @@ export const getBobGatewayTradeQuote = async (input, deps) => {
|
|
|
38
34
|
const tradeQuote = {
|
|
39
35
|
...tradeCommon,
|
|
40
36
|
quoteOrRate: 'quote',
|
|
41
|
-
deadline: Date.now() + FALLBACK_QUOTE_DEADLINE_MS,
|
|
42
37
|
receiveAddress,
|
|
43
38
|
steps: [
|
|
44
39
|
{
|
|
@@ -8,8 +8,7 @@ export const getBobGatewayTradeRate = async (input, deps) => {
|
|
|
8
8
|
const isBtcSell = sellAsset.chainId === btcChainId;
|
|
9
9
|
const recipient = receiveAddress ?? dummyAddressForChainId(buyAsset.chainId);
|
|
10
10
|
const sender = isBtcSell ? undefined : dummyAddressForChainId(sellAsset.chainId);
|
|
11
|
-
|
|
12
|
-
const refundAddress = isBtcSell ? dummyAddressForChainId(sellAsset.chainId) : undefined;
|
|
11
|
+
const refundAddress = dummyAddressForChainId(sellAsset.chainId);
|
|
13
12
|
const maybeContext = await getBobGatewayTradeContext({
|
|
14
13
|
input,
|
|
15
14
|
deps,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { GetEvmTradeQuoteInput, GetEvmTradeRateInput, GetUtxoTradeQuoteInput, GetUtxoTradeRateInput } from '../../types.js';
|
|
1
|
+
import type { GetEvmTradeQuoteInput, GetEvmTradeRateInput, GetTronTradeQuoteInput, GetTronTradeRateInput, GetUtxoTradeQuoteInput, GetUtxoTradeRateInput } from '../../types.js';
|
|
2
2
|
export type BobGatewayMetadata = {
|
|
3
3
|
name: 'bob';
|
|
4
4
|
orderId: string;
|
|
5
5
|
};
|
|
6
|
-
export type BobGatewayTradeQuoteInput = GetEvmTradeQuoteInput | GetUtxoTradeQuoteInput;
|
|
7
|
-
export type BobGatewayTradeRateInput = GetEvmTradeRateInput | GetUtxoTradeRateInput;
|
|
6
|
+
export type BobGatewayTradeQuoteInput = GetEvmTradeQuoteInput | GetUtxoTradeQuoteInput | GetTronTradeQuoteInput;
|
|
7
|
+
export type BobGatewayTradeRateInput = GetEvmTradeRateInput | GetUtxoTradeRateInput | GetTronTradeRateInput;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { ChainId } from '@shapeshiftoss/caip';
|
|
2
2
|
export declare const BOB_GATEWAY_BASE_URL = "https://gateway-api-mainnet.gobob.xyz";
|
|
3
3
|
export declare const chainIdToBobGatewayChainName: {
|
|
4
|
-
readonly [x: string]: "ethereum" | "polygon" | "arbitrum" | "base" | "avalanche" | "bsc" | "bob" | "plasma" | "bera" | "bitcoin" | "sei" | "sonic" | "unichain" | "
|
|
4
|
+
readonly [x: string]: "ethereum" | "polygon" | "arbitrum" | "base" | "avalanche" | "bsc" | "robinhood" | "bob" | "plasma" | "tron" | "bera" | "bitcoin" | "sei" | "sonic" | "unichain" | "hyperevm";
|
|
5
5
|
};
|
|
6
6
|
export declare const bobGatewayChainNameToChainId: Record<BobGatewayChainName, ChainId>;
|
|
7
7
|
export type BobGatewayChainName = (typeof chainIdToBobGatewayChainName)[keyof typeof chainIdToBobGatewayChainName];
|
|
8
8
|
export declare const DUMMY_EVM_ADDRESS: `0x${string}`;
|
|
9
9
|
export declare const DUMMY_BTC_ADDRESS = "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq";
|
|
10
|
-
export declare const DUMMY_TRON_ADDRESS = "TT2T17KZhoDu47i2E4FWxfG79zdkEWkU9N";
|
|
11
10
|
export declare const BOB_GATEWAY_TOKENSWAP_DEFAULT_GAS_LIMIT = "350000";
|
|
12
11
|
export declare const BOB_GATEWAY_OFFRAMP_DEFAULT_GAS_LIMIT = "550000";
|
|
12
|
+
export declare const BOB_GATEWAY_TRON_DEFAULT_ENERGY = "420000";
|
|
13
|
+
export declare const BOB_GATEWAY_TRON_DEFAULT_BANDWIDTH_BYTES = 4000;
|
|
13
14
|
export declare const decimalSlippageToBobBps: (slippageDecimal: string) => string;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { arbitrumChainId, avalancheChainId, baseChainId, berachainChainId, bobChainId, bscChainId, btcChainId, ethChainId, hyperEvmChainId, plasmaChainId, polygonChainId, seiChainId, sonicChainId,
|
|
2
|
-
// tronChainId,
|
|
3
|
-
unichainChainId, } from '@shapeshiftoss/caip';
|
|
1
|
+
import { arbitrumChainId, avalancheChainId, baseChainId, berachainChainId, bobChainId, bscChainId, btcChainId, ethChainId, hyperEvmChainId, plasmaChainId, polygonChainId, robinhoodChainId, seiChainId, sonicChainId, tronChainId, unichainChainId, } from '@shapeshiftoss/caip';
|
|
4
2
|
export const BOB_GATEWAY_BASE_URL = 'https://gateway-api-mainnet.gobob.xyz';
|
|
5
3
|
// Chain name strings expected by the BOB Gateway API
|
|
6
|
-
// https://gateway-api-mainnet.gobob.xyz/
|
|
4
|
+
// https://gateway-api-mainnet.gobob.xyz/v4/get-routes
|
|
7
5
|
export const chainIdToBobGatewayChainName = {
|
|
8
6
|
[arbitrumChainId]: 'arbitrum',
|
|
9
7
|
[avalancheChainId]: 'avalanche',
|
|
@@ -18,15 +16,18 @@ export const chainIdToBobGatewayChainName = {
|
|
|
18
16
|
[unichainChainId]: 'unichain',
|
|
19
17
|
[plasmaChainId]: 'plasma',
|
|
20
18
|
[polygonChainId]: 'polygon',
|
|
21
|
-
[hyperEvmChainId]: '
|
|
22
|
-
|
|
19
|
+
[hyperEvmChainId]: 'hyperevm',
|
|
20
|
+
[robinhoodChainId]: 'robinhood',
|
|
21
|
+
[tronChainId]: 'tron',
|
|
23
22
|
};
|
|
24
23
|
export const bobGatewayChainNameToChainId = Object.fromEntries(Object.entries(chainIdToBobGatewayChainName).map(([chainId, chainName]) => [chainName, chainId]));
|
|
25
24
|
export const DUMMY_EVM_ADDRESS = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045';
|
|
26
25
|
export const DUMMY_BTC_ADDRESS = 'bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq';
|
|
27
|
-
export const DUMMY_TRON_ADDRESS = 'TT2T17KZhoDu47i2E4FWxfG79zdkEWkU9N';
|
|
28
26
|
export const BOB_GATEWAY_TOKENSWAP_DEFAULT_GAS_LIMIT = '350000'; // EVM→EVM
|
|
29
27
|
export const BOB_GATEWAY_OFFRAMP_DEFAULT_GAS_LIMIT = '550000'; // EVM→BTC
|
|
28
|
+
// AllowanceHolder exec measured on mainnet: rates price it before an order exists, token quotes without their allowance fall back to it
|
|
29
|
+
export const BOB_GATEWAY_TRON_DEFAULT_ENERGY = '420000';
|
|
30
|
+
export const BOB_GATEWAY_TRON_DEFAULT_BANDWIDTH_BYTES = 4000;
|
|
30
31
|
// https://docs.gobob.xyz/api-reference/v2/get-a-gateway-quote#parameter-slippage
|
|
31
32
|
export const decimalSlippageToBobBps = (slippageDecimal) => {
|
|
32
33
|
return String(Math.round(parseFloat(slippageDecimal) * 10_000));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { GatewayQuoteV4 } from '@gobob/bob-sdk';
|
|
2
2
|
import type { Result } from '@sniptt/monads';
|
|
3
3
|
import type { StepDataArgs, SwapErrorRight, TxBuildData } from '../../../types.js';
|
|
4
4
|
type BaseArgs = {
|
|
5
|
-
quote:
|
|
5
|
+
quote: GatewayQuoteV4;
|
|
6
6
|
sellAmountCryptoBaseUnit: string;
|
|
7
7
|
spenderAddress: string;
|
|
8
8
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CHAIN_NAMESPACE, fromChainId } from '@shapeshiftoss/caip';
|
|
2
|
-
import { contractAddressOrUndefined } from '@shapeshiftoss/utils';
|
|
3
2
|
import { Err, Ok } from '@sniptt/monads';
|
|
4
3
|
import { TradeQuoteError } from '../../../types.js';
|
|
5
4
|
import { makeNetworkFeeEstimationFailedErr, makeSwapErrorRight, makeTradeStepBuildFailedErr, } from '../../../utils/index.js';
|
|
6
5
|
import { getEvmNetworkFeeCryptoBaseUnit } from '../../../utils/evm/index.js';
|
|
6
|
+
import { getTronContractCallFallbackFeeCryptoBaseUnit, getTronContractCallNetworkFeeCryptoBaseUnit, } from '../../../utils/tron/index.js';
|
|
7
7
|
import { getUtxoNetworkFeeCryptoBaseUnit, UTXO_PLACEHOLDER_ADDRESS } from '../../../utils/utxo/index.js';
|
|
8
|
-
import { BOB_GATEWAY_OFFRAMP_DEFAULT_GAS_LIMIT, BOB_GATEWAY_TOKENSWAP_DEFAULT_GAS_LIMIT, } from './constants.js';
|
|
9
|
-
import { createBobGatewayOrder
|
|
8
|
+
import { BOB_GATEWAY_OFFRAMP_DEFAULT_GAS_LIMIT, BOB_GATEWAY_TOKENSWAP_DEFAULT_GAS_LIMIT, BOB_GATEWAY_TRON_DEFAULT_BANDWIDTH_BYTES, BOB_GATEWAY_TRON_DEFAULT_ENERGY, } from './constants.js';
|
|
9
|
+
import { createBobGatewayOrder } from './helpers.js';
|
|
10
10
|
export async function getBobGatewayStepData(args) {
|
|
11
11
|
const { input, quote, sellAsset, sellAmountCryptoBaseUnit, spenderAddress, deps } = args;
|
|
12
12
|
const { chainNamespace } = fromChainId(sellAsset.chainId);
|
|
@@ -139,19 +139,17 @@ export async function getBobGatewayStepData(args) {
|
|
|
139
139
|
// Tron sells (offramp Tron → BTC, or tokenSwap TRON → EVM)
|
|
140
140
|
case CHAIN_NAMESPACE.Tron: {
|
|
141
141
|
const adapter = deps.assertGetTronChainAdapter(sellAsset.chainId);
|
|
142
|
-
const contractAddress = contractAddressOrUndefined(sellAsset.assetId);
|
|
143
142
|
if (resolved.type === 'rate') {
|
|
143
|
+
// The gateway call isn't built until an order exists, so rates price a measured default
|
|
144
144
|
const networkFeeCryptoBaseUnit = await (async () => {
|
|
145
145
|
try {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
chainSpecific: { contractAddress },
|
|
146
|
+
return await getTronContractCallFallbackFeeCryptoBaseUnit({
|
|
147
|
+
adapter,
|
|
148
|
+
energy: BOB_GATEWAY_TRON_DEFAULT_ENERGY,
|
|
149
|
+
bandwidthBytes: BOB_GATEWAY_TRON_DEFAULT_BANDWIDTH_BYTES,
|
|
150
|
+
contractAddress: spenderAddress,
|
|
151
|
+
fullEnergyOnShareLookupFailure: true,
|
|
153
152
|
});
|
|
154
|
-
return fast.txFee;
|
|
155
153
|
}
|
|
156
154
|
catch { }
|
|
157
155
|
})();
|
|
@@ -165,22 +163,20 @@ export async function getBobGatewayStepData(args) {
|
|
|
165
163
|
if (order.tx.type !== 'tron')
|
|
166
164
|
return Err(makeTradeStepBuildFailedErr('getBobGatewayStepData'));
|
|
167
165
|
const { tx, orderId } = order;
|
|
168
|
-
const
|
|
169
|
-
type: 'tron',
|
|
170
|
-
to: tx.to,
|
|
171
|
-
data: tx.data,
|
|
172
|
-
value: tx.value,
|
|
173
|
-
};
|
|
166
|
+
const call = { to: tx.to, data: tx.data, value: tx.value };
|
|
174
167
|
try {
|
|
175
|
-
const { fast } = await adapter.getFeeData({
|
|
176
|
-
to: toTronBase58(tx.to),
|
|
177
|
-
value: sellAmountCryptoBaseUnit,
|
|
178
|
-
chainSpecific: { from, contractAddress },
|
|
179
|
-
});
|
|
180
168
|
const stepData = {
|
|
181
169
|
orderId,
|
|
182
|
-
transactionData,
|
|
183
|
-
networkFeeCryptoBaseUnit:
|
|
170
|
+
transactionData: { type: 'tron', ...call },
|
|
171
|
+
networkFeeCryptoBaseUnit: await getTronContractCallNetworkFeeCryptoBaseUnit({
|
|
172
|
+
adapter,
|
|
173
|
+
transactionData: call,
|
|
174
|
+
from,
|
|
175
|
+
sellAsset,
|
|
176
|
+
sellAmountCryptoBaseUnit,
|
|
177
|
+
spenderAddress,
|
|
178
|
+
fallbackEnergy: BOB_GATEWAY_TRON_DEFAULT_ENERGY,
|
|
179
|
+
}),
|
|
184
180
|
};
|
|
185
181
|
return Ok(stepData);
|
|
186
182
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { tronChainId } from '@shapeshiftoss/caip';
|
|
2
|
+
import { Ok } from '@sniptt/monads';
|
|
3
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
4
|
+
import { ETH } from '../../../utils/test-data/assets.js';
|
|
5
|
+
import { getBobGatewayStepData } from './getBobGatewayStepData.js';
|
|
6
|
+
import { createBobGatewayOrder } from './helpers.js';
|
|
7
|
+
vi.mock('./helpers', () => ({ createBobGatewayOrder: vi.fn() }));
|
|
8
|
+
const USDT_TRON = {
|
|
9
|
+
...ETH,
|
|
10
|
+
assetId: `${tronChainId}/trc20:TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t`,
|
|
11
|
+
chainId: tronChainId,
|
|
12
|
+
};
|
|
13
|
+
const FROM = 'TT2T17KZhoDu47i2E4FWxfG79zdkEWkU9N';
|
|
14
|
+
// BOB returns the AllowanceHolder as 0x-prefixed 41-hex (TAfbit1ENsRmtZbPQfYU3srURpfYuWYS7K)
|
|
15
|
+
const ALLOWANCE_HOLDER_HEX = '0x4107a39ae4c49dee86e892450b20881f32cd5d500d';
|
|
16
|
+
const tronTx = { type: 'tron', to: ALLOWANCE_HOLDER_HEX, data: '0x2213bc0b', value: '0' };
|
|
17
|
+
const tronAdapter = ({ txFee = '45600000', allowance = '0' } = {}) => ({
|
|
18
|
+
getFeeData: vi.fn().mockResolvedValue({ fast: { txFee } }),
|
|
19
|
+
httpProvider: {
|
|
20
|
+
getChainPrices: () => Promise.resolve({ energyPrice: 100, bandwidthPrice: 1000 }),
|
|
21
|
+
getTrc20Allowance: vi.fn().mockResolvedValue(allowance),
|
|
22
|
+
getTrc20Balance: vi.fn().mockResolvedValue('100000000'),
|
|
23
|
+
getContractEnergyShare: vi.fn().mockResolvedValue({
|
|
24
|
+
callerPercent: 100,
|
|
25
|
+
originEnergyLimit: 0,
|
|
26
|
+
originEnergyAvailable: 0,
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const makeDeps = (tron) => ({ config: {}, assertGetTronChainAdapter: () => tron });
|
|
31
|
+
const quote = {};
|
|
32
|
+
describe('getBobGatewayStepData', () => {
|
|
33
|
+
describe('tron', () => {
|
|
34
|
+
it('prices a rate from the measured default energy and bandwidth at the gateway share', async () => {
|
|
35
|
+
const adapter = tronAdapter();
|
|
36
|
+
const actual = await getBobGatewayStepData({
|
|
37
|
+
type: 'rate',
|
|
38
|
+
input: {},
|
|
39
|
+
deps: makeDeps(adapter),
|
|
40
|
+
quote,
|
|
41
|
+
sellAsset: USDT_TRON,
|
|
42
|
+
sellAmountCryptoBaseUnit: '100000000',
|
|
43
|
+
spenderAddress: 'TAfbit1ENsRmtZbPQfYU3srURpfYuWYS7K',
|
|
44
|
+
});
|
|
45
|
+
// 420000 energy * 1.2 margin * 100 sun + 4000 bytes * 1000 sun
|
|
46
|
+
expect(actual.unwrap()).toEqual({ networkFeeCryptoBaseUnit: '54400000' });
|
|
47
|
+
expect(adapter.httpProvider.getContractEnergyShare).toHaveBeenCalledWith('TAfbit1ENsRmtZbPQfYU3srURpfYuWYS7K');
|
|
48
|
+
});
|
|
49
|
+
it('simulates the real gateway call for a quote', async () => {
|
|
50
|
+
vi.mocked(createBobGatewayOrder).mockResolvedValue(Ok({ offramp: { orderId: 'order-1', tx: tronTx } }));
|
|
51
|
+
const adapter = tronAdapter();
|
|
52
|
+
const actual = await getBobGatewayStepData({
|
|
53
|
+
type: 'quote',
|
|
54
|
+
input: {},
|
|
55
|
+
deps: makeDeps(adapter),
|
|
56
|
+
quote,
|
|
57
|
+
sellAsset: USDT_TRON,
|
|
58
|
+
sellAmountCryptoBaseUnit: '100000000',
|
|
59
|
+
spenderAddress: '',
|
|
60
|
+
from: FROM,
|
|
61
|
+
});
|
|
62
|
+
expect(adapter.getFeeData).toHaveBeenCalledWith({
|
|
63
|
+
to: ALLOWANCE_HOLDER_HEX,
|
|
64
|
+
value: '0',
|
|
65
|
+
chainSpecific: { from: FROM, data: '0x2213bc0b', requireEnergyShare: true },
|
|
66
|
+
});
|
|
67
|
+
expect(actual.unwrap()).toEqual({
|
|
68
|
+
orderId: 'order-1',
|
|
69
|
+
transactionData: { type: 'tron', to: ALLOWANCE_HOLDER_HEX, data: '0x2213bc0b', value: '0' },
|
|
70
|
+
networkFeeCryptoBaseUnit: '45600000',
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
it('prices the measured worst case when the allowance is not granted yet', async () => {
|
|
74
|
+
vi.mocked(createBobGatewayOrder).mockResolvedValue(Ok({ offramp: { orderId: 'order-1', tx: tronTx } }));
|
|
75
|
+
const adapter = tronAdapter({ allowance: '0' });
|
|
76
|
+
adapter.getFeeData.mockRejectedValue(new Error('REVERT opcode executed'));
|
|
77
|
+
const actual = await getBobGatewayStepData({
|
|
78
|
+
type: 'quote',
|
|
79
|
+
input: {},
|
|
80
|
+
deps: makeDeps(adapter),
|
|
81
|
+
quote,
|
|
82
|
+
sellAsset: USDT_TRON,
|
|
83
|
+
sellAmountCryptoBaseUnit: '100000000',
|
|
84
|
+
spenderAddress: 'TAfbit1ENsRmtZbPQfYU3srURpfYuWYS7K',
|
|
85
|
+
from: FROM,
|
|
86
|
+
});
|
|
87
|
+
// 420000 energy * 1.2 margin * 100 sun + (4 calldata + 279 envelope) bytes * 1000 sun
|
|
88
|
+
expect(actual.unwrap()).toMatchObject({
|
|
89
|
+
orderId: 'order-1',
|
|
90
|
+
networkFeeCryptoBaseUnit: '50683000',
|
|
91
|
+
});
|
|
92
|
+
expect(adapter.httpProvider.getTrc20Allowance).toHaveBeenCalledWith({
|
|
93
|
+
contractAddress: 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',
|
|
94
|
+
owner: FROM,
|
|
95
|
+
spender: 'TAfbit1ENsRmtZbPQfYU3srURpfYuWYS7K',
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
it('fails the quote when the simulation reverts with the allowance in place', async () => {
|
|
99
|
+
vi.mocked(createBobGatewayOrder).mockResolvedValue(Ok({ offramp: { orderId: 'order-1', tx: tronTx } }));
|
|
100
|
+
const adapter = tronAdapter({ allowance: '100000000' });
|
|
101
|
+
adapter.getFeeData.mockRejectedValue(new Error('REVERT opcode executed'));
|
|
102
|
+
const actual = await getBobGatewayStepData({
|
|
103
|
+
type: 'quote',
|
|
104
|
+
input: {},
|
|
105
|
+
deps: makeDeps(adapter),
|
|
106
|
+
quote,
|
|
107
|
+
sellAsset: USDT_TRON,
|
|
108
|
+
sellAmountCryptoBaseUnit: '100000000',
|
|
109
|
+
spenderAddress: 'TAfbit1ENsRmtZbPQfYU3srURpfYuWYS7K',
|
|
110
|
+
from: FROM,
|
|
111
|
+
});
|
|
112
|
+
expect(actual.isErr()).toBe(true);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isEvmChainId } from '@shapeshiftoss/chain-adapters';
|
|
2
1
|
import { Err, Ok } from '@sniptt/monads';
|
|
3
2
|
import { v4 as uuid } from 'uuid';
|
|
4
3
|
import { SwapperName } from '../../../types.js';
|
|
@@ -58,7 +57,7 @@ export const getBobGatewayTradeContext = async ({ input, deps, sender, recipient
|
|
|
58
57
|
quote,
|
|
59
58
|
sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
60
59
|
sellAsset,
|
|
61
|
-
spenderAddress:
|
|
60
|
+
spenderAddress: allowanceContract,
|
|
62
61
|
deps,
|
|
63
62
|
},
|
|
64
63
|
});
|