@mmt-finance/clmm-sui-sdk 1.0.1 → 1.0.2
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 +31 -16
- package/dist/index.d.ts +31 -16
- package/dist/index.js +189 -149
- package/dist/index.mjs +190 -150
- package/package.json +2 -2
- package/src/constants/claim-routes.ts +15 -0
- package/src/modules/pool-module.ts +46 -46
- package/src/modules/position-module.ts +98 -103
- package/src/sdk.ts +5 -5
- package/src/utils/coin-utils.ts +13 -12
- package/src/utils/common.ts +5 -5
- package/src/utils/grpc-simulate.ts +37 -0
- package/src/utils/pool-utils.ts +39 -19
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Decimal$1, { Decimal } from 'decimal.js';
|
|
2
2
|
import * as _mysten_sui_transactions from '@mysten/sui/transactions';
|
|
3
3
|
import { Transaction, TransactionArgument, TransactionObjectArgument, TransactionDataBuilder, BuildTransactionOptions } from '@mysten/sui/transactions';
|
|
4
|
-
import {
|
|
4
|
+
import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
5
5
|
import BN from 'bn.js';
|
|
6
6
|
|
|
7
7
|
interface PoolParams {
|
|
@@ -399,15 +399,15 @@ declare class PositionModule implements BaseModule {
|
|
|
399
399
|
feeAmountX: number;
|
|
400
400
|
feeAmountY: number;
|
|
401
401
|
} | null)[]>;
|
|
402
|
-
fetchRewards(positions: any, pools: ExtendedPool[], address: string, client:
|
|
403
|
-
getCoinOwedReward(positionId: string | TransactionArgument, reward_index: number): Promise<
|
|
404
|
-
getOwedCoinX(positionId: string | TransactionArgument): Promise<
|
|
405
|
-
getOwedCoinY(positionId: string | TransactionArgument): Promise<
|
|
406
|
-
getFeeGrowthInsideXLast(positionId: string | TransactionArgument): Promise<
|
|
407
|
-
getFeeGrowthInsideYLast(positionId: string | TransactionArgument): Promise<
|
|
408
|
-
getFeeRate(positionId: string | TransactionArgument): Promise<
|
|
409
|
-
getLiquidity(positionId: string | TransactionArgument): Promise<
|
|
410
|
-
getRewardGrowthInsideLast(positionId: string | TransactionArgument, reward_index: number): Promise<
|
|
402
|
+
fetchRewards(positions: any, pools: ExtendedPool[], address: string, client: SuiGrpcClient): Promise<Record<string, RewardsData>>;
|
|
403
|
+
getCoinOwedReward(positionId: string | TransactionArgument, reward_index: number): Promise<bigint>;
|
|
404
|
+
getOwedCoinX(positionId: string | TransactionArgument): Promise<bigint>;
|
|
405
|
+
getOwedCoinY(positionId: string | TransactionArgument): Promise<bigint>;
|
|
406
|
+
getFeeGrowthInsideXLast(positionId: string | TransactionArgument): Promise<bigint>;
|
|
407
|
+
getFeeGrowthInsideYLast(positionId: string | TransactionArgument): Promise<bigint>;
|
|
408
|
+
getFeeRate(positionId: string | TransactionArgument): Promise<bigint>;
|
|
409
|
+
getLiquidity(positionId: string | TransactionArgument): Promise<bigint>;
|
|
410
|
+
getRewardGrowthInsideLast(positionId: string | TransactionArgument, reward_index: number): Promise<bigint>;
|
|
411
411
|
getTickLowerIndex(positionId: string | TransactionArgument): Promise<number>;
|
|
412
412
|
getTickUpperIndex(positionId: string | TransactionArgument): Promise<number>;
|
|
413
413
|
fetchAllRewards(positionId: string, address: string, pool: ExtendedPool): Promise<RewardsData>;
|
|
@@ -441,11 +441,11 @@ interface SdkOptions {
|
|
|
441
441
|
suiClientUrl?: string;
|
|
442
442
|
customHeaders?: HeadersInit;
|
|
443
443
|
mvrEndpoint?: string;
|
|
444
|
-
client?:
|
|
444
|
+
client?: SuiGrpcClient;
|
|
445
445
|
customRpcNetwork?: 'mainnet' | 'testnet';
|
|
446
446
|
}
|
|
447
447
|
declare class MmtSDK {
|
|
448
|
-
protected readonly rpcModule:
|
|
448
|
+
protected readonly rpcModule: SuiGrpcClient;
|
|
449
449
|
protected readonly poolModule: PoolModule;
|
|
450
450
|
protected readonly positionModule: PositionModule;
|
|
451
451
|
protected readonly routeModule: RouteModule;
|
|
@@ -453,7 +453,7 @@ declare class MmtSDK {
|
|
|
453
453
|
readonly sdkConfig: SdkConfig;
|
|
454
454
|
readonly mvrNamedPackagesPlugin: (transactionData: TransactionDataBuilder, _buildOptions: BuildTransactionOptions, next: () => Promise<void>) => Promise<void>;
|
|
455
455
|
constructor(options?: SdkOptions);
|
|
456
|
-
get rpcClient():
|
|
456
|
+
get rpcClient(): SuiGrpcClient;
|
|
457
457
|
get Pool(): PoolModule;
|
|
458
458
|
get Position(): PositionModule;
|
|
459
459
|
get Route(): RouteModule;
|
|
@@ -685,9 +685,22 @@ declare function getCoinXYForLiquidity(liquidity: Decimal$1.Instance, reserveInS
|
|
|
685
685
|
declare function estimateLiquidityForCoinA(sqrtPriceX: BN, sqrtPriceY: BN, coinAmount: BN): BN;
|
|
686
686
|
declare function estimateLiquidityForCoinB(sqrtPriceX: BN, sqrtPriceY: BN, coinAmount: BN): BN;
|
|
687
687
|
declare function estLiquidityAndcoinAmountFromOneAmounts(lowerTick: number, upperTick: number, coinAmount: BN, iscoinA: boolean, roundUp: boolean, slippage: number, curSqrtPrice: BN): LiquidityInput;
|
|
688
|
-
|
|
688
|
+
/** Move object content shape expected by position/pool helpers (legacy JSON-RPC–compatible). */
|
|
689
|
+
type PackageMoveObject = {
|
|
690
|
+
dataType: 'moveObject';
|
|
691
|
+
type: string;
|
|
692
|
+
fields: Record<string, unknown>;
|
|
693
|
+
};
|
|
694
|
+
/**
|
|
695
|
+
* By default we use `{packageId}::position::Position`, which matches how this SDK consumes the result.
|
|
696
|
+
* Pass `structType` to query another struct under the same (or another) package in one round-trip.
|
|
697
|
+
*/
|
|
698
|
+
type FetchUserObjectsByPkgOptions = {
|
|
699
|
+
structType?: string;
|
|
700
|
+
};
|
|
701
|
+
declare const fetchUserObjectsByPkg: (client: SuiGrpcClient, packageId: string, address: string, options?: FetchUserObjectsByPkgOptions) => Promise<PackageMoveObject[]>;
|
|
689
702
|
declare function getLimitSqrtPriceUsingSlippage({ currentSqrtPrice, tokenX, tokenY, slippagePercentage, isTokenX, }: Pick<ExtendedPool, 'poolId' | 'tokenX' | 'tokenY'> & {
|
|
690
|
-
client:
|
|
703
|
+
client: SuiGrpcClient;
|
|
691
704
|
currentSqrtPrice?: string;
|
|
692
705
|
slippagePercentage: number;
|
|
693
706
|
isTokenX: boolean;
|
|
@@ -719,6 +732,8 @@ declare const mappedMmtV3Pool: {
|
|
|
719
732
|
};
|
|
720
733
|
};
|
|
721
734
|
|
|
735
|
+
type poolUtils_FetchUserObjectsByPkgOptions = FetchUserObjectsByPkgOptions;
|
|
736
|
+
type poolUtils_PackageMoveObject = PackageMoveObject;
|
|
722
737
|
declare const poolUtils_estLiquidityAndcoinAmountFromOneAmounts: typeof estLiquidityAndcoinAmountFromOneAmounts;
|
|
723
738
|
declare const poolUtils_estimateLiquidityForCoinA: typeof estimateLiquidityForCoinA;
|
|
724
739
|
declare const poolUtils_estimateLiquidityForCoinB: typeof estimateLiquidityForCoinB;
|
|
@@ -734,7 +749,7 @@ declare const poolUtils_getCoinXYForLiquidity: typeof getCoinXYForLiquidity;
|
|
|
734
749
|
declare const poolUtils_getLimitSqrtPriceUsingSlippage: typeof getLimitSqrtPriceUsingSlippage;
|
|
735
750
|
declare const poolUtils_mappedMmtV3Pool: typeof mappedMmtV3Pool;
|
|
736
751
|
declare namespace poolUtils {
|
|
737
|
-
export { poolUtils_estLiquidityAndcoinAmountFromOneAmounts as estLiquidityAndcoinAmountFromOneAmounts, poolUtils_estimateLiquidityForCoinA as estimateLiquidityForCoinA, poolUtils_estimateLiquidityForCoinB as estimateLiquidityForCoinB, poolUtils_fetchAllPoolsApi as fetchAllPoolsApi, poolUtils_fetchAllTokenApi as fetchAllTokenApi, poolUtils_fetchPoolApi as fetchPoolApi, poolUtils_fetchRewardersApy as fetchRewardersApy, poolUtils_fetchTickLiquidityApi as fetchTickLiquidityApi, poolUtils_fetchTokenApi as fetchTokenApi, poolUtils_fetchUserObjectsByPkg as fetchUserObjectsByPkg, poolUtils_getCoinAmountFromLiquidity as getCoinAmountFromLiquidity, poolUtils_getCoinXYForLiquidity as getCoinXYForLiquidity, poolUtils_getLimitSqrtPriceUsingSlippage as getLimitSqrtPriceUsingSlippage, poolUtils_mappedMmtV3Pool as mappedMmtV3Pool };
|
|
752
|
+
export { type poolUtils_FetchUserObjectsByPkgOptions as FetchUserObjectsByPkgOptions, type poolUtils_PackageMoveObject as PackageMoveObject, poolUtils_estLiquidityAndcoinAmountFromOneAmounts as estLiquidityAndcoinAmountFromOneAmounts, poolUtils_estimateLiquidityForCoinA as estimateLiquidityForCoinA, poolUtils_estimateLiquidityForCoinB as estimateLiquidityForCoinB, poolUtils_fetchAllPoolsApi as fetchAllPoolsApi, poolUtils_fetchAllTokenApi as fetchAllTokenApi, poolUtils_fetchPoolApi as fetchPoolApi, poolUtils_fetchRewardersApy as fetchRewardersApy, poolUtils_fetchTickLiquidityApi as fetchTickLiquidityApi, poolUtils_fetchTokenApi as fetchTokenApi, poolUtils_fetchUserObjectsByPkg as fetchUserObjectsByPkg, poolUtils_getCoinAmountFromLiquidity as getCoinAmountFromLiquidity, poolUtils_getCoinXYForLiquidity as getCoinXYForLiquidity, poolUtils_getLimitSqrtPriceUsingSlippage as getLimitSqrtPriceUsingSlippage, poolUtils_mappedMmtV3Pool as mappedMmtV3Pool };
|
|
738
753
|
}
|
|
739
754
|
|
|
740
755
|
declare const CLAIM_ROUTES: Record<string, Record<string, string[]>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Decimal$1, { Decimal } from 'decimal.js';
|
|
2
2
|
import * as _mysten_sui_transactions from '@mysten/sui/transactions';
|
|
3
3
|
import { Transaction, TransactionArgument, TransactionObjectArgument, TransactionDataBuilder, BuildTransactionOptions } from '@mysten/sui/transactions';
|
|
4
|
-
import {
|
|
4
|
+
import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
5
5
|
import BN from 'bn.js';
|
|
6
6
|
|
|
7
7
|
interface PoolParams {
|
|
@@ -399,15 +399,15 @@ declare class PositionModule implements BaseModule {
|
|
|
399
399
|
feeAmountX: number;
|
|
400
400
|
feeAmountY: number;
|
|
401
401
|
} | null)[]>;
|
|
402
|
-
fetchRewards(positions: any, pools: ExtendedPool[], address: string, client:
|
|
403
|
-
getCoinOwedReward(positionId: string | TransactionArgument, reward_index: number): Promise<
|
|
404
|
-
getOwedCoinX(positionId: string | TransactionArgument): Promise<
|
|
405
|
-
getOwedCoinY(positionId: string | TransactionArgument): Promise<
|
|
406
|
-
getFeeGrowthInsideXLast(positionId: string | TransactionArgument): Promise<
|
|
407
|
-
getFeeGrowthInsideYLast(positionId: string | TransactionArgument): Promise<
|
|
408
|
-
getFeeRate(positionId: string | TransactionArgument): Promise<
|
|
409
|
-
getLiquidity(positionId: string | TransactionArgument): Promise<
|
|
410
|
-
getRewardGrowthInsideLast(positionId: string | TransactionArgument, reward_index: number): Promise<
|
|
402
|
+
fetchRewards(positions: any, pools: ExtendedPool[], address: string, client: SuiGrpcClient): Promise<Record<string, RewardsData>>;
|
|
403
|
+
getCoinOwedReward(positionId: string | TransactionArgument, reward_index: number): Promise<bigint>;
|
|
404
|
+
getOwedCoinX(positionId: string | TransactionArgument): Promise<bigint>;
|
|
405
|
+
getOwedCoinY(positionId: string | TransactionArgument): Promise<bigint>;
|
|
406
|
+
getFeeGrowthInsideXLast(positionId: string | TransactionArgument): Promise<bigint>;
|
|
407
|
+
getFeeGrowthInsideYLast(positionId: string | TransactionArgument): Promise<bigint>;
|
|
408
|
+
getFeeRate(positionId: string | TransactionArgument): Promise<bigint>;
|
|
409
|
+
getLiquidity(positionId: string | TransactionArgument): Promise<bigint>;
|
|
410
|
+
getRewardGrowthInsideLast(positionId: string | TransactionArgument, reward_index: number): Promise<bigint>;
|
|
411
411
|
getTickLowerIndex(positionId: string | TransactionArgument): Promise<number>;
|
|
412
412
|
getTickUpperIndex(positionId: string | TransactionArgument): Promise<number>;
|
|
413
413
|
fetchAllRewards(positionId: string, address: string, pool: ExtendedPool): Promise<RewardsData>;
|
|
@@ -441,11 +441,11 @@ interface SdkOptions {
|
|
|
441
441
|
suiClientUrl?: string;
|
|
442
442
|
customHeaders?: HeadersInit;
|
|
443
443
|
mvrEndpoint?: string;
|
|
444
|
-
client?:
|
|
444
|
+
client?: SuiGrpcClient;
|
|
445
445
|
customRpcNetwork?: 'mainnet' | 'testnet';
|
|
446
446
|
}
|
|
447
447
|
declare class MmtSDK {
|
|
448
|
-
protected readonly rpcModule:
|
|
448
|
+
protected readonly rpcModule: SuiGrpcClient;
|
|
449
449
|
protected readonly poolModule: PoolModule;
|
|
450
450
|
protected readonly positionModule: PositionModule;
|
|
451
451
|
protected readonly routeModule: RouteModule;
|
|
@@ -453,7 +453,7 @@ declare class MmtSDK {
|
|
|
453
453
|
readonly sdkConfig: SdkConfig;
|
|
454
454
|
readonly mvrNamedPackagesPlugin: (transactionData: TransactionDataBuilder, _buildOptions: BuildTransactionOptions, next: () => Promise<void>) => Promise<void>;
|
|
455
455
|
constructor(options?: SdkOptions);
|
|
456
|
-
get rpcClient():
|
|
456
|
+
get rpcClient(): SuiGrpcClient;
|
|
457
457
|
get Pool(): PoolModule;
|
|
458
458
|
get Position(): PositionModule;
|
|
459
459
|
get Route(): RouteModule;
|
|
@@ -685,9 +685,22 @@ declare function getCoinXYForLiquidity(liquidity: Decimal$1.Instance, reserveInS
|
|
|
685
685
|
declare function estimateLiquidityForCoinA(sqrtPriceX: BN, sqrtPriceY: BN, coinAmount: BN): BN;
|
|
686
686
|
declare function estimateLiquidityForCoinB(sqrtPriceX: BN, sqrtPriceY: BN, coinAmount: BN): BN;
|
|
687
687
|
declare function estLiquidityAndcoinAmountFromOneAmounts(lowerTick: number, upperTick: number, coinAmount: BN, iscoinA: boolean, roundUp: boolean, slippage: number, curSqrtPrice: BN): LiquidityInput;
|
|
688
|
-
|
|
688
|
+
/** Move object content shape expected by position/pool helpers (legacy JSON-RPC–compatible). */
|
|
689
|
+
type PackageMoveObject = {
|
|
690
|
+
dataType: 'moveObject';
|
|
691
|
+
type: string;
|
|
692
|
+
fields: Record<string, unknown>;
|
|
693
|
+
};
|
|
694
|
+
/**
|
|
695
|
+
* By default we use `{packageId}::position::Position`, which matches how this SDK consumes the result.
|
|
696
|
+
* Pass `structType` to query another struct under the same (or another) package in one round-trip.
|
|
697
|
+
*/
|
|
698
|
+
type FetchUserObjectsByPkgOptions = {
|
|
699
|
+
structType?: string;
|
|
700
|
+
};
|
|
701
|
+
declare const fetchUserObjectsByPkg: (client: SuiGrpcClient, packageId: string, address: string, options?: FetchUserObjectsByPkgOptions) => Promise<PackageMoveObject[]>;
|
|
689
702
|
declare function getLimitSqrtPriceUsingSlippage({ currentSqrtPrice, tokenX, tokenY, slippagePercentage, isTokenX, }: Pick<ExtendedPool, 'poolId' | 'tokenX' | 'tokenY'> & {
|
|
690
|
-
client:
|
|
703
|
+
client: SuiGrpcClient;
|
|
691
704
|
currentSqrtPrice?: string;
|
|
692
705
|
slippagePercentage: number;
|
|
693
706
|
isTokenX: boolean;
|
|
@@ -719,6 +732,8 @@ declare const mappedMmtV3Pool: {
|
|
|
719
732
|
};
|
|
720
733
|
};
|
|
721
734
|
|
|
735
|
+
type poolUtils_FetchUserObjectsByPkgOptions = FetchUserObjectsByPkgOptions;
|
|
736
|
+
type poolUtils_PackageMoveObject = PackageMoveObject;
|
|
722
737
|
declare const poolUtils_estLiquidityAndcoinAmountFromOneAmounts: typeof estLiquidityAndcoinAmountFromOneAmounts;
|
|
723
738
|
declare const poolUtils_estimateLiquidityForCoinA: typeof estimateLiquidityForCoinA;
|
|
724
739
|
declare const poolUtils_estimateLiquidityForCoinB: typeof estimateLiquidityForCoinB;
|
|
@@ -734,7 +749,7 @@ declare const poolUtils_getCoinXYForLiquidity: typeof getCoinXYForLiquidity;
|
|
|
734
749
|
declare const poolUtils_getLimitSqrtPriceUsingSlippage: typeof getLimitSqrtPriceUsingSlippage;
|
|
735
750
|
declare const poolUtils_mappedMmtV3Pool: typeof mappedMmtV3Pool;
|
|
736
751
|
declare namespace poolUtils {
|
|
737
|
-
export { poolUtils_estLiquidityAndcoinAmountFromOneAmounts as estLiquidityAndcoinAmountFromOneAmounts, poolUtils_estimateLiquidityForCoinA as estimateLiquidityForCoinA, poolUtils_estimateLiquidityForCoinB as estimateLiquidityForCoinB, poolUtils_fetchAllPoolsApi as fetchAllPoolsApi, poolUtils_fetchAllTokenApi as fetchAllTokenApi, poolUtils_fetchPoolApi as fetchPoolApi, poolUtils_fetchRewardersApy as fetchRewardersApy, poolUtils_fetchTickLiquidityApi as fetchTickLiquidityApi, poolUtils_fetchTokenApi as fetchTokenApi, poolUtils_fetchUserObjectsByPkg as fetchUserObjectsByPkg, poolUtils_getCoinAmountFromLiquidity as getCoinAmountFromLiquidity, poolUtils_getCoinXYForLiquidity as getCoinXYForLiquidity, poolUtils_getLimitSqrtPriceUsingSlippage as getLimitSqrtPriceUsingSlippage, poolUtils_mappedMmtV3Pool as mappedMmtV3Pool };
|
|
752
|
+
export { type poolUtils_FetchUserObjectsByPkgOptions as FetchUserObjectsByPkgOptions, type poolUtils_PackageMoveObject as PackageMoveObject, poolUtils_estLiquidityAndcoinAmountFromOneAmounts as estLiquidityAndcoinAmountFromOneAmounts, poolUtils_estimateLiquidityForCoinA as estimateLiquidityForCoinA, poolUtils_estimateLiquidityForCoinB as estimateLiquidityForCoinB, poolUtils_fetchAllPoolsApi as fetchAllPoolsApi, poolUtils_fetchAllTokenApi as fetchAllTokenApi, poolUtils_fetchPoolApi as fetchPoolApi, poolUtils_fetchRewardersApy as fetchRewardersApy, poolUtils_fetchTickLiquidityApi as fetchTickLiquidityApi, poolUtils_fetchTokenApi as fetchTokenApi, poolUtils_fetchUserObjectsByPkg as fetchUserObjectsByPkg, poolUtils_getCoinAmountFromLiquidity as getCoinAmountFromLiquidity, poolUtils_getCoinXYForLiquidity as getCoinXYForLiquidity, poolUtils_getLimitSqrtPriceUsingSlippage as getLimitSqrtPriceUsingSlippage, poolUtils_mappedMmtV3Pool as mappedMmtV3Pool };
|
|
738
753
|
}
|
|
739
754
|
|
|
740
755
|
declare const CLAIM_ROUTES: Record<string, Record<string, string[]>>;
|