@scallop-io/sui-scallop-sdk 0.47.2 → 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.
Files changed (70) hide show
  1. package/dist/builders/borrowIncentiveBuilder.d.ts +2 -2
  2. package/dist/builders/coreBuilder.d.ts +2 -2
  3. package/dist/builders/index.d.ts +2 -2
  4. package/dist/builders/loyaltyProgramBuilder.d.ts +2 -2
  5. package/dist/builders/oracle.d.ts +4 -1
  6. package/dist/builders/referralBuilder.d.ts +2 -2
  7. package/dist/builders/sCoinBuilder.d.ts +2 -2
  8. package/dist/builders/spoolBuilder.d.ts +2 -2
  9. package/dist/builders/vescaBuilder.d.ts +2 -2
  10. package/dist/constants/common.d.ts +4 -4
  11. package/dist/constants/index.d.ts +1 -1
  12. package/dist/constants/vesca.d.ts +3 -3
  13. package/dist/index.js +125 -96
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +128 -102
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/models/scallop.d.ts +5 -5
  18. package/dist/models/scallopBuilder.d.ts +10 -8
  19. package/dist/models/scallopCache.d.ts +5 -9
  20. package/dist/models/scallopClient.d.ts +2 -2
  21. package/dist/models/scallopQuery.d.ts +1 -1
  22. package/dist/models/scallopUtils.d.ts +2 -2
  23. package/dist/queries/coreQuery.d.ts +3 -3
  24. package/dist/queries/loyaltyProgramQuery.d.ts +1 -1
  25. package/dist/queries/priceQuery.d.ts +1 -1
  26. package/dist/queries/vescaQuery.d.ts +1 -1
  27. package/dist/test.d.ts +1 -0
  28. package/dist/types/builder/borrowIncentive.d.ts +1 -1
  29. package/dist/types/builder/core.d.ts +16 -16
  30. package/dist/types/builder/spool.d.ts +3 -3
  31. package/dist/types/builder/vesca.d.ts +5 -5
  32. package/dist/types/model.d.ts +8 -7
  33. package/dist/types/query/vesca.d.ts +1 -1
  34. package/dist/utils/query.d.ts +1 -1
  35. package/dist/utils/util.d.ts +1 -0
  36. package/package.json +13 -9
  37. package/src/builders/borrowIncentiveBuilder.ts +9 -14
  38. package/src/builders/coreBuilder.ts +15 -15
  39. package/src/builders/index.ts +2 -2
  40. package/src/builders/loyaltyProgramBuilder.ts +5 -5
  41. package/src/builders/oracle.ts +13 -6
  42. package/src/builders/referralBuilder.ts +6 -6
  43. package/src/builders/sCoinBuilder.ts +5 -8
  44. package/src/builders/spoolBuilder.ts +9 -9
  45. package/src/builders/vescaBuilder.ts +5 -5
  46. package/src/constants/common.ts +4 -4
  47. package/src/constants/index.ts +1 -1
  48. package/src/constants/vesca.ts +5 -6
  49. package/src/models/scallop.ts +39 -16
  50. package/src/models/scallopBuilder.ts +14 -7
  51. package/src/models/scallopCache.ts +43 -34
  52. package/src/models/scallopClient.ts +8 -6
  53. package/src/models/scallopQuery.ts +2 -2
  54. package/src/models/scallopUtils.ts +3 -3
  55. package/src/queries/borrowIncentiveQuery.ts +1 -1
  56. package/src/queries/coreQuery.ts +4 -4
  57. package/src/queries/loyaltyProgramQuery.ts +1 -1
  58. package/src/queries/priceQuery.ts +1 -1
  59. package/src/queries/sCoinQuery.ts +2 -2
  60. package/src/queries/spoolQuery.ts +4 -5
  61. package/src/queries/vescaQuery.ts +6 -3
  62. package/src/test.ts +26 -0
  63. package/src/types/address.ts +26 -26
  64. package/src/types/builder/borrowIncentive.ts +1 -1
  65. package/src/types/builder/core.ts +26 -28
  66. package/src/types/builder/spool.ts +2 -3
  67. package/src/types/builder/vesca.ts +5 -9
  68. package/src/types/model.ts +11 -10
  69. package/src/types/query/vesca.ts +1 -1
  70. package/src/utils/query.ts +1 -1
@@ -4,7 +4,7 @@ import { ScallopClient } from './scallopClient';
4
4
  import { ScallopBuilder } from './scallopBuilder';
5
5
  import { ScallopQuery } from './scallopQuery';
