@scallop-io/sui-scallop-sdk 1.4.15-rc.3 → 1.4.17
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 +6 -6
- package/dist/constants/enum.d.ts +2 -2
- package/dist/constants/index.d.ts +0 -1
- package/dist/constants/poolAddress.d.ts +2 -1
- package/dist/constants/queryKeys.d.ts +3 -4
- package/dist/index.d.ts +0 -1
- package/dist/index.js +2019 -1634
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2087 -1697
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallop.d.ts +1 -2
- package/dist/models/scallopBuilder.d.ts +3 -2
- package/dist/models/scallopCache.d.ts +18 -12
- package/dist/models/scallopClient.d.ts +1 -1
- package/dist/models/scallopIndexer.d.ts +1 -1
- package/dist/models/scallopQuery.d.ts +96 -11
- package/dist/models/scallopUtils.d.ts +4 -4
- package/dist/queries/borrowIncentiveQuery.d.ts +6 -1
- package/dist/queries/coreQuery.d.ts +2 -0
- package/dist/queries/objectsQuery.d.ts +1 -2
- package/dist/queries/poolAddressesQuery.d.ts +4 -2
- package/dist/queries/portfolioQuery.d.ts +71 -5
- package/dist/queries/priceQuery.d.ts +4 -0
- package/dist/queries/sCoinQuery.d.ts +1 -1
- package/dist/types/builder/core.d.ts +3 -3
- package/dist/types/model.d.ts +8 -2
- package/dist/utils/index.d.ts +0 -2
- package/package.json +7 -7
- package/src/builders/borrowIncentiveBuilder.ts +11 -5
- package/src/builders/coreBuilder.ts +61 -32
- package/src/builders/loyaltyProgramBuilder.ts +3 -2
- package/src/builders/referralBuilder.ts +16 -6
- package/src/builders/sCoinBuilder.ts +6 -4
- package/src/builders/spoolBuilder.ts +14 -7
- package/src/builders/vescaBuilder.ts +13 -7
- package/src/constants/coinGecko.ts +2 -0
- package/src/constants/common.ts +7 -1
- package/src/constants/enum.ts +46 -20
- package/src/constants/index.ts +0 -1
- package/src/constants/poolAddress.ts +163 -41
- package/src/constants/pyth.ts +2 -0
- package/src/constants/queryKeys.ts +7 -9
- package/src/constants/testAddress.ts +24 -0
- package/src/index.ts +0 -1
- package/src/models/scallop.ts +9 -13
- package/src/models/scallopAddress.ts +2 -9
- package/src/models/scallopBuilder.ts +63 -9
- package/src/models/scallopCache.ts +220 -114
- package/src/models/scallopClient.ts +4 -7
- package/src/models/scallopIndexer.ts +2 -6
- package/src/models/scallopQuery.ts +54 -20
- package/src/models/scallopUtils.ts +9 -13
- package/src/queries/borrowIncentiveQuery.ts +6 -13
- package/src/queries/coreQuery.ts +62 -48
- package/src/queries/loyaltyProgramQuery.ts +1 -3
- package/src/queries/objectsQuery.ts +3 -5
- package/src/queries/poolAddressesQuery.ts +13 -10
- package/src/queries/portfolioQuery.ts +256 -21
- package/src/queries/priceQuery.ts +2 -7
- package/src/queries/sCoinQuery.ts +2 -2
- package/src/queries/spoolQuery.ts +21 -20
- package/src/queries/vescaQuery.ts +3 -7
- package/src/types/builder/core.ts +21 -3
- package/src/types/model.ts +13 -2
- package/src/utils/index.ts +0 -2
- package/src/utils/indexer.ts +3 -1
- package/src/utils/query.ts +2 -2
- package/dist/constants/tokenBucket.d.ts +0 -2
- package/dist/utils/tokenBucket.d.ts +0 -11
- package/src/constants/tokenBucket.ts +0 -2
- package/src/utils/tokenBucket.ts +0 -68
|
@@ -17,6 +17,7 @@ export declare const getPythPrices: ({ address, }: {
|
|
|
17
17
|
export declare const getAllCoinPrices: (query: ScallopQuery, marketPools?: MarketPools, coinPrices?: CoinPrices) => Promise<{
|
|
18
18
|
susdc?: number | undefined;
|
|
19
19
|
ssbeth?: number | undefined;
|
|
20
|
+
ssbusdt?: number | undefined;
|
|
20
21
|
sweth?: number | undefined;
|
|
21
22
|
swbtc?: number | undefined;
|
|
22
23
|
swusdc?: number | undefined;
|
|
@@ -30,8 +31,10 @@ export declare const getAllCoinPrices: (query: ScallopQuery, marketPools?: Marke
|
|
|
30
31
|
ssca?: number | undefined;
|
|
31
32
|
sfud?: number | undefined;
|
|
32
33
|
sdeep?: number | undefined;
|
|
34
|
+
sfdusd?: number | undefined;
|
|
33
35
|
usdc?: number | undefined;
|
|
34
36
|
sbeth?: number | undefined;
|
|
37
|
+
sbusdt?: number | undefined;
|
|
35
38
|
weth?: number | undefined;
|
|
36
39
|
wbtc?: number | undefined;
|
|
37
40
|
wusdc?: number | undefined;
|
|
@@ -46,5 +49,6 @@ export declare const getAllCoinPrices: (query: ScallopQuery, marketPools?: Marke
|
|
|
46
49
|
sca?: number | undefined;
|
|
47
50
|
fud?: number | undefined;
|
|
48
51
|
deep?: number | undefined;
|
|
52
|
+
fdusd?: number | undefined;
|
|
49
53
|
swapt?: number | undefined;
|
|
50
54
|
}>;
|
|
@@ -19,7 +19,7 @@ export declare const getSCoinTotalSupply: ({ utils, }: {
|
|
|
19
19
|
*/
|
|
20
20
|
export declare const getSCoinAmounts: ({ utils, }: {
|
|
21
21
|
utils: ScallopUtils;
|
|
22
|
-
}, sCoinNames?: SupportSCoin[], ownerAddress?: string) => Promise<OptionalKeys<Record<"susdc" | "ssbeth" | "sweth" | "swbtc" | "swusdc" | "swusdt" | "ssui" | "swsol" | "scetus" | "safsui" | "shasui" | "svsui" | "ssca" | "sfud" | "sdeep", number>>>;
|
|
22
|
+
}, sCoinNames?: SupportSCoin[], ownerAddress?: string) => Promise<OptionalKeys<Record<"susdc" | "ssbeth" | "ssbusdt" | "sweth" | "swbtc" | "swusdc" | "swusdt" | "ssui" | "swsol" | "scetus" | "safsui" | "shasui" | "svsui" | "ssca" | "sfud" | "sdeep" | "sfdusd", number>>>;
|
|
23
23
|
/**
|
|
24
24
|
* Query owned sCoin amount.
|
|
25
25
|
*
|
|
@@ -23,12 +23,12 @@ export type CoreNormalMethods = {
|
|
|
23
23
|
addCollateral: (obligation: SuiObjectArg, coin: SuiObjectArg, collateralCoinName: SupportCollateralCoins) => void;
|
|
24
24
|
takeCollateral: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, amount: number, collateralCoinName: SupportCollateralCoins) => TransactionResult;
|
|
25
25
|
deposit: (coin: SuiObjectArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
26
|
-
depositEntry: (coin: SuiObjectArg, poolCoinName: SupportPoolCoins) =>
|
|
26
|
+
depositEntry: (coin: SuiObjectArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
27
27
|
withdraw: (marketCoin: SuiObjectArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
28
|
-
withdrawEntry: (marketCoin: SuiObjectArg, poolCoinName: SupportPoolCoins) =>
|
|
28
|
+
withdrawEntry: (marketCoin: SuiObjectArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
29
29
|
borrow: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, amount: number, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
30
30
|
borrowWithReferral: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, borrowReferral: SuiObjectArg, amount: number | SuiTxArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
31
|
-
borrowEntry: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, amount: number, poolCoinName: SupportPoolCoins) =>
|
|
31
|
+
borrowEntry: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, amount: number, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
32
32
|
repay: (obligation: SuiObjectArg, coin: SuiObjectArg, poolCoinName: SupportPoolCoins) => void;
|
|
33
33
|
borrowFlashLoan: (amount: number | SuiTxArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
34
34
|
repayFlashLoan: (coin: SuiObjectArg, loan: SuiObjectArg, poolCoinName: SupportPoolCoins) => void;
|
package/dist/types/model.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { SuiKit, SuiKitParams, NetworkType } from '@scallop-io/sui-kit';
|
|
|
4
4
|
import type { ScallopAddress, ScallopQuery, ScallopUtils, ScallopBuilder, ScallopIndexer } from '../models';
|
|
5
5
|
import { ScallopCache } from 'src/models/scallopCache';
|
|
6
6
|
import { AddressesInterface } from './address';
|
|
7
|
+
import { QueryClient, QueryClientConfig } from '@tanstack/query-core';
|
|
7
8
|
export type ScallopClientFnReturnType<T extends boolean> = T extends true ? SuiTransactionBlockResponse : Transaction;
|
|
8
9
|
export type ScallopClientVeScaReturnType<T extends boolean> = T extends true ? SuiTransactionBlockResponse : {
|
|
9
10
|
tx: Transaction;
|
|
@@ -12,7 +13,9 @@ export type ScallopClientVeScaReturnType<T extends boolean> = T extends true ? S
|
|
|
12
13
|
export type ScallopBaseInstanceParams = {
|
|
13
14
|
suiKit?: SuiKit;
|
|
14
15
|
};
|
|
15
|
-
export type ScallopCacheInstanceParams = ScallopBaseInstanceParams
|
|
16
|
+
export type ScallopCacheInstanceParams = ScallopBaseInstanceParams & {
|
|
17
|
+
queryClient?: QueryClient;
|
|
18
|
+
};
|
|
16
19
|
export type ScallopAddressInstanceParams = ScallopBaseInstanceParams & {
|
|
17
20
|
cache?: ScallopCache;
|
|
18
21
|
};
|
|
@@ -43,7 +46,7 @@ export type ScallopParams = {
|
|
|
43
46
|
forceAddressesInterface?: Partial<Record<NetworkType, AddressesInterface>>;
|
|
44
47
|
walletAddress?: string;
|
|
45
48
|
} & SuiKitParams;
|
|
46
|
-
export type ScallopClientParams = ScallopParams & ScallopBuilderParams & ScallopQueryParams & ScallopUtilsParams;
|
|
49
|
+
export type ScallopClientParams = ScallopParams & ScallopBuilderParams & ScallopQueryParams & ScallopUtilsParams & ScallopCacheParams;
|
|
47
50
|
export type ScallopBuilderParams = ScallopParams & {
|
|
48
51
|
pythEndpoints?: string[];
|
|
49
52
|
usePythPullModel?: boolean;
|
|
@@ -52,3 +55,6 @@ export type ScallopQueryParams = ScallopParams & ScallopUtilsParams;
|
|
|
52
55
|
export type ScallopUtilsParams = ScallopParams & {
|
|
53
56
|
pythEndpoints?: string[];
|
|
54
57
|
};
|
|
58
|
+
export type ScallopCacheParams = Omit<ScallopParams, 'addressId' | 'forceAddressesInterface'> & {
|
|
59
|
+
cacheOptions?: QueryClientConfig;
|
|
60
|
+
};
|
package/dist/utils/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scallop-io/sui-scallop-sdk",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.17",
|
|
4
4
|
"description": "Typescript sdk for interacting with Scallop contract on SUI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sui",
|
|
@@ -39,13 +39,12 @@
|
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@graphql-typed-document-node/core": "3.2.0",
|
|
42
|
-
"@mysten/
|
|
43
|
-
"@mysten/sui": "^1.3.0",
|
|
42
|
+
"@mysten/sui": "1.3.1",
|
|
44
43
|
"@noble/curves": "^1.2.0",
|
|
45
44
|
"@noble/hashes": "^1.3.2",
|
|
46
45
|
"@pythnetwork/price-service-client": "^1.8.2",
|
|
47
46
|
"@pythnetwork/pyth-sui-js": "2.1.0",
|
|
48
|
-
"@scallop-io/sui-kit": "1.3.1
|
|
47
|
+
"@scallop-io/sui-kit": "1.3.1",
|
|
49
48
|
"@scure/bip39": "^1.2.1",
|
|
50
49
|
"@tanstack/query-core": "5.51.15",
|
|
51
50
|
"axios": "^1.6.0",
|
|
@@ -81,9 +80,10 @@
|
|
|
81
80
|
"vitest": "^0.34.6"
|
|
82
81
|
},
|
|
83
82
|
"peerDependencies": {
|
|
84
|
-
"@mysten/sui": "1.3.
|
|
85
|
-
"@scallop-io/sui-kit": "1.3.1
|
|
86
|
-
"bn.js": "^5.2.1"
|
|
83
|
+
"@mysten/sui": "1.3.1",
|
|
84
|
+
"@scallop-io/sui-kit": "1.3.1",
|
|
85
|
+
"bn.js": "^5.2.1",
|
|
86
|
+
"@mysten/bcs": "^1.2.0"
|
|
87
87
|
},
|
|
88
88
|
"lint-staged": {
|
|
89
89
|
"**/*.ts": [
|
|
@@ -98,7 +98,8 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
|
|
|
98
98
|
|
|
99
99
|
return {
|
|
100
100
|
stakeObligation: (obligationId, obligationKey) => {
|
|
101
|
-
|
|
101
|
+
builder.moveCall(
|
|
102
|
+
txBlock,
|
|
102
103
|
`${borrowIncentiveIds.borrowIncentivePkg}::user::stake`,
|
|
103
104
|
[
|
|
104
105
|
borrowIncentiveIds.config,
|
|
@@ -112,7 +113,8 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
|
|
|
112
113
|
);
|
|
113
114
|
},
|
|
114
115
|
stakeObligationWithVesca: (obligationId, obligationKey, veScaKey) => {
|
|
115
|
-
|
|
116
|
+
builder.moveCall(
|
|
117
|
+
txBlock,
|
|
116
118
|
`${borrowIncentiveIds.borrowIncentivePkg}::user::stake_with_ve_sca`,
|
|
117
119
|
[
|
|
118
120
|
borrowIncentiveIds.config,
|
|
@@ -131,7 +133,8 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
|
|
|
131
133
|
);
|
|
132
134
|
},
|
|
133
135
|
unstakeObligation: (obligationId, obligationKey) => {
|
|
134
|
-
|
|
136
|
+
builder.moveCall(
|
|
137
|
+
txBlock,
|
|
135
138
|
`${borrowIncentiveIds.borrowIncentivePkg}::user::unstake`,
|
|
136
139
|
[
|
|
137
140
|
borrowIncentiveIds.config,
|
|
@@ -145,7 +148,8 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
|
|
|
145
148
|
},
|
|
146
149
|
claimBorrowIncentive: (obligationId, obligationKey, rewardCoinName) => {
|
|
147
150
|
const rewardType = builder.utils.parseCoinType(rewardCoinName);
|
|
148
|
-
return
|
|
151
|
+
return builder.moveCall(
|
|
152
|
+
txBlock,
|
|
149
153
|
`${borrowIncentiveIds.borrowIncentivePkg}::user::redeem_rewards`,
|
|
150
154
|
[
|
|
151
155
|
borrowIncentiveIds.config,
|
|
@@ -159,7 +163,8 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
|
|
|
159
163
|
);
|
|
160
164
|
},
|
|
161
165
|
deactivateBoost: (obligation, veScaKey) => {
|
|
162
|
-
|
|
166
|
+
builder.moveCall(
|
|
167
|
+
txBlock,
|
|
163
168
|
`${borrowIncentiveIds.borrowIncentivePkg}::user::deactivate_boost`,
|
|
164
169
|
[
|
|
165
170
|
borrowIncentiveIds.config,
|
|
@@ -287,6 +292,7 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
|
287
292
|
obligationKey
|
|
288
293
|
);
|
|
289
294
|
|
|
295
|
+
// return await txBlock.claimBorrowIncentive(
|
|
290
296
|
return txBlock.claimBorrowIncentive(
|
|
291
297
|
obligationArg,
|
|
292
298
|
obligationKeyArg,
|
|
@@ -78,7 +78,8 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
78
78
|
|
|
79
79
|
return {
|
|
80
80
|
openObligation: () => {
|
|
81
|
-
const [obligation, obligationKey, obligationHotPotato] =
|
|
81
|
+
const [obligation, obligationKey, obligationHotPotato] = builder.moveCall(
|
|
82
|
+
txBlock,
|
|
82
83
|
`${coreIds.protocolPkg}::open_obligation::open_obligation`,
|
|
83
84
|
[coreIds.version]
|
|
84
85
|
);
|
|
@@ -88,19 +89,24 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
88
89
|
NestedResult,
|
|
89
90
|
];
|
|
90
91
|
},
|
|
91
|
-
returnObligation: (obligation, obligationHotPotato) =>
|
|
92
|
-
|
|
92
|
+
returnObligation: (obligation, obligationHotPotato) => {
|
|
93
|
+
builder.moveCall(
|
|
94
|
+
txBlock,
|
|
93
95
|
`${coreIds.protocolPkg}::open_obligation::return_obligation`,
|
|
94
96
|
[coreIds.version, obligation, obligationHotPotato]
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
);
|
|
98
|
+
},
|
|
99
|
+
openObligationEntry: () => {
|
|
100
|
+
builder.moveCall(
|
|
101
|
+
txBlock,
|
|
98
102
|
`${coreIds.protocolPkg}::open_obligation::open_obligation_entry`,
|
|
99
103
|
[coreIds.version]
|
|
100
|
-
)
|
|
104
|
+
);
|
|
105
|
+
},
|
|
101
106
|
addCollateral: (obligation, coin, collateralCoinName) => {
|
|
102
107
|
const coinType = builder.utils.parseCoinType(collateralCoinName);
|
|
103
|
-
|
|
108
|
+
builder.moveCall(
|
|
109
|
+
txBlock,
|
|
104
110
|
`${coreIds.protocolPkg}::deposit_collateral::deposit_collateral`,
|
|
105
111
|
[coreIds.version, obligation, coreIds.market, coin],
|
|
106
112
|
[coinType]
|
|
@@ -108,7 +114,9 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
108
114
|
},
|
|
109
115
|
takeCollateral: (obligation, obligationKey, amount, collateralCoinName) => {
|
|
110
116
|
const coinType = builder.utils.parseCoinType(collateralCoinName);
|
|
111
|
-
return
|
|
117
|
+
// return await builder.moveCall(
|
|
118
|
+
return builder.moveCall(
|
|
119
|
+
txBlock,
|
|
112
120
|
`${coreIds.protocolPkg}::withdraw_collateral::withdraw_collateral`,
|
|
113
121
|
[
|
|
114
122
|
coreIds.version,
|
|
@@ -125,7 +133,9 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
125
133
|
},
|
|
126
134
|
deposit: (coin, poolCoinName) => {
|
|
127
135
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
128
|
-
return
|
|
136
|
+
// return await builder.moveCall(
|
|
137
|
+
return builder.moveCall(
|
|
138
|
+
txBlock,
|
|
129
139
|
`${coreIds.protocolPkg}::mint::mint`,
|
|
130
140
|
[coreIds.version, coreIds.market, coin, SUI_CLOCK_OBJECT_ID],
|
|
131
141
|
[coinType]
|
|
@@ -133,7 +143,9 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
133
143
|
},
|
|
134
144
|
depositEntry: (coin, poolCoinName) => {
|
|
135
145
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
136
|
-
return
|
|
146
|
+
// return await builder.moveCall(
|
|
147
|
+
return builder.moveCall(
|
|
148
|
+
txBlock,
|
|
137
149
|
`${coreIds.protocolPkg}::mint::mint_entry`,
|
|
138
150
|
[coreIds.version, coreIds.market, coin, SUI_CLOCK_OBJECT_ID],
|
|
139
151
|
[coinType]
|
|
@@ -141,7 +153,9 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
141
153
|
},
|
|
142
154
|
withdraw: (marketCoin, poolCoinName) => {
|
|
143
155
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
144
|
-
return
|
|
156
|
+
// return await builder.moveCall(
|
|
157
|
+
return builder.moveCall(
|
|
158
|
+
txBlock,
|
|
145
159
|
`${coreIds.protocolPkg}::redeem::redeem`,
|
|
146
160
|
[coreIds.version, coreIds.market, marketCoin, SUI_CLOCK_OBJECT_ID],
|
|
147
161
|
[coinType]
|
|
@@ -149,7 +163,9 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
149
163
|
},
|
|
150
164
|
withdrawEntry: (marketCoin, poolCoinName) => {
|
|
151
165
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
152
|
-
return
|
|
166
|
+
// return await builder.moveCall(
|
|
167
|
+
return builder.moveCall(
|
|
168
|
+
txBlock,
|
|
153
169
|
`${coreIds.protocolPkg}::redeem::redeem_entry`,
|
|
154
170
|
[coreIds.version, coreIds.market, marketCoin, SUI_CLOCK_OBJECT_ID],
|
|
155
171
|
[coinType]
|
|
@@ -157,7 +173,9 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
157
173
|
},
|
|
158
174
|
borrow: (obligation, obligationKey, amount, poolCoinName) => {
|
|
159
175
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
160
|
-
return
|
|
176
|
+
// return await builder.moveCall(
|
|
177
|
+
return builder.moveCall(
|
|
178
|
+
txBlock,
|
|
161
179
|
`${coreIds.protocolPkg}::borrow::borrow`,
|
|
162
180
|
[
|
|
163
181
|
coreIds.version,
|
|
@@ -180,7 +198,9 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
180
198
|
poolCoinName
|
|
181
199
|
) => {
|
|
182
200
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
183
|
-
return
|
|
201
|
+
// return await builder.moveCall(
|
|
202
|
+
return builder.moveCall(
|
|
203
|
+
txBlock,
|
|
184
204
|
`${coreIds.protocolPkg}::borrow::borrow_with_referral`,
|
|
185
205
|
[
|
|
186
206
|
coreIds.version,
|
|
@@ -198,7 +218,9 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
198
218
|
},
|
|
199
219
|
borrowEntry: (obligation, obligationKey, amount, poolCoinName) => {
|
|
200
220
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
201
|
-
return
|
|
221
|
+
// return await builder.moveCall(
|
|
222
|
+
return builder.moveCall(
|
|
223
|
+
txBlock,
|
|
202
224
|
`${coreIds.protocolPkg}::borrow::borrow_entry`,
|
|
203
225
|
[
|
|
204
226
|
coreIds.version,
|
|
@@ -215,7 +237,8 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
215
237
|
},
|
|
216
238
|
repay: (obligation, coin, poolCoinName) => {
|
|
217
239
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
218
|
-
|
|
240
|
+
builder.moveCall(
|
|
241
|
+
txBlock,
|
|
219
242
|
`${coreIds.protocolPkg}::repay::repay`,
|
|
220
243
|
[
|
|
221
244
|
coreIds.version,
|
|
@@ -229,7 +252,8 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
229
252
|
},
|
|
230
253
|
borrowFlashLoan: (amount, poolCoinName) => {
|
|
231
254
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
232
|
-
return
|
|
255
|
+
return builder.moveCall(
|
|
256
|
+
txBlock,
|
|
233
257
|
`${coreIds.protocolPkg}::flash_loan::borrow_flash_loan`,
|
|
234
258
|
[coreIds.version, coreIds.market, amount],
|
|
235
259
|
[coinType]
|
|
@@ -237,7 +261,8 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
237
261
|
},
|
|
238
262
|
repayFlashLoan: (coin, loan, poolCoinName) => {
|
|
239
263
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
240
|
-
|
|
264
|
+
builder.moveCall(
|
|
265
|
+
txBlock,
|
|
241
266
|
`${coreIds.protocolPkg}::flash_loan::repay_flash_loan`,
|
|
242
267
|
[coreIds.version, coreIds.market, coin, loan],
|
|
243
268
|
[coinType]
|
|
@@ -273,7 +298,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
273
298
|
|
|
274
299
|
if (collateralCoinName === 'sui') {
|
|
275
300
|
const [suiCoin] = txBlock.splitSUIFromGas([amount]);
|
|
276
|
-
txBlock.addCollateral(obligationArg, suiCoin, collateralCoinName);
|
|
301
|
+
await txBlock.addCollateral(obligationArg, suiCoin, collateralCoinName);
|
|
277
302
|
} else {
|
|
278
303
|
const { leftCoin, takeCoin } = await builder.selectCoin(
|
|
279
304
|
txBlock,
|
|
@@ -281,7 +306,11 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
281
306
|
amount,
|
|
282
307
|
sender
|
|
283
308
|
);
|
|
284
|
-
txBlock.addCollateral(
|
|
309
|
+
await txBlock.addCollateral(
|
|
310
|
+
obligationArg,
|
|
311
|
+
takeCoin,
|
|
312
|
+
collateralCoinName
|
|
313
|
+
);
|
|
285
314
|
txBlock.transferObjects([leftCoin], sender);
|
|
286
315
|
}
|
|
287
316
|
},
|
|
@@ -301,7 +330,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
301
330
|
obligationInfo.obligationId
|
|
302
331
|
);
|
|
303
332
|
await updateOracles(builder, txBlock, updateCoinNames);
|
|
304
|
-
return txBlock.takeCollateral(
|
|
333
|
+
return await txBlock.takeCollateral(
|
|
305
334
|
obligationInfo.obligationId,
|
|
306
335
|
obligationInfo.obligationKey as SuiObjectArg,
|
|
307
336
|
amount,
|
|
@@ -313,7 +342,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
313
342
|
let marketCoinDeposit: TransactionResult | undefined;
|
|
314
343
|
if (poolCoinName === 'sui') {
|
|
315
344
|
const [suiCoin] = txBlock.splitSUIFromGas([amount]);
|
|
316
|
-
marketCoinDeposit = txBlock.deposit(suiCoin, poolCoinName);
|
|
345
|
+
marketCoinDeposit = await txBlock.deposit(suiCoin, poolCoinName);
|
|
317
346
|
} else {
|
|
318
347
|
const { leftCoin, takeCoin } = await builder.selectCoin(
|
|
319
348
|
txBlock,
|
|
@@ -322,12 +351,12 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
322
351
|
sender
|
|
323
352
|
);
|
|
324
353
|
txBlock.transferObjects([leftCoin], sender);
|
|
325
|
-
marketCoinDeposit = txBlock.deposit(takeCoin, poolCoinName);
|
|
354
|
+
marketCoinDeposit = await txBlock.deposit(takeCoin, poolCoinName);
|
|
326
355
|
}
|
|
327
356
|
|
|
328
357
|
// convert to sCoin
|
|
329
358
|
return returnSCoin
|
|
330
|
-
? txBlock.mintSCoin(
|
|
359
|
+
? await txBlock.mintSCoin(
|
|
331
360
|
builder.utils.parseMarketCoinName(poolCoinName),
|
|
332
361
|
marketCoinDeposit
|
|
333
362
|
)
|
|
@@ -347,7 +376,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
347
376
|
totalAmount,
|
|
348
377
|
} = await builder.selectSCoin(txBlock, sCoinName, amount, sender);
|
|
349
378
|
txBlock.transferObjects([leftCoin], sender);
|
|
350
|
-
const marketCoins = txBlock.burnSCoin(sCoinName, sCoins);
|
|
379
|
+
const marketCoins = await txBlock.burnSCoin(sCoinName, sCoins);
|
|
351
380
|
|
|
352
381
|
// check amount
|
|
353
382
|
amount -= totalAmount;
|
|
@@ -378,7 +407,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
378
407
|
sender
|
|
379
408
|
);
|
|
380
409
|
txBlock.transferObjects([leftCoin], sender);
|
|
381
|
-
return txBlock.withdraw(walletMarketCoins, poolCoinName);
|
|
410
|
+
return await txBlock.withdraw(walletMarketCoins, poolCoinName);
|
|
382
411
|
}
|
|
383
412
|
},
|
|
384
413
|
borrowQuick: async (amount, poolCoinName, obligationId, obligationKey) => {
|
|
@@ -394,7 +423,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
394
423
|
)) ?? [];
|
|
395
424
|
const updateCoinNames = [...obligationCoinNames, poolCoinName];
|
|
396
425
|
await updateOracles(builder, txBlock, updateCoinNames);
|
|
397
|
-
return txBlock.borrow(
|
|
426
|
+
return await txBlock.borrow(
|
|
398
427
|
obligationInfo.obligationId,
|
|
399
428
|
obligationInfo.obligationKey as SuiObjectArg,
|
|
400
429
|
amount,
|
|
@@ -420,7 +449,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
420
449
|
)) ?? [];
|
|
421
450
|
const updateCoinNames = [...obligationCoinNames, poolCoinName];
|
|
422
451
|
await updateOracles(builder, txBlock, updateCoinNames);
|
|
423
|
-
return txBlock.borrowWithReferral(
|
|
452
|
+
return await txBlock.borrowWithReferral(
|
|
424
453
|
obligationInfo.obligationId,
|
|
425
454
|
obligationInfo.obligationKey as SuiObjectArg,
|
|
426
455
|
borrowReferral,
|
|
@@ -438,7 +467,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
438
467
|
|
|
439
468
|
if (poolCoinName === 'sui') {
|
|
440
469
|
const [suiCoin] = txBlock.splitSUIFromGas([amount]);
|
|
441
|
-
return txBlock.repay(
|
|
470
|
+
return await txBlock.repay(
|
|
442
471
|
obligationInfo.obligationId,
|
|
443
472
|
suiCoin,
|
|
444
473
|
poolCoinName
|
|
@@ -451,7 +480,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
451
480
|
sender
|
|
452
481
|
);
|
|
453
482
|
txBlock.transferObjects([leftCoin], sender);
|
|
454
|
-
return txBlock.repay(
|
|
483
|
+
return await txBlock.repay(
|
|
455
484
|
obligationInfo.obligationId,
|
|
456
485
|
takeCoin,
|
|
457
486
|
poolCoinName
|
|
@@ -459,7 +488,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
459
488
|
}
|
|
460
489
|
},
|
|
461
490
|
updateAssetPricesQuick: async (assetCoinNames) => {
|
|
462
|
-
return updateOracles(builder, txBlock, assetCoinNames);
|
|
491
|
+
return await updateOracles(builder, txBlock, assetCoinNames);
|
|
463
492
|
},
|
|
464
493
|
};
|
|
465
494
|
};
|
|
@@ -24,7 +24,8 @@ const generateLoyaltyProgramNormalMethod: GenerateLoyaltyProgramNormalMethod =
|
|
|
24
24
|
|
|
25
25
|
return {
|
|
26
26
|
claimLoyaltyRevenue: (veScaKey) => {
|
|
27
|
-
return
|
|
27
|
+
return builder.moveCall(
|
|
28
|
+
txBlock,
|
|
28
29
|
`${loyaltyProgramIds.loyaltyProgramPkgId}::reward_pool::redeem_reward`,
|
|
29
30
|
[loyaltyProgramIds.rewardPool, veScaKey]
|
|
30
31
|
);
|
|
@@ -43,7 +44,7 @@ const generateLoyaltyProgramQuickMethod: GenerateLoyaltyProgramQuickMethod = ({
|
|
|
43
44
|
if (!veScaKey) throw new Error(`No veScaKey found for user ${sender}`);
|
|
44
45
|
|
|
45
46
|
// claim the pending reward
|
|
46
|
-
const rewardCoin = txBlock.claimLoyaltyRevenue(veScaKey);
|
|
47
|
+
const rewardCoin = await txBlock.claimLoyaltyRevenue(veScaKey);
|
|
47
48
|
|
|
48
49
|
// get existing sca coin to merge with
|
|
49
50
|
await builder.utils.mergeSimilarCoins(
|
|
@@ -35,7 +35,8 @@ const generateReferralNormalMethod: GenerateReferralNormalMethod = ({
|
|
|
35
35
|
|
|
36
36
|
return {
|
|
37
37
|
bindToReferral: (veScaKeyId: string) => {
|
|
38
|
-
|
|
38
|
+
builder.moveCall(
|
|
39
|
+
txBlock,
|
|
39
40
|
`${referralIds.referralPgkId}::referral_bindings::bind_ve_sca_referrer`,
|
|
40
41
|
[
|
|
41
42
|
referralIds.referralBindings,
|
|
@@ -48,7 +49,8 @@ const generateReferralNormalMethod: GenerateReferralNormalMethod = ({
|
|
|
48
49
|
},
|
|
49
50
|
claimReferralTicket: (poolCoinName: SupportCoins) => {
|
|
50
51
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
51
|
-
return
|
|
52
|
+
return builder.moveCall(
|
|
53
|
+
txBlock,
|
|
52
54
|
`${referralIds.referralPgkId}::scallop_referral_program::claim_ve_sca_referral_ticket`,
|
|
53
55
|
[
|
|
54
56
|
referralIds.version,
|
|
@@ -63,7 +65,8 @@ const generateReferralNormalMethod: GenerateReferralNormalMethod = ({
|
|
|
63
65
|
},
|
|
64
66
|
burnReferralTicket: (ticket: SuiObjectArg, poolCoinName: SupportCoins) => {
|
|
65
67
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
66
|
-
|
|
68
|
+
builder.moveCall(
|
|
69
|
+
txBlock,
|
|
67
70
|
`${referralIds.referralPgkId}::scallop_referral_program::burn_ve_sca_referral_ticket`,
|
|
68
71
|
[
|
|
69
72
|
referralIds.version,
|
|
@@ -79,7 +82,8 @@ const generateReferralNormalMethod: GenerateReferralNormalMethod = ({
|
|
|
79
82
|
poolCoinName: SupportCoins
|
|
80
83
|
) => {
|
|
81
84
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
82
|
-
return
|
|
85
|
+
return builder.moveCall(
|
|
86
|
+
txBlock,
|
|
83
87
|
`${referralIds.referralPgkId}::referral_revenue_pool::claim_revenue_with_ve_sca_key`,
|
|
84
88
|
[
|
|
85
89
|
referralIds.version,
|
|
@@ -106,10 +110,16 @@ const generateReferralQuickMethod: GenerateReferralQuickMethod = ({
|
|
|
106
110
|
const objToTransfer: SuiObjectArg[] = [];
|
|
107
111
|
for (const coinName of coinNames) {
|
|
108
112
|
if (coinName === 'sui') {
|
|
109
|
-
const rewardCoin = txBlock.claimReferralRevenue(
|
|
113
|
+
const rewardCoin = await txBlock.claimReferralRevenue(
|
|
114
|
+
veScaKey,
|
|
115
|
+
coinName
|
|
116
|
+
);
|
|
110
117
|
objToTransfer.push(rewardCoin);
|
|
111
118
|
} else {
|
|
112
|
-
const rewardCoin = txBlock.claimReferralRevenue(
|
|
119
|
+
const rewardCoin = await txBlock.claimReferralRevenue(
|
|
120
|
+
veScaKey,
|
|
121
|
+
coinName
|
|
122
|
+
);
|
|
113
123
|
try {
|
|
114
124
|
// get the matching user coin if exists
|
|
115
125
|
const coins = await builder.suiKit.suiInteractor.selectCoins(
|
|
@@ -21,7 +21,8 @@ const generateSCoinNormalMethod: GenerateSCoinNormalMethod = ({
|
|
|
21
21
|
|
|
22
22
|
return {
|
|
23
23
|
mintSCoin: (marketCoinName, marketCoin) => {
|
|
24
|
-
return
|
|
24
|
+
return builder.moveCall(
|
|
25
|
+
txBlock,
|
|
25
26
|
`${sCoinPkgIds.pkgId}::s_coin_converter::mint_s_coin`,
|
|
26
27
|
[builder.utils.getSCoinTreasury(marketCoinName), marketCoin],
|
|
27
28
|
[
|
|
@@ -31,7 +32,8 @@ const generateSCoinNormalMethod: GenerateSCoinNormalMethod = ({
|
|
|
31
32
|
);
|
|
32
33
|
},
|
|
33
34
|
burnSCoin: (sCoinName, sCoin) => {
|
|
34
|
-
return
|
|
35
|
+
return builder.moveCall(
|
|
36
|
+
txBlock,
|
|
35
37
|
`${sCoinPkgIds.pkgId}::s_coin_converter::burn_s_coin`,
|
|
36
38
|
[builder.utils.getSCoinTreasury(sCoinName), sCoin],
|
|
37
39
|
[
|
|
@@ -58,7 +60,7 @@ const generateSCoinQuickMethod: GenerateSCoinQuickMethod = ({
|
|
|
58
60
|
);
|
|
59
61
|
|
|
60
62
|
txBlock.transferObjects([leftCoin], sender);
|
|
61
|
-
return txBlock.mintSCoin(marketCoinName, takeCoin);
|
|
63
|
+
return await txBlock.mintSCoin(marketCoinName, takeCoin);
|
|
62
64
|
},
|
|
63
65
|
burnSCoinQuick: async (sCoinName, amount) => {
|
|
64
66
|
const sender = requireSender(txBlock);
|
|
@@ -70,7 +72,7 @@ const generateSCoinQuickMethod: GenerateSCoinQuickMethod = ({
|
|
|
70
72
|
);
|
|
71
73
|
|
|
72
74
|
txBlock.transferObjects([leftCoin], sender);
|
|
73
|
-
return txBlock.burnSCoin(sCoinName, takeCoin);
|
|
75
|
+
return await txBlock.burnSCoin(sCoinName, takeCoin);
|
|
74
76
|
},
|
|
75
77
|
};
|
|
76
78
|
};
|
|
@@ -133,7 +133,8 @@ const generateSpoolNormalMethod: GenerateSpoolNormalMethod = ({
|
|
|
133
133
|
const stakePoolId = builder.address.get(
|
|
134
134
|
`spool.pools.${stakeMarketCoinName}.id`
|
|
135
135
|
);
|
|
136
|
-
return
|
|
136
|
+
return builder.moveCall(
|
|
137
|
+
txBlock,
|
|
137
138
|
`${spoolIds.spoolPkg}::user::new_spool_account`,
|
|
138
139
|
[stakePoolId, SUI_CLOCK_OBJECT_ID],
|
|
139
140
|
[marketCoinType]
|
|
@@ -145,7 +146,8 @@ const generateSpoolNormalMethod: GenerateSpoolNormalMethod = ({
|
|
|
145
146
|
const stakePoolId = builder.address.get(
|
|
146
147
|
`spool.pools.${stakeMarketCoinName}.id`
|
|
147
148
|
);
|
|
148
|
-
|
|
149
|
+
builder.moveCall(
|
|
150
|
+
txBlock,
|
|
149
151
|
`${spoolIds.spoolPkg}::user::stake`,
|
|
150
152
|
[stakePoolId, stakeAccount, coin, SUI_CLOCK_OBJECT_ID],
|
|
151
153
|
[marketCoinType]
|
|
@@ -157,7 +159,8 @@ const generateSpoolNormalMethod: GenerateSpoolNormalMethod = ({
|
|
|
157
159
|
const stakePoolId = builder.address.get(
|
|
158
160
|
`spool.pools.${stakeMarketCoinName}.id`
|
|
159
161
|
);
|
|
160
|
-
return
|
|
162
|
+
return builder.moveCall(
|
|
163
|
+
txBlock,
|
|
161
164
|
`${spoolIds.spoolPkg}::user::unstake`,
|
|
162
165
|
[stakePoolId, stakeAccount, amount, SUI_CLOCK_OBJECT_ID],
|
|
163
166
|
[marketCoinType]
|
|
@@ -174,7 +177,8 @@ const generateSpoolNormalMethod: GenerateSpoolNormalMethod = ({
|
|
|
174
177
|
builder.utils.parseMarketCoinType(stakeMarketCoinName);
|
|
175
178
|
const rewardCoinName = spoolRewardCoins[stakeMarketCoinName];
|
|
176
179
|
const rewardCoinType = builder.utils.parseCoinType(rewardCoinName);
|
|
177
|
-
return
|
|
180
|
+
return builder.moveCall(
|
|
181
|
+
txBlock,
|
|
178
182
|
`${spoolIds.spoolPkg}::user::redeem_rewards`,
|
|
179
183
|
[stakePoolId, rewardPoolId, stakeAccount, SUI_CLOCK_OBJECT_ID],
|
|
180
184
|
[marketCoinType, rewardCoinType]
|
|
@@ -265,7 +269,7 @@ const generateSpoolQuickMethod: GenerateSpoolQuickMethod = ({
|
|
|
265
269
|
for (const account of stakeAccounts) {
|
|
266
270
|
if (account.staked === 0) continue;
|
|
267
271
|
const amountToUnstake = Math.min(amount, account.staked);
|
|
268
|
-
const marketCoin = txBlock.unstake(
|
|
272
|
+
const marketCoin = await txBlock.unstake(
|
|
269
273
|
account.id,
|
|
270
274
|
amountToUnstake,
|
|
271
275
|
stakeMarketCoinName
|
|
@@ -273,7 +277,10 @@ const generateSpoolQuickMethod: GenerateSpoolQuickMethod = ({
|
|
|
273
277
|
|
|
274
278
|
// convert to new sCoin
|
|
275
279
|
if (returnSCoin) {
|
|
276
|
-
const sCoin = txBlock.mintSCoin(
|
|
280
|
+
const sCoin = await txBlock.mintSCoin(
|
|
281
|
+
stakeMarketCoinName,
|
|
282
|
+
marketCoin
|
|
283
|
+
);
|
|
277
284
|
toTransfer.push(sCoin);
|
|
278
285
|
} else {
|
|
279
286
|
toTransfer.push(marketCoin);
|
|
@@ -301,7 +308,7 @@ const generateSpoolQuickMethod: GenerateSpoolQuickMethod = ({
|
|
|
301
308
|
);
|
|
302
309
|
const rewardCoins: TransactionResult[] = [];
|
|
303
310
|
for (const accountId of stakeAccountIds) {
|
|
304
|
-
const rewardCoin = txBlock.claim(accountId, stakeMarketCoinName);
|
|
311
|
+
const rewardCoin = await txBlock.claim(accountId, stakeMarketCoinName);
|
|
305
312
|
rewardCoins.push(rewardCoin);
|
|
306
313
|
}
|
|
307
314
|
return rewardCoins;
|