aftermath-ts-sdk 1.1.96 → 1.2.0-refactor.0
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/general/historicalData/historicalData.d.ts +1 -1
- package/dist/general/historicalData/historicalData.d.ts.map +1 -1
- package/dist/general/nfts/nftsApi.d.ts +1 -5
- package/dist/general/nfts/nftsApi.d.ts.map +1 -1
- package/dist/general/nfts/nftsApi.js +15 -29
- package/dist/general/nfts/nftsApiCasting.d.ts +0 -1
- package/dist/general/nfts/nftsApiCasting.d.ts.map +1 -1
- package/dist/general/nfts/nftsApiCasting.js +0 -10
- package/dist/general/nfts/nftsTypes.d.ts +0 -1
- package/dist/general/nfts/nftsTypes.d.ts.map +1 -1
- package/dist/general/prices/{coingecko/coinGeckoTypes.d.ts → coinGeckoTypes.d.ts} +1 -1
- package/dist/general/prices/coinGeckoTypes.d.ts.map +1 -0
- package/dist/general/providers/aftermath.d.ts.map +1 -1
- package/dist/general/providers/aftermath.js +1 -2
- package/dist/general/providers/aftermathApi.d.ts +1 -34
- package/dist/general/providers/aftermathApi.d.ts.map +1 -1
- package/dist/general/providers/aftermathApi.js +2 -90
- package/dist/general/types/castingTypes.d.ts +0 -7
- package/dist/general/types/castingTypes.d.ts.map +1 -1
- package/dist/general/types/configTypes.d.ts +0 -6
- package/dist/general/types/configTypes.d.ts.map +1 -1
- package/dist/general/types/generalTypes.d.ts +0 -3
- package/dist/general/types/generalTypes.d.ts.map +1 -1
- package/dist/general/types/index.d.ts +1 -0
- package/dist/general/types/index.d.ts.map +1 -1
- package/dist/general/types/index.js +1 -0
- package/dist/general/utils/helpers.d.ts +1 -16
- package/dist/general/utils/helpers.d.ts.map +1 -1
- package/dist/general/utils/helpers.js +2 -32
- package/dist/general/utils/index.d.ts +0 -1
- package/dist/general/utils/index.d.ts.map +1 -1
- package/dist/general/utils/index.js +0 -1
- package/dist/packages/coin/api/coinApi.d.ts +1 -12
- package/dist/packages/coin/api/coinApi.d.ts.map +1 -1
- package/dist/packages/coin/api/coinApi.js +0 -123
- package/dist/packages/dca/api/dcaApi.d.ts +1 -28
- package/dist/packages/dca/api/dcaApi.d.ts.map +1 -1
- package/dist/packages/dca/api/dcaApi.js +0 -172
- package/dist/packages/farms/api/farmsApi.d.ts +1 -24
- package/dist/packages/farms/api/farmsApi.d.ts.map +1 -1
- package/dist/packages/farms/api/farmsApi.js +0 -69
- package/dist/packages/farms/api/farmsApiCasting.d.ts +2 -3
- package/dist/packages/farms/api/farmsApiCasting.d.ts.map +1 -1
- package/dist/packages/farms/api/farmsApiCasting.js +0 -45
- package/dist/packages/farms/api/farmsApiCastingTypes.d.ts +0 -9
- package/dist/packages/farms/api/farmsApiCastingTypes.d.ts.map +1 -1
- package/dist/packages/faucet/api/faucetApi.d.ts +0 -5
- package/dist/packages/faucet/api/faucetApi.d.ts.map +1 -1
- package/dist/packages/faucet/api/faucetApi.js +2 -29
- package/dist/packages/faucet/faucet.d.ts +3 -2
- package/dist/packages/faucet/faucet.d.ts.map +1 -1
- package/dist/packages/faucet/faucet.js +2 -2
- package/dist/packages/leveragedStaking/api/leveragedStakingApi.d.ts.map +1 -1
- package/dist/packages/leveragedStaking/api/leveragedStakingApi.js +383 -298
- package/dist/packages/nftAmm/nftAmmMarket.d.ts +9 -5
- package/dist/packages/nftAmm/nftAmmMarket.d.ts.map +1 -1
- package/dist/packages/nftAmm/nftAmmMarket.js +34 -6
- package/dist/packages/oracle/api/oracleApi.d.ts +1 -10
- package/dist/packages/oracle/api/oracleApi.d.ts.map +1 -1
- package/dist/packages/oracle/api/oracleApi.js +0 -38
- package/dist/packages/perpetuals/api/perpetualsApi.d.ts +2 -58
- package/dist/packages/perpetuals/api/perpetualsApi.d.ts.map +1 -1
- package/dist/packages/perpetuals/api/perpetualsApi.js +0 -735
- package/dist/packages/pools/api/poolsApi.d.ts +2 -217
- package/dist/packages/pools/api/poolsApi.d.ts.map +1 -1
- package/dist/packages/pools/api/poolsApi.js +0 -752
- package/dist/packages/pools/api/poolsApiCasting.d.ts +3 -15
- package/dist/packages/pools/api/poolsApiCasting.d.ts.map +1 -1
- package/dist/packages/pools/api/poolsApiCasting.js +0 -86
- package/dist/packages/pools/api/poolsApiCastingTypes.d.ts +1 -15
- package/dist/packages/pools/api/poolsApiCastingTypes.d.ts.map +1 -1
- package/dist/packages/pools/pools.d.ts +4 -1
- package/dist/packages/pools/pools.d.ts.map +1 -1
- package/dist/packages/pools/pools.js +5 -0
- package/dist/packages/router/api/routerApi.d.ts +2 -116
- package/dist/packages/router/api/routerApi.d.ts.map +1 -1
- package/dist/packages/router/api/routerApi.js +3 -345
- package/dist/packages/router/api/routerApiCasting.d.ts +2 -5
- package/dist/packages/router/api/routerApiCasting.d.ts.map +1 -1
- package/dist/packages/router/api/routerApiCasting.js +0 -104
- package/dist/packages/router/api/routerApiCastingTypes.d.ts +1 -13
- package/dist/packages/router/api/routerApiCastingTypes.d.ts.map +1 -1
- package/dist/packages/router/routerTypes.d.ts +2 -34
- package/dist/packages/router/routerTypes.d.ts.map +1 -1
- package/dist/packages/staking/api/stakingApi.d.ts +2 -50
- package/dist/packages/staking/api/stakingApi.d.ts.map +1 -1
- package/dist/packages/staking/api/stakingApi.js +0 -226
- package/dist/packages/staking/api/stakingApiCasting.d.ts +2 -4
- package/dist/packages/staking/api/stakingApiCasting.d.ts.map +1 -1
- package/dist/packages/staking/api/stakingApiCasting.js +0 -21
- package/dist/packages/staking/api/stakingApiCastingTypes.d.ts +1 -8
- package/dist/packages/staking/api/stakingApiCastingTypes.d.ts.map +1 -1
- package/dist/packages/staking/stakingTypes.d.ts +2 -0
- package/dist/packages/staking/stakingTypes.d.ts.map +1 -1
- package/dist/packages/sui/api/suiApi.d.ts +1 -2
- package/dist/packages/sui/api/suiApi.d.ts.map +1 -1
- package/dist/packages/sui/api/suiApi.js +0 -3
- package/package.json +1 -1
- package/dist/general/dynamicGas/dynamicGasApi.d.ts +0 -15
- package/dist/general/dynamicGas/dynamicGasApi.d.ts.map +0 -1
- package/dist/general/dynamicGas/dynamicGasApi.js +0 -87
- package/dist/general/historicalData/historicalDataApi.d.ts +0 -9
- package/dist/general/historicalData/historicalDataApi.d.ts.map +0 -1
- package/dist/general/historicalData/historicalDataApi.js +0 -13
- package/dist/general/historicalData/historicalDataApiInterface.d.ts +0 -12
- package/dist/general/historicalData/historicalDataApiInterface.d.ts.map +0 -1
- package/dist/general/historicalData/historicalDataApiInterface.js +0 -2
- package/dist/general/historicalData/placeholderHistoricalDataApi.d.ts +0 -13
- package/dist/general/historicalData/placeholderHistoricalDataApi.d.ts.map +0 -1
- package/dist/general/historicalData/placeholderHistoricalDataApi.js +0 -26
- package/dist/general/prices/coingecko/coinGeckoApiHelpers.d.ts +0 -22
- package/dist/general/prices/coingecko/coinGeckoApiHelpers.d.ts.map +0 -1
- package/dist/general/prices/coingecko/coinGeckoApiHelpers.js +0 -179
- package/dist/general/prices/coingecko/coinGeckoPricesApi.d.ts +0 -23
- package/dist/general/prices/coingecko/coinGeckoPricesApi.d.ts.map +0 -1
- package/dist/general/prices/coingecko/coinGeckoPricesApi.js +0 -113
- package/dist/general/prices/coingecko/coinGeckoTypes.d.ts.map +0 -1
- package/dist/general/prices/placeholder/placeholderPricesApi.d.ts +0 -20
- package/dist/general/prices/placeholder/placeholderPricesApi.d.ts.map +0 -1
- package/dist/general/prices/placeholder/placeholderPricesApi.js +0 -85
- package/dist/general/prices/pricesApiInterface.d.ts +0 -13
- package/dist/general/prices/pricesApiInterface.d.ts.map +0 -1
- package/dist/general/prices/pricesApiInterface.js +0 -2
- package/dist/general/prices/pyth/pythPricesApi.d.ts +0 -2
- package/dist/general/prices/pyth/pythPricesApi.d.ts.map +0 -1
- package/dist/general/prices/pyth/pythPricesApi.js +0 -52
- package/dist/general/prices/pyth/pythPricesApiHelpers.d.ts +0 -13
- package/dist/general/prices/pyth/pythPricesApiHelpers.d.ts.map +0 -1
- package/dist/general/prices/pyth/pythPricesApiHelpers.js +0 -77
- package/dist/general/prices/router/routerPricesApi.d.ts +0 -18
- package/dist/general/prices/router/routerPricesApi.d.ts.map +0 -1
- package/dist/general/prices/router/routerPricesApi.js +0 -126
- package/dist/general/utils/indexerCaller.d.ts +0 -14
- package/dist/general/utils/indexerCaller.d.ts.map +0 -1
- package/dist/general/utils/indexerCaller.js +0 -129
- /package/dist/general/prices/{coingecko/coinGeckoTypes.js → coinGeckoTypes.js} +0 -0
|
@@ -10,12 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.RouterApi = void 0;
|
|
13
|
-
const transactions_1 = require("@mysten/sui/transactions");
|
|
14
|
-
const __1 = require("../../..");
|
|
15
13
|
const eventsApiHelpers_1 = require("../../../general/apiHelpers/eventsApiHelpers");
|
|
16
14
|
const routerApiCasting_1 = require("./routerApiCasting");
|
|
17
|
-
const transactions_2 = require("@mysten/sui.js/transactions");
|
|
18
|
-
const transactionsApiHelpers_1 = require("../../../general/apiHelpers/transactionsApiHelpers");
|
|
19
15
|
/**
|
|
20
16
|
* RouterApi class provides methods for interacting with the Aftermath Router API.
|
|
21
17
|
* @class
|
|
@@ -32,302 +28,6 @@ class RouterApi {
|
|
|
32
28
|
constructor(Provider) {
|
|
33
29
|
this.Provider = Provider;
|
|
34
30
|
// =========================================================================
|
|
35
|
-
// Public Methods
|
|
36
|
-
// =========================================================================
|
|
37
|
-
// =========================================================================
|
|
38
|
-
// Inspections
|
|
39
|
-
// =========================================================================
|
|
40
|
-
/**
|
|
41
|
-
* Fetches the total volume of swaps within a specified duration.
|
|
42
|
-
* @param inputs - The inputs for fetching the total volume.
|
|
43
|
-
* @returns A Promise that resolves to an array of total volumes.
|
|
44
|
-
*/
|
|
45
|
-
this.fetchVolume = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
const { durationMs } = inputs;
|
|
47
|
-
return this.Provider.indexerCaller.fetchIndexer(`router/swap-volume/${durationMs}`);
|
|
48
|
-
});
|
|
49
|
-
// =========================================================================
|
|
50
|
-
// Coin Paths
|
|
51
|
-
// =========================================================================
|
|
52
|
-
this.supportedCoins = () => {
|
|
53
|
-
return this.Provider.indexerCaller.fetchIndexer("router/supported-coins", undefined, undefined, undefined, undefined, true);
|
|
54
|
-
};
|
|
55
|
-
this.searchSupportedCoins = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
56
|
-
const { filter } = inputs;
|
|
57
|
-
const coinTypes = yield this.supportedCoins();
|
|
58
|
-
if (coinTypes.includes(filter))
|
|
59
|
-
return [filter];
|
|
60
|
-
const coinMetadatas = (yield Promise.all(coinTypes.map((coin) => this.Provider.Coin().fetchCoinMetadata({ coin })))).reduce((acc, metadata, index) => (Object.assign(Object.assign({}, acc), { [coinTypes[index]]: metadata })), {});
|
|
61
|
-
return __1.Helpers.uniqueArray([
|
|
62
|
-
...__1.Coin.filterCoinsByMetadata({
|
|
63
|
-
filter: filter,
|
|
64
|
-
coinMetadatas,
|
|
65
|
-
}),
|
|
66
|
-
...__1.Coin.filterCoinsByType({ filter, coinTypes }),
|
|
67
|
-
]);
|
|
68
|
-
});
|
|
69
|
-
// =========================================================================
|
|
70
|
-
// Routing
|
|
71
|
-
// =========================================================================
|
|
72
|
-
/**
|
|
73
|
-
* Fetches the complete trade route given an input amount of a specified coin type.
|
|
74
|
-
* @param inputs An object containing the necessary inputs for the trade route calculation.
|
|
75
|
-
* @returns A Promise that resolves to a RouterCompleteTradeRoute object.
|
|
76
|
-
*/
|
|
77
|
-
this.fetchCompleteTradeRouteGivenAmountIn = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
var _a, _b;
|
|
79
|
-
const { coinInType, coinOutType, coinInAmount, referrer, externalFee } = inputs;
|
|
80
|
-
const { paths, output_amount } = yield this.Provider.indexerCaller.fetchIndexer("router/forward-trade-route", Object.assign({ from_coin_type: __1.Helpers.addLeadingZeroesToType(coinInType), to_coin_type: __1.Helpers.addLeadingZeroesToType(coinOutType),
|
|
81
|
-
// NOTE: is this conversion safe ?
|
|
82
|
-
input_amount: Number(coinInAmount), referred: referrer !== undefined }, ("protocolBlacklist" in inputs
|
|
83
|
-
? {
|
|
84
|
-
protocol_blacklist: (_a = inputs.protocolBlacklist) === null || _a === void 0 ? void 0 : _a.map(routerApiCasting_1.RouterApiCasting.routerProtocolNameToRouterServiceProtocol),
|
|
85
|
-
}
|
|
86
|
-
: "protocolWhitelist" in inputs
|
|
87
|
-
? {
|
|
88
|
-
protocol_whitelist: (_b = inputs.protocolWhitelist) === null || _b === void 0 ? void 0 : _b.map(routerApiCasting_1.RouterApiCasting.routerProtocolNameToRouterServiceProtocol),
|
|
89
|
-
}
|
|
90
|
-
: {})), undefined, undefined, undefined, true);
|
|
91
|
-
const completeRoute = yield this.fetchAddNetTradeFeePercentageToCompleteTradeRoute({
|
|
92
|
-
completeRoute: __1.Casting.router.routerCompleteTradeRouteFromServicePaths(paths),
|
|
93
|
-
});
|
|
94
|
-
return Object.assign(Object.assign({}, completeRoute), {
|
|
95
|
-
// NOTE: should these be here ?
|
|
96
|
-
referrer,
|
|
97
|
-
externalFee });
|
|
98
|
-
});
|
|
99
|
-
/**
|
|
100
|
-
* Fetches the complete trade route given the output amount of the trade.
|
|
101
|
-
* @param inputs - An object containing the necessary inputs for fetching the trade route.
|
|
102
|
-
* @returns A Promise that resolves to a RouterCompleteTradeRoute object.
|
|
103
|
-
*/
|
|
104
|
-
this.fetchCompleteTradeRouteGivenAmountOut = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
105
|
-
var _c, _d, _e;
|
|
106
|
-
const { coinInType, coinOutType, coinOutAmount, referrer, externalFee, slippage, } = inputs;
|
|
107
|
-
const { paths } = yield this.Provider.indexerCaller.fetchIndexer("router/backward-trade-route", Object.assign({ from_coin_type: __1.Helpers.addLeadingZeroesToType(coinInType), to_coin_type: __1.Helpers.addLeadingZeroesToType(coinOutType),
|
|
108
|
-
// NOTE: is this conversion safe ?
|
|
109
|
-
output_amount: Math.ceil((1 + slippage + ((_c = externalFee === null || externalFee === void 0 ? void 0 : externalFee.feePercentage) !== null && _c !== void 0 ? _c : 0)) *
|
|
110
|
-
Number(coinOutAmount)), referred: referrer !== undefined }, ("protocolBlacklist" in inputs
|
|
111
|
-
? {
|
|
112
|
-
protocol_blacklist: (_d = inputs.protocolBlacklist) === null || _d === void 0 ? void 0 : _d.map(routerApiCasting_1.RouterApiCasting.routerProtocolNameToRouterServiceProtocol),
|
|
113
|
-
}
|
|
114
|
-
: "protocolWhitelist" in inputs
|
|
115
|
-
? {
|
|
116
|
-
protocol_whitelist: (_e = inputs.protocolWhitelist) === null || _e === void 0 ? void 0 : _e.map(routerApiCasting_1.RouterApiCasting.routerProtocolNameToRouterServiceProtocol),
|
|
117
|
-
}
|
|
118
|
-
: {})), undefined, undefined, undefined, true);
|
|
119
|
-
const completeRoute = yield this.fetchAddNetTradeFeePercentageToCompleteTradeRoute({
|
|
120
|
-
completeRoute: __1.Casting.router.routerCompleteTradeRouteFromServicePaths(paths),
|
|
121
|
-
});
|
|
122
|
-
return Object.assign(Object.assign({}, completeRoute), {
|
|
123
|
-
// NOTE: should these be here ?
|
|
124
|
-
referrer,
|
|
125
|
-
externalFee,
|
|
126
|
-
slippage });
|
|
127
|
-
});
|
|
128
|
-
this.fetchCompleteTradeRouteAndTxGivenAmountIn = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
129
|
-
var _f, _g, _h;
|
|
130
|
-
const { coinInType, coinOutType, coinInAmount, walletAddress, referrer, externalFee, coinIn, isSponsoredTx, slippage, transferCoinOut, } = inputs;
|
|
131
|
-
const initTx = (_f = inputs.tx) !== null && _f !== void 0 ? _f : new transactions_1.Transaction();
|
|
132
|
-
if (walletAddress)
|
|
133
|
-
initTx.setSender(walletAddress);
|
|
134
|
-
const coinTxArg = coinIn !== null && coinIn !== void 0 ? coinIn : (walletAddress
|
|
135
|
-
? yield this.Provider.Coin().fetchCoinWithAmountTx({
|
|
136
|
-
tx: initTx,
|
|
137
|
-
coinAmount: coinInAmount,
|
|
138
|
-
coinType: coinInType,
|
|
139
|
-
walletAddress,
|
|
140
|
-
isSponsoredTx,
|
|
141
|
-
})
|
|
142
|
-
: (() => {
|
|
143
|
-
throw new Error("no walletAddress provided");
|
|
144
|
-
})());
|
|
145
|
-
const txBytes = yield initTx.build({
|
|
146
|
-
client: this.Provider.provider,
|
|
147
|
-
onlyTransactionKind: true,
|
|
148
|
-
});
|
|
149
|
-
const b64TxBytes = Buffer.from(txBytes).toString("base64");
|
|
150
|
-
const { output_coin, tx_kind, output_amount, paths } = yield this.Provider.indexerCaller.fetchIndexer("router/forward-trade-route-tx", Object.assign({ slippage,
|
|
151
|
-
referrer, from_coin_type: __1.Helpers.addLeadingZeroesToType(coinInType), to_coin_type: __1.Helpers.addLeadingZeroesToType(coinOutType),
|
|
152
|
-
// NOTE: is this conversion safe ?
|
|
153
|
-
input_amount: Number(coinInAmount), input_coin: __1.Helpers.transactions.serviceCoinDataFromCoinTxArg({
|
|
154
|
-
coinTxArg,
|
|
155
|
-
}), tx_kind: b64TxBytes, router_fee_recipient: externalFee === null || externalFee === void 0 ? void 0 : externalFee.recipient,
|
|
156
|
-
// NOTE: is this conversion safe ?
|
|
157
|
-
router_fee: externalFee
|
|
158
|
-
? Number(__1.Casting.numberToFixedBigInt(externalFee.feePercentage))
|
|
159
|
-
: undefined }, ("protocolBlacklist" in inputs
|
|
160
|
-
? {
|
|
161
|
-
protocol_blacklist: (_g = inputs.protocolBlacklist) === null || _g === void 0 ? void 0 : _g.map(routerApiCasting_1.RouterApiCasting.routerProtocolNameToRouterServiceProtocol),
|
|
162
|
-
}
|
|
163
|
-
: "protocolWhitelist" in inputs
|
|
164
|
-
? {
|
|
165
|
-
protocol_whitelist: (_h = inputs.protocolWhitelist) === null || _h === void 0 ? void 0 : _h.map(routerApiCasting_1.RouterApiCasting.routerProtocolNameToRouterServiceProtocol),
|
|
166
|
-
}
|
|
167
|
-
: {})), undefined, undefined, undefined, true);
|
|
168
|
-
const tx = transactions_1.Transaction.fromKind(tx_kind);
|
|
169
|
-
transactionsApiHelpers_1.TransactionsApiHelpers.transferTxMetadata({
|
|
170
|
-
initTx,
|
|
171
|
-
newTx: tx,
|
|
172
|
-
});
|
|
173
|
-
const coinOut = __1.Helpers.transactions.coinTxArgFromServiceCoinData({
|
|
174
|
-
serviceCoinData: output_coin,
|
|
175
|
-
});
|
|
176
|
-
if (transferCoinOut && walletAddress) {
|
|
177
|
-
tx.transferObjects([coinOut], walletAddress);
|
|
178
|
-
}
|
|
179
|
-
const completeRoute = yield this.fetchAddNetTradeFeePercentageToCompleteTradeRoute({
|
|
180
|
-
completeRoute: __1.Casting.router.routerCompleteTradeRouteFromServicePaths(paths),
|
|
181
|
-
});
|
|
182
|
-
return {
|
|
183
|
-
tx,
|
|
184
|
-
coinOut,
|
|
185
|
-
coinOutAmount: BigInt(Math.round(output_amount)),
|
|
186
|
-
completeRoute: Object.assign(Object.assign({}, completeRoute), { referrer,
|
|
187
|
-
externalFee }),
|
|
188
|
-
};
|
|
189
|
-
});
|
|
190
|
-
this.fetchCompleteTradeRouteAndTxGivenAmountOut = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
191
|
-
var _j;
|
|
192
|
-
const { coinInType, walletAddress, coinIn, isSponsoredTx, transferCoinOut, } = inputs;
|
|
193
|
-
const completeRoute = yield this.fetchCompleteTradeRouteGivenAmountOut(inputs);
|
|
194
|
-
const initTx = (_j = inputs.tx) !== null && _j !== void 0 ? _j : new transactions_1.Transaction();
|
|
195
|
-
if (walletAddress)
|
|
196
|
-
initTx.setSender(walletAddress);
|
|
197
|
-
const coinTxArg = coinIn !== null && coinIn !== void 0 ? coinIn : (walletAddress
|
|
198
|
-
? yield this.Provider.Coin().fetchCoinWithAmountTx({
|
|
199
|
-
tx: initTx,
|
|
200
|
-
coinAmount: completeRoute.coinIn.amount,
|
|
201
|
-
coinType: coinInType,
|
|
202
|
-
walletAddress,
|
|
203
|
-
isSponsoredTx,
|
|
204
|
-
})
|
|
205
|
-
: (() => {
|
|
206
|
-
throw new Error("no walletAddress provided");
|
|
207
|
-
})());
|
|
208
|
-
const { tx, coinOut } = yield this.fetchTxForCompleteTradeRoute(Object.assign(Object.assign({}, inputs), { completeRoute, coinInId: coinTxArg }));
|
|
209
|
-
if (transferCoinOut && walletAddress) {
|
|
210
|
-
tx.transferObjects([coinOut], walletAddress);
|
|
211
|
-
}
|
|
212
|
-
return {
|
|
213
|
-
tx,
|
|
214
|
-
coinOut,
|
|
215
|
-
coinInAmount: completeRoute.coinIn.amount,
|
|
216
|
-
completeRoute,
|
|
217
|
-
};
|
|
218
|
-
});
|
|
219
|
-
// =========================================================================
|
|
220
|
-
// Transactions
|
|
221
|
-
// =========================================================================
|
|
222
|
-
this.fetchTxForCompleteTradeRoute = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
223
|
-
var _k;
|
|
224
|
-
const { completeRoute, walletAddress, coinInId, isSponsoredTx, slippage, transferCoinOut, } = inputs;
|
|
225
|
-
const externalFee = inputs.completeRoute.externalFee;
|
|
226
|
-
const referrer = inputs.completeRoute.referrer;
|
|
227
|
-
const initTx = (_k = inputs.tx) !== null && _k !== void 0 ? _k : new transactions_1.Transaction();
|
|
228
|
-
if (walletAddress)
|
|
229
|
-
initTx.setSender(walletAddress);
|
|
230
|
-
const coinTxArg = coinInId !== null && coinInId !== void 0 ? coinInId : (walletAddress
|
|
231
|
-
? yield this.Provider.Coin().fetchCoinWithAmountTx({
|
|
232
|
-
tx: initTx,
|
|
233
|
-
coinAmount: completeRoute.coinIn.amount,
|
|
234
|
-
coinType: completeRoute.coinIn.type,
|
|
235
|
-
walletAddress,
|
|
236
|
-
isSponsoredTx,
|
|
237
|
-
})
|
|
238
|
-
: (() => {
|
|
239
|
-
throw new Error("no walletAddress provided");
|
|
240
|
-
})());
|
|
241
|
-
const txBytes = yield initTx.build({
|
|
242
|
-
client: this.Provider.provider,
|
|
243
|
-
onlyTransactionKind: true,
|
|
244
|
-
});
|
|
245
|
-
const b64TxBytes = Buffer.from(txBytes).toString("base64");
|
|
246
|
-
const { output_coin, tx_kind } = yield this.Provider.indexerCaller.fetchIndexer("router/tx-from-trade-route", {
|
|
247
|
-
slippage,
|
|
248
|
-
referrer,
|
|
249
|
-
paths: __1.Casting.router.routerServicePathsFromCompleteTradeRoute(completeRoute),
|
|
250
|
-
input_coin: __1.Helpers.transactions.serviceCoinDataFromCoinTxArg({
|
|
251
|
-
coinTxArg,
|
|
252
|
-
}),
|
|
253
|
-
tx_kind: b64TxBytes,
|
|
254
|
-
router_fee_recipient: externalFee === null || externalFee === void 0 ? void 0 : externalFee.recipient,
|
|
255
|
-
// NOTE: is this conversion safe ?
|
|
256
|
-
router_fee: externalFee
|
|
257
|
-
? Number(__1.Casting.numberToFixedBigInt(externalFee.feePercentage))
|
|
258
|
-
: undefined,
|
|
259
|
-
}, undefined, undefined, undefined, true);
|
|
260
|
-
const tx = transactions_1.Transaction.fromKind(tx_kind);
|
|
261
|
-
transactionsApiHelpers_1.TransactionsApiHelpers.transferTxMetadata({
|
|
262
|
-
initTx,
|
|
263
|
-
newTx: tx,
|
|
264
|
-
});
|
|
265
|
-
const coinOut = __1.Helpers.transactions.coinTxArgFromServiceCoinData({
|
|
266
|
-
serviceCoinData: output_coin,
|
|
267
|
-
});
|
|
268
|
-
if (transferCoinOut && walletAddress) {
|
|
269
|
-
tx.transferObjects([coinOut], walletAddress);
|
|
270
|
-
}
|
|
271
|
-
return {
|
|
272
|
-
tx,
|
|
273
|
-
coinOut,
|
|
274
|
-
};
|
|
275
|
-
});
|
|
276
|
-
this.fetchTxForCompleteTradeRouteV0 = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
277
|
-
var _l;
|
|
278
|
-
const { completeRoute, walletAddress, coinInId, isSponsoredTx, slippage, transferCoinOut, } = inputs;
|
|
279
|
-
const externalFee = inputs.completeRoute.externalFee;
|
|
280
|
-
const referrer = inputs.completeRoute.referrer;
|
|
281
|
-
const initTx = (_l = inputs.tx) !== null && _l !== void 0 ? _l : new transactions_2.TransactionBlock();
|
|
282
|
-
if (walletAddress)
|
|
283
|
-
initTx.setSender(walletAddress);
|
|
284
|
-
const coinTxArg = coinInId !== null && coinInId !== void 0 ? coinInId : (walletAddress
|
|
285
|
-
? yield this.Provider.Coin().fetchCoinWithAmountTx({
|
|
286
|
-
tx: initTx,
|
|
287
|
-
coinAmount: completeRoute.coinIn.amount,
|
|
288
|
-
coinType: completeRoute.coinIn.type,
|
|
289
|
-
walletAddress,
|
|
290
|
-
isSponsoredTx,
|
|
291
|
-
})
|
|
292
|
-
: (() => {
|
|
293
|
-
throw new Error("no walletAddress provided");
|
|
294
|
-
})());
|
|
295
|
-
const txBytes = yield initTx.build({
|
|
296
|
-
client: this.Provider.providerV0,
|
|
297
|
-
onlyTransactionKind: true,
|
|
298
|
-
});
|
|
299
|
-
const b64TxBytes = Buffer.from(txBytes).toString("base64");
|
|
300
|
-
const { output_coin, tx_kind } = yield this.Provider.indexerCaller.fetchIndexer("router/tx-from-trade-route", {
|
|
301
|
-
slippage,
|
|
302
|
-
referrer,
|
|
303
|
-
paths: __1.Casting.router.routerServicePathsFromCompleteTradeRoute(completeRoute),
|
|
304
|
-
input_coin: __1.Helpers.transactions.serviceCoinDataFromCoinTxArgV0({
|
|
305
|
-
coinTxArg,
|
|
306
|
-
}),
|
|
307
|
-
tx_kind: b64TxBytes,
|
|
308
|
-
router_fee_recipient: externalFee === null || externalFee === void 0 ? void 0 : externalFee.recipient,
|
|
309
|
-
// NOTE: is this conversion safe ?
|
|
310
|
-
router_fee: externalFee
|
|
311
|
-
? Number(__1.Casting.numberToFixedBigInt(externalFee.feePercentage))
|
|
312
|
-
: undefined,
|
|
313
|
-
}, undefined, undefined, undefined, true);
|
|
314
|
-
const tx = transactions_2.TransactionBlock.fromKind(tx_kind);
|
|
315
|
-
transactionsApiHelpers_1.TransactionsApiHelpers.transferTxMetadataV0({
|
|
316
|
-
initTx,
|
|
317
|
-
newTx: tx,
|
|
318
|
-
});
|
|
319
|
-
const coinOut = __1.Helpers.transactions.coinTxArgFromServiceCoinDataV0({
|
|
320
|
-
serviceCoinData: output_coin,
|
|
321
|
-
});
|
|
322
|
-
if (transferCoinOut && walletAddress) {
|
|
323
|
-
tx.transferObjects([coinOut], walletAddress);
|
|
324
|
-
}
|
|
325
|
-
return {
|
|
326
|
-
tx,
|
|
327
|
-
coinOut,
|
|
328
|
-
};
|
|
329
|
-
});
|
|
330
|
-
// =========================================================================
|
|
331
31
|
// Events
|
|
332
32
|
// =========================================================================
|
|
333
33
|
// =========================================================================
|
|
@@ -374,6 +74,9 @@ class RouterApi {
|
|
|
374
74
|
};
|
|
375
75
|
}
|
|
376
76
|
// =========================================================================
|
|
77
|
+
// Public Methods
|
|
78
|
+
// =========================================================================
|
|
79
|
+
// =========================================================================
|
|
377
80
|
// Events
|
|
378
81
|
// =========================================================================
|
|
379
82
|
/**
|
|
@@ -395,51 +98,6 @@ class RouterApi {
|
|
|
395
98
|
}, eventFromEventOnChain: routerApiCasting_1.RouterApiCasting.routerTradeEventFromOnChain }));
|
|
396
99
|
});
|
|
397
100
|
}
|
|
398
|
-
// =========================================================================
|
|
399
|
-
// Private Helpers
|
|
400
|
-
// =========================================================================
|
|
401
|
-
fetchAddNetTradeFeePercentageToCompleteTradeRoute(inputs) {
|
|
402
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
403
|
-
const { completeRoute } = inputs;
|
|
404
|
-
const coinsWithFees = completeRoute.routes
|
|
405
|
-
.reduce((acc, route) => [...acc, ...route.paths], [])
|
|
406
|
-
.reduce((acc, path) => [
|
|
407
|
-
...acc,
|
|
408
|
-
{
|
|
409
|
-
coinType: path.coinIn.type,
|
|
410
|
-
fee: path.coinIn.tradeFee,
|
|
411
|
-
},
|
|
412
|
-
{
|
|
413
|
-
coinType: path.coinOut.type,
|
|
414
|
-
fee: path.coinOut.tradeFee,
|
|
415
|
-
},
|
|
416
|
-
], [])
|
|
417
|
-
.filter((data) => data.fee > BigInt(0));
|
|
418
|
-
const coins = __1.Helpers.uniqueArray([
|
|
419
|
-
...coinsWithFees.map((data) => data.coinType),
|
|
420
|
-
completeRoute.coinOut.type,
|
|
421
|
-
]);
|
|
422
|
-
const [coinsToPrice, coinsToDecimals] = yield Promise.all([
|
|
423
|
-
this.Provider.Prices().fetchCoinsToPrice({
|
|
424
|
-
coins,
|
|
425
|
-
}),
|
|
426
|
-
this.Provider.Coin().fetchCoinsToDecimals({
|
|
427
|
-
coins,
|
|
428
|
-
}),
|
|
429
|
-
]);
|
|
430
|
-
const netFeeUsd = coinsWithFees.reduce((acc, data) => acc +
|
|
431
|
-
(coinsToPrice[data.coinType] < 0
|
|
432
|
-
? 0
|
|
433
|
-
: coinsToPrice[data.coinType]) *
|
|
434
|
-
__1.Coin.balanceWithDecimals(data.fee, coinsToDecimals[data.coinType]), 0);
|
|
435
|
-
const coinOutAmountUsd = (coinsToPrice[completeRoute.coinOut.type] < 0
|
|
436
|
-
? 0
|
|
437
|
-
: coinsToPrice[completeRoute.coinOut.type]) *
|
|
438
|
-
__1.Coin.balanceWithDecimals(completeRoute.coinOut.amount, coinsToDecimals[completeRoute.coinOut.type]);
|
|
439
|
-
const netTradeFeePercentage = coinOutAmountUsd <= 0 ? 0 : netFeeUsd / coinOutAmountUsd;
|
|
440
|
-
return Object.assign(Object.assign({}, completeRoute), { netTradeFeePercentage });
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
101
|
}
|
|
444
102
|
exports.RouterApi = RouterApi;
|
|
445
103
|
// =========================================================================
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { RouterTradeEvent } from "../routerTypes";
|
|
2
|
+
import { RouterTradeEventOnChain } from "./routerApiCastingTypes";
|
|
3
3
|
export declare class RouterApiCasting {
|
|
4
4
|
static routerTradeEventFromOnChain: (eventOnChain: RouterTradeEventOnChain) => RouterTradeEvent;
|
|
5
|
-
static routerCompleteTradeRouteFromServicePaths: (paths: RouterServicePaths) => Omit<RouterCompleteTradeRoute, "netTradeFeePercentage">;
|
|
6
|
-
static routerServicePathsFromCompleteTradeRoute: (completeTradeRoute: RouterCompleteTradeRoute) => RouterServicePaths;
|
|
7
|
-
static routerProtocolNameToRouterServiceProtocol: (routerProtocolName: RouterProtocolName) => RouterServiceProtocol;
|
|
8
5
|
}
|
|
9
6
|
//# sourceMappingURL=routerApiCasting.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routerApiCasting.d.ts","sourceRoot":"","sources":["../../../../src/packages/router/api/routerApiCasting.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"routerApiCasting.d.ts","sourceRoot":"","sources":["../../../../src/packages/router/api/routerApiCasting.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,gBAAgB,EAEhB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAElE,qBAAa,gBAAgB;IAK5B,OAAc,2BAA2B,6CAEtC,gBAAgB,CAYjB;CACF"}
|
|
@@ -20,107 +20,3 @@ RouterApiCasting.routerTradeEventFromOnChain = (eventOnChain) => {
|
|
|
20
20
|
type: eventOnChain.type,
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
|
-
RouterApiCasting.routerCompleteTradeRouteFromServicePaths = (paths) => {
|
|
24
|
-
const routes = paths.paths.map((path) => ({
|
|
25
|
-
// TODO: add spot price
|
|
26
|
-
portion: BigInt(path.portion),
|
|
27
|
-
paths: path.path.data.map((hop) => ({
|
|
28
|
-
protocolName: hop.protocol.protocol,
|
|
29
|
-
poolId: hop.pool,
|
|
30
|
-
poolMetadata: {
|
|
31
|
-
protocol: hop.protocol,
|
|
32
|
-
tbData: hop.tb_data,
|
|
33
|
-
},
|
|
34
|
-
coinIn: {
|
|
35
|
-
type: hop.input,
|
|
36
|
-
amount: BigInt(hop.input_amount),
|
|
37
|
-
tradeFee: BigInt(hop.swap_fee.input_fee_amount),
|
|
38
|
-
},
|
|
39
|
-
coinOut: {
|
|
40
|
-
type: hop.output,
|
|
41
|
-
amount: BigInt(hop.output_amount),
|
|
42
|
-
tradeFee: BigInt(hop.swap_fee.output_fee_amount),
|
|
43
|
-
},
|
|
44
|
-
spotPrice: Number(BigInt(hop.input_amount)) /
|
|
45
|
-
Number(BigInt(hop.output_amount)),
|
|
46
|
-
})),
|
|
47
|
-
coinIn: {
|
|
48
|
-
type: path.path.data[0].input,
|
|
49
|
-
amount: BigInt(path.path.data[0].input_amount),
|
|
50
|
-
tradeFee: BigInt(path.path.data[0].swap_fee.input_fee_amount),
|
|
51
|
-
},
|
|
52
|
-
coinOut: {
|
|
53
|
-
type: path.path.data[path.path.data.length - 1].output,
|
|
54
|
-
amount: BigInt(path.path.data[path.path.data.length - 1].output_amount),
|
|
55
|
-
tradeFee: BigInt(path.path.data[path.path.data.length - 1].swap_fee
|
|
56
|
-
.output_fee_amount),
|
|
57
|
-
},
|
|
58
|
-
spotPrice: Number(BigInt(path.path.data[0].input_amount)) /
|
|
59
|
-
Number(BigInt(path.path.data[path.path.data.length - 1].output_amount)),
|
|
60
|
-
}));
|
|
61
|
-
return {
|
|
62
|
-
routes,
|
|
63
|
-
coinIn: {
|
|
64
|
-
type: routes[0].coinIn.type,
|
|
65
|
-
amount: BigInt(paths.amount_in),
|
|
66
|
-
tradeFee: BigInt(paths.protocol_fee.input_fee_amount),
|
|
67
|
-
},
|
|
68
|
-
coinOut: {
|
|
69
|
-
type: routes[routes.length - 1].coinOut.type,
|
|
70
|
-
amount: BigInt(paths.amount_out),
|
|
71
|
-
tradeFee: BigInt(paths.protocol_fee.output_fee_amount),
|
|
72
|
-
},
|
|
73
|
-
spotPrice: Number(paths.amount_in) / Number(paths.amount_out),
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
RouterApiCasting.routerServicePathsFromCompleteTradeRoute = (completeTradeRoute) => {
|
|
77
|
-
const paths = completeTradeRoute.routes.map((route) => ({
|
|
78
|
-
portion: route.portion.toString(),
|
|
79
|
-
path: {
|
|
80
|
-
data: route.paths.map((path) => ({
|
|
81
|
-
pool: path.poolId,
|
|
82
|
-
protocol: path.poolMetadata.protocol,
|
|
83
|
-
tb_data: path.poolMetadata.tbData,
|
|
84
|
-
input: path.coinIn.type,
|
|
85
|
-
output: path.coinOut.type,
|
|
86
|
-
input_amount: path.coinIn.amount.toString(),
|
|
87
|
-
output_amount: path.coinOut.amount.toString(),
|
|
88
|
-
acceptable_price_impact: true,
|
|
89
|
-
swap_fee: {
|
|
90
|
-
input_fee_amount: path.coinIn.tradeFee.toString(),
|
|
91
|
-
output_fee_amount: path.coinOut.tradeFee.toString(),
|
|
92
|
-
},
|
|
93
|
-
})),
|
|
94
|
-
},
|
|
95
|
-
}));
|
|
96
|
-
return {
|
|
97
|
-
paths,
|
|
98
|
-
amount_in: completeTradeRoute.coinIn.amount.toString(),
|
|
99
|
-
amount_out: completeTradeRoute.coinOut.amount.toString(),
|
|
100
|
-
acceptable_price_impact: true,
|
|
101
|
-
protocol_fee: {
|
|
102
|
-
input_fee_amount: completeTradeRoute.coinIn.tradeFee.toString(),
|
|
103
|
-
output_fee_amount: completeTradeRoute.coinOut.tradeFee.toString(),
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
RouterApiCasting.routerProtocolNameToRouterServiceProtocol = (routerProtocolName) => {
|
|
108
|
-
if (routerProtocolName === "Aftermath") {
|
|
109
|
-
return {
|
|
110
|
-
protocol: routerProtocolName,
|
|
111
|
-
pool_type: "Any",
|
|
112
|
-
extension: "Any",
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
else if (routerProtocolName === "Kriya" ||
|
|
116
|
-
routerProtocolName === "SuiSwap" ||
|
|
117
|
-
routerProtocolName === "BlueMove") {
|
|
118
|
-
return {
|
|
119
|
-
protocol: routerProtocolName,
|
|
120
|
-
pool_type: "Any",
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
return {
|
|
124
|
-
protocol: routerProtocolName,
|
|
125
|
-
};
|
|
126
|
-
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BigIntAsString, CoinType,
|
|
1
|
+
import { BigIntAsString, CoinType, SuiAddress } from "../../../types";
|
|
2
2
|
import { EventOnChain } from "../../../general/types/castingTypes";
|
|
3
3
|
export type RouterTradeEventOnChain = EventOnChain<{
|
|
4
4
|
swapper: SuiAddress;
|
|
@@ -9,16 +9,4 @@ export type RouterTradeEventOnChain = EventOnChain<{
|
|
|
9
9
|
router_fee: BigIntAsString;
|
|
10
10
|
router_fee_recipient: SuiAddress;
|
|
11
11
|
}>;
|
|
12
|
-
type IndexerPoolType = "Any" | "Stable" | "Uncorrelated";
|
|
13
|
-
export type RouterServiceProtocol = {
|
|
14
|
-
protocol: Exclude<RouterProtocolName, "Aftermath" | "Kriya" | "SuiSwap" | "BlueMove">;
|
|
15
|
-
} | {
|
|
16
|
-
protocol: "Aftermath";
|
|
17
|
-
pool_type: IndexerPoolType;
|
|
18
|
-
extension: "Any" | "Direct" | "DaoFee";
|
|
19
|
-
} | {
|
|
20
|
-
protocol: "Kriya" | "SuiSwap" | "BlueMove";
|
|
21
|
-
pool_type: IndexerPoolType;
|
|
22
|
-
};
|
|
23
|
-
export {};
|
|
24
12
|
//# sourceMappingURL=routerApiCastingTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routerApiCastingTypes.d.ts","sourceRoot":"","sources":["../../../../src/packages/router/api/routerApiCastingTypes.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"routerApiCastingTypes.d.ts","sourceRoot":"","sources":["../../../../src/packages/router/api/routerApiCastingTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAMnE,MAAM,MAAM,uBAAuB,GAAG,YAAY,CAAC;IAClD,OAAO,EAAE,UAAU,CAAC;IACpB,OAAO,EAAE,QAAQ,CAAC;IAClB,SAAS,EAAE,cAAc,CAAC;IAC1B,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,cAAc,CAAC;IAE3B,UAAU,EAAE,cAAc,CAAC;IAC3B,oBAAoB,EAAE,UAAU,CAAC;CACjC,CAAC,CAAC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { AnyObjectType, Balance, Percentage, Event, Slippage, ApiEventsBody, ObjectId, SuiAddress, TxBytes, BigIntAsString, SerializedTransaction, ExternalFee,
|
|
1
|
+
import { AnyObjectType, Balance, Percentage, Event, Slippage, ApiEventsBody, ObjectId, SuiAddress, TxBytes, BigIntAsString, SerializedTransaction, ExternalFee, IFixed } from "../../general/types/generalTypes";
|
|
2
2
|
import { CoinType, ServiceCoinData } from "../coin/coinTypes";
|
|
3
3
|
import { TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
4
4
|
import { TransactionObjectArgument as TransactionObjectArgumentV0 } from "@mysten/sui.js/transactions";
|
|
5
|
-
import { RouterServiceProtocol } from "./api/routerApiCastingTypes";
|
|
6
5
|
export type UniqueId = string;
|
|
7
6
|
/**
|
|
8
7
|
* Fee info for third party packages wanting to fee route transactions
|
|
@@ -28,10 +27,7 @@ export type RouterTradeRoute = RouterTradeInfo & {
|
|
|
28
27
|
export type RouterTradePath = RouterTradeInfo & {
|
|
29
28
|
protocolName: RouterProtocolName;
|
|
30
29
|
poolId: ObjectId;
|
|
31
|
-
poolMetadata:
|
|
32
|
-
tbData: any;
|
|
33
|
-
protocol: RouterServiceProtocol;
|
|
34
|
-
};
|
|
30
|
+
poolMetadata: any;
|
|
35
31
|
};
|
|
36
32
|
export interface RouterTradeInfo {
|
|
37
33
|
coinIn: RouterTradeCoin;
|
|
@@ -133,32 +129,4 @@ export interface ApiRouterDynamicGasBody {
|
|
|
133
129
|
sponsorAddress: SuiAddress;
|
|
134
130
|
referrer?: SuiAddress;
|
|
135
131
|
}
|
|
136
|
-
export interface RouterServicePaths {
|
|
137
|
-
amount_in: BigIntAsString;
|
|
138
|
-
amount_out: BigIntAsString;
|
|
139
|
-
paths: RouterServicePath[];
|
|
140
|
-
acceptable_price_impact: boolean;
|
|
141
|
-
protocol_fee: RouterServiceSwapFee;
|
|
142
|
-
}
|
|
143
|
-
export interface RouterServicePath {
|
|
144
|
-
portion: IFixedAsString;
|
|
145
|
-
path: {
|
|
146
|
-
data: RouterServiceHop[];
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
export interface RouterServiceHop {
|
|
150
|
-
pool: ObjectId;
|
|
151
|
-
protocol: RouterServiceProtocol;
|
|
152
|
-
tb_data: any;
|
|
153
|
-
input: CoinType;
|
|
154
|
-
output: CoinType;
|
|
155
|
-
input_amount: BigIntAsString;
|
|
156
|
-
output_amount: BigIntAsString;
|
|
157
|
-
acceptable_price_impact: boolean;
|
|
158
|
-
swap_fee: RouterServiceSwapFee;
|
|
159
|
-
}
|
|
160
|
-
export interface RouterServiceSwapFee {
|
|
161
|
-
input_fee_amount: BigIntAsString;
|
|
162
|
-
output_fee_amount: BigIntAsString;
|
|
163
|
-
}
|
|
164
132
|
//# sourceMappingURL=routerTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routerTypes.d.ts","sourceRoot":"","sources":["../../../src/packages/router/routerTypes.ts"],"names":[],"mappings":"AACA,OAAO,EACN,aAAa,EACb,OAAO,EACP,UAAU,EACV,KAAK,EACL,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,UAAU,EACV,OAAO,EACP,cAAc,EACd,qBAAqB,EACrB,WAAW,
|
|
1
|
+
{"version":3,"file":"routerTypes.d.ts","sourceRoot":"","sources":["../../../src/packages/router/routerTypes.ts"],"names":[],"mappings":"AACA,OAAO,EACN,aAAa,EACb,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