6
6
  import { ScallopUtils } from './scallopUtils';
7
- import type { ScallopParams } from '../types/';
7
+ import type { ScallopBuilderParams, ScallopClientParams, ScallopParams, ScallopQueryParams, ScallopUtilsParams } from '../types/';
8
8
  import { ScallopIndexer } from './scallopIndexer';
9
9
  import { ScallopCache } from './scallopCache';
10
10
  import { QueryClientConfig } from '@tanstack/query-core';
@@ -44,20 +44,20 @@ export declare class Scallop {
44
44
  *
45
45
  * @return Scallop Builder.
46
46
  */
47
- createScallopBuilder(): Promise<ScallopBuilder>;
47
+ createScallopBuilder(params?: ScallopBuilderParams): Promise<ScallopBuilder>;
48
48
  /**
49
49
  * Create a scallop client instance that already has initial data.
50
50
  *
51
51
  * @param walletAddress - When user cannot provide a secret key or mnemonic, the scallop client cannot directly derive the address of the transaction the user wants to sign. This argument specifies the wallet address for signing the transaction.
52
52
  * @return Scallop Client.
53
53
  */
54
- createScallopClient(walletAddress?: string): Promise<ScallopClient>;
54
+ createScallopClient(params?: ScallopClientParams): Promise<ScallopClient>;
55
55
  /**
56
56
  * Create a scallop query instance.
57
57
  *
58
58
  * @return Scallop Query.
59
59
  */
60
- createScallopQuery(): Promise<ScallopQuery>;
60
+ createScallopQuery(params?: ScallopQueryParams): Promise<ScallopQuery>;
61
61
  /**
62
62
  * Create a scallop indexer instance.
63
63
  *
@@ -69,5 +69,5 @@ export declare class Scallop {
69
69
  *
70
70
  * @return Scallop Utils.
71
71
  */
72
- createScallopUtils(): Promise<ScallopUtils>;
72
+ createScallopUtils(params?: ScallopUtilsParams): Promise<ScallopUtils>;
73
73
  }
