@shapeshiftoss/swapper 17.6.10 → 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 +29 -18
- 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/constant.js +2 -0
- package/dist/cjs/swappers/AcrossSwapper/utils/getTrade.js +15 -1
- package/dist/cjs/swappers/AvnuSwapper/swapperApi/getTradeQuote.js +9 -0
- package/dist/cjs/swappers/AvnuSwapper/swapperApi/getTradeRate.js +9 -0
- 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 +13 -1
- package/dist/cjs/swappers/BebopSwapper/utils/helpers/helpers.js +47 -1
- package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeQuote.js +17 -1
- package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeRate.js +10 -0
- package/dist/cjs/swappers/CetusSwapper/swapperApi/getTradeQuote.js +10 -0
- package/dist/cjs/swappers/CetusSwapper/swapperApi/getTradeRate.js +10 -0
- 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 +17 -0
- package/dist/cjs/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.js +10 -0
- package/dist/cjs/swappers/CowSwapper/getCowSwapTradeRate/getCowSwapTradeRate.js +9 -0
- 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/swapperApi/getTradeQuote.js +12 -0
- package/dist/cjs/swappers/NearIntentsSwapper/swapperApi/getTradeRate.js +12 -0
- package/dist/cjs/swappers/PortalsSwapper/getPortalsTradeQuote/getPortalsTradeQuote.js +10 -0
- package/dist/cjs/swappers/RelaySwapper/constant.js +4 -3
- package/dist/cjs/swappers/RelaySwapper/utils/getTrade.js +44 -5
- package/dist/cjs/swappers/RelaySwapper/utils/relayTokenToAssetId.js +17 -7
- package/dist/cjs/swappers/StonfiSwapper/swapperApi/getTradeQuote.js +10 -0
- package/dist/cjs/swappers/StonfiSwapper/swapperApi/getTradeRate.js +10 -0
- package/dist/cjs/swappers/SunioSwapper/utils/getQuoteOrRate.js +10 -0
- 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/utils/affiliateFee.d.ts +17 -0
- package/dist/cjs/swappers/utils/affiliateFee.js +43 -0
- package/dist/cjs/thorchain-utils/getL1RateOrQuote.js +57 -4
- 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/types.d.ts +44 -5
- package/dist/cjs/types.js +1 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/constants.js +11 -0
- 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/constant.js +4 -2
- package/dist/esm/swappers/AcrossSwapper/utils/getTrade.js +15 -1
- package/dist/esm/swappers/AvnuSwapper/swapperApi/getTradeQuote.js +9 -0
- package/dist/esm/swappers/AvnuSwapper/swapperApi/getTradeRate.js +9 -0
- 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 +13 -1
- package/dist/esm/swappers/BebopSwapper/utils/helpers/helpers.js +44 -1
- package/dist/esm/swappers/ButterSwap/swapperApi/getTradeQuote.js +17 -1
- package/dist/esm/swappers/ButterSwap/swapperApi/getTradeRate.js +10 -0
- package/dist/esm/swappers/CetusSwapper/swapperApi/getTradeQuote.js +10 -0
- package/dist/esm/swappers/CetusSwapper/swapperApi/getTradeRate.js +10 -0
- 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 +17 -0
- package/dist/esm/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.js +10 -0
- package/dist/esm/swappers/CowSwapper/getCowSwapTradeRate/getCowSwapTradeRate.js +9 -0
- 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/swapperApi/getTradeQuote.js +14 -2
- package/dist/esm/swappers/NearIntentsSwapper/swapperApi/getTradeRate.js +14 -2
- package/dist/esm/swappers/PortalsSwapper/getPortalsTradeQuote/getPortalsTradeQuote.js +10 -0
- package/dist/esm/swappers/RelaySwapper/constant.js +6 -5
- package/dist/esm/swappers/RelaySwapper/utils/getTrade.js +47 -8
- package/dist/esm/swappers/RelaySwapper/utils/relayTokenToAssetId.js +17 -7
- package/dist/esm/swappers/StonfiSwapper/swapperApi/getTradeQuote.js +10 -0
- package/dist/esm/swappers/StonfiSwapper/swapperApi/getTradeRate.js +10 -0
- package/dist/esm/swappers/SunioSwapper/utils/getQuoteOrRate.js +10 -0
- 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/utils/affiliateFee.d.ts +17 -0
- package/dist/esm/swappers/utils/affiliateFee.js +39 -0
- package/dist/esm/thorchain-utils/getL1RateOrQuote.js +57 -4
- 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/types.d.ts +44 -5
- package/dist/esm/types.js +1 -0
- package/package.json +19 -18
|
@@ -2,7 +2,7 @@ import type { Asset } from '@shapeshiftoss/types';
|
|
|
2
2
|
import type { Result } from '@sniptt/monads';
|
|
3
3
|
import type { Address } from 'viem';
|
|
4
4
|
import type { SwapErrorRight } from '../../../types.js';
|
|
5
|
-
import type { BebopQuoteResponse } from '../types.js';
|
|
5
|
+
import type { BebopQuoteResponse, BebopSolanaQuoteResponse } from '../types.js';
|
|
6
6
|
export declare const fetchBebopQuote: ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal, affiliateBps, apiKey, }: {
|
|
7
7
|
buyAsset: Asset;
|
|
8
8
|
sellAsset: Asset;
|
|
@@ -21,3 +21,21 @@ export declare const fetchBebopPrice: ({ buyAsset, sellAsset, sellAmountIncludin
|
|
|
21
21
|
affiliateBps?: string | undefined;
|
|
22
22
|
apiKey: string;
|
|
23
23
|
}) => Promise<Result<BebopQuoteResponse, SwapErrorRight>>;
|
|
24
|
+
export declare const fetchBebopSolanaQuote: ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal, affiliateBps, apiKey, }: {
|
|
25
|
+
buyAsset: Asset;
|
|
26
|
+
sellAsset: Asset;
|
|
27
|
+
sellAmountIncludingProtocolFeesCryptoBaseUnit: string;
|
|
28
|
+
takerAddress: string;
|
|
29
|
+
receiverAddress: string;
|
|
30
|
+
slippageTolerancePercentageDecimal: string;
|
|
31
|
+
affiliateBps?: string | undefined;
|
|
32
|
+
apiKey: string;
|
|
33
|
+
}) => Promise<Result<BebopSolanaQuoteResponse, SwapErrorRight>>;
|
|
34
|
+
export declare const fetchBebopSolanaPrice: ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, receiveAddress, affiliateBps, apiKey, }: {
|
|
35
|
+
buyAsset: Asset;
|
|
36
|
+
sellAsset: Asset;
|
|
37
|
+
sellAmountIncludingProtocolFeesCryptoBaseUnit: string;
|
|
38
|
+
receiveAddress: string | undefined;
|
|
39
|
+
affiliateBps?: string | undefined;
|
|
40
|
+
apiKey: string;
|
|
41
|
+
}) => Promise<Result<BebopSolanaQuoteResponse, SwapErrorRight>>;
|
|
@@ -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
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,
|
|
@@ -6,6 +6,7 @@ import { AddressLookupTableAccount, PublicKey, TransactionMessage, VersionedTran
|
|
|
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) => {
|
|
@@ -122,7 +123,12 @@ export const getTradeQuote = async (input, _deps) => {
|
|
|
122
123
|
if (sellAsset.chainId !== solanaChainId)
|
|
123
124
|
return Ok(undefined);
|
|
124
125
|
const txData = buildTx.data.startsWith('0x') ? buildTx.data.slice(2) : buildTx.data;
|
|
125
|
-
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));
|
|
126
132
|
const adapter = _deps.assertGetSolanaChainAdapter(sellAsset.chainId);
|
|
127
133
|
try {
|
|
128
134
|
const addressLookupTableAccountKeys = versionedTransaction.message.addressTableLookups.map(lookup => lookup.accountKey.toString());
|
|
@@ -141,6 +147,7 @@ export const getTradeQuote = async (input, _deps) => {
|
|
|
141
147
|
return Ok({
|
|
142
148
|
instructions,
|
|
143
149
|
addressLookupTableAddresses: addressLookupTableAccountKeys,
|
|
150
|
+
isOversized,
|
|
144
151
|
});
|
|
145
152
|
}
|
|
146
153
|
catch (error) {
|
|
@@ -184,6 +191,15 @@ export const getTradeQuote = async (input, _deps) => {
|
|
|
184
191
|
...(solanaTransactionMetadata && {
|
|
185
192
|
solanaTransactionMetadata,
|
|
186
193
|
}),
|
|
194
|
+
affiliateFee: buildAffiliateFee({
|
|
195
|
+
strategy: 'buy_asset',
|
|
196
|
+
affiliateBps,
|
|
197
|
+
sellAsset,
|
|
198
|
+
buyAsset,
|
|
199
|
+
sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
200
|
+
buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
|
|
201
|
+
isEstimate: true,
|
|
202
|
+
}),
|
|
187
203
|
};
|
|
188
204
|
const tradeQuote = {
|
|
189
205
|
id: route.hash,
|
|
@@ -5,6 +5,7 @@ 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) => {
|
|
@@ -107,6 +108,15 @@ export const getTradeRate = async (input, _deps) => {
|
|
|
107
108
|
accountNumber,
|
|
108
109
|
allowanceContract: route.contract ?? '0x0',
|
|
109
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
|
+
}),
|
|
110
120
|
};
|
|
111
121
|
const tradeRate = {
|
|
112
122
|
id: route.hash,
|
|
@@ -5,6 +5,7 @@ import { v4 as uuid } from 'uuid';
|
|
|
5
5
|
import { getDefaultSlippageDecimalPercentageForSwapper } from '../../../constants.js';
|
|
6
6
|
import { SwapperName, TradeQuoteError } from '../../../types.js';
|
|
7
7
|
import { makeSwapErrorRight } from '../../../utils.js';
|
|
8
|
+
import { buildAffiliateFee } from '../../utils/affiliateFee.js';
|
|
8
9
|
import { getAggregatorClient, getSuiClient } from '../utils/helpers.js';
|
|
9
10
|
import { getCetusTradeData } from './getCetusTradeData.js';
|
|
10
11
|
export const getTradeQuote = async (input, deps) => {
|
|
@@ -78,6 +79,15 @@ export const getTradeQuote = async (input, deps) => {
|
|
|
78
79
|
sellAsset,
|
|
79
80
|
allowanceContract: '0x0',
|
|
80
81
|
estimatedExecutionTimeMs: undefined,
|
|
82
|
+
affiliateFee: buildAffiliateFee({
|
|
83
|
+
strategy: 'buy_asset',
|
|
84
|
+
affiliateBps,
|
|
85
|
+
sellAsset,
|
|
86
|
+
buyAsset,
|
|
87
|
+
sellAmountCryptoBaseUnit: sellAmount,
|
|
88
|
+
buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
|
|
89
|
+
isEstimate: true,
|
|
90
|
+
}),
|
|
81
91
|
},
|
|
82
92
|
],
|
|
83
93
|
};
|
|
@@ -5,6 +5,7 @@ import { v4 as uuid } from 'uuid';
|
|
|
5
5
|
import { getDefaultSlippageDecimalPercentageForSwapper } from '../../../constants.js';
|
|
6
6
|
import { SwapperName, TradeQuoteError } from '../../../types.js';
|
|
7
7
|
import { makeSwapErrorRight } from '../../../utils.js';
|
|
8
|
+
import { buildAffiliateFee } from '../../utils/affiliateFee.js';
|
|
8
9
|
import { getAggregatorClient, getSuiClient } from '../utils/helpers.js';
|
|
9
10
|
import { getCetusTradeData } from './getCetusTradeData.js';
|
|
10
11
|
export const getTradeRate = async (input, deps) => {
|
|
@@ -76,6 +77,15 @@ export const getTradeRate = async (input, deps) => {
|
|
|
76
77
|
sellAsset,
|
|
77
78
|
allowanceContract: '0x0',
|
|
78
79
|
estimatedExecutionTimeMs: undefined,
|
|
80
|
+
affiliateFee: buildAffiliateFee({
|
|
81
|
+
strategy: 'buy_asset',
|
|
82
|
+
affiliateBps,
|
|
83
|
+
sellAsset,
|
|
84
|
+
buyAsset,
|
|
85
|
+
sellAmountCryptoBaseUnit: sellAmount,
|
|
86
|
+
buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
|
|
87
|
+
isEstimate: true,
|
|
88
|
+
}),
|
|
79
89
|
},
|
|
80
90
|
],
|
|
81
91
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RouterDataV3 } from '@cetusprotocol/aggregator-sdk';
|
|
2
2
|
import { AggregatorClient } from '@cetusprotocol/aggregator-sdk';
|
|
3
|
-
import { SuiClient } from '@
|
|
3
|
+
import { SuiClient } from '@mysten/sui/client';
|
|
4
4
|
import type { Asset } from '@shapeshiftoss/types';
|
|
5
5
|
export declare const getAggregatorClient: (rpcUrl: string) => AggregatorClient;
|
|
6
6
|
export declare const getSuiClient: (rpcUrl: string) => SuiClient;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AggregatorClient, Env } from '@cetusprotocol/aggregator-sdk';
|
|
2
|
-
import { SuiClient } from '@
|
|
2
|
+
import { SuiClient } from '@mysten/sui/client';
|
|
3
3
|
import { fromAssetId } from '@shapeshiftoss/caip';
|
|
4
4
|
let suiClientInstance;
|
|
5
5
|
let aggregatorClientInstance;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { arbitrumAssetId, btcAssetId, ethAssetId, flipAssetId, solAssetId, usdcAssetId, usdcOnArbitrumOneAssetId, usdcOnSolanaAssetId, usdtAssetId, } from '@shapeshiftoss/caip';
|
|
1
|
+
import { arbitrumAssetId, btcAssetId, ethAssetId, flipAssetId, solAssetId, usdcAssetId, usdcOnArbitrumOneAssetId, usdcOnSolanaAssetId, usdtAssetId, usdtOnArbitrumOneAssetId, usdtOnSolanaAssetId, wbtcAssetId, } from '@shapeshiftoss/caip';
|
|
2
2
|
import { KnownChainIds } from '@shapeshiftoss/types';
|
|
3
3
|
import { SwapperName } from '../../types.js';
|
|
4
4
|
import { ChainflipNetwork } from './types.js';
|
|
@@ -11,10 +11,14 @@ export const ChainflipSupportedChainIds = [
|
|
|
11
11
|
KnownChainIds.SolanaMainnet,
|
|
12
12
|
];
|
|
13
13
|
export const ChainflipSupportedAssetIdsByChainId = {
|
|
14
|
-
[KnownChainIds.EthereumMainnet]: [ethAssetId, flipAssetId, usdcAssetId, usdtAssetId],
|
|
15
|
-
[KnownChainIds.ArbitrumMainnet]: [
|
|
14
|
+
[KnownChainIds.EthereumMainnet]: [ethAssetId, flipAssetId, usdcAssetId, usdtAssetId, wbtcAssetId],
|
|
15
|
+
[KnownChainIds.ArbitrumMainnet]: [
|
|
16
|
+
arbitrumAssetId,
|
|
17
|
+
usdcOnArbitrumOneAssetId,
|
|
18
|
+
usdtOnArbitrumOneAssetId,
|
|
19
|
+
],
|
|
16
20
|
[KnownChainIds.BitcoinMainnet]: [btcAssetId],
|
|
17
|
-
[KnownChainIds.SolanaMainnet]: [solAssetId, usdcOnSolanaAssetId],
|
|
21
|
+
[KnownChainIds.SolanaMainnet]: [solAssetId, usdcOnSolanaAssetId, usdtOnSolanaAssetId],
|
|
18
22
|
};
|
|
19
23
|
export const chainIdToChainflipNetwork = {
|
|
20
24
|
[KnownChainIds.EthereumMainnet]: ChainflipNetwork.Ethereum,
|
|
@@ -5,6 +5,7 @@ import { v4 as uuid } from 'uuid';
|
|
|
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 { CHAINFLIP_BOOST_SWAP_SOURCE, CHAINFLIP_DCA_BOOST_SWAP_SOURCE, CHAINFLIP_DCA_QUOTE, CHAINFLIP_DCA_SWAP_SOURCE, CHAINFLIP_REGULAR_QUOTE, CHAINFLIP_SWAP_SOURCE, usdcAsset, } from '../constants.js';
|
|
9
10
|
import { chainflipService } from './chainflipService.js';
|
|
10
11
|
import { getEvmTxFees } from './getEvmTxFees.js';
|
|
@@ -239,6 +240,14 @@ export const getQuoteOrRate = async (input, deps) => {
|
|
|
239
240
|
: undefined,
|
|
240
241
|
chainflipMaxBoostFee: getMaxBoostFee(),
|
|
241
242
|
},
|
|
243
|
+
affiliateFee: buildAffiliateFee({
|
|
244
|
+
strategy: 'buy_asset',
|
|
245
|
+
affiliateBps: commissionBps,
|
|
246
|
+
sellAsset,
|
|
247
|
+
buyAsset,
|
|
248
|
+
sellAmountCryptoBaseUnit: singleQuoteResponse.boostQuote.ingressAmountNative,
|
|
249
|
+
buyAmountCryptoBaseUnit: singleQuoteResponse.boostQuote.egressAmountNative,
|
|
250
|
+
}),
|
|
242
251
|
},
|
|
243
252
|
],
|
|
244
253
|
};
|
|
@@ -290,6 +299,14 @@ export const getQuoteOrRate = async (input, deps) => {
|
|
|
290
299
|
: undefined,
|
|
291
300
|
chainflipMaxBoostFee: 0,
|
|
292
301
|
},
|
|
302
|
+
affiliateFee: buildAffiliateFee({
|
|
303
|
+
strategy: 'buy_asset',
|
|
304
|
+
affiliateBps: commissionBps,
|
|
305
|
+
sellAsset,
|
|
306
|
+
buyAsset,
|
|
307
|
+
sellAmountCryptoBaseUnit: singleQuoteResponse.ingressAmountNative ?? '0',
|
|
308
|
+
buyAmountCryptoBaseUnit: singleQuoteResponse.egressAmountNative ?? '0',
|
|
309
|
+
}),
|
|
293
310
|
},
|
|
294
311
|
],
|
|
295
312
|
};
|
|
@@ -8,6 +8,7 @@ import { getAffiliateAppDataFragmentByChainId, getCowNetwork, getFullAppData, }
|
|
|
8
8
|
import { COW_SWAP_NATIVE_ASSET_MARKER_ADDRESS, COW_SWAP_VAULT_RELAYER_ADDRESS, SUPPORTED_CHAIN_IDS, } from '../../../cowswap-utils/constants.js';
|
|
9
9
|
import { SwapperName, TradeQuoteError } from '../../../types.js';
|
|
10
10
|
import { createTradeAmountTooSmallErr, getInputOutputRate, makeSwapErrorRight, } from '../../../utils.js';
|
|
11
|
+
import { buildAffiliateFee } from '../../utils/affiliateFee.js';
|
|
11
12
|
import { isNativeEvmAsset } from '../../utils/helpers/helpers.js';
|
|
12
13
|
import { cowService } from '../utils/cowService.js';
|
|
13
14
|
import { assertValidTrade, getNowPlusThirtyMinutesTimestamp, getValuesFromQuoteResponse, } from '../utils/helpers/helpers.js';
|
|
@@ -113,6 +114,15 @@ export async function getCowSwapTradeQuote(input, config) {
|
|
|
113
114
|
buyAmountBeforeFeesCryptoBaseUnit,
|
|
114
115
|
buyAmountAfterFeesCryptoBaseUnit,
|
|
115
116
|
source: SwapperName.CowSwap,
|
|
117
|
+
affiliateFee: buildAffiliateFee({
|
|
118
|
+
strategy: 'buy_asset',
|
|
119
|
+
affiliateBps,
|
|
120
|
+
sellAsset,
|
|
121
|
+
buyAsset,
|
|
122
|
+
sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
123
|
+
buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
|
|
124
|
+
isEstimate: true,
|
|
125
|
+
}),
|
|
116
126
|
buyAsset,
|
|
117
127
|
sellAsset,
|
|
118
128
|
accountNumber,
|
|
@@ -8,6 +8,7 @@ import { getAffiliateAppDataFragmentByChainId, getCowNetwork, getFullAppData, }
|
|
|
8
8
|
import { COW_SWAP_NATIVE_ASSET_MARKER_ADDRESS, COW_SWAP_VAULT_RELAYER_ADDRESS, SUPPORTED_CHAIN_IDS, } from '../../../cowswap-utils/constants.js';
|
|
9
9
|
import { SwapperName, TradeQuoteError } from '../../../types.js';
|
|
10
10
|
import { createTradeAmountTooSmallErr, getInputOutputRate, makeSwapErrorRight, } from '../../../utils.js';
|
|
11
|
+
import { buildAffiliateFee } from '../../utils/affiliateFee.js';
|
|
11
12
|
import { isNativeEvmAsset } from '../../utils/helpers/helpers.js';
|
|
12
13
|
import { cowService } from '../utils/cowService.js';
|
|
13
14
|
import { assertValidTrade, getNowPlusThirtyMinutesTimestamp, getValuesFromQuoteResponse, } from '../utils/helpers/helpers.js';
|
|
@@ -113,6 +114,14 @@ export async function getCowSwapTradeRate(input, config) {
|
|
|
113
114
|
buyAmountBeforeFeesCryptoBaseUnit,
|
|
114
115
|
buyAmountAfterFeesCryptoBaseUnit,
|
|
115
116
|
source: SwapperName.CowSwap,
|
|
117
|
+
affiliateFee: buildAffiliateFee({
|
|
118
|
+
strategy: 'buy_asset',
|
|
119
|
+
affiliateBps,
|
|
120
|
+
sellAsset,
|
|
121
|
+
buyAsset,
|
|
122
|
+
sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
123
|
+
buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
|
|
124
|
+
}),
|
|
116
125
|
buyAsset,
|
|
117
126
|
sellAsset,
|
|
118
127
|
accountNumber,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const chainIdToDebridgeChainId: Record<string, number>;
|
|
2
|
+
export declare const debridgeChainIdToChainId: import("lodash").Dictionary<string>;
|
|
3
|
+
export declare const DEBRIDGE_SUPPORTED_CHAIN_IDS: string[];
|
|
4
|
+
export declare const DEFAULT_DEBRIDGE_TOKEN_ADDRESS: "0x0000000000000000000000000000000000000000";
|
|
5
|
+
export declare const DEFAULT_DEBRIDGE_USER_ADDRESS = "0x000000000000000000000000000000000000dead";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { arbitrumChainId, avalancheChainId, baseChainId, berachainChainId, bobChainId, bscChainId, cronosChainId, ethChainId, flowEvmChainId, gnosisChainId, hyperEvmChainId, lineaChainId, mantleChainId, megaethChainId, monadChainId, optimismChainId, plasmaChainId, polygonChainId, seiChainId, sonicChainId, storyChainId, } from '@shapeshiftoss/caip';
|
|
2
|
+
import invert from 'lodash/invert';
|
|
3
|
+
import { zeroAddress } from 'viem';
|
|
4
|
+
export const chainIdToDebridgeChainId = {
|
|
5
|
+
[ethChainId]: 1,
|
|
6
|
+
[optimismChainId]: 10,
|
|
7
|
+
[bscChainId]: 56,
|
|
8
|
+
[gnosisChainId]: 100000002,
|
|
9
|
+
[polygonChainId]: 137,
|
|
10
|
+
[monadChainId]: 100000030,
|
|
11
|
+
[hyperEvmChainId]: 100000022,
|
|
12
|
+
[seiChainId]: 100000027,
|
|
13
|
+
[baseChainId]: 8453,
|
|
14
|
+
[plasmaChainId]: 100000028,
|
|
15
|
+
[arbitrumChainId]: 42161,
|
|
16
|
+
[avalancheChainId]: 43114,
|
|
17
|
+
[mantleChainId]: 100000023,
|
|
18
|
+
[cronosChainId]: 100000019,
|
|
19
|
+
[berachainChainId]: 100000020,
|
|
20
|
+
[lineaChainId]: 59144,
|
|
21
|
+
[bobChainId]: 100000021,
|
|
22
|
+
[sonicChainId]: 100000014,
|
|
23
|
+
[storyChainId]: 100000013,
|
|
24
|
+
[flowEvmChainId]: 100000009,
|
|
25
|
+
[megaethChainId]: 100000031,
|
|
26
|
+
};
|
|
27
|
+
export const debridgeChainIdToChainId = invert(chainIdToDebridgeChainId);
|
|
28
|
+
export const DEBRIDGE_SUPPORTED_CHAIN_IDS = Object.keys(chainIdToDebridgeChainId);
|
|
29
|
+
export const DEFAULT_DEBRIDGE_TOKEN_ADDRESS = zeroAddress;
|
|
30
|
+
export const DEFAULT_DEBRIDGE_USER_ADDRESS = '0x000000000000000000000000000000000000dead';
|