@scallop-io/sui-scallop-sdk 0.42.7 → 0.44.0

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.
@@ -49,36 +49,8 @@ export declare class ScallopBuilder {
49
49
  * @return Take coin and left coin.
50
50
  */
51
51
  selectCoin(txBlock: ScallopTxBlock | SuiKitTxBlock, assetCoinName: SupportAssetCoins, amount: number, sender: string): Promise<{
52
- takeCoin: {
53
- kind: "Input";
54
- index: number;
55
- type?: "object" | "pure" | undefined;
56
- value?: any;
57
- } | {
58
- kind: "GasCoin";
59
- } | {
60
- kind: "Result";
61
- index: number;
62
- } | {
63
- kind: "NestedResult";
64
- index: number;
65
- resultIndex: number;
66
- };
67
- leftCoin: {
68
- kind: "Input";
69
- index: number;
70
- type?: "object" | "pure" | undefined;
71
- value?: any;
72
- } | {
73
- kind: "GasCoin";
74
- } | {
75
- kind: "Result";
76
- index: number;
77
- } | {
78
- kind: "NestedResult";
79
- index: number;
80
- resultIndex: number;
81
- };
52
+ takeCoin: import("@scallop-io/sui-kit").TransactionObjectArgument;
53
+ leftCoin: import("@scallop-io/sui-kit").TransactionObjectArgument;
82
54
  }>;
83
55
  /**
84
56
  * Specifying the sender's amount of market coins to get coins args from transaction result.
@@ -90,36 +62,8 @@ export declare class ScallopBuilder {
90
62
  * @return Take coin and left coin.
91
63
  */
92
64
  selectMarketCoin(txBlock: ScallopTxBlock | SuiKitTxBlock, marketCoinName: SupportMarketCoins, amount: number, sender: string): Promise<{
93
- takeCoin: {
94
- kind: "Input";
95
- index: number;
96
- type?: "object" | "pure" | undefined;
97
- value?: any;
98
- } | {
99
- kind: "GasCoin";
100
- } | {
101
- kind: "Result";
102
- index: number;
103
- } | {
104
- kind: "NestedResult";
105
- index: number;
106
- resultIndex: number;
107
- };
108
- leftCoin: {
109
- kind: "Input";
110
- index: number;
111
- type?: "object" | "pure" | undefined;
112
- value?: any;
113
- } | {
114
- kind: "GasCoin";
115
- } | {
116
- kind: "Result";
117
- index: number;
118
- } | {
119
- kind: "NestedResult";
120
- index: number;
121
- resultIndex: number;
122
- };
65
+ takeCoin: import("@scallop-io/sui-kit").TransactionObjectArgument;
66
+ leftCoin: import("@scallop-io/sui-kit").TransactionObjectArgument;
123
67
  }>;
124
68
  /**
125
69
  * Execute Scallop txBlock using the `signAndSendTxn` methods in suikit.
@@ -4,8 +4,8 @@ import { ScallopUtils } from './scallopUtils';
4
4
  import { ScallopBuilder } from './scallopBuilder';
5
5
  import { ScallopQuery } from './scallopQuery';
6
6
  import type { SuiTransactionBlockResponse } from '@mysten/sui.js/client';
7
- import type { TransactionArgument } from '@mysten/sui.js/transactions';
8
- import type { SuiTxArg } from '@scallop-io/sui-kit';
7
+ import type { TransactionObjectArgument } from '@mysten/sui.js/transactions';
8
+ import type { SuiObjectArg } from '@scallop-io/sui-kit';
9
9
  import type { ScallopClientFnReturnType, ScallopInstanceParams, ScallopClientParams, SupportPoolCoins, SupportCollateralCoins, SupportAssetCoins, SupportStakeCoins, SupportStakeMarketCoins, ScallopTxBlock } from '../types';
10
10
  /**
11
11
  * @description
@@ -123,7 +123,7 @@ export declare class ScallopClient {
123
123
  * @return Transaction block response or transaction block.
124
124
  */
125
125
  depositCollateral(collateralCoinName: SupportCollateralCoins, amount: number): Promise<SuiTransactionBlockResponse>;
126
- depositCollateral<S extends boolean>(collateralCoinName: SupportCollateralCoins, amount: number, sign?: S, obligationId?: SuiTxArg, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
126
+ depositCollateral<S extends boolean>(collateralCoinName: SupportCollateralCoins, amount: number, sign?: S, obligationId?: string, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
127
127
  /**
128
128
  * Withdraw collateral from the specific pool.
129
129
  *
@@ -158,7 +158,7 @@ export declare class ScallopClient {
158
158
  * @return Transaction block response or transaction block.
159
159
  */
160
160
  depositAndStake(stakeCoinName: SupportStakeCoins, amount: number): Promise<SuiTransactionBlockResponse>;
161
- depositAndStake<S extends boolean>(stakeCoinName: SupportStakeCoins, amount: number, sign?: S, stakeAccountId?: SuiTxArg, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
161
+ depositAndStake<S extends boolean>(stakeCoinName: SupportStakeCoins, amount: number, sign?: S, stakeAccountId?: string, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
162
162
  /**
163
163
  * Withdraw asset from the specific pool, must return market coin.
164
164
  *
@@ -202,8 +202,8 @@ export declare class ScallopClient {
202
202
  * @param sign - Decide to directly sign the transaction or return the transaction block.
203
203
  * @return Transaction block response or transaction block.
204
204
  */
205
- flashLoan(poolCoinName: SupportPoolCoins, amount: number, callback: (txBlock: ScallopTxBlock, coin: TransactionArgument) => TransactionArgument): Promise<SuiTransactionBlockResponse>;
206
- flashLoan<S extends boolean>(poolCoinName: SupportPoolCoins, amount: number, callback: (txBlock: ScallopTxBlock, coin: TransactionArgument) => TransactionArgument, sign?: S, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
205
+ flashLoan(poolCoinName: SupportPoolCoins, amount: number, callback: (txBlock: ScallopTxBlock, coin: TransactionObjectArgument | string) => SuiObjectArg): Promise<SuiTransactionBlockResponse>;
206
+ flashLoan<S extends boolean>(poolCoinName: SupportPoolCoins, amount: number, callback: (txBlock: ScallopTxBlock, coin: TransactionObjectArgument | string) => SuiObjectArg, sign?: S, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
207
207
  /**
208
208
  * Create stake account.
209
209
  *
@@ -224,7 +224,7 @@ export declare class ScallopClient {
224
224
  * @return Transaction block response or transaction block.
225
225
  */
226
226
  stake(stakeMarketCoinName: SupportStakeMarketCoins, amount: number): Promise<SuiTransactionBlockResponse>;
227
- stake<S extends boolean>(stakeMarketCoinName: SupportStakeMarketCoins, amount: number, sign?: S, stakeAccountId?: SuiTxArg, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
227
+ stake<S extends boolean>(stakeMarketCoinName: SupportStakeMarketCoins, amount: number, sign?: S, stakeAccountId?: string, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
228
228
  /**
229
229
  * Unstake market coin from the specific spool.
230
230
  *
@@ -236,7 +236,7 @@ export declare class ScallopClient {
236
236
  * @return Transaction block response or transaction block.
237
237
  */
238
238
  unstake(stakeMarketCoinName: SupportStakeMarketCoins, amount: number): Promise<SuiTransactionBlockResponse>;
239
- unstake<S extends boolean>(stakeMarketCoinName: SupportStakeMarketCoins, amount: number, sign?: S, stakeAccountId?: SuiTxArg, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
239
+ unstake<S extends boolean>(stakeMarketCoinName: SupportStakeMarketCoins, amount: number, sign?: S, stakeAccountId?: string, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
240
240
  /**
241
241
  * Unstake market coin from the specific spool and withdraw asset from the corresponding pool.
242
242
  *
@@ -248,7 +248,7 @@ export declare class ScallopClient {
248
248
  * @return Transaction block response or transaction block.
249
249
  */
250
250
  unstakeAndWithdraw(stakeMarketCoinName: SupportStakeMarketCoins, amount: number): Promise<SuiTransactionBlockResponse>;
251
- unstakeAndWithdraw<S extends boolean>(stakeMarketCoinName: SupportStakeMarketCoins, amount: number, sign?: S, stakeAccountId?: SuiTxArg, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
251
+ unstakeAndWithdraw<S extends boolean>(stakeMarketCoinName: SupportStakeMarketCoins, amount: number, sign?: S, stakeAccountId?: string, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
252
252
  /**
253
253
  * Claim reward coin from the specific spool.
254
254
  *
@@ -260,7 +260,7 @@ export declare class ScallopClient {
260
260
  * @return Transaction block response or transaction block.
261
261
  */
262
262
  claim(stakeMarketCoinName: SupportStakeMarketCoins): Promise<SuiTransactionBlockResponse>;
263
- claim<S extends boolean>(stakeMarketCoinName: SupportStakeMarketCoins, sign?: S, stakeAccountId?: SuiTxArg, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
263
+ claim<S extends boolean>(stakeMarketCoinName: SupportStakeMarketCoins, sign?: S, stakeAccountId?: string, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
264
264
  /**
265
265
  * Mint and get test coin.
266
266
  *
@@ -1,3 +1,4 @@
1
+ import { SuiAddressArg } from '@scallop-io/sui-kit';
1
2
  import type { ScallopUtilsParams, ScallopInstanceParams, SupportCoins, SupportAssetCoins, SupportMarketCoins, SupportStakeMarketCoins, CoinWrappedType } from '../types';
2
3
  /**
3
4
  * @description
@@ -64,6 +65,7 @@ export declare class ScallopUtils {
64
65
  */
65
66
  parseCoinNameFromType<T extends SupportAssetCoins>(coinType: string): T extends SupportAssetCoins ? T : SupportAssetCoins;
66
67
  parseCoinNameFromType<T extends SupportMarketCoins>(coinType: string): T extends SupportMarketCoins ? T : SupportMarketCoins;
68
+ parseCoinNameFromType<T extends SupportCoins>(coinType: string): T extends SupportCoins ? T : SupportCoins;
67
69
  /**
68
70
  * Convert marke coin name to coin name.
69
71
  *
@@ -116,7 +118,7 @@ export declare class ScallopUtils {
116
118
  * @param obligationId - The obligation id.
117
119
  * @return Asset coin Names.
118
120
  */
119
- getObligationCoinNames(obligationId: string): Promise<SupportAssetCoins[]>;
121
+ getObligationCoinNames(obligationId: SuiAddressArg): Promise<SupportAssetCoins[]>;
120
122
  /**
121
123
  * Get asset coin price.
122
124
  *
@@ -1,4 +1,5 @@
1
1
  import type { SuiObjectData } from '@mysten/sui.js/client';
2
+ import type { SuiAddressArg } from '@scallop-io/sui-kit';
2
3
  import type { ScallopQuery } from '../models';
3
4
  import { Market, MarketPool, MarketCollateral, SupportAssetCoins, SupportPoolCoins, SupportCollateralCoins, ObligationQueryInterface, Obligation, SupportMarketCoins } from '../types';
4
5
  /**
@@ -92,7 +93,7 @@ export declare const getObligations: (query: ScallopQuery, ownerAddress?: string
92
93
  * @param obligationId - The obligation id.
93
94
  * @return Obligation data.
94
95
  */
95
- export declare const queryObligation: (query: ScallopQuery, obligationId: string) => Promise<ObligationQueryInterface>;
96
+ export declare const queryObligation: (query: ScallopQuery, obligationId: SuiAddressArg) => Promise<ObligationQueryInterface>;
96
97
  /**
97
98
  * Query all owned coin amount.
98
99
  *
@@ -1,7 +1,7 @@
1
- import type { SuiTxBlock as SuiKitTxBlock, SuiTxArg } from '@scallop-io/sui-kit';
1
+ import type { SuiTxBlock as SuiKitTxBlock, SuiAddressArg, SuiObjectArg, SuiTxArg } from '@scallop-io/sui-kit';
2
+ import type { TransactionResult } from '@mysten/sui.js/transactions';
2
3
  import type { ScallopBuilder } from '../../models';
3
4
  import type { SupportCollateralCoins, SupportPoolCoins, SupportAssetCoins } from '../constant';
4
- import type { TransactionResult } from './index';
5
5
  export type CoreIds = {
6
6
  protocolPkg: string;
7
7
  market: string;
@@ -11,27 +11,27 @@ export type CoreIds = {
11
11
  };
12
12
  export type CoreNormalMethods = {
13
13
  openObligation: () => TransactionResult;
14
- returnObligation: (obligation: SuiTxArg, obligationHotPotato: SuiTxArg) => void;
14
+ returnObligation: (obligation: SuiAddressArg, obligationHotPotato: SuiObjectArg) => void;
15
15
  openObligationEntry: () => void;
16
- addCollateral: (obligation: SuiTxArg, coin: SuiTxArg, collateralCoinName: SupportCollateralCoins) => void;
17
- takeCollateral: (obligation: SuiTxArg, obligationKey: SuiTxArg, amount: number, collateralCoinName: SupportCollateralCoins) => TransactionResult;
18
- deposit: (coin: SuiTxArg, poolCoinName: SupportPoolCoins) => TransactionResult;
19
- depositEntry: (coin: SuiTxArg, poolCoinName: SupportPoolCoins) => void;
20
- withdraw: (marketCoin: SuiTxArg, poolCoinName: SupportPoolCoins) => TransactionResult;
21
- withdrawEntry: (marketCoin: SuiTxArg, poolCoinName: SupportPoolCoins) => void;
22
- borrow: (obligation: SuiTxArg, obligationKey: SuiTxArg, amount: number, poolCoinName: SupportPoolCoins) => TransactionResult;
23
- borrowEntry: (obligation: SuiTxArg, obligationKey: SuiTxArg, amount: number, poolCoinName: SupportPoolCoins) => void;
24
- repay: (obligation: SuiTxArg, coin: SuiTxArg, poolCoinName: SupportPoolCoins) => void;
25
- borrowFlashLoan: (amount: number, poolCoinName: SupportPoolCoins) => TransactionResult;
26
- repayFlashLoan: (coin: SuiTxArg, loan: SuiTxArg, poolCoinName: SupportPoolCoins) => void;
16
+ addCollateral: (obligation: SuiAddressArg, coin: SuiObjectArg, collateralCoinName: SupportCollateralCoins) => void;
17
+ takeCollateral: (obligation: SuiAddressArg, obligationKey: SuiAddressArg, amount: SuiTxArg, collateralCoinName: SupportCollateralCoins) => TransactionResult;
18
+ deposit: (coin: SuiObjectArg, poolCoinName: SupportPoolCoins) => TransactionResult;
19
+ depositEntry: (coin: SuiObjectArg, poolCoinName: SupportPoolCoins) => void;
20
+ withdraw: (marketCoin: SuiObjectArg, poolCoinName: SupportPoolCoins) => TransactionResult;
21
+ withdrawEntry: (marketCoin: SuiObjectArg, poolCoinName: SupportPoolCoins) => void;
22
+ borrow: (obligation: SuiAddressArg, obligationKey: SuiAddressArg, amount: SuiTxArg, poolCoinName: SupportPoolCoins) => TransactionResult;
23
+ borrowEntry: (obligation: SuiAddressArg, obligationKey: SuiAddressArg, amount: SuiTxArg, poolCoinName: SupportPoolCoins) => void;
24
+ repay: (obligation: SuiAddressArg, coin: SuiObjectArg, poolCoinName: SupportPoolCoins) => void;
25
+ borrowFlashLoan: (amount: SuiTxArg, poolCoinName: SupportPoolCoins) => TransactionResult;
26
+ repayFlashLoan: (coin: SuiObjectArg, loan: SuiAddressArg, poolCoinName: SupportPoolCoins) => void;
27
27
  };
28
28
  export type CoreQuickMethods = {
29
- addCollateralQuick: (amount: number, collateralCoinName: SupportCollateralCoins, obligationId?: SuiTxArg) => Promise<void>;
30
- takeCollateralQuick: (amount: number, collateralCoinName: SupportCollateralCoins, obligationId?: string, obligationKey?: string) => Promise<TransactionResult>;
31
- borrowQuick: (amount: number, poolCoinName: SupportPoolCoins, obligationId?: string, obligationKey?: string) => Promise<TransactionResult>;
29
+ addCollateralQuick: (amount: number, collateralCoinName: SupportCollateralCoins, obligationId?: SuiAddressArg) => Promise<void>;
30
+ takeCollateralQuick: (amount: number, collateralCoinName: SupportCollateralCoins, obligationId?: SuiAddressArg, obligationKey?: SuiAddressArg) => Promise<TransactionResult>;
31
+ borrowQuick: (amount: number, poolCoinName: SupportPoolCoins, obligationId?: SuiAddressArg, obligationKey?: SuiAddressArg) => Promise<TransactionResult>;
32
32
  depositQuick: (amount: number, poolCoinName: SupportPoolCoins) => Promise<TransactionResult>;
33
33
  withdrawQuick: (amount: number, poolCoinName: SupportPoolCoins) => Promise<TransactionResult>;
34
- repayQuick: (amount: number, poolCoinName: SupportPoolCoins, obligationId?: string) => Promise<void>;
34
+ repayQuick: (amount: number, poolCoinName: SupportPoolCoins, obligationId?: SuiAddressArg) => Promise<void>;
35
35
  updateAssetPricesQuick: (assetCoinNames?: SupportAssetCoins[]) => Promise<void>;
36
36
  };
37
37
  export type SuiTxBlockWithCoreNormalMethods = SuiKitTxBlock & CoreNormalMethods;
@@ -1,7 +1,5 @@
1
- import type { TransactionArgument } from '@mysten/sui.js/transactions';
2
1
  import type { CoreTxBlock } from './core';
3
2
  import type { SpoolTxBlock } from './spool';
4
3
  export type * from './core';
5
4
  export type * from './spool';
6
5
  export type ScallopTxBlock = CoreTxBlock & SpoolTxBlock;
7
- export type TransactionResult = TransactionArgument & TransactionArgument[];
@@ -1,21 +1,20 @@
1
- import type { SuiTxBlock as SuiKitTxBlock, SuiTxArg } from '@scallop-io/sui-kit';
1
+ import type { SuiTxBlock as SuiKitTxBlock, SuiAddressArg, SuiObjectArg, SuiTxArg } from '@scallop-io/sui-kit';
2
+ import type { TransactionResult } from '@mysten/sui.js/transactions';
2
3
  import type { ScallopBuilder } from '../../models';
3
4
  import type { SupportStakeMarketCoins } from '../constant';
4
- import type { TransactionResult } from './index';
5
5
  export type SpoolIds = {
6
6
  spoolPkg: string;
7
7
  };
8
8
  export type SpoolNormalMethods = {
9
9
  createStakeAccount: (stakeMarketCoinName: SupportStakeMarketCoins) => TransactionResult;
10
- stake: (stakeAccount: SuiTxArg, coin: SuiTxArg, stakeMarketCoinName: SupportStakeMarketCoins) => void;
11
- unstake: (stakeAccount: SuiTxArg, amount: number, stakeMarketCoinName: SupportStakeMarketCoins) => TransactionResult;
12
- claim: (stakeAccount: SuiTxArg, stakeMarketCoinName: SupportStakeMarketCoins) => TransactionResult;
10
+ stake: (stakeAccount: SuiAddressArg, coin: SuiObjectArg, stakeMarketCoinName: SupportStakeMarketCoins) => void;
11
+ unstake: (stakeAccount: SuiAddressArg, amount: SuiTxArg, stakeMarketCoinName: SupportStakeMarketCoins) => TransactionResult;
12
+ claim: (stakeAccount: SuiAddressArg, stakeMarketCoinName: SupportStakeMarketCoins) => TransactionResult;
13
13
  };
14
14
  export type SpoolQuickMethods = {
15
- stakeQuick(amountOrMarketCoin: number, stakeMarketCoinName: SupportStakeMarketCoins, stakeAccountId?: SuiTxArg): Promise<void>;
16
- stakeQuick(amountOrMarketCoin: TransactionResult, stakeMarketCoinName: SupportStakeMarketCoins, stakeAccountId?: SuiTxArg): Promise<void>;
17
- unstakeQuick(amount: number, stakeMarketCoinName: SupportStakeMarketCoins, stakeAccountId?: SuiTxArg): Promise<TransactionResult>;
18
- claimQuick(stakeMarketCoinName: SupportStakeMarketCoins, stakeAccountId?: SuiTxArg): Promise<TransactionResult>;
15
+ stakeQuick(amountOrMarketCoin: SuiObjectArg | number, stakeMarketCoinName: SupportStakeMarketCoins, stakeAccountId?: SuiAddressArg): Promise<void>;
16
+ unstakeQuick(amount: number, stakeMarketCoinName: SupportStakeMarketCoins, stakeAccountId?: SuiAddressArg): Promise<TransactionResult[]>;
17
+ claimQuick(stakeMarketCoinName: SupportStakeMarketCoins, stakeAccountId?: SuiAddressArg): Promise<TransactionResult[]>;
19
18
  };
20
19
  export type SuiTxBlockWithSpoolNormalMethods = SuiKitTxBlock & SpoolNormalMethods;
21
20
  export type SpoolTxBlock = SuiTxBlockWithSpoolNormalMethods & SpoolQuickMethods;
@@ -14,3 +14,11 @@ export type StakeMarketCoins = {
14
14
  export type RewardCoins = {
15
15
  [key in SupportStakeMarketCoins]: SupportRewardCoins;
16
16
  };
17
+ export type AssetCoinIds = {
18
+ [key in SupportAssetCoins]: string;
19
+ };
20
+ type PickFromUnion<T, K extends string> = K extends T ? K : never;
21
+ export type WormholeCoinIds = {
22
+ [key in PickFromUnion<SupportAssetCoins, 'eth' | 'btc' | 'usdc' | 'usdt' | 'apt' | 'sol'>]: string;
23
+ };
24
+ export {};
@@ -115,7 +115,7 @@ export type MarketPool = {
115
115
  coinWrappedType: CoinWrappedType;
116
116
  coinDecimal: number;
117
117
  coinPrice: number;
118
- } & Required<Pick<ParsedMarketPoolData, 'reserveFactor' | 'borrowWeight' | 'marketCoinSupplyAmount' | 'minBorrowAmount'>> & CalculatedMarketPoolData;
118
+ } & Required<Pick<ParsedMarketPoolData, 'highKink' | 'midKink' | 'reserveFactor' | 'borrowWeight' | 'marketCoinSupplyAmount' | 'minBorrowAmount'>> & CalculatedMarketPoolData;
119
119
  export type MarketCollateral = {
120
120
  coinName: SupportCollateralCoins;
121
121
  symbol: string;
@@ -17,11 +17,21 @@ export type Lending = Required<Pick<MarketPool, 'coinName' | 'symbol' | 'coinTyp
17
17
  stakedAmount: number;
18
18
  stakedCoin: number;
19
19
  stakedValue: number;
20
+ unstakedMarketAmount: number;
21
+ unstakedMarketCoin: number;
22
+ unstakedAmount: number;
23
+ unstakedCoin: number;
24
+ unstakedValue: number;
20
25
  availableSupplyAmount: number;
26
+ availableSupplyCoin: number;
21
27
  availableWithdrawAmount: number;
28
+ availableWithdrawCoin: number;
22
29
  availableStakeAmount: number;
30
+ availableStakeCoin: number;
23
31
  availableUnstakeAmount: number;
32
+ availableUnstakeCoin: number;
24
33
  availableClaimAmount: number;
34
+ availableClaimCoin: number;
25
35
  };
26
36
  export type ObligationAccount = {
27
37
  obligationId: string;
@@ -36,34 +46,40 @@ export type ObligationAccount = {
36
46
  totalRiskLevel: number;
37
47
  totalDepositedPools: number;
38
48
  totalBorrowedPools: number;
39
- collaterals: OptionalKeys<Record<SupportCollateralCoins, {
40
- coinName: SupportCollateralCoins;
41
- coinType: string;
42
- symbol: string;
43
- depositedAmount: number;
44
- depositedCoin: number;
45
- depositedValue: number;
46
- borrowCapacityValue: number;
47
- requiredCollateralValue: number;
48
- availableDepositAmount: number;
49
- availableDepositCoin: number;
50
- availableWithdrawAmount: number;
51
- availableWithdrawCoin: number;
52
- }>>;
53
- debts: OptionalKeys<Record<SupportPoolCoins, {
54
- coinName: SupportPoolCoins;
55
- coinType: string;
56
- symbol: string;
57
- borrowedAmount: number;
58
- borrowedCoin: number;
59
- borrowedValue: number;
60
- borrowedValueWithWeight: number;
61
- borrowIndex: number;
62
- availableBorrowAmount: number;
63
- availableBorrowCoin: number;
64
- availableRepayAmount: number;
65
- availableRepayCoin: number;
66
- }>>;
49
+ collaterals: OptionalKeys<Record<SupportCollateralCoins, ObligationCollateral>>;
50
+ debts: OptionalKeys<Record<SupportPoolCoins, ObligationDebt>>;
51
+ };
52
+ export type ObligationCollateral = {
53
+ coinName: SupportCollateralCoins;
54
+ coinType: string;
55
+ symbol: string;
56
+ coinDecimal: number;
57
+ coinPrice: number;
58
+ depositedAmount: number;
59
+ depositedCoin: number;
60
+ depositedValue: number;
61
+ borrowCapacityValue: number;
62
+ requiredCollateralValue: number;
63
+ availableDepositAmount: number;
64
+ availableDepositCoin: number;
65
+ availableWithdrawAmount: number;
66
+ availableWithdrawCoin: number;
67
+ };
68
+ export type ObligationDebt = {
69
+ coinName: SupportPoolCoins;
70
+ coinType: string;
71
+ symbol: string;
72
+ coinDecimal: number;
73
+ coinPrice: number;
74
+ borrowedAmount: number;
75
+ borrowedCoin: number;
76
+ borrowedValue: number;
77
+ borrowedValueWithWeight: number;
78
+ borrowIndex: number;
79
+ availableBorrowAmount: number;
80
+ availableBorrowCoin: number;
81
+ availableRepayAmount: number;
82
+ availableRepayCoin: number;
67
83
  };
68
84
  export type TotalValueLocked = {
69
85
  supplyValue: number;
@@ -72,7 +72,7 @@ export type ParsedRewardPoolData = {
72
72
  spoolId: string;
73
73
  };
74
74
  export type CalculatedRewardPoolData = {
75
- stakeApr: number;
75
+ rewardApr: number;
76
76
  totalRewardAmount: number;
77
77
  totalRewardCoin: number;
78
78
  totalRewardValue: number;
@@ -1,3 +1,4 @@
1
+ import BigNumber from 'bignumber.js';
1
2
  import type { ScallopUtils } from '../models';
2
3
  import type { OriginMarketPoolData, ParsedMarketPoolData, CalculatedMarketPoolData, OriginMarketCollateralData, ParsedMarketCollateralData, CalculatedMarketCollateralData, OriginStakePoolData, ParsedStakePoolData, CalculatedStakePoolData, OriginRewardPoolData, ParsedRewardPoolData, CalculatedRewardPoolData } from '../types';
3
4
  /**
@@ -32,3 +33,5 @@ export declare const calculateStakePoolData: (parsedStakePoolData: ParsedStakePo
32
33
  */
33
34
  export declare const parseOriginRewardPoolData: (originRewardPoolData: OriginRewardPoolData) => ParsedRewardPoolData;
34
35
  export declare const calculateRewardPoolData: (parsedStakePoolData: ParsedStakePoolData, parsedRewardPoolData: ParsedRewardPoolData, calculatedStakePoolData: CalculatedStakePoolData, rewardCoinPrice: number, rewardCoinDecimal: number) => CalculatedRewardPoolData;
36
+ export declare const minBigNumber: (...args: BigNumber.Value[]) => BigNumber;
37
+ export declare const maxBigNumber: (...args: BigNumber.Value[]) => BigNumber;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "0.42.7",
3
+ "version": "0.44.0",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -38,37 +38,43 @@
38
38
  "src"
39
39
  ],
40
40
  "dependencies": {
41
- "@mysten/sui.js": "^0.42.0",
42
- "@pythnetwork/price-service-client": "^1.8.0",
43
- "@pythnetwork/pyth-sui-js": "^1.2.2",
44
- "@scallop-io/sui-kit": "^0.42.0",
41
+ "@mysten/bcs": "^0.8.1",
42
+ "@mysten/sui.js": "^0.44.0",
43
+ "@noble/curves": "^1.2.0",
44
+ "@noble/hashes": "^1.3.2",
45
+ "@pythnetwork/price-service-client": "^1.8.1",
46
+ "@pythnetwork/pyth-sui-js": "^1.2.3",
47
+ "@scallop-io/sui-kit": "^0.44.0",
48
+ "@scure/bip39": "^1.2.1",
45
49
  "axios": "^1.5.1",
46
- "bignumber.js": "^9.1.2"
50
+ "bignumber.js": "^9.1.2",
51
+ "superstruct": "^1.0.3",
52
+ "tweetnacl": "^1.0.3"
47
53
  },
48
54
  "devDependencies": {
49
- "@commitlint/cli": "^17.7.2",
50
- "@commitlint/config-conventional": "^17.7.0",
51
- "@commitlint/prompt-cli": "^17.7.2",
52
- "@types/node": "^20.8.2",
53
- "@typescript-eslint/eslint-plugin": "^6.7.4",
54
- "@typescript-eslint/parser": "^6.7.4",
55
+ "@commitlint/cli": "^18.0.0",
56
+ "@commitlint/config-conventional": "^18.0.0",
57
+ "@commitlint/prompt-cli": "^18.0.0",
58
+ "@types/node": "^20.8.7",
59
+ "@typescript-eslint/eslint-plugin": "^6.8.0",
60
+ "@typescript-eslint/parser": "^6.8.0",
55
61
  "dotenv": "^16.3.1",
56
- "eslint": "^8.50.0",
62
+ "eslint": "^8.52.0",
57
63
  "eslint-config-prettier": "^9.0.0",
58
- "eslint-plugin-prettier": "^5.0.0",
64
+ "eslint-plugin-prettier": "^5.0.1",
59
65
  "husky": "^8.0.3",
60
- "lint-staged": "^14.0.1",
66
+ "lint-staged": "^15.0.2",
61
67
  "prettier": "^3.0.3",
62
68
  "standard-version": "^9.5.0",
63
69
  "tsconfig-paths": "^4.2.0",
64
70
  "tsup": "^7.2.0",
65
- "typedoc": "^0.25.1",
71
+ "typedoc": "^0.25.2",
66
72
  "typescript": "^5.2.2",
67
73
  "vitest": "^0.34.6"
68
74
  },
69
75
  "peerDependencies": {
70
- "@mysten/sui.js": "^0.42.0",
71
- "@scallop-io/sui-kit": "^0.42.0"
76
+ "@mysten/sui.js": "^0.44.0",
77
+ "@scallop-io/sui-kit": "^0.44.0"
72
78
  },
73
79
  "lint-staged": {
74
80
  "**/*.ts": [
@@ -3,7 +3,7 @@ import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui.js/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
- import type { SuiTxArg } from '@scallop-io/sui-kit';
6
+ import type { SuiAddressArg } from '@scallop-io/sui-kit';
7
7
  import type { ScallopBuilder } from '../models';
8
8
  import type {
9
9
  CoreIds,
@@ -46,8 +46,8 @@ const requireObligationInfo = async (
46
46
  ...params: [
47
47
  builder: ScallopBuilder,
48
48
  txBlock: SuiKitTxBlock,
49
- obligationId?: SuiTxArg | undefined,
50
- obligationKey?: SuiTxArg | undefined,
49
+ obligationId?: SuiAddressArg,
50
+ obligationKey?: SuiAddressArg,
51
51
  ]
52
52
  ) => {
53
53
  const [builder, txBlock, obligationId, obligationKey] = params;
@@ -275,12 +275,12 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
275
275
  obligationKey
276
276
  );
277
277
  const updateCoinNames = await builder.utils.getObligationCoinNames(
278
- obligationInfo.obligationId as string
278
+ obligationInfo.obligationId
279
279
  );
280
280
  await updateOracles(builder, txBlock, updateCoinNames);
281
281
  return txBlock.takeCollateral(
282
282
  obligationInfo.obligationId,
283
- obligationInfo.obligationKey as SuiTxArg,
283
+ obligationInfo.obligationKey as SuiAddressArg,
284
284
  amount,
285
285
  collateralCoinName
286
286
  );
@@ -321,13 +321,13 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
321
321
  obligationKey
322
322
  );
323
323
  const obligationCoinNames = await builder.utils.getObligationCoinNames(
324
- obligationInfo.obligationId as string
324
+ obligationInfo.obligationId
325
325
  );
326
326
  const updateCoinNames = [...obligationCoinNames, poolCoinName];
327
327
  await updateOracles(builder, txBlock, updateCoinNames);
328
328
  return txBlock.borrow(
329
329
  obligationInfo.obligationId,
330
- obligationInfo.obligationKey as SuiTxArg,
330
+ obligationInfo.obligationKey as SuiAddressArg,
331
331
  amount,
332
332
  poolCoinName
333
333
  );
@@ -3,7 +3,8 @@ import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui.js/utils';
3
3
  import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
4
4
  import { rewardCoins } from '../constants/enum';
5
5
  import { getStakeAccounts } from '../queries/spoolQuery';
6
- import type { SuiTxArg } from '@scallop-io/sui-kit';
6
+ import type { SuiAddressArg } from '@scallop-io/sui-kit';
7
+ import type { TransactionResult } from '@mysten/sui.js/transactions';
7
8
  import type { ScallopBuilder } from '../models';
8
9
  import type {
9
10
  SpoolIds,
@@ -13,7 +14,6 @@ import type {
13
14
  SpoolTxBlock,
14
15
  SupportStakeMarketCoins,
15
16
  ScallopTxBlock,
16
- TransactionResult,
17
17
  } from '../types';
18
18
 
19
19
  /**
@@ -48,7 +48,7 @@ const requireStakeAccountIds = async (
48
48
  builder: ScallopBuilder,
49
49
  txBlock: SuiKitTxBlock,
50
50
  stakeMarketCoinName: SupportStakeMarketCoins,
51
- stakeAccountId?: SuiTxArg,
51
+ stakeAccountId?: SuiAddressArg,
52
52
  ]
53
53
  ) => {
54
54
  const [builder, txBlock, stakeMarketCoinName, stakeAccountId] = params;
@@ -79,7 +79,7 @@ const requireStakeAccounts = async (
79
79
  builder: ScallopBuilder,
80
80
  txBlock: SuiKitTxBlock,
81
81
  stakeMarketCoinName: SupportStakeMarketCoins,
82
- stakeAccountId?: SuiTxArg,
82
+ stakeAccountId?: SuiAddressArg,
83
83
  ]
84
84
  ) => {
85
85
  const [builder, txBlock, stakeMarketCoinName, stakeAccountId] = params;
@@ -4,6 +4,8 @@ import type {
4
4
  MarketCoins,
5
5
  StakeMarketCoins,
6
6
  RewardCoins,
7
+ AssetCoinIds,
8
+ WormholeCoinIds,
7
9
  } from '../types';
8
10
 
9
11
  export const coinDecimals: SupportCoinDecimals = {
@@ -58,3 +60,23 @@ export const rewardCoins: RewardCoins = {
58
60
  susdc: 'sui',
59
61
  susdt: 'sui',
60
62
  };
63
+
64
+ export const coinIds: AssetCoinIds = {
65
+ sui: '0x0000000000000000000000000000000000000000000000000000000000000002',
66
+ eth: '0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5',
67
+ btc: '0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881',
68
+ usdc: '0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf',
69
+ usdt: '0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c',
70
+ apt: '0x3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37',
71
+ sol: '0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8',
72
+ cetus: '0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b',
73
+ };
74
+
75
+ export const wormholeCoinIds: WormholeCoinIds = {
76
+ eth: '0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5',
77
+ btc: '0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881',
78
+ usdc: '0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf',
79
+ usdt: '0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c',
80
+ apt: '0x3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37',
81
+ sol: '0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8',
82
+ };