@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,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const caip_1 = require("@shapeshiftoss/caip");
|
|
4
|
+
const monads_1 = require("@sniptt/monads");
|
|
5
|
+
const vitest_1 = require("vitest");
|
|
6
|
+
const assets_1 = require("../../../utils/test-data/assets");
|
|
7
|
+
const getBobGatewayStepData_1 = require("./getBobGatewayStepData");
|
|
8
|
+
const helpers_1 = require("./helpers");
|
|
9
|
+
vitest_1.vi.mock('./helpers', () => ({ createBobGatewayOrder: vitest_1.vi.fn() }));
|
|
10
|
+
const USDT_TRON = {
|
|
11
|
+
...assets_1.ETH,
|
|
12
|
+
assetId: `${caip_1.tronChainId}/trc20:TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t`,
|
|
13
|
+
chainId: caip_1.tronChainId,
|
|
14
|
+
};
|
|
15
|
+
const FROM = 'TT2T17KZhoDu47i2E4FWxfG79zdkEWkU9N';
|
|
16
|
+
// BOB returns the AllowanceHolder as 0x-prefixed 41-hex (TAfbit1ENsRmtZbPQfYU3srURpfYuWYS7K)
|
|
17
|
+
const ALLOWANCE_HOLDER_HEX = '0x4107a39ae4c49dee86e892450b20881f32cd5d500d';
|
|
18
|
+
const tronTx = { type: 'tron', to: ALLOWANCE_HOLDER_HEX, data: '0x2213bc0b', value: '0' };
|
|
19
|
+
const tronAdapter = ({ txFee = '45600000', allowance = '0' } = {}) => ({
|
|
20
|
+
getFeeData: vitest_1.vi.fn().mockResolvedValue({ fast: { txFee } }),
|
|
21
|
+
httpProvider: {
|
|
22
|
+
getChainPrices: () => Promise.resolve({ energyPrice: 100, bandwidthPrice: 1000 }),
|
|
23
|
+
getTrc20Allowance: vitest_1.vi.fn().mockResolvedValue(allowance),
|
|
24
|
+
getTrc20Balance: vitest_1.vi.fn().mockResolvedValue('100000000'),
|
|
25
|
+
getContractEnergyShare: vitest_1.vi.fn().mockResolvedValue({
|
|
26
|
+
callerPercent: 100,
|
|
27
|
+
originEnergyLimit: 0,
|
|
28
|
+
originEnergyAvailable: 0,
|
|
29
|
+
}),
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
const makeDeps = (tron) => ({ config: {}, assertGetTronChainAdapter: () => tron });
|
|
33
|
+
const quote = {};
|
|
34
|
+
(0, vitest_1.describe)('getBobGatewayStepData', () => {
|
|
35
|
+
(0, vitest_1.describe)('tron', () => {
|
|
36
|
+
(0, vitest_1.it)('prices a rate from the measured default energy and bandwidth at the gateway share', async () => {
|
|
37
|
+
const adapter = tronAdapter();
|
|
38
|
+
const actual = await (0, getBobGatewayStepData_1.getBobGatewayStepData)({
|
|
39
|
+
type: 'rate',
|
|
40
|
+
input: {},
|
|
41
|
+
deps: makeDeps(adapter),
|
|
42
|
+
quote,
|
|
43
|
+
sellAsset: USDT_TRON,
|
|
44
|
+
sellAmountCryptoBaseUnit: '100000000',
|
|
45
|
+
spenderAddress: 'TAfbit1ENsRmtZbPQfYU3srURpfYuWYS7K',
|
|
46
|
+
});
|
|
47
|
+
// 420000 energy * 1.2 margin * 100 sun + 4000 bytes * 1000 sun
|
|
48
|
+
(0, vitest_1.expect)(actual.unwrap()).toEqual({ networkFeeCryptoBaseUnit: '54400000' });
|
|
49
|
+
(0, vitest_1.expect)(adapter.httpProvider.getContractEnergyShare).toHaveBeenCalledWith('TAfbit1ENsRmtZbPQfYU3srURpfYuWYS7K');
|
|
50
|
+
});
|
|
51
|
+
(0, vitest_1.it)('simulates the real gateway call for a quote', async () => {
|
|
52
|
+
vitest_1.vi.mocked(helpers_1.createBobGatewayOrder).mockResolvedValue((0, monads_1.Ok)({ offramp: { orderId: 'order-1', tx: tronTx } }));
|
|
53
|
+
const adapter = tronAdapter();
|
|
54
|
+
const actual = await (0, getBobGatewayStepData_1.getBobGatewayStepData)({
|
|
55
|
+
type: 'quote',
|
|
56
|
+
input: {},
|
|
57
|
+
deps: makeDeps(adapter),
|
|
58
|
+
quote,
|
|
59
|
+
sellAsset: USDT_TRON,
|
|
60
|
+
sellAmountCryptoBaseUnit: '100000000',
|
|
61
|
+
spenderAddress: '',
|
|
62
|
+
from: FROM,
|
|
63
|
+
});
|
|
64
|
+
(0, vitest_1.expect)(adapter.getFeeData).toHaveBeenCalledWith({
|
|
65
|
+
to: ALLOWANCE_HOLDER_HEX,
|
|
66
|
+
value: '0',
|
|
67
|
+
chainSpecific: { from: FROM, data: '0x2213bc0b', requireEnergyShare: true },
|
|
68
|
+
});
|
|
69
|
+
(0, vitest_1.expect)(actual.unwrap()).toEqual({
|
|
70
|
+
orderId: 'order-1',
|
|
71
|
+
transactionData: { type: 'tron', to: ALLOWANCE_HOLDER_HEX, data: '0x2213bc0b', value: '0' },
|
|
72
|
+
networkFeeCryptoBaseUnit: '45600000',
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
(0, vitest_1.it)('prices the measured worst case when the allowance is not granted yet', async () => {
|
|
76
|
+
vitest_1.vi.mocked(helpers_1.createBobGatewayOrder).mockResolvedValue((0, monads_1.Ok)({ offramp: { orderId: 'order-1', tx: tronTx } }));
|
|
77
|
+
const adapter = tronAdapter({ allowance: '0' });
|
|
78
|
+
adapter.getFeeData.mockRejectedValue(new Error('REVERT opcode executed'));
|
|
79
|
+
const actual = await (0, getBobGatewayStepData_1.getBobGatewayStepData)({
|
|
80
|
+
type: 'quote',
|
|
81
|
+
input: {},
|
|
82
|
+
deps: makeDeps(adapter),
|
|
83
|
+
quote,
|
|
84
|
+
sellAsset: USDT_TRON,
|
|
85
|
+
sellAmountCryptoBaseUnit: '100000000',
|
|
86
|
+
spenderAddress: 'TAfbit1ENsRmtZbPQfYU3srURpfYuWYS7K',
|
|
87
|
+
from: FROM,
|
|
88
|
+
});
|
|
89
|
+
// 420000 energy * 1.2 margin * 100 sun + (4 calldata + 279 envelope) bytes * 1000 sun
|
|
90
|
+
(0, vitest_1.expect)(actual.unwrap()).toMatchObject({
|
|
91
|
+
orderId: 'order-1',
|
|
92
|
+
networkFeeCryptoBaseUnit: '50683000',
|
|
93
|
+
});
|
|
94
|
+
(0, vitest_1.expect)(adapter.httpProvider.getTrc20Allowance).toHaveBeenCalledWith({
|
|
95
|
+
contractAddress: 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',
|
|
96
|
+
owner: FROM,
|
|
97
|
+
spender: 'TAfbit1ENsRmtZbPQfYU3srURpfYuWYS7K',
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
(0, vitest_1.it)('fails the quote when the simulation reverts with the allowance in place', async () => {
|
|
101
|
+
vitest_1.vi.mocked(helpers_1.createBobGatewayOrder).mockResolvedValue((0, monads_1.Ok)({ offramp: { orderId: 'order-1', tx: tronTx } }));
|
|
102
|
+
const adapter = tronAdapter({ allowance: '100000000' });
|
|
103
|
+
adapter.getFeeData.mockRejectedValue(new Error('REVERT opcode executed'));
|
|
104
|
+
const actual = await (0, getBobGatewayStepData_1.getBobGatewayStepData)({
|
|
105
|
+
type: 'quote',
|
|
106
|
+
input: {},
|
|
107
|
+
deps: makeDeps(adapter),
|
|
108
|
+
quote,
|
|
109
|
+
sellAsset: USDT_TRON,
|
|
110
|
+
sellAmountCryptoBaseUnit: '100000000',
|
|
111
|
+
spenderAddress: 'TAfbit1ENsRmtZbPQfYU3srURpfYuWYS7K',
|
|
112
|
+
from: FROM,
|
|
113
|
+
});
|
|
114
|
+
(0, vitest_1.expect)(actual.isErr()).toBe(true);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getBobGatewayTradeContext = void 0;
|
|
4
|
-
const chain_adapters_1 = require("@shapeshiftoss/chain-adapters");
|
|
5
4
|
const monads_1 = require("@sniptt/monads");
|
|
6
5
|
const uuid_1 = require("uuid");
|
|
7
6
|
const types_1 = require("../../../types");
|
|
@@ -61,7 +60,7 @@ const getBobGatewayTradeContext = async ({ input, deps, sender, recipient, refun
|
|
|
61
60
|
quote,
|
|
62
61
|
sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
63
62
|
sellAsset,
|
|
64
|
-
spenderAddress:
|
|
63
|
+
spenderAddress: allowanceContract,
|
|
65
64
|
deps,
|
|
66
65
|
},
|
|
67
66
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GatewayOrderStatusV3,
|
|
1
|
+
import type { GatewayOrderStatusV3, GatewayQuoteV4, GetQuoteParams } from '@gobob/bob-sdk';
|
|
2
2
|
import { GatewaySDK } from '@gobob/bob-sdk';
|
|
3
3
|
import type { AssetId, ChainId } from '@shapeshiftoss/caip';
|
|
4
4
|
import type { Asset, AssetsByIdPartial } from '@shapeshiftoss/types';
|
|
@@ -8,7 +8,6 @@ import type { SwapErrorRight, SwapperConfig } from '../../../types';
|
|
|
8
8
|
import type { BobGatewayChainName } from './constants';
|
|
9
9
|
export declare const dummyAddressForChainId: (chainId: ChainId) => string;
|
|
10
10
|
export declare const getBobGatewayClient: (config: SwapperConfig) => GatewaySDK;
|
|
11
|
-
export declare const toTronBase58: (address: string) => string;
|
|
12
11
|
export declare const assetIdToBobGatewayToken: (assetId: string) => string;
|
|
13
12
|
export declare const getBobGatewayAffiliates: (affiliateBps: string) => GetQuoteParams['affiliates'];
|
|
14
13
|
export declare const getBobGatewayQuote: ({ config, sellAsset, buyAsset, sellChainName, buyChainName, sender, recipient, refundAddress, amount, affiliateBps, slippageTolerancePercentageDecimal, }: {
|
|
@@ -23,23 +22,21 @@ export declare const getBobGatewayQuote: ({ config, sellAsset, buyAsset, sellCha
|
|
|
23
22
|
amount: string;
|
|
24
23
|
affiliateBps: string;
|
|
25
24
|
slippageTolerancePercentageDecimal: string | undefined;
|
|
26
|
-
}) => Promise<Result<
|
|
27
|
-
export declare const createBobGatewayOrder: (config: SwapperConfig, quote:
|
|
28
|
-
export declare const
|
|
25
|
+
}) => Promise<Result<GatewayQuoteV4, SwapErrorRight>>;
|
|
26
|
+
export declare const createBobGatewayOrder: (config: SwapperConfig, quote: GatewayQuoteV4) => Promise<import("@sniptt/monads/build/result/result").ResOk<import("@gobob/bob-sdk").GatewayCreateOrderV3, never> | import("@sniptt/monads/build/result/result").ResErr<unknown, SwapErrorRight>>;
|
|
27
|
+
export declare const submitBobGatewayBtcDeposit: ({ config, orderId, bitcoinTxHex, }: {
|
|
29
28
|
config: SwapperConfig;
|
|
30
29
|
orderId: string;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
buyAsset: Asset;
|
|
34
|
-
}) => Promise<void>;
|
|
30
|
+
bitcoinTxHex: string;
|
|
31
|
+
}) => Promise<string>;
|
|
35
32
|
export declare const mapBobGatewayOrderStatusToTxStatus: (status: GatewayOrderStatusV3) => TxStatus;
|
|
36
|
-
export declare const parseBobGatewayQuote: (quote:
|
|
33
|
+
export declare const parseBobGatewayQuote: (quote: GatewayQuoteV4, buyAsset: Asset, assetsById: AssetsByIdPartial) => {
|
|
37
34
|
buyAmountBeforeFeesCryptoBaseUnit: string;
|
|
38
35
|
buyAmountAfterFeesCryptoBaseUnit: string;
|
|
39
36
|
protocolFees: Partial<Record<AssetId, import("../../../types").ProtocolFee>>;
|
|
40
37
|
estimatedExecutionTimeMs: number | undefined;
|
|
41
38
|
};
|
|
42
|
-
export declare const getBobGatewayAllowanceContract: (quote:
|
|
39
|
+
export declare const getBobGatewayAllowanceContract: (quote: GatewayQuoteV4, sellAsset: Asset) => string;
|
|
43
40
|
export declare const assertValidTrade: ({ sellAsset, buyAsset, }: {
|
|
44
41
|
sellAsset: Asset;
|
|
45
42
|
buyAsset: Asset;
|
|
@@ -1,24 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __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
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertValidTrade = exports.getBobGatewayAllowanceContract = exports.parseBobGatewayQuote = exports.mapBobGatewayOrderStatusToTxStatus = exports.
|
|
26
|
+
exports.assertValidTrade = exports.getBobGatewayAllowanceContract = exports.parseBobGatewayQuote = exports.mapBobGatewayOrderStatusToTxStatus = exports.submitBobGatewayBtcDeposit = exports.createBobGatewayOrder = exports.getBobGatewayQuote = exports.getBobGatewayAffiliates = exports.assetIdToBobGatewayToken = exports.getBobGatewayClient = exports.dummyAddressForChainId = void 0;
|
|
4
27
|
const bob_sdk_1 = require("@gobob/bob-sdk");
|
|
28
|
+
const bitcoin = __importStar(require("@shapeshiftoss/bitcoinjs-lib"));
|
|
5
29
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
6
30
|
const chain_adapters_1 = require("@shapeshiftoss/chain-adapters");
|
|
7
31
|
const unchained_client_1 = require("@shapeshiftoss/unchained-client");
|
|
8
32
|
const utils_1 = require("@shapeshiftoss/utils");
|
|
9
33
|
const monads_1 = require("@sniptt/monads");
|
|
10
|
-
const tronweb_1 = require("tronweb");
|
|
11
34
|
const viem_1 = require("viem");
|
|
12
35
|
const constants_1 = require("../../../constants");
|
|
13
36
|
const types_1 = require("../../../types");
|
|
14
37
|
const utils_2 = require("../../../utils");
|
|
15
38
|
const helpers_1 = require("../../../utils/helpers");
|
|
39
|
+
const tron_1 = require("../../../utils/tron");
|
|
16
40
|
const constants_2 = require("./constants");
|
|
17
41
|
const dummyAddressForChainId = (chainId) => {
|
|
18
42
|
if (chainId === caip_1.btcChainId)
|
|
19
43
|
return constants_2.DUMMY_BTC_ADDRESS;
|
|
20
44
|
if (chainId === caip_1.tronChainId)
|
|
21
|
-
return
|
|
45
|
+
return tron_1.TRON_PLACEHOLDER_ADDRESS;
|
|
22
46
|
return constants_2.DUMMY_EVM_ADDRESS;
|
|
23
47
|
};
|
|
24
48
|
exports.dummyAddressForChainId = dummyAddressForChainId;
|
|
@@ -26,14 +50,6 @@ const getBobGatewayClient = (config) => {
|
|
|
26
50
|
return new bob_sdk_1.GatewaySDK({ basePath: constants_2.BOB_GATEWAY_BASE_URL, apiKey: config.VITE_BOB_GATEWAY_API_KEY });
|
|
27
51
|
};
|
|
28
52
|
exports.getBobGatewayClient = getBobGatewayClient;
|
|
29
|
-
const toTronBase58 = (address) => {
|
|
30
|
-
if (address.startsWith('T'))
|
|
31
|
-
return address;
|
|
32
|
-
if (address.startsWith('0x'))
|
|
33
|
-
return tronweb_1.TronWeb.address.fromHex(address.slice(2));
|
|
34
|
-
return tronweb_1.TronWeb.address.fromHex(address);
|
|
35
|
-
};
|
|
36
|
-
exports.toTronBase58 = toTronBase58;
|
|
37
53
|
const assetIdToBobGatewayToken = (assetId) => {
|
|
38
54
|
// BOB Gateway uses the zero address as the token address for native assets
|
|
39
55
|
if (!(0, utils_1.isToken)(assetId))
|
|
@@ -62,7 +78,6 @@ const getBobGatewayQuote = async ({ config, sellAsset, buyAsset, sellChainName,
|
|
|
62
78
|
toUserAddress: recipient,
|
|
63
79
|
amount,
|
|
64
80
|
maxSlippage: Number(slippage),
|
|
65
|
-
ownerAddress: sellChainName === 'bitcoin' ? recipient : sender,
|
|
66
81
|
refundAddress,
|
|
67
82
|
affiliates: (0, exports.getBobGatewayAffiliates)(affiliateBps),
|
|
68
83
|
});
|
|
@@ -108,7 +123,7 @@ const getBobGatewayQuote = async ({ config, sellAsset, buyAsset, sellChainName,
|
|
|
108
123
|
exports.getBobGatewayQuote = getBobGatewayQuote;
|
|
109
124
|
const createBobGatewayOrder = async (config, quote) => {
|
|
110
125
|
try {
|
|
111
|
-
const order = await (0, exports.getBobGatewayClient)(config).api.
|
|
126
|
+
const order = await (0, exports.getBobGatewayClient)(config).api.createOrderV4({ gatewayQuoteV4: quote });
|
|
112
127
|
return (0, monads_1.Ok)(order);
|
|
113
128
|
}
|
|
114
129
|
catch (err) {
|
|
@@ -127,23 +142,13 @@ const createBobGatewayOrder = async (config, quote) => {
|
|
|
127
142
|
}
|
|
128
143
|
};
|
|
129
144
|
exports.createBobGatewayOrder = createBobGatewayOrder;
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return { onramp: { orderId, bitcoinTxid: txHash } };
|
|
136
|
-
}
|
|
137
|
-
// EVM→BTC
|
|
138
|
-
if (constants_2.chainIdToBobGatewayChainName[buyAsset.chainId] === 'bitcoin') {
|
|
139
|
-
return { offramp: { orderId, srcChain: sellChainName, srcTxHash: txHash } };
|
|
140
|
-
}
|
|
141
|
-
// EVM→EVM
|
|
142
|
-
return { tokenSwap: { orderId, srcChain: sellChainName, srcTxHash: txHash } };
|
|
143
|
-
})();
|
|
144
|
-
await (0, exports.getBobGatewayClient)(config).api.registerTxV3({ registerTxV3 });
|
|
145
|
+
const submitBobGatewayBtcDeposit = async ({ config, orderId, bitcoinTxHex, }) => {
|
|
146
|
+
await (0, exports.getBobGatewayClient)(config).api.registerTxV4({
|
|
147
|
+
registerTxV4: { onramp: { orderId, bitcoinTxHex } },
|
|
148
|
+
});
|
|
149
|
+
return bitcoin.Transaction.fromHex(bitcoinTxHex).getId();
|
|
145
150
|
};
|
|
146
|
-
exports.
|
|
151
|
+
exports.submitBobGatewayBtcDeposit = submitBobGatewayBtcDeposit;
|
|
147
152
|
const mapBobGatewayOrderStatusToTxStatus = (status) => {
|
|
148
153
|
if ('inProgress' in status)
|
|
149
154
|
return unchained_client_1.TxStatus.Pending;
|
|
@@ -166,7 +171,7 @@ const bobGatewayFeeToAssetId = (fee) => {
|
|
|
166
171
|
return (0, caip_1.toAssetId)({
|
|
167
172
|
chainId,
|
|
168
173
|
assetNamespace: caip_1.ASSET_NAMESPACE.trc20,
|
|
169
|
-
assetReference:
|
|
174
|
+
assetReference: chain_adapters_1.tron.toTronBase58(fee.address),
|
|
170
175
|
});
|
|
171
176
|
}
|
|
172
177
|
return (0, caip_1.toAssetId)({
|
|
@@ -240,7 +245,7 @@ const getBobGatewayAllowanceContract = (quote, sellAsset) => {
|
|
|
240
245
|
if (!txTo)
|
|
241
246
|
return '';
|
|
242
247
|
if (isTron)
|
|
243
|
-
return
|
|
248
|
+
return chain_adapters_1.tron.toTronBase58(txTo);
|
|
244
249
|
return txTo;
|
|
245
250
|
};
|
|
246
251
|
exports.getBobGatewayAllowanceContract = getBobGatewayAllowanceContract;
|
|
@@ -7,7 +7,6 @@ const monads_1 = require("@sniptt/monads");
|
|
|
7
7
|
const constants_1 = require("../../../constants");
|
|
8
8
|
const types_1 = require("../../../types");
|
|
9
9
|
const utils_2 = require("../../../utils");
|
|
10
|
-
const helpers_1 = require("../../../utils/helpers");
|
|
11
10
|
const getButterSwapStepData_1 = require("../utils/getButterSwapStepData");
|
|
12
11
|
const getButterSwapTradeContext_1 = require("../utils/getButterSwapTradeContext");
|
|
13
12
|
const xhr_1 = require("../xhr");
|
|
@@ -59,20 +58,18 @@ const getTradeQuote = async (input, deps) => {
|
|
|
59
58
|
});
|
|
60
59
|
if (maybeStepData.isErr())
|
|
61
60
|
return (0, monads_1.Err)(maybeStepData.unwrapErr());
|
|
62
|
-
const { networkFeeCryptoBaseUnit, transactionData
|
|
61
|
+
const { networkFeeCryptoBaseUnit, transactionData } = maybeStepData.unwrap();
|
|
63
62
|
const tradeQuote = {
|
|
64
63
|
...tradeCommon,
|
|
65
64
|
quoteOrRate: 'quote',
|
|
66
|
-
deadline: Date.now() + helpers_1.FALLBACK_QUOTE_DEADLINE_MS,
|
|
67
65
|
receiveAddress,
|
|
68
66
|
steps: [
|
|
69
67
|
{
|
|
70
68
|
...stepCommon,
|
|
71
69
|
accountNumber,
|
|
72
|
-
// Tron
|
|
70
|
+
// Tron routes pull the sell token from the buildTx target
|
|
73
71
|
allowanceContract: sellAsset.chainId === caip_1.tronChainId ? buildTx.to : stepCommon.allowanceContract,
|
|
74
72
|
transactionData,
|
|
75
|
-
butterSwapTransactionMetadata,
|
|
76
73
|
feeData: { networkFeeCryptoBaseUnit, protocolFees },
|
|
77
74
|
},
|
|
78
75
|
],
|
|
@@ -2,17 +2,6 @@ import type { Hex } from 'viem';
|
|
|
2
2
|
import type { GetEvmTradeQuoteInput, GetEvmTradeRateInput, GetSolanaTradeQuoteInput, GetSolanaTradeRateInput, GetTronTradeQuoteInput, GetTronTradeRateInput } from '../../types';
|
|
3
3
|
export type ButterSwapTradeQuoteInput = GetEvmTradeQuoteInput | GetSolanaTradeQuoteInput | GetTronTradeQuoteInput;
|
|
4
4
|
export type ButterSwapTradeRateInput = GetEvmTradeRateInput | GetSolanaTradeRateInput | GetTronTradeRateInput;
|
|
5
|
-
export type ButterSwapTransactionMetadata = {
|
|
6
|
-
to: string;
|
|
7
|
-
data: string;
|
|
8
|
-
value: Hex;
|
|
9
|
-
method?: string;
|
|
10
|
-
args?: {
|
|
11
|
-
type: string;
|
|
12
|
-
value: unknown;
|
|
13
|
-
}[];
|
|
14
|
-
memo?: string;
|
|
15
|
-
};
|
|
16
5
|
export type ErrorType = {
|
|
17
6
|
errno: number;
|
|
18
7
|
message: string;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeButterSwapAffiliate = void 0;
|
|
3
|
+
exports.makeButterSwapAffiliate = exports.BUTTERSWAP_TRON_DEFAULT_BANDWIDTH_BYTES = exports.BUTTERSWAP_TRON_FALLBACK_SWAP_ENERGY = void 0;
|
|
4
4
|
const utils_1 = require("@shapeshiftoss/utils");
|
|
5
5
|
const BUTTERSWAP_AFFILIATE = 'shapeshift';
|
|
6
|
+
// The router's total energy per swap, before its deployer's share comes off
|
|
7
|
+
exports.BUTTERSWAP_TRON_FALLBACK_SWAP_ENERGY = '1000000';
|
|
8
|
+
exports.BUTTERSWAP_TRON_DEFAULT_BANDWIDTH_BYTES = 2400;
|
|
6
9
|
// Format is `<nickname>[:rate]`, where rate is in basis points (e.g. `shapeshift:60` = 0.6%).
|
|
7
10
|
const makeButterSwapAffiliate = (affiliateBps) => {
|
|
8
11
|
if ((0, utils_1.bnOrZero)(affiliateBps).lte(0))
|
|
@@ -2,7 +2,7 @@ import type { Asset } from '@shapeshiftoss/types';
|
|
|
2
2
|
import type { Result } from '@sniptt/monads';
|
|
3
3
|
import type { StepDataArgs, SwapErrorRight, TxBuildData } from '../../../types';
|
|
4
4
|
import type { SolanaComputeBudgetOptions } from '../../../utils/solana';
|
|
5
|
-
import type { BuildTxSuccessItem,
|
|
5
|
+
import type { BuildTxSuccessItem, RouteSuccessItem } from '../types';
|
|
6
6
|
export declare const BUTTERSWAP_SOLANA_COMPUTE_BUDGET: SolanaComputeBudgetOptions;
|
|
7
7
|
type BaseArgs = {
|
|
8
8
|
route: RouteSuccessItem;
|
|
@@ -19,8 +19,7 @@ type ButterSwapRateStepData = {
|
|
|
19
19
|
networkFeeCryptoBaseUnit: string;
|
|
20
20
|
};
|
|
21
21
|
type ButterSwapQuoteStepData = {
|
|
22
|
-
transactionData
|
|
23
|
-
butterSwapTransactionMetadata?: ButterSwapTransactionMetadata;
|
|
22
|
+
transactionData: TxBuildData;
|
|
24
23
|
networkFeeCryptoBaseUnit: string;
|
|
25
24
|
};
|
|
26
25
|
export declare function getButterSwapStepData(args: Extract<GetButterSwapStepDataArgs, {
|
|
@@ -10,6 +10,8 @@ const types_1 = require("../../../types");
|
|
|
10
10
|
const utils_2 = require("../../../utils");
|
|
11
11
|
const evm_1 = require("../../../utils/evm");
|
|
12
12
|
const solana_1 = require("../../../utils/solana");
|
|
13
|
+
const tron_1 = require("../../../utils/tron");
|
|
14
|
+
const constants_1 = require("./constants");
|
|
13
15
|
const helpers_1 = require("./helpers");
|
|
14
16
|
// Jupiter swap legs can consume more units than simulated when pool state moves between
|
|
15
17
|
// simulation and landing (CLMM tick crossings), 1.4 matches Jupiter's dynamicComputeUnitLimit margin
|
|
@@ -117,26 +119,52 @@ async function getButterSwapStepData(args) {
|
|
|
117
119
|
return (0, monads_1.Err)((0, utils_2.makeTradeStepBuildFailedErr)('getButterSwapStepData', error));
|
|
118
120
|
}
|
|
119
121
|
}
|
|
120
|
-
// Not yet migrated to a TxBuildData variant - exec still builds from legacy metadata
|
|
121
122
|
case caip_1.CHAIN_NAMESPACE.Tron: {
|
|
122
|
-
const
|
|
123
|
+
const adapter = deps.assertGetTronChainAdapter(sellAsset.chainId);
|
|
123
124
|
if (args.type === 'rate') {
|
|
125
|
+
// Butter's gasFee is a fraction of what the router burns, so rates price the measured swap at the router's share
|
|
126
|
+
const networkFeeCryptoBaseUnit = await (async () => {
|
|
127
|
+
if (!route.contract)
|
|
128
|
+
return (0, helpers_1.getProviderNetworkFeeCryptoBaseUnit)({ route, feeAsset });
|
|
129
|
+
try {
|
|
130
|
+
return await (0, tron_1.getTronContractCallFallbackFeeCryptoBaseUnit)({
|
|
131
|
+
adapter,
|
|
132
|
+
energy: constants_1.BUTTERSWAP_TRON_FALLBACK_SWAP_ENERGY,
|
|
133
|
+
bandwidthBytes: constants_1.BUTTERSWAP_TRON_DEFAULT_BANDWIDTH_BYTES,
|
|
134
|
+
contractAddress: route.contract,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
return (0, helpers_1.getProviderNetworkFeeCryptoBaseUnit)({ route, feeAsset });
|
|
139
|
+
}
|
|
140
|
+
})();
|
|
124
141
|
const stepData = { networkFeeCryptoBaseUnit };
|
|
125
142
|
return (0, monads_1.Ok)(stepData);
|
|
126
143
|
}
|
|
127
|
-
const { buildTx } = args;
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
value: buildTx.value,
|
|
133
|
-
method: buildTx.method,
|
|
134
|
-
args: buildTx.args,
|
|
135
|
-
memo: buildTx.memo,
|
|
136
|
-
},
|
|
137
|
-
networkFeeCryptoBaseUnit,
|
|
144
|
+
const { buildTx, from } = args;
|
|
145
|
+
const call = {
|
|
146
|
+
to: buildTx.to,
|
|
147
|
+
data: buildTx.data,
|
|
148
|
+
value: (0, viem_1.fromHex)(buildTx.value, 'bigint').toString(),
|
|
138
149
|
};
|
|
139
|
-
|
|
150
|
+
try {
|
|
151
|
+
const stepData = {
|
|
152
|
+
transactionData: { type: 'tron', ...call },
|
|
153
|
+
networkFeeCryptoBaseUnit: await (0, tron_1.getTronContractCallNetworkFeeCryptoBaseUnit)({
|
|
154
|
+
adapter,
|
|
155
|
+
transactionData: call,
|
|
156
|
+
from,
|
|
157
|
+
sellAsset,
|
|
158
|
+
sellAmountCryptoBaseUnit,
|
|
159
|
+
spenderAddress: buildTx.to,
|
|
160
|
+
fallbackEnergy: constants_1.BUTTERSWAP_TRON_FALLBACK_SWAP_ENERGY,
|
|
161
|
+
}),
|
|
162
|
+
};
|
|
163
|
+
return (0, monads_1.Ok)(stepData);
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
return (0, monads_1.Err)((0, utils_2.makeNetworkFeeEstimationFailedErr)('getButterSwapStepData', error));
|
|
167
|
+
}
|
|
140
168
|
}
|
|
141
169
|
default:
|
|
142
170
|
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
@@ -17,6 +17,11 @@ const route = routeQuote_1.ROUTE_QUOTE.data[0];
|
|
|
17
17
|
const PROVIDER_GAS_FEE_BASE_UNIT = '1333043669759539'; // 0.001333043669759539 ETH
|
|
18
18
|
const SOL = { ...assets_1.ETH, assetId: `${caip_1.solanaChainId}/slip44:501`, chainId: caip_1.solanaChainId };
|
|
19
19
|
const TRX = { ...assets_1.ETH, assetId: `${caip_1.tronChainId}/slip44:195`, chainId: caip_1.tronChainId };
|
|
20
|
+
const USDT_TRON = {
|
|
21
|
+
...assets_1.ETH,
|
|
22
|
+
assetId: `${caip_1.tronChainId}/trc20:TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t`,
|
|
23
|
+
chainId: caip_1.tronChainId,
|
|
24
|
+
};
|
|
20
25
|
const evmBuildTx = {
|
|
21
26
|
to: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
22
27
|
data: '0xdeadbeef',
|
|
@@ -27,6 +32,7 @@ const makeDeps = (adapters) => ({
|
|
|
27
32
|
assertGetEvmChainAdapter: () => adapters.evm,
|
|
28
33
|
assertGetUtxoChainAdapter: () => adapters.utxo,
|
|
29
34
|
assertGetSolanaChainAdapter: () => adapters.solana,
|
|
35
|
+
assertGetTronChainAdapter: () => adapters.tron,
|
|
30
36
|
});
|
|
31
37
|
const evmAdapter = ({ gasPrice = '1000000000', estimatedGasLimit = '500000', throwOnGasFeeData = false, throwOnFeeData = false, } = {}) => ({
|
|
32
38
|
getGasFeeData: () => {
|
|
@@ -155,36 +161,133 @@ const evmQuoteInput = { supportsEIP1559: false };
|
|
|
155
161
|
});
|
|
156
162
|
});
|
|
157
163
|
(0, vitest_1.describe)('tron', () => {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
164
|
+
const tronBuildTx = { ...evmBuildTx, to: 'TRouterAddress' };
|
|
165
|
+
const tronAdapter = ({ txFee = '9000000', allowance = '0' } = {}) => ({
|
|
166
|
+
getFeeData: vitest_1.vi.fn().mockResolvedValue({ fast: { txFee } }),
|
|
167
|
+
httpProvider: {
|
|
168
|
+
getChainPrices: () => Promise.resolve({ energyPrice: 100, bandwidthPrice: 1000 }),
|
|
169
|
+
getTrc20Allowance: vitest_1.vi.fn().mockResolvedValue(allowance),
|
|
170
|
+
getTrc20Balance: vitest_1.vi.fn().mockResolvedValue('100000000'),
|
|
171
|
+
getContractEnergyShare: vitest_1.vi.fn().mockResolvedValue({
|
|
172
|
+
callerPercent: 100,
|
|
173
|
+
originEnergyLimit: 0,
|
|
174
|
+
originEnergyAvailable: 0,
|
|
175
|
+
}),
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
(0, vitest_1.it)('carries the router call as transactionData and simulates it', async () => {
|
|
179
|
+
const adapter = tronAdapter();
|
|
180
|
+
const actual = await (0, getButterSwapStepData_1.getButterSwapStepData)({
|
|
181
|
+
type: 'quote',
|
|
182
|
+
input: {},
|
|
183
|
+
from: 'TSenderAddress',
|
|
184
|
+
buildTx: tronBuildTx,
|
|
185
|
+
deps: makeDeps({ tron: adapter }),
|
|
186
|
+
route,
|
|
187
|
+
sellAsset: TRX,
|
|
188
|
+
feeAsset: TRX,
|
|
189
|
+
sellAmountCryptoBaseUnit: '1000000',
|
|
190
|
+
spenderAddress: '',
|
|
191
|
+
});
|
|
192
|
+
// Butter's value is the native amount to send: the sell amount for a native sell, 0 for a token
|
|
193
|
+
const transactionData = {
|
|
194
|
+
type: 'tron',
|
|
161
195
|
to: 'TRouterAddress',
|
|
162
|
-
|
|
163
|
-
|
|
196
|
+
data: evmBuildTx.data,
|
|
197
|
+
value: '100000000000000000',
|
|
164
198
|
};
|
|
199
|
+
(0, vitest_1.expect)(actual.unwrap()).toEqual({ transactionData, networkFeeCryptoBaseUnit: '9000000' });
|
|
200
|
+
(0, vitest_1.expect)(adapter.getFeeData).toHaveBeenCalledWith({
|
|
201
|
+
to: 'TRouterAddress',
|
|
202
|
+
value: '100000000000000000',
|
|
203
|
+
chainSpecific: { from: 'TSenderAddress', data: evmBuildTx.data, requireEnergyShare: true },
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
(0, vitest_1.it)('uses the provider value for a token sell', async () => {
|
|
165
207
|
const actual = await (0, getButterSwapStepData_1.getButterSwapStepData)({
|
|
166
208
|
type: 'quote',
|
|
167
209
|
input: {},
|
|
168
210
|
from: 'TSenderAddress',
|
|
169
|
-
buildTx,
|
|
170
|
-
deps: {},
|
|
211
|
+
buildTx: { ...tronBuildTx, value: '0x00' },
|
|
212
|
+
deps: makeDeps({ tron: tronAdapter() }),
|
|
213
|
+
route,
|
|
214
|
+
sellAsset: USDT_TRON,
|
|
215
|
+
feeAsset: TRX,
|
|
216
|
+
sellAmountCryptoBaseUnit: '1000000',
|
|
217
|
+
spenderAddress: '',
|
|
218
|
+
});
|
|
219
|
+
(0, vitest_1.expect)(actual.unwrap().transactionData).toMatchObject({ value: '0' });
|
|
220
|
+
});
|
|
221
|
+
(0, vitest_1.it)('fails a native quote when the simulation fails', async () => {
|
|
222
|
+
const adapter = tronAdapter();
|
|
223
|
+
adapter.getFeeData.mockRejectedValue(new Error('REVERT opcode executed'));
|
|
224
|
+
const actual = await (0, getButterSwapStepData_1.getButterSwapStepData)({
|
|
225
|
+
type: 'quote',
|
|
226
|
+
input: {},
|
|
227
|
+
from: 'TSenderAddress',
|
|
228
|
+
buildTx: tronBuildTx,
|
|
229
|
+
deps: makeDeps({ tron: adapter }),
|
|
171
230
|
route,
|
|
172
231
|
sellAsset: TRX,
|
|
173
232
|
feeAsset: TRX,
|
|
174
233
|
sellAmountCryptoBaseUnit: '1000000',
|
|
175
234
|
spenderAddress: '',
|
|
176
235
|
});
|
|
177
|
-
(0, vitest_1.expect)(actual.
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
},
|
|
236
|
+
(0, vitest_1.expect)(actual.isErr()).toBe(true);
|
|
237
|
+
});
|
|
238
|
+
(0, vitest_1.it)('prices the measured worst case when a token allowance is not granted yet', async () => {
|
|
239
|
+
const adapter = tronAdapter({ allowance: '0' });
|
|
240
|
+
adapter.getFeeData.mockRejectedValue(new Error('REVERT opcode executed'));
|
|
241
|
+
const actual = await (0, getButterSwapStepData_1.getButterSwapStepData)({
|
|
242
|
+
type: 'quote',
|
|
243
|
+
input: {},
|
|
244
|
+
from: 'TSenderAddress',
|
|
245
|
+
buildTx: { ...tronBuildTx, value: '0x00' },
|
|
246
|
+
deps: makeDeps({ tron: adapter }),
|
|
247
|
+
route,
|
|
248
|
+
sellAsset: USDT_TRON,
|
|
249
|
+
feeAsset: TRX,
|
|
250
|
+
sellAmountCryptoBaseUnit: '1000000',
|
|
251
|
+
spenderAddress: '',
|
|
252
|
+
});
|
|
253
|
+
// 1000000 energy * 1.2 margin * 100 sun + (4 calldata + 279 envelope) bytes * 1000 sun
|
|
254
|
+
(0, vitest_1.expect)(actual.unwrap().networkFeeCryptoBaseUnit).toBe('120283000');
|
|
255
|
+
});
|
|
256
|
+
(0, vitest_1.it)('rates price the measured swap at the router share', async () => {
|
|
257
|
+
const adapter = tronAdapter();
|
|
258
|
+
adapter.httpProvider.getContractEnergyShare.mockResolvedValue({
|
|
259
|
+
callerPercent: 5,
|
|
260
|
+
originEnergyLimit: 10_000_000,
|
|
261
|
+
originEnergyAvailable: 5_000_000,
|
|
262
|
+
});
|
|
263
|
+
const actual = await (0, getButterSwapStepData_1.getButterSwapStepData)({
|
|
264
|
+
type: 'rate',
|
|
265
|
+
input: {},
|
|
266
|
+
deps: makeDeps({ tron: adapter }),
|
|
267
|
+
route: { ...route, contract: 'TRouterAddress' },
|
|
268
|
+
sellAsset: TRX,
|
|
269
|
+
feeAsset: TRX,
|
|
270
|
+
sellAmountCryptoBaseUnit: '1000000',
|
|
271
|
+
spenderAddress: '',
|
|
272
|
+
});
|
|
273
|
+
// 1000000 * 5% caller energy * 1.2 margin * 100 sun + 2400 bytes * 1000 sun
|
|
274
|
+
(0, vitest_1.expect)(actual.unwrap()).toEqual({ networkFeeCryptoBaseUnit: '8400000' });
|
|
275
|
+
(0, vitest_1.expect)(adapter.httpProvider.getContractEnergyShare).toHaveBeenCalledWith('TRouterAddress');
|
|
276
|
+
});
|
|
277
|
+
(0, vitest_1.it)('rates fall back to the provider fee when the worst case cannot be priced', async () => {
|
|
278
|
+
const adapter = tronAdapter();
|
|
279
|
+
adapter.httpProvider.getContractEnergyShare.mockRejectedValue(new Error('429'));
|
|
280
|
+
const actual = await (0, getButterSwapStepData_1.getButterSwapStepData)({
|
|
281
|
+
type: 'rate',
|
|
282
|
+
input: {},
|
|
283
|
+
deps: makeDeps({ tron: adapter }),
|
|
284
|
+
route: { ...route, contract: 'TRouterAddress' },
|
|
285
|
+
sellAsset: TRX,
|
|
286
|
+
feeAsset: TRX,
|
|
287
|
+
sellAmountCryptoBaseUnit: '1000000',
|
|
288
|
+
spenderAddress: '',
|
|
187
289
|
});
|
|
290
|
+
(0, vitest_1.expect)(actual.unwrap()).toEqual({ networkFeeCryptoBaseUnit: PROVIDER_GAS_FEE_BASE_UNIT });
|
|
188
291
|
});
|
|
189
292
|
});
|
|
190
293
|
(0, vitest_1.it)('errors on an unsupported chain namespace', async () => {
|