@scallop-io/sui-scallop-sdk 0.47.3 → 1.3.0-alpha.1
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 +87 -71
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +90 -77
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopBuilder.d.ts +10 -8
- 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 +4 -4
- package/dist/types/query/vesca.d.ts +1 -1
- package/dist/utils/query.d.ts +1 -1
- package/dist/utils/util.d.ts +1 -0
- package/package.json +13 -9
- package/src/builders/borrowIncentiveBuilder.ts +6 -6
- package/src/builders/coreBuilder.ts +15 -15
- 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 +6 -6
- package/src/builders/sCoinBuilder.ts +5 -8
- package/src/builders/spoolBuilder.ts +9 -9
- 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 +14 -7
- package/src/models/scallopCache.ts +43 -34
- package/src/models/scallopClient.ts +8 -6
- package/src/models/scallopQuery.ts +2 -2
- package/src/models/scallopUtils.ts +3 -3
- 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 +4 -7
- package/src/types/query/vesca.ts +1 -1
- 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
|
*
|
|
@@ -62,8 +64,8 @@ export declare class ScallopBuilder {
|
|
|
62
64
|
* @return Take coin and left coin.
|
|
63
65
|
*/
|
|
64
66
|
selectMarketCoin(txBlock: ScallopTxBlock | SuiKitTxBlock, marketCoinName: SupportMarketCoins, amount: number, sender?: string): Promise<{
|
|
65
|
-
takeCoin:
|
|
66
|
-
leftCoin:
|
|
67
|
+
takeCoin: any;
|
|
68
|
+
leftCoin: any;
|
|
67
69
|
totalAmount: number;
|
|
68
70
|
}>;
|
|
69
71
|
/**
|
|
@@ -76,8 +78,8 @@ export declare class ScallopBuilder {
|
|
|
76
78
|
* @return Take coin and left coin.
|
|
77
79
|
*/
|
|
78
80
|
selectSCoin(txBlock: ScallopTxBlock | SuiKitTxBlock, sCoinName: SupportSCoin, amount: number, sender?: string): Promise<{
|
|
79
|
-
takeCoin:
|
|
80
|
-
leftCoin:
|
|
81
|
+
takeCoin: any;
|
|
82
|
+
leftCoin: any;
|
|
81
83
|
totalAmount: number;
|
|
82
84
|
}>;
|
|
83
85
|
/**
|
|
@@ -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 } 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.
|
|
@@ -168,7 +168,7 @@ export declare class ScallopUtils {
|
|
|
168
168
|
* @param obligationId - The obligation id.
|
|
169
169
|
* @return Asset coin Names.
|
|
170
170
|
*/
|
|
171
|
-
getObligationCoinNames(obligationId:
|
|
171
|
+
getObligationCoinNames(obligationId: SuiObjectArg): Promise<SupportAssetCoins[] | undefined>;
|
|
172
172
|
/**
|
|
173
173
|
* Get asset coin price.
|
|
174
174
|
*
|
|
@@ -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
|
/**
|
|
@@ -119,7 +119,7 @@ export declare const getObligationLocked: (cache: ScallopCache, obligation: stri
|
|
|
119
119
|
*/
|
|
120
120
|
export declare const queryObligation: ({ address, }: {
|
|
121
121
|
address: ScallopAddress;
|
|
122
|
-
}, obligationId:
|
|
122
|
+
}, obligationId: SuiObjectArg) => Promise<ObligationQueryInterface | undefined>;
|
|
123
123
|
/**
|
|
124
124
|
* Query all owned coin amount.
|
|
125
125
|
*
|
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,11 +1,11 @@
|
|
|
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
|
-
export type ScallopClientFnReturnType<T extends boolean> = T extends true ? SuiTransactionBlockResponse :
|
|
6
|
+
export type ScallopClientFnReturnType<T extends boolean> = T extends true ? SuiTransactionBlockResponse : Transaction;
|
|
7
7
|
export type ScallopClientVeScaReturnType<T extends boolean> = T extends true ? SuiTransactionBlockResponse : {
|
|
8
|
-
tx:
|
|
8
|
+
tx: Transaction;
|
|
9
9
|
scaCoin: TransactionResult;
|
|
10
10
|
};
|
|
11
11
|
export type ScallopBaseInstanceParams = {
|
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,3 +1,4 @@
|
|
|
1
|
+
import type { PriceFeed } from '@pythnetwork/pyth-sui-js';
|
|
1
2
|
import type { ScallopAddress } from '../models';
|
|
2
3
|
import type { SupportAssetCoins, SupportCoins, SupportMarketCoins } from '../types';
|
|
3
4
|
export declare const isMarketCoin: (coinName: SupportCoins) => coinName is SupportMarketCoins;
|
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.1",
|
|
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.0",
|
|
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.
|
|
66
|
+
"@types/node": "^20.4.2",
|
|
65
67
|
"@typescript-eslint/eslint-plugin": "^6.10.0",
|
|
66
68
|
"@typescript-eslint/parser": "^6.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": "^5.
|
|
80
|
+
"typedoc": "^0.26.3",
|
|
81
|
+
"typescript": "^5.3.3",
|
|
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.0",
|
|
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
|
);
|
|
@@ -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,
|
package/src/builders/oracle.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui
|
|
1
|
+
import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui/utils';
|
|
2
2
|
import {
|
|
3
3
|
SuiPythClient,
|
|
4
4
|
SuiPriceServiceConnection,
|
|
5
5
|
} from '@pythnetwork/pyth-sui-js';
|
|
6
6
|
import { SUPPORT_COLLATERALS, SUPPORT_POOLS } from '../constants';
|
|
7
|
-
import type { TransactionArgument } from '@mysten/sui
|
|
7
|
+
import type { TransactionArgument } from '@mysten/sui/transactions';
|
|
8
8
|
import type { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
9
9
|
import type { ScallopBuilder } from '../models';
|
|
10
10
|
import type { SupportAssetCoins, SupportOracleType } from '../types';
|
|
11
11
|
import { PYTH_ENDPOINTS } from 'src/constants/pyth';
|
|
12
|
+
import { TransactionBlock } from '@mysten/sui.js/transactions';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Update the price of the oracle for multiple coin.
|
|
@@ -34,7 +35,7 @@ export const updateOracles = async (
|
|
|
34
35
|
const rules: SupportOracleType[] = builder.isTestnet ? ['pyth'] : ['pyth'];
|
|
35
36
|
if (usePythPullModel && rules.includes('pyth')) {
|
|
36
37
|
const pythClient = new SuiPythClient(
|
|
37
|
-
builder.
|
|
38
|
+
builder.oldSuiClient,
|
|
38
39
|
builder.address.get('core.oracles.pyth.state'),
|
|
39
40
|
builder.address.get('core.oracles.pyth.wormholeState')
|
|
40
41
|
);
|
|
@@ -52,7 +53,7 @@ export const updateOracles = async (
|
|
|
52
53
|
const priceUpdateData =
|
|
53
54
|
await pythConnection.getPriceFeedsUpdateData(priceIds);
|
|
54
55
|
await pythClient.updatePriceFeeds(
|
|
55
|
-
txBlock.txBlock
|
|
56
|
+
TransactionBlock.from(txBlock.serialize()), // convert txBlock to TransactionBlock because pyth sdk not support new @mysten/sui yet
|
|
56
57
|
priceUpdateData,
|
|
57
58
|
priceIds
|
|
58
59
|
);
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
SUI_CLOCK_OBJECT_ID,
|
|
5
5
|
SuiTxBlock as SuiKitTxBlock,
|
|
6
6
|
SuiObjectArg,
|
|
7
|
-
|
|
7
|
+
Transaction,
|
|
8
8
|
} from '@scallop-io/sui-kit';
|
|
9
9
|
import {
|
|
10
10
|
GenerateReferralNormalMethod,
|
|
@@ -39,7 +39,7 @@ const generateReferralNormalMethod: GenerateReferralNormalMethod = ({
|
|
|
39
39
|
`${referralIds.referralPgkId}::referral_bindings::bind_ve_sca_referrer`,
|
|
40
40
|
[
|
|
41
41
|
referralIds.referralBindings,
|
|
42
|
-
txBlock.pure(veScaKeyId),
|
|
42
|
+
txBlock.pure.id(veScaKeyId),
|
|
43
43
|
veScaTable,
|
|
44
44
|
SUI_CLOCK_OBJECT_ID,
|
|
45
45
|
],
|
|
@@ -141,14 +141,14 @@ const generateReferralQuickMethod: GenerateReferralQuickMethod = ({
|
|
|
141
141
|
*/
|
|
142
142
|
export const newReferralTxBlock = (
|
|
143
143
|
builder: ScallopBuilder,
|
|
144
|
-
initTxBlock?: ScallopTxBlock | SuiKitTxBlock |
|
|
144
|
+
initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction
|
|
145
145
|
) => {
|
|
146
146
|
const txBlock =
|
|
147
|
-
initTxBlock instanceof
|
|
147
|
+
initTxBlock instanceof Transaction
|
|
148
148
|
? new SuiKitTxBlock(initTxBlock)
|
|
149
149
|
: initTxBlock
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
? initTxBlock
|
|
151
|
+
: new SuiKitTxBlock();
|
|
152
152
|
|
|
153
153
|
const normalMethod = generateReferralNormalMethod({
|
|
154
154
|
builder,
|