@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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CHAIN_NAMESPACE, fromAssetId, fromChainId } from '@shapeshiftoss/caip';
|
|
2
|
-
import { evm } from '@shapeshiftoss/chain-adapters';
|
|
2
|
+
import { evm, tron } from '@shapeshiftoss/chain-adapters';
|
|
3
3
|
import { bn, contractAddressOrUndefined } from '@shapeshiftoss/utils';
|
|
4
4
|
import { Err, Ok } from '@sniptt/monads';
|
|
5
5
|
import { TradeQuoteError } from '../../../types.js';
|
|
@@ -150,23 +150,42 @@ export async function getChainflipStepData(args) {
|
|
|
150
150
|
return Err(makeNetworkFeeEstimationFailedErr('getChainflipStepData', error));
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
// Un-migrated - exec builds its tx from chainflipSpecific.depositAddress, so no transactionData is carried
|
|
154
153
|
case CHAIN_NAMESPACE.Tron: {
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
const adapter = deps.assertGetTronChainAdapter(sellAsset.chainId);
|
|
155
|
+
const contractAddress = contractAddressOrUndefined(sellAsset.assetId);
|
|
156
|
+
if (args.type === 'rate') {
|
|
157
|
+
// No deposit channel yet, but every channel is a fresh address, so a fresh recipient prices the transfer
|
|
158
|
+
const networkFeeCryptoBaseUnit = await (async () => {
|
|
159
|
+
if (!from)
|
|
160
|
+
return;
|
|
161
|
+
try {
|
|
162
|
+
const { fast } = await adapter.getFeeData({
|
|
163
|
+
to: tron.generateFreshTronAddress(),
|
|
164
|
+
value: sellAmountCryptoBaseUnit,
|
|
165
|
+
chainSpecific: { from, contractAddress },
|
|
166
|
+
});
|
|
167
|
+
return fast.txFee;
|
|
168
|
+
}
|
|
169
|
+
catch { }
|
|
170
|
+
})();
|
|
171
|
+
const stepData = { networkFeeCryptoBaseUnit };
|
|
158
172
|
return Ok(stepData);
|
|
159
173
|
}
|
|
174
|
+
const transactionData = {
|
|
175
|
+
type: 'tron',
|
|
176
|
+
to: args.depositAddress,
|
|
177
|
+
value: sellAmountCryptoBaseUnit,
|
|
178
|
+
};
|
|
160
179
|
try {
|
|
161
|
-
const { fast } = await
|
|
162
|
-
to,
|
|
163
|
-
value:
|
|
164
|
-
chainSpecific: {
|
|
165
|
-
from,
|
|
166
|
-
contractAddress: contractAddressOrUndefined(sellAsset.assetId),
|
|
167
|
-
},
|
|
180
|
+
const { fast } = await adapter.getFeeData({
|
|
181
|
+
to: transactionData.to,
|
|
182
|
+
value: transactionData.value,
|
|
183
|
+
chainSpecific: { from, contractAddress, requireEnergyShare: true },
|
|
168
184
|
});
|
|
169
|
-
const stepData = {
|
|
185
|
+
const stepData = {
|
|
186
|
+
transactionData,
|
|
187
|
+
networkFeeCryptoBaseUnit: fast.txFee,
|
|
188
|
+
};
|
|
170
189
|
return Ok(stepData);
|
|
171
190
|
}
|
|
172
191
|
catch (error) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Err, Ok } from '@sniptt/monads';
|
|
2
2
|
import { assertQuoteAddresses } from '../../../utils/index.js';
|
|
3
|
-
import { FALLBACK_QUOTE_DEADLINE_MS } from '../../../utils/helpers.js';
|
|
4
3
|
import { getDebridgeStepData } from '../utils/getDebridgeStepData.js';
|
|
5
4
|
import { getDebridgeTradeContext } from '../utils/getDebridgeTradeContext.js';
|
|
6
5
|
export const getTradeQuote = async (input, deps) => {
|
|
@@ -24,7 +23,6 @@ export const getTradeQuote = async (input, deps) => {
|
|
|
24
23
|
const tradeQuote = {
|
|
25
24
|
...tradeCommon,
|
|
26
25
|
quoteOrRate: 'quote',
|
|
27
|
-
deadline: Date.now() + FALLBACK_QUOTE_DEADLINE_MS,
|
|
28
26
|
receiveAddress,
|
|
29
27
|
steps: [
|
|
30
28
|
{
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { checkEvmSwapStatus } from '../../utils/index.js';
|
|
2
|
+
import { getEvmTransactionFees, getUnsignedEvmTransaction } from '../../utils/evm/index.js';
|
|
3
|
+
import { getTradeQuote } from './getTradeQuote/getTradeQuote.js';
|
|
4
|
+
import { getTradeRate } from './getTradeRate/getTradeRate.js';
|
|
5
|
+
export const fyndApi = {
|
|
6
|
+
getTradeQuote: (input, deps) => getTradeQuote(input, deps),
|
|
7
|
+
getTradeRate: (input, deps) => getTradeRate(input, deps),
|
|
8
|
+
getUnsignedEvmTransaction,
|
|
9
|
+
getEvmTransactionFees,
|
|
10
|
+
checkTradeStatus: checkEvmSwapStatus,
|
|
11
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Result } from '@sniptt/monads';
|
|
2
|
+
import type { SwapErrorRight, SwapperDeps, TradeQuote } from '../../../types.js';
|
|
3
|
+
import type { FyndTradeQuoteInput } from '../types.js';
|
|
4
|
+
export declare const getTradeQuote: (input: FyndTradeQuoteInput, deps: SwapperDeps) => Promise<Result<TradeQuote[], SwapErrorRight>>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Err, Ok } from '@sniptt/monads';
|
|
2
|
+
import { assertQuoteAddresses } from '../../../utils/index.js';
|
|
3
|
+
import { getFyndStepData } from '../utils/getFyndStepData.js';
|
|
4
|
+
import { getFyndTradeContext } from '../utils/getFyndTradeContext.js';
|
|
5
|
+
export const getTradeQuote = async (input, deps) => {
|
|
6
|
+
const { accountNumber } = input;
|
|
7
|
+
const maybeAddresses = assertQuoteAddresses(input);
|
|
8
|
+
if (maybeAddresses.isErr())
|
|
9
|
+
return Err(maybeAddresses.unwrapErr());
|
|
10
|
+
const { sendAddress, receiveAddress } = maybeAddresses.unwrap();
|
|
11
|
+
const maybeContext = await getFyndTradeContext({
|
|
12
|
+
input,
|
|
13
|
+
deps,
|
|
14
|
+
from: sendAddress,
|
|
15
|
+
to: receiveAddress,
|
|
16
|
+
});
|
|
17
|
+
if (maybeContext.isErr())
|
|
18
|
+
return Err(maybeContext.unwrapErr());
|
|
19
|
+
const { tradeCommon, stepCommon, protocolFees, deadline, stepDataArgs } = maybeContext.unwrap();
|
|
20
|
+
const maybeStepData = await getFyndStepData({ ...stepDataArgs, type: 'quote', input });
|
|
21
|
+
if (maybeStepData.isErr())
|
|
22
|
+
return Err(maybeStepData.unwrapErr());
|
|
23
|
+
const { transactionData, networkFeeCryptoBaseUnit } = maybeStepData.unwrap();
|
|
24
|
+
const tradeQuote = {
|
|
25
|
+
...tradeCommon,
|
|
26
|
+
quoteOrRate: 'quote',
|
|
27
|
+
receiveAddress,
|
|
28
|
+
deadline,
|
|
29
|
+
steps: [
|
|
30
|
+
{
|
|
31
|
+
...stepCommon,
|
|
32
|
+
accountNumber,
|
|
33
|
+
transactionData,
|
|
34
|
+
feeData: { networkFeeCryptoBaseUnit, protocolFees },
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
return Ok([tradeQuote]);
|
|
39
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Result } from '@sniptt/monads';
|
|
2
|
+
import type { SwapErrorRight, SwapperDeps, TradeRate } from '../../../types.js';
|
|
3
|
+
import type { FyndTradeRateInput } from '../types.js';
|
|
4
|
+
export declare const getTradeRate: (input: FyndTradeRateInput, deps: SwapperDeps) => Promise<Result<TradeRate[], SwapErrorRight>>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Err, Ok } from '@sniptt/monads';
|
|
2
|
+
import { EVM_PLACEHOLDER_ADDRESS } from '../../../utils/evm/constants.js';
|
|
3
|
+
import { getFyndStepData } from '../utils/getFyndStepData.js';
|
|
4
|
+
import { getFyndTradeContext } from '../utils/getFyndTradeContext.js';
|
|
5
|
+
export const getTradeRate = async (input, deps) => {
|
|
6
|
+
const { accountNumber, sendAddress, receiveAddress } = input;
|
|
7
|
+
const from = sendAddress ?? EVM_PLACEHOLDER_ADDRESS;
|
|
8
|
+
const to = receiveAddress ?? from;
|
|
9
|
+
const maybeContext = await getFyndTradeContext({ input, deps, from, to });
|
|
10
|
+
if (maybeContext.isErr())
|
|
11
|
+
return Err(maybeContext.unwrapErr());
|
|
12
|
+
const { tradeCommon, stepCommon, protocolFees, stepDataArgs } = maybeContext.unwrap();
|
|
13
|
+
const maybeStepData = await getFyndStepData({ ...stepDataArgs, type: 'rate', input });
|
|
14
|
+
if (maybeStepData.isErr())
|
|
15
|
+
return Err(maybeStepData.unwrapErr());
|
|
16
|
+
const { networkFeeCryptoBaseUnit } = maybeStepData.unwrap();
|
|
17
|
+
const tradeRate = {
|
|
18
|
+
...tradeCommon,
|
|
19
|
+
quoteOrRate: 'rate',
|
|
20
|
+
receiveAddress,
|
|
21
|
+
steps: [
|
|
22
|
+
{
|
|
23
|
+
...stepCommon,
|
|
24
|
+
accountNumber,
|
|
25
|
+
feeData: { networkFeeCryptoBaseUnit, protocolFees },
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
return Ok([tradeRate]);
|
|
30
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Address, Hex } from 'viem';
|
|
2
|
+
import type { GetEvmTradeQuoteInput, GetEvmTradeRateInput } from '../../types.js';
|
|
3
|
+
export type FyndTradeQuoteInput = GetEvmTradeQuoteInput;
|
|
4
|
+
export type FyndTradeRateInput = GetEvmTradeRateInput;
|
|
5
|
+
export type FyndTransaction = {
|
|
6
|
+
to: Address;
|
|
7
|
+
value: string;
|
|
8
|
+
data: Hex;
|
|
9
|
+
client_fee_signature_offset?: number | null;
|
|
10
|
+
};
|
|
11
|
+
export type FyndFeeBreakdown = {
|
|
12
|
+
router_fee: string;
|
|
13
|
+
client_fee: string;
|
|
14
|
+
max_slippage: string;
|
|
15
|
+
min_amount_received: string;
|
|
16
|
+
};
|
|
17
|
+
export type FyndErrorResponse = {
|
|
18
|
+
error: string;
|
|
19
|
+
code: string;
|
|
20
|
+
};
|
|
21
|
+
export type FyndRouteSwap = {
|
|
22
|
+
protocol: string;
|
|
23
|
+
};
|
|
24
|
+
export type FyndEncodedQuote = {
|
|
25
|
+
status: 'success';
|
|
26
|
+
amount_in: string;
|
|
27
|
+
amount_out: string;
|
|
28
|
+
gas_estimate: string;
|
|
29
|
+
route?: {
|
|
30
|
+
swaps: FyndRouteSwap[];
|
|
31
|
+
} | null;
|
|
32
|
+
transaction: FyndTransaction;
|
|
33
|
+
fee_breakdown: FyndFeeBreakdown;
|
|
34
|
+
client_fee_deadline?: number | null;
|
|
35
|
+
};
|
|
36
|
+
export type FyndFailedOrder = {
|
|
37
|
+
status: 'no_route_found' | 'insufficient_liquidity' | 'timeout' | 'not_ready' | 'price_check_failed' | 'encoding_failed';
|
|
38
|
+
};
|
|
39
|
+
export type FyndQuoteResponse = {
|
|
40
|
+
orders: (FyndEncodedQuote | FyndFailedOrder)[];
|
|
41
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const FYND_CHAINS: {
|
|
2
|
+
readonly "eip155:1": {
|
|
3
|
+
readonly name: "ethereum";
|
|
4
|
+
readonly routerAddress: "0x1644d2477f809cc2c71bccfd6dc9497e3f83210d";
|
|
5
|
+
};
|
|
6
|
+
readonly "eip155:8453": {
|
|
7
|
+
readonly name: "base";
|
|
8
|
+
readonly routerAddress: "0xaba5b53b03eafad1c5fc8bd5fc765fc85bb3de67";
|
|
9
|
+
};
|
|
10
|
+
readonly "eip155:42161": {
|
|
11
|
+
readonly name: "arbitrum";
|
|
12
|
+
readonly routerAddress: "0x924f147c50ea59f5180a26031a8b65b2aa1e81cd";
|
|
13
|
+
};
|
|
14
|
+
readonly "eip155:56": {
|
|
15
|
+
readonly name: "bsc";
|
|
16
|
+
readonly routerAddress: "0x7f3d12bbafb8955e51b3ab9588b34c8ad95bda4e";
|
|
17
|
+
};
|
|
18
|
+
readonly "eip155:137": {
|
|
19
|
+
readonly name: "polygon";
|
|
20
|
+
readonly routerAddress: "0xbd4e6011f03355c2a377fd9af939322a7d0a1bc1";
|
|
21
|
+
};
|
|
22
|
+
readonly "eip155:130": {
|
|
23
|
+
readonly name: "unichain";
|
|
24
|
+
readonly routerAddress: "0xcba5574597ad00ea250fd106dab4fc7461949635";
|
|
25
|
+
};
|
|
26
|
+
readonly "eip155:4663": {
|
|
27
|
+
readonly name: "robinhood";
|
|
28
|
+
readonly routerAddress: "0x09215a470bd585e59eb3f4b612fbd2678131ff9e";
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export type FyndSupportedChainId = keyof typeof FYND_CHAINS;
|
|
32
|
+
export declare const FYND_CLIENT_FEE_SHARE = 0.8;
|
|
33
|
+
export declare const FYND_CLIENT_FEE_SIGNATURE_BYTES = 65;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { KnownChainIds } from '@shapeshiftoss/types';
|
|
2
|
+
// Fynd Router Registry: https://docs.propellerheads.xyz/tycho/for-solvers/execution/contract-addresses
|
|
3
|
+
export const FYND_CHAINS = {
|
|
4
|
+
[KnownChainIds.EthereumMainnet]: {
|
|
5
|
+
name: 'ethereum',
|
|
6
|
+
routerAddress: '0x1644d2477f809cc2c71bccfd6dc9497e3f83210d',
|
|
7
|
+
},
|
|
8
|
+
[KnownChainIds.BaseMainnet]: {
|
|
9
|
+
name: 'base',
|
|
10
|
+
routerAddress: '0xaba5b53b03eafad1c5fc8bd5fc765fc85bb3de67',
|
|
11
|
+
},
|
|
12
|
+
[KnownChainIds.ArbitrumMainnet]: {
|
|
13
|
+
name: 'arbitrum',
|
|
14
|
+
routerAddress: '0x924f147c50ea59f5180a26031a8b65b2aa1e81cd',
|
|
15
|
+
},
|
|
16
|
+
[KnownChainIds.BnbSmartChainMainnet]: {
|
|
17
|
+
name: 'bsc',
|
|
18
|
+
routerAddress: '0x7f3d12bbafb8955e51b3ab9588b34c8ad95bda4e',
|
|
19
|
+
},
|
|
20
|
+
[KnownChainIds.PolygonMainnet]: {
|
|
21
|
+
name: 'polygon',
|
|
22
|
+
routerAddress: '0xbd4e6011f03355c2a377fd9af939322a7d0a1bc1',
|
|
23
|
+
},
|
|
24
|
+
[KnownChainIds.UnichainMainnet]: {
|
|
25
|
+
name: 'unichain',
|
|
26
|
+
routerAddress: '0xcba5574597ad00ea250fd106dab4fc7461949635',
|
|
27
|
+
},
|
|
28
|
+
[KnownChainIds.RobinhoodMainnet]: {
|
|
29
|
+
name: 'robinhood',
|
|
30
|
+
routerAddress: '0x09215a470bd585e59eb3f4b612fbd2678131ff9e',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
// Fynd keeps 20% of the client fee, so request the gross bps that nets affiliateBps
|
|
34
|
+
export const FYND_CLIENT_FEE_SHARE = 0.8;
|
|
35
|
+
export const FYND_CLIENT_FEE_SIGNATURE_BYTES = 65;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Result } from '@sniptt/monads';
|
|
2
|
+
import type { SwapErrorRight } from '../../../types.js';
|
|
3
|
+
import type { FyndEncodedQuote, FyndTradeQuoteInput, FyndTradeRateInput } from '../types.js';
|
|
4
|
+
import type { FyndSupportedChainId } from './constants.js';
|
|
5
|
+
export declare const fetchFromFynd: ({ input, chainId, sender, receiver, slippageTolerancePercentageDecimal, clientFeeBps, baseUrl, }: {
|
|
6
|
+
input: FyndTradeQuoteInput | FyndTradeRateInput;
|
|
7
|
+
chainId: FyndSupportedChainId;
|
|
8
|
+
sender: string;
|
|
9
|
+
receiver: string;
|
|
10
|
+
slippageTolerancePercentageDecimal: string;
|
|
11
|
+
clientFeeBps: number;
|
|
12
|
+
baseUrl: string;
|
|
13
|
+
}) => Promise<Result<FyndEncodedQuote, SwapErrorRight>>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Err } from '@sniptt/monads';
|
|
2
|
+
import { FYND_CHAINS } from './constants.js';
|
|
3
|
+
import { fyndService } from './fyndService.js';
|
|
4
|
+
import { convertAssetIdToFyndToken, getFyndRequestError, validateFyndQuoteResponse, } from './helpers.js';
|
|
5
|
+
export const fetchFromFynd = async ({ input, chainId, sender, receiver, slippageTolerancePercentageDecimal, clientFeeBps, baseUrl, }) => {
|
|
6
|
+
const { sellAsset, buyAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit } = input;
|
|
7
|
+
const maybeResponse = await fyndService.post(`${baseUrl}/${FYND_CHAINS[chainId].name}/quote`, {
|
|
8
|
+
orders: [
|
|
9
|
+
{
|
|
10
|
+
token_in: convertAssetIdToFyndToken(sellAsset.assetId),
|
|
11
|
+
token_out: convertAssetIdToFyndToken(buyAsset.assetId),
|
|
12
|
+
amount: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
13
|
+
side: 'sell',
|
|
14
|
+
sender,
|
|
15
|
+
receiver,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
options: {
|
|
19
|
+
timeout_ms: 5_000,
|
|
20
|
+
min_responses: 1,
|
|
21
|
+
encoding_options: {
|
|
22
|
+
slippage: slippageTolerancePercentageDecimal,
|
|
23
|
+
transfer_type: 'transfer_from',
|
|
24
|
+
// The proxy sets the fee receiver and deadline and signs the quote
|
|
25
|
+
...(clientFeeBps > 0 ? { client_fee_params: { bps: clientFeeBps } } : {}),
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
if (maybeResponse.isErr())
|
|
30
|
+
return Err(getFyndRequestError(maybeResponse.unwrapErr()));
|
|
31
|
+
return validateFyndQuoteResponse(maybeResponse.unwrap().data, {
|
|
32
|
+
chainId,
|
|
33
|
+
sellAsset,
|
|
34
|
+
sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
35
|
+
slippageTolerancePercentageDecimal,
|
|
36
|
+
clientFeeBps,
|
|
37
|
+
});
|
|
38
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const fyndService: {
|
|
2
|
+
get: <T = any>(url: string, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T, any, {}>, import("../../../index.js").SwapErrorRight>>;
|
|
3
|
+
post: <T_1 = any>(url: string, data: any, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T_1, any, {}>, import("../../../index.js").SwapErrorRight>>;
|
|
4
|
+
delete: <T_2 = any>(url: string, data: any, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T_2, any, {}>, import("../../../index.js").SwapErrorRight>>;
|
|
5
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Result } from '@sniptt/monads';
|
|
2
|
+
import type { StepDataArgs, SwapErrorRight, TxBuildData } from '../../../types.js';
|
|
3
|
+
import type { FyndEncodedQuote } from '../types.js';
|
|
4
|
+
type BaseArgs = {
|
|
5
|
+
quote: FyndEncodedQuote;
|
|
6
|
+
sellAmountCryptoBaseUnit: string;
|
|
7
|
+
spenderAddress: string;
|
|
8
|
+
};
|
|
9
|
+
export type GetFyndStepDataArgs = StepDataArgs<BaseArgs, {
|
|
10
|
+
from: string;
|
|
11
|
+
}>;
|
|
12
|
+
type FyndRateStepData = {
|
|
13
|
+
networkFeeCryptoBaseUnit: string | undefined;
|
|
14
|
+
};
|
|
15
|
+
type FyndQuoteStepData = {
|
|
16
|
+
transactionData: TxBuildData;
|
|
17
|
+
networkFeeCryptoBaseUnit: string;
|
|
18
|
+
};
|
|
19
|
+
export declare function getFyndStepData(args: Extract<GetFyndStepDataArgs, {
|
|
20
|
+
type: 'rate';
|
|
21
|
+
}>): Promise<Result<FyndRateStepData, SwapErrorRight>>;
|
|
22
|
+
export declare function getFyndStepData(args: Extract<GetFyndStepDataArgs, {
|
|
23
|
+
type: 'quote';
|
|
24
|
+
}>): Promise<Result<FyndQuoteStepData, SwapErrorRight>>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { fromChainId } from '@shapeshiftoss/caip';
|
|
2
|
+
import { Err, Ok } from '@sniptt/monads';
|
|
3
|
+
import { makeNetworkFeeEstimationFailedErr } from '../../../utils/index.js';
|
|
4
|
+
import { getEvmNetworkFeeCryptoBaseUnit } from '../../../utils/evm/index.js';
|
|
5
|
+
export async function getFyndStepData(args) {
|
|
6
|
+
const { quote, sellAsset, sellAmountCryptoBaseUnit, spenderAddress, from, type, input, deps } = args;
|
|
7
|
+
const adapter = deps.assertGetEvmChainAdapter(sellAsset.chainId);
|
|
8
|
+
const supportsEIP1559 = 'supportsEIP1559' in input ? input.supportsEIP1559 : false;
|
|
9
|
+
const transactionData = {
|
|
10
|
+
type: 'evm',
|
|
11
|
+
chainId: Number(fromChainId(sellAsset.chainId).chainReference),
|
|
12
|
+
to: quote.transaction.to,
|
|
13
|
+
data: quote.transaction.data,
|
|
14
|
+
value: quote.transaction.value,
|
|
15
|
+
};
|
|
16
|
+
const stateOverride = { sellAsset, sellAmountCryptoBaseUnit, spenderAddress };
|
|
17
|
+
if (type === 'rate') {
|
|
18
|
+
const networkFeeCryptoBaseUnit = await getEvmNetworkFeeCryptoBaseUnit({
|
|
19
|
+
adapter,
|
|
20
|
+
transactionData,
|
|
21
|
+
from,
|
|
22
|
+
supportsEIP1559,
|
|
23
|
+
stateOverride,
|
|
24
|
+
})
|
|
25
|
+
.catch(() => getEvmNetworkFeeCryptoBaseUnit({ adapter, supportsEIP1559, gasLimit: quote.gas_estimate }))
|
|
26
|
+
.catch(() => undefined);
|
|
27
|
+
const stepData = { networkFeeCryptoBaseUnit };
|
|
28
|
+
return Ok(stepData);
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const networkFeeCryptoBaseUnit = await getEvmNetworkFeeCryptoBaseUnit({
|
|
32
|
+
adapter,
|
|
33
|
+
transactionData,
|
|
34
|
+
from,
|
|
35
|
+
supportsEIP1559,
|
|
36
|
+
stateOverride,
|
|
37
|
+
});
|
|
38
|
+
const stepData = { transactionData, networkFeeCryptoBaseUnit };
|
|
39
|
+
return Ok(stepData);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
return Err(makeNetworkFeeEstimationFailedErr('getFyndStepData', error));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Result } from '@sniptt/monads';
|
|
2
|
+
import type { QuoteFeeData, SwapErrorRight, SwapperDeps, TradeCommon, TradeStepCommon } from '../../../types.js';
|
|
3
|
+
import type { FyndTradeQuoteInput, FyndTradeRateInput } from '../types.js';
|
|
4
|
+
import type { GetFyndStepDataArgs } from './getFyndStepData.js';
|
|
5
|
+
type FyndTradeContext = {
|
|
6
|
+
tradeCommon: TradeCommon;
|
|
7
|
+
stepCommon: Omit<TradeStepCommon, 'feeData'>;
|
|
8
|
+
protocolFees: QuoteFeeData['protocolFees'];
|
|
9
|
+
deadline: number | undefined;
|
|
10
|
+
stepDataArgs: Omit<GetFyndStepDataArgs, 'type' | 'input'>;
|
|
11
|
+
};
|
|
12
|
+
export declare const getFyndTradeContext: ({ input, deps, from, to, }: {
|
|
13
|
+
input: FyndTradeQuoteInput | FyndTradeRateInput;
|
|
14
|
+
deps: SwapperDeps;
|
|
15
|
+
from: string;
|
|
16
|
+
to: string;
|
|
17
|
+
}) => Promise<Result<FyndTradeContext, SwapErrorRight>>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { bn } from '@shapeshiftoss/utils';
|
|
2
|
+
import { Err, Ok } from '@sniptt/monads';
|
|
3
|
+
import { v4 as uuid } from 'uuid';
|
|
4
|
+
import { getDefaultSlippageDecimalPercentageForSwapper } from '../../../constants.js';
|
|
5
|
+
import { SwapperName } from '../../../types.js';
|
|
6
|
+
import { getInputOutputRate } from '../../../utils/index.js';
|
|
7
|
+
import { isNativeEvmAsset, normalizeEpochToMs } from '../../../utils/helpers.js';
|
|
8
|
+
import { fetchFromFynd } from './fetchFromFynd.js';
|
|
9
|
+
import { assertValidTrade, getFyndClientFeeBps, getFyndRouteProtocols } from './helpers.js';
|
|
10
|
+
export const getFyndTradeContext = async ({ input, deps, from, to, }) => {
|
|
11
|
+
const { sellAsset, buyAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, affiliateBps } = input;
|
|
12
|
+
const maybeChainId = assertValidTrade({ sellAsset, buyAsset });
|
|
13
|
+
if (maybeChainId.isErr())
|
|
14
|
+
return Err(maybeChainId.unwrapErr());
|
|
15
|
+
const chainId = maybeChainId.unwrap();
|
|
16
|
+
const slippageTolerancePercentageDecimal = input.slippageTolerancePercentageDecimal ??
|
|
17
|
+
getDefaultSlippageDecimalPercentageForSwapper(SwapperName.Fynd);
|
|
18
|
+
const clientFeeBps = getFyndClientFeeBps(affiliateBps);
|
|
19
|
+
const maybeQuote = await fetchFromFynd({
|
|
20
|
+
input,
|
|
21
|
+
chainId,
|
|
22
|
+
sender: from,
|
|
23
|
+
receiver: to,
|
|
24
|
+
slippageTolerancePercentageDecimal,
|
|
25
|
+
clientFeeBps,
|
|
26
|
+
baseUrl: deps.config.VITE_FYND_BASE_URL,
|
|
27
|
+
});
|
|
28
|
+
if (maybeQuote.isErr())
|
|
29
|
+
return Err(maybeQuote.unwrapErr());
|
|
30
|
+
const quote = maybeQuote.unwrap();
|
|
31
|
+
const { router_fee: routerFee, client_fee: clientFee } = quote.fee_breakdown;
|
|
32
|
+
const buyAmountBeforeFeesCryptoBaseUnit = quote.amount_out;
|
|
33
|
+
const buyAmountAfterFeesCryptoBaseUnit = bn(quote.amount_out)
|
|
34
|
+
.minus(routerFee)
|
|
35
|
+
.minus(clientFee)
|
|
36
|
+
.toFixed();
|
|
37
|
+
const rate = getInputOutputRate({
|
|
38
|
+
sellAmountCryptoBaseUnit: quote.amount_in,
|
|
39
|
+
buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
|
|
40
|
+
sellAsset,
|
|
41
|
+
buyAsset,
|
|
42
|
+
});
|
|
43
|
+
const protocols = getFyndRouteProtocols(quote.route?.swaps);
|
|
44
|
+
const source = protocols.length
|
|
45
|
+
? `${SwapperName.Fynd} • ${protocols.join(', ')}`
|
|
46
|
+
: SwapperName.Fynd;
|
|
47
|
+
const allowanceContract = isNativeEvmAsset(sellAsset.assetId) ? '' : quote.transaction.to;
|
|
48
|
+
const protocolFees = bn(routerFee).gt(0)
|
|
49
|
+
? {
|
|
50
|
+
[buyAsset.assetId]: {
|
|
51
|
+
amountCryptoBaseUnit: routerFee,
|
|
52
|
+
asset: buyAsset,
|
|
53
|
+
requiresBalance: false,
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
: {};
|
|
57
|
+
return Ok({
|
|
58
|
+
tradeCommon: {
|
|
59
|
+
id: uuid(),
|
|
60
|
+
rate,
|
|
61
|
+
swapperName: SwapperName.Fynd,
|
|
62
|
+
affiliateBps,
|
|
63
|
+
slippageTolerancePercentageDecimal,
|
|
64
|
+
},
|
|
65
|
+
stepCommon: {
|
|
66
|
+
estimatedExecutionTimeMs: 0,
|
|
67
|
+
allowanceContract,
|
|
68
|
+
rate,
|
|
69
|
+
sellAsset,
|
|
70
|
+
buyAsset,
|
|
71
|
+
sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
72
|
+
buyAmountBeforeFeesCryptoBaseUnit,
|
|
73
|
+
buyAmountAfterFeesCryptoBaseUnit,
|
|
74
|
+
source,
|
|
75
|
+
affiliateFee: bn(clientFee).gt(0)
|
|
76
|
+
? { assetId: buyAsset.assetId, amountCryptoBaseUnit: clientFee, asset: buyAsset }
|
|
77
|
+
: undefined,
|
|
78
|
+
},
|
|
79
|
+
protocolFees,
|
|
80
|
+
deadline: quote.client_fee_deadline ? normalizeEpochToMs(quote.client_fee_deadline) : undefined,
|
|
81
|
+
stepDataArgs: {
|
|
82
|
+
quote,
|
|
83
|
+
sellAsset,
|
|
84
|
+
sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
85
|
+
spenderAddress: allowanceContract,
|
|
86
|
+
from,
|
|
87
|
+
deps,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AssetId } from '@shapeshiftoss/caip';
|
|
2
|
+
import type { Asset } from '@shapeshiftoss/types';
|
|
3
|
+
import type { Result } from '@sniptt/monads';
|
|
4
|
+
import type { Address } from 'viem';
|
|
5
|
+
import type { SwapErrorRight } from '../../../types.js';
|
|
6
|
+
import type { FyndEncodedQuote, FyndQuoteResponse, FyndRouteSwap } from '../types.js';
|
|
7
|
+
import type { FyndSupportedChainId } from './constants.js';
|
|
8
|
+
export declare const getFyndRouteProtocols: (swaps: FyndRouteSwap[] | undefined) => string[];
|
|
9
|
+
export declare const getFyndClientFeeBps: (affiliateBps: string) => number;
|
|
10
|
+
export declare const convertAssetIdToFyndToken: (assetId: AssetId) => Address;
|
|
11
|
+
export declare const assertValidTrade: ({ sellAsset, buyAsset, }: {
|
|
12
|
+
sellAsset: Asset;
|
|
13
|
+
buyAsset: Asset;
|
|
14
|
+
}) => Result<FyndSupportedChainId, SwapErrorRight>;
|
|
15
|
+
export declare const getFyndRequestError: (error: SwapErrorRight) => SwapErrorRight;
|
|
16
|
+
type FyndQuoteContext = {
|
|
17
|
+
chainId: FyndSupportedChainId;
|
|
18
|
+
sellAsset: Asset;
|
|
19
|
+
sellAmountCryptoBaseUnit: string;
|
|
20
|
+
slippageTolerancePercentageDecimal: string;
|
|
21
|
+
clientFeeBps: number;
|
|
22
|
+
};
|
|
23
|
+
export declare const validateFyndQuoteResponse: (response: FyndQuoteResponse, context: FyndQuoteContext) => Result<FyndEncodedQuote, SwapErrorRight>;
|
|
24
|
+
export {};
|