@scallop-io/sui-scallop-sdk 0.44.28 → 0.46.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/builders/borrowIncentiveBuilder.d.ts +1 -1
- package/dist/builders/referralBuilder.d.ts +12 -0
- package/dist/constants/cache.d.ts +8 -0
- package/dist/constants/common.d.ts +1 -1
- package/dist/index.js +890 -419
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +967 -493
- package/dist/index.mjs.map +1 -1
- package/dist/models/index.d.ts +1 -0
- package/dist/models/scallop.d.ts +7 -1
- package/dist/models/scallopAddress.d.ts +4 -2
- package/dist/models/scallopBuilder.d.ts +2 -0
- package/dist/models/scallopCache.d.ts +75 -0
- package/dist/models/scallopClient.d.ts +2 -0
- package/dist/models/scallopIndexer.d.ts +5 -3
- package/dist/models/scallopQuery.d.ts +28 -28
- package/dist/models/scallopUtils.d.ts +1 -0
- package/dist/queries/coreQuery.d.ts +3 -29
- package/dist/queries/index.d.ts +1 -0
- package/dist/queries/priceQuery.d.ts +3 -1
- package/dist/queries/referralQuery.d.ts +7 -0
- package/dist/queries/vescaQuery.d.ts +6 -2
- package/dist/types/address.d.ts +15 -0
- package/dist/types/builder/core.d.ts +2 -0
- package/dist/types/builder/index.d.ts +2 -1
- package/dist/types/builder/referral.d.ts +30 -0
- package/dist/types/builder/vesca.d.ts +1 -0
- package/dist/types/model.d.ts +2 -0
- package/package.json +8 -6
- package/src/builders/borrowIncentiveBuilder.ts +12 -21
- package/src/builders/coreBuilder.ts +54 -0
- package/src/builders/index.ts +5 -2
- package/src/builders/referralBuilder.ts +178 -0
- package/src/builders/vescaBuilder.ts +8 -6
- package/src/constants/cache.ts +15 -0
- package/src/constants/common.ts +9 -2
- package/src/constants/vesca.ts +1 -3
- package/src/models/index.ts +1 -0
- package/src/models/scallop.ts +26 -7
- package/src/models/scallopAddress.ts +87 -38
- package/src/models/scallopBuilder.ts +14 -4
- package/src/models/scallopCache.ts +285 -0
- package/src/models/scallopClient.ts +15 -4
- package/src/models/scallopIndexer.ts +58 -84
- package/src/models/scallopQuery.ts +54 -5
- package/src/models/scallopUtils.ts +66 -37
- package/src/queries/borrowIncentiveQuery.ts +6 -12
- package/src/queries/coreQuery.ts +83 -260
- package/src/queries/index.ts +1 -0
- package/src/queries/priceQuery.ts +48 -9
- package/src/queries/referralQuery.ts +27 -0
- package/src/queries/spoolQuery.ts +20 -27
- package/src/queries/vescaQuery.ts +95 -17
- package/src/types/address.ts +15 -0
- package/src/types/builder/core.ts +14 -0
- package/src/types/builder/index.ts +2 -0
- package/src/types/builder/referral.ts +51 -0
- package/src/types/builder/vesca.ts +1 -0
- package/src/types/model.ts +2 -0
- package/src/types/query/borrowIncentive.ts +0 -107
package/dist/models/index.d.ts
CHANGED
package/dist/models/scallop.d.ts
CHANGED
|
@@ -6,7 +6,12 @@ import { ScallopQuery } from './scallopQuery';
|
|
|
6
6
|
import { ScallopUtils } from './scallopUtils';
|
|
7
7
|
import type { ScallopParams } from '../types/';
|
|
8
8
|
import { ScallopIndexer } from './scallopIndexer';
|
|
9
|
+
import { ScallopCache } from './scallopCache';
|
|
10
|
+
import { QueryClientConfig } from '@tanstack/query-core';
|
|
9
11
|
/**
|
|
12
|
+
* @argument params - The parameters for the Scallop instance.
|
|
13
|
+
* @argument cacheOptions - The cache options for the QueryClient.
|
|
14
|
+
*
|
|
10
15
|
* @description
|
|
11
16
|
* The main instance that controls interaction with the Scallop contract.
|
|
12
17
|
*
|
|
@@ -23,8 +28,9 @@ import { ScallopIndexer } from './scallopIndexer';
|
|
|
23
28
|
export declare class Scallop {
|
|
24
29
|
params: ScallopParams;
|
|
25
30
|
suiKit: SuiKit;
|
|
31
|
+
cache: ScallopCache;
|
|
26
32
|
private _address;
|
|
27
|
-
constructor(params: ScallopParams);
|
|
33
|
+
constructor(params: ScallopParams, cacheOptions?: QueryClientConfig);
|
|
28
34
|
/**
|
|
29
35
|
* Get a scallop address instance that already has read addresses.
|
|
30
36
|
*
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { NetworkType } from '@scallop-io/sui-kit';
|
|
2
2
|
import type { ScallopAddressParams, AddressesInterface, AddressStringPath } from '../types';
|
|
3
|
+
import { ScallopCache } from './scallopCache';
|
|
3
4
|
/**
|
|
4
5
|
* @description
|
|
5
6
|
* It provides methods for managing addresses.
|
|
@@ -13,12 +14,13 @@ import type { ScallopAddressParams, AddressesInterface, AddressStringPath } from
|
|
|
13
14
|
*/
|
|
14
15
|
export declare class ScallopAddress {
|
|
15
16
|
private readonly _auth?;
|
|
16
|
-
private _requestClient;
|
|
17
|
+
private readonly _requestClient;
|
|
17
18
|
private _id?;
|
|
18
19
|
private _network;
|
|
19
20
|
private _currentAddresses?;
|
|
20
21
|
private _addressesMap;
|
|
21
|
-
|
|
22
|
+
private _cache;
|
|
23
|
+
constructor(params: ScallopAddressParams, cache?: ScallopCache);
|
|
22
24
|
/**
|
|
23
25
|
* Get addresses API id.
|
|
24
26
|
*
|
|
@@ -6,6 +6,7 @@ import type { SuiTransactionBlockResponse } from '@mysten/sui.js/client';
|
|
|
6
6
|
import type { TransactionBlock } from '@mysten/sui.js/transactions';
|
|
7
7
|
import type { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
8
8
|
import type { ScallopInstanceParams, ScallopBuilderParams, ScallopTxBlock, SupportMarketCoins, SupportAssetCoins } from '../types';
|
|
9
|
+
import { ScallopCache } from './scallopCache';
|
|
9
10
|
/**
|
|
10
11
|
* @description
|
|
11
12
|
* It provides methods for operating the transaction block, making it more convenient to organize transaction combinations.
|
|
@@ -25,6 +26,7 @@ export declare class ScallopBuilder {
|
|
|
25
26
|
query: ScallopQuery;
|
|
26
27
|
utils: ScallopUtils;
|
|
27
28
|
walletAddress: string;
|
|
29
|
+
cache: ScallopCache;
|
|
28
30
|
constructor(params: ScallopBuilderParams, instance?: ScallopInstanceParams);
|
|
29
31
|
/**
|
|
30
32
|
* Request the scallop API to initialize data.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { QueryClient, QueryClientConfig } from '@tanstack/query-core';
|
|
2
|
+
import { SuiTxArg } from '@scallop-io/sui-kit';
|
|
3
|
+
import { SuiKit } from '@scallop-io/sui-kit';
|
|
4
|
+
import type { SuiObjectResponse, SuiObjectDataOptions, SuiObjectData, PaginatedObjectsResponse, GetOwnedObjectsParams, DevInspectResults, GetDynamicFieldsParams, DynamicFieldPage, GetDynamicFieldObjectParams, GetBalanceParams } from '@mysten/sui.js/client';
|
|
5
|
+
type QueryInspectTxnParams = {
|
|
6
|
+
queryTarget: string;
|
|
7
|
+
args: SuiTxArg[];
|
|
8
|
+
typeArgs?: any[];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* @description
|
|
12
|
+
* It provides caching for moveCall, RPC Request, and API Request.
|
|
13
|
+
*
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const scallopCache = new scallopCache(<parameters>);
|
|
18
|
+
* scallopCache.<indexer functions>();
|
|
19
|
+
* await scallopCache.<indexer async functions>();
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare class ScallopCache {
|
|
23
|
+
readonly queryClient: QueryClient;
|
|
24
|
+
readonly _suiKit?: SuiKit;
|
|
25
|
+
constructor(cacheOptions?: QueryClientConfig, suiKit?: SuiKit);
|
|
26
|
+
private get suiKit();
|
|
27
|
+
/**
|
|
28
|
+
* @description Invalidate cache based on the refetchType parameter
|
|
29
|
+
* @param refetchType Determines the type of queries to be refetched. Defaults to `active`.
|
|
30
|
+
*
|
|
31
|
+
* - `active`: Only queries that match the refetch predicate and are actively being rendered via useQuery and related functions will be refetched in the background.
|
|
32
|
+
* - `inactive`: Only queries that match the refetch predicate and are NOT actively being rendered via useQuery and related functions will be refetched in the background.
|
|
33
|
+
* - `all`: All queries that match the refetch predicate will be refetched in the background.
|
|
34
|
+
* - `none`: No queries will be refetched. Queries that match the refetch predicate will only be marked as invalid.
|
|
35
|
+
*/
|
|
36
|
+
invalidateAndRefetchAllCache(refetchType: 'all' | 'active' | 'inactive' | 'none'): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* @description Cache protocol config call for 60 seconds.
|
|
39
|
+
* @returns Promise<ProtocolConfig>
|
|
40
|
+
*/
|
|
41
|
+
getProtocolConfig(): Promise<import("@mysten/sui.js/client").ProtocolConfig>;
|
|
42
|
+
/**
|
|
43
|
+
* @description Provides cache for inspectTxn of the SuiKit.
|
|
44
|
+
* @param QueryInspectTxnParams
|
|
45
|
+
* @param txBlock
|
|
46
|
+
* @returns Promise<DevInspectResults>
|
|
47
|
+
*/
|
|
48
|
+
queryInspectTxn({ queryTarget, args, typeArgs, }: QueryInspectTxnParams): Promise<DevInspectResults>;
|
|
49
|
+
/**
|
|
50
|
+
* @description Provides cache for getObject of the SuiKit.
|
|
51
|
+
* @param objectId
|
|
52
|
+
* @param QueryObjectParams
|
|
53
|
+
* @returns Promise<SuiObjectResponse>
|
|
54
|
+
*/
|
|
55
|
+
queryGetObject(objectId: string, options?: SuiObjectDataOptions): Promise<SuiObjectResponse>;
|
|
56
|
+
/**
|
|
57
|
+
* @description Provides cache for getObjects of the SuiKit.
|
|
58
|
+
* @param objectIds
|
|
59
|
+
* @returns Promise<SuiObjectData[]>
|
|
60
|
+
*/
|
|
61
|
+
queryGetObjects(objectIds: string[], options?: SuiObjectDataOptions): Promise<SuiObjectData[]>;
|
|
62
|
+
/**
|
|
63
|
+
* @description Provides cache for getOwnedObjects of the SuiKit.
|
|
64
|
+
* @param input
|
|
65
|
+
* @returns Promise<PaginatedObjectsResponse>
|
|
66
|
+
*/
|
|
67
|
+
queryGetOwnedObjects(input: GetOwnedObjectsParams): Promise<PaginatedObjectsResponse>;
|
|
68
|
+
queryGetDynamicFields(input: GetDynamicFieldsParams): Promise<DynamicFieldPage>;
|
|
69
|
+
queryGetDynamicFieldObject(input: GetDynamicFieldObjectParams): Promise<SuiObjectResponse>;
|
|
70
|
+
queryGetAllCoinBalances(owner: string): Promise<{
|
|
71
|
+
[k: string]: string;
|
|
72
|
+
}>;
|
|
73
|
+
queryGetCoinBalance(input: GetBalanceParams): Promise<string>;
|
|
74
|
+
}
|
|
75
|
+
export {};
|
|
@@ -7,6 +7,7 @@ import type { SuiTransactionBlockResponse } from '@mysten/sui.js/client';
|
|
|
7
7
|
import type { TransactionObjectArgument } from '@mysten/sui.js/transactions';
|
|
8
8
|
import type { SuiObjectArg } from '@scallop-io/sui-kit';
|
|
9
9
|
import type { ScallopClientFnReturnType, ScallopInstanceParams, ScallopClientParams, SupportPoolCoins, SupportCollateralCoins, SupportAssetCoins, SupportStakeCoins, SupportStakeMarketCoins, SupportBorrowIncentiveCoins, ScallopTxBlock } from '../types';
|
|
10
|
+
import { ScallopCache } from './scallopCache';
|
|
10
11
|
/**
|
|
11
12
|
* @description
|
|
12
13
|
* It provides contract interaction operations for general users.
|
|
@@ -26,6 +27,7 @@ export declare class ScallopClient {
|
|
|
26
27
|
builder: ScallopBuilder;
|
|
27
28
|
query: ScallopQuery;
|
|
28
29
|
utils: ScallopUtils;
|
|
30
|
+
cache: ScallopCache;
|
|
29
31
|
walletAddress: string;
|
|
30
32
|
constructor(params: ScallopClientParams, instance?: ScallopInstanceParams);
|
|
31
33
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Market, MarketPools, MarketPool, MarketCollaterals, MarketCollateral, Spools, Spool, BorrowIncentivePools, BorrowIncentivePool, SupportPoolCoins, SupportCollateralCoins, SupportStakeMarketCoins, SupportBorrowIncentiveCoins, TotalValueLocked } from '../types';
|
|
1
|
+
import type { Market, MarketPools, MarketPool, MarketCollaterals, MarketCollateral, Spools, Spool, BorrowIncentivePools, BorrowIncentivePool, SupportPoolCoins, SupportCollateralCoins, SupportStakeMarketCoins, SupportBorrowIncentiveCoins, TotalValueLocked, ScallopQueryParams, ScallopParams, ScallopInstanceParams } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* @description
|
|
4
4
|
* It provides methods to obtain sdk index data from mainnet.
|
|
@@ -12,8 +12,10 @@ import type { Market, MarketPools, MarketPool, MarketCollaterals, MarketCollater
|
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
14
|
export declare class ScallopIndexer {
|
|
15
|
-
private
|
|
16
|
-
|
|
15
|
+
private readonly _cache;
|
|
16
|
+
readonly params: ScallopQueryParams;
|
|
17
|
+
private readonly _requestClient;
|
|
18
|
+
constructor(params: ScallopParams, instance?: ScallopInstanceParams);
|
|
17
19
|
/**
|
|
18
20
|
* Get market index data.
|
|
19
21
|
*
|
|
@@ -3,6 +3,7 @@ import { ScallopQueryParams, ScallopInstanceParams, SupportStakeMarketCoins, Sup
|
|
|
3
3
|
import { ScallopAddress } from './scallopAddress';
|
|
4
4
|
import { ScallopUtils } from './scallopUtils';
|
|
5
5
|
import { ScallopIndexer } from './scallopIndexer';
|
|
6
|
+
import { ScallopCache } from './scallopCache';
|
|
6
7
|
/**
|
|
7
8
|
* @description
|
|
8
9
|
* It provides methods for getting on-chain data from the Scallop contract.
|
|
@@ -21,6 +22,7 @@ export declare class ScallopQuery {
|
|
|
21
22
|
address: ScallopAddress;
|
|
22
23
|
utils: ScallopUtils;
|
|
23
24
|
indexer: ScallopIndexer;
|
|
25
|
+
cache: ScallopCache;
|
|
24
26
|
constructor(params: ScallopQueryParams, instance?: ScallopInstanceParams);
|
|
25
27
|
/**
|
|
26
28
|
* Request the scallop API to initialize data.
|
|
@@ -122,20 +124,7 @@ export declare class ScallopQuery {
|
|
|
122
124
|
* @param ownerAddress - The owner address.
|
|
123
125
|
* @return All coin amounts.
|
|
124
126
|
*/
|
|
125
|
-
getCoinAmounts(assetCoinNames?: SupportAssetCoins[], ownerAddress?: string): Promise<
|
|
126
|
-
eth?: number | undefined;
|
|
127
|
-
btc?: number | undefined;
|
|
128
|
-
usdc?: number | undefined;
|
|
129
|
-
usdt?: number | undefined;
|
|
130
|
-
sui?: number | undefined;
|
|
131
|
-
apt?: number | undefined;
|
|
132
|
-
sol?: number | undefined;
|
|
133
|
-
cetus?: number | undefined;
|
|
134
|
-
afsui?: number | undefined;
|
|
135
|
-
hasui?: number | undefined;
|
|
136
|
-
vsui?: number | undefined;
|
|
137
|
-
sca?: number | undefined;
|
|
138
|
-
}>;
|
|
127
|
+
getCoinAmounts(assetCoinNames?: SupportAssetCoins[], ownerAddress?: string): Promise<import("../types").OptionalKeys<Record<SupportAssetCoins, number>>>;
|
|
139
128
|
/**
|
|
140
129
|
* Get asset coin amount.
|
|
141
130
|
*
|
|
@@ -151,20 +140,7 @@ export declare class ScallopQuery {
|
|
|
151
140
|
* @param ownerAddress - The owner address.
|
|
152
141
|
* @return All market market coin amounts.
|
|
153
142
|
*/
|
|
154
|
-
getMarketCoinAmounts(marketCoinNames?: SupportMarketCoins[], ownerAddress?: string): Promise<
|
|
155
|
-
seth?: number | undefined;
|
|
156
|
-
ssui?: number | undefined;
|
|
157
|
-
susdc?: number | undefined;
|
|
158
|
-
susdt?: number | undefined;
|
|
159
|
-
scetus?: number | undefined;
|
|
160
|
-
safsui?: number | undefined;
|
|
161
|
-
shasui?: number | undefined;
|
|
162
|
-
svsui?: number | undefined;
|
|
163
|
-
sbtc?: number | undefined;
|
|
164
|
-
sapt?: number | undefined;
|
|
165
|
-
ssol?: number | undefined;
|
|
166
|
-
ssca?: number | undefined;
|
|
167
|
-
}>;
|
|
143
|
+
getMarketCoinAmounts(marketCoinNames?: SupportMarketCoins[], ownerAddress?: string): Promise<import("../types").OptionalKeys<Record<SupportMarketCoins, number>>>;
|
|
168
144
|
/**
|
|
169
145
|
* Get market coin amount.
|
|
170
146
|
*
|
|
@@ -180,6 +156,13 @@ export declare class ScallopQuery {
|
|
|
180
156
|
* @return Asset coin price.
|
|
181
157
|
*/
|
|
182
158
|
getPriceFromPyth(assetCoinName: SupportAssetCoins): Promise<number>;
|
|
159
|
+
/**
|
|
160
|
+
* Get prices from pyth fee object.
|
|
161
|
+
*
|
|
162
|
+
* @param assetCoinNames - Array of supported asset coin names.
|
|
163
|
+
* @return Array of asset coin prices.
|
|
164
|
+
*/
|
|
165
|
+
getPricesFromPyth(assetCoinNames: SupportAssetCoins[]): Promise<Record<SupportAssetCoins, number>>;
|
|
183
166
|
/**
|
|
184
167
|
* Get spools data.
|
|
185
168
|
*
|
|
@@ -382,6 +365,23 @@ export declare class ScallopQuery {
|
|
|
382
365
|
* @return Total value locked.
|
|
383
366
|
*/
|
|
384
367
|
getTvl(indexer?: boolean): Promise<import("../types").TotalValueLocked>;
|
|
368
|
+
/**
|
|
369
|
+
* Get all veSca from walletAdddress
|
|
370
|
+
* @param walletAddress
|
|
371
|
+
* @returns array of veSca
|
|
372
|
+
*/
|
|
373
|
+
getVeScas(walletAddress: string): Promise<(import("../types").Vesca | undefined)[]>;
|
|
374
|
+
/**
|
|
375
|
+
* Get total vesca treasury with movecall
|
|
376
|
+
* @returns Promise<string | undefined>
|
|
377
|
+
*/
|
|
378
|
+
getTotalVeScaTreasuryAmount(): Promise<string>;
|
|
379
|
+
/**
|
|
380
|
+
* Return binded veScaKeyId of walletAddress if exist
|
|
381
|
+
* @param walletAddress
|
|
382
|
+
* @returns veScaKeyId
|
|
383
|
+
*/
|
|
384
|
+
getVeScaKeyIdFromReferralBindings(walletAddress: string): Promise<string | null>;
|
|
385
385
|
/**
|
|
386
386
|
* Get binded obligationId from a veScaKey if it exists.
|
|
387
387
|
* @param veScaKey
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SuiObjectData } from '@mysten/sui.js/client';
|
|
2
2
|
import type { SuiAddressArg } from '@scallop-io/sui-kit';
|
|
3
3
|
import type { ScallopQuery } from '../models';
|
|
4
|
-
import { Market, MarketPool, MarketCollateral, SupportAssetCoins, SupportPoolCoins, SupportCollateralCoins, ObligationQueryInterface, Obligation, SupportMarketCoins } from '../types';
|
|
4
|
+
import { Market, MarketPool, MarketCollateral, SupportAssetCoins, SupportPoolCoins, SupportCollateralCoins, ObligationQueryInterface, Obligation, SupportMarketCoins, OptionalKeys } from '../types';
|
|
5
5
|
/**
|
|
6
6
|
* Query market data.
|
|
7
7
|
*
|
|
@@ -122,20 +122,7 @@ export declare const queryObligation: (query: ScallopQuery, obligationId: SuiAdd
|
|
|
122
122
|
* @param ownerAddress - The owner address.
|
|
123
123
|
* @return All owned coin amounts.
|
|
124
124
|
*/
|
|
125
|
-
export declare const getCoinAmounts: (query: ScallopQuery, assetCoinNames?: SupportAssetCoins[], ownerAddress?: string) => Promise<
|
|
126
|
-
eth?: number | undefined;
|
|
127
|
-
btc?: number | undefined;
|
|
128
|
-
usdc?: number | undefined;
|
|
129
|
-
usdt?: number | undefined;
|
|
130
|
-
sui?: number | undefined;
|
|
131
|
-
apt?: number | undefined;
|
|
132
|
-
sol?: number | undefined;
|
|
133
|
-
cetus?: number | undefined;
|
|
134
|
-
afsui?: number | undefined;
|
|
135
|
-
hasui?: number | undefined;
|
|
136
|
-
vsui?: number | undefined;
|
|
137
|
-
sca?: number | undefined;
|
|
138
|
-
}>;
|
|
125
|
+
export declare const getCoinAmounts: (query: ScallopQuery, assetCoinNames?: SupportAssetCoins[], ownerAddress?: string) => Promise<OptionalKeys<Record<SupportAssetCoins, number>>>;
|
|
139
126
|
/**
|
|
140
127
|
* Query owned coin amount.
|
|
141
128
|
*
|
|
@@ -153,20 +140,7 @@ export declare const getCoinAmount: (query: ScallopQuery, assetCoinName: Support
|
|
|
153
140
|
* @param ownerAddress - The owner address.
|
|
154
141
|
* @return All owned market coins amount.
|
|
155
142
|
*/
|
|
156
|
-
export declare const getMarketCoinAmounts: (query: ScallopQuery, marketCoinNames?: SupportMarketCoins[], ownerAddress?: string) => Promise<
|
|
157
|
-
seth?: number | undefined;
|
|
158
|
-
ssui?: number | undefined;
|
|
159
|
-
susdc?: number | undefined;
|
|
160
|
-
susdt?: number | undefined;
|
|
161
|
-
scetus?: number | undefined;
|
|
162
|
-
safsui?: number | undefined;
|
|
163
|
-
shasui?: number | undefined;
|
|
164
|
-
svsui?: number | undefined;
|
|
165
|
-
sbtc?: number | undefined;
|
|
166
|
-
sapt?: number | undefined;
|
|
167
|
-
ssol?: number | undefined;
|
|
168
|
-
ssca?: number | undefined;
|
|
169
|
-
}>;
|
|
143
|
+
export declare const getMarketCoinAmounts: (query: ScallopQuery, marketCoinNames?: SupportMarketCoins[], ownerAddress?: string) => Promise<OptionalKeys<Record<SupportMarketCoins, number>>>;
|
|
170
144
|
/**
|
|
171
145
|
* Query owned market coin (sCoin) amount.
|
|
172
146
|
*
|
package/dist/queries/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SuiObjectData } from '@mysten/sui.js/src/client';
|
|
1
2
|
import type { ScallopQuery } from '../models';
|
|
2
3
|
import type { SupportAssetCoins } from '../types';
|
|
3
4
|
/**
|
|
@@ -7,4 +8,5 @@ import type { SupportAssetCoins } from '../types';
|
|
|
7
8
|
* @param assetCoinName - Specific support asset coin name.
|
|
8
9
|
* @return Asset coin price.
|
|
9
10
|
*/
|
|
10
|
-
export declare const getPythPrice: (query: ScallopQuery, assetCoinName: SupportAssetCoins) => Promise<number>;
|
|
11
|
+
export declare const getPythPrice: (query: ScallopQuery, assetCoinName: SupportAssetCoins, priceFeedObject?: SuiObjectData | null) => Promise<number>;
|
|
12
|
+
export declare const getPythPrices: (query: ScallopQuery, assetCoinNames: SupportAssetCoins[]) => Promise<Record<SupportAssetCoins, number>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ScallopQuery } from 'src/models';
|
|
2
|
+
/**
|
|
3
|
+
* Query the veScaKeyId from the referral bindings table using the borrower address
|
|
4
|
+
* @param query
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export declare const queryVeScaKeyIdFromReferralBindings: (query: ScallopQuery, refereeAddress: string) => Promise<string | null>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Vesca } from '../types';
|
|
2
|
-
import type
|
|
2
|
+
import { type SuiObjectData } from '@mysten/sui.js/client';
|
|
3
3
|
import type { ScallopQuery } from '../models';
|
|
4
4
|
/**
|
|
5
5
|
* Query all owned veSca key.
|
|
@@ -16,7 +16,7 @@ export declare const getVescaKeys: (query: ScallopQuery, ownerAddress?: string)
|
|
|
16
16
|
* @param ownerAddress - The owner address.
|
|
17
17
|
* @return Owned veScas.
|
|
18
18
|
*/
|
|
19
|
-
export declare const getVeScas: (query: ScallopQuery, ownerAddress?: string) => Promise<Vesca[]>;
|
|
19
|
+
export declare const getVeScas: (query: ScallopQuery, ownerAddress?: string) => Promise<(Vesca | undefined)[]>;
|
|
20
20
|
/**
|
|
21
21
|
* Get veSca data.
|
|
22
22
|
*
|
|
@@ -26,3 +26,7 @@ export declare const getVeScas: (query: ScallopQuery, ownerAddress?: string) =>
|
|
|
26
26
|
* @returns Vesca data.
|
|
27
27
|
*/
|
|
28
28
|
export declare const getVeSca: (query: ScallopQuery, veScaKeyId?: string, ownerAddress?: string) => Promise<Vesca | undefined>;
|
|
29
|
+
/**
|
|
30
|
+
* Get current total veSca treasury amount.
|
|
31
|
+
*/
|
|
32
|
+
export declare const getTotalVeScaTreasuryAmount: (query: ScallopQuery) => Promise<string>;
|
package/dist/types/address.d.ts
CHANGED
|
@@ -48,6 +48,7 @@ export interface AddressesInterface {
|
|
|
48
48
|
id: string;
|
|
49
49
|
adminCap: string;
|
|
50
50
|
object: string;
|
|
51
|
+
config: string;
|
|
51
52
|
pools: Partial<Record<SupportStakeMarketCoins, {
|
|
52
53
|
id: string;
|
|
53
54
|
rewardPoolId: string;
|
|
@@ -64,12 +65,26 @@ export interface AddressesInterface {
|
|
|
64
65
|
};
|
|
65
66
|
vesca: {
|
|
66
67
|
id: string;
|
|
68
|
+
object: string;
|
|
67
69
|
adminCap: string;
|
|
68
70
|
tableId: string;
|
|
69
71
|
table: string;
|
|
70
72
|
treasury: string;
|
|
71
73
|
config: string;
|
|
72
74
|
};
|
|
75
|
+
referral: {
|
|
76
|
+
id: string;
|
|
77
|
+
version: string;
|
|
78
|
+
object: string;
|
|
79
|
+
adminCap: string;
|
|
80
|
+
referralBindings: string;
|
|
81
|
+
bindingTableId: string;
|
|
82
|
+
referralRevenuePool: string;
|
|
83
|
+
revenueTableId: string;
|
|
84
|
+
referralTiers: string;
|
|
85
|
+
tiersTableId: string;
|
|
86
|
+
authorizedWitnessList: string;
|
|
87
|
+
};
|
|
73
88
|
}
|
|
74
89
|
type AddressPathsProps<T> = T extends string ? [] : {
|
|
75
90
|
[K in Extract<keyof T, string>]: [K, ...AddressPathsProps<T[K]>];
|
|
@@ -20,6 +20,7 @@ export type CoreNormalMethods = {
|
|
|
20
20
|
withdraw: (marketCoin: SuiObjectArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
21
21
|
withdrawEntry: (marketCoin: SuiObjectArg, poolCoinName: SupportPoolCoins) => void;
|
|
22
22
|
borrow: (obligation: SuiAddressArg, obligationKey: SuiAddressArg, amount: SuiTxArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
23
|
+
borrowWithReferral: (obligation: SuiAddressArg, obligationKey: SuiAddressArg, borrowReferral: SuiObjectArg, amount: SuiTxArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
23
24
|
borrowEntry: (obligation: SuiAddressArg, obligationKey: SuiAddressArg, amount: SuiTxArg, poolCoinName: SupportPoolCoins) => void;
|
|
24
25
|
repay: (obligation: SuiAddressArg, coin: SuiObjectArg, poolCoinName: SupportPoolCoins) => void;
|
|
25
26
|
borrowFlashLoan: (amount: SuiTxArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
@@ -29,6 +30,7 @@ export type CoreQuickMethods = {
|
|
|
29
30
|
addCollateralQuick: (amount: number, collateralCoinName: SupportCollateralCoins, obligationId?: SuiAddressArg) => Promise<void>;
|
|
30
31
|
takeCollateralQuick: (amount: number, collateralCoinName: SupportCollateralCoins, obligationId?: SuiAddressArg, obligationKey?: SuiAddressArg) => Promise<TransactionResult>;
|
|
31
32
|
borrowQuick: (amount: number, poolCoinName: SupportPoolCoins, obligationId?: SuiAddressArg, obligationKey?: SuiAddressArg) => Promise<TransactionResult>;
|
|
33
|
+
borrowWithReferralQuick: (amount: number, poolCoinName: SupportPoolCoins, borrowReferral: SuiObjectArg, obligationId?: SuiAddressArg, obligationKey?: SuiAddressArg) => Promise<TransactionResult>;
|
|
32
34
|
depositQuick: (amount: number, poolCoinName: SupportPoolCoins) => Promise<TransactionResult>;
|
|
33
35
|
withdrawQuick: (amount: number, poolCoinName: SupportPoolCoins) => Promise<TransactionResult>;
|
|
34
36
|
repayQuick: (amount: number, poolCoinName: SupportPoolCoins, obligationId?: SuiAddressArg) => Promise<void>;
|
|
@@ -2,8 +2,9 @@ import type { CoreTxBlock } from './core';
|
|
|
2
2
|
import type { SpoolTxBlock } from './spool';
|
|
3
3
|
import type { BorrowIncentiveTxBlock } from './borrowIncentive';
|
|
4
4
|
import type { VeScaTxBlock } from './vesca';
|
|
5
|
+
import type { ReferralTxBlock } from './referral';
|
|
5
6
|
export type * from './core';
|
|
6
7
|
export type * from './spool';
|
|
7
8
|
export type * from './borrowIncentive';
|
|
8
9
|
export type * from './vesca';
|
|
9
|
-
export type ScallopTxBlock = CoreTxBlock & SpoolTxBlock & BorrowIncentiveTxBlock & VeScaTxBlock;
|
|
10
|
+
export type ScallopTxBlock = CoreTxBlock & SpoolTxBlock & ReferralTxBlock & BorrowIncentiveTxBlock & VeScaTxBlock;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SuiObjectArg, TransactionResult, SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
2
|
+
import { ScallopBuilder } from 'src/models';
|
|
3
|
+
import { SupportPoolCoins } from '../constant';
|
|
4
|
+
export type ReferralIds = {
|
|
5
|
+
referralPgkId: string;
|
|
6
|
+
referralBindings: string;
|
|
7
|
+
referralRevenuePool: string;
|
|
8
|
+
referralTiers: string;
|
|
9
|
+
authorizedWitnessList: string;
|
|
10
|
+
version: string;
|
|
11
|
+
};
|
|
12
|
+
export type ReferralNormalMethods = {
|
|
13
|
+
bindToReferral: (veScaKeyId: string) => void;
|
|
14
|
+
claimReferralTicket: (poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
15
|
+
burnReferralTicket: (ticket: SuiObjectArg, poolCoinName: SupportPoolCoins) => void;
|
|
16
|
+
claimReferralRevenue: (veScaKey: SuiObjectArg, poolCoinName: SupportPoolCoins) => TransactionResult;
|
|
17
|
+
};
|
|
18
|
+
export type ReferralQuickMethods = {
|
|
19
|
+
claimReferralRevenueQuick: (veScaKey: SuiObjectArg, coinNames: SupportPoolCoins[]) => Promise<void>;
|
|
20
|
+
};
|
|
21
|
+
export type SuiTxBlockWithReferralNormalMethods = SuiKitTxBlock & ReferralNormalMethods;
|
|
22
|
+
export type ReferralTxBlock = SuiTxBlockWithReferralNormalMethods & ReferralQuickMethods;
|
|
23
|
+
export type GenerateReferralNormalMethod = (params: {
|
|
24
|
+
builder: ScallopBuilder;
|
|
25
|
+
txBlock: SuiKitTxBlock;
|
|
26
|
+
}) => ReferralNormalMethods;
|
|
27
|
+
export type GenerateReferralQuickMethod = (params: {
|
|
28
|
+
builder: ScallopBuilder;
|
|
29
|
+
txBlock: SuiTxBlockWithReferralNormalMethods;
|
|
30
|
+
}) => ReferralQuickMethods;
|
|
@@ -13,6 +13,7 @@ export type VeScaNormalMethods = {
|
|
|
13
13
|
extendLockAmount: (veScaKey: SuiObjectArg, scaCoin: SuiObjectArg) => void;
|
|
14
14
|
renewExpiredVeSca: (veScaKey: SuiObjectArg, scaCoin: SuiObjectArg, newUnlockAtInSecondTimestamp: SuiTxArg) => void;
|
|
15
15
|
redeemSca: (veScaKey: SuiObjectArg) => TransactionResult;
|
|
16
|
+
mintEmptyVeSca: () => TransactionResult;
|
|
16
17
|
};
|
|
17
18
|
export type VeScaQuickMethods = {
|
|
18
19
|
lockScaQuick(amountOrCoin?: SuiObjectArg | number, lockPeriodInDays?: number, autoCheck?: boolean): Promise<void>;
|
package/dist/types/model.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { SuiTransactionBlockResponse } from '@mysten/sui.js/client';
|
|
|
2
2
|
import type { TransactionBlock } from '@mysten/sui.js/transactions';
|
|
3
3
|
import type { SuiKit, SuiKitParams, NetworkType } from '@scallop-io/sui-kit';
|
|
4
4
|
import type { ScallopAddress, ScallopQuery, ScallopUtils, ScallopBuilder } from '../models';
|
|
5
|
+
import { ScallopCache } from 'src/models/scallopCache';
|
|
5
6
|
export type ScallopClientFnReturnType<T extends boolean> = T extends true ? SuiTransactionBlockResponse : TransactionBlock;
|
|
6
7
|
export type ScallopInstanceParams = {
|
|
7
8
|
suiKit?: SuiKit;
|
|
@@ -9,6 +10,7 @@ export type ScallopInstanceParams = {
|
|
|
9
10
|
query?: ScallopQuery;
|
|
10
11
|
utils?: ScallopUtils;
|
|
11
12
|
builder?: ScallopBuilder;
|
|
13
|
+
cache: ScallopCache;
|
|
12
14
|
};
|
|
13
15
|
export type ScallopAddressParams = {
|
|
14
16
|
id: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scallop-io/sui-scallop-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.0",
|
|
4
4
|
"description": "Typescript sdk for interacting with Scallop contract on SUI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sui",
|
|
@@ -39,14 +39,16 @@
|
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@mysten/bcs": "^0.8.1",
|
|
42
|
-
"@mysten/sui.js": "^0.
|
|
42
|
+
"@mysten/sui.js": "^0.49.1",
|
|
43
43
|
"@noble/curves": "^1.2.0",
|
|
44
44
|
"@noble/hashes": "^1.3.2",
|
|
45
45
|
"@pythnetwork/price-service-client": "^1.8.2",
|
|
46
|
-
"@pythnetwork/pyth-sui-js": "
|
|
47
|
-
"@scallop-io/sui-kit": "^0.
|
|
46
|
+
"@pythnetwork/pyth-sui-js": "2.0.0",
|
|
47
|
+
"@scallop-io/sui-kit": "^0.45.0",
|
|
48
48
|
"@scure/bip39": "^1.2.1",
|
|
49
|
+
"@tanstack/query-core": "^5.28.0",
|
|
49
50
|
"axios": "^1.6.0",
|
|
51
|
+
"bech32": "^2.0.0",
|
|
50
52
|
"bignumber.js": "^9.1.2",
|
|
51
53
|
"superstruct": "^1.0.3",
|
|
52
54
|
"tweetnacl": "^1.0.3"
|
|
@@ -73,8 +75,8 @@
|
|
|
73
75
|
"vitest": "^0.34.6"
|
|
74
76
|
},
|
|
75
77
|
"peerDependencies": {
|
|
76
|
-
"@mysten/sui.js": "
|
|
77
|
-
"@scallop-io/sui-kit": "^0.44.
|
|
78
|
+
"@mysten/sui.js": "0.49.1",
|
|
79
|
+
"@scallop-io/sui-kit": "^0.44.2"
|
|
78
80
|
},
|
|
79
81
|
"lint-staged": {
|
|
80
82
|
"**/*.ts": [
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { TransactionBlock } from '@mysten/sui.js/transactions';
|
|
2
2
|
import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui.js/utils';
|
|
3
3
|
import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
4
|
-
import { borrowIncentiveRewardCoins } from '../constants/enum';
|
|
5
4
|
import {
|
|
6
5
|
getObligations,
|
|
7
6
|
getObligationLocked,
|
|
@@ -9,7 +8,7 @@ import {
|
|
|
9
8
|
} from '../queries';
|
|
10
9
|
import { requireSender } from '../utils';
|
|
11
10
|
import type { SuiObjectArg } from '@scallop-io/sui-kit';
|
|
12
|
-
import type { ScallopBuilder } from '
|
|
11
|
+
import type { ScallopBuilder } from 'src/models';
|
|
13
12
|
import type {
|
|
14
13
|
BorrowIncentiveIds,
|
|
15
14
|
GenerateBorrowIncentiveNormalMethod,
|
|
@@ -20,10 +19,7 @@ import type {
|
|
|
20
19
|
VescaIds,
|
|
21
20
|
} from '../types';
|
|
22
21
|
import { requireVeSca } from './vescaBuilder';
|
|
23
|
-
import {
|
|
24
|
-
IS_VE_SCA_TEST,
|
|
25
|
-
OLD_BORROW_INCENTIVE_PROTOCOL_ID,
|
|
26
|
-
} from 'src/constants';
|
|
22
|
+
import { OLD_BORROW_INCENTIVE_PROTOCOL_ID } from 'src/constants';
|
|
27
23
|
|
|
28
24
|
/**
|
|
29
25
|
* Check and get Obligation information from transaction block.
|
|
@@ -89,9 +85,7 @@ const requireObligationInfo = async (
|
|
|
89
85
|
const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
|
|
90
86
|
({ builder, txBlock }) => {
|
|
91
87
|
const borrowIncentiveIds: BorrowIncentiveIds = {
|
|
92
|
-
borrowIncentivePkg:
|
|
93
|
-
? '0x4d5a7cefa4147b4ace0ca845b20437d6ac0d32e5f2f855171f745472c2576246'
|
|
94
|
-
: builder.address.get('borrowIncentive.id'),
|
|
88
|
+
borrowIncentivePkg: builder.address.get('borrowIncentive.id'),
|
|
95
89
|
query: builder.address.get('borrowIncentive.query'),
|
|
96
90
|
config: builder.address.get('borrowIncentive.config'),
|
|
97
91
|
incentivePools: builder.address.get('borrowIncentive.incentivePools'),
|
|
@@ -160,7 +154,8 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
|
|
|
160
154
|
coinName,
|
|
161
155
|
rewardCoinName
|
|
162
156
|
) => {
|
|
163
|
-
const rewardCoinNames =
|
|
157
|
+
const rewardCoinNames =
|
|
158
|
+
builder.utils.getBorrowIncentiveRewardCoinName(coinName);
|
|
164
159
|
if (rewardCoinNames.includes(rewardCoinName) === false) {
|
|
165
160
|
throw new Error(`Invalid reward coin name ${rewardCoinName}`);
|
|
166
161
|
}
|
|
@@ -228,11 +223,7 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
|
228
223
|
(txn.target ===
|
|
229
224
|
`${OLD_BORROW_INCENTIVE_PROTOCOL_ID}::user::unstake` ||
|
|
230
225
|
txn.target ===
|
|
231
|
-
(
|
|
232
|
-
? `${'0x4d5a7cefa4147b4ace0ca845b20437d6ac0d32e5f2f855171f745472c2576246'}::user::unstake`
|
|
233
|
-
: `${builder.address.get(
|
|
234
|
-
'borrowIncentive.id'
|
|
235
|
-
)}::user::unstake`))
|
|
226
|
+
`${builder.address.get('borrowIncentive.id')}::user::unstake`)
|
|
236
227
|
);
|
|
237
228
|
|
|
238
229
|
if (!obligationLocked || unstakeObligationBeforeStake) {
|
|
@@ -262,11 +253,7 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
|
262
253
|
(txn.target ===
|
|
263
254
|
`${OLD_BORROW_INCENTIVE_PROTOCOL_ID}::user::unstake` ||
|
|
264
255
|
txn.target ===
|
|
265
|
-
(
|
|
266
|
-
? `${'0x4d5a7cefa4147b4ace0ca845b20437d6ac0d32e5f2f855171f745472c2576246'}::user::unstake`
|
|
267
|
-
: `${builder.address.get(
|
|
268
|
-
'borrowIncentive.id'
|
|
269
|
-
)}::user::unstake`))
|
|
256
|
+
`${builder.address.get('borrowIncentive.id')}::user::unstake`)
|
|
270
257
|
);
|
|
271
258
|
|
|
272
259
|
if (!obligationLocked || unstakeObligationBeforeStake) {
|
|
@@ -276,8 +263,12 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
|
276
263
|
builder.query,
|
|
277
264
|
veSca.keyId
|
|
278
265
|
);
|
|
266
|
+
|
|
279
267
|
// if bindedObligationId is equal to obligationId, then use it again
|
|
280
|
-
if (
|
|
268
|
+
if (
|
|
269
|
+
(!bindedObligationId || bindedObligationId === obligationArg) &&
|
|
270
|
+
veSca.currentVeScaBalance > 0
|
|
271
|
+
) {
|
|
281
272
|
txBlock.stakeObligationWithVesca(
|
|
282
273
|
obligationArg,
|
|
283
274
|
obligationtKeyArg,
|