@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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { KnownChainIds } from '@shapeshiftoss/types';
|
|
2
2
|
import type { Address, Hex } from 'viem';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const bebopSupportedEvmChainIds: readonly [KnownChainIds.EthereumMainnet, KnownChainIds.PolygonMainnet, KnownChainIds.ArbitrumMainnet, KnownChainIds.BaseMainnet, KnownChainIds.AvalancheMainnet, KnownChainIds.OptimismMainnet, KnownChainIds.BnbSmartChainMainnet];
|
|
4
|
+
export declare const bebopSupportedChainIds: readonly [KnownChainIds.EthereumMainnet, KnownChainIds.PolygonMainnet, KnownChainIds.ArbitrumMainnet, KnownChainIds.BaseMainnet, KnownChainIds.AvalancheMainnet, KnownChainIds.OptimismMainnet, KnownChainIds.BnbSmartChainMainnet, KnownChainIds.SolanaMainnet];
|
|
4
5
|
export type BebopSupportedChainId = (typeof bebopSupportedChainIds)[number];
|
|
5
6
|
export type BebopQuoteRoute = {
|
|
6
7
|
type: string;
|
|
@@ -87,3 +88,50 @@ export type BebopQuoteResponse = {
|
|
|
87
88
|
export declare const chainIdToBebopChain: Record<BebopSupportedChainId, string>;
|
|
88
89
|
export declare const BEBOP_NATIVE_MARKER = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
89
90
|
export declare const BEBOP_DUMMY_ADDRESS: `0x${string}`;
|
|
91
|
+
export declare const BEBOP_SOLANA_DUMMY_ADDRESS = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
92
|
+
export type BebopSolanaQuoteResponse = {
|
|
93
|
+
requestId: string;
|
|
94
|
+
type: string;
|
|
95
|
+
status: 'QUOTE_SUCCESS' | 'QUOTE_INDIC_ROUTE';
|
|
96
|
+
quoteId: string;
|
|
97
|
+
chainId: number;
|
|
98
|
+
approvalType: string;
|
|
99
|
+
nativeToken: string;
|
|
100
|
+
taker: string;
|
|
101
|
+
receiver: string;
|
|
102
|
+
expiry: number;
|
|
103
|
+
slippage: number;
|
|
104
|
+
gasFee: {
|
|
105
|
+
native: string;
|
|
106
|
+
usd: number;
|
|
107
|
+
};
|
|
108
|
+
buyTokens: Record<string, {
|
|
109
|
+
amount: string;
|
|
110
|
+
decimals: number;
|
|
111
|
+
priceUsd: number;
|
|
112
|
+
symbol: string;
|
|
113
|
+
minimumAmount: string;
|
|
114
|
+
price: number;
|
|
115
|
+
priceBeforeFee: number;
|
|
116
|
+
amountBeforeFee: string;
|
|
117
|
+
deltaFromExpected: number;
|
|
118
|
+
}>;
|
|
119
|
+
sellTokens: Record<string, {
|
|
120
|
+
amount: string;
|
|
121
|
+
decimals: number;
|
|
122
|
+
priceUsd: number;
|
|
123
|
+
symbol: string;
|
|
124
|
+
price: number;
|
|
125
|
+
priceBeforeFee: number;
|
|
126
|
+
}>;
|
|
127
|
+
settlementAddress: string;
|
|
128
|
+
approvalTarget: string;
|
|
129
|
+
requiredSignatures: string[];
|
|
130
|
+
priceImpact: number;
|
|
131
|
+
warnings: string[];
|
|
132
|
+
solana_tx: string;
|
|
133
|
+
blockhash: string;
|
|
134
|
+
makers: string[];
|
|
135
|
+
partnerFee?: Record<string, string>;
|
|
136
|
+
protocolFee?: Record<string, string>;
|
|
137
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BEBOP_DUMMY_ADDRESS = exports.BEBOP_NATIVE_MARKER = exports.chainIdToBebopChain = exports.bebopSupportedChainIds = void 0;
|
|
3
|
+
exports.BEBOP_SOLANA_DUMMY_ADDRESS = exports.BEBOP_DUMMY_ADDRESS = exports.BEBOP_NATIVE_MARKER = exports.chainIdToBebopChain = exports.bebopSupportedChainIds = exports.bebopSupportedEvmChainIds = void 0;
|
|
4
4
|
const types_1 = require("@shapeshiftoss/types");
|
|
5
|
-
exports.
|
|
5
|
+
exports.bebopSupportedEvmChainIds = [
|
|
6
6
|
types_1.KnownChainIds.EthereumMainnet,
|
|
7
7
|
types_1.KnownChainIds.PolygonMainnet,
|
|
8
8
|
types_1.KnownChainIds.ArbitrumMainnet,
|
|
@@ -11,6 +11,10 @@ exports.bebopSupportedChainIds = [
|
|
|
11
11
|
types_1.KnownChainIds.OptimismMainnet,
|
|
12
12
|
types_1.KnownChainIds.BnbSmartChainMainnet,
|
|
13
13
|
];
|
|
14
|
+
exports.bebopSupportedChainIds = [
|
|
15
|
+
...exports.bebopSupportedEvmChainIds,
|
|
16
|
+
types_1.KnownChainIds.SolanaMainnet,
|
|
17
|
+
];
|
|
14
18
|
exports.chainIdToBebopChain = {
|
|
15
19
|
[types_1.KnownChainIds.EthereumMainnet]: 'ethereum',
|
|
16
20
|
[types_1.KnownChainIds.PolygonMainnet]: 'polygon',
|
|
@@ -19,9 +23,12 @@ exports.chainIdToBebopChain = {
|
|
|
19
23
|
[types_1.KnownChainIds.AvalancheMainnet]: 'avalanche',
|
|
20
24
|
[types_1.KnownChainIds.OptimismMainnet]: 'optimism',
|
|
21
25
|
[types_1.KnownChainIds.BnbSmartChainMainnet]: 'bsc',
|
|
26
|
+
[types_1.KnownChainIds.SolanaMainnet]: 'solana',
|
|
22
27
|
};
|
|
23
28
|
exports.BEBOP_NATIVE_MARKER = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
|
24
29
|
// Dummy address used for rate quotes when no wallet is connected.
|
|
25
30
|
// This is Vitalik's address, same as what Bebop's own UI uses for price-only quotes.
|
|
26
31
|
// MUST NEVER be used for executable quote transactions.
|
|
27
32
|
exports.BEBOP_DUMMY_ADDRESS = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045';
|
|
33
|
+
// Solana dummy address for rate quotes - uses the Token Program address which cannot be a real wallet
|
|
34
|
+
exports.BEBOP_SOLANA_DUMMY_ADDRESS = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
|
|
@@ -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';
|
|
5
|
-
import type { BebopQuoteResponse } from '../types';
|
|
5
|
+
import type { BebopQuoteResponse, BebopSolanaQuoteResponse } from '../types';
|
|
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>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchBebopPrice = exports.fetchBebopQuote = void 0;
|
|
3
|
+
exports.fetchBebopSolanaPrice = exports.fetchBebopSolanaQuote = exports.fetchBebopPrice = exports.fetchBebopQuote = void 0;
|
|
4
4
|
const utils_1 = require("@shapeshiftoss/utils");
|
|
5
5
|
const monads_1 = require("@sniptt/monads");
|
|
6
6
|
const viem_1 = require("viem");
|
|
@@ -91,3 +91,88 @@ const fetchBebopPrice = ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesC
|
|
|
91
91
|
});
|
|
92
92
|
};
|
|
93
93
|
exports.fetchBebopPrice = fetchBebopPrice;
|
|
94
|
+
const fetchBebopSolanaQuote = async ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal, affiliateBps, apiKey, }) => {
|
|
95
|
+
try {
|
|
96
|
+
const sellToken = (0, helpers_1.assetIdToBebopSolanaToken)(sellAsset.assetId);
|
|
97
|
+
const buyToken = (0, helpers_1.assetIdToBebopSolanaToken)(buyAsset.assetId);
|
|
98
|
+
const sellAmountFormatted = (0, utils_1.bn)(sellAmountIncludingProtocolFeesCryptoBaseUnit).toFixed(0);
|
|
99
|
+
const slippagePercentage = (0, utils_1.bn)(slippageTolerancePercentageDecimal ?? 0.003)
|
|
100
|
+
.times(100)
|
|
101
|
+
.toNumber();
|
|
102
|
+
const url = 'https://api.bebop.xyz/pmm/solana/v3/quote';
|
|
103
|
+
const params = new URLSearchParams({
|
|
104
|
+
sell_tokens: sellToken,
|
|
105
|
+
buy_tokens: buyToken,
|
|
106
|
+
sell_amounts: sellAmountFormatted,
|
|
107
|
+
taker_address: takerAddress,
|
|
108
|
+
receiver_address: receiverAddress,
|
|
109
|
+
slippage: slippagePercentage.toString(),
|
|
110
|
+
approval_type: 'Standard',
|
|
111
|
+
skip_validation: 'false',
|
|
112
|
+
gasless: 'true',
|
|
113
|
+
source: 'shapeshift',
|
|
114
|
+
});
|
|
115
|
+
if (affiliateBps && affiliateBps !== '0') {
|
|
116
|
+
params.set('fee', affiliateBps);
|
|
117
|
+
}
|
|
118
|
+
const bebopService = (0, bebopService_1.bebopServiceFactory)({ apiKey });
|
|
119
|
+
const maybeResponse = await bebopService.get(`${url}?${params}`);
|
|
120
|
+
if (maybeResponse.isErr()) {
|
|
121
|
+
const err = maybeResponse.unwrapErr();
|
|
122
|
+
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
123
|
+
message: 'Failed to fetch quote from Bebop Solana',
|
|
124
|
+
cause: err.cause,
|
|
125
|
+
code: types_1.TradeQuoteError.QueryFailed,
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
const response = maybeResponse.unwrap();
|
|
129
|
+
if (response.data.status !== 'QUOTE_SUCCESS') {
|
|
130
|
+
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
131
|
+
message: `Bebop Solana quote not executable: ${response.data.status}`,
|
|
132
|
+
code: types_1.TradeQuoteError.InvalidResponse,
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
if (!response.data.solana_tx) {
|
|
136
|
+
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
137
|
+
message: 'Missing solana_tx in response',
|
|
138
|
+
code: types_1.TradeQuoteError.InvalidResponse,
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
// Reject routes containing ANY AMM/CLMM makers - these produce malformed txs
|
|
142
|
+
// (wrong signature count in wire format) and require pre-existing ATAs that
|
|
143
|
+
// Bebop's gasless co-signed flow can't create. This includes mixed routes
|
|
144
|
+
// like ["raydium clmm-rfqm", "🦊"] where Bebop serializes the tx with fewer
|
|
145
|
+
// signature slots than the message header requires.
|
|
146
|
+
// When rejected, other swappers like Jupiter will handle these pairs instead.
|
|
147
|
+
const hasAmmRoute = response.data.makers.some(maker => maker.toLowerCase().includes('clmm') || maker.toLowerCase().includes('amm'));
|
|
148
|
+
if (hasAmmRoute) {
|
|
149
|
+
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
150
|
+
message: `Bebop Solana quote contains AMM routing (${response.data.makers.join(', ')}), which produces malformed txs`,
|
|
151
|
+
code: types_1.TradeQuoteError.NoRouteFound,
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
return (0, monads_1.Ok)(response.data);
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
158
|
+
message: 'Unexpected error fetching Bebop Solana quote',
|
|
159
|
+
cause: error,
|
|
160
|
+
code: types_1.TradeQuoteError.QueryFailed,
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
exports.fetchBebopSolanaQuote = fetchBebopSolanaQuote;
|
|
165
|
+
const fetchBebopSolanaPrice = ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, receiveAddress, affiliateBps, apiKey, }) => {
|
|
166
|
+
const address = receiveAddress || types_2.BEBOP_SOLANA_DUMMY_ADDRESS;
|
|
167
|
+
return (0, exports.fetchBebopSolanaQuote)({
|
|
168
|
+
buyAsset,
|
|
169
|
+
sellAsset,
|
|
170
|
+
sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
171
|
+
takerAddress: address,
|
|
172
|
+
receiverAddress: address,
|
|
173
|
+
slippageTolerancePercentageDecimal: '0.01',
|
|
174
|
+
affiliateBps,
|
|
175
|
+
apiKey,
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
exports.fetchBebopSolanaPrice = fetchBebopSolanaPrice;
|
|
@@ -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").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,13 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateRate = exports.assertValidTrade = exports.isSupportedChainId = exports.assetIdToBebopToken = void 0;
|
|
3
|
+
exports.calculateRate = exports.isBebopSolanaTxSafe = exports.assertValidTrade = exports.isSupportedChainId = exports.assetIdToBebopSolanaToken = exports.assetIdToBebopToken = exports.isSolanaChainId = void 0;
|
|
4
4
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
5
5
|
const utils_1 = require("@shapeshiftoss/utils");
|
|
6
6
|
const monads_1 = require("@sniptt/monads");
|
|
7
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
7
8
|
const viem_1 = require("viem");
|
|
8
9
|
const types_1 = require("../../../../types");
|
|
9
10
|
const utils_2 = require("../../../../utils");
|
|
10
11
|
const types_2 = require("../../types");
|
|
12
|
+
const isSolanaChainId = (chainId) => {
|
|
13
|
+
return chainId === caip_1.solanaChainId;
|
|
14
|
+
};
|
|
15
|
+
exports.isSolanaChainId = isSolanaChainId;
|
|
11
16
|
const assetIdToBebopToken = (assetId) => {
|
|
12
17
|
if (!(0, utils_1.isToken)(assetId))
|
|
13
18
|
return types_2.BEBOP_NATIVE_MARKER;
|
|
@@ -15,6 +20,14 @@ const assetIdToBebopToken = (assetId) => {
|
|
|
15
20
|
return (0, viem_1.getAddress)(assetReference);
|
|
16
21
|
};
|
|
17
22
|
exports.assetIdToBebopToken = assetIdToBebopToken;
|
|
23
|
+
const assetIdToBebopSolanaToken = (assetId) => {
|
|
24
|
+
const { assetReference, chainId } = (0, caip_1.fromAssetId)(assetId);
|
|
25
|
+
if (chainId === caip_1.solanaChainId && !(0, utils_1.isToken)(assetId)) {
|
|
26
|
+
return 'So11111111111111111111111111111111111111112';
|
|
27
|
+
}
|
|
28
|
+
return assetReference;
|
|
29
|
+
};
|
|
30
|
+
exports.assetIdToBebopSolanaToken = assetIdToBebopSolanaToken;
|
|
18
31
|
const isSupportedChainId = (chainId) => {
|
|
19
32
|
return types_2.bebopSupportedChainIds.includes(chainId);
|
|
20
33
|
};
|
|
@@ -46,6 +59,39 @@ const assertValidTrade = ({ buyAsset, sellAsset, }) => {
|
|
|
46
59
|
return (0, monads_1.Ok)(true);
|
|
47
60
|
};
|
|
48
61
|
exports.assertValidTrade = assertValidTrade;
|
|
62
|
+
/**
|
|
63
|
+
* Bebop's /order endpoint has a bug where it hardcodes the taker signature placement
|
|
64
|
+
* at the last signer index. When the taker's pubkey bytes sort before the maker's,
|
|
65
|
+
* the taker ends up at an earlier index, and Bebop places the sig in the wrong slot.
|
|
66
|
+
* This causes ghost txs (order returns "Success" but tx silently fails on-chain).
|
|
67
|
+
*
|
|
68
|
+
* Returns true if the taker is at the expected index (safe to execute), false otherwise.
|
|
69
|
+
* Returns false on decode failure.
|
|
70
|
+
*/
|
|
71
|
+
const isBebopSolanaTxSafe = (solanaTxBase64, takerAddress) => {
|
|
72
|
+
try {
|
|
73
|
+
const tx = web3_js_1.VersionedTransaction.deserialize(Buffer.from(solanaTxBase64, 'base64'));
|
|
74
|
+
const numSigners = tx.message.header.numRequiredSignatures;
|
|
75
|
+
if (numSigners < 1) {
|
|
76
|
+
console.warn('[Bebop Solana] Transaction has no required signers. Rejecting as malformed.');
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
const signerKeys = tx.message.staticAccountKeys.slice(0, numSigners);
|
|
80
|
+
const takerPubkey = new web3_js_1.PublicKey(takerAddress);
|
|
81
|
+
const takerIndex = signerKeys.findIndex(key => key.equals(takerPubkey));
|
|
82
|
+
const expectedIndex = numSigners - 1; // Bebop hardcodes to last signer slot
|
|
83
|
+
if (takerIndex !== expectedIndex) {
|
|
84
|
+
console.warn(`[Bebop Solana] Taker signer index ${takerIndex}, expected ${expectedIndex}. Rejecting to avoid ghost tx.`);
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
console.error(`[Bebop Solana] Failed to decode tx for signer check: ${e.message}`);
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
exports.isBebopSolanaTxSafe = isBebopSolanaTxSafe;
|
|
49
95
|
const calculateRate = ({ buyAmount, sellAmount, buyAsset, sellAsset, }) => {
|
|
50
96
|
return (0, utils_1.convertPrecision)({
|
|
51
97
|
value: buyAmount,
|
|
@@ -9,6 +9,7 @@ const web3_js_1 = require("@solana/web3.js");
|
|
|
9
9
|
const constants_1 = require("../../../constants");
|
|
10
10
|
const types_1 = require("../../../types");
|
|
11
11
|
const utils_2 = require("../../../utils");
|
|
12
|
+
const affiliateFee_1 = require("../../utils/affiliateFee");
|
|
12
13
|
const constants_2 = require("../utils/constants");
|
|
13
14
|
const xhr_1 = require("../xhr");
|
|
14
15
|
const getTradeQuote = async (input, _deps) => {
|
|
@@ -125,7 +126,12 @@ const getTradeQuote = async (input, _deps) => {
|
|
|
125
126
|
if (sellAsset.chainId !== caip_1.solanaChainId)
|
|
126
127
|
return (0, monads_1.Ok)(undefined);
|
|
127
128
|
const txData = buildTx.data.startsWith('0x') ? buildTx.data.slice(2) : buildTx.data;
|
|
128
|
-
const
|
|
129
|
+
const txBytes = Buffer.from(txData, 'hex');
|
|
130
|
+
// Solana transactions are limited to 1232 bytes. If Butter returns a larger tx,
|
|
131
|
+
// we need to split it into a Jito bundle (2 txs with tip in the last one).
|
|
132
|
+
const SOLANA_TX_SIZE_LIMIT = 1232;
|
|
133
|
+
const isOversized = txBytes.length > SOLANA_TX_SIZE_LIMIT;
|
|
134
|
+
const versionedTransaction = web3_js_1.VersionedTransaction.deserialize(new Uint8Array(txBytes));
|
|
129
135
|
const adapter = _deps.assertGetSolanaChainAdapter(sellAsset.chainId);
|
|
130
136
|
try {
|
|
131
137
|
const addressLookupTableAccountKeys = versionedTransaction.message.addressTableLookups.map(lookup => lookup.accountKey.toString());
|
|
@@ -144,6 +150,7 @@ const getTradeQuote = async (input, _deps) => {
|
|
|
144
150
|
return (0, monads_1.Ok)({
|
|
145
151
|
instructions,
|
|
146
152
|
addressLookupTableAddresses: addressLookupTableAccountKeys,
|
|
153
|
+
isOversized,
|
|
147
154
|
});
|
|
148
155
|
}
|
|
149
156
|
catch (error) {
|
|
@@ -187,6 +194,15 @@ const getTradeQuote = async (input, _deps) => {
|
|
|
187
194
|
...(solanaTransactionMetadata && {
|
|
188
195
|
solanaTransactionMetadata,
|
|
189
196
|
}),
|
|
197
|
+
affiliateFee: (0, affiliateFee_1.buildAffiliateFee)({
|
|
198
|
+
strategy: 'buy_asset',
|
|
199
|
+
affiliateBps,
|
|
200
|
+
sellAsset,
|
|
201
|
+
buyAsset,
|
|
202
|
+
sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
203
|
+
buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
|
|
204
|
+
isEstimate: true,
|
|
205
|
+
}),
|
|
190
206
|
};
|
|
191
207
|
const tradeQuote = {
|
|
192
208
|
id: route.hash,
|
|
@@ -8,6 +8,7 @@ const monads_1 = require("@sniptt/monads");
|
|
|
8
8
|
const constants_1 = require("../../../constants");
|
|
9
9
|
const types_1 = require("../../../types");
|
|
10
10
|
const utils_2 = require("../../../utils");
|
|
11
|
+
const affiliateFee_1 = require("../../utils/affiliateFee");
|
|
11
12
|
const constants_2 = require("../utils/constants");
|
|
12
13
|
const xhr_1 = require("../xhr");
|
|
13
14
|
const getTradeRate = async (input, _deps) => {
|
|
@@ -110,6 +111,15 @@ const getTradeRate = async (input, _deps) => {
|
|
|
110
111
|
accountNumber,
|
|
111
112
|
allowanceContract: route.contract ?? '0x0',
|
|
112
113
|
estimatedExecutionTimeMs: route.timeEstimated * 1000,
|
|
114
|
+
affiliateFee: (0, affiliateFee_1.buildAffiliateFee)({
|
|
115
|
+
strategy: 'buy_asset',
|
|
116
|
+
affiliateBps,
|
|
117
|
+
sellAsset,
|
|
118
|
+
buyAsset,
|
|
119
|
+
sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
120
|
+
buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
|
|
121
|
+
isEstimate: true,
|
|
122
|
+
}),
|
|
113
123
|
};
|
|
114
124
|
const tradeRate = {
|
|
115
125
|
id: route.hash,
|
|
@@ -8,6 +8,7 @@ const uuid_1 = require("uuid");
|
|
|
8
8
|
const constants_1 = require("../../../constants");
|
|
9
9
|
const types_1 = require("../../../types");
|
|
10
10
|
const utils_2 = require("../../../utils");
|
|
11
|
+
const affiliateFee_1 = require("../../utils/affiliateFee");
|
|
11
12
|
const helpers_1 = require("../utils/helpers");
|
|
12
13
|
const getCetusTradeData_1 = require("./getCetusTradeData");
|
|
13
14
|
const getTradeQuote = async (input, deps) => {
|
|
@@ -81,6 +82,15 @@ const getTradeQuote = async (input, deps) => {
|
|
|
81
82
|
sellAsset,
|
|
82
83
|
allowanceContract: '0x0',
|
|
83
84
|
estimatedExecutionTimeMs: undefined,
|
|
85
|
+
affiliateFee: (0, affiliateFee_1.buildAffiliateFee)({
|
|
86
|
+
strategy: 'buy_asset',
|
|
87
|
+
affiliateBps,
|
|
88
|
+
sellAsset,
|
|
89
|
+
buyAsset,
|
|
90
|
+
sellAmountCryptoBaseUnit: sellAmount,
|
|
91
|
+
buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
|
|
92
|
+
isEstimate: true,
|
|
93
|
+
}),
|
|
84
94
|
},
|
|
85
95
|
],
|
|
86
96
|
};
|
|
@@ -8,6 +8,7 @@ const uuid_1 = require("uuid");
|
|
|
8
8
|
const constants_1 = require("../../../constants");
|
|
9
9
|
const types_1 = require("../../../types");
|
|
10
10
|
const utils_2 = require("../../../utils");
|
|
11
|
+
const affiliateFee_1 = require("../../utils/affiliateFee");
|
|
11
12
|
const helpers_1 = require("../utils/helpers");
|
|
12
13
|
const getCetusTradeData_1 = require("./getCetusTradeData");
|
|
13
14
|
const getTradeRate = async (input, deps) => {
|
|
@@ -79,6 +80,15 @@ const getTradeRate = async (input, deps) => {
|
|
|
79
80
|
sellAsset,
|
|
80
81
|
allowanceContract: '0x0',
|
|
81
82
|
estimatedExecutionTimeMs: undefined,
|
|
83
|
+
affiliateFee: (0, affiliateFee_1.buildAffiliateFee)({
|
|
84
|
+
strategy: 'buy_asset',
|
|
85
|
+
affiliateBps,
|
|
86
|
+
sellAsset,
|
|
87
|
+
buyAsset,
|
|
88
|
+
sellAmountCryptoBaseUnit: sellAmount,
|
|
89
|
+
buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
|
|
90
|
+
isEstimate: true,
|
|
91
|
+
}),
|
|
82
92
|
},
|
|
83
93
|
],
|
|
84
94
|
};
|
|
@@ -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;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.findBestRoute = exports.getCoinType = exports.getSuiClient = exports.getAggregatorClient = void 0;
|
|
4
4
|
const aggregator_sdk_1 = require("@cetusprotocol/aggregator-sdk");
|
|
5
|
-
const client_1 = require("@
|
|
5
|
+
const client_1 = require("@mysten/sui/client");
|
|
6
6
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
7
7
|
let suiClientInstance;
|
|
8
8
|
let aggregatorClientInstance;
|
|
@@ -14,10 +14,14 @@ exports.ChainflipSupportedChainIds = [
|
|
|
14
14
|
types_1.KnownChainIds.SolanaMainnet,
|
|
15
15
|
];
|
|
16
16
|
exports.ChainflipSupportedAssetIdsByChainId = {
|
|
17
|
-
[types_1.KnownChainIds.EthereumMainnet]: [caip_1.ethAssetId, caip_1.flipAssetId, caip_1.usdcAssetId, caip_1.usdtAssetId],
|
|
18
|
-
[types_1.KnownChainIds.ArbitrumMainnet]: [
|
|
17
|
+
[types_1.KnownChainIds.EthereumMainnet]: [caip_1.ethAssetId, caip_1.flipAssetId, caip_1.usdcAssetId, caip_1.usdtAssetId, caip_1.wbtcAssetId],
|
|
18
|
+
[types_1.KnownChainIds.ArbitrumMainnet]: [
|
|
19
|
+
caip_1.arbitrumAssetId,
|
|
20
|
+
caip_1.usdcOnArbitrumOneAssetId,
|
|
21
|
+
caip_1.usdtOnArbitrumOneAssetId,
|
|
22
|
+
],
|
|
19
23
|
[types_1.KnownChainIds.BitcoinMainnet]: [caip_1.btcAssetId],
|
|
20
|
-
[types_1.KnownChainIds.SolanaMainnet]: [caip_1.solAssetId, caip_1.usdcOnSolanaAssetId],
|
|
24
|
+
[types_1.KnownChainIds.SolanaMainnet]: [caip_1.solAssetId, caip_1.usdcOnSolanaAssetId, caip_1.usdtOnSolanaAssetId],
|
|
21
25
|
};
|
|
22
26
|
exports.chainIdToChainflipNetwork = {
|
|
23
27
|
[types_1.KnownChainIds.EthereumMainnet]: types_3.ChainflipNetwork.Ethereum,
|
|
@@ -8,6 +8,7 @@ const uuid_1 = require("uuid");
|
|
|
8
8
|
const constants_1 = require("../../../constants");
|
|
9
9
|
const types_1 = require("../../../types");
|
|
10
10
|
const utils_2 = require("../../../utils");
|
|
11
|
+
const affiliateFee_1 = require("../../utils/affiliateFee");
|
|
11
12
|
const constants_2 = require("../constants");
|
|
12
13
|
const chainflipService_1 = require("./chainflipService");
|
|
13
14
|
const getEvmTxFees_1 = require("./getEvmTxFees");
|
|
@@ -242,6 +243,14 @@ const getQuoteOrRate = async (input, deps) => {
|
|
|
242
243
|
: undefined,
|
|
243
244
|
chainflipMaxBoostFee: getMaxBoostFee(),
|
|
244
245
|
},
|
|
246
|
+
affiliateFee: (0, affiliateFee_1.buildAffiliateFee)({
|
|
247
|
+
strategy: 'buy_asset',
|
|
248
|
+
affiliateBps: commissionBps,
|
|
249
|
+
sellAsset,
|
|
250
|
+
buyAsset,
|
|
251
|
+
sellAmountCryptoBaseUnit: singleQuoteResponse.boostQuote.ingressAmountNative,
|
|
252
|
+
buyAmountCryptoBaseUnit: singleQuoteResponse.boostQuote.egressAmountNative,
|
|
253
|
+
}),
|
|
245
254
|
},
|
|
246
255
|
],
|
|
247
256
|
};
|
|
@@ -293,6 +302,14 @@ const getQuoteOrRate = async (input, deps) => {
|
|
|
293
302
|
: undefined,
|
|
294
303
|
chainflipMaxBoostFee: 0,
|
|
295
304
|
},
|
|
305
|
+
affiliateFee: (0, affiliateFee_1.buildAffiliateFee)({
|
|
306
|
+
strategy: 'buy_asset',
|
|
307
|
+
affiliateBps: commissionBps,
|
|
308
|
+
sellAsset,
|
|
309
|
+
buyAsset,
|
|
310
|
+
sellAmountCryptoBaseUnit: singleQuoteResponse.ingressAmountNative ?? '0',
|
|
311
|
+
buyAmountCryptoBaseUnit: singleQuoteResponse.egressAmountNative ?? '0',
|
|
312
|
+
}),
|
|
296
313
|
},
|
|
297
314
|
],
|
|
298
315
|
};
|
|
@@ -11,6 +11,7 @@ const cowswap_utils_1 = require("../../../cowswap-utils");
|
|
|
11
11
|
const constants_2 = require("../../../cowswap-utils/constants");
|
|
12
12
|
const types_2 = require("../../../types");
|
|
13
13
|
const utils_2 = require("../../../utils");
|
|
14
|
+
const affiliateFee_1 = require("../../utils/affiliateFee");
|
|
14
15
|
const helpers_1 = require("../../utils/helpers/helpers");
|
|
15
16
|
const cowService_1 = require("../utils/cowService");
|
|
16
17
|
const helpers_2 = require("../utils/helpers/helpers");
|
|
@@ -116,6 +117,15 @@ async function getCowSwapTradeQuote(input, config) {
|
|
|
116
117
|
buyAmountBeforeFeesCryptoBaseUnit,
|
|
117
118
|
buyAmountAfterFeesCryptoBaseUnit,
|
|
118
119
|
source: types_2.SwapperName.CowSwap,
|
|
120
|
+
affiliateFee: (0, affiliateFee_1.buildAffiliateFee)({
|
|
121
|
+
strategy: 'buy_asset',
|
|
122
|
+
affiliateBps,
|
|
123
|
+
sellAsset,
|
|
124
|
+
buyAsset,
|
|
125
|
+
sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
126
|
+
buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
|
|
127
|
+
isEstimate: true,
|
|
128
|
+
}),
|
|
119
129
|
buyAsset,
|
|
120
130
|
sellAsset,
|
|
121
131
|
accountNumber,
|
|
@@ -11,6 +11,7 @@ const cowswap_utils_1 = require("../../../cowswap-utils");
|
|
|
11
11
|
const constants_2 = require("../../../cowswap-utils/constants");
|
|
12
12
|
const types_2 = require("../../../types");
|
|
13
13
|
const utils_2 = require("../../../utils");
|
|
14
|
+
const affiliateFee_1 = require("../../utils/affiliateFee");
|
|
14
15
|
const helpers_1 = require("../../utils/helpers/helpers");
|
|
15
16
|
const cowService_1 = require("../utils/cowService");
|
|
16
17
|
const helpers_2 = require("../utils/helpers/helpers");
|
|
@@ -116,6 +117,14 @@ async function getCowSwapTradeRate(input, config) {
|
|
|
116
117
|
buyAmountBeforeFeesCryptoBaseUnit,
|
|
117
118
|
buyAmountAfterFeesCryptoBaseUnit,
|
|
118
119
|
source: types_2.SwapperName.CowSwap,
|
|
120
|
+
affiliateFee: (0, affiliateFee_1.buildAffiliateFee)({
|
|
121
|
+
strategy: 'buy_asset',
|
|
122
|
+
affiliateBps,
|
|
123
|
+
sellAsset,
|
|
124
|
+
buyAsset,
|
|
125
|
+
sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
126
|
+
buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
|
|
127
|
+
}),
|
|
119
128
|
buyAsset,
|
|
120
129
|
sellAsset,
|
|
121
130
|
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,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DEFAULT_DEBRIDGE_USER_ADDRESS = exports.DEFAULT_DEBRIDGE_TOKEN_ADDRESS = exports.DEBRIDGE_SUPPORTED_CHAIN_IDS = exports.debridgeChainIdToChainId = exports.chainIdToDebridgeChainId = void 0;
|
|
7
|
+
const caip_1 = require("@shapeshiftoss/caip");
|
|
8
|
+
const invert_1 = __importDefault(require("lodash/invert"));
|
|
9
|
+
const viem_1 = require("viem");
|
|
10
|
+
exports.chainIdToDebridgeChainId = {
|
|
11
|
+
[caip_1.ethChainId]: 1,
|
|
12
|
+
[caip_1.optimismChainId]: 10,
|
|
13
|
+
[caip_1.bscChainId]: 56,
|
|
14
|
+
[caip_1.gnosisChainId]: 100000002,
|
|
15
|
+
[caip_1.polygonChainId]: 137,
|
|
16
|
+
[caip_1.monadChainId]: 100000030,
|
|
17
|
+
[caip_1.hyperEvmChainId]: 100000022,
|
|
18
|
+
[caip_1.seiChainId]: 100000027,
|
|
19
|
+
[caip_1.baseChainId]: 8453,
|
|
20
|
+
[caip_1.plasmaChainId]: 100000028,
|
|
21
|
+
[caip_1.arbitrumChainId]: 42161,
|
|
22
|
+
[caip_1.avalancheChainId]: 43114,
|
|
23
|
+
[caip_1.mantleChainId]: 100000023,
|
|
24
|
+
[caip_1.cronosChainId]: 100000019,
|
|
25
|
+
[caip_1.berachainChainId]: 100000020,
|
|
26
|
+
[caip_1.lineaChainId]: 59144,
|
|
27
|
+
[caip_1.bobChainId]: 100000021,
|
|
28
|
+
[caip_1.sonicChainId]: 100000014,
|
|
29
|
+
[caip_1.storyChainId]: 100000013,
|
|
30
|
+
[caip_1.flowEvmChainId]: 100000009,
|
|
31
|
+
[caip_1.megaethChainId]: 100000031,
|
|
32
|
+
};
|
|
33
|
+
exports.debridgeChainIdToChainId = (0, invert_1.default)(exports.chainIdToDebridgeChainId);
|
|
34
|
+
exports.DEBRIDGE_SUPPORTED_CHAIN_IDS = Object.keys(exports.chainIdToDebridgeChainId);
|
|
35
|
+
exports.DEFAULT_DEBRIDGE_TOKEN_ADDRESS = viem_1.zeroAddress;
|
|
36
|
+
exports.DEFAULT_DEBRIDGE_USER_ADDRESS = '0x000000000000000000000000000000000000dead';
|