@@ -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.js/client';
6
- import type { TransactionBlock } from '@mysten/sui.js/transactions';
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 | TransactionBlock): ScallopTxBlock;
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: import("@scallop-io/sui-kit").TransactionObjectArgument;
66
- leftCoin: import("@scallop-io/sui-kit").TransactionObjectArgument;
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: import("@scallop-io/sui-kit").TransactionObjectArgument;
80
- leftCoin: import("@scallop-io/sui-kit").TransactionObjectArgument;
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 | TransactionBlock): Promise<SuiTransactionBlockResponse>;
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 { SuiTxArg } from '@scallop-io/sui-kit';
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.js/client';
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: SuiTxArg[];
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.js/client").PaginatedObjectsResponse | null>;
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.js/client';
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 { SuiAddressArg, SuiTxArg, SuiTxBlock } from '@scallop-io/sui-kit';
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: SuiAddressArg): Promise<SupportAssetCoins[] | undefined>;
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.js/client';
2
- import type { SuiAddressArg } from '@scallop-io/sui-kit';
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: SuiAddressArg) => Promise<ObligationQueryInterface | undefined>;
122
+ }, obligationId: SuiObjectArg) => Promise<ObligationQueryInterface | undefined>;
123
123
  /**
124
124
  * Query all owned coin amount.
125
125
  *
@@ -1,4 +1,4 @@
1
- import { SuiObjectData } from '@mysten/sui.js/client';
1
+ import { SuiObjectData } from '@mysten/sui/src/client';
2
2
  import { ScallopQuery } from 'src/models';
3
3
  import { LoyaltyProgramInfo } from 'src/types';
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { SuiObjectData } from '@mysten/sui.js/client';
1
+ import { SuiObjectData } from '@mysten/sui/client';
2
2
  import type { ScallopAddress } from '../models';
3
3
  import type { SupportAssetCoins } from '../types';
4
4
  /**
@@ -1,5 +1,5 @@
1
1
  import { VeScaTreasuryInfo, Vesca } from '../types';
2
- import { type SuiObjectData } from '@mysten/sui.js/client';
2
+ import { type SuiObjectData } from '@mysten/sui/client';
3
3
  import type { ScallopUtils } from '../models';
4
4
  /**
5
5
  * Query all owned veSca key.
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.js/transactions';
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, SuiAddressArg, SuiObjectArg, SuiTxArg } from '@scallop-io/sui-kit';
2
- import type { TransactionArgument, TransactionResult } from '@mysten/sui.js/transactions';
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: SuiAddressArg, obligationHotPotato: SuiObjectArg) => void;
21
+ returnObligation: (obligation: SuiObjectArg, obligationHotPotato: SuiObjectArg) => void;
22
22
  openObligationEntry: () => void;
23
- addCollateral: (obligation: SuiAddressArg, coin: SuiObjectArg, collateralCoinName: SupportCollateralCoins) => void;
24
- takeCollateral: (obligation: SuiAddressArg, obligationKey: SuiAddressArg, amount: SuiTxArg, collateralCoinName: SupportCollateralCoins) => TransactionResult;
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: SuiAddressArg, obligationKey: SuiAddressArg, amount: SuiTxArg, poolCoinName: SupportPoolCoins) => TransactionResult;
30
- borrowWithReferral: (obligation: SuiAddressArg, obligationKey: SuiAddressArg, borrowReferral: SuiObjectArg, amount: SuiTxArg, poolCoinName: SupportPoolCoins) => TransactionResult;
31
- borrowEntry: (obligation: SuiAddressArg, obligationKey: SuiAddressArg, amount: SuiTxArg, poolCoinName: SupportPoolCoins) => void;
32
- repay: (obligation: SuiAddressArg, coin: SuiObjectArg, poolCoinName: SupportPoolCoins) => void;
33
- borrowFlashLoan: (amount: SuiTxArg, poolCoinName: SupportPoolCoins) => TransactionResult;
34
- repayFlashLoan: (coin: SuiObjectArg, loan: SuiAddressArg, poolCoinName: SupportPoolCoins) => void;
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?: SuiAddressArg) => Promise<void>;
38
- takeCollateralQuick: (amount: number, collateralCoinName: SupportCollateralCoins, obligationId?: SuiAddressArg, obligationKey?: SuiAddressArg) => Promise<TransactionResult>;
39
- borrowQuick: (amount: number, poolCoinName: SupportPoolCoins, obligationId?: SuiAddressArg, obligationKey?: SuiAddressArg) => Promise<TransactionResult>;
40
- borrowWithReferralQuick: (amount: number, poolCoinName: SupportPoolCoins, borrowReferral: SuiObjectArg, obligationId?: SuiAddressArg, obligationKey?: SuiAddressArg) => Promise<TransactionResult>;
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?: SuiAddressArg) => Promise<void>;
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, SuiTxArg } from '@scallop-io/sui-kit';
2
- import type { TransactionResult } from '@mysten/sui.js/transactions';
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: SuiTxArg, stakeMarketCoinName: SupportStakeMarketCoins) => TransactionResult;
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, SuiTxArg } from '@scallop-io/sui-kit';
2
- import type { TransactionResult } from '@mysten/sui.js/transactions';
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: SuiTxArg) => TransactionResult;
12
- extendLockPeriod: (veScaKey: SuiObjectArg, newUnlockAtInSecondTimestamp: SuiTxArg) => void;
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: SuiTxArg) => void;
14
+ renewExpiredVeSca: (veScaKey: SuiObjectArg, scaCoin: SuiObjectArg, newUnlockAtInSecondTimestamp: number) => void;
15
15
  redeemSca: (veScaKey: SuiObjectArg) => TransactionResult;
16
16
  mintEmptyVeSca: () => TransactionResult;
17
17
  };
@@ -1,11 +1,11 @@
1
- import type { SuiTransactionBlockResponse } from '@mysten/sui.js/client';
2
- import type { TransactionBlock, TransactionResult } from '@mysten/sui.js/transactions';
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 : TransactionBlock;
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: TransactionBlock;
8
+ tx: Transaction;
9
9
  scaCoin: TransactionResult;
10
10
  };
11
11
  export type ScallopBaseInstanceParams = {
@@ -40,11 +40,12 @@ export type ScallopParams = {
40
40
  addressesId?: string;
41
41
  walletAddress?: string;
42
42
  } & SuiKitParams;
43
- export type ScallopClientParams = ScallopParams;
43
+ export type ScallopClientParams = ScallopParams & ScallopBuilderParams & ScallopQueryParams & ScallopUtilsParams;
44
44
  export type ScallopBuilderParams = ScallopParams & {
45
45
  pythEndpoints?: string[];
46
- };
47
- export type ScallopQueryParams = ScallopParams;
46
+ usePythPullModel?: boolean;
47
+ } & ScallopQueryParams;
48
+ export type ScallopQueryParams = ScallopParams & ScallopUtilsParams;
48
49
  export type ScallopUtilsParams = ScallopParams & {
49
50
  pythEndpoints?: string[];
50
51
  };
@@ -1,4 +1,4 @@
1
- import type { SuiObjectRef } from '@mysten/sui.js/client';
1
+ import type { SuiObjectRef } from '@mysten/sui/client';
2
2
  export type Vesca = {
3
3
  id: string;
4
4
  keyId: string;
@@ -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: 'increase' | 'decrease') => number;
62
+ export declare const estimatedFactor: (amount: number, scaleStep: number, type: "increase" | "decrease") => number;
@@ -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.47.2",
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": "^3.2.0",
42
- "@mysten/bcs": "^0.8.1",
43
- "@mysten/sui.js": "^0.54.1",
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": "0.52.0",
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.8.10",
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.25.3",
78
- "typescript": "^5.2.2",
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": "0.52.0",
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 { TransactionBlock } from '@mysten/sui.js/transactions';
2
- import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui.js/utils';
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';
@@ -255,19 +255,14 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
255
255
  const bindedVeScaKey =
256
256
  await builder.query.getBindedVeScaKey(obligationArg);
257
257
 
258
- if (veScaKey && veScaKey !== bindedVeScaKey) {
259
- throw new Error(
260
- 'Binded veScaKey is not equal to the provided veScaKey'
261
- );
262
- }
263
- if (bindedVeScaKey) {
258
+ if ((veScaKey && veScaKey !== bindedVeScaKey) || !bindedVeScaKey) {
259
+ txBlock.stakeObligation(obligationArg, obligationKeyArg);
260
+ } else {
264
261
  txBlock.stakeObligationWithVesca(
265
262
  obligationArg,
266
263
  obligationKeyArg,
267
264
  bindedVeScaKey
268
265
  );
269
- } else {
270
- txBlock.stakeObligation(obligationArg, obligationKeyArg);
271
266
  }
272
267
  }
273
268
  },
@@ -320,14 +315,14 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
320
315
  */
