@scallop-io/sui-scallop-sdk 0.47.6 → 1.3.0-alpha.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/builders/borrowIncentiveBuilder.d.ts +2 -2
- package/dist/builders/coreBuilder.d.ts +2 -2
- package/dist/builders/index.d.ts +2 -2
- package/dist/builders/loyaltyProgramBuilder.d.ts +2 -2
- package/dist/builders/referralBuilder.d.ts +2 -2
- package/dist/builders/sCoinBuilder.d.ts +2 -2
- package/dist/builders/spoolBuilder.d.ts +2 -2
- package/dist/builders/vescaBuilder.d.ts +2 -2
- package/dist/constants/common.d.ts +4 -4
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/vesca.d.ts +3 -3
- package/dist/index.js +149 -83
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +152 -89
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopBuilder.d.ts +6 -4
- package/dist/models/scallopCache.d.ts +5 -9
- package/dist/models/scallopClient.d.ts +2 -2
- package/dist/models/scallopQuery.d.ts +1 -1
- package/dist/models/scallopUtils.d.ts +2 -2
- package/dist/queries/coreQuery.d.ts +3 -3
- package/dist/queries/loyaltyProgramQuery.d.ts +1 -1
- package/dist/queries/priceQuery.d.ts +1 -1
- package/dist/queries/vescaQuery.d.ts +1 -1
- package/dist/test.d.ts +1 -0
- package/dist/types/builder/borrowIncentive.d.ts +1 -1
- package/dist/types/builder/core.d.ts +16 -16
- package/dist/types/builder/spool.d.ts +3 -3
- package/dist/types/builder/vesca.d.ts +5 -5
- package/dist/types/model.d.ts +6 -6
- package/dist/types/query/vesca.d.ts +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/indexer.d.ts +17 -0
- package/dist/utils/query.d.ts +1 -1
- package/dist/utils/util.d.ts +4 -3
- package/package.json +15 -11
- package/src/builders/borrowIncentiveBuilder.ts +6 -6
- package/src/builders/coreBuilder.ts +17 -17
- package/src/builders/index.ts +2 -2
- package/src/builders/loyaltyProgramBuilder.ts +5 -5
- package/src/builders/oracle.ts +5 -4
- package/src/builders/referralBuilder.ts +7 -7
- package/src/builders/sCoinBuilder.ts +5 -8
- package/src/builders/spoolBuilder.ts +10 -10
- package/src/builders/vescaBuilder.ts +5 -5
- package/src/constants/common.ts +4 -4
- package/src/constants/index.ts +1 -1
- package/src/constants/vesca.ts +5 -6
- package/src/models/scallopBuilder.ts +15 -7
- package/src/models/scallopCache.ts +43 -34
- package/src/models/scallopClient.ts +10 -9
- package/src/models/scallopQuery.ts +36 -2
- package/src/models/scallopUtils.ts +5 -4
- package/src/queries/borrowIncentiveQuery.ts +1 -1
- package/src/queries/coreQuery.ts +4 -4
- package/src/queries/loyaltyProgramQuery.ts +1 -1
- package/src/queries/priceQuery.ts +1 -1
- package/src/queries/sCoinQuery.ts +2 -2
- package/src/queries/spoolQuery.ts +4 -5
- package/src/queries/vescaQuery.ts +6 -3
- package/src/test.ts +26 -0
- package/src/types/address.ts +26 -26
- package/src/types/builder/borrowIncentive.ts +1 -1
- package/src/types/builder/core.ts +26 -28
- package/src/types/builder/spool.ts +2 -3
- package/src/types/builder/vesca.ts +5 -9
- package/src/types/model.ts +6 -9
- package/src/types/query/vesca.ts +1 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/indexer.ts +39 -0
- package/src/utils/query.ts +1 -1
|
@@ -2,11 +2,12 @@ import { SuiKit } from '@scallop-io/sui-kit';
|
|
|
2
2
|
import { ScallopAddress } from './scallopAddress';
|
|
3
3
|
import { ScallopQuery } from './scallopQuery';
|
|
4
4
|
import { ScallopUtils } from './scallopUtils';
|
|
5
|
-
import type { SuiTransactionBlockResponse } from '@mysten/sui
|
|
6
|
-
import type {
|
|
5
|
+
import type { SuiTransactionBlockResponse } from '@mysten/sui/client';
|
|
6
|
+
import type { Transaction } from '@mysten/sui/transactions';
|
|
7
7
|
import type { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
8
8
|
import type { ScallopBuilderParams, ScallopTxBlock, SupportMarketCoins, SupportAssetCoins, SupportSCoin, ScallopBuilderInstanceParams, SelectCoinReturnType } from '../types';
|
|
9
9
|
import { ScallopCache } from './scallopCache';
|
|
10
|
+
import { SuiClient as SuiClientV0 } from '@mysten/sui.js/client';
|
|
10
11
|
/**
|
|
11
12
|
* @description
|
|
12
13
|
* It provides methods for operating the transaction block, making it more convenient to organize transaction combinations.
|
|
@@ -27,6 +28,7 @@ export declare class ScallopBuilder {
|
|
|
27
28
|
utils: ScallopUtils;
|
|
28
29
|
walletAddress: string;
|
|
29
30
|
cache: ScallopCache;
|
|
31
|
+
oldSuiClient: SuiClientV0;
|
|
30
32
|
constructor(params: ScallopBuilderParams, instance?: ScallopBuilderInstanceParams);
|
|
31
33
|
/**
|
|
32
34
|
* Request the scallop API to initialize data.
|
|
@@ -41,7 +43,7 @@ export declare class ScallopBuilder {
|
|
|
41
43
|
* @param txBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
|
|
42
44
|
* @return Scallop txBlock.
|
|
43
45
|
*/
|
|
44
|
-
createTxBlock(txBlock?: ScallopTxBlock | SuiKitTxBlock |
|
|
46
|
+
createTxBlock(txBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction): ScallopTxBlock;
|
|
45
47
|
/**
|
|
46
48
|
* Specifying the sender's amount of coins to get coins args from transaction result.
|
|
47
49
|
*
|
|
@@ -85,5 +87,5 @@ export declare class ScallopBuilder {
|
|
|
85
87
|
*
|
|
86
88
|
* @param txBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
|
|
87
89
|
*/
|
|
88
|
-
signAndSendTxBlock(txBlock: ScallopTxBlock | SuiKitTxBlock |
|
|
90
|
+
signAndSendTxBlock(txBlock: ScallopTxBlock | SuiKitTxBlock | Transaction): Promise<SuiTransactionBlockResponse>;
|
|
89
91
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { QueryClient, QueryClientConfig } from '@tanstack/query-core';
|
|
2
|
-
import {
|
|
2
|
+
import { SuiObjectArg, SuiTxBlock } from '@scallop-io/sui-kit';
|
|
3
3
|
import { SuiKit } from '@scallop-io/sui-kit';
|
|
4
|
-
import type { SuiObjectResponse, SuiObjectDataOptions, SuiObjectData, GetOwnedObjectsParams, DevInspectResults, GetDynamicFieldsParams, DynamicFieldPage, GetDynamicFieldObjectParams, GetBalanceParams } from '@mysten/sui
|
|
4
|
+
import type { SuiObjectResponse, SuiObjectDataOptions, SuiObjectData, GetOwnedObjectsParams, DevInspectResults, GetDynamicFieldsParams, DynamicFieldPage, GetDynamicFieldObjectParams, GetBalanceParams } from '@mysten/sui/client';
|
|
5
5
|
import { TokenBucket } from 'src/utils';
|
|
6
6
|
type QueryInspectTxnParams = {
|
|
7
7
|
queryTarget: string;
|
|
8
|
-
args:
|
|
8
|
+
args: SuiObjectArg[];
|
|
9
9
|
typeArgs?: any[];
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
@@ -38,11 +38,7 @@ export declare class ScallopCache {
|
|
|
38
38
|
* - `none`: No queries will be refetched. Queries that match the refetch predicate will only be marked as invalid.
|
|
39
39
|
*/
|
|
40
40
|
invalidateAndRefetchAllCache(refetchType: 'all' | 'active' | 'inactive' | 'none'): Promise<void>;
|
|
41
|
-
|
|
42
|
-
* @description Cache protocol config call for 60 seconds.
|
|
43
|
-
* @returns Promise<ProtocolConfig>
|
|
44
|
-
*/
|
|
45
|
-
getProtocolConfig(): Promise<import("@mysten/sui.js/client").ProtocolConfig | null>;
|
|
41
|
+
resolveArgs(txb: SuiTxBlock, args: SuiObjectArg[]): Promise<SuiObjectArg[]>;
|
|
46
42
|
/**
|
|
47
43
|
* @description Provides cache for inspectTxn of the SuiKit.
|
|
48
44
|
* @param QueryInspectTxnParams
|
|
@@ -68,7 +64,7 @@ export declare class ScallopCache {
|
|
|
68
64
|
* @param input
|
|
69
65
|
* @returns Promise<PaginatedObjectsResponse>
|
|
70
66
|
*/
|
|
71
|
-
queryGetOwnedObjects(input: GetOwnedObjectsParams): Promise<import("@mysten/sui
|
|
67
|
+
queryGetOwnedObjects(input: GetOwnedObjectsParams): Promise<import("@mysten/sui/client").PaginatedObjectsResponse | null>;
|
|
72
68
|
queryGetDynamicFields(input: GetDynamicFieldsParams): Promise<DynamicFieldPage | null>;
|
|
73
69
|
queryGetDynamicFieldObject(input: GetDynamicFieldObjectParams): Promise<SuiObjectResponse | null>;
|
|
74
70
|
queryGetAllCoinBalances(owner: string): Promise<{
|
|
@@ -3,9 +3,9 @@ import { ScallopAddress } from './scallopAddress';
|
|
|
3
3
|
import { ScallopUtils } from './scallopUtils';
|
|
4
4
|
import { ScallopBuilder } from './scallopBuilder';
|
|
5
5
|
import { ScallopQuery } from './scallopQuery';
|
|
6
|
+
import type { SuiTransactionBlockResponse } from '@mysten/sui/client';
|
|
7
|
+
import type { TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
6
8
|
import { ScallopCache } from './scallopCache';
|
|
7
|
-
import type { SuiTransactionBlockResponse } from '@mysten/sui.js/client';
|
|
8
|
-
import type { TransactionObjectArgument } from '@mysten/sui.js/transactions';
|
|
9
9
|
import type { SuiObjectArg } from '@scallop-io/sui-kit';
|
|
10
10
|
import type { ScallopClientFnReturnType, ScallopClientParams, SupportPoolCoins, SupportCollateralCoins, SupportAssetCoins, SupportStakeCoins, SupportStakeMarketCoins, SupportBorrowIncentiveCoins, ScallopTxBlock, ScallopClientVeScaReturnType, ScallopClientInstanceParams } from '../types';
|
|
11
11
|
/**
|
|
@@ -4,7 +4,7 @@ import { ScallopAddress } from './scallopAddress';
|
|
|
4
4
|
import { ScallopUtils } from './scallopUtils';
|
|
5
5
|
import { ScallopIndexer } from './scallopIndexer';
|
|
6
6
|
import { ScallopCache } from './scallopCache';
|
|
7
|
-
import { SuiObjectData } from '@mysten/sui
|
|
7
|
+
import { SuiObjectData } from '@mysten/sui/src/client';
|
|
8
8
|
/**
|
|
9
9
|
* @description
|
|
10
10
|
* It provides methods for getting on-chain data from the Scallop contract.
|
|
@@ -2,7 +2,7 @@ import { SuiKit } from '@scallop-io/sui-kit';
|
|
|
2
2
|
import { ScallopAddress } from './scallopAddress';
|
|
3
3
|
import { ScallopCache } from './scallopCache';
|
|
4
4
|
import type { ScallopUtilsParams, SupportCoins, SupportAssetCoins, SupportMarketCoins, SupportStakeMarketCoins, SupportBorrowIncentiveCoins, CoinWrappedType, SupportSCoin, ScallopUtilsInstanceParams, SupportSuiBridgeCoins, SupportWormholeCoins } from '../types';
|
|
5
|
-
import type {
|
|
5
|
+
import type { SuiObjectArg, SuiTxArg, SuiTxBlock } from '@scallop-io/sui-kit';
|
|
6
6
|
/**
|
|
7
7
|
* @description
|
|
8
8
|
* Integrates some helper functions frequently used in interactions with the Scallop contract.
|
|
@@ -170,7 +170,7 @@ export declare class ScallopUtils {
|
|
|
170
170
|
* @param obligationId - The obligation id.
|
|
171
171
|
* @return Asset coin Names.
|
|
172
172
|
*/
|
|
173
|
-
getObligationCoinNames(obligationId:
|
|
173
|
+
getObligationCoinNames(obligationId: SuiObjectArg): Promise<SupportAssetCoins[] | undefined>;
|
|
174
174
|
/**
|
|
175
175
|
* Get asset coin price.
|
|
176
176
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { SuiObjectData } from '@mysten/sui
|
|
2
|
-
import type {
|
|
1
|
+
import type { SuiObjectData } from '@mysten/sui/client';
|
|
2
|
+
import type { SuiObjectArg } from '@scallop-io/sui-kit';
|
|
3
3
|
import type { ScallopAddress, ScallopCache, ScallopQuery } from '../models';
|
|
4
4
|
import { Market, MarketPool, MarketCollateral, SupportAssetCoins, SupportPoolCoins, SupportCollateralCoins, ObligationQueryInterface, Obligation, SupportMarketCoins, OptionalKeys } from '../types';
|
|
5
5
|
/**
|
|
@@ -121,7 +121,7 @@ export declare const getObligationLocked: (cache: ScallopCache, obligation: stri
|
|
|
121
121
|
*/
|
|
122
122
|
export declare const queryObligation: ({ address, }: {
|
|
123
123
|
address: ScallopAddress;
|
|
124
|
-
}, obligationId:
|
|
124
|
+
}, obligationId: SuiObjectArg) => Promise<ObligationQueryInterface | undefined>;
|
|
125
125
|
/**
|
|
126
126
|
* Query all owned coin amount.
|
|
127
127
|
*
|
package/dist/test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SuiTxBlock as SuiKitTxBlock, SuiObjectArg } from '@scallop-io/sui-kit';
|
|
2
|
-
import type { TransactionResult } from '@mysten/sui
|
|
2
|
+
import type { TransactionResult } from '@mysten/sui/transactions';
|
|
3
3
|
import type { ScallopBuilder } from '../../models';
|
|
4
4
|
import type { SupportBorrowIncentiveCoins, SupportBorrowIncentiveRewardCoins } from '../constant';
|
|
5
5
|
export type BorrowIncentiveIds = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { SuiTxBlock as SuiKitTxBlock,
|
|
2
|
-
import type { TransactionArgument, TransactionResult } from '@mysten/sui
|
|
1
|
+
import type { SuiTxBlock as SuiKitTxBlock, SuiObjectArg } from '@scallop-io/sui-kit';
|
|
2
|
+
import type { TransactionArgument, TransactionResult } from '@mysten/sui/transactions';
|
|
3
3
|
import type { ScallopBuilder } from '../../models';
|
|
4
4
|
import type { SupportCollateralCoins, SupportPoolCoins, SupportAssetCoins } from '../constant';
|
|
5
5
|
import { SuiTxBlockWithSpool } from '.';
|
|
@@ -18,29 +18,29 @@ type ObligationKey = NestedResult;
|
|
|
18
18
|
type ObligationHotPotato = NestedResult;
|
|
19
19
|
export type CoreNormalMethods = {
|
|
20
20
|
openObligation: () => [Obligation, ObligationKey, ObligationHotPotato];
|
|
21
|
-
returnObligation: (obligation:
|
|
21
|
+
returnObligation: (obligation: SuiObjectArg, obligationHotPotato: SuiObjectArg) => void;
|
|
22
22
|
openObligationEntry: () => void;
|
|
23
|
-
addCollateral: (obligation:
|
|
24
|
-
takeCollateral: (obligation:
|
|
23
|
+
addCollateral: (obligation: SuiObjectArg, coin: SuiObjectArg, collateralCoinName: SupportCollateralCoins) => void;
|
|
24
|
+
takeCollateral: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, amount: number, collateralCoinName: SupportCollateralCoins) => TransactionResult;
|
|
25
25
|
deposit: (coin: SuiObjectArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
26
26
|
depositEntry: (coin: SuiObjectArg, poolCoinName: SupportPoolCoins) => void;
|
|
27
27
|
withdraw: (marketCoin: SuiObjectArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
28
28
|
withdrawEntry: (marketCoin: SuiObjectArg, poolCoinName: SupportPoolCoins) => void;
|
|
29
|
-
borrow: (obligation:
|
|
30
|
-
borrowWithReferral: (obligation:
|
|
31
|
-
borrowEntry: (obligation:
|
|
32
|
-
repay: (obligation:
|
|
33
|
-
borrowFlashLoan: (amount:
|
|
34
|
-
repayFlashLoan: (coin: SuiObjectArg, loan:
|
|
29
|
+
borrow: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, amount: number, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
30
|
+
borrowWithReferral: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, borrowReferral: SuiObjectArg, amount: number, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
31
|
+
borrowEntry: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, amount: number, poolCoinName: SupportPoolCoins) => void;
|
|
32
|
+
repay: (obligation: SuiObjectArg, coin: SuiObjectArg, poolCoinName: SupportPoolCoins) => void;
|
|
33
|
+
borrowFlashLoan: (amount: number, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
34
|
+
repayFlashLoan: (coin: SuiObjectArg, loan: SuiObjectArg, poolCoinName: SupportPoolCoins) => void;
|
|
35
35
|
};
|
|
36
36
|
export type CoreQuickMethods = {
|
|
37
|
-
addCollateralQuick: (amount: number, collateralCoinName: SupportCollateralCoins, obligationId?:
|
|
38
|
-
takeCollateralQuick: (amount: number, collateralCoinName: SupportCollateralCoins, obligationId?:
|
|
39
|
-
borrowQuick: (amount: number, poolCoinName: SupportPoolCoins, obligationId?:
|
|
40
|
-
borrowWithReferralQuick: (amount: number, poolCoinName: SupportPoolCoins, borrowReferral: SuiObjectArg, obligationId?:
|
|
37
|
+
addCollateralQuick: (amount: number, collateralCoinName: SupportCollateralCoins, obligationId?: SuiObjectArg) => Promise<void>;
|
|
38
|
+
takeCollateralQuick: (amount: number, collateralCoinName: SupportCollateralCoins, obligationId?: SuiObjectArg, obligationKey?: SuiObjectArg) => Promise<TransactionResult>;
|
|
39
|
+
borrowQuick: (amount: number, poolCoinName: SupportPoolCoins, obligationId?: SuiObjectArg, obligationKey?: SuiObjectArg) => Promise<TransactionResult>;
|
|
40
|
+
borrowWithReferralQuick: (amount: number, poolCoinName: SupportPoolCoins, borrowReferral: SuiObjectArg, obligationId?: SuiObjectArg, obligationKey?: SuiObjectArg) => Promise<TransactionResult>;
|
|
41
41
|
depositQuick: (amount: number, poolCoinName: SupportPoolCoins, returnSCoin?: boolean) => Promise<TransactionResult>;
|
|
42
42
|
withdrawQuick: (amount: number, poolCoinName: SupportPoolCoins) => Promise<TransactionResult>;
|
|
43
|
-
repayQuick: (amount: number, poolCoinName: SupportPoolCoins, obligationId?:
|
|
43
|
+
repayQuick: (amount: number, poolCoinName: SupportPoolCoins, obligationId?: SuiObjectArg) => Promise<void>;
|
|
44
44
|
updateAssetPricesQuick: (assetCoinNames?: SupportAssetCoins[]) => Promise<void>;
|
|
45
45
|
};
|
|
46
46
|
export type SuiTxBlockWithCoreNormalMethods = SuiKitTxBlock & SuiTxBlockWithSpool & CoreNormalMethods;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { SuiTxBlock as SuiKitTxBlock, SuiAddressArg, SuiObjectArg
|
|
2
|
-
import type { TransactionResult } from '@mysten/sui
|
|
1
|
+
import type { SuiTxBlock as SuiKitTxBlock, SuiAddressArg, SuiObjectArg } from '@scallop-io/sui-kit';
|
|
2
|
+
import type { TransactionResult } from '@mysten/sui/transactions';
|
|
3
3
|
import type { ScallopBuilder } from '../../models';
|
|
4
4
|
import type { SupportStakeMarketCoins } from '../constant';
|
|
5
5
|
import { SuiTxBlockWithSCoin } from '.';
|
|
@@ -9,7 +9,7 @@ export type SpoolIds = {
|
|
|
9
9
|
export type SpoolNormalMethods = {
|
|
10
10
|
createStakeAccount: (stakeMarketCoinName: SupportStakeMarketCoins) => TransactionResult;
|
|
11
11
|
stake: (stakeAccount: SuiAddressArg, coin: SuiObjectArg, stakeMarketCoinName: SupportStakeMarketCoins) => void;
|
|
12
|
-
unstake: (stakeAccount: SuiAddressArg, amount:
|
|
12
|
+
unstake: (stakeAccount: SuiAddressArg, amount: number, stakeMarketCoinName: SupportStakeMarketCoins) => TransactionResult;
|
|
13
13
|
claim: (stakeAccount: SuiAddressArg, stakeMarketCoinName: SupportStakeMarketCoins) => TransactionResult;
|
|
14
14
|
};
|
|
15
15
|
export type SpoolQuickMethods = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SuiTxBlock as SuiKitTxBlock, SuiObjectArg
|
|
2
|
-
import type { TransactionResult } from '@mysten/sui
|
|
1
|
+
import { SuiTxBlock as SuiKitTxBlock, SuiObjectArg } from '@scallop-io/sui-kit';
|
|
2
|
+
import type { TransactionResult } from '@mysten/sui/transactions';
|
|
3
3
|
import { ScallopBuilder } from 'src/models';
|
|
4
4
|
export type VescaIds = {
|
|
5
5
|
pkgId: string;
|
|
@@ -8,10 +8,10 @@ export type VescaIds = {
|
|
|
8
8
|
config: string;
|
|
9
9
|
};
|
|
10
10
|
export type VeScaNormalMethods = {
|
|
11
|
-
lockSca: (scaCoin: SuiObjectArg, unlockAtInSecondTimestamp:
|
|
12
|
-
extendLockPeriod: (veScaKey: SuiObjectArg, newUnlockAtInSecondTimestamp:
|
|
11
|
+
lockSca: (scaCoin: SuiObjectArg, unlockAtInSecondTimestamp: number) => TransactionResult;
|
|
12
|
+
extendLockPeriod: (veScaKey: SuiObjectArg, newUnlockAtInSecondTimestamp: number) => void;
|
|
13
13
|
extendLockAmount: (veScaKey: SuiObjectArg, scaCoin: SuiObjectArg) => void;
|
|
14
|
-
renewExpiredVeSca: (veScaKey: SuiObjectArg, scaCoin: SuiObjectArg, newUnlockAtInSecondTimestamp:
|
|
14
|
+
renewExpiredVeSca: (veScaKey: SuiObjectArg, scaCoin: SuiObjectArg, newUnlockAtInSecondTimestamp: number) => void;
|
|
15
15
|
redeemSca: (veScaKey: SuiObjectArg) => TransactionResult;
|
|
16
16
|
mintEmptyVeSca: () => TransactionResult;
|
|
17
17
|
};
|
package/dist/types/model.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { SuiTransactionBlockResponse } from '@mysten/sui
|
|
2
|
-
import type {
|
|
1
|
+
import type { SuiTransactionBlockResponse } from '@mysten/sui/client';
|
|
2
|
+
import type { Transaction, TransactionResult } from '@mysten/sui/transactions';
|
|
3
3
|
import type { SuiKit, SuiKitParams, NetworkType } from '@scallop-io/sui-kit';
|
|
4
4
|
import type { ScallopAddress, ScallopQuery, ScallopUtils, ScallopBuilder, ScallopIndexer } from '../models';
|
|
5
5
|
import { ScallopCache } from 'src/models/scallopCache';
|
|
6
6
|
import { AddressesInterface } from './address';
|
|
7
|
-
export type ScallopClientFnReturnType<T extends boolean> = T extends true ? SuiTransactionBlockResponse :
|
|
7
|
+
export type ScallopClientFnReturnType<T extends boolean> = T extends true ? SuiTransactionBlockResponse : Transaction;
|
|
8
8
|
export type ScallopClientVeScaReturnType<T extends boolean> = T extends true ? SuiTransactionBlockResponse : {
|
|
9
|
-
tx:
|
|
9
|
+
tx: Transaction;
|
|
10
10
|
scaCoin: TransactionResult;
|
|
11
11
|
};
|
|
12
12
|
export type ScallopBaseInstanceParams = {
|
|
@@ -36,11 +36,11 @@ export type ScallopAddressParams = {
|
|
|
36
36
|
id: string;
|
|
37
37
|
auth?: string;
|
|
38
38
|
network?: NetworkType;
|
|
39
|
-
forceInterface?: Record<NetworkType, AddressesInterface
|
|
39
|
+
forceInterface?: Partial<Record<NetworkType, AddressesInterface>>;
|
|
40
40
|
};
|
|
41
41
|
export type ScallopParams = {
|
|
42
42
|
addressesId?: string;
|
|
43
|
-
forceAddressesInterface?: Record<NetworkType, AddressesInterface
|
|
43
|
+
forceAddressesInterface?: Partial<Record<NetworkType, AddressesInterface>>;
|
|
44
44
|
walletAddress?: string;
|
|
45
45
|
} & SuiKitParams;
|
|
46
46
|
export type ScallopClientParams = ScallopParams & ScallopBuilderParams & ScallopQueryParams & ScallopUtilsParams;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic wrapper for methods with indexer fallback.
|
|
3
|
+
*
|
|
4
|
+
* @param method - The method to call with fallback behavior.
|
|
5
|
+
* @param context - The context (`this`) of the class instance.
|
|
6
|
+
* @param args - The arguments to pass to the method.
|
|
7
|
+
* @returns The result of the method call.
|
|
8
|
+
*/
|
|
9
|
+
export declare function callMethodWithIndexerFallback(method: Function, context: any, ...args: any[]): Promise<any>;
|
|
10
|
+
/**
|
|
11
|
+
* This function creates a wrapper for methods that have an indexer parameter.
|
|
12
|
+
* It ensures fallback behavior if indexer fails.
|
|
13
|
+
*
|
|
14
|
+
* @param method - The method to wrap.
|
|
15
|
+
* @returns A function that applies indexer fallback.
|
|
16
|
+
*/
|
|
17
|
+
export declare function withIndexerFallback(method: Function): (...args: any[]) => Promise<any>;
|
package/dist/utils/query.d.ts
CHANGED
|
@@ -59,4 +59,4 @@ export declare const maxBigNumber: (...args: BigNumber.Value[]) => BigNumber;
|
|
|
59
59
|
* @param type - The type of the calculation.
|
|
60
60
|
* @return The estimated factor
|
|
61
61
|
* */
|
|
62
|
-
export declare const estimatedFactor: (amount: number, scaleStep: number, type:
|
|
62
|
+
export declare const estimatedFactor: (amount: number, scaleStep: number, type: "increase" | "decrease") => number;
|
package/dist/utils/util.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { PriceFeed } from '@pythnetwork/pyth-sui-js';
|
|
1
2
|
import type { ScallopAddress } from '../models';
|
|
2
|
-
import type { SupportAssetCoins, SupportCoins, SupportMarketCoins } from '../types';
|
|
3
|
+
import type { SupportAssetCoins, SupportCoins, SupportMarketCoins, SupportSuiBridgeCoins, SupportWormholeCoins } from '../types';
|
|
3
4
|
export declare const isMarketCoin: (coinName: SupportCoins) => coinName is SupportMarketCoins;
|
|
4
|
-
export declare const isSuiBridgeAsset: (coinName: any) => coinName is
|
|
5
|
-
export declare const isWormholeAsset: (coinName: any) => coinName is
|
|
5
|
+
export declare const isSuiBridgeAsset: (coinName: any) => coinName is SupportSuiBridgeCoins;
|
|
6
|
+
export declare const isWormholeAsset: (coinName: any) => coinName is SupportWormholeCoins;
|
|
6
7
|
export declare const parseAssetSymbol: (coinName: SupportCoins) => string;
|
|
7
8
|
/**
|
|
8
9
|
* Parse price from pyth price feed.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scallop-io/sui-scallop-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.3.0-alpha.2",
|
|
4
4
|
"description": "Typescript sdk for interacting with Scallop contract on SUI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sui",
|
|
@@ -38,14 +38,15 @@
|
|
|
38
38
|
"src"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@graphql-typed-document-node/core": "
|
|
42
|
-
"@mysten/bcs": "^0.
|
|
43
|
-
"@mysten/sui
|
|
41
|
+
"@graphql-typed-document-node/core": "3.2.0",
|
|
42
|
+
"@mysten/bcs": "^1.0.3",
|
|
43
|
+
"@mysten/sui": "^1.3.0",
|
|
44
|
+
"@mysten/sui.js": "0.54.1",
|
|
44
45
|
"@noble/curves": "^1.2.0",
|
|
45
46
|
"@noble/hashes": "^1.3.2",
|
|
46
47
|
"@pythnetwork/price-service-client": "^1.8.2",
|
|
47
48
|
"@pythnetwork/pyth-sui-js": "2.0.0",
|
|
48
|
-
"@scallop-io/sui-kit": "
|
|
49
|
+
"@scallop-io/sui-kit": "1.3.1-alpha.1",
|
|
49
50
|
"@scure/bip39": "^1.2.1",
|
|
50
51
|
"@tanstack/query-core": "^5.28.0",
|
|
51
52
|
"axios": "^1.6.0",
|
|
@@ -55,32 +56,35 @@
|
|
|
55
56
|
"graphql": "^16.9.0",
|
|
56
57
|
"superstruct": "^1.0.3",
|
|
57
58
|
"tweetnacl": "^1.0.3",
|
|
59
|
+
"valibot": "^0.36.0",
|
|
58
60
|
"zod": "^3.23.8"
|
|
59
61
|
},
|
|
60
62
|
"devDependencies": {
|
|
61
63
|
"@commitlint/cli": "^18.2.0",
|
|
62
64
|
"@commitlint/config-conventional": "^18.1.0",
|
|
63
65
|
"@commitlint/prompt-cli": "^18.2.0",
|
|
64
|
-
"@types/node": "^20.
|
|
65
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
66
|
-
"@typescript-eslint/parser": "
|
|
66
|
+
"@types/node": "^20.4.2",
|
|
67
|
+
"@typescript-eslint/eslint-plugin": "^8.11.0",
|
|
68
|
+
"@typescript-eslint/parser": "8.10.0",
|
|
67
69
|
"dotenv": "^16.3.1",
|
|
68
70
|
"eslint": "^8.53.0",
|
|
69
71
|
"eslint-config-prettier": "^9.0.0",
|
|
70
72
|
"eslint-plugin-prettier": "^5.0.1",
|
|
73
|
+
"graphql-config": "^5.0.3",
|
|
71
74
|
"husky": "^8.0.3",
|
|
72
75
|
"lint-staged": "^15.0.2",
|
|
73
76
|
"prettier": "^3.0.3",
|
|
74
77
|
"standard-version": "^9.5.0",
|
|
75
78
|
"tsconfig-paths": "^4.2.0",
|
|
76
79
|
"tsup": "^7.2.0",
|
|
77
|
-
"typedoc": "^0.
|
|
78
|
-
"typescript": "
|
|
80
|
+
"typedoc": "^0.26.3",
|
|
81
|
+
"typescript": "5.5.4",
|
|
79
82
|
"vitest": "^0.34.6"
|
|
80
83
|
},
|
|
81
84
|
"peerDependencies": {
|
|
85
|
+
"@mysten/sui": "1.3.0",
|
|
82
86
|
"@mysten/sui.js": "0.54.1",
|
|
83
|
-
"@scallop-io/sui-kit": "
|
|
87
|
+
"@scallop-io/sui-kit": "1.3.1-alpha.1",
|
|
84
88
|
"bn.js": "^5.2.1"
|
|
85
89
|
},
|
|
86
90
|
"lint-staged": {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui
|
|
1
|
+
import { Transaction } from '@mysten/sui/transactions';
|
|
2
|
+
import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui/utils';
|
|
3
3
|
import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
4
4
|
import { getObligations, getObligationLocked } from '../queries';
|
|
5
5
|
import { requireSender } from '../utils';
|
|
@@ -315,14 +315,14 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
|
315
315
|
*/
|
|
316
316
|
export const newBorrowIncentiveTxBlock = (
|
|
317
317
|
builder: ScallopBuilder,
|
|
318
|
-
initTxBlock?: ScallopTxBlock | SuiKitTxBlock |
|
|
318
|
+
initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction
|
|
319
319
|
) => {
|
|
320
320
|
const txBlock =
|
|
321
|
-
initTxBlock instanceof
|
|
321
|
+
initTxBlock instanceof Transaction
|
|
322
322
|
? new SuiKitTxBlock(initTxBlock)
|
|
323
323
|
: initTxBlock
|
|
324
|
-
|
|
325
|
-
|
|
324
|
+
? initTxBlock
|
|
325
|
+
: new SuiKitTxBlock();
|
|
326
326
|
|
|
327
327
|
const normalMethod = generateBorrowIncentiveNormalMethod({
|
|
328
328
|
builder,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui
|
|
1
|
+
import { Transaction } from '@mysten/sui/transactions';
|
|
2
|
+
import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui/utils';
|
|
3
3
|
import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
4
4
|
import { getObligations } from '../queries';
|
|
5
5
|
import { updateOracles } from './oracle';
|
|
6
6
|
import { requireSender } from '../utils';
|
|
7
|
-
import type {
|
|
7
|
+
import type { SuiObjectArg, TransactionResult } from '@scallop-io/sui-kit';
|
|
8
8
|
import type { ScallopBuilder } from '../models';
|
|
9
9
|
import type {
|
|
10
10
|
CoreIds,
|
|
@@ -35,8 +35,8 @@ const requireObligationInfo = async (
|
|
|
35
35
|
...params: [
|
|
36
36
|
builder: ScallopBuilder,
|
|
37
37
|
txBlock: SuiKitTxBlock,
|
|
38
|
-
obligationId?:
|
|
39
|
-
obligationKey?:
|
|
38
|
+
obligationId?: SuiObjectArg,
|
|
39
|
+
obligationKey?: SuiObjectArg,
|
|
40
40
|
]
|
|
41
41
|
) => {
|
|
42
42
|
const [builder, txBlock, obligationId, obligationKey] = params;
|
|
@@ -116,7 +116,7 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
116
116
|
obligationKey,
|
|
117
117
|
coreIds.market,
|
|
118
118
|
coreIds.coinDecimalsRegistry,
|
|
119
|
-
amount,
|
|
119
|
+
txBlock.pure.u64(amount),
|
|
120
120
|
coreIds.xOracle,
|
|
121
121
|
SUI_CLOCK_OBJECT_ID,
|
|
122
122
|
],
|
|
@@ -189,7 +189,7 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
189
189
|
coreIds.market,
|
|
190
190
|
coreIds.coinDecimalsRegistry,
|
|
191
191
|
borrowReferral,
|
|
192
|
-
amount,
|
|
192
|
+
txBlock.pure.u64(amount),
|
|
193
193
|
coreIds.xOracle,
|
|
194
194
|
SUI_CLOCK_OBJECT_ID,
|
|
195
195
|
],
|
|
@@ -206,7 +206,7 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
206
206
|
obligationKey,
|
|
207
207
|
coreIds.market,
|
|
208
208
|
coreIds.coinDecimalsRegistry,
|
|
209
|
-
amount,
|
|
209
|
+
txBlock.pure.u64(amount),
|
|
210
210
|
coreIds.xOracle,
|
|
211
211
|
SUI_CLOCK_OBJECT_ID,
|
|
212
212
|
],
|
|
@@ -303,7 +303,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
303
303
|
await updateOracles(builder, txBlock, updateCoinNames);
|
|
304
304
|
return txBlock.takeCollateral(
|
|
305
305
|
obligationInfo.obligationId,
|
|
306
|
-
obligationInfo.obligationKey as
|
|
306
|
+
obligationInfo.obligationKey as SuiObjectArg,
|
|
307
307
|
amount,
|
|
308
308
|
collateralCoinName
|
|
309
309
|
);
|
|
@@ -364,11 +364,11 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
364
364
|
txBlock.transferObjects([leftCoin], sender);
|
|
365
365
|
txBlock.mergeCoins(marketCoins, [walletMarketCoins]);
|
|
366
366
|
}
|
|
367
|
-
} catch (
|
|
367
|
+
} catch (_e) {
|
|
368
368
|
// ignore
|
|
369
369
|
}
|
|
370
370
|
return txBlock.withdraw(marketCoins, poolCoinName);
|
|
371
|
-
} catch (
|
|
371
|
+
} catch (_e) {
|
|
372
372
|
// no sCoin found
|
|
373
373
|
const { leftCoin, takeCoin: walletMarketCoins } =
|
|
374
374
|
await builder.selectMarketCoin(
|
|
@@ -396,7 +396,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
396
396
|
await updateOracles(builder, txBlock, updateCoinNames);
|
|
397
397
|
return txBlock.borrow(
|
|
398
398
|
obligationInfo.obligationId,
|
|
399
|
-
obligationInfo.obligationKey as
|
|
399
|
+
obligationInfo.obligationKey as SuiObjectArg,
|
|
400
400
|
amount,
|
|
401
401
|
poolCoinName
|
|
402
402
|
);
|
|
@@ -422,7 +422,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
422
422
|
await updateOracles(builder, txBlock, updateCoinNames);
|
|
423
423
|
return txBlock.borrowWithReferral(
|
|
424
424
|
obligationInfo.obligationId,
|
|
425
|
-
obligationInfo.obligationKey as
|
|
425
|
+
obligationInfo.obligationKey as SuiObjectArg,
|
|
426
426
|
borrowReferral,
|
|
427
427
|
amount,
|
|
428
428
|
poolCoinName
|
|
@@ -476,15 +476,15 @@ export const newCoreTxBlock = (
|
|
|
476
476
|
initTxBlock?:
|
|
477
477
|
| ScallopTxBlock
|
|
478
478
|
| SuiKitTxBlock
|
|
479
|
-
|
|
|
479
|
+
| Transaction
|
|
480
480
|
| SuiTxBlockWithSpool
|
|
481
481
|
) => {
|
|
482
482
|
const txBlock =
|
|
483
|
-
initTxBlock instanceof
|
|
483
|
+
initTxBlock instanceof Transaction
|
|
484
484
|
? new SuiKitTxBlock(initTxBlock)
|
|
485
485
|
: initTxBlock
|
|
486
|
-
|
|
487
|
-
|
|
486
|
+
? initTxBlock
|
|
487
|
+
: new SuiKitTxBlock();
|
|
488
488
|
|
|
489
489
|
const normalMethod = generateCoreNormalMethod({
|
|
490
490
|
builder,
|
package/src/builders/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Transaction } from '@mysten/sui/transactions';
|
|
2
2
|
import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
3
3
|
import { newCoreTxBlock } from './coreBuilder';
|
|
4
4
|
import { newSpoolTxBlock } from './spoolBuilder';
|
|
@@ -19,7 +19,7 @@ import { newSCoinTxBlock } from './sCoinBuilder';
|
|
|
19
19
|
*/
|
|
20
20
|
export const newScallopTxBlock = (
|
|
21
21
|
builder: ScallopBuilder,
|
|
22
|
-
initTxBlock?: ScallopTxBlock | SuiKitTxBlock |
|
|
22
|
+
initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction
|
|
23
23
|
): ScallopTxBlock => {
|
|
24
24
|
const vescaTxBlock = newVeScaTxBlock(builder, initTxBlock);
|
|
25
25
|
const loyaltyTxBlock = newLoyaltyProgramTxBlock(builder, vescaTxBlock);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Transaction } from '@mysten/sui/transactions';
|
|
2
2
|
import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
3
3
|
import { coinIds } from 'src/constants';
|
|
4
4
|
import { ScallopBuilder } from 'src/models';
|
|
@@ -66,14 +66,14 @@ const generateLoyaltyProgramQuickMethod: GenerateLoyaltyProgramQuickMethod = ({
|
|
|
66
66
|
*/
|
|
67
67
|
export const newLoyaltyProgramTxBlock = (
|
|
68
68
|
builder: ScallopBuilder,
|
|
69
|
-
initTxBlock?: ScallopTxBlock | SuiKitTxBlock |
|
|
69
|
+
initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction
|
|
70
70
|
) => {
|
|
71
71
|
const txBlock =
|
|
72
|
-
initTxBlock instanceof
|
|
72
|
+
initTxBlock instanceof Transaction
|
|
73
73
|
? new SuiKitTxBlock(initTxBlock)
|
|
74
74
|
: initTxBlock
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
? initTxBlock
|
|
76
|
+
: new SuiKitTxBlock();
|
|
77
77
|
|
|
78
78
|
const normalMethod = generateLoyaltyProgramNormalMethod({
|
|
79
79
|
builder,
|