@rhea-finance/cross-chain-aggregation-dex 0.1.2 → 0.1.4
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/index.d.mts +42 -2
- package/dist/index.d.ts +42 -2
- package/dist/index.js +241 -318
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +239 -318
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -298,7 +298,7 @@ declare const logger: {
|
|
|
298
298
|
|
|
299
299
|
/** Set the SDK-wide bluechip token config used for NearIntents compatibility and intermediate routing. */
|
|
300
300
|
declare function setBluechipTokensConfig(config: BluechipTokensConfig): void;
|
|
301
|
-
/** Get the bluechip token config; returns an empty object
|
|
301
|
+
/** Get the bluechip token config; returns an empty object if unset. */
|
|
302
302
|
declare function getBluechipTokensConfig(): BluechipTokensConfig;
|
|
303
303
|
/**
|
|
304
304
|
* Normalize a NEAR asset id:
|
|
@@ -332,6 +332,18 @@ declare function formatGasToTgas(gasInYoctoNEAR: string | number): string;
|
|
|
332
332
|
* @returns Formatted gas string in yoctoNEAR
|
|
333
333
|
*/
|
|
334
334
|
declare function formatGasString(gas: string | number | bigint): string;
|
|
335
|
+
/**
|
|
336
|
+
* Select the best quote from multiple quotes based on maximum amountOut
|
|
337
|
+
*/
|
|
338
|
+
declare function selectBestQuote<T extends {
|
|
339
|
+
amountOut: string;
|
|
340
|
+
}, R = any>(quotes: Array<{
|
|
341
|
+
quote: T;
|
|
342
|
+
router: R;
|
|
343
|
+
}>): {
|
|
344
|
+
quote: T;
|
|
345
|
+
router: R;
|
|
346
|
+
};
|
|
335
347
|
|
|
336
348
|
/** NEAR DEX router implementation (FindPath for routing + REF for execution). */
|
|
337
349
|
|
|
@@ -416,6 +428,7 @@ interface CompleteQuoteParams {
|
|
|
416
428
|
slippage: number;
|
|
417
429
|
recipient: string;
|
|
418
430
|
refundTo?: string;
|
|
431
|
+
customRecipientMsg?: string;
|
|
419
432
|
}
|
|
420
433
|
interface CompleteQuoteResult {
|
|
421
434
|
intents: {
|
|
@@ -428,10 +441,12 @@ interface CompleteQuoteResult {
|
|
|
428
441
|
tokenIn: TokenInfo;
|
|
429
442
|
tokenOut: TokenInfo;
|
|
430
443
|
executor: DexRouter;
|
|
444
|
+
routeType?: "v1" | "v2";
|
|
431
445
|
};
|
|
432
446
|
finalAmountOut: string;
|
|
433
447
|
totalPriceImpact?: number;
|
|
434
448
|
totalFee?: number;
|
|
449
|
+
routeType?: "v1" | "v2" | "intents";
|
|
435
450
|
}
|
|
436
451
|
interface CompleteQuoteConfig {
|
|
437
452
|
intentsQuotationAdapter: IntentsQuotationAdapter;
|
|
@@ -442,6 +457,8 @@ interface CompleteQuoteConfig {
|
|
|
442
457
|
getWrapNearContractId(): string;
|
|
443
458
|
};
|
|
444
459
|
currentUserAddress?: string;
|
|
460
|
+
/** Optional function to check if token supports Intents (beyond bluechip tokens) */
|
|
461
|
+
isIntentsSupportedToken?: (token: TokenInfo) => boolean;
|
|
445
462
|
}
|
|
446
463
|
/**
|
|
447
464
|
* Build a "complete quote":
|
|
@@ -454,4 +471,27 @@ interface CompleteQuoteConfig {
|
|
|
454
471
|
*/
|
|
455
472
|
declare function completeQuote(params: CompleteQuoteParams, config: CompleteQuoteConfig): Promise<CompleteQuoteResult>;
|
|
456
473
|
|
|
457
|
-
|
|
474
|
+
/**
|
|
475
|
+
* Same-chain swap quote (NEAR -> NEAR)
|
|
476
|
+
* Queries V1 and V2 routers in parallel and selects the best route based on maximum amountOut
|
|
477
|
+
*/
|
|
478
|
+
|
|
479
|
+
interface QuoteSameChainSwapParams {
|
|
480
|
+
tokenIn: TokenInfo;
|
|
481
|
+
tokenOut: TokenInfo;
|
|
482
|
+
amountIn: string;
|
|
483
|
+
slippage: number;
|
|
484
|
+
recipient: string;
|
|
485
|
+
currentUserAddress: string;
|
|
486
|
+
}
|
|
487
|
+
interface QuoteSameChainSwapResult {
|
|
488
|
+
quote: QuoteResult;
|
|
489
|
+
router: DexRouter;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Quote same-chain swap (NEAR -> NEAR) by querying V1 and V2 routers in parallel
|
|
493
|
+
* and selecting the best route based on maximum amountOut
|
|
494
|
+
*/
|
|
495
|
+
declare function quoteSameChainSwap(params: QuoteSameChainSwapParams, dexRouters: DexRouter[]): Promise<QuoteSameChainSwapResult>;
|
|
496
|
+
|
|
497
|
+
export { AggregateDexRouter, type AggregateDexRouterConfig, type BaseExecuteParams, type BaseQuoteParams, type BluechipTokenConfig, type BluechipTokensConfig, type CompleteQuoteConfig, type CompleteQuoteParams, type CompleteQuoteResult, type ConfigAdapter, type DexRouter, type ExecuteParams, type ExecuteResult, type FindPathAdapter, type FindPathResponse, type IntentsQuotationAdapter, type IntentsQuoteResult, type NearChainAdapter, NearSmartRouter, type NearSmartRouterConfig, type PoolInfo, type QuoteParams, type QuoteResult, type QuoteSameChainSwapParams, type QuoteSameChainSwapResult, type RecipientExecuteParams, type RecipientQuoteParams, type Route, type RouterCapabilities, type SimpleQuoteParams, type SupportedChain, type SwapMultiDexPathAdapter, type SwapMultiDexPathResponse, type TokenInfo, completeQuote, convertSlippageToBasisPoints, findBestBluechipToken, formatGasString, formatGasToTgas, getBluechipTokensConfig, isNearIntentsSupportedToken, logger, normalizeDestinationAsset, normalizeTokenId, quoteSameChainSwap, requiresRecipient, requiresRecipientInExecute, selectBestQuote, setBluechipTokensConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -298,7 +298,7 @@ declare const logger: {
|
|
|
298
298
|
|
|
299
299
|
/** Set the SDK-wide bluechip token config used for NearIntents compatibility and intermediate routing. */
|
|
300
300
|
declare function setBluechipTokensConfig(config: BluechipTokensConfig): void;
|
|
301
|
-
/** Get the bluechip token config; returns an empty object
|
|
301
|
+
/** Get the bluechip token config; returns an empty object if unset. */
|
|
302
302
|
declare function getBluechipTokensConfig(): BluechipTokensConfig;
|
|
303
303
|
/**
|
|
304
304
|
* Normalize a NEAR asset id:
|
|
@@ -332,6 +332,18 @@ declare function formatGasToTgas(gasInYoctoNEAR: string | number): string;
|
|
|
332
332
|
* @returns Formatted gas string in yoctoNEAR
|
|
333
333
|
*/
|
|
334
334
|
declare function formatGasString(gas: string | number | bigint): string;
|
|
335
|
+
/**
|
|
336
|
+
* Select the best quote from multiple quotes based on maximum amountOut
|
|
337
|
+
*/
|
|
338
|
+
declare function selectBestQuote<T extends {
|
|
339
|
+
amountOut: string;
|
|
340
|
+
}, R = any>(quotes: Array<{
|
|
341
|
+
quote: T;
|
|
342
|
+
router: R;
|
|
343
|
+
}>): {
|
|
344
|
+
quote: T;
|
|
345
|
+
router: R;
|
|
346
|
+
};
|
|
335
347
|
|
|
336
348
|
/** NEAR DEX router implementation (FindPath for routing + REF for execution). */
|
|
337
349
|
|
|
@@ -416,6 +428,7 @@ interface CompleteQuoteParams {
|
|
|
416
428
|
slippage: number;
|
|
417
429
|
recipient: string;
|
|
418
430
|
refundTo?: string;
|
|
431
|
+
customRecipientMsg?: string;
|
|
419
432
|
}
|
|
420
433
|
interface CompleteQuoteResult {
|
|
421
434
|
intents: {
|
|
@@ -428,10 +441,12 @@ interface CompleteQuoteResult {
|
|
|
428
441
|
tokenIn: TokenInfo;
|
|
429
442
|
tokenOut: TokenInfo;
|
|
430
443
|
executor: DexRouter;
|
|
444
|
+
routeType?: "v1" | "v2";
|
|
431
445
|
};
|
|
432
446
|
finalAmountOut: string;
|
|
433
447
|
totalPriceImpact?: number;
|
|
434
448
|
totalFee?: number;
|
|
449
|
+
routeType?: "v1" | "v2" | "intents";
|
|
435
450
|
}
|
|
436
451
|
interface CompleteQuoteConfig {
|
|
437
452
|
intentsQuotationAdapter: IntentsQuotationAdapter;
|
|
@@ -442,6 +457,8 @@ interface CompleteQuoteConfig {
|
|
|
442
457
|
getWrapNearContractId(): string;
|
|
443
458
|
};
|
|
444
459
|
currentUserAddress?: string;
|
|
460
|
+
/** Optional function to check if token supports Intents (beyond bluechip tokens) */
|
|
461
|
+
isIntentsSupportedToken?: (token: TokenInfo) => boolean;
|
|
445
462
|
}
|
|
446
463
|
/**
|
|
447
464
|
* Build a "complete quote":
|
|
@@ -454,4 +471,27 @@ interface CompleteQuoteConfig {
|
|
|
454
471
|
*/
|
|
455
472
|
declare function completeQuote(params: CompleteQuoteParams, config: CompleteQuoteConfig): Promise<CompleteQuoteResult>;
|
|
456
473
|
|
|
457
|
-
|
|
474
|
+
/**
|
|
475
|
+
* Same-chain swap quote (NEAR -> NEAR)
|
|
476
|
+
* Queries V1 and V2 routers in parallel and selects the best route based on maximum amountOut
|
|
477
|
+
*/
|
|
478
|
+
|
|
479
|
+
interface QuoteSameChainSwapParams {
|
|
480
|
+
tokenIn: TokenInfo;
|
|
481
|
+
tokenOut: TokenInfo;
|
|
482
|
+
amountIn: string;
|
|
483
|
+
slippage: number;
|
|
484
|
+
recipient: string;
|
|
485
|
+
currentUserAddress: string;
|
|
486
|
+
}
|
|
487
|
+
interface QuoteSameChainSwapResult {
|
|
488
|
+
quote: QuoteResult;
|
|
489
|
+
router: DexRouter;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Quote same-chain swap (NEAR -> NEAR) by querying V1 and V2 routers in parallel
|
|
493
|
+
* and selecting the best route based on maximum amountOut
|
|
494
|
+
*/
|
|
495
|
+
declare function quoteSameChainSwap(params: QuoteSameChainSwapParams, dexRouters: DexRouter[]): Promise<QuoteSameChainSwapResult>;
|
|
496
|
+
|
|
497
|
+
export { AggregateDexRouter, type AggregateDexRouterConfig, type BaseExecuteParams, type BaseQuoteParams, type BluechipTokenConfig, type BluechipTokensConfig, type CompleteQuoteConfig, type CompleteQuoteParams, type CompleteQuoteResult, type ConfigAdapter, type DexRouter, type ExecuteParams, type ExecuteResult, type FindPathAdapter, type FindPathResponse, type IntentsQuotationAdapter, type IntentsQuoteResult, type NearChainAdapter, NearSmartRouter, type NearSmartRouterConfig, type PoolInfo, type QuoteParams, type QuoteResult, type QuoteSameChainSwapParams, type QuoteSameChainSwapResult, type RecipientExecuteParams, type RecipientQuoteParams, type Route, type RouterCapabilities, type SimpleQuoteParams, type SupportedChain, type SwapMultiDexPathAdapter, type SwapMultiDexPathResponse, type TokenInfo, completeQuote, convertSlippageToBasisPoints, findBestBluechipToken, formatGasString, formatGasToTgas, getBluechipTokensConfig, isNearIntentsSupportedToken, logger, normalizeDestinationAsset, normalizeTokenId, quoteSameChainSwap, requiresRecipient, requiresRecipientInExecute, selectBestQuote, setBluechipTokensConfig };
|