321
316
  export const newBorrowIncentiveTxBlock = (
322
317
  builder: ScallopBuilder,
323
- initTxBlock?: ScallopTxBlock | SuiKitTxBlock | TransactionBlock
318
+ initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction
324
319
  ) => {
325
320
  const txBlock =
326
- initTxBlock instanceof TransactionBlock
321
+ initTxBlock instanceof Transaction
327
322
  ? new SuiKitTxBlock(initTxBlock)
328
323
  : initTxBlock
329
- ? initTxBlock
330
- : new SuiKitTxBlock();
324
+ ? initTxBlock
325
+ : new SuiKitTxBlock();
331
326
 
332
327
  const normalMethod = generateBorrowIncentiveNormalMethod({
333
328
  builder,
@@ -1,10 +1,10 @@
1
- import { TransactionBlock } from '@mysten/sui.js/transactions';
2
- import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui.js/utils';
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 { SuiAddressArg, TransactionResult } from '@scallop-io/sui-kit';
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?: SuiAddressArg,
39
- obligationKey?: SuiAddressArg,
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 SuiAddressArg,
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 SuiAddressArg,
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 SuiAddressArg,
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
- | TransactionBlock
479
+ | Transaction
480
480
  | SuiTxBlockWithSpool
481
481
  ) => {
482
482
  const txBlock =
483
- initTxBlock instanceof TransactionBlock
483
+ initTxBlock instanceof Transaction
484
484
  ? new SuiKitTxBlock(initTxBlock)
485
485
  : initTxBlock
486
- ? initTxBlock
487
- : new SuiKitTxBlock();
486
+ ? initTxBlock
487
+ : new SuiKitTxBlock();
488
488
 
489
489
  const normalMethod = generateCoreNormalMethod({
490
490
  builder,
@@ -1,4 +1,4 @@
1
- import { TransactionBlock } from '@mysten/sui.js/transactions';
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 | TransactionBlock
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 { TransactionBlock } from '@mysten/sui.js/transactions';
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 | TransactionBlock
69
+ initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction
70
70
  ) => {
71
71
  const txBlock =
72
- initTxBlock instanceof TransactionBlock
72
+ initTxBlock instanceof Transaction
73
73
  ? new SuiKitTxBlock(initTxBlock)
74
74
  : initTxBlock
75
- ? initTxBlock
76
- : new SuiKitTxBlock();
75
+ ? initTxBlock
76
+ : new SuiKitTxBlock();
77
77
 
78
78
  const normalMethod = generateLoyaltyProgramNormalMethod({
79
79
  builder,