@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
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { makeSwapperAxiosServiceMonadic } from '../../../utils/index.js';
|
|
3
|
+
import { SYMBIOSIS_PARTNER_ID } from './constants.js';
|
|
4
|
+
const symbiosisServiceBase = axios.create({
|
|
5
|
+
timeout: 10000,
|
|
6
|
+
headers: {
|
|
7
|
+
Accept: 'application/json',
|
|
8
|
+
'Content-Type': 'application/json',
|
|
9
|
+
'X-Partner-Id': SYMBIOSIS_PARTNER_ID,
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
export const symbiosisService = makeSwapperAxiosServiceMonadic(symbiosisServiceBase);
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { GetEvmTradeQuoteInput, GetEvmTradeRateInput, GetTronTradeQuoteInput, GetTronTradeRateInput } from '../../../types.js';
|
|
2
|
+
export type SymbiosisTradeQuoteInput = GetEvmTradeQuoteInput | GetTronTradeQuoteInput;
|
|
3
|
+
export type SymbiosisTradeRateInput = GetEvmTradeRateInput | GetTronTradeRateInput;
|
|
4
|
+
export type SymbiosisToken = {
|
|
5
|
+
chainId: number;
|
|
6
|
+
address: string;
|
|
7
|
+
decimals: number;
|
|
8
|
+
symbol: string;
|
|
9
|
+
};
|
|
10
|
+
export type SymbiosisTokenAmount = SymbiosisToken & {
|
|
11
|
+
amount: string;
|
|
12
|
+
};
|
|
13
|
+
export type SymbiosisQuoteRequest = {
|
|
14
|
+
tokenAmountIn: Omit<SymbiosisTokenAmount, 'symbol'>;
|
|
15
|
+
tokenOut: Omit<SymbiosisToken, 'symbol'>;
|
|
16
|
+
from: string;
|
|
17
|
+
to: string;
|
|
18
|
+
slippage: number;
|
|
19
|
+
disabledProviders: string;
|
|
20
|
+
partnerAddress?: string;
|
|
21
|
+
};
|
|
22
|
+
export type SymbiosisFee = {
|
|
23
|
+
provider: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
value: SymbiosisTokenAmount;
|
|
26
|
+
};
|
|
27
|
+
export type SymbiosisEvmTx = {
|
|
28
|
+
chainId: number;
|
|
29
|
+
to: string;
|
|
30
|
+
data: string;
|
|
31
|
+
value?: string;
|
|
32
|
+
};
|
|
33
|
+
export type SymbiosisTronTx = {
|
|
34
|
+
chainId: number;
|
|
35
|
+
from: string;
|
|
36
|
+
to: string;
|
|
37
|
+
data: string;
|
|
38
|
+
value?: string;
|
|
39
|
+
feeLimit: number;
|
|
40
|
+
functionSelector?: string;
|
|
41
|
+
};
|
|
42
|
+
export type SymbiosisSwapTx = {
|
|
43
|
+
type: 'evm';
|
|
44
|
+
tx: SymbiosisEvmTx;
|
|
45
|
+
} | {
|
|
46
|
+
type: 'tron';
|
|
47
|
+
tx: SymbiosisTronTx;
|
|
48
|
+
};
|
|
49
|
+
export type SymbiosisQuoteResponse = SymbiosisSwapTx & {
|
|
50
|
+
kind: string;
|
|
51
|
+
labels: string[];
|
|
52
|
+
approveTo?: string;
|
|
53
|
+
tokenAmountOut: SymbiosisTokenAmount;
|
|
54
|
+
tokenAmountOutMin: SymbiosisTokenAmount;
|
|
55
|
+
fees: SymbiosisFee[];
|
|
56
|
+
estimatedTime: number;
|
|
57
|
+
};
|
|
58
|
+
export type SymbiosisErrorResponse = {
|
|
59
|
+
code: number;
|
|
60
|
+
message: string;
|
|
61
|
+
};
|
|
62
|
+
export declare enum SymbiosisStatusCode {
|
|
63
|
+
NotFound = -1,
|
|
64
|
+
Success = 0,
|
|
65
|
+
Pending = 1,
|
|
66
|
+
Stuck = 2,
|
|
67
|
+
Reverted = 3
|
|
68
|
+
}
|
|
69
|
+
export type SymbiosisTxResponse = {
|
|
70
|
+
status: {
|
|
71
|
+
code: SymbiosisStatusCode;
|
|
72
|
+
text: string;
|
|
73
|
+
};
|
|
74
|
+
tx?: {
|
|
75
|
+
hash?: string;
|
|
76
|
+
chainId: number;
|
|
77
|
+
};
|
|
78
|
+
txIn?: {
|
|
79
|
+
hash?: string;
|
|
80
|
+
chainId: number;
|
|
81
|
+
};
|
|
82
|
+
transitTokenSent?: SymbiosisTokenAmount;
|
|
83
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var SymbiosisStatusCode;
|
|
2
|
+
(function (SymbiosisStatusCode) {
|
|
3
|
+
SymbiosisStatusCode[SymbiosisStatusCode["NotFound"] = -1] = "NotFound";
|
|
4
|
+
SymbiosisStatusCode[SymbiosisStatusCode["Success"] = 0] = "Success";
|
|
5
|
+
SymbiosisStatusCode[SymbiosisStatusCode["Pending"] = 1] = "Pending";
|
|
6
|
+
SymbiosisStatusCode[SymbiosisStatusCode["Stuck"] = 2] = "Stuck";
|
|
7
|
+
SymbiosisStatusCode[SymbiosisStatusCode["Reverted"] = 3] = "Reverted";
|
|
8
|
+
})(SymbiosisStatusCode || (SymbiosisStatusCode = {}));
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { SwapperName } from '../../types.js';
|
|
2
1
|
import { getCosmosSdkTransactionFees, getUnsignedCosmosSdkTransaction } from '../../utils/cosmossdk/index.js';
|
|
3
2
|
import { getEvmTransactionFees, getUnsignedEvmTransaction } from '../../utils/evm/index.js';
|
|
4
3
|
import { getSolanaTransactionFees, getUnsignedSolanaTransaction } from '../../utils/solana/index.js';
|
|
5
|
-
import { checkTradeStatus
|
|
4
|
+
import { checkTradeStatus } from '../../utils/thorchain/index.js';
|
|
5
|
+
import { getTronTransactionFees, getUnsignedTronTransaction } from '../../utils/tron/index.js';
|
|
6
6
|
import { getUnsignedUtxoTransaction, getUtxoTransactionFees } from '../../utils/utxo/index.js';
|
|
7
7
|
import { getTradeQuote } from './getTradeQuote/getTradeQuote.js';
|
|
8
8
|
import { getTradeRate } from './getTradeRate/getTradeRate.js';
|
|
9
|
-
const swapperName = SwapperName.Thorchain;
|
|
10
9
|
export const thorchainApi = {
|
|
11
10
|
getTradeRate: (input, deps) => getTradeRate(input, deps),
|
|
12
11
|
getTradeQuote: (input, deps) => getTradeQuote(input, deps),
|
|
@@ -18,8 +17,8 @@ export const thorchainApi = {
|
|
|
18
17
|
getCosmosSdkTransactionFees,
|
|
19
18
|
getUnsignedSolanaTransaction,
|
|
20
19
|
getSolanaTransactionFees,
|
|
21
|
-
getUnsignedTronTransaction
|
|
22
|
-
getTronTransactionFees
|
|
20
|
+
getUnsignedTronTransaction,
|
|
21
|
+
getTronTransactionFees,
|
|
23
22
|
checkTradeStatus: input => {
|
|
24
23
|
const { config } = input;
|
|
25
24
|
const nodeUrl = `${config.VITE_THORCHAIN_NODE_URL}/thorchain`;
|
|
@@ -1017,6 +1017,7 @@
|
|
|
1017
1017
|
"eip155:1/erc20:0x2c06ba9e7f0daccbc1f6a33ea67e85bb68fbee3a",
|
|
1018
1018
|
"eip155:1/erc20:0xcbb8f1bda10b9696c57e13bc128fe674769dcec0",
|
|
1019
1019
|
"eip155:1/erc20:0x72dfb2e44f59c5ad2bafe84314e5b99a7cd5075e",
|
|
1020
|
+
"eip155:1/erc20:0xce682c89c63d2850cb2ca898e44d6c7c30d897a6",
|
|
1020
1021
|
"eip155:43114/erc20:0xc891eb4cbdeff6e073e859e987815ed1505c2acd",
|
|
1021
1022
|
"eip155:43114/erc20:0xd24c2ad096400b6fbcd2ad8b24e7acbc21a1da64",
|
|
1022
1023
|
"eip155:43114/erc20:0x47c3118ad183712acd42648e9e522e13690f29a0",
|
|
@@ -41,5 +41,6 @@
|
|
|
41
41
|
"THOR.TCY": "cosmos:thorchain-1/slip44:tcy",
|
|
42
42
|
"TRON.TRX": "tron:0x2b6653dc/slip44:195",
|
|
43
43
|
"TRON.USDT-TR7NHQJEKQXGTCI8Q8ZY4PL8OTSZGJLJ6T": "tron:0x2b6653dc/trc20:tr7nhqjekqxgtci8q8zy4pl8otszgjlj6t",
|
|
44
|
+
"ZEC.ZEC": "bip122:00040fe8ec8471911baa1db1266ea15d/slip44:133",
|
|
44
45
|
"THOR.RUNE": "cosmos:thorchain-1/slip44:931"
|
|
45
46
|
}
|
|
@@ -34,7 +34,12 @@ export const addL1ToLongtailPartsToMemo = ({ sellAssetChainId, quotedMemo, aggre
|
|
|
34
34
|
finalAssetAddress: finalAssetContractAddressShortened,
|
|
35
35
|
});
|
|
36
36
|
const [prefix, nativeAssetName, address, nativeAssetLimitWithManualSlippage, affiliate, affiliateBps, aggregatorLastTwoChars, finalAssetContract,] = quotedMemoWithAggregatorAndFinalAssetContract.split(MEMO_PART_DELIMITER);
|
|
37
|
-
|
|
37
|
+
// THORNode quote memos may already use the shortened native asset name
|
|
38
|
+
const shortenedNativeAssetNames = Object.values(shortenedNativeAssetNameByNativeAssetName);
|
|
39
|
+
const isAlreadyShortened = shortenedNativeAssetNames.includes(nativeAssetName);
|
|
40
|
+
const shortenedNativeAssetName = isAlreadyShortened
|
|
41
|
+
? nativeAssetName
|
|
42
|
+
: shortenedNativeAssetNameByNativeAssetName[nativeAssetName];
|
|
38
43
|
assert(shortenedNativeAssetName, 'cannot find shortened native asset name');
|
|
39
44
|
const memoWithoutFinalAssetLimit = [
|
|
40
45
|
prefix,
|
|
@@ -35,6 +35,21 @@ describe('addL1ToLongtailPartsToMemo', () => {
|
|
|
35
35
|
// The aggregator will turn the finalAssetAmountOut from 94136714201 to 9413671420 using the last 2 bytes as exponents
|
|
36
36
|
`=:e:0x32DBc9Cf9E8FbCebE1e0a2ecF05Ed86Ca3096Cb6:42:ss:100:d2:a6df4741:94136714201`);
|
|
37
37
|
});
|
|
38
|
+
it('should accept a quoted memo with an already shortened native asset name', () => {
|
|
39
|
+
const finalAssetAmountOut = '9508759019';
|
|
40
|
+
const quotedMemo = `=:e:0x32DBc9Cf9E8FbCebE1e0a2ecF05Ed86Ca3096Cb6:42:ss:100`;
|
|
41
|
+
const modifiedMemo = addL1ToLongtailPartsToMemo({
|
|
42
|
+
sellAssetChainId: ethChainId,
|
|
43
|
+
quotedMemo,
|
|
44
|
+
aggregator: AGGREGATOR_ADDRESS,
|
|
45
|
+
finalAssetAssetId: FINAL_ASSET_ASSETID,
|
|
46
|
+
finalAssetAmountOut,
|
|
47
|
+
slippageBps,
|
|
48
|
+
longtailTokens: THORCHAIN_ASSETIDS_ONE_COLLISION,
|
|
49
|
+
affiliate: THORCHAIN_AFFILIATE_NAME,
|
|
50
|
+
});
|
|
51
|
+
expect(modifiedMemo).toBe(`=:e:0x32DBc9Cf9E8FbCebE1e0a2ecF05Ed86Ca3096Cb6:42:ss:100:d2:a6df4741:94136714201`);
|
|
52
|
+
});
|
|
38
53
|
it('should throw if chainId is BCH and initial memo length is > 220', () => {
|
|
39
54
|
const finalAssetAmountOut = '2083854765519275828179229';
|
|
40
55
|
const memoOver220Bytes = `=:ETH.ETH:${REALLY_BIG_ADDRESS}:42:ss:100`;
|
|
@@ -67,5 +67,12 @@ export const assertValidL1ToLongtailTrade = async ({ sellAsset, buyAsset, deps,
|
|
|
67
67
|
details: { sellAssetChainId: sellAsset.chainId },
|
|
68
68
|
}));
|
|
69
69
|
}
|
|
70
|
+
if (sellAsset.assetId === buyAssetFeeAsset.assetId) {
|
|
71
|
+
return Err(makeSwapErrorRight({
|
|
72
|
+
message: `[getThorTradeQuote] - Cannot swap ${sellAsset.assetId} to itself before the aggregator.`,
|
|
73
|
+
code: TradeQuoteError.UnsupportedTradePair,
|
|
74
|
+
details: { buyAsset, sellAsset },
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
70
77
|
return Ok({ buyAssetFeeAsset, longtailTokens });
|
|
71
78
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { TS_AGGREGATOR_TOKEN_TRANSFER_PROXY_CONTRACT_MAINNET } from '@shapeshiftoss/contracts';
|
|
2
1
|
import { convertDecimalPercentageToBasisPoints } from '@shapeshiftoss/utils';
|
|
3
2
|
import { Err, Ok } from '@sniptt/monads';
|
|
4
3
|
import { getDefaultSlippageDecimalPercentageForSwapper } from '../../../constants.js';
|
|
@@ -82,7 +81,6 @@ export const getL1ToLongtailQuote = async (input, deps, streamingInterval, swapp
|
|
|
82
81
|
buyAmountAfterFeesCryptoBaseUnit: quotedAmountOut.toString(),
|
|
83
82
|
// This is wrong, we should get the get the value before fees or display ETH value received after the thorchain bridge
|
|
84
83
|
buyAmountBeforeFeesCryptoBaseUnit: quotedAmountOut.toString(),
|
|
85
|
-
allowanceContract: TS_AGGREGATOR_TOKEN_TRANSFER_PROXY_CONTRACT_MAINNET,
|
|
86
84
|
transactionData,
|
|
87
85
|
feeData: { ...s.feeData, networkFeeCryptoBaseUnit },
|
|
88
86
|
})),
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { TS_AGGREGATOR_TOKEN_TRANSFER_PROXY_CONTRACT_MAINNET } from '@shapeshiftoss/contracts';
|
|
2
1
|
import { Err, Ok } from '@sniptt/monads';
|
|
3
2
|
import { getSuccessfulTrades, getThorL1TradeRate, TradeType } from '../../../utils/thorchain/index.js';
|
|
4
3
|
import { assertValidL1ToLongtailTrade } from './assertValidLongtailTrade.js';
|
|
@@ -35,7 +34,6 @@ export const getL1ToLongtailRate = async (input, deps, streamingInterval, swappe
|
|
|
35
34
|
buyAmountAfterFeesCryptoBaseUnit: quotedAmountOut.toString(),
|
|
36
35
|
// This is wrong, we should get the get the value before fees or display ETH value received after the thorchain bridge
|
|
37
36
|
buyAmountBeforeFeesCryptoBaseUnit: quotedAmountOut.toString(),
|
|
38
|
-
allowanceContract: TS_AGGREGATOR_TOKEN_TRANSFER_PROXY_CONTRACT_MAINNET,
|
|
39
37
|
})),
|
|
40
38
|
isLongtail: true,
|
|
41
39
|
});
|
|
@@ -74,7 +74,7 @@ export const getLongtailToL1Quote = async (input, deps, streamingInterval, swapp
|
|
|
74
74
|
return Ok({
|
|
75
75
|
...quote,
|
|
76
76
|
// The aggregator swapIn deadline is tighter than the daemon quote expiry
|
|
77
|
-
deadline: Math.min(quote.deadline, Number(deadline) * 1000),
|
|
77
|
+
deadline: Math.min(quote.deadline ?? Infinity, Number(deadline) * 1000),
|
|
78
78
|
data: data ?? quote.data,
|
|
79
79
|
// This logic will need to be updated to support multi-hop, if that's ever implemented for THORChain
|
|
80
80
|
steps: quote.steps.map(s => ({
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { AssetId } from '@shapeshiftoss/caip';
|
|
2
|
-
export declare const getUniqueAddressSubstring: (destinationAssetId: AssetId, longTailAssetIds: AssetId[]) =>
|
|
2
|
+
export declare const getUniqueAddressSubstring: (destinationAssetId: AssetId, longTailAssetIds: AssetId[]) => string;
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
+
import { fromAssetId } from '@shapeshiftoss/caip';
|
|
2
|
+
const MINIMUM_UNIQUE_SUBSTRING = 2;
|
|
3
|
+
// Mirrors THORNode's externalAssetMatch: a case-insensitive suffix match against the target chain's token list only
|
|
1
4
|
export const getUniqueAddressSubstring = (destinationAssetId, longTailAssetIds) => {
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const { chainId, assetReference } = fromAssetId(destinationAssetId);
|
|
6
|
+
const address = assetReference.toLowerCase();
|
|
7
|
+
const sameChainAddresses = longTailAssetIds
|
|
8
|
+
.map(assetId => fromAssetId(assetId))
|
|
9
|
+
.filter(asset => asset.chainId === chainId)
|
|
10
|
+
.map(asset => asset.assetReference.toLowerCase());
|
|
11
|
+
if (!sameChainAddresses.includes(address))
|
|
12
|
+
return address;
|
|
13
|
+
for (let length = MINIMUM_UNIQUE_SUBSTRING; length < address.length; length++) {
|
|
14
|
+
const suffix = address.slice(-length);
|
|
15
|
+
const matchCount = sameChainAddresses.filter(sameChainAddress => sameChainAddress.endsWith(suffix)).length;
|
|
16
|
+
if (matchCount === 1)
|
|
17
|
+
return suffix;
|
|
8
18
|
}
|
|
9
|
-
|
|
10
|
-
Object.keys(substringsCount).forEach(substring => {
|
|
11
|
-
if (assetId.includes(substring)) {
|
|
12
|
-
substringsCount[substring] += 1;
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
for (const [substring, count] of Object.entries(substringsCount)) {
|
|
17
|
-
if (count === 1) {
|
|
18
|
-
maybeShortenedDestinationAddress = substring;
|
|
19
|
-
break;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return maybeShortenedDestinationAddress;
|
|
19
|
+
return address;
|
|
23
20
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ethChainId, toAssetId } from '@shapeshiftoss/caip';
|
|
1
|
+
import { bscChainId, ethChainId, toAssetId } from '@shapeshiftoss/caip';
|
|
2
2
|
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import longtailTokens from '../../generated/generatedThorLongtailTokens.json';
|
|
3
4
|
import { getUniqueAddressSubstring } from './getUniqueAddressSubstring.js';
|
|
4
5
|
const FINAL_ASSET_ASSETID = toAssetId({
|
|
5
6
|
chainId: ethChainId,
|
|
@@ -16,6 +17,16 @@ const BIGGER_COLLIDING_FINAL_ASSETID = toAssetId({
|
|
|
16
17
|
assetReference: '0xa0b86991c6218b36c1d19d4a2e9eb032a6dF4741',
|
|
17
18
|
assetNamespace: 'erc20',
|
|
18
19
|
});
|
|
20
|
+
const SAME_ADDRESS_OTHER_CHAIN_ASSETID = toAssetId({
|
|
21
|
+
chainId: bscChainId,
|
|
22
|
+
assetReference: '0x8a65ac0E23F31979db06Ec62Af62b432a6dF4741',
|
|
23
|
+
assetNamespace: 'erc20',
|
|
24
|
+
});
|
|
25
|
+
const ONE_INCH_ASSETID = toAssetId({
|
|
26
|
+
chainId: ethChainId,
|
|
27
|
+
assetReference: '0x111111111117dc0aa78b770fa6a738034120c302',
|
|
28
|
+
assetNamespace: 'erc20',
|
|
29
|
+
});
|
|
19
30
|
const SHORTENED_FINAL_ASSET_ADDRESS = 'a6df4741';
|
|
20
31
|
const BIGGER_SHORTENED_FINAL_ASSET_ADDRESS = '432a6df4741';
|
|
21
32
|
const THORCHAIN_ASSETIDS_ONE_COLLISION = [FINAL_ASSET_ASSETID, COLLIDING_FINAL_ASSETID];
|
|
@@ -33,4 +44,21 @@ describe('getUniqueAddressSubstring', () => {
|
|
|
33
44
|
const substring = getUniqueAddressSubstring(FINAL_ASSET_ASSETID, THORCHAIN_ASSETIDS_TWO_COLLISION);
|
|
34
45
|
expect(substring).toBe(BIGGER_SHORTENED_FINAL_ASSET_ADDRESS);
|
|
35
46
|
});
|
|
47
|
+
it('should ignore the same address on other chains', () => {
|
|
48
|
+
const substring = getUniqueAddressSubstring(FINAL_ASSET_ASSETID, [
|
|
49
|
+
...THORCHAIN_ASSETIDS_ONE_COLLISION,
|
|
50
|
+
SAME_ADDRESS_OTHER_CHAIN_ASSETID,
|
|
51
|
+
]);
|
|
52
|
+
expect(substring).toBe(SHORTENED_FINAL_ASSET_ADDRESS);
|
|
53
|
+
});
|
|
54
|
+
it('should return the full address when the asset is not in the list', () => {
|
|
55
|
+
const substring = getUniqueAddressSubstring(FINAL_ASSET_ASSETID, [COLLIDING_FINAL_ASSETID]);
|
|
56
|
+
expect(substring).toBe('0x8a65ac0e23f31979db06ec62af62b432a6df4741');
|
|
57
|
+
});
|
|
58
|
+
it('should return a hex suffix for an address listed on multiple chains', () => {
|
|
59
|
+
expect(longtailTokens).toContain(ONE_INCH_ASSETID);
|
|
60
|
+
const substring = getUniqueAddressSubstring(ONE_INCH_ASSETID, longtailTokens);
|
|
61
|
+
expect(substring).toMatch(/^[0-9a-f]+$/);
|
|
62
|
+
expect('0x111111111117dc0aa78b770fa6a738034120c302'.endsWith(substring)).toBe(true);
|
|
63
|
+
});
|
|
36
64
|
});
|
|
@@ -2,11 +2,13 @@ import { Err, Ok } from '@sniptt/monads';
|
|
|
2
2
|
import { getDefaultSlippageDecimalPercentageForSwapper } from '../../../constants.js';
|
|
3
3
|
import { SwapperName, TradeQuoteError } from '../../../types.js';
|
|
4
4
|
import { assertQuoteAddresses, makeSwapErrorRight } from '../../../utils/index.js';
|
|
5
|
-
import {
|
|
5
|
+
import { isNativeEvmAsset } from '../../../utils/helpers.js';
|
|
6
6
|
import { fetchZrxQuote } from '../utils/fetchFromZrx.js';
|
|
7
|
+
import { getZrxNativeCheckDeadline } from '../utils/getZrxNativeCheckDeadline.js';
|
|
7
8
|
import { getZrxStepData } from '../utils/getZrxStepData.js';
|
|
8
9
|
import { getZrxTradeContext } from '../utils/getZrxTradeContext.js';
|
|
9
10
|
import { assertValidTrade, isWrappedNativeSell } from '../utils/helpers.js';
|
|
11
|
+
const isValidDeadlineSeconds = (deadline) => Number.isSafeInteger(deadline) && deadline > 0 && Number.isSafeInteger(deadline * 1000);
|
|
10
12
|
export const getZrxTradeQuote = async (input, deps) => {
|
|
11
13
|
const { sellAsset, buyAsset, accountNumber, affiliateBps, sellAmountIncludingProtocolFeesCryptoBaseUnit, } = input;
|
|
12
14
|
const maybeAddresses = assertQuoteAddresses(input);
|
|
@@ -39,6 +41,16 @@ export const getZrxTradeQuote = async (input, deps) => {
|
|
|
39
41
|
return Err(maybeZrxQuoteResponse.unwrapErr());
|
|
40
42
|
const { sellAmount, buyAmount, fees, permit2, transaction, route } = maybeZrxQuoteResponse.unwrap();
|
|
41
43
|
const permit2Eip712 = permit2?.eip712;
|
|
44
|
+
const permit2Deadline = permit2Eip712 ? Number(permit2Eip712.message.deadline) : undefined;
|
|
45
|
+
if (permit2Deadline !== undefined &&
|
|
46
|
+
((typeof permit2Eip712?.message.deadline !== 'string' &&
|
|
47
|
+
typeof permit2Eip712?.message.deadline !== 'number') ||
|
|
48
|
+
!isValidDeadlineSeconds(permit2Deadline))) {
|
|
49
|
+
return Err(makeSwapErrorRight({
|
|
50
|
+
message: 'Invalid Permit2 deadline from 0x response',
|
|
51
|
+
code: TradeQuoteError.InvalidResponse,
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
42
54
|
if (!isNativeEvmAsset(sellAsset.assetId) && !isWrappedNativeSell(route) && !permit2Eip712) {
|
|
43
55
|
return Err(makeSwapErrorRight({
|
|
44
56
|
message: 'Missing required Permit2 metadata from 0x response',
|
|
@@ -53,6 +65,17 @@ export const getZrxTradeQuote = async (input, deps) => {
|
|
|
53
65
|
details: { transaction, permit2Eip712 },
|
|
54
66
|
}));
|
|
55
67
|
}
|
|
68
|
+
// Permit2 calldata is not decodable until the signature is spliced in, so only native sells are read
|
|
69
|
+
const nativeCheckDeadline = permit2Eip712
|
|
70
|
+
? undefined
|
|
71
|
+
: getZrxNativeCheckDeadline(transaction.data);
|
|
72
|
+
if (nativeCheckDeadline !== undefined && !isValidDeadlineSeconds(nativeCheckDeadline)) {
|
|
73
|
+
return Err(makeSwapErrorRight({
|
|
74
|
+
message: 'Invalid NATIVE_CHECK deadline in 0x calldata',
|
|
75
|
+
code: TradeQuoteError.InvalidResponse,
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
const deadlineSeconds = permit2Deadline ?? nativeCheckDeadline;
|
|
56
79
|
const maybeContext = getZrxTradeContext({
|
|
57
80
|
input,
|
|
58
81
|
deps,
|
|
@@ -76,7 +99,7 @@ export const getZrxTradeQuote = async (input, deps) => {
|
|
|
76
99
|
const tradeQuote = {
|
|
77
100
|
...tradeCommon,
|
|
78
101
|
quoteOrRate: 'quote',
|
|
79
|
-
deadline:
|
|
102
|
+
deadline: deadlineSeconds === undefined ? undefined : deadlineSeconds * 1000,
|
|
80
103
|
receiveAddress,
|
|
81
104
|
steps: [
|
|
82
105
|
{
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { KnownChainIds } from '@shapeshiftoss/types';
|
|
2
|
+
import { Ok } from '@sniptt/monads';
|
|
3
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
4
|
+
import { TradeQuoteError } from '../../../types.js';
|
|
5
|
+
import { ETH, USDC_MAINNET, WETH } from '../../../utils/test-data/assets.js';
|
|
6
|
+
import { fetchZrxQuote } from '../utils/fetchFromZrx.js';
|
|
7
|
+
import { getZrxTradeQuote } from './getZrxTradeQuote.js';
|
|
8
|
+
vi.mock('../utils/fetchFromZrx', () => ({ fetchZrxQuote: vi.fn() }));
|
|
9
|
+
vi.mock('../utils/getZrxStepData', () => ({
|
|
10
|
+
getZrxStepData: vi.fn(({ permit2Eip712 }) => Promise.resolve(Ok({
|
|
11
|
+
transactionData: {
|
|
12
|
+
type: 'evm',
|
|
13
|
+
chainId: 1,
|
|
14
|
+
to: '0x1111111111111111111111111111111111111111',
|
|
15
|
+
data: '0x1234',
|
|
16
|
+
value: '0',
|
|
17
|
+
...(permit2Eip712 && {
|
|
18
|
+
signatureRequired: { type: 'permit2', eip712: permit2Eip712 },
|
|
19
|
+
}),
|
|
20
|
+
},
|
|
21
|
+
networkFeeCryptoBaseUnit: '100000',
|
|
22
|
+
}))),
|
|
23
|
+
}));
|
|
24
|
+
const input = {
|
|
25
|
+
sellAsset: WETH,
|
|
26
|
+
buyAsset: USDC_MAINNET,
|
|
27
|
+
sellAmountIncludingProtocolFeesCryptoBaseUnit: '1000000000000000000',
|
|
28
|
+
sendAddress: '0x1111111111111111111111111111111111111111',
|
|
29
|
+
receiveAddress: '0x1111111111111111111111111111111111111111',
|
|
30
|
+
accountNumber: 0,
|
|
31
|
+
affiliateBps: '0',
|
|
32
|
+
allowMultiHop: false,
|
|
33
|
+
quoteOrRate: 'quote',
|
|
34
|
+
chainId: KnownChainIds.EthereumMainnet,
|
|
35
|
+
supportsEIP1559: true,
|
|
36
|
+
};
|
|
37
|
+
const deps = {
|
|
38
|
+
assetsById: {},
|
|
39
|
+
config: { VITE_ZRX_BASE_URL: 'https://example.com' },
|
|
40
|
+
};
|
|
41
|
+
const typedData = (deadline) => ({
|
|
42
|
+
domain: { name: 'Permit2', chainId: 1 },
|
|
43
|
+
types: { PermitTransferFrom: [{ name: 'deadline', type: 'uint256' }] },
|
|
44
|
+
primaryType: 'PermitTransferFrom',
|
|
45
|
+
message: { deadline },
|
|
46
|
+
});
|
|
47
|
+
// Live Settler calldata for an ETH -> USDC sell, NATIVE_CHECK deadline 1791997786
|
|
48
|
+
const nativeSellCalldata = '0x1fff991f000000000000000000000000ea8eb5ba11a3ea66f417ae29abf70c6fb4ba9626000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000e750ef800000000000000000000000000000000000000000000000000000000000000a0939d83c32b72441d72643cf60000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000003600000000000000000000000000000000000000000000000000000000000000044bd01c226000000000000000000000000000000000000000000000000000000006acfb75a000000000000000000000000000000000000000000000000016345785d8a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010438c9c147000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00000000000000000000000000000000000000000000000000000000000f4240000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000024d0e30db00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e48d68a156000000000000000000000000666fedd4cdd4e890a5ad20e7b60975409435a64a00000000000000000000000000000000000000000000000000000000000f4240000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040c02aaa39b223fe8d0a0e5c4f27ead9083c756cc201000064fffd8963efd1fc6a506488495d951d5263988d25a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008434ee90ca000000000000000000000000f5c4f3dc02c3fb9279495a8fef7b0741da956157000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000e9a9ab900000000000000000000000000000000000000000000000000000000000f424000000000000000000000000000000000000000000000000000000000';
|
|
49
|
+
const quoteResponse = (eip712, data = '0x1234') => ({
|
|
50
|
+
blockNumber: '1',
|
|
51
|
+
buyAmount: '1000000',
|
|
52
|
+
buyToken: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
53
|
+
sellAmount: input.sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
54
|
+
sellToken: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
55
|
+
fees: { integratorFee: null, zeroExFee: null, gasFee: null },
|
|
56
|
+
issues: { allowance: null, balance: null, simulationIncomplete: false, invalidSourcesPassed: [] },
|
|
57
|
+
liquidityAvailable: true,
|
|
58
|
+
minBuyAmount: '990000',
|
|
59
|
+
route: { fills: [], tokens: [] },
|
|
60
|
+
tokenMetadata: {
|
|
61
|
+
buyToken: { buyTaxBps: null, sellTaxBps: null },
|
|
62
|
+
sellToken: { buyTaxBps: null, sellTaxBps: null },
|
|
63
|
+
},
|
|
64
|
+
totalNetworkFee: null,
|
|
65
|
+
zid: 'test',
|
|
66
|
+
permit2: eip712 ? { type: 'Permit2', hash: '0x1234', eip712 } : null,
|
|
67
|
+
transaction: {
|
|
68
|
+
to: '0x1111111111111111111111111111111111111111',
|
|
69
|
+
data,
|
|
70
|
+
gas: '100000',
|
|
71
|
+
gasPrice: '1000000000',
|
|
72
|
+
value: '0',
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
describe('getZrxTradeQuote Permit2 deadline', () => {
|
|
76
|
+
beforeEach(() => {
|
|
77
|
+
vi.mocked(fetchZrxQuote).mockResolvedValue(Ok(quoteResponse(typedData('1791934983'))));
|
|
78
|
+
});
|
|
79
|
+
it.each(['1791934983', 1791934983])('uses the provider deadline in milliseconds (%s)', async (deadline) => {
|
|
80
|
+
const eip712 = typedData(deadline);
|
|
81
|
+
vi.mocked(fetchZrxQuote).mockResolvedValue(Ok(quoteResponse(eip712)));
|
|
82
|
+
const result = await getZrxTradeQuote(input, deps);
|
|
83
|
+
expect(result.isOk()).toBe(true);
|
|
84
|
+
const [quote] = result.unwrap();
|
|
85
|
+
expect(quote.deadline).toBe(1791934983000);
|
|
86
|
+
expect(quote.steps[0].transactionData).toMatchObject({
|
|
87
|
+
signatureRequired: { eip712 },
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
it.each([undefined, null, true, '', 'invalid', '-1', '1.5', '9007199254740991'])('rejects an invalid Permit2 deadline (%s)', async (deadline) => {
|
|
91
|
+
vi.mocked(fetchZrxQuote).mockResolvedValue(Ok(quoteResponse(typedData(deadline))));
|
|
92
|
+
const result = await getZrxTradeQuote(input, deps);
|
|
93
|
+
expect(result.isErr()).toBe(true);
|
|
94
|
+
expect(result.unwrapErr().code).toBe(TradeQuoteError.InvalidResponse);
|
|
95
|
+
});
|
|
96
|
+
it('reads the NATIVE_CHECK deadline from native-token sell calldata', async () => {
|
|
97
|
+
vi.mocked(fetchZrxQuote).mockResolvedValue(Ok(quoteResponse(null, nativeSellCalldata)));
|
|
98
|
+
const result = await getZrxTradeQuote({ ...input, sellAsset: ETH }, deps);
|
|
99
|
+
expect(result.isOk()).toBe(true);
|
|
100
|
+
expect(result.unwrap()[0].deadline).toBe(1791997786000);
|
|
101
|
+
});
|
|
102
|
+
it('leaves native-token quotes without a NATIVE_CHECK action free of a fabricated deadline', async () => {
|
|
103
|
+
vi.mocked(fetchZrxQuote).mockResolvedValue(Ok(quoteResponse(null)));
|
|
104
|
+
const result = await getZrxTradeQuote({ ...input, sellAsset: ETH }, deps);
|
|
105
|
+
expect(result.isOk()).toBe(true);
|
|
106
|
+
expect(result.unwrap()[0].deadline).toBeUndefined();
|
|
107
|
+
});
|
|
108
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { KnownChainIds } from '@shapeshiftoss/types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TypedData } from 'eip-712';
|
|
3
|
+
import type { Address } from 'viem';
|
|
3
4
|
import type { GetEvmTradeQuoteInput, GetEvmTradeRateInput } from '../../types.js';
|
|
4
5
|
export type ZrxTradeQuoteInput = GetEvmTradeQuoteInput;
|
|
5
6
|
export type ZrxTradeRateInput = GetEvmTradeRateInput;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getZrxNativeCheckDeadline: (data: string) => number | undefined;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { decodeFunctionData, parseAbi, toFunctionSelector } from 'viem';
|
|
2
|
+
const settlerAbi = parseAbi([
|
|
3
|
+
'function execute((address recipient, address buyToken, uint256 minAmountOut) slippage, bytes[] actions, bytes32 zid)',
|
|
4
|
+
'function NATIVE_CHECK(uint256 deadline, uint256 msgValue)',
|
|
5
|
+
]);
|
|
6
|
+
const NATIVE_CHECK_SELECTOR = toFunctionSelector('function NATIVE_CHECK(uint256,uint256)');
|
|
7
|
+
// Native sells carry no Permit2, but Settler reverts with SignatureExpired past any NATIVE_CHECK deadline
|
|
8
|
+
export const getZrxNativeCheckDeadline = (data) => {
|
|
9
|
+
try {
|
|
10
|
+
const { functionName, args } = decodeFunctionData({ abi: settlerAbi, data: data });
|
|
11
|
+
if (functionName !== 'execute')
|
|
12
|
+
return undefined;
|
|
13
|
+
const deadlines = args[1]
|
|
14
|
+
.filter(action => action.startsWith(NATIVE_CHECK_SELECTOR))
|
|
15
|
+
.map(action => decodeFunctionData({ abi: settlerAbi, data: action }))
|
|
16
|
+
.flatMap(decoded => decoded.functionName === 'NATIVE_CHECK' ? [Number(decoded.args[0])] : []);
|
|
17
|
+
return deadlines.length ? Math.min(...deadlines) : undefined;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
};
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -12,14 +12,12 @@ import type { InterpolationOptions } from 'node-polyglot';
|
|
|
12
12
|
import type { AvnuMetadata } from './swappers/AvnuSwapper/types.js';
|
|
13
13
|
import type { BebopMetadata } from './swappers/BebopSwapper/types.js';
|
|
14
14
|
import type { BobGatewayMetadata } from './swappers/BobGatewaySwapper/types.js';
|
|
15
|
-
import type { ButterSwapTransactionMetadata } from './swappers/ButterSwap/types.js';
|
|
16
15
|
import type { ChainflipMetadata } from './swappers/ChainflipSwapper/types.js';
|
|
17
16
|
import type { CowMessageToSign } from './swappers/CowSwapper/types.js';
|
|
18
17
|
import type { DebridgeMetadata } from './swappers/DebridgeSwapper/utils/types.js';
|
|
19
18
|
import type { NearIntentsMetadata } from './swappers/NearIntentsSwapper/types.js';
|
|
20
|
-
import type { RelayMetadata
|
|
19
|
+
import type { RelayMetadata } from './swappers/RelaySwapper/utils/types.js';
|
|
21
20
|
import type { StonfiMetadata, StonfiTransactionData } from './swappers/StonfiSwapper/types.js';
|
|
22
|
-
import type { SunioTransactionData } from './swappers/SunioSwapper/types.js';
|
|
23
21
|
import type { makeSwapperAxiosServiceMonadic } from './utils/index.js';
|
|
24
22
|
import type { MayachainMetadata, ThorchainMetadata } from './utils/thorchain/types.js';
|
|
25
23
|
export type SwapperConfig = {
|
|
@@ -45,6 +43,7 @@ export type SwapperConfig = {
|
|
|
45
43
|
VITE_COWSWAP_BASE_URL: string;
|
|
46
44
|
VITE_PORTALS_BASE_URL: string;
|
|
47
45
|
VITE_ZRX_BASE_URL: string;
|
|
46
|
+
VITE_FYND_BASE_URL: string;
|
|
48
47
|
VITE_CHAINFLIP_API_KEY: string;
|
|
49
48
|
VITE_CHAINFLIP_API_URL: string;
|
|
50
49
|
VITE_FEATURE_CHAINFLIP_SWAP_DCA: boolean;
|
|
@@ -58,6 +57,7 @@ export type SwapperConfig = {
|
|
|
58
57
|
VITE_ACROSS_API_KEY: string;
|
|
59
58
|
VITE_DEBRIDGE_API_URL: string;
|
|
60
59
|
VITE_BOB_GATEWAY_API_KEY: string;
|
|
60
|
+
VITE_SYMBIOSIS_API_URL: string;
|
|
61
61
|
};
|
|
62
62
|
export declare enum SwapperName {
|
|
63
63
|
Thorchain = "THORChain",
|
|
@@ -78,7 +78,9 @@ export declare enum SwapperName {
|
|
|
78
78
|
Stonfi = "STON.fi",
|
|
79
79
|
Across = "Across",
|
|
80
80
|
Debridge = "deBridge",
|
|
81
|
-
BobGateway = "BOB Gateway"
|
|
81
|
+
BobGateway = "BOB Gateway",
|
|
82
|
+
Symbiosis = "Symbiosis",
|
|
83
|
+
Fynd = "Fynd"
|
|
82
84
|
}
|
|
83
85
|
export type SwapSource = SwapperName | `${SwapperName} • ${string}`;
|
|
84
86
|
export type SwapErrorRight = {
|
|
@@ -323,8 +325,9 @@ export type TxBuildData = {
|
|
|
323
325
|
} | {
|
|
324
326
|
type: 'tron';
|
|
325
327
|
to: string;
|
|
326
|
-
data: string;
|
|
327
328
|
value: string;
|
|
329
|
+
data?: string;
|
|
330
|
+
memo?: string;
|
|
328
331
|
} | {
|
|
329
332
|
type: 'cowswap';
|
|
330
333
|
chainId: ChainId;
|
|
@@ -344,12 +347,6 @@ export type TradeStepCommon = {
|
|
|
344
347
|
estimatedExecutionTimeMs: number | undefined;
|
|
345
348
|
swapperMetadata?: SwapperMetadata;
|
|
346
349
|
stonfiTransactionData?: StonfiTransactionData;
|
|
347
|
-
sunioTransactionData?: SunioTransactionData;
|
|
348
|
-
relayTransactionMetadata?: RelayTransactionMetadata;
|
|
349
|
-
butterSwapTransactionMetadata?: ButterSwapTransactionMetadata;
|
|
350
|
-
chainflipSpecific?: {
|
|
351
|
-
depositAddress?: string;
|
|
352
|
-
};
|
|
353
350
|
affiliateFee?: AffiliateFee;
|
|
354
351
|
};
|
|
355
352
|
export type TradeQuoteStep = TradeStepCommon & {
|
|
@@ -456,7 +453,7 @@ export type TradeQuote = TradeQuoteBase & {
|
|
|
456
453
|
} & {
|
|
457
454
|
quoteOrRate: 'quote';
|
|
458
455
|
receiveAddress: string;
|
|
459
|
-
deadline
|
|
456
|
+
deadline?: number;
|
|
460
457
|
};
|
|
461
458
|
export type MultiHopTradeQuote = TradeQuote & {
|
|
462
459
|
steps: MultiHopTradeQuoteSteps;
|
|
@@ -477,6 +474,11 @@ export type EvmMessageExecutionProps = {
|
|
|
477
474
|
};
|
|
478
475
|
export type UtxoTransactionExecutionProps = {
|
|
479
476
|
signAndBroadcastTransaction: (txToSign: SignTx<UtxoChainId>) => Promise<string>;
|
|
477
|
+
signTransaction?: (txToSign: SignTx<UtxoChainId>) => Promise<string>;
|
|
478
|
+
};
|
|
479
|
+
export type UtxoTransactionExecutionContext = {
|
|
480
|
+
config: SwapperConfig;
|
|
481
|
+
swapperMetadata: SwapperMetadata | undefined;
|
|
480
482
|
};
|
|
481
483
|
export type CosmosSdkTransactionExecutionProps = {
|
|
482
484
|
signAndBroadcastTransaction: (txToSign: SignTx<CosmosSdkChainId>) => Promise<string>;
|
|
@@ -587,7 +589,7 @@ export type Swapper = {
|
|
|
587
589
|
supportsExternalPayment?: boolean;
|
|
588
590
|
executeEvmTransaction?: (txToSign: SignTx<EvmChainId>, callbacks: EvmTransactionExecutionProps) => Promise<string>;
|
|
589
591
|
executeEvmMessage?: (txMetaToSign: EvmMessageToSign, callbacks: EvmMessageExecutionProps, config: SwapperConfig) => Promise<string>;
|
|
590
|
-
executeUtxoTransaction?: (txToSign: SignTx<UtxoChainId>, callbacks: UtxoTransactionExecutionProps) => Promise<string>;
|
|
592
|
+
executeUtxoTransaction?: (txToSign: SignTx<UtxoChainId>, callbacks: UtxoTransactionExecutionProps, context?: UtxoTransactionExecutionContext) => Promise<string>;
|
|
591
593
|
executeCosmosSdkTransaction?: (txToSign: SignTx<CosmosSdkChainId>, callbacks: CosmosSdkTransactionExecutionProps) => Promise<string>;
|
|
592
594
|
executeSolanaTransaction?: (txToSign: SolanaSignTx, callbacks: SolanaTransactionExecutionProps) => Promise<string>;
|
|
593
595
|
executeSolanaMessage?: (messageData: SolanaMessageToSign, callbacks: SolanaMessageExecutionProps, config: SwapperConfig) => Promise<string>;
|
package/dist/esm/types.js
CHANGED
|
@@ -19,6 +19,8 @@ export var SwapperName;
|
|
|
19
19
|
SwapperName["Across"] = "Across";
|
|
20
20
|
SwapperName["Debridge"] = "deBridge";
|
|
21
21
|
SwapperName["BobGateway"] = "BOB Gateway";
|
|
22
|
+
SwapperName["Symbiosis"] = "Symbiosis";
|
|
23
|
+
SwapperName["Fynd"] = "Fynd";
|
|
22
24
|
})(SwapperName || (SwapperName = {}));
|
|
23
25
|
export var TradeQuoteError;
|
|
24
26
|
(function (TradeQuoteError) {
|