@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
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getRelayStepData = exports.RELAY_SOLANA_COMPUTE_BUDGET = void 0;
|
|
4
4
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
5
|
+
const chain_adapters_1 = require("@shapeshiftoss/chain-adapters");
|
|
5
6
|
const utils_1 = require("@shapeshiftoss/utils");
|
|
6
7
|
const monads_1 = require("@sniptt/monads");
|
|
7
8
|
const utils_2 = require("../../../utils");
|
|
8
9
|
const evm_1 = require("../../../utils/evm");
|
|
9
10
|
const solana_1 = require("../../../utils/solana");
|
|
11
|
+
const tron_1 = require("../../../utils/tron");
|
|
10
12
|
const utxo_1 = require("../../../utils/utxo");
|
|
13
|
+
const constant_1 = require("../constant");
|
|
11
14
|
const getRelayPsbtRelayer_1 = require("./getRelayPsbtRelayer");
|
|
12
15
|
const helpers_1 = require("./helpers");
|
|
13
16
|
const types_1 = require("./types");
|
|
@@ -172,25 +175,55 @@ async function getRelayStepData({ data, sellAsset, sellAmountCryptoBaseUnit, spe
|
|
|
172
175
|
return (0, monads_1.Err)((0, utils_2.makeNetworkFeeEstimationFailedErr)('getRelayStepData', error));
|
|
173
176
|
}
|
|
174
177
|
}
|
|
178
|
+
// Native and token sells alike are a call into relay's depositor contract
|
|
175
179
|
if ((0, types_1.isRelayQuoteTronItemData)(data)) {
|
|
176
|
-
const contractAddress = data.parameter
|
|
177
|
-
const tronCallData = data.parameter?.data;
|
|
178
|
-
const isTronToken = (0, utils_1.isToken)(sellAsset.assetId);
|
|
179
|
-
if (isTronToken && !contractAddress)
|
|
180
|
-
return (0, monads_1.Err)((0, utils_2.makeTradeStepBuildFailedErr)('getRelayStepData'));
|
|
181
|
-
if (isTronToken && !tronCallData)
|
|
182
|
-
return (0, monads_1.Err)((0, utils_2.makeTradeStepBuildFailedErr)('getRelayStepData'));
|
|
180
|
+
const { contract_address: contractAddress, data: callData, call_value: callValue, } = data.parameter ?? {};
|
|
183
181
|
if (type === 'rate') {
|
|
182
|
+
// Relay's gas figure runs ~35% under the deposit's measured energy, so rates price the measured call
|
|
183
|
+
const networkFeeCryptoBaseUnit = await (async () => {
|
|
184
|
+
if (!contractAddress || !callData)
|
|
185
|
+
return fallbackNetworkFeeCryptoBaseUnit;
|
|
186
|
+
try {
|
|
187
|
+
return await (0, tron_1.getTronContractCallFallbackFeeCryptoBaseUnit)({
|
|
188
|
+
adapter: deps.assertGetTronChainAdapter(sellAsset.chainId),
|
|
189
|
+
energy: constant_1.RELAY_TRON_FALLBACK_DEPOSIT_ENERGY,
|
|
190
|
+
bandwidthBytes: chain_adapters_1.tron.getTronContractCallBandwidthBytes(callData),
|
|
191
|
+
contractAddress,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
return fallbackNetworkFeeCryptoBaseUnit;
|
|
196
|
+
}
|
|
197
|
+
})();
|
|
198
|
+
const stepData = { networkFeeCryptoBaseUnit };
|
|
199
|
+
return (0, monads_1.Ok)(stepData);
|
|
200
|
+
}
|
|
201
|
+
if (!contractAddress || !callData)
|
|
202
|
+
return (0, monads_1.Err)((0, utils_2.makeTradeStepBuildFailedErr)('getRelayStepData'));
|
|
203
|
+
const isNativeSell = !(0, utils_1.isToken)(sellAsset.assetId);
|
|
204
|
+
const call = {
|
|
205
|
+
to: contractAddress,
|
|
206
|
+
data: callData,
|
|
207
|
+
value: String(callValue ?? (isNativeSell ? sellAmountCryptoBaseUnit : 0)),
|
|
208
|
+
};
|
|
209
|
+
try {
|
|
184
210
|
const stepData = {
|
|
185
|
-
|
|
211
|
+
transactionData: { type: 'tron', ...call },
|
|
212
|
+
networkFeeCryptoBaseUnit: await (0, tron_1.getTronContractCallNetworkFeeCryptoBaseUnit)({
|
|
213
|
+
adapter: deps.assertGetTronChainAdapter(sellAsset.chainId),
|
|
214
|
+
transactionData: call,
|
|
215
|
+
from,
|
|
216
|
+
sellAsset,
|
|
217
|
+
sellAmountCryptoBaseUnit,
|
|
218
|
+
spenderAddress: contractAddress,
|
|
219
|
+
fallbackEnergy: constant_1.RELAY_TRON_FALLBACK_DEPOSIT_ENERGY,
|
|
220
|
+
}),
|
|
186
221
|
};
|
|
187
222
|
return (0, monads_1.Ok)(stepData);
|
|
188
223
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
};
|
|
193
|
-
return (0, monads_1.Ok)(stepData);
|
|
224
|
+
catch (error) {
|
|
225
|
+
return (0, monads_1.Err)((0, utils_2.makeNetworkFeeEstimationFailedErr)('getRelayStepData', error));
|
|
226
|
+
}
|
|
194
227
|
}
|
|
195
228
|
return (0, monads_1.Err)((0, utils_2.makeTradeStepBuildFailedErr)('getRelayStepData'));
|
|
196
229
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
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 assets_1 = require("../../../utils/test-data/assets");
|
|
6
|
+
const getRelayStepData_1 = require("./getRelayStepData");
|
|
7
|
+
const helpers_1 = require("./helpers");
|
|
8
|
+
const USDT = 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t';
|
|
9
|
+
const TRX = { ...assets_1.ETH, assetId: `${caip_1.tronChainId}/slip44:195`, chainId: caip_1.tronChainId };
|
|
10
|
+
const USDT_TRON = { ...assets_1.ETH, assetId: `${caip_1.tronChainId}/trc20:${USDT}`, chainId: caip_1.tronChainId };
|
|
11
|
+
const FROM = 'TT2T17KZhoDu47i2E4FWxfG79zdkEWkU9N';
|
|
12
|
+
const DEPOSITOR_HEX = '41f0623e1012177482912fb057e44e1a9769b1f588';
|
|
13
|
+
const DEPOSITOR = 'TXtEs6t2oUWQsNos7m68gbHdE9Q5n6x2oN';
|
|
14
|
+
const tronItem = {
|
|
15
|
+
type: 'TriggerSmartContract',
|
|
16
|
+
parameter: { contract_address: DEPOSITOR_HEX, data: '49290c1c', call_value: 50000000 },
|
|
17
|
+
};
|
|
18
|
+
const tronAdapter = ({ txFee = '9000000', allowance = '0' } = {}) => ({
|
|
19
|
+
getFeeData: vitest_1.vi.fn().mockResolvedValue({ fast: { txFee } }),
|
|
20
|
+
httpProvider: {
|
|
21
|
+
getChainPrices: () => Promise.resolve({ energyPrice: 100, bandwidthPrice: 1000 }),
|
|
22
|
+
getTrc20Allowance: vitest_1.vi.fn().mockResolvedValue(allowance),
|
|
23
|
+
getTrc20Balance: vitest_1.vi.fn().mockResolvedValue('100000000'),
|
|
24
|
+
getContractEnergyShare: vitest_1.vi.fn().mockResolvedValue({
|
|
25
|
+
callerPercent: 100,
|
|
26
|
+
originEnergyLimit: 0,
|
|
27
|
+
originEnergyAvailable: 0,
|
|
28
|
+
}),
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
const makeDeps = (tron) => ({ assertGetTronChainAdapter: () => tron });
|
|
32
|
+
const baseArgs = {
|
|
33
|
+
data: tronItem,
|
|
34
|
+
sellAsset: TRX,
|
|
35
|
+
sellAmountCryptoBaseUnit: '50000000',
|
|
36
|
+
spenderAddress: '',
|
|
37
|
+
orderId: undefined,
|
|
38
|
+
xpub: undefined,
|
|
39
|
+
fallbackNetworkFeeCryptoBaseUnit: '6100715',
|
|
40
|
+
};
|
|
41
|
+
(0, vitest_1.describe)('getRelayAllowanceContract', () => {
|
|
42
|
+
(0, vitest_1.it)('returns the tron depositor as relay gives it', () => {
|
|
43
|
+
(0, vitest_1.expect)((0, helpers_1.getRelayAllowanceContract)(tronItem)).toBe(DEPOSITOR_HEX);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
(0, vitest_1.describe)('getRelayStepData', () => {
|
|
47
|
+
(0, vitest_1.describe)('tron', () => {
|
|
48
|
+
(0, vitest_1.it)('carries the depositor call as transactionData and simulates it', async () => {
|
|
49
|
+
const adapter = tronAdapter();
|
|
50
|
+
const actual = await (0, getRelayStepData_1.getRelayStepData)({
|
|
51
|
+
...baseArgs,
|
|
52
|
+
type: 'quote',
|
|
53
|
+
input: {},
|
|
54
|
+
from: FROM,
|
|
55
|
+
deps: makeDeps(adapter),
|
|
56
|
+
});
|
|
57
|
+
const transactionData = {
|
|
58
|
+
type: 'tron',
|
|
59
|
+
to: DEPOSITOR_HEX,
|
|
60
|
+
data: '49290c1c',
|
|
61
|
+
value: '50000000',
|
|
62
|
+
};
|
|
63
|
+
(0, vitest_1.expect)(actual.unwrap()).toEqual({ transactionData, networkFeeCryptoBaseUnit: '9000000' });
|
|
64
|
+
(0, vitest_1.expect)(adapter.getFeeData).toHaveBeenCalledWith({
|
|
65
|
+
to: DEPOSITOR_HEX,
|
|
66
|
+
value: '50000000',
|
|
67
|
+
chainSpecific: { from: FROM, data: '49290c1c', requireEnergyShare: true },
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
(0, vitest_1.it)('fails a native quote when the simulation fails', async () => {
|
|
71
|
+
const adapter = tronAdapter();
|
|
72
|
+
adapter.getFeeData.mockRejectedValue(new Error('REVERT opcode executed'));
|
|
73
|
+
const actual = await (0, getRelayStepData_1.getRelayStepData)({
|
|
74
|
+
...baseArgs,
|
|
75
|
+
type: 'quote',
|
|
76
|
+
input: {},
|
|
77
|
+
from: FROM,
|
|
78
|
+
deps: makeDeps(adapter),
|
|
79
|
+
});
|
|
80
|
+
(0, vitest_1.expect)(actual.isErr()).toBe(true);
|
|
81
|
+
});
|
|
82
|
+
(0, vitest_1.it)('prices the measured worst case when a token allowance is not granted yet', async () => {
|
|
83
|
+
const adapter = tronAdapter({ allowance: '0' });
|
|
84
|
+
adapter.getFeeData.mockRejectedValue(new Error('REVERT opcode executed'));
|
|
85
|
+
const actual = await (0, getRelayStepData_1.getRelayStepData)({
|
|
86
|
+
...baseArgs,
|
|
87
|
+
data: { type: 'TriggerSmartContract', parameter: { ...tronItem.parameter, call_value: 0 } },
|
|
88
|
+
sellAsset: USDT_TRON,
|
|
89
|
+
type: 'quote',
|
|
90
|
+
input: {},
|
|
91
|
+
from: FROM,
|
|
92
|
+
deps: makeDeps(adapter),
|
|
93
|
+
});
|
|
94
|
+
// 100000 energy * 1.2 margin * 100 sun + (4 calldata + 279 envelope) bytes * 1000 sun
|
|
95
|
+
(0, vitest_1.expect)(actual.unwrap().networkFeeCryptoBaseUnit).toBe('12283000');
|
|
96
|
+
(0, vitest_1.expect)(adapter.httpProvider.getTrc20Allowance).toHaveBeenCalledWith({
|
|
97
|
+
contractAddress: USDT,
|
|
98
|
+
owner: FROM,
|
|
99
|
+
spender: DEPOSITOR,
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
(0, vitest_1.it)('prices a rate from the measured deposit', async () => {
|
|
103
|
+
const adapter = tronAdapter();
|
|
104
|
+
const actual = await (0, getRelayStepData_1.getRelayStepData)({
|
|
105
|
+
...baseArgs,
|
|
106
|
+
type: 'rate',
|
|
107
|
+
input: {},
|
|
108
|
+
from: FROM,
|
|
109
|
+
deps: makeDeps(adapter),
|
|
110
|
+
});
|
|
111
|
+
// 100000 energy * 1.2 margin * 100 sun + (4 calldata + 279 envelope) bytes * 1000 sun
|
|
112
|
+
(0, vitest_1.expect)(actual.unwrap()).toEqual({ networkFeeCryptoBaseUnit: '12283000' });
|
|
113
|
+
(0, vitest_1.expect)(adapter.httpProvider.getContractEnergyShare).toHaveBeenCalledWith(DEPOSITOR);
|
|
114
|
+
});
|
|
115
|
+
(0, vitest_1.it)('falls back to the relay fee when the measured deposit cannot be priced', async () => {
|
|
116
|
+
const adapter = tronAdapter();
|
|
117
|
+
adapter.httpProvider.getChainPrices = () => Promise.reject(new Error('429'));
|
|
118
|
+
const actual = await (0, getRelayStepData_1.getRelayStepData)({
|
|
119
|
+
...baseArgs,
|
|
120
|
+
type: 'rate',
|
|
121
|
+
input: {},
|
|
122
|
+
from: FROM,
|
|
123
|
+
deps: makeDeps(adapter),
|
|
124
|
+
});
|
|
125
|
+
(0, vitest_1.expect)(actual.unwrap()).toEqual({ networkFeeCryptoBaseUnit: '6100715' });
|
|
126
|
+
});
|
|
127
|
+
(0, vitest_1.it)('fails to build without the depositor call', async () => {
|
|
128
|
+
const actual = await (0, getRelayStepData_1.getRelayStepData)({
|
|
129
|
+
...baseArgs,
|
|
130
|
+
data: { type: 'TriggerSmartContract', parameter: {} },
|
|
131
|
+
type: 'quote',
|
|
132
|
+
input: {},
|
|
133
|
+
from: FROM,
|
|
134
|
+
deps: makeDeps(tronAdapter()),
|
|
135
|
+
});
|
|
136
|
+
(0, vitest_1.expect)(actual.isErr()).toBe(true);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
});
|
|
@@ -13,6 +13,7 @@ type RelayTradeContext = {
|
|
|
13
13
|
}[];
|
|
14
14
|
stepDataArgs: Omit<GetRelayStepDataArgs, 'type' | 'input' | 'data' | 'spenderAddress'>;
|
|
15
15
|
relayId: string;
|
|
16
|
+
deadline: number | undefined;
|
|
16
17
|
};
|
|
17
18
|
export declare const getRelayTradeContext: ({ input, deps, relayChainMap, }: {
|
|
18
19
|
input: RelayTradeQuoteInput | RelayTradeRateInput | RelayExactOutputTradeQuoteInput | RelayExactOutputTradeRateInput;
|
|
@@ -264,6 +264,9 @@ const getRelayTradeContext = async ({ input, deps, relayChainMap, }) => {
|
|
|
264
264
|
.plus(appFeesBaseUnit)
|
|
265
265
|
.toFixed();
|
|
266
266
|
const relayId = quote.steps[0].requestId;
|
|
267
|
+
// Only cross-chain (protocol v2) orders carry an expiry; past it the solver submits a no-fill refund
|
|
268
|
+
const orderDeadline = quote.protocol?.v2?.orderData?.output?.deadline;
|
|
269
|
+
const deadline = orderDeadline === undefined ? undefined : (0, helpers_1.normalizeEpochToMs)(orderDeadline);
|
|
267
270
|
const relayStepInputs = swapSteps.map(step => {
|
|
268
271
|
const data = step.items?.[0]?.data;
|
|
269
272
|
return { data, allowanceContract: (0, helpers_2.getRelayAllowanceContract)(data) };
|
|
@@ -307,6 +310,7 @@ const getRelayTradeContext = async ({ input, deps, relayChainMap, }) => {
|
|
|
307
310
|
...appFeesAsProtocolFee,
|
|
308
311
|
},
|
|
309
312
|
relayStepInputs,
|
|
313
|
+
deadline,
|
|
310
314
|
stepDataArgs: {
|
|
311
315
|
sellAsset,
|
|
312
316
|
sellAmountCryptoBaseUnit,
|
|
@@ -56,8 +56,7 @@ const resolveRelayAddresses = ({ input, sellChainId, buyChainId, }) => {
|
|
|
56
56
|
return { sendAddress, recipient, refundTo };
|
|
57
57
|
};
|
|
58
58
|
exports.resolveRelayAddresses = resolveRelayAddresses;
|
|
59
|
-
// The spender to approve
|
|
60
|
-
// UTXO/Solana need no allowance. Derived from the provider route, not the built transactionData.
|
|
59
|
+
// The spender to approve is the call target: EVM data.to, tron the depositor; UTXO/Solana need none
|
|
61
60
|
const getRelayAllowanceContract = (data) => {
|
|
62
61
|
if (!data)
|
|
63
62
|
return '';
|
|
@@ -25,14 +25,14 @@ const relayStatusToTxStatus = (status) => {
|
|
|
25
25
|
exports.relayStatusToTxStatus = relayStatusToTxStatus;
|
|
26
26
|
// Relay index requests by origin tx hash, resolving a swap we hold no relayId for
|
|
27
27
|
const fetchRelayRequestByTxHash = async (txHash, config) => {
|
|
28
|
-
const maybeResponse = await relayService_1.relayService.get(`${config.VITE_RELAY_API_URL}/requests/
|
|
28
|
+
const maybeResponse = await relayService_1.relayService.get(`${config.VITE_RELAY_API_URL}/requests/v3?depositTxHash=${txHash}`, (0, relayService_1.getRelayRequestConfig)(config));
|
|
29
29
|
// Match the origin tx ourselves rather than trusting the listing to have filtered on it
|
|
30
|
-
return maybeResponse.map(({ data }) => data.requests?.find(({ data: request }) => request?.inTxs?.some(({ hash }) => hash?.toLowerCase() === txHash.toLowerCase())));
|
|
30
|
+
return maybeResponse.map(({ data }) => data.requests?.find(({ data: request }) => request?.inTxs?.some(({ txHash: hash }) => hash?.toLowerCase() === txHash.toLowerCase())));
|
|
31
31
|
};
|
|
32
32
|
exports.fetchRelayRequestByTxHash = fetchRelayRequestByTxHash;
|
|
33
33
|
const getRelayRequestFailureMessage = (request) => {
|
|
34
34
|
const { failReason, refundFailReason } = request.data ?? {};
|
|
35
|
-
// Relay report 'N/A' rather than
|
|
35
|
+
// Relay can report 'N/A' rather than null when there isn't one
|
|
36
36
|
const reason = [failReason, refundFailReason].find(value => value && value !== 'N/A');
|
|
37
37
|
return reason ?? 'Bridge failed';
|
|
38
38
|
};
|
|
@@ -18,7 +18,7 @@ const relayTokenToAssetId = (relayToken) => {
|
|
|
18
18
|
return relayToken.address === constant_1.RELAY_SOLANA_TOKEN_ADDRESS;
|
|
19
19
|
}
|
|
20
20
|
if (chainId === caip_1.tronChainId) {
|
|
21
|
-
return relayToken.address ===
|
|
21
|
+
return relayToken.address === chain_adapters_1.tron.TRON_ZERO_ADDRESS;
|
|
22
22
|
}
|
|
23
23
|
return false;
|
|
24
24
|
})();
|
|
@@ -3,22 +3,18 @@ export type RelayTradeQuoteInput = GetEvmTradeQuoteInput | GetUtxoTradeQuoteInpu
|
|
|
3
3
|
export type RelayTradeRateInput = GetEvmTradeRateInput | GetUtxoTradeRateInput | GetSolanaTradeRateInput | GetTronTradeRateInput;
|
|
4
4
|
export type RelayExactOutputTradeQuoteInput = WithExactBuyAmount<RelayTradeQuoteInput>;
|
|
5
5
|
export type RelayExactOutputTradeRateInput = WithExactBuyAmount<RelayTradeRateInput>;
|
|
6
|
-
export type RelayTransactionMetadata = {
|
|
7
|
-
to?: string;
|
|
8
|
-
data?: string;
|
|
9
|
-
};
|
|
10
6
|
export type RelayMetadata = {
|
|
11
7
|
name: 'relay';
|
|
12
8
|
relayId: string;
|
|
13
9
|
data?: string;
|
|
14
10
|
};
|
|
15
11
|
export type RelayRequestTransaction = {
|
|
16
|
-
|
|
12
|
+
txHash?: string;
|
|
17
13
|
chainId?: number;
|
|
18
14
|
};
|
|
19
15
|
export type RelayRequestData = {
|
|
20
|
-
failReason?: string;
|
|
21
|
-
refundFailReason?: string;
|
|
16
|
+
failReason?: string | null;
|
|
17
|
+
refundFailReason?: string | null;
|
|
22
18
|
inTxs?: RelayRequestTransaction[];
|
|
23
19
|
outTxs?: RelayRequestTransaction[];
|
|
24
20
|
};
|
|
@@ -114,6 +110,7 @@ export type RelayQuoteTronItemData = {
|
|
|
114
110
|
owner_address?: string;
|
|
115
111
|
contract_address?: string;
|
|
116
112
|
data?: string;
|
|
113
|
+
call_value?: number;
|
|
117
114
|
};
|
|
118
115
|
};
|
|
119
116
|
export type RelayQuoteItem = {
|
|
@@ -124,9 +121,14 @@ export type RelayQuoteStep = {
|
|
|
124
121
|
requestId: string;
|
|
125
122
|
items?: RelayQuoteItem[];
|
|
126
123
|
};
|
|
124
|
+
export type RelayOrderData = {
|
|
125
|
+
output?: {
|
|
126
|
+
deadline?: number;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
127
129
|
export type RelayProtocolV2 = {
|
|
128
130
|
orderId: string | undefined;
|
|
129
|
-
orderData?:
|
|
131
|
+
orderData?: RelayOrderData;
|
|
130
132
|
paymentDetails?: {
|
|
131
133
|
chainId: string;
|
|
132
134
|
depository: string;
|
|
@@ -2,77 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sunioApi = void 0;
|
|
4
4
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
5
|
-
const chain_adapters_1 = require("@shapeshiftoss/chain-adapters");
|
|
6
5
|
const unchained_client_1 = require("@shapeshiftoss/unchained-client");
|
|
7
|
-
const tronweb_1 = require("tronweb");
|
|
8
6
|
const utils_1 = require("../../utils");
|
|
7
|
+
const tron_1 = require("../../utils/tron");
|
|
9
8
|
const getSunioTradeQuote_1 = require("./getSunioTradeQuote/getSunioTradeQuote");
|
|
10
9
|
const getSunioTradeRate_1 = require("./getSunioTradeRate/getSunioTradeRate");
|
|
11
|
-
const buildSwapContractCall_1 = require("./utils/buildSwapContractCall");
|
|
12
|
-
const buildSwapRouteParameters_1 = require("./utils/buildSwapRouteParameters");
|
|
13
|
-
const constants_1 = require("./utils/constants");
|
|
14
|
-
const getSunioTransactionFees_1 = require("./utils/getSunioTransactionFees");
|
|
15
10
|
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
16
11
|
exports.sunioApi = {
|
|
17
12
|
getTradeQuote: (input, deps) => (0, getSunioTradeQuote_1.getSunioTradeQuote)(input, deps),
|
|
18
13
|
getTradeRate: (input, deps) => (0, getSunioTradeRate_1.getSunioTradeRate)(input, deps),
|
|
19
|
-
getUnsignedTronTransaction:
|
|
20
|
-
|
|
21
|
-
if (!(0, utils_1.isExecutableTradeQuote)(tradeQuote)) {
|
|
22
|
-
throw new Error('Unable to execute a trade rate quote');
|
|
23
|
-
}
|
|
24
|
-
const step = (0, utils_1.getExecutableTradeStep)(tradeQuote, stepIndex);
|
|
25
|
-
const adapter = assertGetTronChainAdapter(caip_1.tronChainId);
|
|
26
|
-
const sunioTransactionData = step.sunioTransactionData;
|
|
27
|
-
if (!sunioTransactionData)
|
|
28
|
-
throw new Error('[Sun.io] Missing transaction data in quote');
|
|
29
|
-
const rpcUrl = adapter.httpProvider.getRpcUrl();
|
|
30
|
-
const tronWeb = new tronweb_1.TronWeb({
|
|
31
|
-
fullHost: rpcUrl,
|
|
32
|
-
headers: config.VITE_TRON_GRID_API_KEY
|
|
33
|
-
? { 'TRON-PRO-API-KEY': config.VITE_TRON_GRID_API_KEY }
|
|
34
|
-
: {},
|
|
35
|
-
});
|
|
36
|
-
const routeParams = (0, buildSwapRouteParameters_1.buildSwapRouteParameters)(sunioTransactionData.route, step.sellAmountIncludingProtocolFeesCryptoBaseUnit, step.buyAmountAfterFeesCryptoBaseUnit, tradeQuote.receiveAddress, slippageTolerancePercentageDecimal);
|
|
37
|
-
const parameters = (0, buildSwapContractCall_1.buildSwapExactInputParameters)(routeParams);
|
|
38
|
-
const isSellingNativeTrx = step.sellAsset.assetId === caip_1.tronAssetId;
|
|
39
|
-
const callValue = isSellingNativeTrx
|
|
40
|
-
? Number(step.sellAmountIncludingProtocolFeesCryptoBaseUnit)
|
|
41
|
-
: 0;
|
|
42
|
-
const options = {
|
|
43
|
-
feeLimit: 100_000_000,
|
|
44
|
-
callValue,
|
|
45
|
-
};
|
|
46
|
-
const txData = await tronWeb.transactionBuilder.triggerSmartContract(constants_1.SUNIO_SMART_ROUTER_CONTRACT, buildSwapContractCall_1.SUNIO_SWAP_EXACT_INPUT_SELECTOR, options, parameters, from);
|
|
47
|
-
if (!txData.result || !txData.result.result) {
|
|
48
|
-
throw new Error('[Sun.io] Failed to build swap transaction');
|
|
49
|
-
}
|
|
50
|
-
const transaction = txData.transaction;
|
|
51
|
-
const rawDataHex = typeof transaction.raw_data_hex === 'string'
|
|
52
|
-
? transaction.raw_data_hex
|
|
53
|
-
: Buffer.isBuffer(transaction.raw_data_hex)
|
|
54
|
-
? transaction.raw_data_hex.toString('hex')
|
|
55
|
-
: Array.isArray(transaction.raw_data_hex)
|
|
56
|
-
? Buffer.from(transaction.raw_data_hex).toString('hex')
|
|
57
|
-
: (() => {
|
|
58
|
-
throw new Error(`Unexpected raw_data_hex type: ${typeof transaction.raw_data_hex}`);
|
|
59
|
-
})();
|
|
60
|
-
if (!/^[0-9a-fA-F]+$/.test(rawDataHex)) {
|
|
61
|
-
throw new Error(`Invalid raw_data_hex format: ${rawDataHex.slice(0, 100)}`);
|
|
62
|
-
}
|
|
63
|
-
const accountNumber = step.accountNumber;
|
|
64
|
-
if (accountNumber === undefined) {
|
|
65
|
-
throw new Error('[Sun.io] accountNumber is required for execution');
|
|
66
|
-
}
|
|
67
|
-
const bip44Params = adapter.getBip44Params({ accountNumber });
|
|
68
|
-
const addressNList = (0, chain_adapters_1.toAddressNList)(bip44Params);
|
|
69
|
-
return {
|
|
70
|
-
addressNList,
|
|
71
|
-
rawDataHex,
|
|
72
|
-
transaction,
|
|
73
|
-
};
|
|
74
|
-
},
|
|
75
|
-
getTronTransactionFees: getSunioTransactionFees_1.getSunioTransactionFees,
|
|
14
|
+
getUnsignedTronTransaction: tron_1.getUnsignedTronTransaction,
|
|
15
|
+
getTronTransactionFees: tron_1.getTronTransactionFees,
|
|
76
16
|
checkTradeStatus: async ({ txHash, assertGetTronChainAdapter }) => {
|
|
77
17
|
try {
|
|
78
18
|
// Wait for TronGrid indexing to avoid false "REVERT"
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getSunioTradeQuote = void 0;
|
|
4
4
|
const monads_1 = require("@sniptt/monads");
|
|
5
5
|
const utils_1 = require("../../../utils");
|
|
6
|
-
const helpers_1 = require("../../../utils/helpers");
|
|
7
6
|
const getSunioStepData_1 = require("../utils/getSunioStepData");
|
|
8
7
|
const getSunioTradeContext_1 = require("../utils/getSunioTradeContext");
|
|
9
8
|
const getSunioTradeQuote = async (input, deps) => {
|
|
@@ -24,17 +23,17 @@ const getSunioTradeQuote = async (input, deps) => {
|
|
|
24
23
|
});
|
|
25
24
|
if (maybeStepData.isErr())
|
|
26
25
|
return (0, monads_1.Err)(maybeStepData.unwrapErr());
|
|
27
|
-
const { networkFeeCryptoBaseUnit,
|
|
26
|
+
const { networkFeeCryptoBaseUnit, transactionData, deadline } = maybeStepData.unwrap();
|
|
28
27
|
const tradeQuote = {
|
|
29
28
|
...tradeCommon,
|
|
30
29
|
quoteOrRate: 'quote',
|
|
31
|
-
deadline
|
|
30
|
+
deadline,
|
|
32
31
|
receiveAddress,
|
|
33
32
|
steps: [
|
|
34
33
|
{
|
|
35
34
|
...stepCommon,
|
|
36
35
|
accountNumber,
|
|
37
|
-
|
|
36
|
+
transactionData,
|
|
38
37
|
feeData: { networkFeeCryptoBaseUnit, protocolFees },
|
|
39
38
|
},
|
|
40
39
|
],
|
|
@@ -10,7 +10,13 @@ const getSunioTradeRate = async (input, deps) => {
|
|
|
10
10
|
if (maybeContext.isErr())
|
|
11
11
|
return (0, monads_1.Err)(maybeContext.unwrapErr());
|
|
12
12
|
const { tradeCommon, stepCommon, protocolFees, stepDataArgs } = maybeContext.unwrap();
|
|
13
|
-
|
|
13
|
+
// Sun.io is tron-only, so the receive address is also the seller's account to simulate from
|
|
14
|
+
const maybeStepData = await (0, getSunioStepData_1.getSunioStepData)({
|
|
15
|
+
...stepDataArgs,
|
|
16
|
+
type: 'rate',
|
|
17
|
+
input,
|
|
18
|
+
from: input.sendAddress ?? receiveAddress,
|
|
19
|
+
});
|
|
14
20
|
if (maybeStepData.isErr())
|
|
15
21
|
return (0, monads_1.Err)(maybeStepData.unwrapErr());
|
|
16
22
|
const { networkFeeCryptoBaseUnit } = maybeStepData.unwrap();
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import type { SunioRoute } from '../types';
|
|
2
|
+
type BuildSunioSwapCalldataArgs = {
|
|
3
|
+
route: SunioRoute;
|
|
4
|
+
sellAmountCryptoBaseUnit: string;
|
|
5
|
+
minBuyAmountCryptoBaseUnit: string;
|
|
6
|
+
recipient: string;
|
|
7
|
+
slippageTolerancePercentageDecimal: string;
|
|
8
|
+
deadline: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const buildSunioSwapCalldata: ({ route, sellAmountCryptoBaseUnit, minBuyAmountCryptoBaseUnit, recipient, slippageTolerancePercentageDecimal, deadline, }: BuildSunioSwapCalldataArgs) => string;
|
|
11
|
+
export {};
|
|
@@ -1,33 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
exports.buildSunioSwapCalldata = void 0;
|
|
4
|
+
const chain_adapters_1 = require("@shapeshiftoss/chain-adapters");
|
|
5
|
+
const utils_1 = require("@shapeshiftoss/utils");
|
|
6
|
+
const viem_1 = require("viem");
|
|
7
|
+
const SUNIO_SWAP_EXACT_INPUT_ABI = (0, viem_1.parseAbiItem)('function swapExactInput(address[], string[], uint256[], uint24[], (uint256,uint256,address,uint256))');
|
|
8
|
+
// SmartExchangeRouter swapExactInput calldata - the TVM ABI is EVM-compatible, addresses as 20-byte bodies
|
|
9
|
+
const buildSunioSwapCalldata = ({ route, sellAmountCryptoBaseUnit, minBuyAmountCryptoBaseUnit, recipient, slippageTolerancePercentageDecimal, deadline, }) => {
|
|
10
|
+
const amountOutMin = (0, utils_1.bn)(minBuyAmountCryptoBaseUnit)
|
|
11
|
+
.times((0, utils_1.bn)(1).minus(slippageTolerancePercentageDecimal))
|
|
12
|
+
.toFixed(0);
|
|
13
|
+
// The SmartExchangeRouter expects sum(versionLen) === path.length: the first pool segment consumes
|
|
14
|
+
// 2 tokens (input + output) and each subsequent pool reuses the previous output, consuming 1 new
|
|
15
|
+
// token. Relies on the Sun.io API returning poolVersions per-hop (poolVersions.length ===
|
|
16
|
+
// tokens.length - 1), which it does.
|
|
17
|
+
const versionLen = route.poolVersions.map((_, index) => (index === 0 ? 2n : 1n));
|
|
18
|
+
const swapData = [
|
|
19
|
+
BigInt(sellAmountCryptoBaseUnit),
|
|
20
|
+
BigInt(amountOutMin),
|
|
21
|
+
chain_adapters_1.tron.toTronHex(recipient),
|
|
22
|
+
BigInt(Math.floor(deadline / 1000)),
|
|
23
|
+
];
|
|
24
|
+
return (0, viem_1.encodeFunctionData)({
|
|
25
|
+
abi: [SUNIO_SWAP_EXACT_INPUT_ABI],
|
|
26
|
+
functionName: 'swapExactInput',
|
|
27
|
+
args: [
|
|
28
|
+
route.tokens.map(chain_adapters_1.tron.toTronHex),
|
|
29
|
+
route.poolVersions,
|
|
30
|
+
versionLen,
|
|
31
|
+
route.poolFees.map(Number),
|
|
32
|
+
swapData,
|
|
33
|
+
],
|
|
34
|
+
});
|
|
15
35
|
};
|
|
16
|
-
|
|
17
|
-
// estimation and execution so both encode the call identically.
|
|
18
|
-
const buildSwapExactInputParameters = (routeParams) => [
|
|
19
|
-
{ type: 'address[]', value: routeParams.path },
|
|
20
|
-
{ type: 'string[]', value: routeParams.poolVersion },
|
|
21
|
-
{ type: 'uint256[]', value: routeParams.versionLen },
|
|
22
|
-
{ type: 'uint24[]', value: routeParams.fees },
|
|
23
|
-
{
|
|
24
|
-
type: 'tuple(uint256,uint256,address,uint256)',
|
|
25
|
-
value: convertAddressesToEvmFormat([
|
|
26
|
-
routeParams.swapData.amountIn,
|
|
27
|
-
routeParams.swapData.amountOutMin,
|
|
28
|
-
routeParams.swapData.recipient,
|
|
29
|
-
routeParams.swapData.deadline,
|
|
30
|
-
]),
|
|
31
|
-
},
|
|
32
|
-
];
|
|
33
|
-
exports.buildSwapExactInputParameters = buildSwapExactInputParameters;
|
|
36
|
+
exports.buildSunioSwapCalldata = buildSunioSwapCalldata;
|
|
@@ -2,7 +2,7 @@ export declare const SUNIO_SUPPORTED_CHAIN_IDS: readonly [import("@shapeshiftoss
|
|
|
2
2
|
export declare const SUNIO_API_BASE_URL = "https://rot.endjgfsv.link";
|
|
3
3
|
export declare const SUNIO_SMART_ROUTER_CONTRACT: "TCFNp179Lg46D16zKoumd4Poa2WFFdtqYj";
|
|
4
4
|
export declare const DEFAULT_SLIPPAGE_PERCENTAGE = "0.005";
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
5
|
+
export declare const SUNIO_SWAP_DEADLINE_MS: number;
|
|
6
|
+
export declare const SUNIO_FALLBACK_SWAP_ENERGY_NATIVE = "250000";
|
|
7
|
+
export declare const SUNIO_FALLBACK_SWAP_ENERGY_TRC20 = "480000";
|
|
7
8
|
export declare const SUNIO_DEX_TYPES: "PSM,CURVE,CURVE_COMBINATION,WTRX,SUNSWAP_V1,SUNSWAP_V2,SUNSWAP_V3";
|
|
8
|
-
export declare const SUNIO_TRON_NATIVE_ADDRESS: "T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.SUNIO_DEX_TYPES = exports.SUNIO_FALLBACK_SWAP_ENERGY_TRC20 = exports.SUNIO_FALLBACK_SWAP_ENERGY_NATIVE = exports.SUNIO_SWAP_DEADLINE_MS = exports.DEFAULT_SLIPPAGE_PERCENTAGE = exports.SUNIO_SMART_ROUTER_CONTRACT = exports.SUNIO_API_BASE_URL = exports.SUNIO_SUPPORTED_CHAIN_IDS = void 0;
|
|
4
4
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
5
5
|
exports.SUNIO_SUPPORTED_CHAIN_IDS = [caip_1.tronChainId];
|
|
6
6
|
// NOTE: This domain looks suspicious, but it's the official Sun.io backend API
|
|
@@ -11,12 +11,8 @@ exports.SUNIO_API_BASE_URL = 'https://rot.endjgfsv.link';
|
|
|
11
11
|
// This is the current mainnet router that sun.io's frontend uses
|
|
12
12
|
exports.SUNIO_SMART_ROUTER_CONTRACT = 'TCFNp179Lg46D16zKoumd4Poa2WFFdtqYj';
|
|
13
13
|
exports.DEFAULT_SLIPPAGE_PERCENTAGE = '0.005';
|
|
14
|
-
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
exports.SUNIO_FALLBACK_SWAP_ENERGY_NATIVE = 215_000;
|
|
19
|
-
exports.SUNIO_FALLBACK_SWAP_ENERGY_TRC20 = 375_000;
|
|
14
|
+
exports.SUNIO_SWAP_DEADLINE_MS = 20 * 60 * 1000;
|
|
15
|
+
// p90 router energy on mainnet, for rates that can't simulate and token quotes without their allowance
|
|
16
|
+
exports.SUNIO_FALLBACK_SWAP_ENERGY_NATIVE = '250000';
|
|
17
|
+
exports.SUNIO_FALLBACK_SWAP_ENERGY_TRC20 = '480000';
|
|
20
18
|
exports.SUNIO_DEX_TYPES = 'PSM,CURVE,CURVE_COMBINATION,WTRX,SUNSWAP_V1,SUNSWAP_V2,SUNSWAP_V3';
|
|
21
|
-
// Native TRX token address (used when assetId is not a TRC-20 token)
|
|
22
|
-
exports.SUNIO_TRON_NATIVE_ADDRESS = 'T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb';
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import type { Result } from '@sniptt/monads';
|
|
2
|
-
import type { StepDataArgs, SwapErrorRight } from '../../../types';
|
|
3
|
-
import type { SunioRoute
|
|
2
|
+
import type { StepDataArgs, SwapErrorRight, TxBuildData } from '../../../types';
|
|
3
|
+
import type { SunioRoute } from '../types';
|
|
4
4
|
type BaseArgs = {
|
|
5
5
|
route: SunioRoute;
|
|
6
6
|
sellAmountCryptoBaseUnit: string;
|
|
7
|
+
buyAmountCryptoBaseUnit: string;
|
|
7
8
|
};
|
|
8
9
|
export type GetSunioStepDataArgs = StepDataArgs<BaseArgs>;
|
|
10
|
+
type TronTxBuildData = Extract<TxBuildData, {
|
|
11
|
+
type: 'tron';
|
|
12
|
+
}>;
|
|
9
13
|
type SunioRateStepData = {
|
|
10
14
|
networkFeeCryptoBaseUnit: string | undefined;
|
|
11
15
|
};
|
|
12
16
|
type SunioQuoteStepData = {
|
|
17
|
+
transactionData: TronTxBuildData;
|
|
13
18
|
networkFeeCryptoBaseUnit: string;
|
|
14
|
-
|
|
19
|
+
deadline: number;
|
|
15
20
|
};
|
|
16
21
|
export declare function getSunioStepData(args: Extract<GetSunioStepDataArgs, {
|
|
17
22
|
type: 'rate';
|