@scallop-io/sui-scallop-sdk 0.42.8 → 0.44.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/constants/common.d.ts +2 -2
- package/dist/index.js +20 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -6
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopBuilder.d.ts +4 -60
- package/dist/models/scallopClient.d.ts +10 -10
- package/dist/models/scallopQuery.d.ts +10 -0
- package/dist/models/scallopUtils.d.ts +4 -1
- package/dist/queries/coreQuery.d.ts +10 -1
- package/dist/queries/portfolioQuery.d.ts +2 -0
- package/dist/types/builder/core.d.ts +18 -18
- package/dist/types/builder/index.d.ts +0 -2
- package/dist/types/builder/spool.d.ts +8 -9
- package/package.json +24 -18
- package/src/builders/coreBuilder.ts +7 -7
- package/src/builders/spoolBuilder.ts +4 -4
- package/src/constants/common.ts +4 -0
- package/src/constants/enum.ts +10 -0
- package/src/models/scallopClient.ts +20 -20
- package/src/models/scallopUtils.ts +2 -2
- package/src/queries/coreQuery.ts +2 -1
- package/src/types/builder/core.ts +34 -29
- package/src/types/builder/index.ts +0 -2
- package/src/types/builder/spool.ts +15 -17
|
@@ -6,8 +6,8 @@ import { ScallopUtils } from './scallopUtils';
|
|
|
6
6
|
import { ScallopBuilder } from './scallopBuilder';
|
|
7
7
|
import { ScallopQuery } from './scallopQuery';
|
|
8
8
|
import type { SuiTransactionBlockResponse } from '@mysten/sui.js/client';
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
9
|
+
import type { TransactionObjectArgument } from '@mysten/sui.js/transactions';
|
|
10
|
+
import type { SuiObjectArg } from '@scallop-io/sui-kit';
|
|
11
11
|
import type {
|
|
12
12
|
ScallopClientFnReturnType,
|
|
13
13
|
ScallopInstanceParams,
|
|
@@ -237,14 +237,14 @@ export class ScallopClient {
|
|
|
237
237
|
collateralCoinName: SupportCollateralCoins,
|
|
238
238
|
amount: number,
|
|
239
239
|
sign?: S,
|
|
240
|
-
obligationId?:
|
|
240
|
+
obligationId?: string,
|
|
241
241
|
walletAddress?: string
|
|
242
242
|
): Promise<ScallopClientFnReturnType<S>>;
|
|
243
243
|
public async depositCollateral<S extends boolean>(
|
|
244
244
|
collateralCoinName: SupportCollateralCoins,
|
|
245
245
|
amount: number,
|
|
246
246
|
sign: S = true as S,
|
|
247
|
-
obligationId?:
|
|
247
|
+
obligationId?: string,
|
|
248
248
|
walletAddress?: string
|
|
249
249
|
): Promise<ScallopClientFnReturnType<S>> {
|
|
250
250
|
const txBlock = this.builder.createTxBlock();
|
|
@@ -374,14 +374,14 @@ export class ScallopClient {
|
|
|
374
374
|
stakeCoinName: SupportStakeCoins,
|
|
375
375
|
amount: number,
|
|
376
376
|
sign?: S,
|
|
377
|
-
stakeAccountId?:
|
|
377
|
+
stakeAccountId?: string,
|
|
378
378
|
walletAddress?: string
|
|
379
379
|
): Promise<ScallopClientFnReturnType<S>>;
|
|
380
380
|
public async depositAndStake<S extends boolean>(
|
|
381
381
|
stakeCoinName: SupportStakeCoins,
|
|
382
382
|
amount: number,
|
|
383
383
|
sign: S = true as S,
|
|
384
|
-
stakeAccountId?:
|
|
384
|
+
stakeAccountId?: string,
|
|
385
385
|
walletAddress?: string
|
|
386
386
|
): Promise<ScallopClientFnReturnType<S>> {
|
|
387
387
|
const txBlock = this.builder.createTxBlock();
|
|
@@ -543,16 +543,16 @@ export class ScallopClient {
|
|
|
543
543
|
amount: number,
|
|
544
544
|
callback: (
|
|
545
545
|
txBlock: ScallopTxBlock,
|
|
546
|
-
coin:
|
|
547
|
-
) =>
|
|
546
|
+
coin: TransactionObjectArgument | string
|
|
547
|
+
) => SuiObjectArg
|
|
548
548
|
): Promise<SuiTransactionBlockResponse>;
|
|
549
549
|
public async flashLoan<S extends boolean>(
|
|
550
550
|
poolCoinName: SupportPoolCoins,
|
|
551
551
|
amount: number,
|
|
552
552
|
callback: (
|
|
553
553
|
txBlock: ScallopTxBlock,
|
|
554
|
-
coin:
|
|
555
|
-
) =>
|
|
554
|
+
coin: TransactionObjectArgument | string
|
|
555
|
+
) => SuiObjectArg,
|
|
556
556
|
sign?: S,
|
|
557
557
|
walletAddress?: string
|
|
558
558
|
): Promise<ScallopClientFnReturnType<S>>;
|
|
@@ -561,8 +561,8 @@ export class ScallopClient {
|
|
|
561
561
|
amount: number,
|
|
562
562
|
callback: (
|
|
563
563
|
txBlock: ScallopTxBlock,
|
|
564
|
-
coin:
|
|
565
|
-
) =>
|
|
564
|
+
coin: TransactionObjectArgument | string
|
|
565
|
+
) => SuiObjectArg,
|
|
566
566
|
sign: S = true as S,
|
|
567
567
|
walletAddress?: string
|
|
568
568
|
): Promise<ScallopClientFnReturnType<S>> {
|
|
@@ -637,14 +637,14 @@ export class ScallopClient {
|
|
|
637
637
|
stakeMarketCoinName: SupportStakeMarketCoins,
|
|
638
638
|
amount: number,
|
|
639
639
|
sign?: S,
|
|
640
|
-
stakeAccountId?:
|
|
640
|
+
stakeAccountId?: string,
|
|
641
641
|
walletAddress?: string
|
|
642
642
|
): Promise<ScallopClientFnReturnType<S>>;
|
|
643
643
|
public async stake<S extends boolean>(
|
|
644
644
|
stakeMarketCoinName: SupportStakeMarketCoins,
|
|
645
645
|
amount: number,
|
|
646
646
|
sign: S = true as S,
|
|
647
|
-
stakeAccountId?:
|
|
647
|
+
stakeAccountId?: string,
|
|
648
648
|
walletAddress?: string
|
|
649
649
|
): Promise<ScallopClientFnReturnType<S>> {
|
|
650
650
|
const txBlock = this.builder.createTxBlock();
|
|
@@ -689,14 +689,14 @@ export class ScallopClient {
|
|
|
689
689
|
stakeMarketCoinName: SupportStakeMarketCoins,
|
|
690
690
|
amount: number,
|
|
691
691
|
sign?: S,
|
|
692
|
-
stakeAccountId?:
|
|
692
|
+
stakeAccountId?: string,
|
|
693
693
|
walletAddress?: string
|
|
694
694
|
): Promise<ScallopClientFnReturnType<S>>;
|
|
695
695
|
public async unstake<S extends boolean>(
|
|
696
696
|
stakeMarketCoinName: SupportStakeMarketCoins,
|
|
697
697
|
amount: number,
|
|
698
698
|
sign: S = true as S,
|
|
699
|
-
stakeAccountId?:
|
|
699
|
+
stakeAccountId?: string,
|
|
700
700
|
walletAddress?: string
|
|
701
701
|
): Promise<ScallopClientFnReturnType<S>> {
|
|
702
702
|
const txBlock = this.builder.createTxBlock();
|
|
@@ -737,14 +737,14 @@ export class ScallopClient {
|
|
|
737
737
|
stakeMarketCoinName: SupportStakeMarketCoins,
|
|
738
738
|
amount: number,
|
|
739
739
|
sign?: S,
|
|
740
|
-
stakeAccountId?:
|
|
740
|
+
stakeAccountId?: string,
|
|
741
741
|
walletAddress?: string
|
|
742
742
|
): Promise<ScallopClientFnReturnType<S>>;
|
|
743
743
|
public async unstakeAndWithdraw<S extends boolean>(
|
|
744
744
|
stakeMarketCoinName: SupportStakeMarketCoins,
|
|
745
745
|
amount: number,
|
|
746
746
|
sign: S = true as S,
|
|
747
|
-
stakeAccountId?:
|
|
747
|
+
stakeAccountId?: string,
|
|
748
748
|
walletAddress?: string
|
|
749
749
|
): Promise<ScallopClientFnReturnType<S>> {
|
|
750
750
|
const txBlock = this.builder.createTxBlock();
|
|
@@ -791,13 +791,13 @@ export class ScallopClient {
|
|
|
791
791
|
public async claim<S extends boolean>(
|
|
792
792
|
stakeMarketCoinName: SupportStakeMarketCoins,
|
|
793
793
|
sign?: S,
|
|
794
|
-
stakeAccountId?:
|
|
794
|
+
stakeAccountId?: string,
|
|
795
795
|
walletAddress?: string
|
|
796
796
|
): Promise<ScallopClientFnReturnType<S>>;
|
|
797
797
|
public async claim<S extends boolean>(
|
|
798
798
|
stakeMarketCoinName: SupportStakeMarketCoins,
|
|
799
799
|
sign: S = true as S,
|
|
800
|
-
stakeAccountId?:
|
|
800
|
+
stakeAccountId?: string,
|
|
801
801
|
walletAddress?: string
|
|
802
802
|
): Promise<ScallopClientFnReturnType<S>> {
|
|
803
803
|
const txBlock = this.builder.createTxBlock();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SUI_TYPE_ARG, normalizeStructTag } from '@mysten/sui.js/utils';
|
|
2
|
-
import { SuiKit } from '@scallop-io/sui-kit';
|
|
2
|
+
import { SuiAddressArg, SuiKit } from '@scallop-io/sui-kit';
|
|
3
3
|
import { SuiPriceServiceConnection } from '@pythnetwork/pyth-sui-js';
|
|
4
4
|
import { ScallopAddress } from './scallopAddress';
|
|
5
5
|
import { ScallopQuery } from './scallopQuery';
|
|
@@ -294,7 +294,7 @@ export class ScallopUtils {
|
|
|
294
294
|
* @param obligationId - The obligation id.
|
|
295
295
|
* @return Asset coin Names.
|
|
296
296
|
*/
|
|
297
|
-
public async getObligationCoinNames(obligationId:
|
|
297
|
+
public async getObligationCoinNames(obligationId: SuiAddressArg) {
|
|
298
298
|
const obligation = await queryObligation(this._query, obligationId);
|
|
299
299
|
const collateralCoinTypes = obligation.collaterals.map((collateral) => {
|
|
300
300
|
return `0x${collateral.type.name}`;
|
package/src/queries/coreQuery.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
calculateMarketCollateralData,
|
|
13
13
|
} from '../utils';
|
|
14
14
|
import type { SuiObjectResponse, SuiObjectData } from '@mysten/sui.js/client';
|
|
15
|
+
import type { SuiAddressArg } from '@scallop-io/sui-kit';
|
|
15
16
|
import type { ScallopQuery } from '../models';
|
|
16
17
|
import {
|
|
17
18
|
Market,
|
|
@@ -603,7 +604,7 @@ export const getObligations = async (
|
|
|
603
604
|
*/
|
|
604
605
|
export const queryObligation = async (
|
|
605
606
|
query: ScallopQuery,
|
|
606
|
-
obligationId:
|
|
607
|
+
obligationId: SuiAddressArg
|
|
607
608
|
) => {
|
|
608
609
|
const packageId = query.address.get('core.packages.query.id');
|
|
609
610
|
const queryTarget = `${packageId}::obligation_query::obligation_data`;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
SuiTxBlock as SuiKitTxBlock,
|
|
3
|
+
SuiAddressArg,
|
|
4
|
+
SuiObjectArg,
|
|
3
5
|
SuiTxArg,
|
|
4
6
|
} from '@scallop-io/sui-kit';
|
|
7
|
+
import type { TransactionResult } from '@mysten/sui.js/transactions';
|
|
5
8
|
import type { ScallopBuilder } from '../../models';
|
|
6
9
|
import type {
|
|
7
10
|
SupportCollateralCoins,
|
|
8
11
|
SupportPoolCoins,
|
|
9
12
|
SupportAssetCoins,
|
|
10
13
|
} from '../constant';
|
|
11
|
-
import type { TransactionResult } from './index';
|
|
12
14
|
|
|
13
15
|
export type CoreIds = {
|
|
14
16
|
protocolPkg: string;
|
|
@@ -21,55 +23,58 @@ export type CoreIds = {
|
|
|
21
23
|
export type CoreNormalMethods = {
|
|
22
24
|
openObligation: () => TransactionResult;
|
|
23
25
|
returnObligation: (
|
|
24
|
-
obligation:
|
|
25
|
-
obligationHotPotato:
|
|
26
|
+
obligation: SuiAddressArg,
|
|
27
|
+
obligationHotPotato: SuiObjectArg
|
|
26
28
|
) => void;
|
|
27
29
|
openObligationEntry: () => void;
|
|
28
30
|
addCollateral: (
|
|
29
|
-
obligation:
|
|
30
|
-
coin:
|
|
31
|
+
obligation: SuiAddressArg,
|
|
32
|
+
coin: SuiObjectArg,
|
|
31
33
|
collateralCoinName: SupportCollateralCoins
|
|
32
34
|
) => void;
|
|
33
35
|
takeCollateral: (
|
|
34
|
-
obligation:
|
|
35
|
-
obligationKey:
|
|
36
|
-
amount:
|
|
36
|
+
obligation: SuiAddressArg,
|
|
37
|
+
obligationKey: SuiAddressArg,
|
|
38
|
+
amount: SuiTxArg,
|
|
37
39
|
collateralCoinName: SupportCollateralCoins
|
|
38
40
|
) => TransactionResult;
|
|
39
41
|
deposit: (
|
|
40
|
-
coin:
|
|
42
|
+
coin: SuiObjectArg,
|
|
41
43
|
poolCoinName: SupportPoolCoins
|
|
42
44
|
) => TransactionResult;
|
|
43
|
-
depositEntry: (coin:
|
|
45
|
+
depositEntry: (coin: SuiObjectArg, poolCoinName: SupportPoolCoins) => void;
|
|
44
46
|
withdraw: (
|
|
45
|
-
marketCoin:
|
|
47
|
+
marketCoin: SuiObjectArg,
|
|
46
48
|
poolCoinName: SupportPoolCoins
|
|
47
49
|
) => TransactionResult;
|
|
48
|
-
withdrawEntry: (
|
|
50
|
+
withdrawEntry: (
|
|
51
|
+
marketCoin: SuiObjectArg,
|
|
52
|
+
poolCoinName: SupportPoolCoins
|
|
53
|
+
) => void;
|
|
49
54
|
borrow: (
|
|
50
|
-
obligation:
|
|
51
|
-
obligationKey:
|
|
52
|
-
amount:
|
|
55
|
+
obligation: SuiAddressArg,
|
|
56
|
+
obligationKey: SuiAddressArg,
|
|
57
|
+
amount: SuiTxArg,
|
|
53
58
|
poolCoinName: SupportPoolCoins
|
|
54
59
|
) => TransactionResult;
|
|
55
60
|
borrowEntry: (
|
|
56
|
-
obligation:
|
|
57
|
-
obligationKey:
|
|
58
|
-
amount:
|
|
61
|
+
obligation: SuiAddressArg,
|
|
62
|
+
obligationKey: SuiAddressArg,
|
|
63
|
+
amount: SuiTxArg,
|
|
59
64
|
poolCoinName: SupportPoolCoins
|
|
60
65
|
) => void;
|
|
61
66
|
repay: (
|
|
62
|
-
obligation:
|
|
63
|
-
coin:
|
|
67
|
+
obligation: SuiAddressArg,
|
|
68
|
+
coin: SuiObjectArg,
|
|
64
69
|
poolCoinName: SupportPoolCoins
|
|
65
70
|
) => void;
|
|
66
71
|
borrowFlashLoan: (
|
|
67
|
-
amount:
|
|
72
|
+
amount: SuiTxArg,
|
|
68
73
|
poolCoinName: SupportPoolCoins
|
|
69
74
|
) => TransactionResult;
|
|
70
75
|
repayFlashLoan: (
|
|
71
|
-
coin:
|
|
72
|
-
loan:
|
|
76
|
+
coin: SuiObjectArg,
|
|
77
|
+
loan: SuiAddressArg,
|
|
73
78
|
poolCoinName: SupportPoolCoins
|
|
74
79
|
) => void;
|
|
75
80
|
};
|
|
@@ -78,19 +83,19 @@ export type CoreQuickMethods = {
|
|
|
78
83
|
addCollateralQuick: (
|
|
79
84
|
amount: number,
|
|
80
85
|
collateralCoinName: SupportCollateralCoins,
|
|
81
|
-
obligationId?:
|
|
86
|
+
obligationId?: SuiAddressArg
|
|
82
87
|
) => Promise<void>;
|
|
83
88
|
takeCollateralQuick: (
|
|
84
89
|
amount: number,
|
|
85
90
|
collateralCoinName: SupportCollateralCoins,
|
|
86
|
-
obligationId?:
|
|
87
|
-
obligationKey?:
|
|
91
|
+
obligationId?: SuiAddressArg,
|
|
92
|
+
obligationKey?: SuiAddressArg
|
|
88
93
|
) => Promise<TransactionResult>;
|
|
89
94
|
borrowQuick: (
|
|
90
95
|
amount: number,
|
|
91
96
|
poolCoinName: SupportPoolCoins,
|
|
92
|
-
obligationId?:
|
|
93
|
-
obligationKey?:
|
|
97
|
+
obligationId?: SuiAddressArg,
|
|
98
|
+
obligationKey?: SuiAddressArg
|
|
94
99
|
) => Promise<TransactionResult>;
|
|
95
100
|
depositQuick: (
|
|
96
101
|
amount: number,
|
|
@@ -103,7 +108,7 @@ export type CoreQuickMethods = {
|
|
|
103
108
|
repayQuick: (
|
|
104
109
|
amount: number,
|
|
105
110
|
poolCoinName: SupportPoolCoins,
|
|
106
|
-
obligationId?:
|
|
111
|
+
obligationId?: SuiAddressArg
|
|
107
112
|
) => Promise<void>;
|
|
108
113
|
updateAssetPricesQuick: (
|
|
109
114
|
assetCoinNames?: SupportAssetCoins[]
|
|
@@ -1,4 +1,3 @@
|
|
|
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
|
|
|
@@ -6,4 +5,3 @@ export type * from './core';
|
|
|
6
5
|
export type * from './spool';
|
|
7
6
|
|
|
8
7
|
export type ScallopTxBlock = CoreTxBlock & SpoolTxBlock;
|
|
9
|
-
export type TransactionResult = TransactionArgument & TransactionArgument[];
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
SuiTxBlock as SuiKitTxBlock,
|
|
3
|
+
SuiAddressArg,
|
|
4
|
+
SuiObjectArg,
|
|
3
5
|
SuiTxArg,
|
|
4
6
|
} from '@scallop-io/sui-kit';
|
|
7
|
+
import type { TransactionResult } from '@mysten/sui.js/transactions';
|
|
5
8
|
import type { ScallopBuilder } from '../../models';
|
|
6
9
|
import type { SupportStakeMarketCoins } from '../constant';
|
|
7
|
-
import type { TransactionResult } from './index';
|
|
8
10
|
|
|
9
11
|
export type SpoolIds = {
|
|
10
12
|
spoolPkg: string;
|
|
@@ -15,41 +17,37 @@ export type SpoolNormalMethods = {
|
|
|
15
17
|
stakeMarketCoinName: SupportStakeMarketCoins
|
|
16
18
|
) => TransactionResult;
|
|
17
19
|
stake: (
|
|
18
|
-
stakeAccount:
|
|
19
|
-
coin:
|
|
20
|
+
stakeAccount: SuiAddressArg,
|
|
21
|
+
coin: SuiObjectArg,
|
|
20
22
|
stakeMarketCoinName: SupportStakeMarketCoins
|
|
21
23
|
) => void;
|
|
22
24
|
unstake: (
|
|
23
|
-
stakeAccount:
|
|
24
|
-
amount:
|
|
25
|
+
stakeAccount: SuiAddressArg,
|
|
26
|
+
amount: SuiTxArg,
|
|
25
27
|
stakeMarketCoinName: SupportStakeMarketCoins
|
|
26
28
|
) => TransactionResult;
|
|
27
29
|
claim: (
|
|
28
|
-
stakeAccount:
|
|
30
|
+
stakeAccount: SuiAddressArg,
|
|
29
31
|
stakeMarketCoinName: SupportStakeMarketCoins
|
|
30
32
|
) => TransactionResult;
|
|
31
33
|
};
|
|
32
34
|
|
|
33
35
|
export type SpoolQuickMethods = {
|
|
34
36
|
stakeQuick(
|
|
35
|
-
amountOrMarketCoin: number,
|
|
37
|
+
amountOrMarketCoin: SuiObjectArg | number,
|
|
36
38
|
stakeMarketCoinName: SupportStakeMarketCoins,
|
|
37
|
-
stakeAccountId?:
|
|
38
|
-
): Promise<void>;
|
|
39
|
-
stakeQuick(
|
|
40
|
-
amountOrMarketCoin: TransactionResult,
|
|
41
|
-
stakeMarketCoinName: SupportStakeMarketCoins,
|
|
42
|
-
stakeAccountId?: SuiTxArg
|
|
39
|
+
stakeAccountId?: SuiAddressArg
|
|
43
40
|
): Promise<void>;
|
|
41
|
+
|
|
44
42
|
unstakeQuick(
|
|
45
43
|
amount: number,
|
|
46
44
|
stakeMarketCoinName: SupportStakeMarketCoins,
|
|
47
|
-
stakeAccountId?:
|
|
48
|
-
): Promise<TransactionResult>;
|
|
45
|
+
stakeAccountId?: SuiAddressArg
|
|
46
|
+
): Promise<TransactionResult[]>;
|
|
49
47
|
claimQuick(
|
|
50
48
|
stakeMarketCoinName: SupportStakeMarketCoins,
|
|
51
|
-
stakeAccountId?:
|
|
52
|
-
): Promise<TransactionResult>;
|
|
49
|
+
stakeAccountId?: SuiAddressArg
|
|
50
|
+
): Promise<TransactionResult[]>;
|
|
53
51
|
};
|
|
54
52
|
|
|
55
53
|
export type SuiTxBlockWithSpoolNormalMethods = SuiKitTxBlock &
|