@shapeshiftoss/swapper 17.6.9 → 17.6.11
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/LICENSE.md +21 -0
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/constants.js +72 -43
- package/dist/cjs/cowswap-utils/constants.js +3 -0
- package/dist/cjs/cowswap-utils/index.js +6 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/swappers/AcrossSwapper/AcrossSwapper.d.ts +2 -0
- package/dist/cjs/swappers/AcrossSwapper/AcrossSwapper.js +8 -0
- package/dist/cjs/swappers/AcrossSwapper/constant.d.ts +9 -0
- package/dist/cjs/swappers/AcrossSwapper/constant.js +50 -0
- package/dist/cjs/swappers/AcrossSwapper/endpoints.d.ts +2 -0
- package/dist/cjs/swappers/AcrossSwapper/endpoints.js +113 -0
- package/dist/cjs/swappers/AcrossSwapper/getTradeQuote/getTradeQuote.d.ts +3 -0
- package/dist/cjs/swappers/AcrossSwapper/getTradeQuote/getTradeQuote.js +31 -0
- package/dist/cjs/swappers/AcrossSwapper/getTradeRate/getTradeRate.d.ts +3 -0
- package/dist/cjs/swappers/AcrossSwapper/getTradeRate/getTradeRate.js +19 -0
- package/dist/cjs/swappers/AcrossSwapper/index.d.ts +1 -0
- package/dist/cjs/swappers/AcrossSwapper/index.js +5 -0
- package/dist/cjs/swappers/AcrossSwapper/utils/acrossService.d.ts +5 -0
- package/dist/cjs/swappers/AcrossSwapper/utils/acrossService.js +17 -0
- package/dist/cjs/swappers/AcrossSwapper/utils/fetchAcrossTrade.d.ts +19 -0
- package/dist/cjs/swappers/AcrossSwapper/utils/fetchAcrossTrade.js +27 -0
- package/dist/cjs/swappers/AcrossSwapper/utils/getTrade.d.ts +11 -0
- package/dist/cjs/swappers/AcrossSwapper/utils/getTrade.js +349 -0
- package/dist/cjs/swappers/AcrossSwapper/utils/types.d.ts +177 -0
- package/dist/cjs/swappers/AcrossSwapper/utils/types.js +17 -0
- package/dist/cjs/swappers/AvnuSwapper/endpoints.js +42 -14
- package/dist/cjs/swappers/AvnuSwapper/swapperApi/getTradeQuote.js +19 -5
- package/dist/cjs/swappers/AvnuSwapper/swapperApi/getTradeRate.js +17 -4
- package/dist/cjs/swappers/BebopSwapper/BebopSwapper.js +2 -0
- package/dist/cjs/swappers/BebopSwapper/endpoints.js +35 -2
- package/dist/cjs/swappers/BebopSwapper/executeSolanaMessage.d.ts +2 -0
- package/dist/cjs/swappers/BebopSwapper/executeSolanaMessage.js +47 -0
- package/dist/cjs/swappers/BebopSwapper/getBebopSolanaTradeQuote/getBebopSolanaTradeQuote.d.ts +4 -0
- package/dist/cjs/swappers/BebopSwapper/getBebopSolanaTradeQuote/getBebopSolanaTradeQuote.js +91 -0
- package/dist/cjs/swappers/BebopSwapper/getBebopSolanaTradeRate/getBebopSolanaTradeRate.d.ts +4 -0
- package/dist/cjs/swappers/BebopSwapper/getBebopSolanaTradeRate/getBebopSolanaTradeRate.js +88 -0
- package/dist/cjs/swappers/BebopSwapper/getBebopTradeQuote/getBebopTradeQuote.js +10 -0
- package/dist/cjs/swappers/BebopSwapper/getBebopTradeRate/getBebopTradeRate.js +10 -0
- package/dist/cjs/swappers/BebopSwapper/types.d.ts +49 -1
- package/dist/cjs/swappers/BebopSwapper/types.js +9 -2
- package/dist/cjs/swappers/BebopSwapper/utils/fetchFromBebop.d.ts +19 -1
- package/dist/cjs/swappers/BebopSwapper/utils/fetchFromBebop.js +86 -1
- package/dist/cjs/swappers/BebopSwapper/utils/helpers/helpers.d.ts +14 -2
- package/dist/cjs/swappers/BebopSwapper/utils/helpers/helpers.js +47 -1
- package/dist/cjs/swappers/ButterSwap/ButterSwap.js +1 -0
- package/dist/cjs/swappers/ButterSwap/endpoints.js +56 -0
- package/dist/cjs/swappers/ButterSwap/swapperApi/checkTradeStatus.js +19 -0
- package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeQuote.js +44 -15
- package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeQuote.test.js +1 -0
- package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeRate.js +33 -16
- package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeRate.test.js +2 -0
- package/dist/cjs/swappers/ButterSwap/types.d.ts +1 -0
- package/dist/cjs/swappers/ButterSwap/utils/helpers.js +1 -0
- package/dist/cjs/swappers/ButterSwap/xhr.d.ts +2 -2
- package/dist/cjs/swappers/ButterSwap/xhr.js +7 -2
- package/dist/cjs/swappers/CetusSwapper/endpoints.js +3 -8
- package/dist/cjs/swappers/CetusSwapper/swapperApi/getTradeQuote.js +11 -1
- package/dist/cjs/swappers/CetusSwapper/swapperApi/getTradeRate.js +11 -1
- package/dist/cjs/swappers/CetusSwapper/utils/helpers.d.ts +1 -1
- package/dist/cjs/swappers/CetusSwapper/utils/helpers.js +1 -1
- package/dist/cjs/swappers/ChainflipSwapper/constants.js +7 -3
- package/dist/cjs/swappers/ChainflipSwapper/utils/getQuoteOrRate.js +28 -5
- package/dist/cjs/swappers/ChainflipSwapper/utils/helpers.js +8 -2
- package/dist/cjs/swappers/CowSwapper/CowSwapper.js +1 -1
- package/dist/cjs/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.js +11 -1
- package/dist/cjs/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.test.js +5 -5
- package/dist/cjs/swappers/CowSwapper/getCowSwapTradeRate/getCowSwapTradeRate.js +10 -1
- package/dist/cjs/swappers/CowSwapper/utils/helpers/helpers.js +8 -2
- package/dist/cjs/swappers/DebridgeSwapper/DebridgeSwapper.d.ts +2 -0
- package/dist/cjs/swappers/DebridgeSwapper/DebridgeSwapper.js +7 -0
- package/dist/cjs/swappers/DebridgeSwapper/constant.d.ts +5 -0
- package/dist/cjs/swappers/DebridgeSwapper/constant.js +36 -0
- package/dist/cjs/swappers/DebridgeSwapper/endpoints.d.ts +2 -0
- package/dist/cjs/swappers/DebridgeSwapper/endpoints.js +217 -0
- package/dist/cjs/swappers/DebridgeSwapper/getTradeQuote/getTradeQuote.d.ts +3 -0
- package/dist/cjs/swappers/DebridgeSwapper/getTradeQuote/getTradeQuote.js +31 -0
- package/dist/cjs/swappers/DebridgeSwapper/getTradeRate/getTradeRate.d.ts +3 -0
- package/dist/cjs/swappers/DebridgeSwapper/getTradeRate/getTradeRate.js +19 -0
- package/dist/cjs/swappers/DebridgeSwapper/index.d.ts +1 -0
- package/dist/cjs/swappers/DebridgeSwapper/index.js +5 -0
- package/dist/cjs/swappers/DebridgeSwapper/utils/debridgeService.d.ts +5 -0
- package/dist/cjs/swappers/DebridgeSwapper/utils/debridgeService.js +17 -0
- package/dist/cjs/swappers/DebridgeSwapper/utils/fetchDebridgeSingleChainTrade.d.ts +16 -0
- package/dist/cjs/swappers/DebridgeSwapper/utils/fetchDebridgeSingleChainTrade.js +23 -0
- package/dist/cjs/swappers/DebridgeSwapper/utils/fetchDebridgeTrade.d.ts +20 -0
- package/dist/cjs/swappers/DebridgeSwapper/utils/fetchDebridgeTrade.js +29 -0
- package/dist/cjs/swappers/DebridgeSwapper/utils/getTrade.d.ts +11 -0
- package/dist/cjs/swappers/DebridgeSwapper/utils/getTrade.js +369 -0
- package/dist/cjs/swappers/DebridgeSwapper/utils/types.d.ts +155 -0
- package/dist/cjs/swappers/DebridgeSwapper/utils/types.js +9 -0
- package/dist/cjs/swappers/JupiterSwapper/swapperApi/getTradeQuote.js +32 -0
- package/dist/cjs/swappers/JupiterSwapper/swapperApi/getTradeRate.js +9 -0
- package/dist/cjs/swappers/MayachainSwapper/utils/poolAssetHelpers/poolAssetHelpers.js +1 -1
- package/dist/cjs/swappers/NearIntentsSwapper/NearIntentsSwapper.js +1 -0
- package/dist/cjs/swappers/NearIntentsSwapper/endpoints.js +31 -0
- package/dist/cjs/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.js +48 -1
- package/dist/cjs/swappers/NearIntentsSwapper/swapperApi/getTradeRate.js +73 -1
- package/dist/cjs/swappers/NearIntentsSwapper/types.d.ts +1 -1
- package/dist/cjs/swappers/NearIntentsSwapper/types.js +6 -0
- package/dist/cjs/swappers/NearIntentsSwapper/utils/helpers/helpers.js +23 -4
- package/dist/cjs/swappers/PortalsSwapper/getPortalsTradeQuote/getPortalsTradeQuote.js +10 -0
- package/dist/cjs/swappers/PortalsSwapper/getPortalsTradeRate/getPortalsTradeRate.js +8 -3
- package/dist/cjs/swappers/RelaySwapper/constant.js +27 -1
- package/dist/cjs/swappers/RelaySwapper/utils/getRelayDefaultUserAddress.d.ts +1 -1
- package/dist/cjs/swappers/RelaySwapper/utils/getTrade.js +57 -7
- package/dist/cjs/swappers/RelaySwapper/utils/relayTokenToAssetId.js +110 -0
- package/dist/cjs/swappers/RelaySwapper/utils/types.d.ts +15 -0
- package/dist/cjs/swappers/StonfiSwapper/StonfiSwapper.d.ts +2 -0
- package/dist/cjs/swappers/StonfiSwapper/StonfiSwapper.js +8 -0
- package/dist/cjs/swappers/StonfiSwapper/endpoints.d.ts +2 -0
- package/dist/cjs/swappers/StonfiSwapper/endpoints.js +227 -0
- package/dist/cjs/swappers/StonfiSwapper/index.d.ts +4 -0
- package/dist/cjs/swappers/StonfiSwapper/index.js +25 -0
- package/dist/cjs/swappers/StonfiSwapper/swapperApi/getTradeQuote.d.ts +2 -0
- package/dist/cjs/swappers/StonfiSwapper/swapperApi/getTradeQuote.js +129 -0
- package/dist/cjs/swappers/StonfiSwapper/swapperApi/getTradeRate.d.ts +2 -0
- package/dist/cjs/swappers/StonfiSwapper/swapperApi/getTradeRate.js +115 -0
- package/dist/cjs/swappers/StonfiSwapper/types.d.ts +60 -0
- package/dist/cjs/swappers/StonfiSwapper/types.js +5 -0
- package/dist/cjs/swappers/StonfiSwapper/utils/constants.d.ts +5 -0
- package/dist/cjs/swappers/StonfiSwapper/utils/constants.js +8 -0
- package/dist/cjs/swappers/StonfiSwapper/utils/helpers.d.ts +11 -0
- package/dist/cjs/swappers/StonfiSwapper/utils/helpers.js +135 -0
- package/dist/cjs/swappers/StonfiSwapper/utils/omnistonManager.d.ts +5 -0
- package/dist/cjs/swappers/StonfiSwapper/utils/omnistonManager.js +20 -0
- package/dist/cjs/swappers/SunioSwapper/endpoints.js +1 -1
- package/dist/cjs/swappers/SunioSwapper/utils/getQuoteOrRate.js +14 -3
- package/dist/cjs/swappers/ThorchainSwapper/ThorchainSwapper.js +3 -0
- package/dist/cjs/swappers/ThorchainSwapper/endpoints.js +2 -0
- package/dist/cjs/swappers/ThorchainSwapper/generated/generatedTradableAssetMap.json +1 -0
- package/dist/cjs/swappers/ThorchainSwapper/utils/poolAssetHelpers/poolAssetHelpers.d.ts +1 -1
- package/dist/cjs/swappers/ThorchainSwapper/utils/poolAssetHelpers/poolAssetHelpers.js +2 -1
- package/dist/cjs/swappers/ThorchainSwapper/utils/poolAssetHelpers/poolAssetHelpers.test.js +10 -0
- package/dist/cjs/swappers/ZrxSwapper/getZrxTradeQuote/getZrxTradeQuote.js +9 -0
- package/dist/cjs/swappers/ZrxSwapper/getZrxTradeRate/getZrxTradeRate.js +9 -0
- package/dist/cjs/swappers/ZrxSwapper/utils/helpers/helpers.d.ts +1 -1
- package/dist/cjs/swappers/utils/affiliateFee.d.ts +17 -0
- package/dist/cjs/swappers/utils/affiliateFee.js +43 -0
- package/dist/cjs/swappers/utils/filterBuyAssetsBySellAssetId/filterBuyAssetsBySellAssetId.js +2 -5
- package/dist/cjs/swappers/utils/helpers/helpers.js +3 -0
- package/dist/cjs/thorchain-utils/getCallDataFromQuote.d.ts +1 -1
- package/dist/cjs/thorchain-utils/getL1RateOrQuote.js +87 -9
- package/dist/cjs/thorchain-utils/getQuote.js +8 -2
- package/dist/cjs/thorchain-utils/index.d.ts +2 -1
- package/dist/cjs/thorchain-utils/index.js +2 -1
- package/dist/cjs/thorchain-utils/solana/constants.d.ts +1 -0
- package/dist/cjs/thorchain-utils/solana/constants.js +6 -0
- package/dist/cjs/thorchain-utils/solana/getSolanaTransactionFees.d.ts +2 -0
- package/dist/cjs/thorchain-utils/solana/getSolanaTransactionFees.js +41 -0
- package/dist/cjs/thorchain-utils/solana/getThorTxData.d.ts +12 -0
- package/dist/cjs/thorchain-utils/solana/getThorTxData.js +14 -0
- package/dist/cjs/thorchain-utils/solana/getUnsignedSolanaTransaction.d.ts +3 -0
- package/dist/cjs/thorchain-utils/solana/getUnsignedSolanaTransaction.js +64 -0
- package/dist/cjs/thorchain-utils/solana/index.d.ts +3 -0
- package/dist/cjs/thorchain-utils/solana/index.js +19 -0
- package/dist/cjs/tron-utils/getUnsignedTronTransaction.js +22 -2
- package/dist/cjs/types.d.ts +118 -8
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/utils.d.ts +4 -3
- package/dist/cjs/utils.js +35 -7
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/constants.js +42 -13
- package/dist/esm/cowswap-utils/constants.js +3 -0
- package/dist/esm/cowswap-utils/index.js +6 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/swappers/AcrossSwapper/AcrossSwapper.d.ts +2 -0
- package/dist/esm/swappers/AcrossSwapper/AcrossSwapper.js +5 -0
- package/dist/esm/swappers/AcrossSwapper/constant.d.ts +9 -0
- package/dist/esm/swappers/AcrossSwapper/constant.js +44 -0
- package/dist/esm/swappers/AcrossSwapper/endpoints.d.ts +2 -0
- package/dist/esm/swappers/AcrossSwapper/endpoints.js +107 -0
- package/dist/esm/swappers/AcrossSwapper/getTradeQuote/getTradeQuote.d.ts +3 -0
- package/dist/esm/swappers/AcrossSwapper/getTradeQuote/getTradeQuote.js +27 -0
- package/dist/esm/swappers/AcrossSwapper/getTradeRate/getTradeRate.d.ts +3 -0
- package/dist/esm/swappers/AcrossSwapper/getTradeRate/getTradeRate.js +15 -0
- package/dist/esm/swappers/AcrossSwapper/index.d.ts +1 -0
- package/dist/esm/swappers/AcrossSwapper/index.js +1 -0
- package/dist/esm/swappers/AcrossSwapper/utils/acrossService.d.ts +5 -0
- package/dist/esm/swappers/AcrossSwapper/utils/acrossService.js +11 -0
- package/dist/esm/swappers/AcrossSwapper/utils/fetchAcrossTrade.d.ts +19 -0
- package/dist/esm/swappers/AcrossSwapper/utils/fetchAcrossTrade.js +23 -0
- package/dist/esm/swappers/AcrossSwapper/utils/getTrade.d.ts +11 -0
- package/dist/esm/swappers/AcrossSwapper/utils/getTrade.js +342 -0
- package/dist/esm/swappers/AcrossSwapper/utils/types.d.ts +177 -0
- package/dist/esm/swappers/AcrossSwapper/utils/types.js +13 -0
- package/dist/esm/swappers/AvnuSwapper/endpoints.js +43 -15
- package/dist/esm/swappers/AvnuSwapper/swapperApi/getTradeQuote.js +19 -5
- package/dist/esm/swappers/AvnuSwapper/swapperApi/getTradeRate.js +17 -4
- package/dist/esm/swappers/BebopSwapper/BebopSwapper.js +2 -0
- package/dist/esm/swappers/BebopSwapper/endpoints.js +36 -3
- package/dist/esm/swappers/BebopSwapper/executeSolanaMessage.d.ts +2 -0
- package/dist/esm/swappers/BebopSwapper/executeSolanaMessage.js +40 -0
- package/dist/esm/swappers/BebopSwapper/getBebopSolanaTradeQuote/getBebopSolanaTradeQuote.d.ts +4 -0
- package/dist/esm/swappers/BebopSwapper/getBebopSolanaTradeQuote/getBebopSolanaTradeQuote.js +87 -0
- package/dist/esm/swappers/BebopSwapper/getBebopSolanaTradeRate/getBebopSolanaTradeRate.d.ts +4 -0
- package/dist/esm/swappers/BebopSwapper/getBebopSolanaTradeRate/getBebopSolanaTradeRate.js +84 -0
- package/dist/esm/swappers/BebopSwapper/getBebopTradeQuote/getBebopTradeQuote.js +10 -0
- package/dist/esm/swappers/BebopSwapper/getBebopTradeRate/getBebopTradeRate.js +10 -0
- package/dist/esm/swappers/BebopSwapper/types.d.ts +49 -1
- package/dist/esm/swappers/BebopSwapper/types.js +8 -1
- package/dist/esm/swappers/BebopSwapper/utils/fetchFromBebop.d.ts +19 -1
- package/dist/esm/swappers/BebopSwapper/utils/fetchFromBebop.js +85 -2
- package/dist/esm/swappers/BebopSwapper/utils/helpers/helpers.d.ts +14 -2
- package/dist/esm/swappers/BebopSwapper/utils/helpers/helpers.js +44 -1
- package/dist/esm/swappers/ButterSwap/ButterSwap.js +2 -1
- package/dist/esm/swappers/ButterSwap/endpoints.js +56 -0
- package/dist/esm/swappers/ButterSwap/swapperApi/checkTradeStatus.js +20 -1
- package/dist/esm/swappers/ButterSwap/swapperApi/getTradeQuote.js +46 -17
- package/dist/esm/swappers/ButterSwap/swapperApi/getTradeQuote.test.js +1 -0
- package/dist/esm/swappers/ButterSwap/swapperApi/getTradeRate.js +35 -18
- package/dist/esm/swappers/ButterSwap/swapperApi/getTradeRate.test.js +2 -0
- package/dist/esm/swappers/ButterSwap/types.d.ts +1 -0
- package/dist/esm/swappers/ButterSwap/utils/helpers.js +1 -0
- package/dist/esm/swappers/ButterSwap/xhr.d.ts +2 -2
- package/dist/esm/swappers/ButterSwap/xhr.js +8 -3
- package/dist/esm/swappers/CetusSwapper/endpoints.js +3 -8
- package/dist/esm/swappers/CetusSwapper/swapperApi/getTradeQuote.js +11 -1
- package/dist/esm/swappers/CetusSwapper/swapperApi/getTradeRate.js +11 -1
- package/dist/esm/swappers/CetusSwapper/utils/helpers.d.ts +1 -1
- package/dist/esm/swappers/CetusSwapper/utils/helpers.js +1 -1
- package/dist/esm/swappers/ChainflipSwapper/constants.js +8 -4
- package/dist/esm/swappers/ChainflipSwapper/utils/getQuoteOrRate.js +29 -6
- package/dist/esm/swappers/ChainflipSwapper/utils/helpers.js +9 -3
- package/dist/esm/swappers/CowSwapper/CowSwapper.js +1 -1
- package/dist/esm/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.js +11 -1
- package/dist/esm/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.test.js +5 -5
- package/dist/esm/swappers/CowSwapper/getCowSwapTradeRate/getCowSwapTradeRate.js +10 -1
- package/dist/esm/swappers/CowSwapper/utils/helpers/helpers.js +9 -3
- package/dist/esm/swappers/DebridgeSwapper/DebridgeSwapper.d.ts +2 -0
- package/dist/esm/swappers/DebridgeSwapper/DebridgeSwapper.js +4 -0
- package/dist/esm/swappers/DebridgeSwapper/constant.d.ts +5 -0
- package/dist/esm/swappers/DebridgeSwapper/constant.js +30 -0
- package/dist/esm/swappers/DebridgeSwapper/endpoints.d.ts +2 -0
- package/dist/esm/swappers/DebridgeSwapper/endpoints.js +211 -0
- package/dist/esm/swappers/DebridgeSwapper/getTradeQuote/getTradeQuote.d.ts +3 -0
- package/dist/esm/swappers/DebridgeSwapper/getTradeQuote/getTradeQuote.js +27 -0
- package/dist/esm/swappers/DebridgeSwapper/getTradeRate/getTradeRate.d.ts +3 -0
- package/dist/esm/swappers/DebridgeSwapper/getTradeRate/getTradeRate.js +15 -0
- package/dist/esm/swappers/DebridgeSwapper/index.d.ts +1 -0
- package/dist/esm/swappers/DebridgeSwapper/index.js +1 -0
- package/dist/esm/swappers/DebridgeSwapper/utils/debridgeService.d.ts +5 -0
- package/dist/esm/swappers/DebridgeSwapper/utils/debridgeService.js +11 -0
- package/dist/esm/swappers/DebridgeSwapper/utils/fetchDebridgeSingleChainTrade.d.ts +16 -0
- package/dist/esm/swappers/DebridgeSwapper/utils/fetchDebridgeSingleChainTrade.js +19 -0
- package/dist/esm/swappers/DebridgeSwapper/utils/fetchDebridgeTrade.d.ts +20 -0
- package/dist/esm/swappers/DebridgeSwapper/utils/fetchDebridgeTrade.js +25 -0
- package/dist/esm/swappers/DebridgeSwapper/utils/getTrade.d.ts +11 -0
- package/dist/esm/swappers/DebridgeSwapper/utils/getTrade.js +362 -0
- package/dist/esm/swappers/DebridgeSwapper/utils/types.d.ts +155 -0
- package/dist/esm/swappers/DebridgeSwapper/utils/types.js +5 -0
- package/dist/esm/swappers/JupiterSwapper/swapperApi/getTradeQuote.js +33 -1
- package/dist/esm/swappers/JupiterSwapper/swapperApi/getTradeRate.js +9 -0
- package/dist/esm/swappers/MayachainSwapper/utils/poolAssetHelpers/poolAssetHelpers.js +1 -1
- package/dist/esm/swappers/NearIntentsSwapper/NearIntentsSwapper.js +2 -1
- package/dist/esm/swappers/NearIntentsSwapper/endpoints.js +31 -0
- package/dist/esm/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.js +50 -3
- package/dist/esm/swappers/NearIntentsSwapper/swapperApi/getTradeRate.js +75 -3
- package/dist/esm/swappers/NearIntentsSwapper/types.d.ts +1 -1
- package/dist/esm/swappers/NearIntentsSwapper/types.js +6 -0
- package/dist/esm/swappers/NearIntentsSwapper/utils/helpers/helpers.js +23 -4
- package/dist/esm/swappers/PortalsSwapper/getPortalsTradeQuote/getPortalsTradeQuote.js +10 -0
- package/dist/esm/swappers/PortalsSwapper/getPortalsTradeRate/getPortalsTradeRate.js +8 -3
- package/dist/esm/swappers/RelaySwapper/constant.js +29 -3
- package/dist/esm/swappers/RelaySwapper/utils/getRelayDefaultUserAddress.d.ts +1 -1
- package/dist/esm/swappers/RelaySwapper/utils/getTrade.js +60 -10
- package/dist/esm/swappers/RelaySwapper/utils/relayTokenToAssetId.js +110 -0
- package/dist/esm/swappers/RelaySwapper/utils/types.d.ts +15 -0
- package/dist/esm/swappers/StonfiSwapper/StonfiSwapper.d.ts +2 -0
- package/dist/esm/swappers/StonfiSwapper/StonfiSwapper.js +5 -0
- package/dist/esm/swappers/StonfiSwapper/endpoints.d.ts +2 -0
- package/dist/esm/swappers/StonfiSwapper/endpoints.js +224 -0
- package/dist/esm/swappers/StonfiSwapper/index.d.ts +4 -0
- package/dist/esm/swappers/StonfiSwapper/index.js +4 -0
- package/dist/esm/swappers/StonfiSwapper/swapperApi/getTradeQuote.d.ts +2 -0
- package/dist/esm/swappers/StonfiSwapper/swapperApi/getTradeQuote.js +125 -0
- package/dist/esm/swappers/StonfiSwapper/swapperApi/getTradeRate.d.ts +2 -0
- package/dist/esm/swappers/StonfiSwapper/swapperApi/getTradeRate.js +111 -0
- package/dist/esm/swappers/StonfiSwapper/types.d.ts +60 -0
- package/dist/esm/swappers/StonfiSwapper/types.js +2 -0
- package/dist/esm/swappers/StonfiSwapper/utils/constants.d.ts +5 -0
- package/dist/esm/swappers/StonfiSwapper/utils/constants.js +5 -0
- package/dist/esm/swappers/StonfiSwapper/utils/helpers.d.ts +11 -0
- package/dist/esm/swappers/StonfiSwapper/utils/helpers.js +124 -0
- package/dist/esm/swappers/StonfiSwapper/utils/omnistonManager.d.ts +5 -0
- package/dist/esm/swappers/StonfiSwapper/utils/omnistonManager.js +17 -0
- package/dist/esm/swappers/SunioSwapper/endpoints.js +1 -1
- package/dist/esm/swappers/SunioSwapper/utils/getQuoteOrRate.js +15 -4
- package/dist/esm/swappers/ThorchainSwapper/ThorchainSwapper.js +3 -0
- package/dist/esm/swappers/ThorchainSwapper/endpoints.js +3 -1
- package/dist/esm/swappers/ThorchainSwapper/generated/generatedTradableAssetMap.json +1 -0
- package/dist/esm/swappers/ThorchainSwapper/utils/poolAssetHelpers/poolAssetHelpers.d.ts +1 -1
- package/dist/esm/swappers/ThorchainSwapper/utils/poolAssetHelpers/poolAssetHelpers.js +2 -1
- package/dist/esm/swappers/ThorchainSwapper/utils/poolAssetHelpers/poolAssetHelpers.test.js +11 -1
- package/dist/esm/swappers/ZrxSwapper/getZrxTradeQuote/getZrxTradeQuote.js +9 -0
- package/dist/esm/swappers/ZrxSwapper/getZrxTradeRate/getZrxTradeRate.js +9 -0
- package/dist/esm/swappers/ZrxSwapper/utils/helpers/helpers.d.ts +1 -1
- package/dist/esm/swappers/utils/affiliateFee.d.ts +17 -0
- package/dist/esm/swappers/utils/affiliateFee.js +39 -0
- package/dist/esm/swappers/utils/filterBuyAssetsBySellAssetId/filterBuyAssetsBySellAssetId.js +2 -5
- package/dist/esm/swappers/utils/helpers/helpers.js +4 -1
- package/dist/esm/thorchain-utils/getCallDataFromQuote.d.ts +1 -1
- package/dist/esm/thorchain-utils/getL1RateOrQuote.js +88 -10
- package/dist/esm/thorchain-utils/getQuote.js +9 -3
- package/dist/esm/thorchain-utils/index.d.ts +2 -1
- package/dist/esm/thorchain-utils/index.js +1 -0
- package/dist/esm/thorchain-utils/solana/constants.d.ts +1 -0
- package/dist/esm/thorchain-utils/solana/constants.js +3 -0
- package/dist/esm/thorchain-utils/solana/getSolanaTransactionFees.d.ts +2 -0
- package/dist/esm/thorchain-utils/solana/getSolanaTransactionFees.js +37 -0
- package/dist/esm/thorchain-utils/solana/getThorTxData.d.ts +12 -0
- package/dist/esm/thorchain-utils/solana/getThorTxData.js +10 -0
- package/dist/esm/thorchain-utils/solana/getUnsignedSolanaTransaction.d.ts +3 -0
- package/dist/esm/thorchain-utils/solana/getUnsignedSolanaTransaction.js +60 -0
- package/dist/esm/thorchain-utils/solana/index.d.ts +3 -0
- package/dist/esm/thorchain-utils/solana/index.js +3 -0
- package/dist/esm/tron-utils/getUnsignedTronTransaction.js +22 -2
- package/dist/esm/types.d.ts +118 -8
- package/dist/esm/types.js +3 -0
- package/dist/esm/utils.d.ts +4 -3
- package/dist/esm/utils.js +34 -7
- package/package.json +27 -24
|
@@ -3,9 +3,9 @@ import { Err, Ok } from '@sniptt/monads';
|
|
|
3
3
|
import { getAddress } from 'viem';
|
|
4
4
|
import { TradeQuoteError } from '../../../types.js';
|
|
5
5
|
import { makeSwapErrorRight } from '../../../utils.js';
|
|
6
|
-
import { BEBOP_DUMMY_ADDRESS, chainIdToBebopChain } from '../types.js';
|
|
6
|
+
import { BEBOP_DUMMY_ADDRESS, BEBOP_SOLANA_DUMMY_ADDRESS, chainIdToBebopChain } from '../types.js';
|
|
7
7
|
import { bebopServiceFactory } from './bebopService.js';
|
|
8
|
-
import { assetIdToBebopToken } from './helpers/helpers.js';
|
|
8
|
+
import { assetIdToBebopSolanaToken, assetIdToBebopToken } from './helpers/helpers.js';
|
|
9
9
|
export const fetchBebopQuote = async ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal, affiliateBps, apiKey, }) => {
|
|
10
10
|
try {
|
|
11
11
|
const sellToken = assetIdToBebopToken(sellAsset.assetId);
|
|
@@ -86,3 +86,86 @@ export const fetchBebopPrice = ({ buyAsset, sellAsset, sellAmountIncludingProtoc
|
|
|
86
86
|
apiKey,
|
|
87
87
|
});
|
|
88
88
|
};
|
|
89
|
+
export const fetchBebopSolanaQuote = async ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal, affiliateBps, apiKey, }) => {
|
|
90
|
+
try {
|
|
91
|
+
const sellToken = assetIdToBebopSolanaToken(sellAsset.assetId);
|
|
92
|
+
const buyToken = assetIdToBebopSolanaToken(buyAsset.assetId);
|
|
93
|
+
const sellAmountFormatted = bn(sellAmountIncludingProtocolFeesCryptoBaseUnit).toFixed(0);
|
|
94
|
+
const slippagePercentage = bn(slippageTolerancePercentageDecimal ?? 0.003)
|
|
95
|
+
.times(100)
|
|
96
|
+
.toNumber();
|
|
97
|
+
const url = 'https://api.bebop.xyz/pmm/solana/v3/quote';
|
|
98
|
+
const params = new URLSearchParams({
|
|
99
|
+
sell_tokens: sellToken,
|
|
100
|
+
buy_tokens: buyToken,
|
|
101
|
+
sell_amounts: sellAmountFormatted,
|
|
102
|
+
taker_address: takerAddress,
|
|
103
|
+
receiver_address: receiverAddress,
|
|
104
|
+
slippage: slippagePercentage.toString(),
|
|
105
|
+
approval_type: 'Standard',
|
|
106
|
+
skip_validation: 'false',
|
|
107
|
+
gasless: 'true',
|
|
108
|
+
source: 'shapeshift',
|
|
109
|
+
});
|
|
110
|
+
if (affiliateBps && affiliateBps !== '0') {
|
|
111
|
+
params.set('fee', affiliateBps);
|
|
112
|
+
}
|
|
113
|
+
const bebopService = bebopServiceFactory({ apiKey });
|
|
114
|
+
const maybeResponse = await bebopService.get(`${url}?${params}`);
|
|
115
|
+
if (maybeResponse.isErr()) {
|
|
116
|
+
const err = maybeResponse.unwrapErr();
|
|
117
|
+
return Err(makeSwapErrorRight({
|
|
118
|
+
message: 'Failed to fetch quote from Bebop Solana',
|
|
119
|
+
cause: err.cause,
|
|
120
|
+
code: TradeQuoteError.QueryFailed,
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
123
|
+
const response = maybeResponse.unwrap();
|
|
124
|
+
if (response.data.status !== 'QUOTE_SUCCESS') {
|
|
125
|
+
return Err(makeSwapErrorRight({
|
|
126
|
+
message: `Bebop Solana quote not executable: ${response.data.status}`,
|
|
127
|
+
code: TradeQuoteError.InvalidResponse,
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
if (!response.data.solana_tx) {
|
|
131
|
+
return Err(makeSwapErrorRight({
|
|
132
|
+
message: 'Missing solana_tx in response',
|
|
133
|
+
code: TradeQuoteError.InvalidResponse,
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
// Reject routes containing ANY AMM/CLMM makers - these produce malformed txs
|
|
137
|
+
// (wrong signature count in wire format) and require pre-existing ATAs that
|
|
138
|
+
// Bebop's gasless co-signed flow can't create. This includes mixed routes
|
|
139
|
+
// like ["raydium clmm-rfqm", "🦊"] where Bebop serializes the tx with fewer
|
|
140
|
+
// signature slots than the message header requires.
|
|
141
|
+
// When rejected, other swappers like Jupiter will handle these pairs instead.
|
|
142
|
+
const hasAmmRoute = response.data.makers.some(maker => maker.toLowerCase().includes('clmm') || maker.toLowerCase().includes('amm'));
|
|
143
|
+
if (hasAmmRoute) {
|
|
144
|
+
return Err(makeSwapErrorRight({
|
|
145
|
+
message: `Bebop Solana quote contains AMM routing (${response.data.makers.join(', ')}), which produces malformed txs`,
|
|
146
|
+
code: TradeQuoteError.NoRouteFound,
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
return Ok(response.data);
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
return Err(makeSwapErrorRight({
|
|
153
|
+
message: 'Unexpected error fetching Bebop Solana quote',
|
|
154
|
+
cause: error,
|
|
155
|
+
code: TradeQuoteError.QueryFailed,
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
export const fetchBebopSolanaPrice = ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, receiveAddress, affiliateBps, apiKey, }) => {
|
|
160
|
+
const address = receiveAddress || BEBOP_SOLANA_DUMMY_ADDRESS;
|
|
161
|
+
return fetchBebopSolanaQuote({
|
|
162
|
+
buyAsset,
|
|
163
|
+
sellAsset,
|
|
164
|
+
sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
165
|
+
takerAddress: address,
|
|
166
|
+
receiverAddress: address,
|
|
167
|
+
slippageTolerancePercentageDecimal: '0.01',
|
|
168
|
+
affiliateBps,
|
|
169
|
+
apiKey,
|
|
170
|
+
});
|
|
171
|
+
};
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import type { AssetId, ChainId } from '@shapeshiftoss/caip';
|
|
2
2
|
import type { Asset } from '@shapeshiftoss/types';
|
|
3
|
+
export declare const isSolanaChainId: (chainId: ChainId) => boolean;
|
|
3
4
|
export declare const assetIdToBebopToken: (assetId: AssetId) => string;
|
|
4
|
-
export declare const
|
|
5
|
+
export declare const assetIdToBebopSolanaToken: (assetId: AssetId) => string;
|
|
6
|
+
export declare const isSupportedChainId: (chainId: ChainId) => chainId is import("@shapeshiftoss/types").KnownChainIds.EthereumMainnet | import("@shapeshiftoss/types").KnownChainIds.AvalancheMainnet | import("@shapeshiftoss/types").KnownChainIds.OptimismMainnet | import("@shapeshiftoss/types").KnownChainIds.BnbSmartChainMainnet | import("@shapeshiftoss/types").KnownChainIds.PolygonMainnet | import("@shapeshiftoss/types").KnownChainIds.ArbitrumMainnet | import("@shapeshiftoss/types").KnownChainIds.BaseMainnet | import("@shapeshiftoss/types").KnownChainIds.SolanaMainnet;
|
|
5
7
|
export declare const assertValidTrade: ({ buyAsset, sellAsset, }: {
|
|
6
8
|
buyAsset: Asset;
|
|
7
9
|
sellAsset: Asset;
|
|
8
|
-
}) => import("@sniptt/monads/build/result/result").
|
|
10
|
+
}) => import("@sniptt/monads/build/result/result").ResErr<unknown, import("../../../../types.js").SwapErrorRight> | import("@sniptt/monads/build/result/result").ResOk<boolean, never>;
|
|
11
|
+
/**
|
|
12
|
+
* Bebop's /order endpoint has a bug where it hardcodes the taker signature placement
|
|
13
|
+
* at the last signer index. When the taker's pubkey bytes sort before the maker's,
|
|
14
|
+
* the taker ends up at an earlier index, and Bebop places the sig in the wrong slot.
|
|
15
|
+
* This causes ghost txs (order returns "Success" but tx silently fails on-chain).
|
|
16
|
+
*
|
|
17
|
+
* Returns true if the taker is at the expected index (safe to execute), false otherwise.
|
|
18
|
+
* Returns false on decode failure.
|
|
19
|
+
*/
|
|
20
|
+
export declare const isBebopSolanaTxSafe: (solanaTxBase64: string, takerAddress: string) => boolean;
|
|
9
21
|
export declare const calculateRate: ({ buyAmount, sellAmount, buyAsset, sellAsset, }: {
|
|
10
22
|
buyAmount: string;
|
|
11
23
|
sellAmount: string;
|
|
@@ -1,16 +1,27 @@
|
|
|
1
|
-
import { fromAssetId } from '@shapeshiftoss/caip';
|
|
1
|
+
import { fromAssetId, solanaChainId } from '@shapeshiftoss/caip';
|
|
2
2
|
import { bn, convertPrecision, isToken } from '@shapeshiftoss/utils';
|
|
3
3
|
import { Err, Ok } from '@sniptt/monads';
|
|
4
|
+
import { PublicKey, VersionedTransaction } from '@solana/web3.js';
|
|
4
5
|
import { getAddress } from 'viem';
|
|
5
6
|
import { TradeQuoteError } from '../../../../types.js';
|
|
6
7
|
import { makeSwapErrorRight } from '../../../../utils.js';
|
|
7
8
|
import { BEBOP_NATIVE_MARKER, bebopSupportedChainIds } from '../../types.js';
|
|
9
|
+
export const isSolanaChainId = (chainId) => {
|
|
10
|
+
return chainId === solanaChainId;
|
|
11
|
+
};
|
|
8
12
|
export const assetIdToBebopToken = (assetId) => {
|
|
9
13
|
if (!isToken(assetId))
|
|
10
14
|
return BEBOP_NATIVE_MARKER;
|
|
11
15
|
const { assetReference } = fromAssetId(assetId);
|
|
12
16
|
return getAddress(assetReference);
|
|
13
17
|
};
|
|
18
|
+
export const assetIdToBebopSolanaToken = (assetId) => {
|
|
19
|
+
const { assetReference, chainId } = fromAssetId(assetId);
|
|
20
|
+
if (chainId === solanaChainId && !isToken(assetId)) {
|
|
21
|
+
return 'So11111111111111111111111111111111111111112';
|
|
22
|
+
}
|
|
23
|
+
return assetReference;
|
|
24
|
+
};
|
|
14
25
|
export const isSupportedChainId = (chainId) => {
|
|
15
26
|
return bebopSupportedChainIds.includes(chainId);
|
|
16
27
|
};
|
|
@@ -40,6 +51,38 @@ export const assertValidTrade = ({ buyAsset, sellAsset, }) => {
|
|
|
40
51
|
}
|
|
41
52
|
return Ok(true);
|
|
42
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* Bebop's /order endpoint has a bug where it hardcodes the taker signature placement
|
|
56
|
+
* at the last signer index. When the taker's pubkey bytes sort before the maker's,
|
|
57
|
+
* the taker ends up at an earlier index, and Bebop places the sig in the wrong slot.
|
|
58
|
+
* This causes ghost txs (order returns "Success" but tx silently fails on-chain).
|
|
59
|
+
*
|
|
60
|
+
* Returns true if the taker is at the expected index (safe to execute), false otherwise.
|
|
61
|
+
* Returns false on decode failure.
|
|
62
|
+
*/
|
|
63
|
+
export const isBebopSolanaTxSafe = (solanaTxBase64, takerAddress) => {
|
|
64
|
+
try {
|
|
65
|
+
const tx = VersionedTransaction.deserialize(Buffer.from(solanaTxBase64, 'base64'));
|
|
66
|
+
const numSigners = tx.message.header.numRequiredSignatures;
|
|
67
|
+
if (numSigners < 1) {
|
|
68
|
+
console.warn('[Bebop Solana] Transaction has no required signers. Rejecting as malformed.');
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
const signerKeys = tx.message.staticAccountKeys.slice(0, numSigners);
|
|
72
|
+
const takerPubkey = new PublicKey(takerAddress);
|
|
73
|
+
const takerIndex = signerKeys.findIndex(key => key.equals(takerPubkey));
|
|
74
|
+
const expectedIndex = numSigners - 1; // Bebop hardcodes to last signer slot
|
|
75
|
+
if (takerIndex !== expectedIndex) {
|
|
76
|
+
console.warn(`[Bebop Solana] Taker signer index ${takerIndex}, expected ${expectedIndex}. Rejecting to avoid ghost tx.`);
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
console.error(`[Bebop Solana] Failed to decode tx for signer check: ${e.message}`);
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
43
86
|
export const calculateRate = ({ buyAmount, sellAmount, buyAsset, sellAsset, }) => {
|
|
44
87
|
return convertPrecision({
|
|
45
88
|
value: buyAmount,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { executeEvmTransaction, executeSolanaTransaction } from '../../utils.js';
|
|
1
|
+
import { executeEvmTransaction, executeSolanaTransaction, executeTronTransaction, } from '../../utils.js';
|
|
2
2
|
export const butterSwap = {
|
|
3
3
|
executeEvmTransaction,
|
|
4
4
|
executeSolanaTransaction,
|
|
5
|
+
executeTronTransaction,
|
|
5
6
|
executeUtxoTransaction: (txToSign, { signAndBroadcastTransaction }) => {
|
|
6
7
|
return signAndBroadcastTransaction(txToSign);
|
|
7
8
|
},
|
|
@@ -2,6 +2,8 @@ import { evm } from '@shapeshiftoss/chain-adapters';
|
|
|
2
2
|
import BigNumber from 'bignumber.js';
|
|
3
3
|
import { getSolanaTransactionFees } from '../../solana-utils/getSolanaTransactionFees.js';
|
|
4
4
|
import { getUnsignedSolanaTransaction } from '../../solana-utils/getUnsignedSolanaTransaction.js';
|
|
5
|
+
import { getTronTransactionFees } from '../../tron-utils/getTronTransactionFees.js';
|
|
6
|
+
import { getUnsignedTronTransaction } from '../../tron-utils/getUnsignedTronTransaction.js';
|
|
5
7
|
import { getExecutableTradeStep, isExecutableTradeQuote } from '../../utils.js';
|
|
6
8
|
import { checkTradeStatus } from './swapperApi/checkTradeStatus.js';
|
|
7
9
|
import { getTradeQuote } from './swapperApi/getTradeQuote.js';
|
|
@@ -64,6 +66,60 @@ export const butterSwapApi = {
|
|
|
64
66
|
gasLimit: BigNumber.max(feeData.gasLimit, gasLimit).toFixed(),
|
|
65
67
|
});
|
|
66
68
|
},
|
|
69
|
+
getUnsignedUtxoTransaction: async ({ stepIndex, tradeQuote, xpub, accountType, assertGetUtxoChainAdapter, }) => {
|
|
70
|
+
if (!isExecutableTradeQuote(tradeQuote))
|
|
71
|
+
throw new Error('Unable to execute a trade rate quote');
|
|
72
|
+
const step = getExecutableTradeStep(tradeQuote, stepIndex);
|
|
73
|
+
const { accountNumber, sellAsset, butterSwapTransactionMetadata } = step;
|
|
74
|
+
if (!butterSwapTransactionMetadata)
|
|
75
|
+
throw new Error('Transaction metadata is required');
|
|
76
|
+
const { to, memo } = butterSwapTransactionMetadata;
|
|
77
|
+
if (!to)
|
|
78
|
+
throw new Error('Missing deposit address');
|
|
79
|
+
if (!memo)
|
|
80
|
+
throw new Error('Missing memo (opReturnData)');
|
|
81
|
+
const adapter = assertGetUtxoChainAdapter(sellAsset.chainId);
|
|
82
|
+
const { fast } = await adapter.getFeeData({
|
|
83
|
+
to,
|
|
84
|
+
value: step.sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
85
|
+
chainSpecific: { pubkey: xpub, opReturnData: memo },
|
|
86
|
+
sendMax: false,
|
|
87
|
+
});
|
|
88
|
+
return adapter.buildSendApiTransaction({
|
|
89
|
+
value: step.sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
90
|
+
xpub,
|
|
91
|
+
to,
|
|
92
|
+
accountNumber,
|
|
93
|
+
chainSpecific: {
|
|
94
|
+
accountType,
|
|
95
|
+
opReturnData: memo,
|
|
96
|
+
satoshiPerByte: fast.chainSpecific.satoshiPerByte,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
getUtxoTransactionFees: async ({ stepIndex, tradeQuote, xpub, assertGetUtxoChainAdapter }) => {
|
|
101
|
+
if (!isExecutableTradeQuote(tradeQuote))
|
|
102
|
+
throw new Error('Unable to execute a trade rate quote');
|
|
103
|
+
const step = getExecutableTradeStep(tradeQuote, stepIndex);
|
|
104
|
+
const { sellAsset, butterSwapTransactionMetadata } = step;
|
|
105
|
+
if (!butterSwapTransactionMetadata)
|
|
106
|
+
throw new Error('Transaction metadata is required');
|
|
107
|
+
const { to, memo } = butterSwapTransactionMetadata;
|
|
108
|
+
if (!to)
|
|
109
|
+
throw new Error('Missing deposit address');
|
|
110
|
+
if (!memo)
|
|
111
|
+
throw new Error('Missing memo (opReturnData)');
|
|
112
|
+
const adapter = assertGetUtxoChainAdapter(sellAsset.chainId);
|
|
113
|
+
const { fast } = await adapter.getFeeData({
|
|
114
|
+
to,
|
|
115
|
+
value: step.sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
116
|
+
chainSpecific: { pubkey: xpub, opReturnData: memo },
|
|
117
|
+
sendMax: false,
|
|
118
|
+
});
|
|
119
|
+
return fast.txFee;
|
|
120
|
+
},
|
|
67
121
|
getUnsignedSolanaTransaction,
|
|
68
122
|
getSolanaTransactionFees,
|
|
123
|
+
getTronTransactionFees,
|
|
124
|
+
getUnsignedTronTransaction,
|
|
69
125
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { solanaChainId } from '@shapeshiftoss/caip';
|
|
1
|
+
import { solanaChainId, tronChainId } from '@shapeshiftoss/caip';
|
|
2
2
|
import { isEvmChainId } from '@shapeshiftoss/chain-adapters';
|
|
3
3
|
import { TxStatus } from '@shapeshiftoss/unchained-client';
|
|
4
4
|
import { checkEvmSwapStatus, checkSolanaSwapStatus, createDefaultStatusResponse, } from '../../../utils.js';
|
|
@@ -33,6 +33,25 @@ export const checkTradeStatus = async (input) => {
|
|
|
33
33
|
fetchIsSmartContractAddressQuery,
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
|
+
if (sellChainId === tronChainId) {
|
|
37
|
+
const adapter = input.assertGetTronChainAdapter(tronChainId);
|
|
38
|
+
const tx = await adapter.httpProvider.getTransaction({ txid: txHash });
|
|
39
|
+
if (!tx) {
|
|
40
|
+
return createDefaultStatusResponse(txHash);
|
|
41
|
+
}
|
|
42
|
+
const contractRet = tx.ret?.[0]?.contractRet;
|
|
43
|
+
// Only mark as confirmed if SUCCESS AND has confirmations (in a block)
|
|
44
|
+
const status = contractRet === 'SUCCESS' && tx.confirmations > 0
|
|
45
|
+
? TxStatus.Confirmed
|
|
46
|
+
: contractRet === 'REVERT'
|
|
47
|
+
? TxStatus.Failed
|
|
48
|
+
: TxStatus.Pending;
|
|
49
|
+
return {
|
|
50
|
+
status,
|
|
51
|
+
buyTxHash: txHash,
|
|
52
|
+
message: undefined,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
36
55
|
// Fallback: unknown same-chain type (should never happen for Butter, but just in case). Avoid bridge polling.
|
|
37
56
|
return createDefaultStatusResponse(txHash);
|
|
38
57
|
}
|
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { btcChainId, solanaChainId, tronChainId } from '@shapeshiftoss/caip';
|
|
2
2
|
import { isEvmChainId } from '@shapeshiftoss/chain-adapters';
|
|
3
|
-
import { bnOrZero, chainIdToFeeAssetId, convertDecimalPercentageToBasisPoints,
|
|
3
|
+
import { BigAmount, bnOrZero, chainIdToFeeAssetId, convertDecimalPercentageToBasisPoints, } from '@shapeshiftoss/utils';
|
|
4
4
|
import { Err, Ok } from '@sniptt/monads';
|
|
5
5
|
import { AddressLookupTableAccount, PublicKey, TransactionMessage, VersionedTransaction, } from '@solana/web3.js';
|
|
6
6
|
import { getDefaultSlippageDecimalPercentageForSwapper } from '../../../constants.js';
|
|
7
7
|
import { SwapperName, TradeQuoteError } from '../../../types.js';
|
|
8
8
|
import { createTradeAmountTooSmallErr, getInputOutputRate, makeSwapErrorRight, } from '../../../utils.js';
|
|
9
|
+
import { buildAffiliateFee } from '../../utils/affiliateFee.js';
|
|
9
10
|
import { makeButterSwapAffiliate } from '../utils/constants.js';
|
|
10
11
|
import { ButterSwapErrorCode, butterSwapErrorToTradeQuoteError, fetchTxData, getButterRoute, isBuildTxSuccess, isRouteSuccess, } from '../xhr.js';
|
|
11
12
|
export const getTradeQuote = async (input, _deps) => {
|
|
12
13
|
const { sellAsset, buyAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, receiveAddress, sendAddress, slippageTolerancePercentageDecimal, accountNumber, affiliateBps, } = input;
|
|
13
14
|
if (!isEvmChainId(sellAsset.chainId) &&
|
|
14
15
|
sellAsset.chainId !== btcChainId &&
|
|
15
|
-
sellAsset.chainId !== solanaChainId
|
|
16
|
+
sellAsset.chainId !== solanaChainId &&
|
|
17
|
+
sellAsset.chainId !== tronChainId) {
|
|
16
18
|
return Err(makeSwapErrorRight({
|
|
17
19
|
message: `Unsupported chain`,
|
|
18
20
|
code: TradeQuoteError.UnsupportedChain,
|
|
19
21
|
}));
|
|
20
22
|
}
|
|
21
|
-
//
|
|
22
|
-
if (sellAsset.assetId === btcAssetId) {
|
|
23
|
-
return Err(makeSwapErrorRight({
|
|
24
|
-
message: `BTC sells are currently unsupported`,
|
|
25
|
-
code: TradeQuoteError.UnsupportedChain,
|
|
26
|
-
}));
|
|
27
|
-
}
|
|
23
|
+
// TODO: Debug why same-chain Tron swaps revert (swapAndCall method works on EVM but 0 successful on Tron)
|
|
28
24
|
if (!sendAddress) {
|
|
29
25
|
return Err(makeSwapErrorRight({
|
|
30
26
|
message: '[getTradeQuote] sendAddress is required for ButterSwap',
|
|
@@ -38,7 +34,10 @@ export const getTradeQuote = async (input, _deps) => {
|
|
|
38
34
|
const routeResult = await getButterRoute({
|
|
39
35
|
sellAsset,
|
|
40
36
|
buyAsset,
|
|
41
|
-
|
|
37
|
+
sellAmountCryptoPrecision: BigAmount.fromBaseUnit({
|
|
38
|
+
value: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
39
|
+
precision: sellAsset.precision,
|
|
40
|
+
}).toPrecision(),
|
|
42
41
|
slippage,
|
|
43
42
|
affiliate: makeButterSwapAffiliate(affiliateBps),
|
|
44
43
|
});
|
|
@@ -47,7 +46,10 @@ export const getTradeQuote = async (input, _deps) => {
|
|
|
47
46
|
const routeResponse = routeResult.unwrap();
|
|
48
47
|
if (!isRouteSuccess(routeResponse)) {
|
|
49
48
|
if (routeResponse.errno === ButterSwapErrorCode.InsufficientAmount) {
|
|
50
|
-
const minAmountCryptoBaseUnit =
|
|
49
|
+
const minAmountCryptoBaseUnit = BigAmount.fromPrecision({
|
|
50
|
+
value: routeResponse.minAmount,
|
|
51
|
+
precision: sellAsset.precision,
|
|
52
|
+
}).toBaseUnit();
|
|
51
53
|
return Err(createTradeAmountTooSmallErr({
|
|
52
54
|
minAmountCryptoBaseUnit,
|
|
53
55
|
assetId: sellAsset.assetId,
|
|
@@ -97,13 +99,19 @@ export const getTradeQuote = async (input, _deps) => {
|
|
|
97
99
|
}));
|
|
98
100
|
}
|
|
99
101
|
// Map gasFee.amount to networkFeeCryptoBaseUnit using fee asset precision
|
|
100
|
-
const networkFeeCryptoBaseUnit =
|
|
102
|
+
const networkFeeCryptoBaseUnit = BigAmount.fromPrecision({
|
|
103
|
+
value: bnOrZero(route.gasFee?.amount),
|
|
104
|
+
precision: feeAsset.precision,
|
|
105
|
+
}).toBaseUnit();
|
|
101
106
|
// Use destination receive amount as a priority if present and defined
|
|
102
107
|
// It won't for same-chain swaps, so we fall back to the source chain receive amount (i.e source chain *is* the destination chain)
|
|
103
108
|
const outputAmount = route.dstChain?.totalAmountOut ?? route.srcChain.totalAmountOut;
|
|
104
109
|
// TODO: affiliate fees not yet here, gut feel is that Butter won't do the swap output - fees logic for us here
|
|
105
110
|
// Sanity check me when affiliates are implemented, and do the math ourselves if needed
|
|
106
|
-
const buyAmountAfterFeesCryptoBaseUnit =
|
|
111
|
+
const buyAmountAfterFeesCryptoBaseUnit = BigAmount.fromPrecision({
|
|
112
|
+
value: outputAmount,
|
|
113
|
+
precision: buyAsset.precision,
|
|
114
|
+
}).toBaseUnit();
|
|
107
115
|
const rate = getInputOutputRate({
|
|
108
116
|
sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
109
117
|
buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
|
|
@@ -115,7 +123,12 @@ export const getTradeQuote = async (input, _deps) => {
|
|
|
115
123
|
if (sellAsset.chainId !== solanaChainId)
|
|
116
124
|
return Ok(undefined);
|
|
117
125
|
const txData = buildTx.data.startsWith('0x') ? buildTx.data.slice(2) : buildTx.data;
|
|
118
|
-
const
|
|
126
|
+
const txBytes = Buffer.from(txData, 'hex');
|
|
127
|
+
// Solana transactions are limited to 1232 bytes. If Butter returns a larger tx,
|
|
128
|
+
// we need to split it into a Jito bundle (2 txs with tip in the last one).
|
|
129
|
+
const SOLANA_TX_SIZE_LIMIT = 1232;
|
|
130
|
+
const isOversized = txBytes.length > SOLANA_TX_SIZE_LIMIT;
|
|
131
|
+
const versionedTransaction = VersionedTransaction.deserialize(new Uint8Array(txBytes));
|
|
119
132
|
const adapter = _deps.assertGetSolanaChainAdapter(sellAsset.chainId);
|
|
120
133
|
try {
|
|
121
134
|
const addressLookupTableAccountKeys = versionedTransaction.message.addressTableLookups.map(lookup => lookup.accountKey.toString());
|
|
@@ -134,6 +147,7 @@ export const getTradeQuote = async (input, _deps) => {
|
|
|
134
147
|
return Ok({
|
|
135
148
|
instructions,
|
|
136
149
|
addressLookupTableAddresses: addressLookupTableAccountKeys,
|
|
150
|
+
isOversized,
|
|
137
151
|
});
|
|
138
152
|
}
|
|
139
153
|
catch (error) {
|
|
@@ -148,7 +162,10 @@ export const getTradeQuote = async (input, _deps) => {
|
|
|
148
162
|
}
|
|
149
163
|
const solanaTransactionMetadata = maybeSolanaTransactionMetadata?.unwrap();
|
|
150
164
|
const step = {
|
|
151
|
-
buyAmountBeforeFeesCryptoBaseUnit:
|
|
165
|
+
buyAmountBeforeFeesCryptoBaseUnit: BigAmount.fromPrecision({
|
|
166
|
+
value: outputAmount,
|
|
167
|
+
precision: buyAsset.precision,
|
|
168
|
+
}).toBaseUnit(),
|
|
152
169
|
buyAmountAfterFeesCryptoBaseUnit,
|
|
153
170
|
sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
154
171
|
feeData: {
|
|
@@ -160,17 +177,29 @@ export const getTradeQuote = async (input, _deps) => {
|
|
|
160
177
|
buyAsset,
|
|
161
178
|
sellAsset,
|
|
162
179
|
accountNumber,
|
|
163
|
-
allowanceContract: route.contract ?? '0x0',
|
|
180
|
+
allowanceContract: sellAsset.chainId === tronChainId ? buildTx.to : route.contract ?? '0x0',
|
|
164
181
|
estimatedExecutionTimeMs: route.timeEstimated * 1000,
|
|
165
182
|
butterSwapTransactionMetadata: {
|
|
166
183
|
to: buildTx.to,
|
|
167
184
|
data: buildTx.data,
|
|
168
185
|
value: buildTx.value,
|
|
169
186
|
gasLimit: bnOrZero(route.gasEstimatedTarget).toFixed(),
|
|
187
|
+
method: buildTx.method,
|
|
188
|
+
args: buildTx.args,
|
|
189
|
+
memo: buildTx.memo,
|
|
170
190
|
},
|
|
171
191
|
...(solanaTransactionMetadata && {
|
|
172
192
|
solanaTransactionMetadata,
|
|
173
193
|
}),
|
|
194
|
+
affiliateFee: buildAffiliateFee({
|
|
195
|
+
strategy: 'buy_asset',
|
|
196
|
+
affiliateBps,
|
|
197
|
+
sellAsset,
|
|
198
|
+
buyAsset,
|
|
199
|
+
sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
200
|
+
buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
|
|
201
|
+
isEstimate: true,
|
|
202
|
+
}),
|
|
174
203
|
};
|
|
175
204
|
const tradeQuote = {
|
|
176
205
|
id: route.hash,
|
|
@@ -34,6 +34,7 @@ describe('getTradeQuote', () => {
|
|
|
34
34
|
assertGetSuiChainAdapter: () => vi.fn(),
|
|
35
35
|
assertGetNearChainAdapter: () => vi.fn(),
|
|
36
36
|
assertGetStarknetChainAdapter: () => vi.fn(),
|
|
37
|
+
assertGetTonChainAdapter: () => vi.fn(),
|
|
37
38
|
config: {
|
|
38
39
|
VITE_BUTTERSWAP_CLIENT_ID: 'test',
|
|
39
40
|
},
|
|
@@ -1,39 +1,35 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { btcChainId, solanaChainId, tronChainId } from '@shapeshiftoss/caip';
|
|
2
2
|
import { isEvmChainId } from '@shapeshiftoss/chain-adapters';
|
|
3
|
-
import {
|
|
3
|
+
import { BigAmount, bnOrZero, chainIdToFeeAssetId, convertDecimalPercentageToBasisPoints, } from '@shapeshiftoss/utils';
|
|
4
4
|
import { Err, Ok } from '@sniptt/monads';
|
|
5
5
|
import { getDefaultSlippageDecimalPercentageForSwapper } from '../../../constants.js';
|
|
6
6
|
import { SwapperName, TradeQuoteError } from '../../../types.js';
|
|
7
7
|
import { createTradeAmountTooSmallErr, getInputOutputRate, makeSwapErrorRight, } from '../../../utils.js';
|
|
8
|
+
import { buildAffiliateFee } from '../../utils/affiliateFee.js';
|
|
8
9
|
import { makeButterSwapAffiliate } from '../utils/constants.js';
|
|
9
10
|
import { ButterSwapErrorCode, butterSwapErrorToTradeQuoteError, getButterRoute, isRouteSuccess, } from '../xhr.js';
|
|
10
11
|
export const getTradeRate = async (input, _deps) => {
|
|
11
12
|
const { sellAsset, buyAsset, affiliateBps, accountNumber, receiveAddress, sellAmountIncludingProtocolFeesCryptoBaseUnit, } = input;
|
|
12
13
|
if (!isEvmChainId(sellAsset.chainId) &&
|
|
13
14
|
sellAsset.chainId !== btcChainId &&
|
|
14
|
-
sellAsset.chainId !== solanaChainId
|
|
15
|
+
sellAsset.chainId !== solanaChainId &&
|
|
16
|
+
sellAsset.chainId !== tronChainId) {
|
|
15
17
|
return Err(makeSwapErrorRight({
|
|
16
18
|
message: `Unsupported chain`,
|
|
17
19
|
code: TradeQuoteError.UnsupportedChain,
|
|
18
20
|
}));
|
|
19
21
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
code: TradeQuoteError.UnsupportedChain,
|
|
25
|
-
}));
|
|
26
|
-
}
|
|
27
|
-
const amount = bn(sellAmountIncludingProtocolFeesCryptoBaseUnit)
|
|
28
|
-
.shiftedBy(-sellAsset.precision)
|
|
29
|
-
.toString();
|
|
22
|
+
const amount = BigAmount.fromBaseUnit({
|
|
23
|
+
value: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
24
|
+
precision: sellAsset.precision,
|
|
25
|
+
}).toPrecision();
|
|
30
26
|
const feeAssetId = chainIdToFeeAssetId(sellAsset.chainId);
|
|
31
27
|
const slippageTolerancePercentageDecimal = getDefaultSlippageDecimalPercentageForSwapper(SwapperName.ButterSwap);
|
|
32
28
|
const slippage = convertDecimalPercentageToBasisPoints(slippageTolerancePercentageDecimal).toString();
|
|
33
29
|
const result = await getButterRoute({
|
|
34
30
|
sellAsset,
|
|
35
31
|
buyAsset,
|
|
36
|
-
|
|
32
|
+
sellAmountCryptoPrecision: amount,
|
|
37
33
|
slippage,
|
|
38
34
|
affiliate: makeButterSwapAffiliate(affiliateBps),
|
|
39
35
|
});
|
|
@@ -43,7 +39,10 @@ export const getTradeRate = async (input, _deps) => {
|
|
|
43
39
|
const routeResponse = result.unwrap();
|
|
44
40
|
if (!isRouteSuccess(routeResponse)) {
|
|
45
41
|
if (routeResponse.errno === ButterSwapErrorCode.InsufficientAmount) {
|
|
46
|
-
const minAmountCryptoBaseUnit =
|
|
42
|
+
const minAmountCryptoBaseUnit = BigAmount.fromPrecision({
|
|
43
|
+
value: routeResponse.minAmount,
|
|
44
|
+
precision: sellAsset.precision,
|
|
45
|
+
}).toBaseUnit();
|
|
47
46
|
return Err(createTradeAmountTooSmallErr({
|
|
48
47
|
minAmountCryptoBaseUnit,
|
|
49
48
|
assetId: sellAsset.assetId,
|
|
@@ -66,7 +65,10 @@ export const getTradeRate = async (input, _deps) => {
|
|
|
66
65
|
const outputAmount = route.dstChain?.totalAmountOut ?? route.srcChain.totalAmountOut;
|
|
67
66
|
// TODO: affiliate fees not yet here, gut feel is that Butter won't do the swap output - fees logic for us here
|
|
68
67
|
// Sanity check me when affiliates are implemented, and do the math ourselves if needed
|
|
69
|
-
const buyAmountAfterFeesCryptoBaseUnit =
|
|
68
|
+
const buyAmountAfterFeesCryptoBaseUnit = BigAmount.fromPrecision({
|
|
69
|
+
value: outputAmount,
|
|
70
|
+
precision: buyAsset.precision,
|
|
71
|
+
}).toBaseUnit();
|
|
70
72
|
const rate = getInputOutputRate({
|
|
71
73
|
sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
72
74
|
buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
|
|
@@ -82,12 +84,18 @@ export const getTradeRate = async (input, _deps) => {
|
|
|
82
84
|
}
|
|
83
85
|
// Map gasFee.amount to networkFeeCryptoBaseUnit using fee asset precision
|
|
84
86
|
const networkFeeCryptoBaseUnit = bnOrZero(route.gasFee?.amount).gt(0)
|
|
85
|
-
?
|
|
87
|
+
? BigAmount.fromPrecision({
|
|
88
|
+
value: route.gasFee.amount,
|
|
89
|
+
precision: feeAsset.precision,
|
|
90
|
+
}).toBaseUnit()
|
|
86
91
|
: '0';
|
|
87
92
|
// Always a single step
|
|
88
93
|
const step = {
|
|
89
94
|
rate,
|
|
90
|
-
buyAmountBeforeFeesCryptoBaseUnit:
|
|
95
|
+
buyAmountBeforeFeesCryptoBaseUnit: BigAmount.fromPrecision({
|
|
96
|
+
value: outputAmount,
|
|
97
|
+
precision: buyAsset.precision,
|
|
98
|
+
}).toBaseUnit(),
|
|
91
99
|
buyAmountAfterFeesCryptoBaseUnit,
|
|
92
100
|
sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
93
101
|
feeData: {
|
|
@@ -100,6 +108,15 @@ export const getTradeRate = async (input, _deps) => {
|
|
|
100
108
|
accountNumber,
|
|
101
109
|
allowanceContract: route.contract ?? '0x0',
|
|
102
110
|
estimatedExecutionTimeMs: route.timeEstimated * 1000,
|
|
111
|
+
affiliateFee: buildAffiliateFee({
|
|
112
|
+
strategy: 'buy_asset',
|
|
113
|
+
affiliateBps,
|
|
114
|
+
sellAsset,
|
|
115
|
+
buyAsset,
|
|
116
|
+
sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
117
|
+
buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
|
|
118
|
+
isEstimate: true,
|
|
119
|
+
}),
|
|
103
120
|
};
|
|
104
121
|
const tradeRate = {
|
|
105
122
|
id: route.hash,
|
|
@@ -25,6 +25,7 @@ describe('getTradeRate', () => {
|
|
|
25
25
|
assertGetSuiChainAdapter: () => vi.fn(),
|
|
26
26
|
assertGetNearChainAdapter: () => vi.fn(),
|
|
27
27
|
assertGetStarknetChainAdapter: () => vi.fn(),
|
|
28
|
+
assertGetTonChainAdapter: () => vi.fn(),
|
|
28
29
|
config: {
|
|
29
30
|
VITE_BUTTERSWAP_CLIENT_ID: 'test',
|
|
30
31
|
},
|
|
@@ -61,6 +62,7 @@ describe('getTradeRate', () => {
|
|
|
61
62
|
assertGetSuiChainAdapter: () => vi.fn(),
|
|
62
63
|
assertGetNearChainAdapter: () => vi.fn(),
|
|
63
64
|
assertGetStarknetChainAdapter: () => vi.fn(),
|
|
65
|
+
assertGetTonChainAdapter: () => vi.fn(),
|
|
64
66
|
config: {
|
|
65
67
|
VITE_BUTTERSWAP_CLIENT_ID: 'test',
|
|
66
68
|
},
|
|
@@ -10,6 +10,7 @@ const BUTTERSWAP_CHAIN_ID_TO_CHAIN_ID = {
|
|
|
10
10
|
43114: KnownChainIds.AvalancheMainnet,
|
|
11
11
|
1360108768460801: KnownChainIds.SolanaMainnet,
|
|
12
12
|
1360095883558913: KnownChainIds.BitcoinMainnet,
|
|
13
|
+
728126428: KnownChainIds.TronMainnet,
|
|
13
14
|
};
|
|
14
15
|
const CHAIN_ID_TO_BUTTERSWAP_CHAIN_ID = Object.entries(BUTTERSWAP_CHAIN_ID_TO_CHAIN_ID).reduce((acc, [butterSwapChainId, chainId]) => {
|
|
15
16
|
acc[chainId] = Number(butterSwapChainId);
|
|
@@ -20,11 +20,11 @@ type ButterSwapPromise<T> = Promise<Result<T, SwapErrorRight>>;
|
|
|
20
20
|
export type GetButterRouteArgs = {
|
|
21
21
|
sellAsset: Asset;
|
|
22
22
|
buyAsset: Asset;
|
|
23
|
-
|
|
23
|
+
sellAmountCryptoPrecision: string;
|
|
24
24
|
slippage: string;
|
|
25
25
|
affiliate?: string;
|
|
26
26
|
};
|
|
27
|
-
export declare const getButterRoute: ({ sellAsset, buyAsset,
|
|
27
|
+
export declare const getButterRoute: ({ sellAsset, buyAsset, sellAmountCryptoPrecision, slippage, affiliate, }: GetButterRouteArgs) => ButterSwapPromise<RouteResponse>;
|
|
28
28
|
export type ButterBuildTxArgs = {
|
|
29
29
|
hash: string;
|
|
30
30
|
slippage: string;
|