@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("../../..").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("../../..").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("../../..").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("../../..").SwapErrorRight>>;
|
|
5
5
|
};
|
|
6
6
|
export type SunioService = ReturnType<typeof sunioServiceFactory>;
|
|
@@ -78,6 +78,11 @@ const expectedQuoteResponse = [
|
|
|
78
78
|
thorchainSpecific: {
|
|
79
79
|
maxStreamingQuantity: undefined,
|
|
80
80
|
},
|
|
81
|
+
thorchainTransactionMetadata: {
|
|
82
|
+
to: '0x3624525075b88B24ecc29CE226b0CEc1fFcB6976',
|
|
83
|
+
data: '0x',
|
|
84
|
+
value: '0',
|
|
85
|
+
},
|
|
81
86
|
},
|
|
82
87
|
],
|
|
83
88
|
},
|
|
@@ -121,6 +126,11 @@ const expectedQuoteResponse = [
|
|
|
121
126
|
thorchainSpecific: {
|
|
122
127
|
maxStreamingQuantity: undefined,
|
|
123
128
|
},
|
|
129
|
+
thorchainTransactionMetadata: {
|
|
130
|
+
to: '0x3624525075b88B24ecc29CE226b0CEc1fFcB6976',
|
|
131
|
+
data: '0x',
|
|
132
|
+
value: '0',
|
|
133
|
+
},
|
|
124
134
|
},
|
|
125
135
|
],
|
|
126
136
|
},
|
|
@@ -15,23 +15,13 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) ||
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
35
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
26
|
exports.getL1ToLongtailQuote = void 0;
|
|
37
27
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
@@ -137,7 +127,7 @@ const getL1ToLongtailQuote = async (input, deps, streamingInterval, swapperName)
|
|
|
137
127
|
// This is wrong, we should get the get the value before fees or display ETH value received after the thorchain bridge
|
|
138
128
|
buyAmountBeforeFeesCryptoBaseUnit: quotedAmountOut.toString(),
|
|
139
129
|
allowanceContract: contracts_1.TS_AGGREGATOR_TOKEN_TRANSFER_PROXY_CONTRACT_MAINNET,
|
|
140
|
-
})),
|
|
130
|
+
})),
|
|
141
131
|
isLongtail: true,
|
|
142
132
|
longtailData: {
|
|
143
133
|
L1ToLongtailExpectedAmountOut: quotedAmountOut.toString(),
|
|
@@ -15,23 +15,13 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) ||
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
35
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
26
|
exports.getL1ToLongtailRate = void 0;
|
|
37
27
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
@@ -125,7 +115,7 @@ const getL1ToLongtailRate = async (input, deps, streamingInterval, swapperName)
|
|
|
125
115
|
// This is wrong, we should get the get the value before fees or display ETH value received after the thorchain bridge
|
|
126
116
|
buyAmountBeforeFeesCryptoBaseUnit: quotedAmountOut.toString(),
|
|
127
117
|
allowanceContract: contracts_1.TS_AGGREGATOR_TOKEN_TRANSFER_PROXY_CONTRACT_MAINNET,
|
|
128
|
-
})),
|
|
118
|
+
})),
|
|
129
119
|
isLongtail: true,
|
|
130
120
|
longtailData: {
|
|
131
121
|
L1ToLongtailExpectedAmountOut: quotedAmountOut.toString(),
|
|
@@ -61,7 +61,7 @@ const getLongtailToL1Quote = async (input, deps, streamingInterval, swapperName)
|
|
|
61
61
|
sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
62
62
|
sellAsset,
|
|
63
63
|
allowanceContract: contracts_1.TS_AGGREGATOR_TOKEN_TRANSFER_PROXY_CONTRACT_MAINNET,
|
|
64
|
-
})),
|
|
64
|
+
})),
|
|
65
65
|
isLongtail: true,
|
|
66
66
|
longtailData: {
|
|
67
67
|
longtailToL1ExpectedAmountOut: quotedAmountOut.toString(),
|
|
@@ -61,7 +61,7 @@ const getLongtailToL1Rate = async (input, deps, streamingInterval, swapperName)
|
|
|
61
61
|
sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
62
62
|
sellAsset,
|
|
63
63
|
allowanceContract: contracts_1.TS_AGGREGATOR_TOKEN_TRANSFER_PROXY_CONTRACT_MAINNET,
|
|
64
|
-
})),
|
|
64
|
+
})),
|
|
65
65
|
isLongtail: true,
|
|
66
66
|
longtailData: {
|
|
67
67
|
longtailToL1ExpectedAmountOut: quotedAmountOut.toString(),
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.shortenedNativeAssetNameByNativeAssetName = exports.selectBestRate = exports.getQuotedAmountOutByPool = exports.getContractDataByPool = exports.generateV3PoolAddressesAcrossFeeRange = exports.feeAmountToContractMap = exports.contractToFeeAmountMap = exports.AggregatorContract = exports.getTokenFromAsset = exports.getWrappedToken = void 0;
|
|
4
|
-
exports.getTradeType = getTradeType;
|
|
3
|
+
exports.shortenedNativeAssetNameByNativeAssetName = exports.selectBestRate = exports.getQuotedAmountOutByPool = exports.getContractDataByPool = exports.generateV3PoolAddressesAcrossFeeRange = exports.feeAmountToContractMap = exports.contractToFeeAmountMap = exports.AggregatorContract = exports.getTradeType = exports.getTokenFromAsset = exports.getWrappedToken = void 0;
|
|
5
4
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
6
5
|
const contracts_1 = require("@shapeshiftoss/contracts");
|
|
7
6
|
const sdk_core_1 = require("@uniswap/sdk-core");
|
|
@@ -47,6 +46,7 @@ function getTradeType(sellAssetPool, buyAssetPool, sellPoolId, buyPoolId) {
|
|
|
47
46
|
return undefined;
|
|
48
47
|
}
|
|
49
48
|
}
|
|
49
|
+
exports.getTradeType = getTradeType;
|
|
50
50
|
// TODO: we need to fetch these contracts dynamically, as the whitelist can change
|
|
51
51
|
var AggregatorContract;
|
|
52
52
|
(function (AggregatorContract) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getZrxTradeQuote =
|
|
3
|
+
exports.getZrxTradeQuote = void 0;
|
|
4
4
|
const chain_adapters_1 = require("@shapeshiftoss/chain-adapters");
|
|
5
5
|
const contracts_1 = require("@shapeshiftoss/contracts");
|
|
6
6
|
const utils_1 = require("@shapeshiftoss/utils");
|
|
@@ -122,3 +122,4 @@ async function getZrxTradeQuote(input, assertGetEvmChainAdapter, assetsById, zrx
|
|
|
122
122
|
}));
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
+
exports.getZrxTradeQuote = getZrxTradeQuote;
|
|
@@ -15,23 +15,13 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) ||
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
35
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
26
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
37
27
|
const types_1 = require("@shapeshiftoss/types");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getZrxTradeRate =
|
|
3
|
+
exports.getZrxTradeRate = void 0;
|
|
4
4
|
const contracts_1 = require("@shapeshiftoss/contracts");
|
|
5
5
|
const monads_1 = require("@sniptt/monads");
|
|
6
6
|
const uuid_1 = require("uuid");
|
|
@@ -78,3 +78,4 @@ async function getZrxTradeRate(input, assetsById, zrxBaseUrl) {
|
|
|
78
78
|
],
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
|
+
exports.getZrxTradeRate = getZrxTradeRate;
|
|
@@ -27,9 +27,9 @@ const fetchFromZrx = async ({ quoteOrRate, buyAsset, sellAsset, sellAmountInclud
|
|
|
27
27
|
sellAmount: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
28
28
|
taker: sellAddress,
|
|
29
29
|
swapFeeBps: (0, utils_1.bn)(affiliateBps).toNumber(),
|
|
30
|
-
swapFeeToken: (0, helpers_2.assetIdToZrxToken)(buyAsset.assetId),
|
|
30
|
+
swapFeeToken: (0, helpers_2.assetIdToZrxToken)(buyAsset.assetId),
|
|
31
31
|
slippageBps: (0, utils_1.convertDecimalPercentageToBasisPoints)(slippageTolerancePercentageDecimal).toNumber(),
|
|
32
|
-
swapFeeRecipient: maybeTreasuryAddress,
|
|
32
|
+
swapFeeRecipient: maybeTreasuryAddress,
|
|
33
33
|
feeRecipientTradeSurplus: maybeTreasuryAddress, // Where trade surplus is sent
|
|
34
34
|
},
|
|
35
35
|
});
|
|
@@ -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';
|
|
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';
|
|
|
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';
|
|
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
|
};
|
|
@@ -68,7 +68,14 @@ const checkTradeStatus = async ({ txHash, chainId, address, fetchIsSmartContract
|
|
|
68
68
|
return { buyTxHash, status: unchained_client_1.TxStatus.Pending, message };
|
|
69
69
|
}
|
|
70
70
|
catch (e) {
|
|
71
|
-
|
|
71
|
+
const message = (() => {
|
|
72
|
+
if (axios_1.default.isAxiosError(e))
|
|
73
|
+
return e.response?.data?.message ?? e.message;
|
|
74
|
+
if (e instanceof Error)
|
|
75
|
+
return e.message;
|
|
76
|
+
return String(e);
|
|
77
|
+
})();
|
|
78
|
+
console.error(`checkTradeStatus(${nativeChain}, ${txHash}): ${message}`);
|
|
72
79
|
return { buyTxHash: undefined, status: unchained_client_1.TxStatus.Unknown, message: undefined };
|
|
73
80
|
}
|
|
74
81
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Asset } from '@shapeshiftoss/types';
|
|
2
|
+
import type { SwapperConfig, SwapperName } from '../../types';
|
|
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,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getThorTxData = void 0;
|
|
4
|
+
const getInboundAddressDataForChain_1 = require("../getInboundAddressDataForChain");
|
|
5
|
+
const index_1 = require("../index");
|
|
6
|
+
const getThorTxData = async ({ sellAsset, config, swapperName, }) => {
|
|
7
|
+
// Native assets on the swapper's own chain (RUNE on THORChain, CACAO on MAYAChain)
|
|
8
|
+
// deposit via MsgDeposit and have no recipient address.
|
|
9
|
+
if (sellAsset.chainId === (0, index_1.getChainIdBySwapper)(swapperName))
|
|
10
|
+
return { vault: '' };
|
|
11
|
+
// Everything else (e.g. ATOM via THORChain, RUNE via MAYAChain) sends via MsgSend
|
|
12
|
+
// to the swapper's inbound vault on that chain.
|
|
13
|
+
const daemonUrl = (0, index_1.getDaemonUrl)(config, swapperName);
|
|
14
|
+
const res = await (0, getInboundAddressDataForChain_1.getInboundAddressDataForChain)(daemonUrl, sellAsset.assetId, true, swapperName);
|
|
15
|
+
if (res.isErr())
|
|
16
|
+
throw res.unwrapErr();
|
|
17
|
+
return { vault: res.unwrap().address };
|
|
18
|
+
};
|
|
19
|
+
exports.getThorTxData = getThorTxData;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Asset } from '@shapeshiftoss/types';
|
|
2
2
|
import type { SwapperConfig, SwapperName } from '../types';
|
|
3
3
|
import type { ThorEvmTradeQuote } from './types';
|
|
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;
|
|
@@ -15,23 +15,13 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) ||
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
35
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
26
|
exports.getL1RateOrQuote = void 0;
|
|
37
27
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
@@ -43,8 +33,10 @@ const tronweb_1 = require("tronweb");
|
|
|
43
33
|
const uuid_1 = require("uuid");
|
|
44
34
|
const index_1 = require("../index");
|
|
45
35
|
const affiliateFee_1 = require("../swappers/utils/affiliateFee");
|
|
36
|
+
const helpers_1 = require("../swappers/utils/helpers/helpers");
|
|
46
37
|
const types_1 = require("../types");
|
|
47
38
|
const utils_2 = require("../utils");
|
|
39
|
+
const cosmossdk = __importStar(require("./cosmossdk"));
|
|
48
40
|
const evm = __importStar(require("./evm"));
|
|
49
41
|
const getLimitWithManualSlippage_1 = require("./getLimitWithManualSlippage/getLimitWithManualSlippage");
|
|
50
42
|
const getQuote_1 = require("./getQuote");
|
|
@@ -164,7 +156,7 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
164
156
|
affilate: (0, index_2.getAffiliate)(swapperName),
|
|
165
157
|
});
|
|
166
158
|
};
|
|
167
|
-
const makeThorTradeRateOrQuote = ({ route, memo, allowanceContract, feeData, data, router, vault, }) => {
|
|
159
|
+
const makeThorTradeRateOrQuote = ({ route, memo, allowanceContract, feeData, data, router, vault, thorchainTransactionMetadata, }) => {
|
|
168
160
|
const buyAmountAfterFeesCryptoBaseUnit = (0, utils_1.convertPrecision)({
|
|
169
161
|
value: route.expectedAmountOutThorBaseUnit,
|
|
170
162
|
inputExponent: buyAssetNativePrecision,
|
|
@@ -218,6 +210,7 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
218
210
|
thorchainSpecific: {
|
|
219
211
|
maxStreamingQuantity: route.quote.max_streaming_quantity,
|
|
220
212
|
},
|
|
213
|
+
thorchainTransactionMetadata,
|
|
221
214
|
},
|
|
222
215
|
],
|
|
223
216
|
};
|
|
@@ -249,6 +242,11 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
249
242
|
data,
|
|
250
243
|
router,
|
|
251
244
|
vault,
|
|
245
|
+
thorchainTransactionMetadata: {
|
|
246
|
+
to: router,
|
|
247
|
+
data,
|
|
248
|
+
value: (0, helpers_1.isNativeEvmAsset)(sellAsset.assetId) ? sellAmountCryptoBaseUnit : '0',
|
|
249
|
+
},
|
|
252
250
|
feeData: {
|
|
253
251
|
protocolFees: getProtocolFees(route.quote),
|
|
254
252
|
networkFeeCryptoBaseUnit,
|
|
@@ -294,8 +292,13 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
294
292
|
})();
|
|
295
293
|
return makeThorTradeRateOrQuote({
|
|
296
294
|
route,
|
|
297
|
-
allowanceContract: '0x0',
|
|
295
|
+
allowanceContract: '0x0',
|
|
298
296
|
memo,
|
|
297
|
+
thorchainTransactionMetadata: {
|
|
298
|
+
to: vault,
|
|
299
|
+
memo,
|
|
300
|
+
value: sellAmountCryptoBaseUnit,
|
|
301
|
+
},
|
|
299
302
|
feeData,
|
|
300
303
|
});
|
|
301
304
|
}));
|
|
@@ -311,11 +314,18 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
311
314
|
case caip_1.CHAIN_NAMESPACE.CosmosSdk: {
|
|
312
315
|
const cosmosChainAdapter = assertGetCosmosSdkChainAdapter(sellAsset.chainId);
|
|
313
316
|
const { fast } = await cosmosChainAdapter.getFeeData({});
|
|
317
|
+
const { vault } = await cosmossdk.getThorTxData({ sellAsset, config, swapperName });
|
|
314
318
|
return (0, monads_1.Ok)(perRouteValues.map((route) => {
|
|
319
|
+
const memo = getMemo(route);
|
|
315
320
|
return makeThorTradeRateOrQuote({
|
|
316
321
|
route,
|
|
317
|
-
memo
|
|
318
|
-
allowanceContract: '0x0',
|
|
322
|
+
memo,
|
|
323
|
+
allowanceContract: '0x0',
|
|
324
|
+
thorchainTransactionMetadata: {
|
|
325
|
+
to: vault,
|
|
326
|
+
memo,
|
|
327
|
+
value: sellAmountCryptoBaseUnit,
|
|
328
|
+
},
|
|
319
329
|
feeData: {
|
|
320
330
|
networkFeeCryptoBaseUnit: fast.txFee,
|
|
321
331
|
protocolFees: getProtocolFees(route.quote),
|
|
@@ -329,13 +339,13 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
329
339
|
case caip_1.CHAIN_NAMESPACE.Solana: {
|
|
330
340
|
const adapter = assertGetSolanaChainAdapter(sellAsset.chainId);
|
|
331
341
|
const sendAddress = input.sendAddress;
|
|
342
|
+
const { vault } = await solana.getThorTxData({ sellAsset, config, swapperName });
|
|
332
343
|
const maybeRoutes = await Promise.allSettled(perRouteValues.map(async (route) => {
|
|
333
344
|
const memo = getMemo(route);
|
|
334
345
|
const protocolFees = getProtocolFees(route.quote);
|
|
335
346
|
const feeData = await (async () => {
|
|
336
347
|
if (!sendAddress)
|
|
337
348
|
return { networkFeeCryptoBaseUnit: undefined, protocolFees };
|
|
338
|
-
const { vault } = await solana.getThorTxData({ sellAsset, config, swapperName });
|
|
339
349
|
const memoInstruction = new web3_js_1.TransactionInstruction({
|
|
340
350
|
keys: [],
|
|
341
351
|
programId: new web3_js_1.PublicKey(SOLANA_MEMO_PROGRAM_ID),
|
|
@@ -361,6 +371,11 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
361
371
|
route,
|
|
362
372
|
allowanceContract: '0x0',
|
|
363
373
|
memo,
|
|
374
|
+
thorchainTransactionMetadata: {
|
|
375
|
+
to: vault,
|
|
376
|
+
memo,
|
|
377
|
+
value: sellAmountCryptoBaseUnit,
|
|
378
|
+
},
|
|
364
379
|
feeData,
|
|
365
380
|
});
|
|
366
381
|
}));
|
|
@@ -374,20 +389,15 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
374
389
|
return (0, monads_1.Ok)(routes);
|
|
375
390
|
}
|
|
376
391
|
case caip_1.CHAIN_NAMESPACE.Tron: {
|
|
392
|
+
const { vault } = await tron.getThorTxData({ sellAsset, config, swapperName });
|
|
377
393
|
const maybeRoutes = await Promise.allSettled(perRouteValues.map(async (route) => {
|
|
378
394
|
const memo = getMemo(route);
|
|
379
395
|
let networkFeeCryptoBaseUnit = undefined;
|
|
380
396
|
// Calculate fees for rates when we have a receive address (wallet connected)
|
|
381
|
-
if (input.quoteOrRate === 'rate' && input.receiveAddress) {
|
|
397
|
+
if (input.quoteOrRate === 'rate' && input.receiveAddress && vault) {
|
|
382
398
|
try {
|
|
383
399
|
const { sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit } = input;
|
|
384
400
|
const contractAddress = (0, utils_1.contractAddressOrUndefined)(sellAsset.assetId);
|
|
385
|
-
// Get vault address
|
|
386
|
-
const { vault } = await tron.getThorTxData({
|
|
387
|
-
sellAsset,
|
|
388
|
-
config,
|
|
389
|
-
swapperName,
|
|
390
|
-
});
|
|
391
401
|
// Estimate fees using the receive address for accurate energy calculation
|
|
392
402
|
const tronWeb = new tronweb_1.TronWeb({
|
|
393
403
|
fullHost: deps.config.VITE_TRON_NODE_URL,
|
|
@@ -400,7 +410,7 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
400
410
|
// TRC20: Estimate energy with actual recipient
|
|
401
411
|
try {
|
|
402
412
|
const result = await tronWeb.transactionBuilder.triggerConstantContract(contractAddress, 'transfer(address,uint256)', {}, [
|
|
403
|
-
{ type: 'address', value: vault },
|
|
413
|
+
{ type: 'address', value: vault },
|
|
404
414
|
{
|
|
405
415
|
type: 'uint256',
|
|
406
416
|
value: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
@@ -434,8 +444,13 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
434
444
|
// For quotes, fees will be calculated in getTronTransactionFees when executing
|
|
435
445
|
return Promise.resolve(makeThorTradeRateOrQuote({
|
|
436
446
|
route,
|
|
437
|
-
allowanceContract: '0x0',
|
|
447
|
+
allowanceContract: '0x0',
|
|
438
448
|
memo,
|
|
449
|
+
thorchainTransactionMetadata: {
|
|
450
|
+
to: vault,
|
|
451
|
+
memo,
|
|
452
|
+
value: sellAmountCryptoBaseUnit,
|
|
453
|
+
},
|
|
439
454
|
feeData: {
|
|
440
455
|
networkFeeCryptoBaseUnit,
|
|
441
456
|
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';
|
|
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,26 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getThresholdedAffiliateBps = exports.
|
|
3
|
+
exports.getThresholdedAffiliateBps = exports.getExpectedAffiliateFeeSellAssetThorBaseUnit = exports.getOutboundFeeSellAssetThorBaseUnit = void 0;
|
|
4
4
|
const utils_1 = require("@shapeshiftoss/utils");
|
|
5
5
|
const index_1 = require("../index");
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
// Convert native fee to sell asset's native precision before dividing by `assetPrice`.
|
|
7
|
+
// MAYA's CACAO is 10-dec but pool assets are 8-dec — skip this and the result is 100x off.
|
|
8
|
+
const getOutboundFeeSellAssetThorBaseUnit = (runePerAsset, sellAssetId, swapperName) => {
|
|
9
|
+
const nativeFeeSellAssetThorBaseUnit = (0, utils_1.convertPrecision)({
|
|
10
|
+
value: (0, index_1.getNativeFee)(swapperName),
|
|
11
|
+
inputExponent: (0, index_1.getNativePrecision)((0, index_1.getSwapperNativeAssetId)(swapperName), swapperName),
|
|
12
|
+
outputExponent: (0, index_1.getNativePrecision)(sellAssetId, swapperName),
|
|
13
|
+
});
|
|
14
|
+
return nativeFeeSellAssetThorBaseUnit.dividedBy(runePerAsset);
|
|
8
15
|
};
|
|
9
|
-
exports.
|
|
10
|
-
const
|
|
11
|
-
const
|
|
16
|
+
exports.getOutboundFeeSellAssetThorBaseUnit = getOutboundFeeSellAssetThorBaseUnit;
|
|
17
|
+
const getExpectedAffiliateFeeSellAssetThorBaseUnit = (sellAmountCryptoBaseUnit, sellAsset, affiliateBps, swapperName) => {
|
|
18
|
+
const sellAmountThorBaseUnit = (0, utils_1.convertPrecision)({
|
|
12
19
|
value: sellAmountCryptoBaseUnit,
|
|
13
20
|
inputExponent: sellAsset.precision,
|
|
14
21
|
outputExponent: (0, index_1.getNativePrecision)(sellAsset.assetId, swapperName),
|
|
15
22
|
});
|
|
16
23
|
const affiliatePercent = (0, utils_1.convertBasisPointsToDecimalPercentage)(affiliateBps);
|
|
17
|
-
return
|
|
24
|
+
return sellAmountThorBaseUnit.times(affiliatePercent);
|
|
18
25
|
};
|
|
19
|
-
exports.
|
|
26
|
+
exports.getExpectedAffiliateFeeSellAssetThorBaseUnit = getExpectedAffiliateFeeSellAssetThorBaseUnit;
|
|
20
27
|
// don't apply an affiliate fee if it's below the outbound fee for the inbound pool
|
|
21
28
|
const getThresholdedAffiliateBps = async ({ sellAsset, affiliateBps, sellAmountCryptoBaseUnit, config, swapperName, }) => {
|
|
22
29
|
const midgardUrl = (0, index_1.getMidgardUrl)(config, swapperName);
|
|
23
|
-
const
|
|
30
|
+
const outboundFeeSellAssetThorBaseUnit = await (async () => {
|
|
24
31
|
if ((0, index_1.isNativeAsset)(sellAsset.assetId, swapperName))
|
|
25
32
|
return (0, index_1.getNativeFee)(swapperName);
|
|
26
33
|
const sellPoolId = (0, index_1.getPoolAssetId)({ assetId: sellAsset.assetId, swapperName });
|
|
@@ -29,12 +36,12 @@ const getThresholdedAffiliateBps = async ({ sellAsset, affiliateBps, sellAmountC
|
|
|
29
36
|
if (res.isErr())
|
|
30
37
|
throw res.unwrapErr();
|
|
31
38
|
const pool = res.unwrap().data;
|
|
32
|
-
// calculate the rune outbound fee denominated in the sell asset, in
|
|
33
|
-
return (0, exports.
|
|
39
|
+
// calculate the rune outbound fee denominated in the sell asset, in thor base units
|
|
40
|
+
return (0, exports.getOutboundFeeSellAssetThorBaseUnit)(pool.assetPrice, sellAsset.assetId, swapperName);
|
|
34
41
|
})();
|
|
35
|
-
// calculate the expected affiliate fee, in
|
|
36
|
-
const
|
|
37
|
-
const isAffiliateFeeBelowOutboundFee =
|
|
42
|
+
// calculate the expected affiliate fee, in thor base units
|
|
43
|
+
const expectedAffiliateFeeSellAssetThorBaseUnit = (0, exports.getExpectedAffiliateFeeSellAssetThorBaseUnit)(sellAmountCryptoBaseUnit, sellAsset, affiliateBps, swapperName);
|
|
44
|
+
const isAffiliateFeeBelowOutboundFee = expectedAffiliateFeeSellAssetThorBaseUnit.lte(outboundFeeSellAssetThorBaseUnit);
|
|
38
45
|
return isAffiliateFeeBelowOutboundFee ? '0' : affiliateBps;
|
|
39
46
|
};
|
|
40
47
|
exports.getThresholdedAffiliateBps = getThresholdedAffiliateBps;
|