@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,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const types_1 = require("@shapeshiftoss/types");
|
|
4
|
+
const monads_1 = require("@sniptt/monads");
|
|
5
|
+
const vitest_1 = require("vitest");
|
|
6
|
+
const types_2 = require("../../../types");
|
|
7
|
+
const assets_1 = require("../../../utils/test-data/assets");
|
|
8
|
+
const fetchFromZrx_1 = require("../utils/fetchFromZrx");
|
|
9
|
+
const getZrxTradeQuote_1 = require("./getZrxTradeQuote");
|
|
10
|
+
vitest_1.vi.mock('../utils/fetchFromZrx', () => ({ fetchZrxQuote: vitest_1.vi.fn() }));
|
|
11
|
+
vitest_1.vi.mock('../utils/getZrxStepData', () => ({
|
|
12
|
+
getZrxStepData: vitest_1.vi.fn(({ permit2Eip712 }) => Promise.resolve((0, monads_1.Ok)({
|
|
13
|
+
transactionData: {
|
|
14
|
+
type: 'evm',
|
|
15
|
+
chainId: 1,
|
|
16
|
+
to: '0x1111111111111111111111111111111111111111',
|
|
17
|
+
data: '0x1234',
|
|
18
|
+
value: '0',
|
|
19
|
+
...(permit2Eip712 && {
|
|
20
|
+
signatureRequired: { type: 'permit2', eip712: permit2Eip712 },
|
|
21
|
+
}),
|
|
22
|
+
},
|
|
23
|
+
networkFeeCryptoBaseUnit: '100000',
|
|
24
|
+
}))),
|
|
25
|
+
}));
|
|
26
|
+
const input = {
|
|
27
|
+
sellAsset: assets_1.WETH,
|
|
28
|
+
buyAsset: assets_1.USDC_MAINNET,
|
|
29
|
+
sellAmountIncludingProtocolFeesCryptoBaseUnit: '1000000000000000000',
|
|
30
|
+
sendAddress: '0x1111111111111111111111111111111111111111',
|
|
31
|
+
receiveAddress: '0x1111111111111111111111111111111111111111',
|
|
32
|
+
accountNumber: 0,
|
|
33
|
+
affiliateBps: '0',
|
|
34
|
+
allowMultiHop: false,
|
|
35
|
+
quoteOrRate: 'quote',
|
|
36
|
+
chainId: types_1.KnownChainIds.EthereumMainnet,
|
|
37
|
+
supportsEIP1559: true,
|
|
38
|
+
};
|
|
39
|
+
const deps = {
|
|
40
|
+
assetsById: {},
|
|
41
|
+
config: { VITE_ZRX_BASE_URL: 'https://example.com' },
|
|
42
|
+
};
|
|
43
|
+
const typedData = (deadline) => ({
|
|
44
|
+
domain: { name: 'Permit2', chainId: 1 },
|
|
45
|
+
types: { PermitTransferFrom: [{ name: 'deadline', type: 'uint256' }] },
|
|
46
|
+
primaryType: 'PermitTransferFrom',
|
|
47
|
+
message: { deadline },
|
|
48
|
+
});
|
|
49
|
+
// Live Settler calldata for an ETH -> USDC sell, NATIVE_CHECK deadline 1791997786
|
|
50
|
+
const nativeSellCalldata = '0x1fff991f000000000000000000000000ea8eb5ba11a3ea66f417ae29abf70c6fb4ba9626000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000e750ef800000000000000000000000000000000000000000000000000000000000000a0939d83c32b72441d72643cf60000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000003600000000000000000000000000000000000000000000000000000000000000044bd01c226000000000000000000000000000000000000000000000000000000006acfb75a000000000000000000000000000000000000000000000000016345785d8a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010438c9c147000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00000000000000000000000000000000000000000000000000000000000f4240000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000024d0e30db00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e48d68a156000000000000000000000000666fedd4cdd4e890a5ad20e7b60975409435a64a00000000000000000000000000000000000000000000000000000000000f4240000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040c02aaa39b223fe8d0a0e5c4f27ead9083c756cc201000064fffd8963efd1fc6a506488495d951d5263988d25a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008434ee90ca000000000000000000000000f5c4f3dc02c3fb9279495a8fef7b0741da956157000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000e9a9ab900000000000000000000000000000000000000000000000000000000000f424000000000000000000000000000000000000000000000000000000000';
|
|
51
|
+
const quoteResponse = (eip712, data = '0x1234') => ({
|
|
52
|
+
blockNumber: '1',
|
|
53
|
+
buyAmount: '1000000',
|
|
54
|
+
buyToken: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
55
|
+
sellAmount: input.sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
56
|
+
sellToken: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
57
|
+
fees: { integratorFee: null, zeroExFee: null, gasFee: null },
|
|
58
|
+
issues: { allowance: null, balance: null, simulationIncomplete: false, invalidSourcesPassed: [] },
|
|
59
|
+
liquidityAvailable: true,
|
|
60
|
+
minBuyAmount: '990000',
|
|
61
|
+
route: { fills: [], tokens: [] },
|
|
62
|
+
tokenMetadata: {
|
|
63
|
+
buyToken: { buyTaxBps: null, sellTaxBps: null },
|
|
64
|
+
sellToken: { buyTaxBps: null, sellTaxBps: null },
|
|
65
|
+
},
|
|
66
|
+
totalNetworkFee: null,
|
|
67
|
+
zid: 'test',
|
|
68
|
+
permit2: eip712 ? { type: 'Permit2', hash: '0x1234', eip712 } : null,
|
|
69
|
+
transaction: {
|
|
70
|
+
to: '0x1111111111111111111111111111111111111111',
|
|
71
|
+
data,
|
|
72
|
+
gas: '100000',
|
|
73
|
+
gasPrice: '1000000000',
|
|
74
|
+
value: '0',
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
(0, vitest_1.describe)('getZrxTradeQuote Permit2 deadline', () => {
|
|
78
|
+
(0, vitest_1.beforeEach)(() => {
|
|
79
|
+
vitest_1.vi.mocked(fetchFromZrx_1.fetchZrxQuote).mockResolvedValue((0, monads_1.Ok)(quoteResponse(typedData('1791934983'))));
|
|
80
|
+
});
|
|
81
|
+
vitest_1.it.each(['1791934983', 1791934983])('uses the provider deadline in milliseconds (%s)', async (deadline) => {
|
|
82
|
+
const eip712 = typedData(deadline);
|
|
83
|
+
vitest_1.vi.mocked(fetchFromZrx_1.fetchZrxQuote).mockResolvedValue((0, monads_1.Ok)(quoteResponse(eip712)));
|
|
84
|
+
const result = await (0, getZrxTradeQuote_1.getZrxTradeQuote)(input, deps);
|
|
85
|
+
(0, vitest_1.expect)(result.isOk()).toBe(true);
|
|
86
|
+
const [quote] = result.unwrap();
|
|
87
|
+
(0, vitest_1.expect)(quote.deadline).toBe(1791934983000);
|
|
88
|
+
(0, vitest_1.expect)(quote.steps[0].transactionData).toMatchObject({
|
|
89
|
+
signatureRequired: { eip712 },
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
vitest_1.it.each([undefined, null, true, '', 'invalid', '-1', '1.5', '9007199254740991'])('rejects an invalid Permit2 deadline (%s)', async (deadline) => {
|
|
93
|
+
vitest_1.vi.mocked(fetchFromZrx_1.fetchZrxQuote).mockResolvedValue((0, monads_1.Ok)(quoteResponse(typedData(deadline))));
|
|
94
|
+
const result = await (0, getZrxTradeQuote_1.getZrxTradeQuote)(input, deps);
|
|
95
|
+
(0, vitest_1.expect)(result.isErr()).toBe(true);
|
|
96
|
+
(0, vitest_1.expect)(result.unwrapErr().code).toBe(types_2.TradeQuoteError.InvalidResponse);
|
|
97
|
+
});
|
|
98
|
+
(0, vitest_1.it)('reads the NATIVE_CHECK deadline from native-token sell calldata', async () => {
|
|
99
|
+
vitest_1.vi.mocked(fetchFromZrx_1.fetchZrxQuote).mockResolvedValue((0, monads_1.Ok)(quoteResponse(null, nativeSellCalldata)));
|
|
100
|
+
const result = await (0, getZrxTradeQuote_1.getZrxTradeQuote)({ ...input, sellAsset: assets_1.ETH }, deps);
|
|
101
|
+
(0, vitest_1.expect)(result.isOk()).toBe(true);
|
|
102
|
+
(0, vitest_1.expect)(result.unwrap()[0].deadline).toBe(1791997786000);
|
|
103
|
+
});
|
|
104
|
+
(0, vitest_1.it)('leaves native-token quotes without a NATIVE_CHECK action free of a fabricated deadline', async () => {
|
|
105
|
+
vitest_1.vi.mocked(fetchFromZrx_1.fetchZrxQuote).mockResolvedValue((0, monads_1.Ok)(quoteResponse(null)));
|
|
106
|
+
const result = await (0, getZrxTradeQuote_1.getZrxTradeQuote)({ ...input, sellAsset: assets_1.ETH }, deps);
|
|
107
|
+
(0, vitest_1.expect)(result.isOk()).toBe(true);
|
|
108
|
+
(0, vitest_1.expect)(result.unwrap()[0].deadline).toBeUndefined();
|
|
109
|
+
});
|
|
110
|
+
});
|
|
@@ -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';
|
|
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,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getZrxNativeCheckDeadline = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const settlerAbi = (0, viem_1.parseAbi)([
|
|
6
|
+
'function execute((address recipient, address buyToken, uint256 minAmountOut) slippage, bytes[] actions, bytes32 zid)',
|
|
7
|
+
'function NATIVE_CHECK(uint256 deadline, uint256 msgValue)',
|
|
8
|
+
]);
|
|
9
|
+
const NATIVE_CHECK_SELECTOR = (0, viem_1.toFunctionSelector)('function NATIVE_CHECK(uint256,uint256)');
|
|
10
|
+
// Native sells carry no Permit2, but Settler reverts with SignatureExpired past any NATIVE_CHECK deadline
|
|
11
|
+
const getZrxNativeCheckDeadline = (data) => {
|
|
12
|
+
try {
|
|
13
|
+
const { functionName, args } = (0, viem_1.decodeFunctionData)({ abi: settlerAbi, data: data });
|
|
14
|
+
if (functionName !== 'execute')
|
|
15
|
+
return undefined;
|
|
16
|
+
const deadlines = args[1]
|
|
17
|
+
.filter(action => action.startsWith(NATIVE_CHECK_SELECTOR))
|
|
18
|
+
.map(action => (0, viem_1.decodeFunctionData)({ abi: settlerAbi, data: action }))
|
|
19
|
+
.flatMap(decoded => decoded.functionName === 'NATIVE_CHECK' ? [Number(decoded.args[0])] : []);
|
|
20
|
+
return deadlines.length ? Math.min(...deadlines) : undefined;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
exports.getZrxNativeCheckDeadline = getZrxNativeCheckDeadline;
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -12,14 +12,12 @@ import type { InterpolationOptions } from 'node-polyglot';
|
|
|
12
12
|
import type { AvnuMetadata } from './swappers/AvnuSwapper/types';
|
|
13
13
|
import type { BebopMetadata } from './swappers/BebopSwapper/types';
|
|
14
14
|
import type { BobGatewayMetadata } from './swappers/BobGatewaySwapper/types';
|
|
15
|
-
import type { ButterSwapTransactionMetadata } from './swappers/ButterSwap/types';
|
|
16
15
|
import type { ChainflipMetadata } from './swappers/ChainflipSwapper/types';
|
|
17
16
|
import type { CowMessageToSign } from './swappers/CowSwapper/types';
|
|
18
17
|
import type { DebridgeMetadata } from './swappers/DebridgeSwapper/utils/types';
|
|
19
18
|
import type { NearIntentsMetadata } from './swappers/NearIntentsSwapper/types';
|
|
20
|
-
import type { RelayMetadata
|
|
19
|
+
import type { RelayMetadata } from './swappers/RelaySwapper/utils/types';
|
|
21
20
|
import type { StonfiMetadata, StonfiTransactionData } from './swappers/StonfiSwapper/types';
|
|
22
|
-
import type { SunioTransactionData } from './swappers/SunioSwapper/types';
|
|
23
21
|
import type { makeSwapperAxiosServiceMonadic } from './utils';
|
|
24
22
|
import type { MayachainMetadata, ThorchainMetadata } from './utils/thorchain/types';
|
|
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/cjs/types.js
CHANGED
|
@@ -22,6 +22,8 @@ var SwapperName;
|
|
|
22
22
|
SwapperName["Across"] = "Across";
|
|
23
23
|
SwapperName["Debridge"] = "deBridge";
|
|
24
24
|
SwapperName["BobGateway"] = "BOB Gateway";
|
|
25
|
+
SwapperName["Symbiosis"] = "Symbiosis";
|
|
26
|
+
SwapperName["Fynd"] = "Fynd";
|
|
25
27
|
})(SwapperName || (exports.SwapperName = SwapperName = {}));
|
|
26
28
|
var TradeQuoteError;
|
|
27
29
|
(function (TradeQuoteError) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { AssetId, ChainId } from '@shapeshiftoss/caip';
|
|
2
2
|
import type { TradeAmount, TradeStepCommon } from '../types';
|
|
3
3
|
import { SwapperName } from '../types';
|
|
4
|
-
export declare const FALLBACK_QUOTE_DEADLINE_MS = 60000;
|
|
5
4
|
export declare const getTradeAmount: (input: {
|
|
6
5
|
sellAmountIncludingProtocolFeesCryptoBaseUnit: string;
|
|
7
6
|
} | {
|
|
@@ -10,5 +9,5 @@ export declare const getTradeAmount: (input: {
|
|
|
10
9
|
export declare const normalizeEpochToMs: (value: number) => number;
|
|
11
10
|
export declare const isNativeEvmAsset: (assetId: AssetId) => boolean;
|
|
12
11
|
export declare const getTreasuryAddressFromChainId: (chainId: ChainId) => string;
|
|
13
|
-
export type DepositAddressStep = Pick<TradeStepCommon, '
|
|
12
|
+
export type DepositAddressStep = Pick<TradeStepCommon, 'swapperMetadata'>;
|
|
14
13
|
export declare const getDepositAddress: (step: DepositAddressStep, swapperName: SwapperName) => string | undefined;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDepositAddress = exports.getTreasuryAddressFromChainId = exports.isNativeEvmAsset = exports.normalizeEpochToMs = exports.getTradeAmount =
|
|
3
|
+
exports.getDepositAddress = exports.getTreasuryAddressFromChainId = exports.isNativeEvmAsset = exports.normalizeEpochToMs = exports.getTradeAmount = void 0;
|
|
4
4
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
5
5
|
const types_1 = require("@shapeshiftoss/types");
|
|
6
6
|
const utils_1 = require("@shapeshiftoss/utils");
|
|
7
7
|
const types_2 = require("../types");
|
|
8
|
-
// Deadline for providers without their own expiry - short enough to keep priced amounts honest
|
|
9
|
-
exports.FALLBACK_QUOTE_DEADLINE_MS = 60_000;
|
|
10
8
|
const getTradeAmount = (input) => 'buyAmountCryptoBaseUnit' in input
|
|
11
9
|
? { direction: 'exactOut', cryptoBaseUnit: input.buyAmountCryptoBaseUnit }
|
|
12
10
|
: { direction: 'exactIn', cryptoBaseUnit: input.sellAmountIncludingProtocolFeesCryptoBaseUnit };
|
|
@@ -23,33 +21,8 @@ const normalizeEpochToMs = (value) => {
|
|
|
23
21
|
};
|
|
24
22
|
exports.normalizeEpochToMs = normalizeEpochToMs;
|
|
25
23
|
const isNativeEvmAsset = (assetId) => {
|
|
26
|
-
const { chainId } = (0, caip_1.fromAssetId)(assetId);
|
|
27
|
-
|
|
28
|
-
case types_1.KnownChainIds.EthereumMainnet:
|
|
29
|
-
return assetId === caip_1.ethAssetId;
|
|
30
|
-
case types_1.KnownChainIds.AvalancheMainnet:
|
|
31
|
-
return assetId === caip_1.avalancheAssetId;
|
|
32
|
-
case types_1.KnownChainIds.OptimismMainnet:
|
|
33
|
-
return assetId === caip_1.optimismAssetId;
|
|
34
|
-
case types_1.KnownChainIds.BnbSmartChainMainnet:
|
|
35
|
-
return assetId === caip_1.bscAssetId;
|
|
36
|
-
case types_1.KnownChainIds.PolygonMainnet:
|
|
37
|
-
return assetId === caip_1.polygonAssetId;
|
|
38
|
-
case types_1.KnownChainIds.GnosisMainnet:
|
|
39
|
-
return assetId === caip_1.gnosisAssetId;
|
|
40
|
-
case types_1.KnownChainIds.ArbitrumMainnet:
|
|
41
|
-
return assetId === caip_1.arbitrumAssetId;
|
|
42
|
-
case types_1.KnownChainIds.BaseMainnet:
|
|
43
|
-
return assetId === caip_1.baseAssetId;
|
|
44
|
-
case types_1.KnownChainIds.MonadMainnet:
|
|
45
|
-
return assetId === caip_1.monadAssetId;
|
|
46
|
-
case types_1.KnownChainIds.PlasmaMainnet:
|
|
47
|
-
return assetId === caip_1.plasmaAssetId;
|
|
48
|
-
case types_1.KnownChainIds.KatanaMainnet:
|
|
49
|
-
return assetId === caip_1.katanaAssetId;
|
|
50
|
-
default:
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
24
|
+
const { chainId, chainNamespace } = (0, caip_1.fromAssetId)(assetId);
|
|
25
|
+
return chainNamespace === caip_1.CHAIN_NAMESPACE.Evm && assetId === (0, utils_1.chainIdToFeeAssetId)(chainId);
|
|
53
26
|
};
|
|
54
27
|
exports.isNativeEvmAsset = isNativeEvmAsset;
|
|
55
28
|
const DAO_TREASURY_BY_CHAIN_ID = {
|
|
@@ -84,8 +57,11 @@ const getTreasuryAddressFromChainId = (chainId) => {
|
|
|
84
57
|
exports.getTreasuryAddressFromChainId = getTreasuryAddressFromChainId;
|
|
85
58
|
const getDepositAddress = (step, swapperName) => {
|
|
86
59
|
switch (swapperName) {
|
|
87
|
-
case types_2.SwapperName.Chainflip:
|
|
88
|
-
|
|
60
|
+
case types_2.SwapperName.Chainflip: {
|
|
61
|
+
if (step.swapperMetadata?.name !== 'chainflip')
|
|
62
|
+
return;
|
|
63
|
+
return step.swapperMetadata.depositAddress || undefined;
|
|
64
|
+
}
|
|
89
65
|
case types_2.SwapperName.NearIntents: {
|
|
90
66
|
if (step.swapperMetadata?.name !== 'nearIntents')
|
|
91
67
|
return;
|
|
@@ -57,7 +57,9 @@ const helpers_1 = require("./helpers");
|
|
|
57
57
|
const makeStep = (step) => step;
|
|
58
58
|
(0, vitest_1.describe)('getDepositAddress', () => {
|
|
59
59
|
(0, vitest_1.it)('reads the chainflip deposit address', () => {
|
|
60
|
-
const step = makeStep({
|
|
60
|
+
const step = makeStep({
|
|
61
|
+
swapperMetadata: { name: 'chainflip', swapId: 1, depositAddress: 'bc1qdeposit' },
|
|
62
|
+
});
|
|
61
63
|
(0, vitest_1.expect)((0, helpers_1.getDepositAddress)(step, types_2.SwapperName.Chainflip)).toBe('bc1qdeposit');
|
|
62
64
|
});
|
|
63
65
|
(0, vitest_1.it)('returns undefined when chainflip has no deposit address', () => {
|
|
@@ -80,7 +82,9 @@ const makeStep = (step) => step;
|
|
|
80
82
|
(0, vitest_1.expect)((0, helpers_1.getDepositAddress)(step, types_2.SwapperName.NearIntents)).toBeUndefined();
|
|
81
83
|
});
|
|
82
84
|
(0, vitest_1.it)('returns undefined for swappers that do not use deposit addresses', () => {
|
|
83
|
-
const step = makeStep({
|
|
85
|
+
const step = makeStep({
|
|
86
|
+
swapperMetadata: { name: 'chainflip', swapId: 1, depositAddress: 'bc1qdeposit' },
|
|
87
|
+
});
|
|
84
88
|
(0, vitest_1.expect)((0, helpers_1.getDepositAddress)(step, types_2.SwapperName.Relay)).toBeUndefined();
|
|
85
89
|
});
|
|
86
90
|
});
|
|
@@ -5,7 +5,6 @@ const caip_1 = require("@shapeshiftoss/caip");
|
|
|
5
5
|
const contracts_1 = require("@shapeshiftoss/contracts");
|
|
6
6
|
const utils_1 = require("@shapeshiftoss/utils");
|
|
7
7
|
const monads_1 = require("@sniptt/monads");
|
|
8
|
-
const tronweb_1 = require("tronweb");
|
|
9
8
|
const viem_1 = require("viem");
|
|
10
9
|
const types_1 = require("../../types");
|
|
11
10
|
const utils_2 = require("../../utils");
|
|
@@ -272,58 +271,42 @@ async function getThorStepData({ type, input, from, deps, swapperName, tradeType
|
|
|
272
271
|
}
|
|
273
272
|
case caip_1.CHAIN_NAMESPACE.Tron: {
|
|
274
273
|
const { vault } = await (0, getThorTxData_1.getThorTxData)({ sellAsset, config, swapperName });
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
const bandwidthPrice = params.find(p => p.key === 'getTransactionFee')?.value ?? 1000;
|
|
291
|
-
const energyPrice = params.find(p => p.key === 'getEnergyFee')?.value ?? 100;
|
|
292
|
-
if (contractAddress) {
|
|
293
|
-
// TRC20: Estimate energy with actual recipient
|
|
294
|
-
try {
|
|
295
|
-
const result = await tronWeb.transactionBuilder.triggerConstantContract(contractAddress, 'transfer(address,uint256)', {}, [
|
|
296
|
-
{ type: 'address', value: vault },
|
|
297
|
-
{ type: 'uint256', value: sellAmountCryptoBaseUnit },
|
|
298
|
-
], input.receiveAddress);
|
|
299
|
-
const energyUsed = result.energy_used ?? 65000;
|
|
300
|
-
const energyFee = energyUsed * energyPrice * 1.5; // 1.5x safety margin
|
|
301
|
-
const bandwidthFee = 276 * bandwidthPrice; // TRC20 bandwidth
|
|
302
|
-
return String(Math.ceil(energyFee + bandwidthFee));
|
|
303
|
-
}
|
|
304
|
-
catch {
|
|
305
|
-
// Fallback: Conservative estimate
|
|
306
|
-
return String(13_000_000); // 13 TRX worst case
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
// TRX transfer bandwidth: Base tx + memo bytes
|
|
310
|
-
const baseBytes = 198;
|
|
311
|
-
const memoBytes = rawMemo ? Buffer.from(rawMemo, 'utf8').length : 0;
|
|
312
|
-
const totalBandwidth = baseBytes + memoBytes;
|
|
313
|
-
return String(totalBandwidth * bandwidthPrice);
|
|
314
|
-
}
|
|
315
|
-
catch {
|
|
316
|
-
// Leave as undefined if estimation fails
|
|
317
|
-
return undefined;
|
|
318
|
-
}
|
|
319
|
-
})();
|
|
274
|
+
const adapter = deps.assertGetTronChainAdapter(sellAsset.chainId);
|
|
275
|
+
const contractAddress = (0, utils_1.contractAddressOrUndefined)(sellAsset.assetId);
|
|
276
|
+
const estimate = async (txMemo) => {
|
|
277
|
+
const { fast } = await adapter.getFeeData({
|
|
278
|
+
to: vault,
|
|
279
|
+
value: sellAmountCryptoBaseUnit,
|
|
280
|
+
chainSpecific: {
|
|
281
|
+
from,
|
|
282
|
+
contractAddress,
|
|
283
|
+
memo: txMemo,
|
|
284
|
+
requireEnergyShare: type === 'quote',
|
|
285
|
+
},
|
|
286
|
+
});
|
|
287
|
+
return fast.txFee;
|
|
288
|
+
};
|
|
320
289
|
if (type === 'rate') {
|
|
290
|
+
// Rates size the memo with the raw thornode memo (processed memo is '' for rates)
|
|
291
|
+
const networkFeeCryptoBaseUnit = await (async () => {
|
|
292
|
+
try {
|
|
293
|
+
return await estimate(rawMemo);
|
|
294
|
+
}
|
|
295
|
+
catch { }
|
|
296
|
+
})();
|
|
321
297
|
const stepData = { networkFeeCryptoBaseUnit };
|
|
322
298
|
return (0, monads_1.Ok)(stepData);
|
|
323
299
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
300
|
+
try {
|
|
301
|
+
const stepData = {
|
|
302
|
+
transactionData: { type: 'tron', to: vault, value: sellAmountCryptoBaseUnit, memo },
|
|
303
|
+
networkFeeCryptoBaseUnit: await estimate(memo),
|
|
304
|
+
};
|
|
305
|
+
return (0, monads_1.Ok)(stepData);
|
|
306
|
+
}
|
|
307
|
+
catch (error) {
|
|
308
|
+
return (0, monads_1.Err)((0, utils_2.makeNetworkFeeEstimationFailedErr)('getThorStepData', error));
|
|
309
|
+
}
|
|
327
310
|
}
|
|
328
311
|
default:
|
|
329
312
|
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const caip_1 = require("@shapeshiftoss/caip");
|
|
4
|
+
const vitest_1 = require("vitest");
|
|
5
|
+
const types_1 = require("../../types");
|
|
6
|
+
const assets_1 = require("../test-data/assets");
|
|
7
|
+
const getThorStepData_1 = require("./getThorStepData");
|
|
8
|
+
const types_2 = require("./types");
|
|
9
|
+
vitest_1.vi.mock('./getThorTxData', () => ({
|
|
10
|
+
getThorTxData: vitest_1.vi.fn().mockResolvedValue({ vault: 'TVault' }),
|
|
11
|
+
getThorRouterAndVault: vitest_1.vi.fn(),
|
|
12
|
+
}));
|
|
13
|
+
const USDT = 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t';
|
|
14
|
+
const USDT_TRON = { ...assets_1.ETH, assetId: `${caip_1.tronChainId}/trc20:${USDT}`, chainId: caip_1.tronChainId };
|
|
15
|
+
const FROM = 'TT2T17KZhoDu47i2E4FWxfG79zdkEWkU9N';
|
|
16
|
+
const tronAdapter = (txFee = '9000000') => ({
|
|
17
|
+
getFeeData: vitest_1.vi.fn().mockResolvedValue({ fast: { txFee } }),
|
|
18
|
+
});
|
|
19
|
+
const makeDeps = (tron) => ({ config: {}, assertGetTronChainAdapter: () => tron });
|
|
20
|
+
const baseArgs = {
|
|
21
|
+
swapperName: types_1.SwapperName.Thorchain,
|
|
22
|
+
tradeType: types_2.TradeType.L1ToL1,
|
|
23
|
+
sellAsset: USDT_TRON,
|
|
24
|
+
sellAmountCryptoBaseUnit: '100000000',
|
|
25
|
+
expiry: 0,
|
|
26
|
+
rawMemo: '=:ETH.ETH:0xabc:1',
|
|
27
|
+
};
|
|
28
|
+
(0, vitest_1.describe)('getThorStepData tron', () => {
|
|
29
|
+
(0, vitest_1.it)('carries the vault transfer as transactionData and estimates it for a quote', async () => {
|
|
30
|
+
const adapter = tronAdapter();
|
|
31
|
+
const actual = await (0, getThorStepData_1.getThorStepData)({
|
|
32
|
+
...baseArgs,
|
|
33
|
+
type: 'quote',
|
|
34
|
+
input: {},
|
|
35
|
+
deps: makeDeps(adapter),
|
|
36
|
+
from: FROM,
|
|
37
|
+
memo: '=:ETH.ETH:0xabc:1/1/0:ss:55',
|
|
38
|
+
});
|
|
39
|
+
(0, vitest_1.expect)(actual.unwrap()).toEqual({
|
|
40
|
+
transactionData: {
|
|
41
|
+
type: 'tron',
|
|
42
|
+
to: 'TVault',
|
|
43
|
+
value: '100000000',
|
|
44
|
+
memo: '=:ETH.ETH:0xabc:1/1/0:ss:55',
|
|
45
|
+
},
|
|
46
|
+
networkFeeCryptoBaseUnit: '9000000',
|
|
47
|
+
});
|
|
48
|
+
(0, vitest_1.expect)(adapter.getFeeData).toHaveBeenCalledWith({
|
|
49
|
+
to: 'TVault',
|
|
50
|
+
value: '100000000',
|
|
51
|
+
chainSpecific: {
|
|
52
|
+
from: FROM,
|
|
53
|
+
contractAddress: USDT,
|
|
54
|
+
memo: '=:ETH.ETH:0xabc:1/1/0:ss:55',
|
|
55
|
+
requireEnergyShare: true,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
(0, vitest_1.it)('fails the quote when estimation fails', async () => {
|
|
60
|
+
const adapter = tronAdapter();
|
|
61
|
+
adapter.getFeeData.mockRejectedValue(new Error('rpc down'));
|
|
62
|
+
const actual = await (0, getThorStepData_1.getThorStepData)({
|
|
63
|
+
...baseArgs,
|
|
64
|
+
type: 'quote',
|
|
65
|
+
input: {},
|
|
66
|
+
deps: makeDeps(adapter),
|
|
67
|
+
from: FROM,
|
|
68
|
+
memo: '=:ETH.ETH:0xabc:1/1/0:ss:55',
|
|
69
|
+
});
|
|
70
|
+
(0, vitest_1.expect)(actual.isErr()).toBe(true);
|
|
71
|
+
});
|
|
72
|
+
(0, vitest_1.it)('sizes a rate with the raw memo and no sender', async () => {
|
|
73
|
+
const adapter = tronAdapter();
|
|
74
|
+
const actual = await (0, getThorStepData_1.getThorStepData)({
|
|
75
|
+
...baseArgs,
|
|
76
|
+
type: 'rate',
|
|
77
|
+
input: {},
|
|
78
|
+
deps: makeDeps(adapter),
|
|
79
|
+
memo: '',
|
|
80
|
+
});
|
|
81
|
+
(0, vitest_1.expect)(actual.unwrap()).toEqual({ networkFeeCryptoBaseUnit: '9000000' });
|
|
82
|
+
(0, vitest_1.expect)(adapter.getFeeData).toHaveBeenCalledWith({
|
|
83
|
+
to: 'TVault',
|
|
84
|
+
value: '100000000',
|
|
85
|
+
chainSpecific: {
|
|
86
|
+
from: undefined,
|
|
87
|
+
contractAddress: USDT,
|
|
88
|
+
memo: '=:ETH.ETH:0xabc:1',
|
|
89
|
+
requireEnergyShare: false,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
});
|
|
@@ -15,7 +15,6 @@ export * from './getThorL1TradeContexts';
|
|
|
15
15
|
export * from './getThorL1TradeQuote';
|
|
16
16
|
export * from './getThorL1TradeRate';
|
|
17
17
|
export * from './getPoolDetails';
|
|
18
|
-
export * as tron from './tron';
|
|
19
18
|
export declare const getChainIdBySwapper: (swapperName: SwapperName) => import("@shapeshiftoss/caip").ChainId;
|
|
20
19
|
export declare const isThorTradeRate: (quote: TradeRate | undefined) => quote is ThorTradeRate;
|
|
21
20
|
export declare const isThorTradeQuote: (quote: TradeQuote | undefined) => quote is ThorTradeQuote;
|
|
@@ -10,23 +10,11 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
15
|
};
|
|
21
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
-
if (mod && mod.__esModule) return mod;
|
|
23
|
-
var result = {};
|
|
24
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
-
__setModuleDefault(result, mod);
|
|
26
|
-
return result;
|
|
27
|
-
};
|
|
28
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.getSwapSource = exports.getPoolAssetId = exports.getAffiliate = exports.getNativePrecision = exports.isNativeAsset = exports.getMidgardUrl = exports.getDaemonUrl = exports.isThorTradeQuote = exports.isThorTradeRate = exports.getChainIdBySwapper =
|
|
17
|
+
exports.getSwapSource = exports.getPoolAssetId = exports.getAffiliate = exports.getNativePrecision = exports.isNativeAsset = exports.getMidgardUrl = exports.getDaemonUrl = exports.isThorTradeQuote = exports.isThorTradeRate = exports.getChainIdBySwapper = void 0;
|
|
30
18
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
31
19
|
const MayachainSwapper_1 = require("../../swappers/MayachainSwapper");
|
|
32
20
|
const ThorchainSwapper_1 = require("../../swappers/ThorchainSwapper");
|
|
@@ -44,7 +32,6 @@ __exportStar(require("./getThorL1TradeContexts"), exports);
|
|
|
44
32
|
__exportStar(require("./getThorL1TradeQuote"), exports);
|
|
45
33
|
__exportStar(require("./getThorL1TradeRate"), exports);
|
|
46
34
|
__exportStar(require("./getPoolDetails"), exports);
|
|
47
|
-
exports.tron = __importStar(require("./tron"));
|
|
48
35
|
const getChainIdBySwapper = (swapperName) => {
|
|
49
36
|
switch (swapperName) {
|
|
50
37
|
case types_1.SwapperName.Thorchain:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const TRON_PLACEHOLDER_ADDRESS = "TT2T17KZhoDu47i2E4FWxfG79zdkEWkU9N";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TRON_PLACEHOLDER_ADDRESS = void 0;
|
|
4
|
+
// An activated mainnet account, standing in as the sender/recipient for walletless rate estimation
|
|
5
|
+
exports.TRON_PLACEHOLDER_ADDRESS = 'TT2T17KZhoDu47i2E4FWxfG79zdkEWkU9N';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { tron } from '@shapeshiftoss/chain-adapters';
|
|
2
|
+
import type { Asset } from '@shapeshiftoss/types';
|
|
3
|
+
import type { TxBuildData } from '../../types';
|
|
4
|
+
export type TronContractCall = Omit<Extract<TxBuildData, {
|
|
5
|
+
type: 'tron';
|
|
6
|
+
}>, 'type' | 'data' | 'memo'> & {
|
|
7
|
+
data: string;
|
|
8
|
+
};
|
|
9
|
+
type GetTronContractCallFallbackFeeArgs = {
|
|
10
|
+
adapter: tron.ChainAdapter;
|
|
11
|
+
energy: string;
|
|
12
|
+
bandwidthBytes: number;
|
|
13
|
+
contractAddress?: string;
|
|
14
|
+
fullEnergyOnShareLookupFailure?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare const getTronContractCallFallbackFeeCryptoBaseUnit: ({ adapter, energy, bandwidthBytes, contractAddress, fullEnergyOnShareLookupFailure, }: GetTronContractCallFallbackFeeArgs) => Promise<string>;
|
|
17
|
+
type GetTronContractCallNetworkFeeArgs = {
|
|
18
|
+
adapter: tron.ChainAdapter;
|
|
19
|
+
transactionData: TronContractCall;
|
|
20
|
+
from: string;
|
|
21
|
+
sellAsset: Asset;
|
|
22
|
+
sellAmountCryptoBaseUnit: string;
|
|
23
|
+
spenderAddress: string;
|
|
24
|
+
fallbackEnergy: string;
|
|
25
|
+
};
|
|
26
|
+
export declare const getTronContractCallNetworkFeeCryptoBaseUnit: ({ adapter, transactionData, from, sellAsset, sellAmountCryptoBaseUnit, spenderAddress, fallbackEnergy, }: GetTronContractCallNetworkFeeArgs) => Promise<string>;
|
|
27
|
+
export {};
|