@shapeshiftoss/swapper 17.7.2 → 17.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/index.js +7 -17
- package/dist/cjs/swappers/AcrossSwapper/utils/acrossService.d.ts +3 -3
- package/dist/cjs/swappers/AcrossSwapper/utils/getTrade.js +2 -1
- package/dist/cjs/swappers/ArbitrumBridgeSwapper/endpoints.d.ts +3 -3
- package/dist/cjs/swappers/ArbitrumBridgeSwapper/getTradeQuote/getTradeQuote.js +2 -2
- package/dist/cjs/swappers/ArbitrumBridgeSwapper/getTradeRate/getTradeRate.js +2 -1
- package/dist/cjs/swappers/ArbitrumBridgeSwapper/utils/fetchArbitrumBridgeSwap.d.ts +2 -2
- package/dist/cjs/swappers/AvnuSwapper/endpoints.js +2 -2
- package/dist/cjs/swappers/AvnuSwapper/utils/constants.d.ts +1 -1
- package/dist/cjs/swappers/BebopSwapper/getBebopSolanaTradeQuote/getBebopSolanaTradeQuote.js +2 -1
- package/dist/cjs/swappers/BebopSwapper/getBebopSolanaTradeRate/getBebopSolanaTradeRate.js +2 -1
- package/dist/cjs/swappers/BebopSwapper/getBebopTradeQuote/getBebopTradeQuote.js +3 -2
- package/dist/cjs/swappers/BebopSwapper/getBebopTradeRate/getBebopTradeRate.js +3 -2
- package/dist/cjs/swappers/BebopSwapper/types.d.ts +1 -1
- package/dist/cjs/swappers/BebopSwapper/utils/bebopService.d.ts +1 -1
- package/dist/cjs/swappers/BebopSwapper/utils/fetchFromBebop.d.ts +4 -4
- package/dist/cjs/swappers/BebopSwapper/utils/helpers/helpers.d.ts +1 -2
- package/dist/cjs/swappers/ButterSwap/swapperApi/checkTradeStatus.test.js +9 -19
- package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeQuote.js +1 -1
- package/dist/cjs/swappers/ButterSwap/test-data/routeQuote.js +4 -4
- package/dist/cjs/swappers/ButterSwap/utils/butterSwapHistoryService.d.ts +3 -3
- package/dist/cjs/swappers/ButterSwap/utils/butterSwapService.d.ts +3 -3
- package/dist/cjs/swappers/ButterSwap/xhr.js +4 -4
- package/dist/cjs/swappers/CetusSwapper/utils/constants.d.ts +1 -1
- package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasQuoteBoostQuote.js +5 -4
- package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasQuoteEstimatedDurationsSeconds.js +5 -4
- package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasQuoteQuote.js +5 -5
- package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasQuoteQuoteFee.js +5 -5
- package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasStatusChunkInfo.js +5 -4
- package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasStatusDca.js +5 -4
- package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasStatusEgress.js +5 -4
- package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasStatusSwap.js +5 -4
- package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasSwapDepositAddress.js +5 -4
- package/dist/cjs/swappers/ChainflipSwapper/utils/chainflipService.d.ts +3 -3
- package/dist/cjs/swappers/ChainflipSwapper/utils/getQuoteOrRate.js +2 -2
- package/dist/cjs/swappers/ChainflipSwapper/utils/getUtxoTxFees.d.ts +1 -1
- package/dist/cjs/swappers/ChainflipSwapper/utils/helpers.d.ts +2 -3
- package/dist/cjs/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.js +3 -2
- package/dist/cjs/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.test.js +8 -8
- package/dist/cjs/swappers/CowSwapper/getCowSwapTradeRate/getCowSwapTradeRate.js +3 -2
- package/dist/cjs/swappers/CowSwapper/utils/cowService.d.ts +3 -3
- package/dist/cjs/swappers/DebridgeSwapper/utils/debridgeService.d.ts +3 -3
- package/dist/cjs/swappers/DebridgeSwapper/utils/getTrade.js +2 -1
- package/dist/cjs/swappers/NearIntentsSwapper/constants.d.ts +1 -0
- package/dist/cjs/swappers/NearIntentsSwapper/constants.js +2 -1
- package/dist/cjs/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.js +5 -2
- package/dist/cjs/swappers/NearIntentsSwapper/utils/helpers/helpers.d.ts +2 -2
- package/dist/cjs/swappers/NearIntentsSwapper/utils/helpers/helpers.js +5 -1
- package/dist/cjs/swappers/PortalsSwapper/getPortalsTradeQuote/getPortalsTradeQuote.js +2 -1
- package/dist/cjs/swappers/PortalsSwapper/getPortalsTradeRate/getPortalsTradeRate.js +4 -3
- package/dist/cjs/swappers/PortalsSwapper/utils/helpers.d.ts +1 -1
- package/dist/cjs/swappers/RelaySwapper/constant.d.ts +1 -39
- package/dist/cjs/swappers/RelaySwapper/utils/fetchRelayTrade.d.ts +1 -1
- package/dist/cjs/swappers/RelaySwapper/utils/getRelayPsbtRelayer.js +7 -17
- package/dist/cjs/swappers/RelaySwapper/utils/getTrade.js +2 -1
- package/dist/cjs/swappers/RelaySwapper/utils/relayService.d.ts +3 -3
- package/dist/cjs/swappers/SunioSwapper/utils/getQuoteOrRate.js +2 -1
- package/dist/cjs/swappers/SunioSwapper/utils/helpers/helpers.d.ts +1 -2
- package/dist/cjs/swappers/SunioSwapper/utils/sunioService.d.ts +3 -3
- package/dist/cjs/swappers/ThorchainSwapper/getTradeQuote/getTradeQuote.test.js +10 -0
- package/dist/cjs/swappers/ThorchainSwapper/utils/getL1ToLongtailQuote.js +8 -18
- package/dist/cjs/swappers/ThorchainSwapper/utils/getL1ToLongtailRate.js +8 -18
- package/dist/cjs/swappers/ThorchainSwapper/utils/getLongtailQuote.js +1 -1
- package/dist/cjs/swappers/ThorchainSwapper/utils/getLongtailRate.js +1 -1
- package/dist/cjs/swappers/ThorchainSwapper/utils/longTailHelpers.js +2 -2
- package/dist/cjs/swappers/ZrxSwapper/getZrxTradeQuote/getZrxTradeQuote.js +2 -1
- package/dist/cjs/swappers/ZrxSwapper/getZrxTradeQuote/getZrxTradeQuote.test.js +7 -17
- package/dist/cjs/swappers/ZrxSwapper/getZrxTradeRate/getZrxTradeRate.js +2 -1
- package/dist/cjs/swappers/ZrxSwapper/utils/fetchFromZrx.js +2 -2
- package/dist/cjs/swappers/ZrxSwapper/utils/helpers/helpers.d.ts +3 -2
- package/dist/cjs/swappers/ZrxSwapper/utils/zrxService.d.ts +1 -1
- package/dist/cjs/swappers/utils/test-data/cryptoMarketDataById.d.ts +1 -35
- package/dist/cjs/thorchain-utils/checkTradeStatus.js +8 -1
- package/dist/cjs/thorchain-utils/cosmossdk/getThorTxData.d.ts +12 -0
- package/dist/cjs/thorchain-utils/cosmossdk/getThorTxData.js +19 -0
- package/dist/cjs/thorchain-utils/cosmossdk/index.d.ts +1 -0
- package/dist/cjs/thorchain-utils/cosmossdk/index.js +1 -0
- package/dist/cjs/thorchain-utils/getCallDataFromQuote.d.ts +1 -1
- package/dist/cjs/thorchain-utils/getL1RateOrQuote.js +46 -31
- package/dist/cjs/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.d.ts +3 -2
- package/dist/cjs/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.js +21 -14
- package/dist/cjs/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.test.js +11 -5
- package/dist/cjs/thorchain-utils/index.d.ts +1 -0
- package/dist/cjs/thorchain-utils/index.js +19 -18
- package/dist/cjs/thorchain-utils/parseBuyTxHash.d.ts +1 -1
- package/dist/cjs/thorchain-utils/service.d.ts +3 -3
- package/dist/cjs/tron-utils/getTronTransactionFees.d.ts +1 -1
- package/dist/cjs/types.d.ts +6 -0
- package/dist/cjs/utils/tenderly/storageSlots.js +20 -20
- package/dist/cjs/utils.d.ts +4 -4
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/swappers/AcrossSwapper/utils/acrossService.d.ts +3 -3
- package/dist/esm/swappers/ArbitrumBridgeSwapper/endpoints.d.ts +3 -3
- package/dist/esm/swappers/ArbitrumBridgeSwapper/utils/fetchArbitrumBridgeSwap.d.ts +2 -2
- package/dist/esm/swappers/AvnuSwapper/endpoints.js +2 -2
- package/dist/esm/swappers/AvnuSwapper/utils/constants.d.ts +1 -1
- package/dist/esm/swappers/BebopSwapper/getBebopTradeQuote/getBebopTradeQuote.js +1 -1
- package/dist/esm/swappers/BebopSwapper/getBebopTradeRate/getBebopTradeRate.js +1 -1
- package/dist/esm/swappers/BebopSwapper/types.d.ts +1 -1
- package/dist/esm/swappers/BebopSwapper/utils/bebopService.d.ts +1 -1
- package/dist/esm/swappers/BebopSwapper/utils/fetchFromBebop.d.ts +4 -4
- package/dist/esm/swappers/BebopSwapper/utils/helpers/helpers.d.ts +1 -2
- package/dist/esm/swappers/ButterSwap/swapperApi/checkTradeStatus.test.js +2 -2
- package/dist/esm/swappers/ButterSwap/swapperApi/getTradeQuote.js +1 -1
- package/dist/esm/swappers/ButterSwap/test-data/routeQuote.js +4 -4
- package/dist/esm/swappers/ButterSwap/utils/butterSwapHistoryService.d.ts +3 -3
- package/dist/esm/swappers/ButterSwap/utils/butterSwapService.d.ts +3 -3
- package/dist/esm/swappers/CetusSwapper/utils/constants.d.ts +1 -1
- package/dist/esm/swappers/ChainflipSwapper/utils/chainflipService.d.ts +3 -3
- package/dist/esm/swappers/ChainflipSwapper/utils/getQuoteOrRate.js +2 -2
- package/dist/esm/swappers/ChainflipSwapper/utils/getUtxoTxFees.d.ts +1 -1
- package/dist/esm/swappers/ChainflipSwapper/utils/helpers.d.ts +2 -3
- package/dist/esm/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.js +1 -1
- package/dist/esm/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.test.js +8 -8
- package/dist/esm/swappers/CowSwapper/getCowSwapTradeRate/getCowSwapTradeRate.js +1 -1
- package/dist/esm/swappers/CowSwapper/utils/cowService.d.ts +3 -3
- package/dist/esm/swappers/DebridgeSwapper/utils/debridgeService.d.ts +3 -3
- package/dist/esm/swappers/NearIntentsSwapper/constants.d.ts +1 -0
- package/dist/esm/swappers/NearIntentsSwapper/constants.js +1 -0
- package/dist/esm/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.js +7 -4
- package/dist/esm/swappers/NearIntentsSwapper/utils/helpers/helpers.d.ts +2 -2
- package/dist/esm/swappers/NearIntentsSwapper/utils/helpers/helpers.js +5 -1
- package/dist/esm/swappers/PortalsSwapper/getPortalsTradeRate/getPortalsTradeRate.js +2 -2
- package/dist/esm/swappers/PortalsSwapper/utils/helpers.d.ts +1 -1
- package/dist/esm/swappers/RelaySwapper/constant.d.ts +1 -39
- package/dist/esm/swappers/RelaySwapper/utils/fetchRelayTrade.d.ts +1 -1
- package/dist/esm/swappers/RelaySwapper/utils/relayService.d.ts +3 -3
- package/dist/esm/swappers/SunioSwapper/utils/helpers/helpers.d.ts +1 -2
- package/dist/esm/swappers/SunioSwapper/utils/sunioService.d.ts +3 -3
- package/dist/esm/swappers/ThorchainSwapper/getTradeQuote/getTradeQuote.test.js +10 -0
- package/dist/esm/swappers/ThorchainSwapper/utils/getL1ToLongtailQuote.js +1 -1
- package/dist/esm/swappers/ThorchainSwapper/utils/getL1ToLongtailRate.js +1 -1
- package/dist/esm/swappers/ThorchainSwapper/utils/getLongtailQuote.js +1 -1
- package/dist/esm/swappers/ThorchainSwapper/utils/getLongtailRate.js +1 -1
- package/dist/esm/swappers/ZrxSwapper/utils/fetchFromZrx.js +2 -2
- package/dist/esm/swappers/ZrxSwapper/utils/helpers/helpers.d.ts +3 -2
- package/dist/esm/swappers/ZrxSwapper/utils/zrxService.d.ts +1 -1
- package/dist/esm/swappers/utils/test-data/cryptoMarketDataById.d.ts +1 -35
- package/dist/esm/thorchain-utils/checkTradeStatus.js +8 -1
- package/dist/esm/thorchain-utils/cosmossdk/getThorTxData.d.ts +12 -0
- package/dist/esm/thorchain-utils/cosmossdk/getThorTxData.js +15 -0
- package/dist/esm/thorchain-utils/cosmossdk/index.d.ts +1 -0
- package/dist/esm/thorchain-utils/cosmossdk/index.js +1 -0
- package/dist/esm/thorchain-utils/getCallDataFromQuote.d.ts +1 -1
- package/dist/esm/thorchain-utils/getL1RateOrQuote.js +39 -14
- package/dist/esm/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.d.ts +3 -2
- package/dist/esm/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.js +20 -13
- package/dist/esm/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.test.js +12 -6
- package/dist/esm/thorchain-utils/index.d.ts +1 -0
- package/dist/esm/thorchain-utils/index.js +11 -1
- package/dist/esm/thorchain-utils/parseBuyTxHash.d.ts +1 -1
- package/dist/esm/thorchain-utils/service.d.ts +3 -3
- package/dist/esm/tron-utils/getTronTransactionFees.d.ts +1 -1
- package/dist/esm/types.d.ts +6 -0
- package/dist/esm/utils/tenderly/storageSlots.js +20 -20
- package/dist/esm/utils.d.ts +4 -4
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const sunioServiceFactory: () => {
|
|
2
|
-
get: <T = any>(url: string, config?: import("axios").AxiosRequestConfig<any>) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T>, import("../../../index.js").SwapErrorRight>>;
|
|
3
|
-
post: <
|
|
4
|
-
delete: <
|
|
2
|
+
get: <T = any>(url: string, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T, any, {}>, import("../../../index.js").SwapErrorRight>>;
|
|
3
|
+
post: <T_1 = any>(url: string, data: any, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T_1, any, {}>, import("../../../index.js").SwapErrorRight>>;
|
|
4
|
+
delete: <T_2 = any>(url: string, data: any, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T_2, any, {}>, import("../../../index.js").SwapErrorRight>>;
|
|
5
5
|
};
|
|
6
6
|
export type SunioService = ReturnType<typeof sunioServiceFactory>;
|
|
@@ -76,6 +76,11 @@ const expectedQuoteResponse = [
|
|
|
76
76
|
thorchainSpecific: {
|
|
77
77
|
maxStreamingQuantity: undefined,
|
|
78
78
|
},
|
|
79
|
+
thorchainTransactionMetadata: {
|
|
80
|
+
to: '0x3624525075b88B24ecc29CE226b0CEc1fFcB6976',
|
|
81
|
+
data: '0x',
|
|
82
|
+
value: '0',
|
|
83
|
+
},
|
|
79
84
|
},
|
|
80
85
|
],
|
|
81
86
|
},
|
|
@@ -119,6 +124,11 @@ const expectedQuoteResponse = [
|
|
|
119
124
|
thorchainSpecific: {
|
|
120
125
|
maxStreamingQuantity: undefined,
|
|
121
126
|
},
|
|
127
|
+
thorchainTransactionMetadata: {
|
|
128
|
+
to: '0x3624525075b88B24ecc29CE226b0CEc1fFcB6976',
|
|
129
|
+
data: '0x',
|
|
130
|
+
value: '0',
|
|
131
|
+
},
|
|
122
132
|
},
|
|
123
133
|
],
|
|
124
134
|
},
|
|
@@ -101,7 +101,7 @@ export const getL1ToLongtailQuote = async (input, deps, streamingInterval, swapp
|
|
|
101
101
|
// This is wrong, we should get the get the value before fees or display ETH value received after the thorchain bridge
|
|
102
102
|
buyAmountBeforeFeesCryptoBaseUnit: quotedAmountOut.toString(),
|
|
103
103
|
allowanceContract: TS_AGGREGATOR_TOKEN_TRANSFER_PROXY_CONTRACT_MAINNET,
|
|
104
|
-
})),
|
|
104
|
+
})),
|
|
105
105
|
isLongtail: true,
|
|
106
106
|
longtailData: {
|
|
107
107
|
L1ToLongtailExpectedAmountOut: quotedAmountOut.toString(),
|
|
@@ -89,7 +89,7 @@ export const getL1ToLongtailRate = async (input, deps, streamingInterval, swappe
|
|
|
89
89
|
// This is wrong, we should get the get the value before fees or display ETH value received after the thorchain bridge
|
|
90
90
|
buyAmountBeforeFeesCryptoBaseUnit: quotedAmountOut.toString(),
|
|
91
91
|
allowanceContract: TS_AGGREGATOR_TOKEN_TRANSFER_PROXY_CONTRACT_MAINNET,
|
|
92
|
-
})),
|
|
92
|
+
})),
|
|
93
93
|
isLongtail: true,
|
|
94
94
|
longtailData: {
|
|
95
95
|
L1ToLongtailExpectedAmountOut: quotedAmountOut.toString(),
|
|
@@ -55,7 +55,7 @@ export const getLongtailToL1Quote = async (input, deps, streamingInterval, swapp
|
|
|
55
55
|
sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
56
56
|
sellAsset,
|
|
57
57
|
allowanceContract: TS_AGGREGATOR_TOKEN_TRANSFER_PROXY_CONTRACT_MAINNET,
|
|
58
|
-
})),
|
|
58
|
+
})),
|
|
59
59
|
isLongtail: true,
|
|
60
60
|
longtailData: {
|
|
61
61
|
longtailToL1ExpectedAmountOut: quotedAmountOut.toString(),
|
|
@@ -55,7 +55,7 @@ export const getLongtailToL1Rate = async (input, deps, streamingInterval, swappe
|
|
|
55
55
|
sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
56
56
|
sellAsset,
|
|
57
57
|
allowanceContract: TS_AGGREGATOR_TOKEN_TRANSFER_PROXY_CONTRACT_MAINNET,
|
|
58
|
-
})),
|
|
58
|
+
})),
|
|
59
59
|
isLongtail: true,
|
|
60
60
|
longtailData: {
|
|
61
61
|
longtailToL1ExpectedAmountOut: quotedAmountOut.toString(),
|
|
@@ -24,9 +24,9 @@ const fetchFromZrx = async ({ quoteOrRate, buyAsset, sellAsset, sellAmountInclud
|
|
|
24
24
|
sellAmount: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
25
25
|
taker: sellAddress,
|
|
26
26
|
swapFeeBps: bn(affiliateBps).toNumber(),
|
|
27
|
-
swapFeeToken: assetIdToZrxToken(buyAsset.assetId),
|
|
27
|
+
swapFeeToken: assetIdToZrxToken(buyAsset.assetId),
|
|
28
28
|
slippageBps: convertDecimalPercentageToBasisPoints(slippageTolerancePercentageDecimal).toNumber(),
|
|
29
|
-
swapFeeRecipient: maybeTreasuryAddress,
|
|
29
|
+
swapFeeRecipient: maybeTreasuryAddress,
|
|
30
30
|
feeRecipientTradeSurplus: maybeTreasuryAddress, // Where trade surplus is sent
|
|
31
31
|
},
|
|
32
32
|
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { AssetId, ChainId } from '@shapeshiftoss/caip';
|
|
2
2
|
import type { Asset, AssetsByIdPartial } from '@shapeshiftoss/types';
|
|
3
|
-
import
|
|
3
|
+
import { KnownChainIds } from '@shapeshiftoss/types';
|
|
4
|
+
import type { ZrxFees } from '../../types.js';
|
|
4
5
|
export declare const assetIdToZrxToken: (assetId: AssetId) => string;
|
|
5
6
|
export declare const zrxTokenToAssetId: (token: string, chainId: ChainId) => AssetId;
|
|
6
|
-
export declare const isSupportedChainId: (chainId: ChainId) => chainId is
|
|
7
|
+
export declare const isSupportedChainId: (chainId: ChainId) => chainId is KnownChainIds.EthereumMainnet | KnownChainIds.AvalancheMainnet | KnownChainIds.OptimismMainnet | KnownChainIds.BnbSmartChainMainnet | KnownChainIds.PolygonMainnet | KnownChainIds.ArbitrumMainnet | KnownChainIds.BaseMainnet;
|
|
7
8
|
export declare const assertValidTrade: ({ buyAsset, sellAsset, }: {
|
|
8
9
|
buyAsset: Asset;
|
|
9
10
|
sellAsset: Asset;
|
|
@@ -4,6 +4,6 @@ import type { MonadicSwapperAxiosService } from '../../../types.js';
|
|
|
4
4
|
type AxiosInstanceHoF = (instance: AxiosInstance, options?: Omit<RetryConfig, 'instance'>) => AxiosInstance;
|
|
5
5
|
export declare const zrxServiceFactory: ({ baseUrl, wrapper, }: {
|
|
6
6
|
baseUrl: string;
|
|
7
|
-
wrapper?: AxiosInstanceHoF;
|
|
7
|
+
wrapper?: AxiosInstanceHoF | undefined;
|
|
8
8
|
}) => MonadicSwapperAxiosService;
|
|
9
9
|
export {};
|
|
@@ -1,39 +1,5 @@
|
|
|
1
|
-
import { AVAX, BSC, BTC, ETH, FOX_GNOSIS, FOX_MAINNET, OPTIMISM, RUNE, USDC_GNOSIS, USDC_MAINNET, WBTC, WETH } from './assets.js';
|
|
2
1
|
export declare const marketDataByAssetIdUsd: {
|
|
3
|
-
[
|
|
4
|
-
price: string;
|
|
5
|
-
};
|
|
6
|
-
[FOX_GNOSIS.assetId]: {
|
|
7
|
-
price: string;
|
|
8
|
-
};
|
|
9
|
-
[ETH.assetId]: {
|
|
10
|
-
price: string;
|
|
11
|
-
};
|
|
12
|
-
[AVAX.assetId]: {
|
|
13
|
-
price: string;
|
|
14
|
-
};
|
|
15
|
-
[BSC.assetId]: {
|
|
16
|
-
price: string;
|
|
17
|
-
};
|
|
18
|
-
[BTC.assetId]: {
|
|
19
|
-
price: string;
|
|
20
|
-
};
|
|
21
|
-
[RUNE.assetId]: {
|
|
22
|
-
price: string;
|
|
23
|
-
};
|
|
24
|
-
[OPTIMISM.assetId]: {
|
|
25
|
-
price: string;
|
|
26
|
-
};
|
|
27
|
-
[USDC_MAINNET.assetId]: {
|
|
28
|
-
price: string;
|
|
29
|
-
};
|
|
30
|
-
[USDC_GNOSIS.assetId]: {
|
|
31
|
-
price: string;
|
|
32
|
-
};
|
|
33
|
-
[WBTC.assetId]: {
|
|
34
|
-
price: string;
|
|
35
|
-
};
|
|
36
|
-
[WETH.assetId]: {
|
|
2
|
+
[x: string]: {
|
|
37
3
|
price: string;
|
|
38
4
|
};
|
|
39
5
|
};
|
|
@@ -62,7 +62,14 @@ export const checkTradeStatus = async ({ txHash, chainId, address, fetchIsSmartC
|
|
|
62
62
|
return { buyTxHash, status: TxStatus.Pending, message };
|
|
63
63
|
}
|
|
64
64
|
catch (e) {
|
|
65
|
-
|
|
65
|
+
const message = (() => {
|
|
66
|
+
if (axios.isAxiosError(e))
|
|
67
|
+
return e.response?.data?.message ?? e.message;
|
|
68
|
+
if (e instanceof Error)
|
|
69
|
+
return e.message;
|
|
70
|
+
return String(e);
|
|
71
|
+
})();
|
|
72
|
+
console.error(`checkTradeStatus(${nativeChain}, ${txHash}): ${message}`);
|
|
66
73
|
return { buyTxHash: undefined, status: TxStatus.Unknown, message: undefined };
|
|
67
74
|
}
|
|
68
75
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Asset } from '@shapeshiftoss/types';
|
|
2
|
+
import type { SwapperConfig, SwapperName } from '../../types.js';
|
|
3
|
+
type GetThorTxDataArgs = {
|
|
4
|
+
sellAsset: Asset;
|
|
5
|
+
config: SwapperConfig;
|
|
6
|
+
swapperName: SwapperName;
|
|
7
|
+
};
|
|
8
|
+
type GetThorTxDataReturn = {
|
|
9
|
+
vault: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const getThorTxData: ({ sellAsset, config, swapperName, }: GetThorTxDataArgs) => Promise<GetThorTxDataReturn>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getInboundAddressDataForChain } from '../getInboundAddressDataForChain.js';
|
|
2
|
+
import { getChainIdBySwapper, getDaemonUrl } from '../index.js';
|
|
3
|
+
export const getThorTxData = async ({ sellAsset, config, swapperName, }) => {
|
|
4
|
+
// Native assets on the swapper's own chain (RUNE on THORChain, CACAO on MAYAChain)
|
|
5
|
+
// deposit via MsgDeposit and have no recipient address.
|
|
6
|
+
if (sellAsset.chainId === getChainIdBySwapper(swapperName))
|
|
7
|
+
return { vault: '' };
|
|
8
|
+
// Everything else (e.g. ATOM via THORChain, RUNE via MAYAChain) sends via MsgSend
|
|
9
|
+
// to the swapper's inbound vault on that chain.
|
|
10
|
+
const daemonUrl = getDaemonUrl(config, swapperName);
|
|
11
|
+
const res = await getInboundAddressDataForChain(daemonUrl, sellAsset.assetId, true, swapperName);
|
|
12
|
+
if (res.isErr())
|
|
13
|
+
throw res.unwrapErr();
|
|
14
|
+
return { vault: res.unwrap().address };
|
|
15
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Asset } from '@shapeshiftoss/types';
|
|
2
2
|
import type { SwapperConfig, SwapperName } from '../types.js';
|
|
3
3
|
import type { ThorEvmTradeQuote } from './types.js';
|
|
4
|
-
export declare const getCallDataFromQuote: ({ tradeType, data, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, memo: tcMemo, expiry, config, longtailData, slippageTolerancePercentageDecimal, vault, swapperName, }: Pick<ThorEvmTradeQuote, "
|
|
4
|
+
export declare const getCallDataFromQuote: ({ tradeType, data, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, memo: tcMemo, expiry, config, longtailData, slippageTolerancePercentageDecimal, vault, swapperName, }: Pick<ThorEvmTradeQuote, "data" | "slippageTolerancePercentageDecimal" | "memo" | "expiry" | "tradeType" | "aggregator" | "vault" | "longtailData"> & {
|
|
5
5
|
sellAmountIncludingProtocolFeesCryptoBaseUnit: string;
|
|
6
6
|
config: SwapperConfig;
|
|
7
7
|
sellAsset: Asset;
|
|
@@ -7,8 +7,10 @@ import { TronWeb } from 'tronweb';
|
|
|
7
7
|
import { v4 as uuid } from 'uuid';
|
|
8
8
|
import { getDefaultSlippageDecimalPercentageForSwapper } from '../index.js';
|
|
9
9
|
import { buildAffiliateFee } from '../swappers/utils/affiliateFee.js';
|
|
10
|
+
import { isNativeEvmAsset } from '../swappers/utils/helpers/helpers.js';
|
|
10
11
|
import { TradeQuoteError } from '../types.js';
|
|
11
12
|
import { getInputOutputRate, makeSwapErrorRight } from '../utils.js';
|
|
13
|
+
import * as cosmossdk from './cosmossdk/index.js';
|
|
12
14
|
import * as evm from './evm/index.js';
|
|
13
15
|
import { getLimitWithManualSlippage } from './getLimitWithManualSlippage/getLimitWithManualSlippage.js';
|
|
14
16
|
import { getQuote } from './getQuote.js';
|
|
@@ -128,7 +130,7 @@ export const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType
|
|
|
128
130
|
affilate: getAffiliate(swapperName),
|
|
129
131
|
});
|
|
130
132
|
};
|
|
131
|
-
const makeThorTradeRateOrQuote = ({ route, memo, allowanceContract, feeData, data, router, vault, }) => {
|
|
133
|
+
const makeThorTradeRateOrQuote = ({ route, memo, allowanceContract, feeData, data, router, vault, thorchainTransactionMetadata, }) => {
|
|
132
134
|
const buyAmountAfterFeesCryptoBaseUnit = convertPrecision({
|
|
133
135
|
value: route.expectedAmountOutThorBaseUnit,
|
|
134
136
|
inputExponent: buyAssetNativePrecision,
|
|
@@ -182,6 +184,7 @@ export const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType
|
|
|
182
184
|
thorchainSpecific: {
|
|
183
185
|
maxStreamingQuantity: route.quote.max_streaming_quantity,
|
|
184
186
|
},
|
|
187
|
+
thorchainTransactionMetadata,
|
|
185
188
|
},
|
|
186
189
|
],
|
|
187
190
|
};
|
|
@@ -213,6 +216,11 @@ export const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType
|
|
|
213
216
|
data,
|
|
214
217
|
router,
|
|
215
218
|
vault,
|
|
219
|
+
thorchainTransactionMetadata: {
|
|
220
|
+
to: router,
|
|
221
|
+
data,
|
|
222
|
+
value: isNativeEvmAsset(sellAsset.assetId) ? sellAmountCryptoBaseUnit : '0',
|
|
223
|
+
},
|
|
216
224
|
feeData: {
|
|
217
225
|
protocolFees: getProtocolFees(route.quote),
|
|
218
226
|
networkFeeCryptoBaseUnit,
|
|
@@ -258,8 +266,13 @@ export const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType
|
|
|
258
266
|
})();
|
|
259
267
|
return makeThorTradeRateOrQuote({
|
|
260
268
|
route,
|
|
261
|
-
allowanceContract: '0x0',
|
|
269
|
+
allowanceContract: '0x0',
|
|
262
270
|
memo,
|
|
271
|
+
thorchainTransactionMetadata: {
|
|
272
|
+
to: vault,
|
|
273
|
+
memo,
|
|
274
|
+
value: sellAmountCryptoBaseUnit,
|
|
275
|
+
},
|
|
263
276
|
feeData,
|
|
264
277
|
});
|
|
265
278
|
}));
|
|
@@ -275,11 +288,18 @@ export const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType
|
|
|
275
288
|
case CHAIN_NAMESPACE.CosmosSdk: {
|
|
276
289
|
const cosmosChainAdapter = assertGetCosmosSdkChainAdapter(sellAsset.chainId);
|
|
277
290
|
const { fast } = await cosmosChainAdapter.getFeeData({});
|
|
291
|
+
const { vault } = await cosmossdk.getThorTxData({ sellAsset, config, swapperName });
|
|
278
292
|
return Ok(perRouteValues.map((route) => {
|
|
293
|
+
const memo = getMemo(route);
|
|
279
294
|
return makeThorTradeRateOrQuote({
|
|
280
295
|
route,
|
|
281
|
-
memo
|
|
282
|
-
allowanceContract: '0x0',
|
|
296
|
+
memo,
|
|
297
|
+
allowanceContract: '0x0',
|
|
298
|
+
thorchainTransactionMetadata: {
|
|
299
|
+
to: vault,
|
|
300
|
+
memo,
|
|
301
|
+
value: sellAmountCryptoBaseUnit,
|
|
302
|
+
},
|
|
283
303
|
feeData: {
|
|
284
304
|
networkFeeCryptoBaseUnit: fast.txFee,
|
|
285
305
|
protocolFees: getProtocolFees(route.quote),
|
|
@@ -293,13 +313,13 @@ export const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType
|
|
|
293
313
|
case CHAIN_NAMESPACE.Solana: {
|
|
294
314
|
const adapter = assertGetSolanaChainAdapter(sellAsset.chainId);
|
|
295
315
|
const sendAddress = input.sendAddress;
|
|
316
|
+
const { vault } = await solana.getThorTxData({ sellAsset, config, swapperName });
|
|
296
317
|
const maybeRoutes = await Promise.allSettled(perRouteValues.map(async (route) => {
|
|
297
318
|
const memo = getMemo(route);
|
|
298
319
|
const protocolFees = getProtocolFees(route.quote);
|
|
299
320
|
const feeData = await (async () => {
|
|
300
321
|
if (!sendAddress)
|
|
301
322
|
return { networkFeeCryptoBaseUnit: undefined, protocolFees };
|
|
302
|
-
const { vault } = await solana.getThorTxData({ sellAsset, config, swapperName });
|
|
303
323
|
const memoInstruction = new TransactionInstruction({
|
|
304
324
|
keys: [],
|
|
305
325
|
programId: new PublicKey(SOLANA_MEMO_PROGRAM_ID),
|
|
@@ -325,6 +345,11 @@ export const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType
|
|
|
325
345
|
route,
|
|
326
346
|
allowanceContract: '0x0',
|
|
327
347
|
memo,
|
|
348
|
+
thorchainTransactionMetadata: {
|
|
349
|
+
to: vault,
|
|
350
|
+
memo,
|
|
351
|
+
value: sellAmountCryptoBaseUnit,
|
|
352
|
+
},
|
|
328
353
|
feeData,
|
|
329
354
|
});
|
|
330
355
|
}));
|
|
@@ -338,20 +363,15 @@ export const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType
|
|
|
338
363
|
return Ok(routes);
|
|
339
364
|
}
|
|
340
365
|
case CHAIN_NAMESPACE.Tron: {
|
|
366
|
+
const { vault } = await tron.getThorTxData({ sellAsset, config, swapperName });
|
|
341
367
|
const maybeRoutes = await Promise.allSettled(perRouteValues.map(async (route) => {
|
|
342
368
|
const memo = getMemo(route);
|
|
343
369
|
let networkFeeCryptoBaseUnit = undefined;
|
|
344
370
|
// Calculate fees for rates when we have a receive address (wallet connected)
|
|
345
|
-
if (input.quoteOrRate === 'rate' && input.receiveAddress) {
|
|
371
|
+
if (input.quoteOrRate === 'rate' && input.receiveAddress && vault) {
|
|
346
372
|
try {
|
|
347
373
|
const { sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit } = input;
|
|
348
374
|
const contractAddress = contractAddressOrUndefined(sellAsset.assetId);
|
|
349
|
-
// Get vault address
|
|
350
|
-
const { vault } = await tron.getThorTxData({
|
|
351
|
-
sellAsset,
|
|
352
|
-
config,
|
|
353
|
-
swapperName,
|
|
354
|
-
});
|
|
355
375
|
// Estimate fees using the receive address for accurate energy calculation
|
|
356
376
|
const tronWeb = new TronWeb({
|
|
357
377
|
fullHost: deps.config.VITE_TRON_NODE_URL,
|
|
@@ -364,7 +384,7 @@ export const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType
|
|
|
364
384
|
// TRC20: Estimate energy with actual recipient
|
|
365
385
|
try {
|
|
366
386
|
const result = await tronWeb.transactionBuilder.triggerConstantContract(contractAddress, 'transfer(address,uint256)', {}, [
|
|
367
|
-
{ type: 'address', value: vault },
|
|
387
|
+
{ type: 'address', value: vault },
|
|
368
388
|
{
|
|
369
389
|
type: 'uint256',
|
|
370
390
|
value: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
@@ -398,8 +418,13 @@ export const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType
|
|
|
398
418
|
// For quotes, fees will be calculated in getTronTransactionFees when executing
|
|
399
419
|
return Promise.resolve(makeThorTradeRateOrQuote({
|
|
400
420
|
route,
|
|
401
|
-
allowanceContract: '0x0',
|
|
421
|
+
allowanceContract: '0x0',
|
|
402
422
|
memo,
|
|
423
|
+
thorchainTransactionMetadata: {
|
|
424
|
+
to: vault,
|
|
425
|
+
memo,
|
|
426
|
+
value: sellAmountCryptoBaseUnit,
|
|
427
|
+
},
|
|
403
428
|
feeData: {
|
|
404
429
|
networkFeeCryptoBaseUnit,
|
|
405
430
|
protocolFees: getProtocolFees(route.quote),
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { AssetId } from '@shapeshiftoss/caip';
|
|
1
2
|
import type { Asset } from '@shapeshiftoss/types';
|
|
2
3
|
import type { SwapperConfig, SwapperName } from '../../types.js';
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const getOutboundFeeSellAssetThorBaseUnit: (runePerAsset: string, sellAssetId: AssetId, swapperName: SwapperName) => BigNumber;
|
|
5
|
+
export declare const getExpectedAffiliateFeeSellAssetThorBaseUnit: (sellAmountCryptoBaseUnit: string, sellAsset: Asset, affiliateBps: string, swapperName: SwapperName) => BigNumber;
|
|
5
6
|
export declare const getThresholdedAffiliateBps: ({ sellAsset, affiliateBps, sellAmountCryptoBaseUnit, config, swapperName, }: {
|
|
6
7
|
sellAsset: Asset;
|
|
7
8
|
affiliateBps: string;
|
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getMidgardUrl, getNativeFee, getNativePrecision, getPoolAssetId, isNativeAsset, thorService, } from '../index.js';
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { convertBasisPointsToDecimalPercentage, convertPrecision } from '@shapeshiftoss/utils';
|
|
2
|
+
import { getMidgardUrl, getNativeFee, getNativePrecision, getPoolAssetId, getSwapperNativeAssetId, isNativeAsset, thorService, } from '../index.js';
|
|
3
|
+
// Convert native fee to sell asset's native precision before dividing by `assetPrice`.
|
|
4
|
+
// MAYA's CACAO is 10-dec but pool assets are 8-dec — skip this and the result is 100x off.
|
|
5
|
+
export const getOutboundFeeSellAssetThorBaseUnit = (runePerAsset, sellAssetId, swapperName) => {
|
|
6
|
+
const nativeFeeSellAssetThorBaseUnit = convertPrecision({
|
|
7
|
+
value: getNativeFee(swapperName),
|
|
8
|
+
inputExponent: getNativePrecision(getSwapperNativeAssetId(swapperName), swapperName),
|
|
9
|
+
outputExponent: getNativePrecision(sellAssetId, swapperName),
|
|
10
|
+
});
|
|
11
|
+
return nativeFeeSellAssetThorBaseUnit.dividedBy(runePerAsset);
|
|
5
12
|
};
|
|
6
|
-
export const
|
|
7
|
-
const
|
|
13
|
+
export const getExpectedAffiliateFeeSellAssetThorBaseUnit = (sellAmountCryptoBaseUnit, sellAsset, affiliateBps, swapperName) => {
|
|
14
|
+
const sellAmountThorBaseUnit = convertPrecision({
|
|
8
15
|
value: sellAmountCryptoBaseUnit,
|
|
9
16
|
inputExponent: sellAsset.precision,
|
|
10
17
|
outputExponent: getNativePrecision(sellAsset.assetId, swapperName),
|
|
11
18
|
});
|
|
12
19
|
const affiliatePercent = convertBasisPointsToDecimalPercentage(affiliateBps);
|
|
13
|
-
return
|
|
20
|
+
return sellAmountThorBaseUnit.times(affiliatePercent);
|
|
14
21
|
};
|
|
15
22
|
// don't apply an affiliate fee if it's below the outbound fee for the inbound pool
|
|
16
23
|
export const getThresholdedAffiliateBps = async ({ sellAsset, affiliateBps, sellAmountCryptoBaseUnit, config, swapperName, }) => {
|
|
17
24
|
const midgardUrl = getMidgardUrl(config, swapperName);
|
|
18
|
-
const
|
|
25
|
+
const outboundFeeSellAssetThorBaseUnit = await (async () => {
|
|
19
26
|
if (isNativeAsset(sellAsset.assetId, swapperName))
|
|
20
27
|
return getNativeFee(swapperName);
|
|
21
28
|
const sellPoolId = getPoolAssetId({ assetId: sellAsset.assetId, swapperName });
|
|
@@ -24,11 +31,11 @@ export const getThresholdedAffiliateBps = async ({ sellAsset, affiliateBps, sell
|
|
|
24
31
|
if (res.isErr())
|
|
25
32
|
throw res.unwrapErr();
|
|
26
33
|
const pool = res.unwrap().data;
|
|
27
|
-
// calculate the rune outbound fee denominated in the sell asset, in
|
|
28
|
-
return
|
|
34
|
+
// calculate the rune outbound fee denominated in the sell asset, in thor base units
|
|
35
|
+
return getOutboundFeeSellAssetThorBaseUnit(pool.assetPrice, sellAsset.assetId, swapperName);
|
|
29
36
|
})();
|
|
30
|
-
// calculate the expected affiliate fee, in
|
|
31
|
-
const
|
|
32
|
-
const isAffiliateFeeBelowOutboundFee =
|
|
37
|
+
// calculate the expected affiliate fee, in thor base units
|
|
38
|
+
const expectedAffiliateFeeSellAssetThorBaseUnit = getExpectedAffiliateFeeSellAssetThorBaseUnit(sellAmountCryptoBaseUnit, sellAsset, affiliateBps, swapperName);
|
|
39
|
+
const isAffiliateFeeBelowOutboundFee = expectedAffiliateFeeSellAssetThorBaseUnit.lte(outboundFeeSellAssetThorBaseUnit);
|
|
33
40
|
return isAffiliateFeeBelowOutboundFee ? '0' : affiliateBps;
|
|
34
41
|
};
|
package/dist/esm/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.test.js
CHANGED
|
@@ -5,7 +5,7 @@ import { describe, expect, it, vi } from 'vitest';
|
|
|
5
5
|
import { ETH } from '../../swappers/utils/test-data/index.js';
|
|
6
6
|
import { SwapperName } from '../../types.js';
|
|
7
7
|
import { thorService } from '../service.js';
|
|
8
|
-
import {
|
|
8
|
+
import { getExpectedAffiliateFeeSellAssetThorBaseUnit, getOutboundFeeSellAssetThorBaseUnit, getThresholdedAffiliateBps, } from './getThresholdedAffiliateBps.js';
|
|
9
9
|
const mockedThorService = vi.mocked(thorService);
|
|
10
10
|
const mocks = vi.hoisted(() => ({
|
|
11
11
|
get: vi.fn(),
|
|
@@ -24,18 +24,24 @@ vi.mock('../service', () => {
|
|
|
24
24
|
thorService: mockAxios.default.create(),
|
|
25
25
|
};
|
|
26
26
|
});
|
|
27
|
-
describe('
|
|
27
|
+
describe('getOutboundFeeSellAssetThorBaseUnit', () => {
|
|
28
28
|
it('should return 0.02 rune denominated in the target asset, in thor units', () => {
|
|
29
29
|
const assetPricePrecision = '4.00000'; // 1 token is 4x as valuable as 1 rune
|
|
30
|
-
expect(
|
|
30
|
+
expect(getOutboundFeeSellAssetThorBaseUnit(assetPricePrecision, ETH.assetId, SwapperName.Thorchain).toNumber()).toEqual(Number(thorchain.NATIVE_FEE) / 4);
|
|
31
|
+
});
|
|
32
|
+
it('should scale CACAO 10-dec native fee down to non-CACAO 8-dec sell asset precision on MAYA', () => {
|
|
33
|
+
// 1 eth = 100 cacao, NATIVE_FEE = 2e9 (10-dec CACAO = 0.2 CACAO)
|
|
34
|
+
// 0.2 CACAO / 100 (CACAO/ETH) = 0.002 ETH = 200_000 at 8-dec ETH
|
|
35
|
+
const assetPrice = '100';
|
|
36
|
+
expect(getOutboundFeeSellAssetThorBaseUnit(assetPrice, ETH.assetId, SwapperName.Mayachain).toNumber()).toEqual(200_000);
|
|
31
37
|
});
|
|
32
38
|
});
|
|
33
|
-
describe('
|
|
39
|
+
describe('getExpectedAffiliateFeeSellAssetThorBaseUnit', () => {
|
|
34
40
|
it('should return the correct affiliate fee in thor base units', () => {
|
|
35
41
|
const sellAmountCryptoBaseUnit = '1000000000000000000'; // 1 eth
|
|
36
42
|
const affiliateBps = '35';
|
|
37
43
|
const sellAsset = ETH;
|
|
38
|
-
const result =
|
|
44
|
+
const result = getExpectedAffiliateFeeSellAssetThorBaseUnit(sellAmountCryptoBaseUnit, sellAsset, affiliateBps, SwapperName.Thorchain);
|
|
39
45
|
const expectation = bn('100000000').times('0.0035').toFixed(0);
|
|
40
46
|
expect(result.toFixed(0)).toEqual(expectation);
|
|
41
47
|
});
|
|
@@ -43,7 +49,7 @@ describe('getExpectedAffiliateFeeSellAssetThorUnit', () => {
|
|
|
43
49
|
const sellAmountCryptoBaseUnit = '1000000000000000000'; // 1 eth
|
|
44
50
|
const affiliateBps = '0';
|
|
45
51
|
const sellAsset = ETH;
|
|
46
|
-
const result =
|
|
52
|
+
const result = getExpectedAffiliateFeeSellAssetThorBaseUnit(sellAmountCryptoBaseUnit, sellAsset, affiliateBps, SwapperName.Thorchain);
|
|
47
53
|
const expectation = '0';
|
|
48
54
|
expect(result.toFixed(0)).toEqual(expectation);
|
|
49
55
|
});
|
|
@@ -23,6 +23,7 @@ export declare const getDaemonUrl: (config: SwapperConfig, swapperName: SwapperN
|
|
|
23
23
|
export declare const getMidgardUrl: (config: SwapperConfig, swapperName: SwapperName) => string;
|
|
24
24
|
export declare const isNativeAsset: (assetId: AssetId, swapperName: SwapperName) => boolean;
|
|
25
25
|
export declare const getNativePrecision: (assetId: AssetId, swapperName: SwapperName) => 8 | 10;
|
|
26
|
+
export declare const getSwapperNativeAssetId: (swapperName: SwapperName) => AssetId;
|
|
26
27
|
export declare const getNativeFee: (swapperName: SwapperName) => "2000000" | "2000000000";
|
|
27
28
|
export declare const getAffiliate: (swapperName: SwapperName) => "ss" | "ssmaya";
|
|
28
29
|
export declare const getPoolAssetId: ({ assetId, swapperName, }: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mayachainAssetId, mayachainChainId, thorchainChainId } from '@shapeshiftoss/caip';
|
|
1
|
+
import { mayachainAssetId, mayachainChainId, thorchainAssetId, thorchainChainId, } from '@shapeshiftoss/caip';
|
|
2
2
|
import * as adapters from '@shapeshiftoss/chain-adapters';
|
|
3
3
|
import { assetIdToMayaPoolAssetId, CACAO_PRECISION, isCacao, MAYACHAIN_AFFILIATE_NAME, MAYACHAIN_PRECISION, MAYACHAIN_STREAM_SWAP_SOURCE, } from '../swappers/MayachainSwapper/index.js';
|
|
4
4
|
import { assetIdToThorPoolAssetId, isRune, THORCHAIN_AFFILIATE_NAME, THORCHAIN_LONGTAIL_STREAMING_SWAP_SOURCE, THORCHAIN_LONGTAIL_SWAP_SOURCE, THORCHAIN_PRECISION, THORCHAIN_STREAM_SWAP_SOURCE, } from '../swappers/ThorchainSwapper/index.js';
|
|
@@ -69,6 +69,16 @@ export const getNativePrecision = (assetId, swapperName) => {
|
|
|
69
69
|
throw new Error(`Invalid swapper: ${swapperName}`);
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
|
+
export const getSwapperNativeAssetId = (swapperName) => {
|
|
73
|
+
switch (swapperName) {
|
|
74
|
+
case SwapperName.Thorchain:
|
|
75
|
+
return thorchainAssetId;
|
|
76
|
+
case SwapperName.Mayachain:
|
|
77
|
+
return mayachainAssetId;
|
|
78
|
+
default:
|
|
79
|
+
throw new Error(`Invalid swapper: ${swapperName}`);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
72
82
|
export const getNativeFee = (swapperName) => {
|
|
73
83
|
switch (swapperName) {
|
|
74
84
|
case SwapperName.Thorchain:
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ThorNodeTxSchema } from './types.js';
|
|
2
|
-
export declare const parseThorBuyTxHash: (sellTxId: string, latestOutTx: ThorNodeTxSchema | undefined, nativeChain:
|
|
2
|
+
export declare const parseThorBuyTxHash: (sellTxId: string, latestOutTx: ThorNodeTxSchema | undefined, nativeChain: 'THOR' | 'MAYA') => string | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const thorService: {
|
|
2
|
-
get: <T = any>(url: string, config?: import("axios").AxiosRequestConfig<any>) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T>, import("../index.js").SwapErrorRight>>;
|
|
3
|
-
post: <
|
|
4
|
-
delete: <
|
|
2
|
+
get: <T = any>(url: string, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T, any, {}>, import("../index.js").SwapErrorRight>>;
|
|
3
|
+
post: <T_1 = any>(url: string, data: any, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T_1, any, {}>, import("../index.js").SwapErrorRight>>;
|
|
4
|
+
delete: <T_2 = any>(url: string, data: any, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T_2, any, {}>, import("../index.js").SwapErrorRight>>;
|
|
5
5
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { GetUnsignedTronTransactionArgs } from '../types.js';
|
|
2
|
-
export declare const getTronTransactionFees: ({ tradeQuote, stepIndex, }: Pick<GetUnsignedTronTransactionArgs,
|
|
2
|
+
export declare const getTronTransactionFees: ({ tradeQuote, stepIndex, }: Pick<GetUnsignedTronTransactionArgs, 'tradeQuote' | 'stepIndex'>) => Promise<string>;
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -327,6 +327,12 @@ export type TradeQuoteStep = {
|
|
|
327
327
|
thorchainSpecific?: {
|
|
328
328
|
maxStreamingQuantity?: number;
|
|
329
329
|
};
|
|
330
|
+
thorchainTransactionMetadata?: {
|
|
331
|
+
to: string;
|
|
332
|
+
data?: string;
|
|
333
|
+
value?: string;
|
|
334
|
+
memo?: string;
|
|
335
|
+
};
|
|
330
336
|
relayTransactionMetadata?: RelayTransactionMetadata;
|
|
331
337
|
butterSwapTransactionMetadata?: {
|
|
332
338
|
to: string;
|
|
@@ -23,39 +23,39 @@ export const getAllowanceStorageSlot = (ownerAddress, spenderAddress, allowanceS
|
|
|
23
23
|
// USDC (BEP20 - BSC): balance at slot 1, allowance at slot 2
|
|
24
24
|
export const KNOWN_BALANCE_SLOTS = {
|
|
25
25
|
// USDT - Native Tether deployment (custom slot 2)
|
|
26
|
-
'0xdac17f958d2ee523a2206206994597c13d831ec7': 2,
|
|
26
|
+
'0xdac17f958d2ee523a2206206994597c13d831ec7': 2,
|
|
27
27
|
// Slot 51 pattern (L2GatewayToken + ERC20Upgradeable + storage gaps)
|
|
28
28
|
// Various L2 tokens use this pattern with different implementations
|
|
29
|
-
'0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9': 51,
|
|
30
|
-
'0x912ce59144191c1204e64559fe8253a0e49e6548': 51,
|
|
31
|
-
'0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7': 51,
|
|
32
|
-
'0x01bff41798a0bcf287b996046ca68b395dbc1071': 51,
|
|
29
|
+
'0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9': 51,
|
|
30
|
+
'0x912ce59144191c1204e64559fe8253a0e49e6548': 51,
|
|
31
|
+
'0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7': 51,
|
|
32
|
+
'0x01bff41798a0bcf287b996046ca68b395dbc1071': 51,
|
|
33
33
|
// Wormhole bridge pattern (slot 5)
|
|
34
|
-
'0xca7dec8550f43a5e46e3dfb95801f64280e75b27': 5,
|
|
34
|
+
'0xca7dec8550f43a5e46e3dfb95801f64280e75b27': 5,
|
|
35
35
|
// USDT - BEP20 pattern (slot 1 - Binance-Peg token)
|
|
36
|
-
'0x55d398326f99059ff775485246999027b3197955': 1,
|
|
36
|
+
'0x55d398326f99059ff775485246999027b3197955': 1,
|
|
37
37
|
// USDT - xDai bridge pattern (slot 3)
|
|
38
|
-
'0x4ecaba5870353805a9f068101a40e0f32ed605c6': 3,
|
|
38
|
+
'0x4ecaba5870353805a9f068101a40e0f32ed605c6': 3,
|
|
39
39
|
// USDT - Standard ERC20 deployments (slot 0)
|
|
40
40
|
// Polygon confirmed, Optimism bridged USDT (0x94b008aa...) also uses slot 0
|
|
41
41
|
// USDC (Circle native deployments - all use slot 9)
|
|
42
|
-
'0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48': 9,
|
|
43
|
-
'0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e': 9,
|
|
44
|
-
'0x0b2c639c533813f4aa9d7837caf62653d097ff85': 9,
|
|
45
|
-
'0x3c499c542cef5e3811e1192ce70d8cc03d5c3359': 9,
|
|
46
|
-
'0xaf88d065e77c8cc2239327c5edb3a432268e5831': 9,
|
|
47
|
-
'0x833589fcd6edb6e08f4c7c32d4f71b54bda02913': 9,
|
|
42
|
+
'0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48': 9,
|
|
43
|
+
'0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e': 9,
|
|
44
|
+
'0x0b2c639c533813f4aa9d7837caf62653d097ff85': 9,
|
|
45
|
+
'0x3c499c542cef5e3811e1192ce70d8cc03d5c3359': 9,
|
|
46
|
+
'0xaf88d065e77c8cc2239327c5edb3a432268e5831': 9,
|
|
47
|
+
'0x833589fcd6edb6e08f4c7c32d4f71b54bda02913': 9,
|
|
48
48
|
// USDC (BEP20 pattern on BSC - slot 1)
|
|
49
49
|
'0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d': 1, // USDC BSC (BEP20)
|
|
50
50
|
};
|
|
51
51
|
export const KNOWN_ALLOWANCE_SLOTS = {
|
|
52
52
|
// USDT allowance slots (explicit mapping for all non-standard implementations)
|
|
53
|
-
'0xdac17f958d2ee523a2206206994597c13d831ec7': 5,
|
|
54
|
-
'0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9': 52,
|
|
55
|
-
'0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7': 52,
|
|
56
|
-
'0x01bff41798a0bcf287b996046ca68b395dbc1071': 52,
|
|
57
|
-
'0x55d398326f99059ff775485246999027b3197955': 2,
|
|
58
|
-
'0x4ecaba5870353805a9f068101a40e0f32ed605c6': 4,
|
|
53
|
+
'0xdac17f958d2ee523a2206206994597c13d831ec7': 5,
|
|
54
|
+
'0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9': 52,
|
|
55
|
+
'0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7': 52,
|
|
56
|
+
'0x01bff41798a0bcf287b996046ca68b395dbc1071': 52,
|
|
57
|
+
'0x55d398326f99059ff775485246999027b3197955': 2,
|
|
58
|
+
'0x4ecaba5870353805a9f068101a40e0f32ed605c6': 4,
|
|
59
59
|
// Note: Polygon and Optimism standard bridged USDT (0x94b008aa...) use slot 1 (fallback)
|
|
60
60
|
// Note: SWEAT (slot 5) allowance auto-inferred to slot 6 via Wormhole pattern
|
|
61
61
|
// USDC allowance slots (BSC uses BEP20 pattern, not Circle FiatToken)
|