@scallop-io/sui-scallop-sdk 1.4.27 → 1.5.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.
- package/dist/index.d.mts +30 -2
- package/dist/index.d.ts +30 -2
- package/dist/index.js +53 -52
- package/dist/index.mjs +7 -7
- package/package.json +1 -1
- package/src/builders/borrowIncentiveBuilder.ts +11 -25
- package/src/builders/coreBuilder.ts +15 -72
- package/src/builders/oracle.ts +73 -46
- package/src/builders/referralBuilder.ts +9 -20
- package/src/builders/spoolBuilder.ts +10 -38
- package/src/builders/vescaBuilder.ts +11 -26
- package/src/constants/enum.ts +10 -5
- package/src/constants/index.ts +1 -0
- package/src/constants/poolAddress.ts +343 -184
- package/src/constants/testAddress.ts +79 -287
- package/src/constants/xoracle.ts +28 -0
- package/src/models/scallopPrice.ts +0 -0
- package/src/models/scallopQuery.ts +41 -8
- package/src/models/scallopUtils.ts +1 -1
- package/src/queries/coreQuery.ts +16 -6
- package/src/queries/index.ts +1 -0
- package/src/queries/vescaQuery.ts +8 -17
- package/src/queries/xOracleQuery.ts +124 -0
- package/src/types/address.ts +1 -0
- package/src/types/constant/index.ts +1 -0
- package/src/types/constant/xOracle.ts +11 -0
- package/src/utils/util.ts +1 -1
package/package.json
CHANGED
|
@@ -98,6 +98,12 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
|
|
|
98
98
|
config: builder.address.get('vesca.config'),
|
|
99
99
|
};
|
|
100
100
|
|
|
101
|
+
const clockObjectRef = txBlock.sharedObjectRef({
|
|
102
|
+
objectId: SUI_CLOCK_OBJECT_ID,
|
|
103
|
+
mutable: false,
|
|
104
|
+
initialSharedVersion: '1',
|
|
105
|
+
});
|
|
106
|
+
|
|
101
107
|
return {
|
|
102
108
|
stakeObligation: (obligationId, obligationKey) => {
|
|
103
109
|
builder.moveCall(
|
|
@@ -110,11 +116,7 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
|
|
|
110
116
|
obligationKey,
|
|
111
117
|
obligationId,
|
|
112
118
|
borrowIncentiveIds.obligationAccessStore,
|
|
113
|
-
|
|
114
|
-
objectId: SUI_CLOCK_OBJECT_ID,
|
|
115
|
-
mutable: false,
|
|
116
|
-
initialSharedVersion: '1',
|
|
117
|
-
}),
|
|
119
|
+
clockObjectRef,
|
|
118
120
|
]
|
|
119
121
|
);
|
|
120
122
|
},
|
|
@@ -133,11 +135,7 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
|
|
|
133
135
|
veScaIds.treasury,
|
|
134
136
|
veScaIds.table,
|
|
135
137
|
veScaKey,
|
|
136
|
-
|
|
137
|
-
objectId: SUI_CLOCK_OBJECT_ID,
|
|
138
|
-
mutable: false,
|
|
139
|
-
initialSharedVersion: '1',
|
|
140
|
-
}),
|
|
138
|
+
clockObjectRef,
|
|
141
139
|
],
|
|
142
140
|
[]
|
|
143
141
|
);
|
|
@@ -152,11 +150,7 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
|
|
|
152
150
|
borrowIncentiveIds.incentiveAccounts,
|
|
153
151
|
obligationKey,
|
|
154
152
|
obligationId,
|
|
155
|
-
|
|
156
|
-
objectId: SUI_CLOCK_OBJECT_ID,
|
|
157
|
-
mutable: false,
|
|
158
|
-
initialSharedVersion: '1',
|
|
159
|
-
}),
|
|
153
|
+
clockObjectRef,
|
|
160
154
|
]
|
|
161
155
|
);
|
|
162
156
|
},
|
|
@@ -171,11 +165,7 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
|
|
|
171
165
|
borrowIncentiveIds.incentiveAccounts,
|
|
172
166
|
obligationKey,
|
|
173
167
|
obligationId,
|
|
174
|
-
|
|
175
|
-
objectId: SUI_CLOCK_OBJECT_ID,
|
|
176
|
-
mutable: false,
|
|
177
|
-
initialSharedVersion: '1',
|
|
178
|
-
}),
|
|
168
|
+
clockObjectRef,
|
|
179
169
|
],
|
|
180
170
|
[rewardType]
|
|
181
171
|
);
|
|
@@ -190,11 +180,7 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
|
|
|
190
180
|
borrowIncentiveIds.incentiveAccounts,
|
|
191
181
|
obligation,
|
|
192
182
|
veScaKey,
|
|
193
|
-
|
|
194
|
-
objectId: SUI_CLOCK_OBJECT_ID,
|
|
195
|
-
mutable: false,
|
|
196
|
-
initialSharedVersion: '1',
|
|
197
|
-
}),
|
|
183
|
+
clockObjectRef,
|
|
198
184
|
]
|
|
199
185
|
);
|
|
200
186
|
},
|
|
@@ -75,6 +75,11 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
75
75
|
|
|
76
76
|
const referralPkgId = builder.address.get('referral.id');
|
|
77
77
|
const referralWitnessType = `${referralPkgId}::scallop_referral_program::REFERRAL_WITNESS`;
|
|
78
|
+
const clockObjectRef = txBlock.sharedObjectRef({
|
|
79
|
+
objectId: SUI_CLOCK_OBJECT_ID,
|
|
80
|
+
mutable: false,
|
|
81
|
+
initialSharedVersion: '1',
|
|
82
|
+
});
|
|
78
83
|
|
|
79
84
|
return {
|
|
80
85
|
openObligation: () => {
|
|
@@ -126,11 +131,7 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
126
131
|
coreIds.coinDecimalsRegistry,
|
|
127
132
|
txBlock.pure.u64(amount),
|
|
128
133
|
coreIds.xOracle,
|
|
129
|
-
|
|
130
|
-
objectId: SUI_CLOCK_OBJECT_ID,
|
|
131
|
-
mutable: false,
|
|
132
|
-
initialSharedVersion: '1',
|
|
133
|
-
}),
|
|
134
|
+
clockObjectRef,
|
|
134
135
|
],
|
|
135
136
|
[coinType]
|
|
136
137
|
);
|
|
@@ -141,16 +142,7 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
141
142
|
return builder.moveCall(
|
|
142
143
|
txBlock,
|
|
143
144
|
`${coreIds.protocolPkg}::mint::mint`,
|
|
144
|
-
[
|
|
145
|
-
coreIds.version,
|
|
146
|
-
coreIds.market,
|
|
147
|
-
coin,
|
|
148
|
-
txBlock.sharedObjectRef({
|
|
149
|
-
objectId: SUI_CLOCK_OBJECT_ID,
|
|
150
|
-
mutable: false,
|
|
151
|
-
initialSharedVersion: '1',
|
|
152
|
-
}),
|
|
153
|
-
],
|
|
145
|
+
[coreIds.version, coreIds.market, coin, clockObjectRef],
|
|
154
146
|
[coinType]
|
|
155
147
|
);
|
|
156
148
|
},
|
|
@@ -160,16 +152,7 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
160
152
|
return builder.moveCall(
|
|
161
153
|
txBlock,
|
|
162
154
|
`${coreIds.protocolPkg}::mint::mint_entry`,
|
|
163
|
-
[
|
|
164
|
-
coreIds.version,
|
|
165
|
-
coreIds.market,
|
|
166
|
-
coin,
|
|
167
|
-
txBlock.sharedObjectRef({
|
|
168
|
-
objectId: SUI_CLOCK_OBJECT_ID,
|
|
169
|
-
mutable: false,
|
|
170
|
-
initialSharedVersion: '1',
|
|
171
|
-
}),
|
|
172
|
-
],
|
|
155
|
+
[coreIds.version, coreIds.market, coin, clockObjectRef],
|
|
173
156
|
[coinType]
|
|
174
157
|
);
|
|
175
158
|
},
|
|
@@ -179,16 +162,7 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
179
162
|
return builder.moveCall(
|
|
180
163
|
txBlock,
|
|
181
164
|
`${coreIds.protocolPkg}::redeem::redeem`,
|
|
182
|
-
[
|
|
183
|
-
coreIds.version,
|
|
184
|
-
coreIds.market,
|
|
185
|
-
marketCoin,
|
|
186
|
-
txBlock.sharedObjectRef({
|
|
187
|
-
objectId: SUI_CLOCK_OBJECT_ID,
|
|
188
|
-
mutable: false,
|
|
189
|
-
initialSharedVersion: '1',
|
|
190
|
-
}),
|
|
191
|
-
],
|
|
165
|
+
[coreIds.version, coreIds.market, marketCoin, clockObjectRef],
|
|
192
166
|
[coinType]
|
|
193
167
|
);
|
|
194
168
|
},
|
|
@@ -198,16 +172,7 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
198
172
|
return builder.moveCall(
|
|
199
173
|
txBlock,
|
|
200
174
|
`${coreIds.protocolPkg}::redeem::redeem_entry`,
|
|
201
|
-
[
|
|
202
|
-
coreIds.version,
|
|
203
|
-
coreIds.market,
|
|
204
|
-
marketCoin,
|
|
205
|
-
txBlock.sharedObjectRef({
|
|
206
|
-
objectId: SUI_CLOCK_OBJECT_ID,
|
|
207
|
-
mutable: false,
|
|
208
|
-
initialSharedVersion: '1',
|
|
209
|
-
}),
|
|
210
|
-
],
|
|
175
|
+
[coreIds.version, coreIds.market, marketCoin, clockObjectRef],
|
|
211
176
|
[coinType]
|
|
212
177
|
);
|
|
213
178
|
},
|
|
@@ -225,11 +190,7 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
225
190
|
coreIds.coinDecimalsRegistry,
|
|
226
191
|
amount,
|
|
227
192
|
coreIds.xOracle,
|
|
228
|
-
|
|
229
|
-
objectId: SUI_CLOCK_OBJECT_ID,
|
|
230
|
-
mutable: false,
|
|
231
|
-
initialSharedVersion: '1',
|
|
232
|
-
}),
|
|
193
|
+
clockObjectRef,
|
|
233
194
|
],
|
|
234
195
|
[coinType]
|
|
235
196
|
);
|
|
@@ -255,11 +216,7 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
255
216
|
borrowReferral,
|
|
256
217
|
typeof amount === 'number' ? txBlock.pure.u64(amount) : amount,
|
|
257
218
|
coreIds.xOracle,
|
|
258
|
-
|
|
259
|
-
objectId: SUI_CLOCK_OBJECT_ID,
|
|
260
|
-
mutable: false,
|
|
261
|
-
initialSharedVersion: '1',
|
|
262
|
-
}),
|
|
219
|
+
clockObjectRef,
|
|
263
220
|
],
|
|
264
221
|
[coinType, referralWitnessType]
|
|
265
222
|
);
|
|
@@ -278,11 +235,7 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
278
235
|
coreIds.coinDecimalsRegistry,
|
|
279
236
|
txBlock.pure.u64(amount),
|
|
280
237
|
coreIds.xOracle,
|
|
281
|
-
|
|
282
|
-
objectId: SUI_CLOCK_OBJECT_ID,
|
|
283
|
-
mutable: false,
|
|
284
|
-
initialSharedVersion: '1',
|
|
285
|
-
}),
|
|
238
|
+
clockObjectRef,
|
|
286
239
|
],
|
|
287
240
|
[coinType]
|
|
288
241
|
);
|
|
@@ -292,17 +245,7 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
292
245
|
builder.moveCall(
|
|
293
246
|
txBlock,
|
|
294
247
|
`${coreIds.protocolPkg}::repay::repay`,
|
|
295
|
-
[
|
|
296
|
-
coreIds.version,
|
|
297
|
-
obligation,
|
|
298
|
-
coreIds.market,
|
|
299
|
-
coin,
|
|
300
|
-
txBlock.sharedObjectRef({
|
|
301
|
-
objectId: SUI_CLOCK_OBJECT_ID,
|
|
302
|
-
mutable: false,
|
|
303
|
-
initialSharedVersion: '1',
|
|
304
|
-
}),
|
|
305
|
-
],
|
|
248
|
+
[coreIds.version, obligation, coreIds.market, coin, clockObjectRef],
|
|
306
249
|
[coinType]
|
|
307
250
|
);
|
|
308
251
|
},
|
|
@@ -479,7 +422,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
479
422
|
)) ?? [];
|
|
480
423
|
const updateCoinNames = [...obligationCoinNames, poolCoinName];
|
|
481
424
|
await updateOracles(builder, txBlock, updateCoinNames);
|
|
482
|
-
return
|
|
425
|
+
return txBlock.borrow(
|
|
483
426
|
obligationInfo.obligationId,
|
|
484
427
|
obligationInfo.obligationKey as SuiObjectArg,
|
|
485
428
|
amount,
|
package/src/builders/oracle.ts
CHANGED
|
@@ -7,8 +7,14 @@ import { SUPPORT_COLLATERALS, SUPPORT_POOLS } from '../constants';
|
|
|
7
7
|
import type { TransactionArgument } from '@mysten/sui/transactions';
|
|
8
8
|
import type { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
9
9
|
import type { ScallopBuilder } from '../models';
|
|
10
|
-
import type {
|
|
10
|
+
import type {
|
|
11
|
+
SupportAssetCoins,
|
|
12
|
+
SupportOracleType,
|
|
13
|
+
xOracleRules,
|
|
14
|
+
xOracleRuleType,
|
|
15
|
+
} from '../types';
|
|
11
16
|
import { PYTH_ENDPOINTS } from 'src/constants/pyth';
|
|
17
|
+
import { xOracleList } from 'src/constants';
|
|
12
18
|
|
|
13
19
|
/**
|
|
14
20
|
* Update the price of the oracle for multiple coin.
|
|
@@ -21,18 +27,26 @@ import { PYTH_ENDPOINTS } from 'src/constants/pyth';
|
|
|
21
27
|
export const updateOracles = async (
|
|
22
28
|
builder: ScallopBuilder,
|
|
23
29
|
txBlock: SuiKitTxBlock,
|
|
24
|
-
assetCoinNames
|
|
30
|
+
assetCoinNames: SupportAssetCoins[] = [
|
|
31
|
+
...new Set([...SUPPORT_POOLS, ...SUPPORT_COLLATERALS]),
|
|
32
|
+
],
|
|
25
33
|
options: {
|
|
26
34
|
usePythPullModel: boolean;
|
|
27
35
|
} = { usePythPullModel: true }
|
|
28
36
|
) => {
|
|
29
37
|
const usePythPullModel =
|
|
30
38
|
builder.params.usePythPullModel ?? options.usePythPullModel;
|
|
31
|
-
|
|
32
|
-
|
|
39
|
+
// const rules: SupportOracleType[] = builder.isTestnet ? ['pyth'] : ['pyth'];
|
|
40
|
+
const flattenedRules: SupportOracleType[] = [
|
|
41
|
+
...new Set(
|
|
42
|
+
Object.values(xOracleList).flatMap(({ primary, secondary }) => [
|
|
43
|
+
...primary,
|
|
44
|
+
...secondary,
|
|
45
|
+
])
|
|
46
|
+
),
|
|
33
47
|
];
|
|
34
|
-
|
|
35
|
-
if (
|
|
48
|
+
|
|
49
|
+
if (flattenedRules.includes('pyth') && usePythPullModel) {
|
|
36
50
|
const pythClient = new SuiPythClient(
|
|
37
51
|
builder.suiKit.client(),
|
|
38
52
|
builder.address.get('core.oracles.pyth.state'),
|
|
@@ -69,7 +83,12 @@ export const updateOracles = async (
|
|
|
69
83
|
// Remove duplicate coin names.
|
|
70
84
|
const updateAssetCoinNames = [...new Set(assetCoinNames)];
|
|
71
85
|
for (const assetCoinName of updateAssetCoinNames) {
|
|
72
|
-
await updateOracle(
|
|
86
|
+
await updateOracle(
|
|
87
|
+
builder,
|
|
88
|
+
txBlock,
|
|
89
|
+
assetCoinName,
|
|
90
|
+
xOracleList[assetCoinName]
|
|
91
|
+
);
|
|
73
92
|
}
|
|
74
93
|
};
|
|
75
94
|
|
|
@@ -84,7 +103,7 @@ const updateOracle = async (
|
|
|
84
103
|
builder: ScallopBuilder,
|
|
85
104
|
txBlock: SuiKitTxBlock,
|
|
86
105
|
assetCoinName: SupportAssetCoins,
|
|
87
|
-
rules:
|
|
106
|
+
rules: xOracleRules
|
|
88
107
|
) => {
|
|
89
108
|
const coinType = builder.utils.parseCoinType(assetCoinName);
|
|
90
109
|
|
|
@@ -129,7 +148,7 @@ const updateOracle = async (
|
|
|
129
148
|
*/
|
|
130
149
|
const updatePrice = (
|
|
131
150
|
txBlock: SuiKitTxBlock,
|
|
132
|
-
rules:
|
|
151
|
+
rules: xOracleRules,
|
|
133
152
|
xOraclePackageId: string,
|
|
134
153
|
xOracleId: TransactionArgument | string,
|
|
135
154
|
pythPackageId: string,
|
|
@@ -150,37 +169,42 @@ const updatePrice = (
|
|
|
150
169
|
xOracleId,
|
|
151
170
|
coinType
|
|
152
171
|
);
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
172
|
+
Object.entries(rules).forEach(([type, rule]: [any, SupportOracleType[]]) => {
|
|
173
|
+
if (rule.includes('pyth')) {
|
|
174
|
+
updatePythPrice(
|
|
175
|
+
type,
|
|
176
|
+
txBlock,
|
|
177
|
+
pythPackageId,
|
|
178
|
+
request,
|
|
179
|
+
pythStateId,
|
|
180
|
+
pythFeedObjectId,
|
|
181
|
+
pythRegistryId,
|
|
182
|
+
coinType
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
if (rule.includes('supra')) {
|
|
186
|
+
updateSupraPrice(
|
|
187
|
+
type,
|
|
188
|
+
txBlock,
|
|
189
|
+
supraPackageId,
|
|
190
|
+
request,
|
|
191
|
+
supraHolderId,
|
|
192
|
+
supraRegistryId,
|
|
193
|
+
coinType
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
if (rule.includes('switchboard')) {
|
|
197
|
+
updateSwitchboardPrice(
|
|
198
|
+
type,
|
|
199
|
+
txBlock,
|
|
200
|
+
switchboardPackageId,
|
|
201
|
+
request,
|
|
202
|
+
switchboardAggregatorId,
|
|
203
|
+
switchboardRegistryId,
|
|
204
|
+
coinType
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
184
208
|
|
|
185
209
|
confirmPriceUpdateRequest(
|
|
186
210
|
txBlock,
|
|
@@ -260,6 +284,7 @@ const confirmPriceUpdateRequest = (
|
|
|
260
284
|
* @return TxBlock created by SuiKit.
|
|
261
285
|
*/
|
|
262
286
|
const updateSupraPrice = (
|
|
287
|
+
type: xOracleRuleType,
|
|
263
288
|
txBlock: SuiKitTxBlock,
|
|
264
289
|
packageId: string,
|
|
265
290
|
request: TransactionArgument,
|
|
@@ -268,15 +293,15 @@ const updateSupraPrice = (
|
|
|
268
293
|
coinType: string
|
|
269
294
|
) => {
|
|
270
295
|
txBlock.moveCall(
|
|
271
|
-
`${packageId}::rule::
|
|
296
|
+
`${packageId}::rule::set_price_as_${type}`,
|
|
272
297
|
[
|
|
273
298
|
request,
|
|
274
299
|
holderId,
|
|
275
300
|
registryId,
|
|
276
301
|
txBlock.sharedObjectRef({
|
|
277
302
|
objectId: SUI_CLOCK_OBJECT_ID,
|
|
278
|
-
mutable: false,
|
|
279
303
|
initialSharedVersion: '1',
|
|
304
|
+
mutable: false,
|
|
280
305
|
}),
|
|
281
306
|
],
|
|
282
307
|
[coinType]
|
|
@@ -296,6 +321,7 @@ const updateSupraPrice = (
|
|
|
296
321
|
* @return TxBlock created by SuiKit.
|
|
297
322
|
*/
|
|
298
323
|
const updateSwitchboardPrice = (
|
|
324
|
+
type: xOracleRuleType,
|
|
299
325
|
txBlock: SuiKitTxBlock,
|
|
300
326
|
packageId: string,
|
|
301
327
|
request: TransactionArgument,
|
|
@@ -304,15 +330,15 @@ const updateSwitchboardPrice = (
|
|
|
304
330
|
coinType: string
|
|
305
331
|
) => {
|
|
306
332
|
txBlock.moveCall(
|
|
307
|
-
`${packageId}::rule::
|
|
333
|
+
`${packageId}::rule::set_price_as_${type}`,
|
|
308
334
|
[
|
|
309
335
|
request,
|
|
310
336
|
aggregatorId,
|
|
311
337
|
registryId,
|
|
312
338
|
txBlock.sharedObjectRef({
|
|
313
339
|
objectId: SUI_CLOCK_OBJECT_ID,
|
|
314
|
-
mutable: false,
|
|
315
340
|
initialSharedVersion: '1',
|
|
341
|
+
mutable: false,
|
|
316
342
|
}),
|
|
317
343
|
],
|
|
318
344
|
[coinType]
|
|
@@ -335,6 +361,7 @@ const updateSwitchboardPrice = (
|
|
|
335
361
|
* @return TxBlock created by SuiKit.
|
|
336
362
|
*/
|
|
337
363
|
const updatePythPrice = (
|
|
364
|
+
type: xOracleRuleType,
|
|
338
365
|
txBlock: SuiKitTxBlock,
|
|
339
366
|
packageId: string,
|
|
340
367
|
request: TransactionArgument,
|
|
@@ -344,7 +371,7 @@ const updatePythPrice = (
|
|
|
344
371
|
coinType: string
|
|
345
372
|
) => {
|
|
346
373
|
txBlock.moveCall(
|
|
347
|
-
`${packageId}::rule::
|
|
374
|
+
`${packageId}::rule::set_price_as_${type}`,
|
|
348
375
|
[
|
|
349
376
|
request,
|
|
350
377
|
stateId,
|
|
@@ -352,8 +379,8 @@ const updatePythPrice = (
|
|
|
352
379
|
registryId,
|
|
353
380
|
txBlock.sharedObjectRef({
|
|
354
381
|
objectId: SUI_CLOCK_OBJECT_ID,
|
|
355
|
-
mutable: false,
|
|
356
382
|
initialSharedVersion: '1',
|
|
383
|
+
mutable: false,
|
|
357
384
|
}),
|
|
358
385
|
],
|
|
359
386
|
[coinType]
|
|
@@ -32,6 +32,11 @@ const generateReferralNormalMethod: GenerateReferralNormalMethod = ({
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
const veScaTable = builder.address.get('vesca.table');
|
|
35
|
+
const clockObjectRef = txBlock.sharedObjectRef({
|
|
36
|
+
objectId: SUI_CLOCK_OBJECT_ID,
|
|
37
|
+
mutable: false,
|
|
38
|
+
initialSharedVersion: '1',
|
|
39
|
+
});
|
|
35
40
|
|
|
36
41
|
return {
|
|
37
42
|
bindToReferral: (veScaKeyId: string) => {
|
|
@@ -42,11 +47,7 @@ const generateReferralNormalMethod: GenerateReferralNormalMethod = ({
|
|
|
42
47
|
referralIds.referralBindings,
|
|
43
48
|
txBlock.pure.id(veScaKeyId),
|
|
44
49
|
veScaTable,
|
|
45
|
-
|
|
46
|
-
objectId: SUI_CLOCK_OBJECT_ID,
|
|
47
|
-
mutable: false,
|
|
48
|
-
initialSharedVersion: '1',
|
|
49
|
-
}),
|
|
50
|
+
clockObjectRef,
|
|
50
51
|
],
|
|
51
52
|
[]
|
|
52
53
|
);
|
|
@@ -62,11 +63,7 @@ const generateReferralNormalMethod: GenerateReferralNormalMethod = ({
|
|
|
62
63
|
referralIds.referralBindings,
|
|
63
64
|
referralIds.authorizedWitnessList,
|
|
64
65
|
referralIds.referralTiers,
|
|
65
|
-
|
|
66
|
-
objectId: SUI_CLOCK_OBJECT_ID,
|
|
67
|
-
mutable: false,
|
|
68
|
-
initialSharedVersion: '1',
|
|
69
|
-
}),
|
|
66
|
+
clockObjectRef,
|
|
70
67
|
],
|
|
71
68
|
[coinType]
|
|
72
69
|
);
|
|
@@ -80,11 +77,7 @@ const generateReferralNormalMethod: GenerateReferralNormalMethod = ({
|
|
|
80
77
|
referralIds.version,
|
|
81
78
|
ticket,
|
|
82
79
|
referralIds.referralRevenuePool,
|
|
83
|
-
|
|
84
|
-
objectId: SUI_CLOCK_OBJECT_ID,
|
|
85
|
-
mutable: false,
|
|
86
|
-
initialSharedVersion: '1',
|
|
87
|
-
}),
|
|
80
|
+
clockObjectRef,
|
|
88
81
|
],
|
|
89
82
|
[coinType]
|
|
90
83
|
);
|
|
@@ -101,11 +94,7 @@ const generateReferralNormalMethod: GenerateReferralNormalMethod = ({
|
|
|
101
94
|
referralIds.version,
|
|
102
95
|
referralIds.referralRevenuePool,
|
|
103
96
|
veScaKey,
|
|
104
|
-
|
|
105
|
-
objectId: SUI_CLOCK_OBJECT_ID,
|
|
106
|
-
mutable: false,
|
|
107
|
-
initialSharedVersion: '1',
|
|
108
|
-
}),
|
|
97
|
+
clockObjectRef,
|
|
109
98
|
],
|
|
110
99
|
[coinType]
|
|
111
100
|
);
|
|
@@ -126,6 +126,12 @@ const generateSpoolNormalMethod: GenerateSpoolNormalMethod = ({
|
|
|
126
126
|
const spoolIds: SpoolIds = {
|
|
127
127
|
spoolPkg: builder.address.get('spool.id'),
|
|
128
128
|
};
|
|
129
|
+
const clockObjectRef = txBlock.sharedObjectRef({
|
|
130
|
+
objectId: SUI_CLOCK_OBJECT_ID,
|
|
131
|
+
mutable: false,
|
|
132
|
+
initialSharedVersion: '1',
|
|
133
|
+
});
|
|
134
|
+
|
|
129
135
|
return {
|
|
130
136
|
createStakeAccount: (stakeMarketCoinName) => {
|
|
131
137
|
const marketCoinType =
|
|
@@ -136,14 +142,7 @@ const generateSpoolNormalMethod: GenerateSpoolNormalMethod = ({
|
|
|
136
142
|
return builder.moveCall(
|
|
137
143
|
txBlock,
|
|
138
144
|
`${spoolIds.spoolPkg}::user::new_spool_account`,
|
|
139
|
-
[
|
|
140
|
-
stakePoolId,
|
|
141
|
-
txBlock.sharedObjectRef({
|
|
142
|
-
objectId: SUI_CLOCK_OBJECT_ID,
|
|
143
|
-
mutable: false,
|
|
144
|
-
initialSharedVersion: '1',
|
|
145
|
-
}),
|
|
146
|
-
],
|
|
145
|
+
[stakePoolId, clockObjectRef],
|
|
147
146
|
[marketCoinType]
|
|
148
147
|
);
|
|
149
148
|
},
|
|
@@ -156,16 +155,7 @@ const generateSpoolNormalMethod: GenerateSpoolNormalMethod = ({
|
|
|
156
155
|
builder.moveCall(
|
|
157
156
|
txBlock,
|
|
158
157
|
`${spoolIds.spoolPkg}::user::stake`,
|
|
159
|
-
[
|
|
160
|
-
stakePoolId,
|
|
161
|
-
stakeAccount,
|
|
162
|
-
coin,
|
|
163
|
-
txBlock.sharedObjectRef({
|
|
164
|
-
objectId: SUI_CLOCK_OBJECT_ID,
|
|
165
|
-
mutable: false,
|
|
166
|
-
initialSharedVersion: '1',
|
|
167
|
-
}),
|
|
168
|
-
],
|
|
158
|
+
[stakePoolId, stakeAccount, coin, clockObjectRef],
|
|
169
159
|
[marketCoinType]
|
|
170
160
|
);
|
|
171
161
|
},
|
|
@@ -178,16 +168,7 @@ const generateSpoolNormalMethod: GenerateSpoolNormalMethod = ({
|
|
|
178
168
|
return builder.moveCall(
|
|
179
169
|
txBlock,
|
|
180
170
|
`${spoolIds.spoolPkg}::user::unstake`,
|
|
181
|
-
[
|
|
182
|
-
stakePoolId,
|
|
183
|
-
stakeAccount,
|
|
184
|
-
amount,
|
|
185
|
-
txBlock.sharedObjectRef({
|
|
186
|
-
objectId: SUI_CLOCK_OBJECT_ID,
|
|
187
|
-
mutable: false,
|
|
188
|
-
initialSharedVersion: '1',
|
|
189
|
-
}),
|
|
190
|
-
],
|
|
171
|
+
[stakePoolId, stakeAccount, amount, clockObjectRef],
|
|
191
172
|
[marketCoinType]
|
|
192
173
|
);
|
|
193
174
|
},
|
|
@@ -205,16 +186,7 @@ const generateSpoolNormalMethod: GenerateSpoolNormalMethod = ({
|
|
|
205
186
|
return builder.moveCall(
|
|
206
187
|
txBlock,
|
|
207
188
|
`${spoolIds.spoolPkg}::user::redeem_rewards`,
|
|
208
|
-
[
|
|
209
|
-
stakePoolId,
|
|
210
|
-
rewardPoolId,
|
|
211
|
-
stakeAccount,
|
|
212
|
-
txBlock.sharedObjectRef({
|
|
213
|
-
objectId: SUI_CLOCK_OBJECT_ID,
|
|
214
|
-
mutable: false,
|
|
215
|
-
initialSharedVersion: '1',
|
|
216
|
-
}),
|
|
217
|
-
],
|
|
189
|
+
[stakePoolId, rewardPoolId, stakeAccount, clockObjectRef],
|
|
218
190
|
[marketCoinType, rewardCoinType]
|
|
219
191
|
);
|
|
220
192
|
},
|