@minswap/noodles-sdk 0.1.2 → 0.2.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/0~rslib-runtime.js +1 -1
- package/dist/263.js +1 -0
- package/dist/806.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +60 -381
- package/dist/index.js +1 -1
- package/dist/pay.cjs +1 -1
- package/dist/pay.d.ts +3 -16
- package/dist/pay.js +1 -1
- package/dist/portfolio.cjs +1 -0
- package/dist/portfolio.d.ts +704 -0
- package/dist/portfolio.js +1 -0
- package/package.json +16 -3
- package/dist/832.js +0 -1
|
@@ -0,0 +1,704 @@
|
|
|
1
|
+
import { Coin } from '@flowx-finance/sdk';
|
|
2
|
+
import type { GetRoutesResult } from '@flowx-finance/sdk';
|
|
3
|
+
import type { Protocol } from '@flowx-finance/sdk';
|
|
4
|
+
import { QuoteResponse } from '@bluefin-exchange/bluefin7k-aggregator-sdk';
|
|
5
|
+
import type { RouterCompleteTradeRoute } from 'aftermath-ts-sdk';
|
|
6
|
+
import type { RouterDataV3 } from '@cetusprotocol/aggregator-sdk';
|
|
7
|
+
import { SourceDex } from '@bluefin-exchange/bluefin7k-aggregator-sdk';
|
|
8
|
+
import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
9
|
+
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
10
|
+
|
|
11
|
+
declare class AftermathAggregator {
|
|
12
|
+
private _config;
|
|
13
|
+
private _aftermathClient;
|
|
14
|
+
private _suiClient;
|
|
15
|
+
constructor(config: AftermathAggregatorConfig, suiClient: SuiJsonRpcClient);
|
|
16
|
+
private aftermathClient;
|
|
17
|
+
/**
|
|
18
|
+
* Finds the optimal trade route for swapping tokens
|
|
19
|
+
* @param params - Trade route parameters
|
|
20
|
+
* @param params.coinInAmount - Amount of input token to swap
|
|
21
|
+
* @param params.coinInType - Type/address of input token
|
|
22
|
+
* @param params.coinOutType - Type/address of output token
|
|
23
|
+
* @returns Promise resolving to complete trade route with pricing and path information
|
|
24
|
+
*/
|
|
25
|
+
getTradeRoute({ coinInAmount, coinInType, coinOutType, tradeFee, }: GetTradeRouteRequest): Promise<RouterCompleteTradeRoute | null>;
|
|
26
|
+
/**
|
|
27
|
+
* Builds a transaction for executing a trade route
|
|
28
|
+
* @param params - Transaction parameters
|
|
29
|
+
* @param params.completeRoute - Complete trade route from getTradeRoute()
|
|
30
|
+
* @param params.walletAddress - Address of the wallet executing the trade
|
|
31
|
+
* @param params.slippage - Maximum acceptable slippage (e.g., 0.01 for 1%)
|
|
32
|
+
* @returns Promise resolving to built transaction bytes ready for signing and execution
|
|
33
|
+
*/
|
|
34
|
+
getTransaction({ completeRoute, walletAddress, slippage }: GetTransactionRequest): Promise<Uint8Array>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare namespace AftermathAggregator {
|
|
38
|
+
function toCommonTradeRoutes(tradeRoute: RouterCompleteTradeRoute): FinalTradeRoute | null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
declare type AftermathAggregatorConfig = {
|
|
42
|
+
defaultTradeFee: TradeFeeOptions;
|
|
43
|
+
aftermathApiKey?: string;
|
|
44
|
+
/** Defaults to the MAINNET endpoint when omitted. */
|
|
45
|
+
aftermathApiEndpoint?: string;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Unified access to the supported DEX aggregators (Cetus, FlowX, Aftermath, 7K).
|
|
50
|
+
*/
|
|
51
|
+
declare class AggregatorModule implements IModule {
|
|
52
|
+
readonly sdk: NoodlesSdk;
|
|
53
|
+
private _aftermathAggregator;
|
|
54
|
+
private _sevenkAggregator;
|
|
55
|
+
private _cetusAggregator;
|
|
56
|
+
private _flowXAggregator;
|
|
57
|
+
constructor(sdk: NoodlesSdk);
|
|
58
|
+
get aftermathAggregator(): AftermathAggregator;
|
|
59
|
+
get sevenkAggregator(): SevenKAggregator;
|
|
60
|
+
get cetusAggregator(): CetusAggregator;
|
|
61
|
+
get flowXAggregator(): FlowXAggregator;
|
|
62
|
+
/**
|
|
63
|
+
* Finds the optimal trade route using the specified aggregator
|
|
64
|
+
* @param aggregator - The aggregator to use for route finding
|
|
65
|
+
* @param params - Trade route parameters including token types and amounts
|
|
66
|
+
* @returns Promise resolving to route response with both standardized and raw data, or null if no route found
|
|
67
|
+
*/
|
|
68
|
+
getTradeRoute(aggregator: SupportedAggregator, params: GetTradeRouteRequest_5): Promise<GetTradeRouteResponse | null>;
|
|
69
|
+
/**
|
|
70
|
+
* Builds a transaction from an existing trade route
|
|
71
|
+
* @param aggregator - The aggregator that generated the route
|
|
72
|
+
* @param params - Transaction parameters including wallet address, route, and slippage
|
|
73
|
+
* @returns Promise resolving to built transaction bytes ready for signing and execution
|
|
74
|
+
*/
|
|
75
|
+
getTransactionByRoute(aggregator: SupportedAggregator, params: GetTransactionByRouteRequest): Promise<Uint8Array>;
|
|
76
|
+
/**
|
|
77
|
+
* Combines route finding and transaction building into a single operation
|
|
78
|
+
* This is a convenience method that calls getTradeRoute followed by getTransactionByRoute
|
|
79
|
+
* @param aggregator - The aggregator to use for both route finding and transaction building
|
|
80
|
+
* @param params - Combined parameters including trade details, wallet address, and slippage
|
|
81
|
+
* @returns Promise resolving to complete response with route info and built transaction, or null if no route found
|
|
82
|
+
*/
|
|
83
|
+
getTradeTransaction(aggregator: SupportedAggregator, params: GetTradeTransactionRequest): Promise<GetTradeTransactionResponse | null>;
|
|
84
|
+
/**
|
|
85
|
+
* Finds the best rate across all aggregators and returns the optimal trade transaction
|
|
86
|
+
* This method queries all available aggregators and selects the one with the best output amount
|
|
87
|
+
* @param params - Combined parameters including trade details, wallet address, and slippage
|
|
88
|
+
* @returns Promise resolving to complete response with route info and built transaction from the best aggregator, or null if no routes found
|
|
89
|
+
*/
|
|
90
|
+
getTradeTransactionWithBestRate(params: GetTradeTransactionRequest): Promise<GetTradeTransactionResponse | null>;
|
|
91
|
+
/**
|
|
92
|
+
* Gets the expected output amount for a trade using the specified aggregator
|
|
93
|
+
* This is a lightweight method that only fetches the route and returns the output amount
|
|
94
|
+
* without building a transaction
|
|
95
|
+
*
|
|
96
|
+
* @param aggregator - The aggregator to use for calculating output amount
|
|
97
|
+
* @param params - Trade route parameters including token types and input amount
|
|
98
|
+
* @returns Promise resolving to the expected output amount in smallest unit, or null if no route found
|
|
99
|
+
*/
|
|
100
|
+
getAmountOut(aggregator: SupportedAggregator, params: GetTradeRouteRequest_5): Promise<bigint | null>;
|
|
101
|
+
/**
|
|
102
|
+
* Finds the best output amount across all aggregators without building a transaction
|
|
103
|
+
* This method queries all available aggregators in parallel and returns the aggregator
|
|
104
|
+
* that provides the highest output amount along with that amount
|
|
105
|
+
*
|
|
106
|
+
* @param params - Trade route parameters including token types and input amount
|
|
107
|
+
* @returns Promise resolving to an object containing the best output amount and the aggregator that provided it, or null if no routes found
|
|
108
|
+
*/
|
|
109
|
+
getBestAmountOut(params: GetTradeRouteRequest_5): Promise<{
|
|
110
|
+
amountOut: bigint;
|
|
111
|
+
aggregator: SupportedAggregator;
|
|
112
|
+
} | null>;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export declare type AlphalendPositionResponse = {
|
|
116
|
+
positionId: string;
|
|
117
|
+
netWorth: number;
|
|
118
|
+
dailyEarnings: number;
|
|
119
|
+
netApr: number;
|
|
120
|
+
safeBorrowLimit: number;
|
|
121
|
+
borrowLimitUsed: number;
|
|
122
|
+
liquidationThreshold: number;
|
|
123
|
+
totalSuppliedUsd: number;
|
|
124
|
+
aggregatedSupplyApr: number;
|
|
125
|
+
totalBorrowedUsd: number;
|
|
126
|
+
aggregatedBorrowApr: number;
|
|
127
|
+
suppliedAmounts: {
|
|
128
|
+
coinType: string;
|
|
129
|
+
amount: number;
|
|
130
|
+
}[];
|
|
131
|
+
borrowedAmounts: {
|
|
132
|
+
coinType: string;
|
|
133
|
+
amount: number;
|
|
134
|
+
}[];
|
|
135
|
+
rewardsToClaimUsd: number;
|
|
136
|
+
rewardsToClaim: {
|
|
137
|
+
coinType: string;
|
|
138
|
+
rewardAmount: number;
|
|
139
|
+
}[];
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
declare class CetusAggregator {
|
|
143
|
+
private _config;
|
|
144
|
+
private _suiClient;
|
|
145
|
+
private _cetusClient;
|
|
146
|
+
private getCetusClientConfig;
|
|
147
|
+
constructor(config: CetusAggregatorConfig, suiClient: SuiGrpcClient);
|
|
148
|
+
private cetusClient;
|
|
149
|
+
/**
|
|
150
|
+
* Finds the optimal trade route for swapping tokens using Cetus aggregator
|
|
151
|
+
* @param params - Trade route parameters
|
|
152
|
+
* @param params.coinInAmount - Amount of input token to swap
|
|
153
|
+
* @param params.coinInType - Type/address of input token
|
|
154
|
+
* @param params.coinOutType - Type/address of output token
|
|
155
|
+
* @param params.metaAggregator - If true, only meta-supported protocols are used and no extra overlay fee is applied
|
|
156
|
+
* @returns Promise resolving to router data with pricing and route information, or null if no route found
|
|
157
|
+
*/
|
|
158
|
+
getTradeRoute({ coinInAmount, coinInType, coinOutType, tradeFee, metaAggregator, supportedProtocols, }: GetTradeRouteRequest_3 & {
|
|
159
|
+
supportedProtocols?: string[];
|
|
160
|
+
}): Promise<RouterDataV3 | null>;
|
|
161
|
+
/**
|
|
162
|
+
* Builds a transaction for executing a trade route from Cetus aggregator
|
|
163
|
+
* @param params - Transaction parameters
|
|
164
|
+
* @param params.completeRoute - Complete router data from getTradeRoute() (aliased as routers)
|
|
165
|
+
* @param params.walletAddress - Address of the wallet executing the trade
|
|
166
|
+
* @param params.slippage - Maximum acceptable slippage (e.g., 0.01 for 1%)
|
|
167
|
+
* @returns Promise resolving to built transaction bytes ready for signing and execution
|
|
168
|
+
*/
|
|
169
|
+
getTransaction({ completeRoute: routers, walletAddress, slippage, tradeFee, metaAggregator, }: GetTransactionRequest_3): Promise<Uint8Array>;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
declare namespace CetusAggregator {
|
|
173
|
+
function toCommonTradeRoutes(tradeRoute: RouterDataV3, coinInType: string, coinOutType: string): FinalTradeRoute | null;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
declare type CetusAggregatorConfig = {
|
|
177
|
+
defaultTradeFee: TradeFeeOptions;
|
|
178
|
+
cetusApiKey?: string;
|
|
179
|
+
cetusApiEndpoint?: string;
|
|
180
|
+
cetusPartnerId?: string;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/** A single quote request in a {@link CoinAmountOutRequest} batch. */
|
|
184
|
+
export declare type CoinAmountOutItem = {
|
|
185
|
+
coin_in_amount: string;
|
|
186
|
+
coin_in_type: string;
|
|
187
|
+
coin_out_type: string;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export declare type CoinAmountOutRequest = CoinAmountOutItem[];
|
|
191
|
+
|
|
192
|
+
declare class CurveModule implements IModule {
|
|
193
|
+
readonly sdk: NoodlesSdk;
|
|
194
|
+
constructor(sdk: NoodlesSdk);
|
|
195
|
+
getEstimatedAmountOut(platform: SupportedBondingCurve, params: GetCurveEstimatedAmountOutRequest): Promise<bigint>;
|
|
196
|
+
getTradeTransaction(platform: SupportedBondingCurve, params: GetCurveTradeTransactionRequest): Promise<Uint8Array>;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
declare enum Environment {
|
|
200
|
+
Prod = "prod",
|
|
201
|
+
Staging = "staging"
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
declare type FinalTradeRoute = {
|
|
205
|
+
coinIn: string;
|
|
206
|
+
coinOut: string;
|
|
207
|
+
amountIn: bigint;
|
|
208
|
+
amountOut: bigint;
|
|
209
|
+
routes: TradeRoute[];
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
declare class FlowXAggregator {
|
|
213
|
+
private _config;
|
|
214
|
+
private _suiClient;
|
|
215
|
+
constructor(config: FlowXAggregatorConfig, suiClient: SuiGrpcClient);
|
|
216
|
+
private getCommission;
|
|
217
|
+
/**
|
|
218
|
+
* Finds the optimal trade route for swapping tokens using FlowX aggregator
|
|
219
|
+
* @param params - Trade route parameters
|
|
220
|
+
* @param params.coinInAmount - Amount of input token to swap
|
|
221
|
+
* @param params.coinInType - Type/address of input token
|
|
222
|
+
* @param params.coinOutType - Type/address of output token
|
|
223
|
+
* @param params.metaAggregator - If true, only meta-supported DEXs are used and no extra commission is applied
|
|
224
|
+
* @returns Promise resolving to routes result with pricing and path information, or null if no route found
|
|
225
|
+
*/
|
|
226
|
+
getTradeRoute({ coinInAmount, coinInType, coinOutType, tradeFee, metaAggregator, supportedProtocols, }: GetTradeRouteRequest_4 & {
|
|
227
|
+
supportedProtocols?: Protocol[];
|
|
228
|
+
}): Promise<GetRoutesResult<Coin, Coin> | null>;
|
|
229
|
+
/**
|
|
230
|
+
* Builds a transaction for executing a trade route from FlowX aggregator
|
|
231
|
+
* @param params - Transaction parameters
|
|
232
|
+
* @param params.walletAddress - Address of the wallet executing the trade
|
|
233
|
+
* @param params.completeRoute - Complete routes result from getTradeRoute()
|
|
234
|
+
* @param params.slippage - Maximum acceptable slippage (e.g., 0.01 for 1%)
|
|
235
|
+
* @returns Promise resolving to built transaction bytes ready for signing and execution
|
|
236
|
+
*/
|
|
237
|
+
getTransaction({ walletAddress, completeRoute, slippage, tradeFee, metaAggregator, }: GetTransactionRequest_4): Promise<Uint8Array>;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
declare namespace FlowXAggregator {
|
|
241
|
+
function toCommonTradeRoutes(tradeRoute: GetRoutesResult<Coin, Coin>): FinalTradeRoute | null;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
declare type FlowXAggregatorConfig = {
|
|
245
|
+
defaultTradeFee: TradeFeeOptions;
|
|
246
|
+
flowxApiKey?: string;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
declare type GetCurveEstimatedAmountOutRequest = {
|
|
250
|
+
/** Amount of input coin to trade (in smallest unit) */
|
|
251
|
+
coinInAmount: bigint;
|
|
252
|
+
/** Type/address of the input coin */
|
|
253
|
+
coinInType: string;
|
|
254
|
+
/** Type/address of the output coin */
|
|
255
|
+
coinOutType: string;
|
|
256
|
+
/** Custom trade fee for this request, if not provided, the default trade fee will be applied */
|
|
257
|
+
tradeFee?: TradeFeeOptions;
|
|
258
|
+
/** The bonding curve Pool ID */
|
|
259
|
+
poolId: string;
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
declare type GetCurveTradeTransactionRequest = {
|
|
263
|
+
/** Amount of input coin to trade (in smallest unit) */
|
|
264
|
+
coinInAmount: bigint;
|
|
265
|
+
/** Type/address of the input coin */
|
|
266
|
+
coinInType: string;
|
|
267
|
+
/** Type/address of the output coin */
|
|
268
|
+
coinOutType: string;
|
|
269
|
+
/** Wallet address that will execute the transaction */
|
|
270
|
+
walletAddress: string;
|
|
271
|
+
/** Slippage tolerance as decimal (e.g., 0.01 for 1%) */
|
|
272
|
+
slippage: number;
|
|
273
|
+
/** Custom trade fee for this request, if not provided, the default trade fee will be applied */
|
|
274
|
+
tradeFee?: TradeFeeOptions;
|
|
275
|
+
/** The bonding curve Pool ID */
|
|
276
|
+
poolId: string;
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
declare type GetTradeRouteRequest = {
|
|
280
|
+
/** coinInAmount is in the input coin's smallest unit (base units, not decimals). */
|
|
281
|
+
coinInAmount: bigint;
|
|
282
|
+
coinInType: string;
|
|
283
|
+
coinOutType: string;
|
|
284
|
+
/** Overrides defaultTradeFee for this request only. */
|
|
285
|
+
tradeFee?: TradeFeeOptions;
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
declare type GetTradeRouteRequest_2 = {
|
|
289
|
+
/** coinInAmount is in the input coin's smallest unit (base units, not decimals). */
|
|
290
|
+
coinInAmount: bigint;
|
|
291
|
+
coinInType: string;
|
|
292
|
+
coinOutType: string;
|
|
293
|
+
/** Overrides defaultTradeFee for this request only. */
|
|
294
|
+
tradeFee?: TradeFeeOptions;
|
|
295
|
+
/** When true, restrict to meta-supported DEXs and charge no commission (the meta-aggregator adds its own overlay fee). */
|
|
296
|
+
metaAggregator?: boolean;
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
declare type GetTradeRouteRequest_3 = {
|
|
300
|
+
/** coinInAmount is in the input coin's smallest unit (base units, not decimals). */
|
|
301
|
+
coinInAmount: bigint;
|
|
302
|
+
coinInType: string;
|
|
303
|
+
coinOutType: string;
|
|
304
|
+
/** Overrides defaultTradeFee for this request only. */
|
|
305
|
+
tradeFee?: TradeFeeOptions;
|
|
306
|
+
/** When true, restrict to meta-supported protocols and add no overlay fee (the meta-aggregator owns the fee). */
|
|
307
|
+
metaAggregator?: boolean;
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
declare type GetTradeRouteRequest_4 = {
|
|
311
|
+
/** coinInAmount is in the input coin's smallest unit (base units, not decimals). */
|
|
312
|
+
coinInAmount: bigint;
|
|
313
|
+
coinInType: string;
|
|
314
|
+
coinOutType: string;
|
|
315
|
+
/** Overrides defaultTradeFee for this request only. */
|
|
316
|
+
tradeFee?: TradeFeeOptions;
|
|
317
|
+
/** When true, restrict to meta-supported DEXs and charge no commission (the meta-aggregator owns the fee). */
|
|
318
|
+
metaAggregator?: boolean;
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
declare type GetTradeRouteRequest_5 = {
|
|
322
|
+
/** Input amount in the coin's smallest unit (base-units, not decimals) */
|
|
323
|
+
coinInAmount: bigint;
|
|
324
|
+
coinInType: string;
|
|
325
|
+
coinOutType: string;
|
|
326
|
+
/** Overrides the SDK's default trade fee for this request */
|
|
327
|
+
tradeFee?: TradeFeeOptions;
|
|
328
|
+
/** Restrict to meta-supported aggregators, charging no extra aggregator fee */
|
|
329
|
+
metaAggregator?: boolean;
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
declare type GetTradeRouteResponse = {
|
|
333
|
+
route: FinalTradeRoute;
|
|
334
|
+
/** Raw aggregator response; shape varies per aggregator, passed back to build the tx */
|
|
335
|
+
aggregatorRoute: any;
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
declare type GetTradeTransactionRequest = {
|
|
339
|
+
/** Input amount in the coin's smallest unit (base-units, not decimals) */
|
|
340
|
+
coinInAmount: bigint;
|
|
341
|
+
coinInType: string;
|
|
342
|
+
coinOutType: string;
|
|
343
|
+
walletAddress: string;
|
|
344
|
+
/** Slippage tolerance as decimal (e.g. 0.01 for 1%) */
|
|
345
|
+
slippage: number;
|
|
346
|
+
/** Overrides the SDK's default trade fee for this request */
|
|
347
|
+
tradeFee?: TradeFeeOptions;
|
|
348
|
+
/** Restrict to meta-supported aggregators, charging no extra aggregator fee */
|
|
349
|
+
metaAggregator?: boolean;
|
|
350
|
+
poolId: string;
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
declare type GetTradeTransactionResponse = {
|
|
354
|
+
route: FinalTradeRoute;
|
|
355
|
+
aggregatorRoute: any;
|
|
356
|
+
/** Built transaction bytes ready for signing and execution */
|
|
357
|
+
transaction: Uint8Array;
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
declare type GetTransactionByRouteRequest = {
|
|
361
|
+
walletAddress: string;
|
|
362
|
+
/** Raw aggregator response from a prior getTradeRoute call */
|
|
363
|
+
completeRoute: any;
|
|
364
|
+
/** Slippage tolerance as decimal (e.g. 0.01 for 1%) */
|
|
365
|
+
slippage: number;
|
|
366
|
+
/** Overrides the SDK's default trade fee for this request */
|
|
367
|
+
tradeFee?: TradeFeeOptions;
|
|
368
|
+
/** Skip the extra aggregator fee on Cetus, FlowX, and 7K routes */
|
|
369
|
+
metaAggregator?: boolean;
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
declare type GetTransactionRequest = {
|
|
373
|
+
walletAddress: string;
|
|
374
|
+
completeRoute: RouterCompleteTradeRoute;
|
|
375
|
+
/** Slippage tolerance as a fraction, e.g. 0.01 for 1%. */
|
|
376
|
+
slippage: number;
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
declare type GetTransactionRequest_2 = {
|
|
380
|
+
walletAddress: string;
|
|
381
|
+
completeRoute: QuoteResponse;
|
|
382
|
+
/** Slippage tolerance as a fraction, e.g. 0.01 for 1%. */
|
|
383
|
+
slippage: number;
|
|
384
|
+
tradeFee?: TradeFeeOptions;
|
|
385
|
+
/** When true, charge no commission (the meta-aggregator owns the fee). */
|
|
386
|
+
metaAggregator?: boolean;
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
declare type GetTransactionRequest_3 = {
|
|
390
|
+
walletAddress: string;
|
|
391
|
+
completeRoute: RouterDataV3;
|
|
392
|
+
/** Slippage tolerance as a fraction, e.g. 0.01 for 1%. */
|
|
393
|
+
slippage: number;
|
|
394
|
+
tradeFee?: TradeFeeOptions;
|
|
395
|
+
/** When true, add no overlay fee (the meta-aggregator owns the fee). */
|
|
396
|
+
metaAggregator?: boolean;
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
declare type GetTransactionRequest_4 = {
|
|
400
|
+
walletAddress: string;
|
|
401
|
+
completeRoute: GetRoutesResult<Coin, Coin>;
|
|
402
|
+
/** Slippage tolerance as a fraction, e.g. 0.01 for 1%. */
|
|
403
|
+
slippage: number;
|
|
404
|
+
tradeFee?: TradeFeeOptions;
|
|
405
|
+
/** When true, charge no commission (the meta-aggregator owns the fee). */
|
|
406
|
+
metaAggregator?: boolean;
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
declare interface IModule {
|
|
410
|
+
readonly sdk: NoodlesSdk;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Thrown by the portfolio methods when the supplied wallet address is not a
|
|
415
|
+
* valid Sui address. Consumers can catch this to map it to a 400 response.
|
|
416
|
+
*/
|
|
417
|
+
export declare class InvalidSuiAddressError extends Error {
|
|
418
|
+
constructor(address: string);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
export declare type LendingResponse = {
|
|
422
|
+
scallop: ScallopPositionResponse | undefined;
|
|
423
|
+
navi: NaviPositionResponse | undefined;
|
|
424
|
+
alphalend: AlphalendPositionResponse[];
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
export declare type NaviPositionResponse = {
|
|
428
|
+
borrows: {
|
|
429
|
+
coinType: string;
|
|
430
|
+
amount: number;
|
|
431
|
+
}[];
|
|
432
|
+
supplies: {
|
|
433
|
+
coinType: string;
|
|
434
|
+
amount: number;
|
|
435
|
+
}[];
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
declare enum Network {
|
|
439
|
+
Mainnet = "mainnet",
|
|
440
|
+
Testnet = "testnet"
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Read-only portfolio SDK: aggregates a wallet's lending positions across
|
|
445
|
+
* Scallop, Navi and Alphalend, and resolves best-rate output amounts for a
|
|
446
|
+
* batch of coin pairs.
|
|
447
|
+
*
|
|
448
|
+
* It is the library form of the Noodles backend's `PortfolioHandler` — it only
|
|
449
|
+
* fetches and shapes data, leaving HTTP/transport concerns to the caller.
|
|
450
|
+
*/
|
|
451
|
+
export declare class NoodlesPortfolioSdk {
|
|
452
|
+
private readonly noodlesSdk;
|
|
453
|
+
private readonly scallopAddressId;
|
|
454
|
+
private scallopQuery;
|
|
455
|
+
private alphalendClient;
|
|
456
|
+
constructor(options: NoodlesPortfolioSdkOptions);
|
|
457
|
+
private assertValidAddress;
|
|
458
|
+
private getScallopQuery;
|
|
459
|
+
private getAlphalendClient;
|
|
460
|
+
/**
|
|
461
|
+
* Fetches the wallet's full Scallop portfolio (lendings, borrowings, veSCA, etc.).
|
|
462
|
+
* @param address - The wallet's Sui address.
|
|
463
|
+
* @returns The wallet's Scallop position.
|
|
464
|
+
* @throws {InvalidSuiAddressError} If `address` is not a valid Sui address.
|
|
465
|
+
*/
|
|
466
|
+
getScallopPosition(address: string): Promise<ScallopPositionResponse>;
|
|
467
|
+
/**
|
|
468
|
+
* Fetches the wallet's Navi supply/borrow balances via `@naviprotocol/lending`
|
|
469
|
+
* (the successor to the legacy `navi-sdk`). Regular and e-mode positions are
|
|
470
|
+
* folded into the same `supplies`/`borrows` lists; zero-amount entries are dropped.
|
|
471
|
+
*
|
|
472
|
+
* Runs on a nested @mysten/sui v1 (see file header); no client is passed so navi
|
|
473
|
+
* builds its own v1 client.
|
|
474
|
+
* @param address - The wallet's Sui address.
|
|
475
|
+
* @returns The wallet's Navi supplies and borrows.
|
|
476
|
+
* @throws {InvalidSuiAddressError} If `address` is not a valid Sui address.
|
|
477
|
+
*/
|
|
478
|
+
getNaviPosition(address: string): Promise<NaviPositionResponse>;
|
|
479
|
+
/**
|
|
480
|
+
* Fetches the wallet's Alphalend positions, resolving each market id to its coin type.
|
|
481
|
+
* @param address - The wallet's Sui address.
|
|
482
|
+
* @returns One entry per Alphalend position; empty when the wallet has none.
|
|
483
|
+
* @throws {InvalidSuiAddressError} If `address` is not a valid Sui address.
|
|
484
|
+
*/
|
|
485
|
+
getAlphalendPosition(address: string): Promise<AlphalendPositionResponse[]>;
|
|
486
|
+
/**
|
|
487
|
+
* Fetches the wallet's positions across all supported lending protocols in
|
|
488
|
+
* parallel (Scallop, Navi, Alphalend).
|
|
489
|
+
* @param address - The wallet's Sui address.
|
|
490
|
+
* @returns The per-protocol positions keyed by `scallop`, `navi`, and `alphalend`.
|
|
491
|
+
* @throws {InvalidSuiAddressError} If `address` is not a valid Sui address.
|
|
492
|
+
*/
|
|
493
|
+
getAllLendingPositions(address: string): Promise<LendingResponse>;
|
|
494
|
+
/**
|
|
495
|
+
* Resolves the best-rate output amount (as a base-unit string) for each
|
|
496
|
+
* requested coin pair, querying the aggregator in parallel batches.
|
|
497
|
+
* @param request - Coin pairs to quote, each `{ coin_in_amount, coin_in_type, coin_out_type }`.
|
|
498
|
+
* @returns One base-unit amount string per request item, index-aligned with `request`;
|
|
499
|
+
* a pair with no available route resolves to `"0"`.
|
|
500
|
+
*/
|
|
501
|
+
getCoinAmountOut(request: CoinAmountOutRequest): Promise<string[]>;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
export declare type NoodlesPortfolioSdkOptions = {
|
|
505
|
+
/**
|
|
506
|
+
* The main Noodles SDK instance — used for aggregator quoting
|
|
507
|
+
* ({@link NoodlesPortfolioSdk.getCoinAmountOut}).
|
|
508
|
+
*/
|
|
509
|
+
noodlesSdk: NoodlesSdk;
|
|
510
|
+
/** Override the Scallop address registry id (defaults to mainnet). */
|
|
511
|
+
scallopAddressId?: string;
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
declare class NoodlesSdk {
|
|
515
|
+
readonly network: Network;
|
|
516
|
+
readonly env: Environment;
|
|
517
|
+
readonly options: SdkOptions;
|
|
518
|
+
private _suiGrpcClient;
|
|
519
|
+
private _suiJsonRpcClient;
|
|
520
|
+
readonly aggregatorModule: AggregatorModule;
|
|
521
|
+
readonly curveModule: CurveModule;
|
|
522
|
+
constructor(options: SdkOptions, network?: Network, env?: Environment);
|
|
523
|
+
get suiClient(): SuiGrpcClient;
|
|
524
|
+
get suiJsonRpcClient(): SuiJsonRpcClient;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Response/request types for {@link NoodlesPortfolioSdk}.
|
|
529
|
+
*/
|
|
530
|
+
export declare type ScallopPositionResponse = {
|
|
531
|
+
totalLockedScaValue: number;
|
|
532
|
+
lendings: {
|
|
533
|
+
suppliedCoin: number;
|
|
534
|
+
suppliedValue: number;
|
|
535
|
+
stakedCoin: number;
|
|
536
|
+
coinName: string;
|
|
537
|
+
symbol: string;
|
|
538
|
+
coinType: string;
|
|
539
|
+
coinPrice: number;
|
|
540
|
+
coinDecimals: number;
|
|
541
|
+
supplyApr: number;
|
|
542
|
+
supplyApy: number;
|
|
543
|
+
incentiveApr: number;
|
|
544
|
+
}[];
|
|
545
|
+
borrowings: {
|
|
546
|
+
obligationId: string;
|
|
547
|
+
totalDebtsInUsd: number;
|
|
548
|
+
totalCollateralInUsd: number;
|
|
549
|
+
riskLevel: number;
|
|
550
|
+
availableCollateralInUsd: number;
|
|
551
|
+
totalUnhealthyCollateralInUsd: number;
|
|
552
|
+
collaterals: {
|
|
553
|
+
coinName: string;
|
|
554
|
+
symbol: string;
|
|
555
|
+
coinDecimals: number;
|
|
556
|
+
coinType: string;
|
|
557
|
+
coinPrice: number;
|
|
558
|
+
depositedCoin: number;
|
|
559
|
+
depositedValueInUsd: number;
|
|
560
|
+
}[];
|
|
561
|
+
borrowedPools: {
|
|
562
|
+
coinName: string;
|
|
563
|
+
symbol: string;
|
|
564
|
+
coinDecimals: number;
|
|
565
|
+
coinType: string;
|
|
566
|
+
coinPrice: number;
|
|
567
|
+
borrowedCoin: number;
|
|
568
|
+
borrowedValueInUsd: number;
|
|
569
|
+
borrowApr: number | undefined;
|
|
570
|
+
borrowApy: number | undefined;
|
|
571
|
+
incentiveInfos: {
|
|
572
|
+
coinName: string;
|
|
573
|
+
symbol: string;
|
|
574
|
+
coinType: string;
|
|
575
|
+
incentiveApr: number;
|
|
576
|
+
}[];
|
|
577
|
+
}[];
|
|
578
|
+
}[];
|
|
579
|
+
pendingRewards: {
|
|
580
|
+
lendings: any;
|
|
581
|
+
borrowIncentives: any;
|
|
582
|
+
};
|
|
583
|
+
veScas: {
|
|
584
|
+
veScaKey: string;
|
|
585
|
+
coinPrice: number;
|
|
586
|
+
lockedScaInCoin: number;
|
|
587
|
+
lockedScaInUsd: number;
|
|
588
|
+
currentVeScaBalance: number;
|
|
589
|
+
remainingLockPeriodInDays: number;
|
|
590
|
+
unlockAt: number;
|
|
591
|
+
}[];
|
|
592
|
+
totalDebtValue: number;
|
|
593
|
+
totalCollateralValue: number;
|
|
594
|
+
totalSupplyValue: number;
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* Sui clients used by the SDK.
|
|
599
|
+
*
|
|
600
|
+
* `grpc` is required. `jsonRpc` is optional — when omitted, the SDK creates a
|
|
601
|
+
* default JSON-RPC client against the public Sui fullnode for the SDK network.
|
|
602
|
+
* (JSON-RPC is still required by third-party SDKs such as Aftermath and Pyth.)
|
|
603
|
+
*/
|
|
604
|
+
declare type SdkClients = {
|
|
605
|
+
grpc: SuiGrpcClient;
|
|
606
|
+
jsonRpc?: SuiJsonRpcClient;
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
declare type SdkOptions = {
|
|
610
|
+
clients: SdkClients;
|
|
611
|
+
tradeFee: TradeFeeOptions;
|
|
612
|
+
/** Optional API key for Astros aggregator access */
|
|
613
|
+
astrosApiKey?: string;
|
|
614
|
+
/** Optional API key for authenticated Aftermath API access */
|
|
615
|
+
aftermathApiKey?: string;
|
|
616
|
+
/** Optional custom Aftermath API endpoint (defaults to MAINNET if not provided) */
|
|
617
|
+
aftermathApiEndpoint?: string;
|
|
618
|
+
/** Optional API key for 7K Protocol access */
|
|
619
|
+
sevenKApiKey?: string;
|
|
620
|
+
/** Optional API key for Cetus aggregator access */
|
|
621
|
+
cetusApiKey?: string;
|
|
622
|
+
/** Optional custom Cetus API endpoint */
|
|
623
|
+
cetusApiEndpoint?: string;
|
|
624
|
+
/** Optional partner ID for Cetus integration */
|
|
625
|
+
cetusPartnerId?: string;
|
|
626
|
+
/** Optional API key for FlowX aggregator access */
|
|
627
|
+
flowxApiKey?: string;
|
|
628
|
+
};
|
|
629
|
+
|
|
630
|
+
declare class SevenKAggregator {
|
|
631
|
+
private _config;
|
|
632
|
+
private _suiClient;
|
|
633
|
+
constructor(config: SevenKAggregatorConfig, suiClient: SuiGrpcClient);
|
|
634
|
+
/**
|
|
635
|
+
* Finds the optimal trade route for swapping tokens using 7K Protocol
|
|
636
|
+
* @param params - Trade route parameters
|
|
637
|
+
* @param params.coinInAmount - Amount of input token to swap
|
|
638
|
+
* @param params.coinInType - Type/address of input token
|
|
639
|
+
* @param params.coinOutType - Type/address of output token
|
|
640
|
+
* @param params.metaAggregator - If true, only meta-supported DEXs are used and no extra commission is applied
|
|
641
|
+
* @returns Promise resolving to quote response with pricing and route information, or null if no route found
|
|
642
|
+
*/
|
|
643
|
+
getTradeRoute({ coinInAmount, coinInType, coinOutType, tradeFee, metaAggregator, supportedProtocols, }: GetTradeRouteRequest_2 & {
|
|
644
|
+
supportedProtocols?: SourceDex[];
|
|
645
|
+
}): Promise<QuoteResponse | null>;
|
|
646
|
+
/**
|
|
647
|
+
* Builds a transaction for executing a trade route from 7K Protocol
|
|
648
|
+
* @param params - Transaction parameters
|
|
649
|
+
* @param params.walletAddress - Address of the wallet executing the trade
|
|
650
|
+
* @param params.completeRoute - Complete quote response from getTradeRoute()
|
|
651
|
+
* @param params.slippage - Maximum acceptable slippage (e.g., 0.01 for 1%)
|
|
652
|
+
* @returns Promise resolving to built transaction bytes ready for signing and execution
|
|
653
|
+
*/
|
|
654
|
+
getTransaction({ walletAddress, completeRoute, slippage, tradeFee, metaAggregator, }: GetTransactionRequest_2): Promise<Uint8Array>;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
declare namespace SevenKAggregator {
|
|
658
|
+
function toCommonTradeRoutes(tradeRouteResponse: QuoteResponse): FinalTradeRoute | null;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
declare type SevenKAggregatorConfig = {
|
|
662
|
+
defaultTradeFee: TradeFeeOptions;
|
|
663
|
+
sevenKApiKey?: string;
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
declare enum SupportedAggregator {
|
|
667
|
+
AFTERMATH = "AFTERMATH",
|
|
668
|
+
SEVENK = "7K",
|
|
669
|
+
CETUS = "CETUS",
|
|
670
|
+
FLOWX = "FLOWX"
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
declare enum SupportedBondingCurve {
|
|
674
|
+
BLAST_FUN = "BLAST_FUN",
|
|
675
|
+
MOONBAGS = "MOONBAGS"
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
declare type TradeFeeOptions = {
|
|
679
|
+
/** Decimal fraction, not bps: 0.01 = 1%, 0.003 = 0.3% */
|
|
680
|
+
tradeFeePercent: number;
|
|
681
|
+
tradeFeeRecipientAddress: string;
|
|
682
|
+
};
|
|
683
|
+
|
|
684
|
+
declare namespace TradeFeeOptions {
|
|
685
|
+
function equals(a: TradeFeeOptions, b: TradeFeeOptions): boolean;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
declare type TradePath = {
|
|
689
|
+
poolAddress: string;
|
|
690
|
+
coinIn: string;
|
|
691
|
+
coinOut: string;
|
|
692
|
+
amountIn: bigint;
|
|
693
|
+
amountOut: bigint;
|
|
694
|
+
};
|
|
695
|
+
|
|
696
|
+
declare type TradeRoute = {
|
|
697
|
+
coinIn: string;
|
|
698
|
+
coinOut: string;
|
|
699
|
+
amountIn: bigint;
|
|
700
|
+
amountOut: bigint;
|
|
701
|
+
paths: TradePath[];
|
|
702
|
+
};
|
|
703
|
+
|
|
704
|
+
export { }
|