@scallop-io/sui-scallop-sdk 0.45.0 → 0.46.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 +1 -1
- package/dist/builders/referralBuilder.d.ts +12 -0
- package/dist/constants/common.d.ts +1 -1
- package/dist/index.js +533 -279
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +587 -329
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopCache.d.ts +6 -2
- package/dist/models/scallopQuery.d.ts +26 -28
- 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/package.json +7 -6
- package/src/builders/borrowIncentiveBuilder.ts +10 -19
- 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/common.ts +9 -2
- package/src/constants/vesca.ts +1 -3
- package/src/models/scallopAddress.ts +63 -19
- package/src/models/scallopCache.ts +42 -2
- package/src/models/scallopQuery.ts +40 -0
- package/src/models/scallopUtils.ts +35 -35
- package/src/queries/borrowIncentiveQuery.ts +2 -5
- package/src/queries/coreQuery.ts +33 -197
- package/src/queries/index.ts +1 -0
- package/src/queries/priceQuery.ts +48 -7
- package/src/queries/referralQuery.ts +27 -0
- package/src/queries/spoolQuery.ts +8 -12
- package/src/queries/vescaQuery.ts +94 -15
- 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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { QueryClient, QueryClientConfig } from '@tanstack/query-core';
|
|
2
2
|
import { SuiTxArg } from '@scallop-io/sui-kit';
|
|
3
3
|
import { SuiKit } from '@scallop-io/sui-kit';
|
|
4
|
-
import type { SuiObjectResponse, SuiObjectDataOptions, SuiObjectData, PaginatedObjectsResponse, GetOwnedObjectsParams, DevInspectResults, GetDynamicFieldsParams, DynamicFieldPage, GetDynamicFieldObjectParams } from '@mysten/sui.js/client';
|
|
4
|
+
import type { SuiObjectResponse, SuiObjectDataOptions, SuiObjectData, PaginatedObjectsResponse, GetOwnedObjectsParams, DevInspectResults, GetDynamicFieldsParams, DynamicFieldPage, GetDynamicFieldObjectParams, GetBalanceParams } from '@mysten/sui.js/client';
|
|
5
5
|
type QueryInspectTxnParams = {
|
|
6
6
|
queryTarget: string;
|
|
7
7
|
args: SuiTxArg[];
|
|
@@ -38,7 +38,7 @@ export declare class ScallopCache {
|
|
|
38
38
|
* @description Cache protocol config call for 60 seconds.
|
|
39
39
|
* @returns Promise<ProtocolConfig>
|
|
40
40
|
*/
|
|
41
|
-
|
|
41
|
+
getProtocolConfig(): Promise<import("@mysten/sui.js/client").ProtocolConfig>;
|
|
42
42
|
/**
|
|
43
43
|
* @description Provides cache for inspectTxn of the SuiKit.
|
|
44
44
|
* @param QueryInspectTxnParams
|
|
@@ -67,5 +67,9 @@ export declare class ScallopCache {
|
|
|
67
67
|
queryGetOwnedObjects(input: GetOwnedObjectsParams): Promise<PaginatedObjectsResponse>;
|
|
68
68
|
queryGetDynamicFields(input: GetDynamicFieldsParams): Promise<DynamicFieldPage>;
|
|
69
69
|
queryGetDynamicFieldObject(input: GetDynamicFieldObjectParams): Promise<SuiObjectResponse>;
|
|
70
|
+
queryGetAllCoinBalances(owner: string): Promise<{
|
|
71
|
+
[k: string]: string;
|
|
72
|
+
}>;
|
|
73
|
+
queryGetCoinBalance(input: GetBalanceParams): Promise<string>;
|
|
70
74
|
}
|
|
71
75
|
export {};
|
|
@@ -124,20 +124,7 @@ export declare class ScallopQuery {
|
|
|
124
124
|
* @param ownerAddress - The owner address.
|
|
125
125
|
* @return All coin amounts.
|
|
126
126
|
*/
|
|
127
|
-
getCoinAmounts(assetCoinNames?: SupportAssetCoins[], ownerAddress?: string): Promise<
|
|
128
|
-
eth?: number | undefined;
|
|
129
|
-
btc?: number | undefined;
|
|
130
|
-
usdc?: number | undefined;
|
|
131
|
-
usdt?: number | undefined;
|
|
132
|
-
sui?: number | undefined;
|
|
133
|
-
apt?: number | undefined;
|
|
134
|
-
sol?: number | undefined;
|
|
135
|
-
cetus?: number | undefined;
|
|
136
|
-
afsui?: number | undefined;
|
|
137
|
-
hasui?: number | undefined;
|
|
138
|
-
vsui?: number | undefined;
|
|
139
|
-
sca?: number | undefined;
|
|
140
|
-
}>;
|
|
127
|
+
getCoinAmounts(assetCoinNames?: SupportAssetCoins[], ownerAddress?: string): Promise<import("../types").OptionalKeys<Record<SupportAssetCoins, number>>>;
|
|
141
128
|
/**
|
|
142
129
|
* Get asset coin amount.
|
|
143
130
|
*
|
|
@@ -153,20 +140,7 @@ export declare class ScallopQuery {
|
|
|
153
140
|
* @param ownerAddress - The owner address.
|
|
154
141
|
* @return All market market coin amounts.
|
|
155
142
|
*/
|
|
156
|
-
getMarketCoinAmounts(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
|
+
getMarketCoinAmounts(marketCoinNames?: SupportMarketCoins[], ownerAddress?: string): Promise<import("../types").OptionalKeys<Record<SupportMarketCoins, number>>>;
|
|
170
144
|
/**
|
|
171
145
|
* Get market coin amount.
|
|
172
146
|
*
|
|
@@ -182,6 +156,13 @@ export declare class ScallopQuery {
|
|
|
182
156
|
* @return Asset coin price.
|
|
183
157
|
*/
|
|
184
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>>;
|
|
185
166
|
/**
|
|
186
167
|
* Get spools data.
|
|
187
168
|
*
|
|
@@ -384,6 +365,23 @@ export declare class ScallopQuery {
|
|
|
384
365
|
* @return Total value locked.
|
|
385
366
|
*/
|
|
386
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>;
|
|
387
385
|
/**
|
|
388
386
|
* Get binded obligationId from a veScaKey if it exists.
|
|
389
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scallop-io/sui-scallop-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.1",
|
|
4
4
|
"description": "Typescript sdk for interacting with Scallop contract on SUI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sui",
|
|
@@ -39,15 +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
49
|
"@tanstack/query-core": "^5.28.0",
|
|
50
50
|
"axios": "^1.6.0",
|
|
51
|
+
"bech32": "^2.0.0",
|
|
51
52
|
"bignumber.js": "^9.1.2",
|
|
52
53
|
"superstruct": "^1.0.3",
|
|
53
54
|
"tweetnacl": "^1.0.3"
|
|
@@ -74,8 +75,8 @@
|
|
|
74
75
|
"vitest": "^0.34.6"
|
|
75
76
|
},
|
|
76
77
|
"peerDependencies": {
|
|
77
|
-
"@mysten/sui.js": "
|
|
78
|
-
"@scallop-io/sui-kit": "^0.44.
|
|
78
|
+
"@mysten/sui.js": "0.49.1",
|
|
79
|
+
"@scallop-io/sui-kit": "^0.44.2"
|
|
79
80
|
},
|
|
80
81
|
"lint-staged": {
|
|
81
82
|
"**/*.ts": [
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from '../queries';
|
|
9
9
|
import { requireSender } from '../utils';
|
|
10
10
|
import type { SuiObjectArg } from '@scallop-io/sui-kit';
|
|
11
|
-
import type { ScallopBuilder } from '
|
|
11
|
+
import type { ScallopBuilder } from 'src/models';
|
|
12
12
|
import type {
|
|
13
13
|
BorrowIncentiveIds,
|
|
14
14
|
GenerateBorrowIncentiveNormalMethod,
|
|
@@ -19,10 +19,7 @@ import type {
|
|
|
19
19
|
VescaIds,
|
|
20
20
|
} from '../types';
|
|
21
21
|
import { requireVeSca } from './vescaBuilder';
|
|
22
|
-
import {
|
|
23
|
-
IS_VE_SCA_TEST,
|
|
24
|
-
OLD_BORROW_INCENTIVE_PROTOCOL_ID,
|
|
25
|
-
} from 'src/constants';
|
|
22
|
+
import { OLD_BORROW_INCENTIVE_PROTOCOL_ID } from 'src/constants';
|
|
26
23
|
|
|
27
24
|
/**
|
|
28
25
|
* Check and get Obligation information from transaction block.
|
|
@@ -88,9 +85,7 @@ const requireObligationInfo = async (
|
|
|
88
85
|
const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
|
|
89
86
|
({ builder, txBlock }) => {
|
|
90
87
|
const borrowIncentiveIds: BorrowIncentiveIds = {
|
|
91
|
-
borrowIncentivePkg:
|
|
92
|
-
? '0x4d5a7cefa4147b4ace0ca845b20437d6ac0d32e5f2f855171f745472c2576246'
|
|
93
|
-
: builder.address.get('borrowIncentive.id'),
|
|
88
|
+
borrowIncentivePkg: builder.address.get('borrowIncentive.id'),
|
|
94
89
|
query: builder.address.get('borrowIncentive.query'),
|
|
95
90
|
config: builder.address.get('borrowIncentive.config'),
|
|
96
91
|
incentivePools: builder.address.get('borrowIncentive.incentivePools'),
|
|
@@ -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,
|
|
@@ -70,6 +70,10 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
70
70
|
coinDecimalsRegistry: builder.address.get('core.coinDecimalsRegistry'),
|
|
71
71
|
xOracle: builder.address.get('core.oracles.xOracle'),
|
|
72
72
|
};
|
|
73
|
+
|
|
74
|
+
const referralPkgId = builder.address.get('referral.id');
|
|
75
|
+
const referralWitnessType = `${referralPkgId}::scallop_referral_program::REFERRAL_WITNESS`;
|
|
76
|
+
|
|
73
77
|
return {
|
|
74
78
|
openObligation: () =>
|
|
75
79
|
txBlock.moveCall(
|
|
@@ -160,6 +164,30 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
|
|
|
160
164
|
[coinType]
|
|
161
165
|
);
|
|
162
166
|
},
|
|
167
|
+
borrowWithReferral: (
|
|
168
|
+
obligation,
|
|
169
|
+
obligationKey,
|
|
170
|
+
borrowReferral,
|
|
171
|
+
amount,
|
|
172
|
+
poolCoinName
|
|
173
|
+
) => {
|
|
174
|
+
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
175
|
+
return txBlock.moveCall(
|
|
176
|
+
`${coreIds.protocolPkg}::borrow::borrow_with_referral`,
|
|
177
|
+
[
|
|
178
|
+
coreIds.version,
|
|
179
|
+
obligation,
|
|
180
|
+
obligationKey,
|
|
181
|
+
coreIds.market,
|
|
182
|
+
coreIds.coinDecimalsRegistry,
|
|
183
|
+
borrowReferral,
|
|
184
|
+
amount,
|
|
185
|
+
coreIds.xOracle,
|
|
186
|
+
SUI_CLOCK_OBJECT_ID,
|
|
187
|
+
],
|
|
188
|
+
[coinType, referralWitnessType]
|
|
189
|
+
);
|
|
190
|
+
},
|
|
163
191
|
borrowEntry: (obligation, obligationKey, amount, poolCoinName) => {
|
|
164
192
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
165
193
|
return txBlock.moveCall(
|
|
@@ -319,6 +347,32 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
|
|
|
319
347
|
poolCoinName
|
|
320
348
|
);
|
|
321
349
|
},
|
|
350
|
+
borrowWithReferralQuick: async (
|
|
351
|
+
amount,
|
|
352
|
+
poolCoinName,
|
|
353
|
+
borrowReferral,
|
|
354
|
+
obligationId,
|
|
355
|
+
obligationKey
|
|
356
|
+
) => {
|
|
357
|
+
const obligationInfo = await requireObligationInfo(
|
|
358
|
+
builder,
|
|
359
|
+
txBlock,
|
|
360
|
+
obligationId,
|
|
361
|
+
obligationKey
|
|
362
|
+
);
|
|
363
|
+
const obligationCoinNames = await builder.utils.getObligationCoinNames(
|
|
364
|
+
obligationInfo.obligationId
|
|
365
|
+
);
|
|
366
|
+
const updateCoinNames = [...obligationCoinNames, poolCoinName];
|
|
367
|
+
await updateOracles(builder, txBlock, updateCoinNames);
|
|
368
|
+
return txBlock.borrowWithReferral(
|
|
369
|
+
obligationInfo.obligationId,
|
|
370
|
+
obligationInfo.obligationKey as SuiAddressArg,
|
|
371
|
+
borrowReferral,
|
|
372
|
+
amount,
|
|
373
|
+
poolCoinName
|
|
374
|
+
);
|
|
375
|
+
},
|
|
322
376
|
repayQuick: async (amount, poolCoinName, obligationId) => {
|
|
323
377
|
const sender = requireSender(txBlock);
|
|
324
378
|
const obligationInfo = await requireObligationInfo(
|
package/src/builders/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { newBorrowIncentiveTxBlock } from './borrowIncentiveBuilder';
|
|
|
6
6
|
import { newVeScaTxBlock } from './vescaBuilder';
|
|
7
7
|
import type { ScallopBuilder } from '../models';
|
|
8
8
|
import type { ScallopTxBlock } from '../types';
|
|
9
|
+
import { newReferralTxBlock } from './referralBuilder';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Create a new ScallopTxBlock instance.
|
|
@@ -23,15 +24,17 @@ export const newScallopTxBlock = (
|
|
|
23
24
|
builder,
|
|
24
25
|
vescaTxBlock
|
|
25
26
|
);
|
|
26
|
-
const
|
|
27
|
+
const referralTxBlock = newReferralTxBlock(builder, borrowIncentiveTxBlock);
|
|
28
|
+
const spoolTxBlock = newSpoolTxBlock(builder, referralTxBlock);
|
|
27
29
|
const coreTxBlock = newCoreTxBlock(builder, spoolTxBlock);
|
|
28
|
-
|
|
29
30
|
return new Proxy(coreTxBlock, {
|
|
30
31
|
get: (target, prop) => {
|
|
31
32
|
if (prop in vescaTxBlock) {
|
|
32
33
|
return Reflect.get(vescaTxBlock, prop);
|
|
33
34
|
} else if (prop in borrowIncentiveTxBlock) {
|
|
34
35
|
return Reflect.get(borrowIncentiveTxBlock, prop);
|
|
36
|
+
} else if (prop in referralTxBlock) {
|
|
37
|
+
return Reflect.get(referralTxBlock, prop);
|
|
35
38
|
} else if (prop in spoolTxBlock) {
|
|
36
39
|
return Reflect.get(spoolTxBlock, prop);
|
|
37
40
|
}
|