@scallop-io/sui-scallop-sdk 0.47.3 → 1.3.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builders/borrowIncentiveBuilder.d.ts +2 -2
- package/dist/builders/coreBuilder.d.ts +2 -2
- package/dist/builders/index.d.ts +2 -2
- package/dist/builders/loyaltyProgramBuilder.d.ts +2 -2
- package/dist/builders/referralBuilder.d.ts +2 -2
- package/dist/builders/sCoinBuilder.d.ts +2 -2
- package/dist/builders/spoolBuilder.d.ts +2 -2
- package/dist/builders/vescaBuilder.d.ts +2 -2
- package/dist/constants/common.d.ts +4 -4
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/vesca.d.ts +3 -3
- package/dist/index.js +87 -71
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +90 -77
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopBuilder.d.ts +10 -8
- package/dist/models/scallopCache.d.ts +5 -9
- package/dist/models/scallopClient.d.ts +2 -2
- package/dist/models/scallopQuery.d.ts +1 -1
- package/dist/models/scallopUtils.d.ts +2 -2
- package/dist/queries/coreQuery.d.ts +3 -3
- package/dist/queries/loyaltyProgramQuery.d.ts +1 -1
- package/dist/queries/priceQuery.d.ts +1 -1
- package/dist/queries/vescaQuery.d.ts +1 -1
- package/dist/test.d.ts +1 -0
- package/dist/types/builder/borrowIncentive.d.ts +1 -1
- package/dist/types/builder/core.d.ts +16 -16
- package/dist/types/builder/spool.d.ts +3 -3
- package/dist/types/builder/vesca.d.ts +5 -5
- package/dist/types/model.d.ts +4 -4
- package/dist/types/query/vesca.d.ts +1 -1
- package/dist/utils/query.d.ts +1 -1
- package/dist/utils/util.d.ts +1 -0
- package/package.json +13 -9
- package/src/builders/borrowIncentiveBuilder.ts +6 -6
- package/src/builders/coreBuilder.ts +15 -15
- package/src/builders/index.ts +2 -2
- package/src/builders/loyaltyProgramBuilder.ts +5 -5
- package/src/builders/oracle.ts +5 -4
- package/src/builders/referralBuilder.ts +6 -6
- package/src/builders/sCoinBuilder.ts +5 -8
- package/src/builders/spoolBuilder.ts +9 -9
- package/src/builders/vescaBuilder.ts +5 -5
- package/src/constants/common.ts +4 -4
- package/src/constants/index.ts +1 -1
- package/src/constants/vesca.ts +5 -6
- package/src/models/scallopBuilder.ts +14 -7
- package/src/models/scallopCache.ts +43 -34
- package/src/models/scallopClient.ts +8 -6
- package/src/models/scallopQuery.ts +2 -2
- package/src/models/scallopUtils.ts +3 -3
- package/src/queries/borrowIncentiveQuery.ts +1 -1
- package/src/queries/coreQuery.ts +4 -4
- package/src/queries/loyaltyProgramQuery.ts +1 -1
- package/src/queries/priceQuery.ts +1 -1
- package/src/queries/sCoinQuery.ts +2 -2
- package/src/queries/spoolQuery.ts +4 -5
- package/src/queries/vescaQuery.ts +6 -3
- package/src/test.ts +26 -0
- package/src/types/address.ts +26 -26
- package/src/types/builder/borrowIncentive.ts +1 -1
- package/src/types/builder/core.ts +26 -28
- package/src/types/builder/spool.ts +2 -3
- package/src/types/builder/vesca.ts +5 -9
- package/src/types/model.ts +4 -7
- package/src/types/query/vesca.ts +1 -1
- package/src/utils/query.ts +1 -1
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TransactionBlock,
|
|
3
|
-
SuiTxBlock as SuiKitTxBlock,
|
|
4
|
-
} from '@scallop-io/sui-kit';
|
|
1
|
+
import { Transaction, SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
5
2
|
import { ScallopBuilder } from 'src/models';
|
|
6
3
|
import {
|
|
7
4
|
BaseScallopTxBlock,
|
|
@@ -83,15 +80,15 @@ export const newSCoinTxBlock = (
|
|
|
83
80
|
initTxBlock?:
|
|
84
81
|
| ScallopTxBlock
|
|
85
82
|
| SuiKitTxBlock
|
|
86
|
-
|
|
|
83
|
+
| Transaction
|
|
87
84
|
| BaseScallopTxBlock
|
|
88
85
|
) => {
|
|
89
86
|
const txBlock =
|
|
90
|
-
initTxBlock instanceof
|
|
87
|
+
initTxBlock instanceof Transaction
|
|
91
88
|
? new SuiKitTxBlock(initTxBlock)
|
|
92
89
|
: initTxBlock
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
? initTxBlock
|
|
91
|
+
: new SuiKitTxBlock();
|
|
95
92
|
|
|
96
93
|
const normalMethod = generateSCoinNormalMethod({
|
|
97
94
|
builder,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui
|
|
1
|
+
import { Transaction } from '@mysten/sui/transactions';
|
|
2
|
+
import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui/utils';
|
|
3
3
|
import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
4
4
|
import { spoolRewardCoins } from '../constants/enum';
|
|
5
5
|
import { getStakeAccounts } from '../queries/spoolQuery';
|
|
6
6
|
import { requireSender } from '../utils';
|
|
7
7
|
import type { SuiAddressArg } from '@scallop-io/sui-kit';
|
|
8
|
-
import type { TransactionResult } from '@mysten/sui
|
|
8
|
+
import type { TransactionResult } from '@mysten/sui/transactions';
|
|
9
9
|
import type { ScallopBuilder } from '../models';
|
|
10
10
|
import type {
|
|
11
11
|
SpoolIds,
|
|
@@ -166,10 +166,10 @@ const generateSpoolNormalMethod: GenerateSpoolNormalMethod = ({
|
|
|
166
166
|
claim: (stakeAccount, stakeMarketCoinName) => {
|
|
167
167
|
const stakePoolId = builder.address.get(
|
|
168
168
|
`spool.pools.${stakeMarketCoinName}.id`
|
|
169
|
-
);
|
|
169
|
+
) as string;
|
|
170
170
|
const rewardPoolId = builder.address.get(
|
|
171
171
|
`spool.pools.${stakeMarketCoinName}.rewardPoolId`
|
|
172
|
-
);
|
|
172
|
+
) as string;
|
|
173
173
|
const marketCoinType =
|
|
174
174
|
builder.utils.parseMarketCoinType(stakeMarketCoinName);
|
|
175
175
|
const rewardCoinName = spoolRewardCoins[stakeMarketCoinName];
|
|
@@ -317,15 +317,15 @@ export const newSpoolTxBlock = (
|
|
|
317
317
|
initTxBlock?:
|
|
318
318
|
| ScallopTxBlock
|
|
319
319
|
| SuiKitTxBlock
|
|
320
|
-
|
|
|
320
|
+
| Transaction
|
|
321
321
|
| SuiTxBlockWithSCoin
|
|
322
322
|
) => {
|
|
323
323
|
const txBlock =
|
|
324
|
-
initTxBlock instanceof
|
|
324
|
+
initTxBlock instanceof Transaction
|
|
325
325
|
? new SuiKitTxBlock(initTxBlock)
|
|
326
326
|
: initTxBlock
|
|
327
|
-
|
|
328
|
-
|
|
327
|
+
? initTxBlock
|
|
328
|
+
: new SuiKitTxBlock();
|
|
329
329
|
|
|
330
330
|
const normalMethod = generateSpoolNormalMethod({
|
|
331
331
|
builder,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SUI_CLOCK_OBJECT_ID,
|
|
3
3
|
SuiTxBlock,
|
|
4
|
-
|
|
4
|
+
Transaction,
|
|
5
5
|
SuiTxBlock as SuiKitTxBlock,
|
|
6
6
|
} from '@scallop-io/sui-kit';
|
|
7
7
|
import { SCA_COIN_TYPE } from 'src/constants';
|
|
@@ -366,14 +366,14 @@ const generateQuickVeScaMethod: GenerateVeScaQuickMethod = ({
|
|
|
366
366
|
*/
|
|
367
367
|
export const newVeScaTxBlock = (
|
|
368
368
|
builder: ScallopBuilder,
|
|
369
|
-
initTxBlock?: ScallopTxBlock | SuiKitTxBlock |
|
|
369
|
+
initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction
|
|
370
370
|
) => {
|
|
371
371
|
const txBlock =
|
|
372
|
-
initTxBlock instanceof
|
|
372
|
+
initTxBlock instanceof Transaction
|
|
373
373
|
? new SuiKitTxBlock(initTxBlock)
|
|
374
374
|
: initTxBlock
|
|
375
|
-
|
|
376
|
-
|
|
375
|
+
? initTxBlock
|
|
376
|
+
: new SuiKitTxBlock();
|
|
377
377
|
|
|
378
378
|
const normalMethod = generateNormalVeScaMethod({
|
|
379
379
|
builder,
|
package/src/constants/common.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// export const API_BASE_URL = 'https://sui.api.scallop.io';
|
|
2
|
-
export const API_BASE_URL = 'https://sui.apis.scallop.io';
|
|
3
|
-
export const SDK_API_BASE_URL = 'https://sdk.api.scallop.io';
|
|
2
|
+
export const API_BASE_URL = 'https://sui.apis.scallop.io' as const;
|
|
3
|
+
export const SDK_API_BASE_URL = 'https://sdk.api.scallop.io' as const;
|
|
4
4
|
|
|
5
|
-
export const IS_VE_SCA_TEST = false;
|
|
6
|
-
export const USE_TEST_ADDRESS = false;
|
|
5
|
+
export const IS_VE_SCA_TEST: boolean = false;
|
|
6
|
+
export const USE_TEST_ADDRESS: boolean = false;
|
|
7
7
|
|
|
8
8
|
export const ADDRESSES_ID =
|
|
9
9
|
IS_VE_SCA_TEST || USE_TEST_ADDRESS
|
package/src/constants/index.ts
CHANGED
package/src/constants/vesca.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export const UNLOCK_ROUND_DURATION = 60 * 60 * 24; // 1
|
|
2
|
-
export const MAX_LOCK_ROUNDS
|
|
3
|
-
export const MAX_LOCK_DURATION
|
|
4
|
-
MAX_LOCK_ROUNDS * UNLOCK_ROUND_DURATION; // 4 years in seconds
|
|
1
|
+
export const UNLOCK_ROUND_DURATION = 60 * 60 * 24; // 1 day in seconds
|
|
2
|
+
export const MAX_LOCK_ROUNDS = 1460 as const; // 4 years in days (or 9 days for testing)
|
|
3
|
+
export const MAX_LOCK_DURATION = MAX_LOCK_ROUNDS * UNLOCK_ROUND_DURATION; // 4 years in seconds
|
|
5
4
|
|
|
6
|
-
export const MIN_INITIAL_LOCK_AMOUNT
|
|
7
|
-
export const MIN_TOP_UP_AMOUNT
|
|
5
|
+
export const MIN_INITIAL_LOCK_AMOUNT = 10_000_000_000 as const;
|
|
6
|
+
export const MIN_TOP_UP_AMOUNT = 1_000_000_000 as const;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { normalizeSuiAddress } from '@mysten/sui
|
|
1
|
+
import { normalizeSuiAddress } from '@mysten/sui/utils';
|
|
2
2
|
import { SuiKit } from '@scallop-io/sui-kit';
|
|
3
3
|
import { ADDRESSES_ID } from '../constants';
|
|
4
4
|
import { newScallopTxBlock } from '../builders';
|
|
5
5
|
import { ScallopAddress } from './scallopAddress';
|
|
6
6
|
import { ScallopQuery } from './scallopQuery';
|
|
7
7
|
import { ScallopUtils } from './scallopUtils';
|
|
8
|
-
import type { SuiTransactionBlockResponse } from '@mysten/sui
|
|
9
|
-
import type {
|
|
8
|
+
import type { SuiTransactionBlockResponse } from '@mysten/sui/client';
|
|
9
|
+
import type { Transaction } from '@mysten/sui/transactions';
|
|
10
10
|
import type { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
11
11
|
import type {
|
|
12
12
|
ScallopBuilderParams,
|
|
@@ -19,6 +19,7 @@ import type {
|
|
|
19
19
|
} from '../types';
|
|
20
20
|
import { ScallopCache } from './scallopCache';
|
|
21
21
|
import { DEFAULT_CACHE_OPTIONS } from 'src/constants/cache';
|
|
22
|
+
import { SuiClient as SuiClientV0 } from '@mysten/sui.js/client';
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* @description
|
|
@@ -42,6 +43,9 @@ export class ScallopBuilder {
|
|
|
42
43
|
public walletAddress: string;
|
|
43
44
|
public cache: ScallopCache;
|
|
44
45
|
|
|
46
|
+
// For compatibility with pyth sdk
|
|
47
|
+
public oldSuiClient: SuiClientV0;
|
|
48
|
+
|
|
45
49
|
public constructor(
|
|
46
50
|
params: ScallopBuilderParams,
|
|
47
51
|
instance?: ScallopBuilderInstanceParams
|
|
@@ -88,6 +92,11 @@ export class ScallopBuilder {
|
|
|
88
92
|
this.isTestnet = params.networkType
|
|
89
93
|
? params.networkType === 'testnet'
|
|
90
94
|
: false;
|
|
95
|
+
|
|
96
|
+
// intitialize old Sui Client version
|
|
97
|
+
this.oldSuiClient = new SuiClientV0({
|
|
98
|
+
url: this.suiKit.suiInteractor.currentFullNode,
|
|
99
|
+
});
|
|
91
100
|
}
|
|
92
101
|
|
|
93
102
|
/**
|
|
@@ -112,9 +121,7 @@ export class ScallopBuilder {
|
|
|
112
121
|
* @param txBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
|
|
113
122
|
* @return Scallop txBlock.
|
|
114
123
|
*/
|
|
115
|
-
public createTxBlock(
|
|
116
|
-
txBlock?: ScallopTxBlock | SuiKitTxBlock | TransactionBlock
|
|
117
|
-
) {
|
|
124
|
+
public createTxBlock(txBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction) {
|
|
118
125
|
return newScallopTxBlock(this, txBlock);
|
|
119
126
|
}
|
|
120
127
|
|
|
@@ -210,7 +217,7 @@ export class ScallopBuilder {
|
|
|
210
217
|
* @param txBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
|
|
211
218
|
*/
|
|
212
219
|
public async signAndSendTxBlock(
|
|
213
|
-
txBlock: ScallopTxBlock | SuiKitTxBlock |
|
|
220
|
+
txBlock: ScallopTxBlock | SuiKitTxBlock | Transaction
|
|
214
221
|
) {
|
|
215
222
|
return (await this.suiKit.signAndSendTxn(
|
|
216
223
|
txBlock
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { QueryClient, QueryClientConfig } from '@tanstack/query-core';
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
SuiObjectArg,
|
|
4
4
|
SuiTxBlock,
|
|
5
5
|
normalizeStructTag,
|
|
6
6
|
normalizeSuiAddress,
|
|
@@ -17,7 +17,7 @@ import type {
|
|
|
17
17
|
GetDynamicFieldObjectParams,
|
|
18
18
|
GetBalanceParams,
|
|
19
19
|
SuiClient,
|
|
20
|
-
} from '@mysten/sui
|
|
20
|
+
} from '@mysten/sui/client';
|
|
21
21
|
import { DEFAULT_CACHE_OPTIONS } from 'src/constants/cache';
|
|
22
22
|
import { callWithRateLimit, TokenBucket } from 'src/utils';
|
|
23
23
|
import {
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
|
|
28
28
|
type QueryInspectTxnParams = {
|
|
29
29
|
queryTarget: string;
|
|
30
|
-
args:
|
|
30
|
+
args: SuiObjectArg[];
|
|
31
31
|
typeArgs?: any[];
|
|
32
32
|
};
|
|
33
33
|
|
|
@@ -92,20 +92,43 @@ export class ScallopCache {
|
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
95
|
+
public async resolveArgs(
|
|
96
|
+
txb: SuiTxBlock,
|
|
97
|
+
args: SuiObjectArg[]
|
|
98
|
+
): Promise<SuiObjectArg[]> {
|
|
99
|
+
return await Promise.all(
|
|
100
|
+
args.map(async (arg) => {
|
|
101
|
+
if (typeof arg === 'string') {
|
|
102
|
+
const objData = (await this.queryGetObject(arg, { showOwner: true }))
|
|
103
|
+
?.data;
|
|
104
|
+
if (!objData) return arg;
|
|
105
|
+
const owner = objData?.owner as any;
|
|
106
|
+
if (!owner) return arg;
|
|
107
|
+
|
|
108
|
+
if ('Shared' in owner) {
|
|
109
|
+
return txb.sharedObjectRef({
|
|
110
|
+
objectId: objData.objectId,
|
|
111
|
+
initialSharedVersion: owner.Shared.initial_shared_version,
|
|
112
|
+
mutable: true,
|
|
113
|
+
});
|
|
114
|
+
} else {
|
|
115
|
+
return txb.objectRef({
|
|
116
|
+
objectId: objData.objectId,
|
|
117
|
+
version: objData.version,
|
|
118
|
+
digest: objData.digest,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
} else if ('objectId' in arg && 'version' in arg && 'digest' in arg) {
|
|
122
|
+
return txb.objectRef({
|
|
123
|
+
objectId: arg.objectId,
|
|
124
|
+
version: arg.version as string,
|
|
125
|
+
digest: arg.digest,
|
|
126
|
+
});
|
|
127
|
+
} else {
|
|
128
|
+
return arg;
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
);
|
|
109
132
|
}
|
|
110
133
|
|
|
111
134
|
/**
|
|
@@ -121,23 +144,9 @@ export class ScallopCache {
|
|
|
121
144
|
}: QueryInspectTxnParams): Promise<DevInspectResults | null> {
|
|
122
145
|
const txBlock = new SuiTxBlock();
|
|
123
146
|
|
|
124
|
-
|
|
125
|
-
const resolvedArgs = await Promise.all(
|
|
126
|
-
args.map(async (arg) => {
|
|
127
|
-
if (typeof arg === 'string') {
|
|
128
|
-
return (await this.queryGetObject(arg, { showContent: true }))?.data;
|
|
129
|
-
}
|
|
130
|
-
return arg;
|
|
131
|
-
})
|
|
132
|
-
);
|
|
133
|
-
txBlock.moveCall(queryTarget, resolvedArgs, typeArgs);
|
|
147
|
+
const resolvedArgs = await this.resolveArgs(txBlock, args);
|
|
134
148
|
|
|
135
|
-
|
|
136
|
-
const txBytes = await txBlock.txBlock.build({
|
|
137
|
-
client: this.client,
|
|
138
|
-
onlyTransactionKind: true,
|
|
139
|
-
protocolConfig: (await this.getProtocolConfig()) ?? undefined,
|
|
140
|
-
});
|
|
149
|
+
txBlock.moveCall(queryTarget, resolvedArgs, typeArgs);
|
|
141
150
|
|
|
142
151
|
const query = await this.queryClient.fetchQuery({
|
|
143
152
|
queryKey: typeArgs
|
|
@@ -150,7 +159,7 @@ export class ScallopCache {
|
|
|
150
159
|
],
|
|
151
160
|
queryFn: async () => {
|
|
152
161
|
return await callWithRateLimit(this.tokenBucket, () =>
|
|
153
|
-
this.suiKit.inspectTxn(
|
|
162
|
+
this.suiKit.inspectTxn(txBlock)
|
|
154
163
|
);
|
|
155
164
|
},
|
|
156
165
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeSuiAddress } from '@mysten/sui
|
|
1
|
+
import { normalizeSuiAddress } from '@mysten/sui/utils';
|
|
2
2
|
import { SuiKit } from '@scallop-io/sui-kit';
|
|
3
3
|
import { DEFAULT_CACHE_OPTIONS } from 'src/constants/cache';
|
|
4
4
|
import {
|
|
@@ -12,13 +12,13 @@ import { ScallopAddress } from './scallopAddress';
|
|
|
12
12
|
import { ScallopUtils } from './scallopUtils';
|
|
13
13
|
import { ScallopBuilder } from './scallopBuilder';
|
|
14
14
|
import { ScallopQuery } from './scallopQuery';
|
|
15
|
-
import {
|
|
16
|
-
import { requireSender } from 'src/utils';
|
|
17
|
-
import type { SuiTransactionBlockResponse } from '@mysten/sui.js/client';
|
|
15
|
+
import type { SuiTransactionBlockResponse } from '@mysten/sui/client';
|
|
18
16
|
import type {
|
|
19
17
|
TransactionObjectArgument,
|
|
20
18
|
TransactionResult,
|
|
21
|
-
} from '@mysten/sui
|
|
19
|
+
} from '@mysten/sui/transactions';
|
|
20
|
+
import { ScallopCache } from './scallopCache';
|
|
21
|
+
import { requireSender } from 'src/utils';
|
|
22
22
|
import type { SuiObjectArg } from '@scallop-io/sui-kit';
|
|
23
23
|
import type {
|
|
24
24
|
ScallopClientFnReturnType,
|
|
@@ -604,7 +604,7 @@ export class ScallopClient {
|
|
|
604
604
|
callback: (
|
|
605
605
|
txBlock: ScallopTxBlock,
|
|
606
606
|
coin: TransactionObjectArgument | string
|
|
607
|
-
) => SuiObjectArg
|
|
607
|
+
) => SuiObjectArg | Promise<SuiObjectArg>,
|
|
608
608
|
sign: S = true as S,
|
|
609
609
|
walletAddress?: string
|
|
610
610
|
): Promise<ScallopClientFnReturnType<S>> {
|
|
@@ -812,6 +812,8 @@ export class ScallopClient {
|
|
|
812
812
|
);
|
|
813
813
|
const stakeCoinName =
|
|
814
814
|
this.utils.parseCoinName<SupportStakeCoins>(stakeMarketCoinName);
|
|
815
|
+
|
|
816
|
+
console.log(stakeMarketCoin, stakeCoinName);
|
|
815
817
|
if (stakeMarketCoin) {
|
|
816
818
|
const coin = txBlock.withdraw(stakeMarketCoin, stakeCoinName);
|
|
817
819
|
await this.utils.mergeSimilarCoins(
|
|
@@ -53,14 +53,14 @@ import { ScallopUtils } from './scallopUtils';
|
|
|
53
53
|
import { ScallopIndexer } from './scallopIndexer';
|
|
54
54
|
import { ScallopCache } from './scallopCache';
|
|
55
55
|
import { DEFAULT_CACHE_OPTIONS } from 'src/constants/cache';
|
|
56
|
-
import { SuiObjectData } from '@mysten/sui
|
|
56
|
+
import { SuiObjectData } from '@mysten/sui/src/client';
|
|
57
57
|
import {
|
|
58
58
|
getSCoinAmount,
|
|
59
59
|
getSCoinAmounts,
|
|
60
60
|
getSCoinSwapRate,
|
|
61
61
|
getSCoinTotalSupply,
|
|
62
62
|
} from 'src/queries/sCoinQuery';
|
|
63
|
-
import { normalizeSuiAddress } from '@mysten/sui
|
|
63
|
+
import { normalizeSuiAddress } from '@mysten/sui/utils';
|
|
64
64
|
import { getSupplyLimit } from 'src/queries/supplyLimit';
|
|
65
65
|
|
|
66
66
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SUI_TYPE_ARG, normalizeStructTag } from '@mysten/sui
|
|
1
|
+
import { SUI_TYPE_ARG, normalizeStructTag } from '@mysten/sui/utils';
|
|
2
2
|
import { SuiKit } from '@scallop-io/sui-kit';
|
|
3
3
|
import { SuiPriceServiceConnection } from '@pythnetwork/pyth-sui-js';
|
|
4
4
|
import { ScallopAddress } from './scallopAddress';
|
|
@@ -41,7 +41,7 @@ import type {
|
|
|
41
41
|
SupportSCoin,
|
|
42
42
|
ScallopUtilsInstanceParams,
|
|
43
43
|
} from '../types';
|
|
44
|
-
import type {
|
|
44
|
+
import type { SuiObjectArg, SuiTxArg, SuiTxBlock } from '@scallop-io/sui-kit';
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* @description
|
|
@@ -444,7 +444,7 @@ export class ScallopUtils {
|
|
|
444
444
|
* @param obligationId - The obligation id.
|
|
445
445
|
* @return Asset coin Names.
|
|
446
446
|
*/
|
|
447
|
-
public async getObligationCoinNames(obligationId:
|
|
447
|
+
public async getObligationCoinNames(obligationId: SuiObjectArg) {
|
|
448
448
|
const obligation = await queryObligation(this, obligationId);
|
|
449
449
|
if (!obligation) return undefined;
|
|
450
450
|
|
package/src/queries/coreQuery.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeStructTag } from '@mysten/sui
|
|
1
|
+
import { normalizeStructTag } from '@mysten/sui/utils';
|
|
2
2
|
import {
|
|
3
3
|
SUPPORT_POOLS,
|
|
4
4
|
PROTOCOL_OBJECT_ID,
|
|
@@ -13,8 +13,8 @@ import {
|
|
|
13
13
|
parseOriginMarketCollateralData,
|
|
14
14
|
calculateMarketCollateralData,
|
|
15
15
|
} from '../utils';
|
|
16
|
-
import type { SuiObjectResponse, SuiObjectData } from '@mysten/sui
|
|
17
|
-
import type {
|
|
16
|
+
import type { SuiObjectResponse, SuiObjectData } from '@mysten/sui/client';
|
|
17
|
+
import type { SuiObjectArg } from '@scallop-io/sui-kit';
|
|
18
18
|
import type { ScallopAddress, ScallopCache, ScallopQuery } from '../models';
|
|
19
19
|
import {
|
|
20
20
|
Market,
|
|
@@ -819,7 +819,7 @@ export const queryObligation = async (
|
|
|
819
819
|
}: {
|
|
820
820
|
address: ScallopAddress;
|
|
821
821
|
},
|
|
822
|
-
obligationId:
|
|
822
|
+
obligationId: SuiObjectArg
|
|
823
823
|
) => {
|
|
824
824
|
const packageId = address.get('core.packages.query.id');
|
|
825
825
|
const queryTarget = `${packageId}::obligation_query::obligation_data`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bcs } from '@mysten/sui
|
|
1
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
2
2
|
import assert from 'assert';
|
|
3
3
|
import BigNumber from 'bignumber.js';
|
|
4
4
|
import { SUPPORT_SCOIN } from 'src/constants';
|
|
@@ -38,7 +38,7 @@ export const getSCoinTotalSupply = async (
|
|
|
38
38
|
const type = results[0].returnValues[0][1]; // should be u64
|
|
39
39
|
assert(type === 'u64', 'Result type is not u64');
|
|
40
40
|
|
|
41
|
-
return BigNumber(bcs.
|
|
41
|
+
return BigNumber(bcs.u64().parse(value))
|
|
42
42
|
.shiftedBy(utils.getCoinDecimal(utils.parseCoinName(sCoinName)))
|
|
43
43
|
.toNumber();
|
|
44
44
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeStructTag } from '@mysten/sui
|
|
1
|
+
import { normalizeStructTag } from '@mysten/sui/utils';
|
|
2
2
|
import { SUPPORT_SPOOLS } from '../constants';
|
|
3
3
|
import {
|
|
4
4
|
parseOriginSpoolData,
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
calculateSpoolRewardPoolData,
|
|
8
8
|
isMarketCoin,
|
|
9
9
|
} from '../utils';
|
|
10
|
-
import type { SuiObjectResponse } from '@mysten/sui
|
|
10
|
+
import type { SuiObjectResponse } from '@mysten/sui/client';
|
|
11
11
|
import type { ScallopQuery, ScallopUtils } from '../models';
|
|
12
12
|
import type {
|
|
13
13
|
MarketPool,
|
|
@@ -292,9 +292,8 @@ export const getStakeAccounts = async (
|
|
|
292
292
|
utils.parseCoinName<SupportStakeCoins>(stakeMarketCoinName);
|
|
293
293
|
const marketCoinType = utils.parseMarketCoinType(stakeCoinName);
|
|
294
294
|
|
|
295
|
-
types[
|
|
296
|
-
|
|
297
|
-
] = `${spoolObjectId}::spool_account::SpoolAccount<${marketCoinType}>`;
|
|
295
|
+
types[stakeMarketCoinName as SupportStakeMarketCoins] =
|
|
296
|
+
`${spoolObjectId}::spool_account::SpoolAccount<${marketCoinType}>`;
|
|
298
297
|
return types;
|
|
299
298
|
},
|
|
300
299
|
{} as Record<SupportStakeMarketCoins, string>
|
|
@@ -4,12 +4,13 @@ import {
|
|
|
4
4
|
type SuiObjectResponse,
|
|
5
5
|
type SuiObjectData,
|
|
6
6
|
DevInspectResults,
|
|
7
|
-
} from '@mysten/sui
|
|
7
|
+
} from '@mysten/sui/client';
|
|
8
8
|
import type { ScallopUtils } from '../models';
|
|
9
9
|
import { MAX_LOCK_DURATION } from 'src/constants';
|
|
10
10
|
import { SUI_CLOCK_OBJECT_ID, SuiTxBlock } from '@scallop-io/sui-kit';
|
|
11
|
-
import { bcs } from '@mysten/sui
|
|
11
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
12
12
|
import { z as zod } from 'zod';
|
|
13
|
+
import assert from 'assert';
|
|
13
14
|
/**
|
|
14
15
|
* Query all owned veSca key.
|
|
15
16
|
*
|
|
@@ -207,6 +208,7 @@ const getTotalVeScaTreasuryAmount = async (
|
|
|
207
208
|
);
|
|
208
209
|
|
|
209
210
|
const txb = new SuiTxBlock();
|
|
211
|
+
|
|
210
212
|
// refresh first
|
|
211
213
|
txb.moveCall(refreshQueryTarget, resolvedRefreshArgs);
|
|
212
214
|
txb.moveCall(veScaAmountQueryTarget, resolvedVeScaAmountArgs);
|
|
@@ -231,7 +233,8 @@ const getTotalVeScaTreasuryAmount = async (
|
|
|
231
233
|
if (results && results[1].returnValues) {
|
|
232
234
|
const value = Uint8Array.from(results[1].returnValues[0][0]);
|
|
233
235
|
const type = results[1].returnValues[0][1];
|
|
234
|
-
|
|
236
|
+
assert(type === 'u64', 'Result type is not u64');
|
|
237
|
+
return bcs.u64().parse(value);
|
|
235
238
|
}
|
|
236
239
|
|
|
237
240
|
return '0';
|
package/src/test.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ScallopQuery } from './models';
|
|
2
|
+
|
|
3
|
+
const query = new ScallopQuery({
|
|
4
|
+
walletAddress:
|
|
5
|
+
'0xe78704e7c188b1902dbb630dc4c3ef7f46740c8cf121e38b3438ac1daea09f2d',
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
const main = async () => {
|
|
9
|
+
try {
|
|
10
|
+
await query.init();
|
|
11
|
+
const result = await query.suiKit.client().getObject({
|
|
12
|
+
id: '0xaa72bd551b25715b8f9d72f226fa02526bdf2e085a86faec7184230c5209bb6e',
|
|
13
|
+
options: {
|
|
14
|
+
showContent: true,
|
|
15
|
+
showType: true,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
console.dir(result.data, { depth: null });
|
|
19
|
+
} catch (e) {
|
|
20
|
+
console.error(e);
|
|
21
|
+
} finally {
|
|
22
|
+
process.exit(0);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
main();
|
package/src/types/address.ts
CHANGED
|
@@ -27,13 +27,13 @@ export interface AddressesInterface {
|
|
|
27
27
|
[K in SupportOracleType]: K extends (typeof SUPPORT_ORACLES)[0]
|
|
28
28
|
? string
|
|
29
29
|
: K extends (typeof SUPPORT_ORACLES)[1]
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
? string
|
|
31
|
+
: K extends (typeof SUPPORT_ORACLES)[2]
|
|
32
|
+
? {
|
|
33
|
+
feed: string;
|
|
34
|
+
feedObject: string;
|
|
35
|
+
}
|
|
36
|
+
: never;
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
>
|
|
@@ -46,19 +46,19 @@ export interface AddressesInterface {
|
|
|
46
46
|
holder: string;
|
|
47
47
|
}
|
|
48
48
|
: K extends (typeof SUPPORT_ORACLES)[1]
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
49
|
+
? {
|
|
50
|
+
registry: string;
|
|
51
|
+
registryCap: string;
|
|
52
|
+
}
|
|
53
|
+
: K extends (typeof SUPPORT_ORACLES)[2]
|
|
54
|
+
? {
|
|
55
|
+
registry: string;
|
|
56
|
+
registryCap: string;
|
|
57
|
+
state: string;
|
|
58
|
+
wormhole: string;
|
|
59
|
+
wormholeState: string;
|
|
60
|
+
}
|
|
61
|
+
: never;
|
|
62
62
|
} & { xOracle: string; xOracleCap: string };
|
|
63
63
|
packages: Partial<
|
|
64
64
|
Record<
|
|
@@ -145,12 +145,12 @@ type AddressPathsProps<T> = T extends string
|
|
|
145
145
|
type Join<T extends string[], D extends string> = T extends []
|
|
146
146
|
? never
|
|
147
147
|
: T extends [infer F]
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
148
|
+
? F
|
|
149
|
+
: T extends [infer F, ...infer R]
|
|
150
|
+
? F extends string
|
|
151
|
+
? `${F}${D}${Join<Extract<R, string[]>, D>}`
|
|
152
|
+
: never
|
|
153
|
+
: string;
|
|
154
154
|
|
|
155
155
|
export type AddressStringPath = Join<
|
|
156
156
|
AddressPathsProps<AddressesInterface>,
|
|
@@ -2,7 +2,7 @@ import type {
|
|
|
2
2
|
SuiTxBlock as SuiKitTxBlock,
|
|
3
3
|
SuiObjectArg,
|
|
4
4
|
} from '@scallop-io/sui-kit';
|
|
5
|
-
import type { TransactionResult } from '@mysten/sui
|
|
5
|
+
import type { TransactionResult } from '@mysten/sui/transactions';
|
|
6
6
|
import type { ScallopBuilder } from '../../models';
|
|
7
7
|
import type {
|
|
8
8
|
SupportBorrowIncentiveCoins,
|