@scallop-io/sui-scallop-sdk 0.46.55 → 0.46.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants/common.d.ts +1 -1
- package/dist/constants/pyth.d.ts +1 -1
- package/dist/index.js +1752 -1602
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1720 -1570
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallop.d.ts +1 -1
- package/dist/models/scallopAddress.d.ts +4 -4
- package/dist/models/scallopBuilder.d.ts +2 -2
- package/dist/models/scallopCache.d.ts +2 -2
- package/dist/models/scallopClient.d.ts +7 -2
- package/dist/models/scallopIndexer.d.ts +3 -3
- package/dist/models/scallopPrice.d.ts +0 -0
- package/dist/models/scallopQuery.d.ts +10 -4
- package/dist/models/scallopUtils.d.ts +8 -7
- package/dist/queries/borrowIncentiveQuery.d.ts +10 -4
- package/dist/queries/coreQuery.d.ts +8 -4
- package/dist/queries/priceQuery.d.ts +7 -3
- package/dist/queries/referralQuery.d.ts +2 -2
- package/dist/queries/sCoinQuery.d.ts +18 -4
- package/dist/queries/spoolQuery.d.ts +10 -4
- package/dist/queries/vescaQuery.d.ts +7 -5
- package/dist/types/builder/vesca.d.ts +2 -1
- package/dist/types/model.d.ts +27 -12
- package/dist/types/query/core.d.ts +1 -0
- package/package.json +1 -1
- package/src/builders/borrowIncentiveBuilder.ts +19 -21
- package/src/builders/coreBuilder.ts +10 -8
- package/src/builders/spoolBuilder.ts +2 -2
- package/src/builders/vescaBuilder.ts +12 -4
- package/src/constants/common.ts +2 -0
- package/src/constants/enum.ts +4 -0
- package/src/constants/pyth.ts +2 -2
- package/src/models/scallop.ts +14 -20
- package/src/models/scallopAddress.ts +15 -5
- package/src/models/scallopBuilder.ts +29 -25
- package/src/models/scallopCache.ts +2 -2
- package/src/models/scallopClient.ts +91 -32
- package/src/models/scallopIndexer.ts +15 -8
- package/src/models/scallopPrice.ts +0 -0
- package/src/models/scallopQuery.ts +47 -25
- package/src/models/scallopUtils.ts +75 -74
- package/src/queries/borrowIncentiveQuery.ts +40 -29
- package/src/queries/coreQuery.ts +38 -24
- package/src/queries/portfolioQuery.ts +1 -2
- package/src/queries/priceQuery.ts +20 -9
- package/src/queries/referralQuery.ts +4 -4
- package/src/queries/sCoinQuery.ts +95 -17
- package/src/queries/spoolQuery.ts +26 -14
- package/src/queries/vescaQuery.ts +32 -26
- package/src/types/builder/vesca.ts +8 -1
- package/src/types/model.ts +40 -11
- package/src/types/query/core.ts +1 -0
package/dist/models/scallop.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export declare class Scallop {
|
|
|
30
30
|
params: ScallopParams;
|
|
31
31
|
suiKit: SuiKit;
|
|
32
32
|
cache: ScallopCache;
|
|
33
|
-
private
|
|
33
|
+
private address;
|
|
34
34
|
constructor(params: ScallopParams, cacheOptions?: QueryClientConfig, tokenBucket?: TokenBucket);
|
|
35
35
|
/**
|
|
36
36
|
* Get a scallop address instance that already has read addresses.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { ScallopAddressParams, AddressesInterface, AddressStringPath } from '../types';
|
|
1
|
+
import { type NetworkType } from '@scallop-io/sui-kit';
|
|
2
|
+
import type { ScallopAddressParams, AddressesInterface, AddressStringPath, ScallopAddressInstanceParams } from '../types';
|
|
3
3
|
import { ScallopCache } from './scallopCache';
|
|
4
4
|
/**
|
|
5
5
|
* @description
|
|
@@ -19,8 +19,8 @@ export declare class ScallopAddress {
|
|
|
19
19
|
private _network;
|
|
20
20
|
private _currentAddresses?;
|
|
21
21
|
private _addressesMap;
|
|
22
|
-
|
|
23
|
-
constructor(params: ScallopAddressParams,
|
|
22
|
+
cache: ScallopCache;
|
|
23
|
+
constructor(params: ScallopAddressParams, instance?: ScallopAddressInstanceParams);
|
|
24
24
|
/**
|
|
25
25
|
* Get addresses API id.
|
|
26
26
|
*
|
|
@@ -5,7 +5,7 @@ import { ScallopUtils } from './scallopUtils';
|
|
|
5
5
|
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
|
-
import type {
|
|
8
|
+
import type { ScallopBuilderParams, ScallopTxBlock, SupportMarketCoins, SupportAssetCoins, SupportSCoin, ScallopBuilderInstanceParams } from '../types';
|
|
9
9
|
import { ScallopCache } from './scallopCache';
|
|
10
10
|
/**
|
|
11
11
|
* @description
|
|
@@ -27,7 +27,7 @@ export declare class ScallopBuilder {
|
|
|
27
27
|
utils: ScallopUtils;
|
|
28
28
|
walletAddress: string;
|
|
29
29
|
cache: ScallopCache;
|
|
30
|
-
constructor(params: ScallopBuilderParams, instance?:
|
|
30
|
+
constructor(params: ScallopBuilderParams, instance?: ScallopBuilderInstanceParams);
|
|
31
31
|
/**
|
|
32
32
|
* Request the scallop API to initialize data.
|
|
33
33
|
*
|
|
@@ -22,9 +22,9 @@ type QueryInspectTxnParams = {
|
|
|
22
22
|
*/
|
|
23
23
|
export declare class ScallopCache {
|
|
24
24
|
readonly queryClient: QueryClient;
|
|
25
|
-
readonly _suiKit
|
|
25
|
+
readonly _suiKit: SuiKit;
|
|
26
26
|
private tokenBucket;
|
|
27
|
-
constructor(
|
|
27
|
+
constructor(suiKit: SuiKit, cacheOptions?: QueryClientConfig, tokenBucket?: TokenBucket);
|
|
28
28
|
private get suiKit();
|
|
29
29
|
private get client();
|
|
30
30
|
/**
|
|
@@ -7,7 +7,7 @@ import { ScallopCache } from './scallopCache';
|
|
|
7
7
|
import type { SuiTransactionBlockResponse } from '@mysten/sui.js/client';
|
|
8
8
|
import type { TransactionObjectArgument } from '@mysten/sui.js/transactions';
|
|
9
9
|
import type { SuiObjectArg } from '@scallop-io/sui-kit';
|
|
10
|
-
import type { ScallopClientFnReturnType,
|
|
10
|
+
import type { ScallopClientFnReturnType, ScallopClientParams, SupportPoolCoins, SupportCollateralCoins, SupportAssetCoins, SupportStakeCoins, SupportStakeMarketCoins, SupportBorrowIncentiveCoins, ScallopTxBlock, ScallopClientVeScaReturnType, ScallopClientInstanceParams } from '../types';
|
|
11
11
|
/**
|
|
12
12
|
* @description
|
|
13
13
|
* It provides contract interaction operations for general users.
|
|
@@ -29,7 +29,7 @@ export declare class ScallopClient {
|
|
|
29
29
|
utils: ScallopUtils;
|
|
30
30
|
cache: ScallopCache;
|
|
31
31
|
walletAddress: string;
|
|
32
|
-
constructor(params: ScallopClientParams, instance?:
|
|
32
|
+
constructor(params: ScallopClientParams, instance?: ScallopClientInstanceParams);
|
|
33
33
|
/**
|
|
34
34
|
* Request the scallop API to initialize data.
|
|
35
35
|
*
|
|
@@ -299,6 +299,11 @@ export declare class ScallopClient {
|
|
|
299
299
|
* @returns Transaction response
|
|
300
300
|
*/
|
|
301
301
|
migrateAllMarketCoin<S extends boolean>(sign?: S): Promise<ScallopClientFnReturnType<S>>;
|
|
302
|
+
/**
|
|
303
|
+
* Claim unlocked SCA from all veSCA accounts.
|
|
304
|
+
*/
|
|
305
|
+
claimAllUnlockedSca(): Promise<SuiTransactionBlockResponse>;
|
|
306
|
+
claimAllUnlockedSca<S extends boolean>(sign?: S): Promise<ScallopClientVeScaReturnType<S>>;
|
|
302
307
|
/**
|
|
303
308
|
* Mint and get test coin.
|
|
304
309
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Market, MarketPools, MarketPool, MarketCollaterals, MarketCollateral, Spools, Spool, BorrowIncentivePools, BorrowIncentivePool, SupportPoolCoins, SupportCollateralCoins, SupportStakeMarketCoins, SupportBorrowIncentiveCoins, TotalValueLocked, ScallopQueryParams, ScallopParams,
|
|
1
|
+
import type { Market, MarketPools, MarketPool, MarketCollaterals, MarketCollateral, Spools, Spool, BorrowIncentivePools, BorrowIncentivePool, SupportPoolCoins, SupportCollateralCoins, SupportStakeMarketCoins, SupportBorrowIncentiveCoins, TotalValueLocked, ScallopQueryParams, ScallopParams, ScallopIndexerInstanceParams } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* @description
|
|
4
4
|
* It provides methods to obtain sdk index data from mainnet.
|
|
@@ -12,10 +12,10 @@ import type { Market, MarketPools, MarketPool, MarketCollaterals, MarketCollater
|
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
14
|
export declare class ScallopIndexer {
|
|
15
|
-
private readonly
|
|
15
|
+
private readonly cache;
|
|
16
16
|
readonly params: ScallopQueryParams;
|
|
17
17
|
private readonly _requestClient;
|
|
18
|
-
constructor(params: ScallopParams, instance?:
|
|
18
|
+
constructor(params: ScallopParams, instance?: ScallopIndexerInstanceParams);
|
|
19
19
|
/**
|
|
20
20
|
* Get market index data.
|
|
21
21
|
*
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SuiKit } from '@scallop-io/sui-kit';
|
|
2
|
-
import { ScallopQueryParams,
|
|
2
|
+
import { ScallopQueryParams, SupportStakeMarketCoins, SupportAssetCoins, SupportPoolCoins, SupportCollateralCoins, SupportMarketCoins, SupportBorrowIncentiveCoins, SupportSCoin, ScallopQueryInstanceParams } from '../types';
|
|
3
3
|
import { ScallopAddress } from './scallopAddress';
|
|
4
4
|
import { ScallopUtils } from './scallopUtils';
|
|
5
5
|
import { ScallopIndexer } from './scallopIndexer';
|
|
@@ -25,7 +25,7 @@ export declare class ScallopQuery {
|
|
|
25
25
|
indexer: ScallopIndexer;
|
|
26
26
|
cache: ScallopCache;
|
|
27
27
|
walletAddress: string;
|
|
28
|
-
constructor(params: ScallopQueryParams, instance?:
|
|
28
|
+
constructor(params: ScallopQueryParams, instance?: ScallopQueryInstanceParams);
|
|
29
29
|
/**
|
|
30
30
|
* Request the scallop API to initialize data.
|
|
31
31
|
*
|
|
@@ -383,7 +383,7 @@ export declare class ScallopQuery {
|
|
|
383
383
|
* @param walletAddress
|
|
384
384
|
* @returns veScaKeyId
|
|
385
385
|
*/
|
|
386
|
-
getVeScaKeyIdFromReferralBindings(walletAddress
|
|
386
|
+
getVeScaKeyIdFromReferralBindings(walletAddress?: string): Promise<string | null>;
|
|
387
387
|
/**
|
|
388
388
|
* Get binded obligationId from a veScaKey if it exists.
|
|
389
389
|
* @param veScaKey
|
|
@@ -415,7 +415,7 @@ export declare class ScallopQuery {
|
|
|
415
415
|
* @param ownerAddress - The owner address.
|
|
416
416
|
* @return All market sCoin amounts.
|
|
417
417
|
*/
|
|
418
|
-
getSCoinAmounts(sCoinNames?: SupportSCoin[], ownerAddress?: string): Promise<import("../types").OptionalKeys<Record<"seth" | "ssui" | "susdc" | "susdt" | "scetus" | "safsui" | "shasui" | "svsui" | "ssca", number>>>;
|
|
418
|
+
getSCoinAmounts(sCoinNames?: SupportSCoin[], ownerAddress?: string): Promise<import("../types").OptionalKeys<Record<"seth" | "ssui" | "susdc" | "susdt" | "scetus" | "safsui" | "shasui" | "svsui" | "ssca" | "ssol" | "sbtc", number>>>;
|
|
419
419
|
/**
|
|
420
420
|
* Get sCoin amount.
|
|
421
421
|
*
|
|
@@ -424,5 +424,11 @@ export declare class ScallopQuery {
|
|
|
424
424
|
* @return sCoin amount.
|
|
425
425
|
*/
|
|
426
426
|
getSCoinAmount(sCoinName: SupportSCoin | SupportMarketCoins, ownerAddress?: string): Promise<number>;
|
|
427
|
+
/**
|
|
428
|
+
* Get swap rate from sCoin A to sCoin B
|
|
429
|
+
* @param assetCoinNames
|
|
430
|
+
* @returns
|
|
431
|
+
*/
|
|
432
|
+
getSCoinSwapRate(fromSCoin: SupportSCoin, toSCoin: SupportSCoin): Promise<number>;
|
|
427
433
|
getFlashLoanFees(assetCoinNames?: SupportAssetCoins[]): Promise<Record<"eth" | "btc" | "usdc" | "usdt" | "sui" | "apt" | "sol" | "cetus" | "afsui" | "hasui" | "vsui" | "sca", number>>;
|
|
428
434
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { SuiKit } from '@scallop-io/sui-kit';
|
|
1
2
|
import { ScallopAddress } from './scallopAddress';
|
|
2
|
-
import
|
|
3
|
+
import { ScallopCache } from './scallopCache';
|
|
4
|
+
import type { ScallopUtilsParams, SupportCoins, SupportAssetCoins, SupportMarketCoins, SupportStakeMarketCoins, SupportBorrowIncentiveCoins, CoinWrappedType, SupportSCoin, ScallopUtilsInstanceParams } from '../types';
|
|
3
5
|
import type { SuiAddressArg, SuiTxArg, SuiTxBlock } from '@scallop-io/sui-kit';
|
|
4
6
|
/**
|
|
5
7
|
* @description
|
|
@@ -16,12 +18,11 @@ import type { SuiAddressArg, SuiTxArg, SuiTxBlock } from '@scallop-io/sui-kit';
|
|
|
16
18
|
export declare class ScallopUtils {
|
|
17
19
|
readonly params: ScallopUtilsParams;
|
|
18
20
|
readonly isTestnet: boolean;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
suiKit: SuiKit;
|
|
22
|
+
address: ScallopAddress;
|
|
23
|
+
cache: ScallopCache;
|
|
22
24
|
private _priceMap;
|
|
23
|
-
|
|
24
|
-
constructor(params: ScallopUtilsParams, instance?: ScallopInstanceParams);
|
|
25
|
+
constructor(params: ScallopUtilsParams, instance?: ScallopUtilsInstanceParams);
|
|
25
26
|
/**
|
|
26
27
|
* Request the scallop API to initialize data.
|
|
27
28
|
*
|
|
@@ -166,7 +167,7 @@ export declare class ScallopUtils {
|
|
|
166
167
|
* @param obligationId - The obligation id.
|
|
167
168
|
* @return Asset coin Names.
|
|
168
169
|
*/
|
|
169
|
-
getObligationCoinNames(obligationId: SuiAddressArg): Promise<SupportAssetCoins[]>;
|
|
170
|
+
getObligationCoinNames(obligationId: SuiAddressArg): Promise<SupportAssetCoins[] | undefined>;
|
|
170
171
|
/**
|
|
171
172
|
* Get asset coin price.
|
|
172
173
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ScallopQuery } from '../models';
|
|
1
|
+
import type { ScallopAddress, ScallopQuery, ScallopUtils } from '../models';
|
|
2
2
|
import type { SupportBorrowIncentiveCoins } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Query borrow incentive pools data.
|
|
@@ -25,7 +25,9 @@ export declare const queryBorrowIncentivePools: (query: ScallopQuery, borrowInce
|
|
|
25
25
|
* @param borrowIncentiveCoinNames - Specific an array of support borrow incentive coin name.
|
|
26
26
|
* @return Borrow incentive accounts data.
|
|
27
27
|
*/
|
|
28
|
-
export declare const queryBorrowIncentiveAccounts: (
|
|
28
|
+
export declare const queryBorrowIncentiveAccounts: ({ utils, }: {
|
|
29
|
+
utils: ScallopUtils;
|
|
30
|
+
}, obligationId: string, borrowIncentiveCoinNames?: SupportBorrowIncentiveCoins[]) => Promise<{
|
|
29
31
|
eth?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
|
|
30
32
|
usdc?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
|
|
31
33
|
usdt?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
|
|
@@ -41,5 +43,9 @@ export declare const queryBorrowIncentiveAccounts: (query: ScallopQuery, obligat
|
|
|
41
43
|
* @param veScaKey
|
|
42
44
|
* @returns
|
|
43
45
|
*/
|
|
44
|
-
export declare const getBindedObligationId: (
|
|
45
|
-
|
|
46
|
+
export declare const getBindedObligationId: ({ address, }: {
|
|
47
|
+
address: ScallopAddress;
|
|
48
|
+
}, veScaKeyId: string) => Promise<string | null>;
|
|
49
|
+
export declare const getBindedVeScaKey: ({ address, }: {
|
|
50
|
+
address: ScallopAddress;
|
|
51
|
+
}, obliationId: string) => Promise<string | null>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SuiObjectData } from '@mysten/sui.js/client';
|
|
2
2
|
import type { SuiAddressArg } from '@scallop-io/sui-kit';
|
|
3
|
-
import type { ScallopQuery } from '../models';
|
|
3
|
+
import type { ScallopAddress, ScallopCache, ScallopQuery } from '../models';
|
|
4
4
|
import { Market, MarketPool, MarketCollateral, SupportAssetCoins, SupportPoolCoins, SupportCollateralCoins, ObligationQueryInterface, Obligation, SupportMarketCoins, OptionalKeys } from '../types';
|
|
5
5
|
/**
|
|
6
6
|
* Query market data.
|
|
@@ -94,7 +94,9 @@ export declare const getMarketCollateral: (query: ScallopQuery, collateralCoinNa
|
|
|
94
94
|
* @param ownerAddress - The owner address.
|
|
95
95
|
* @return Owned obligations.
|
|
96
96
|
*/
|
|
97
|
-
export declare const getObligations: (
|
|
97
|
+
export declare const getObligations: ({ address, }: {
|
|
98
|
+
address: ScallopAddress;
|
|
99
|
+
}, ownerAddress: string) => Promise<Obligation[]>;
|
|
98
100
|
/**
|
|
99
101
|
* Query obligation locked status.
|
|
100
102
|
*
|
|
@@ -102,7 +104,7 @@ export declare const getObligations: (query: ScallopQuery, ownerAddress?: string
|
|
|
102
104
|
* @param obligationId - The obligation id.
|
|
103
105
|
* @return Obligation locked status.
|
|
104
106
|
*/
|
|
105
|
-
export declare const getObligationLocked: (
|
|
107
|
+
export declare const getObligationLocked: (cache: ScallopCache, obligationId: string) => Promise<boolean>;
|
|
106
108
|
/**
|
|
107
109
|
* Query obligation data.
|
|
108
110
|
*
|
|
@@ -113,7 +115,9 @@ export declare const getObligationLocked: (query: ScallopQuery, obligationId: st
|
|
|
113
115
|
* @param obligationId - The obligation id.
|
|
114
116
|
* @return Obligation data.
|
|
115
117
|
*/
|
|
116
|
-
export declare const queryObligation: (
|
|
118
|
+
export declare const queryObligation: ({ address, }: {
|
|
119
|
+
address: ScallopAddress;
|
|
120
|
+
}, obligationId: SuiAddressArg) => Promise<ObligationQueryInterface | undefined>;
|
|
117
121
|
/**
|
|
118
122
|
* Query all owned coin amount.
|
|
119
123
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SuiObjectData } from '@mysten/sui.js/client';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ScallopAddress } from '../models';
|
|
3
3
|
import type { SupportAssetCoins } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* Get price from pyth fee object.
|
|
@@ -8,5 +8,9 @@ import type { SupportAssetCoins } from '../types';
|
|
|
8
8
|
* @param assetCoinName - Specific support asset coin name.
|
|
9
9
|
* @return Asset coin price.
|
|
10
10
|
*/
|
|
11
|
-
export declare const getPythPrice: (
|
|
12
|
-
|
|
11
|
+
export declare const getPythPrice: ({ address, }: {
|
|
12
|
+
address: ScallopAddress;
|
|
13
|
+
}, assetCoinName: SupportAssetCoins, priceFeedObject?: SuiObjectData | null) => Promise<number>;
|
|
14
|
+
export declare const getPythPrices: ({ address, }: {
|
|
15
|
+
address: ScallopAddress;
|
|
16
|
+
}, assetCoinNames: SupportAssetCoins[]) => Promise<Record<SupportAssetCoins, number>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ScallopAddress } from 'src/models';
|
|
2
2
|
/**
|
|
3
3
|
* Query the veScaKeyId from the referral bindings table using the borrower address
|
|
4
4
|
* @param query
|
|
5
5
|
* @returns
|
|
6
6
|
*/
|
|
7
|
-
export declare const queryVeScaKeyIdFromReferralBindings: (
|
|
7
|
+
export declare const queryVeScaKeyIdFromReferralBindings: (address: ScallopAddress, refereeAddress: string) => Promise<string | null>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ScallopQuery } from 'src/models';
|
|
1
|
+
import { ScallopQuery, ScallopUtils } from 'src/models';
|
|
2
2
|
import { OptionalKeys, SupportSCoin, sCoinBalance } from 'src/types';
|
|
3
3
|
/**
|
|
4
4
|
* Get total supply of sCoin
|
|
@@ -6,7 +6,9 @@ import { OptionalKeys, SupportSCoin, sCoinBalance } from 'src/types';
|
|
|
6
6
|
* @param sCoinName
|
|
7
7
|
* @returns `number`
|
|
8
8
|
*/
|
|
9
|
-
export declare const getSCoinTotalSupply: (
|
|
9
|
+
export declare const getSCoinTotalSupply: ({ utils, }: {
|
|
10
|
+
utils: ScallopUtils;
|
|
11
|
+
}, sCoinName: SupportSCoin) => Promise<sCoinBalance>;
|
|
10
12
|
/**
|
|
11
13
|
* Query all owned sCoin amount.
|
|
12
14
|
*
|
|
@@ -15,7 +17,9 @@ export declare const getSCoinTotalSupply: (query: ScallopQuery, sCoinName: Suppo
|
|
|
15
17
|
* @param ownerAddress - The owner address.
|
|
16
18
|
* @return All owned sCoins amount.
|
|
17
19
|
*/
|
|
18
|
-
export declare const getSCoinAmounts: (
|
|
20
|
+
export declare const getSCoinAmounts: ({ utils, }: {
|
|
21
|
+
utils: ScallopUtils;
|
|
22
|
+
}, sCoinNames?: SupportSCoin[], ownerAddress?: string) => Promise<OptionalKeys<Record<"seth" | "ssui" | "susdc" | "susdt" | "scetus" | "safsui" | "shasui" | "svsui" | "ssca" | "ssol" | "sbtc", number>>>;
|
|
19
23
|
/**
|
|
20
24
|
* Query owned sCoin amount.
|
|
21
25
|
*
|
|
@@ -24,4 +28,14 @@ export declare const getSCoinAmounts: (query: ScallopQuery, sCoinNames?: Support
|
|
|
24
28
|
* @param ownerAddress - The owner address.
|
|
25
29
|
* @return Owned sCoin amount.
|
|
26
30
|
*/
|
|
27
|
-
export declare const getSCoinAmount: (
|
|
31
|
+
export declare const getSCoinAmount: ({ utils, }: {
|
|
32
|
+
utils: ScallopUtils;
|
|
33
|
+
}, sCoinName: SupportSCoin, ownerAddress?: string) => Promise<number>;
|
|
34
|
+
/**
|
|
35
|
+
* Get swap rate from sCoin A to sCoin B.
|
|
36
|
+
* @param fromSCoin
|
|
37
|
+
* @param toSCoin
|
|
38
|
+
* @param underlyingCoinPrice - The price of the underlying coin. For example, if fromSCoin is sSUI and toSCoin is sUSDC, then underlyingCoinPrice represents the price of 1 SUI in USDC.
|
|
39
|
+
* @returns number
|
|
40
|
+
*/
|
|
41
|
+
export declare const getSCoinSwapRate: (query: ScallopQuery, fromSCoin: SupportSCoin, toSCoin: SupportSCoin, underlyingCoinPrice?: number) => Promise<number>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ScallopQuery } from '../models';
|
|
1
|
+
import type { ScallopQuery, ScallopUtils } from '../models';
|
|
2
2
|
import type { MarketPool, Spool, StakePool, StakeRewardPool, StakeAccounts, SupportStakeMarketCoins, CoinPrices } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Get spools data.
|
|
@@ -36,7 +36,9 @@ export declare const getSpool: (query: ScallopQuery, marketCoinName: SupportStak
|
|
|
36
36
|
* @param ownerAddress - Owner address.
|
|
37
37
|
* @return Stake accounts.
|
|
38
38
|
*/
|
|
39
|
-
export declare const getStakeAccounts: (
|
|
39
|
+
export declare const getStakeAccounts: ({ utils, }: {
|
|
40
|
+
utils: ScallopUtils;
|
|
41
|
+
}, ownerAddress?: string) => Promise<StakeAccounts>;
|
|
40
42
|
/**
|
|
41
43
|
* Get stake pool data.
|
|
42
44
|
*
|
|
@@ -48,7 +50,9 @@ export declare const getStakeAccounts: (query: ScallopQuery, ownerAddress?: stri
|
|
|
48
50
|
* @param marketCoinName - Specific support stake market coin name.
|
|
49
51
|
* @return Stake pool data.
|
|
50
52
|
*/
|
|
51
|
-
export declare const getStakePool: (
|
|
53
|
+
export declare const getStakePool: ({ utils, }: {
|
|
54
|
+
utils: ScallopUtils;
|
|
55
|
+
}, marketCoinName: SupportStakeMarketCoins) => Promise<StakePool | undefined>;
|
|
52
56
|
/**
|
|
53
57
|
* Get stake reward pool of the owner.
|
|
54
58
|
*
|
|
@@ -60,4 +64,6 @@ export declare const getStakePool: (query: ScallopQuery, marketCoinName: Support
|
|
|
60
64
|
* @param marketCoinName - Specific support stake market coin name.
|
|
61
65
|
* @return Stake reward pool.
|
|
62
66
|
*/
|
|
63
|
-
export declare const getStakeRewardPool: (
|
|
67
|
+
export declare const getStakeRewardPool: ({ utils, }: {
|
|
68
|
+
utils: ScallopUtils;
|
|
69
|
+
}, marketCoinName: SupportStakeMarketCoins) => Promise<StakeRewardPool | undefined>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VeScaTreasuryInfo, Vesca } from '../types';
|
|
2
2
|
import { type SuiObjectData } from '@mysten/sui.js/client';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ScallopUtils } from '../models';
|
|
4
4
|
/**
|
|
5
5
|
* Query all owned veSca key.
|
|
6
6
|
*
|
|
@@ -8,7 +8,7 @@ import type { ScallopQuery } from '../models';
|
|
|
8
8
|
* @param ownerAddress - The owner address.
|
|
9
9
|
* @return Owned veSca key.
|
|
10
10
|
*/
|
|
11
|
-
export declare const getVescaKeys: (
|
|
11
|
+
export declare const getVescaKeys: (utils: ScallopUtils, ownerAddress?: string) => Promise<SuiObjectData[]>;
|
|
12
12
|
/**
|
|
13
13
|
* Query all owned veSca.
|
|
14
14
|
*
|
|
@@ -16,7 +16,9 @@ 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: (
|
|
19
|
+
export declare const getVeScas: ({ utils, }: {
|
|
20
|
+
utils: ScallopUtils;
|
|
21
|
+
}, ownerAddress?: string) => Promise<Vesca[]>;
|
|
20
22
|
/**
|
|
21
23
|
* Get veSca data.
|
|
22
24
|
*
|
|
@@ -25,10 +27,10 @@ export declare const getVeScas: (query: ScallopQuery, ownerAddress?: string) =>
|
|
|
25
27
|
* @param ownerAddress - The owner address.
|
|
26
28
|
* @returns Vesca data.
|
|
27
29
|
*/
|
|
28
|
-
export declare const getVeSca: (
|
|
30
|
+
export declare const getVeSca: (utils: ScallopUtils, veScaKey?: string | SuiObjectData, ownerAddress?: string) => Promise<Vesca | undefined>;
|
|
29
31
|
/**
|
|
30
32
|
* Get veSCA treasury informations
|
|
31
33
|
* @param query
|
|
32
34
|
* @returns VeScaTreasuryInfo
|
|
33
35
|
*/
|
|
34
|
-
export declare const getVeScaTreasuryInfo: (
|
|
36
|
+
export declare const getVeScaTreasuryInfo: (utils: ScallopUtils) => Promise<VeScaTreasuryInfo | null>;
|
|
@@ -15,6 +15,7 @@ export type VeScaNormalMethods = {
|
|
|
15
15
|
redeemSca: (veScaKey: SuiObjectArg) => TransactionResult;
|
|
16
16
|
mintEmptyVeSca: () => TransactionResult;
|
|
17
17
|
};
|
|
18
|
+
export type RedeemScaQuickReturnType<T extends boolean> = T extends true ? void : TransactionResult | undefined;
|
|
18
19
|
export type VeScaQuickMethods = {
|
|
19
20
|
/**
|
|
20
21
|
* Quick methods to automate
|
|
@@ -36,7 +37,7 @@ export type VeScaQuickMethods = {
|
|
|
36
37
|
extendLockPeriodQuick: (lockPeriodInDays: number, veScaKey?: SuiObjectArg, autoCheck?: boolean) => Promise<void>;
|
|
37
38
|
extendLockAmountQuick: (scaAmount: number, veScaKey?: SuiObjectArg, autoCheck?: boolean) => Promise<void>;
|
|
38
39
|
renewExpiredVeScaQuick: (scaAmount: number, lockPeriodInDays: number, veScaKey?: SuiObjectArg, autoCheck?: boolean) => Promise<void>;
|
|
39
|
-
redeemScaQuick: (
|
|
40
|
+
redeemScaQuick: <T extends boolean>(veSCaKey?: SuiObjectArg, transferSca?: T) => Promise<RedeemScaQuickReturnType<T>>;
|
|
40
41
|
};
|
|
41
42
|
export type SuiTxBlockWithVeScaNormalMethods = SuiKitTxBlock & VeScaNormalMethods;
|
|
42
43
|
export type VeScaTxBlock = SuiTxBlockWithVeScaNormalMethods & VeScaQuickMethods;
|
package/dist/types/model.d.ts
CHANGED
|
@@ -1,16 +1,35 @@
|
|
|
1
1
|
import type { SuiTransactionBlockResponse } from '@mysten/sui.js/client';
|
|
2
|
-
import type { TransactionBlock } from '@mysten/sui.js/transactions';
|
|
2
|
+
import type { TransactionBlock, TransactionResult } from '@mysten/sui.js/transactions';
|
|
3
3
|
import type { SuiKit, SuiKitParams, NetworkType } from '@scallop-io/sui-kit';
|
|
4
|
-
import type { ScallopAddress, ScallopQuery, ScallopUtils, ScallopBuilder } from '../models';
|
|
4
|
+
import type { ScallopAddress, ScallopQuery, ScallopUtils, ScallopBuilder, ScallopIndexer } from '../models';
|
|
5
5
|
import { ScallopCache } from 'src/models/scallopCache';
|
|
6
6
|
export type ScallopClientFnReturnType<T extends boolean> = T extends true ? SuiTransactionBlockResponse : TransactionBlock;
|
|
7
|
-
export type
|
|
7
|
+
export type ScallopClientVeScaReturnType<T extends boolean> = T extends true ? SuiTransactionBlockResponse : {
|
|
8
|
+
tx: TransactionBlock;
|
|
9
|
+
scaCoin: TransactionResult;
|
|
10
|
+
};
|
|
11
|
+
export type ScallopBaseInstanceParams = {
|
|
8
12
|
suiKit?: SuiKit;
|
|
13
|
+
};
|
|
14
|
+
export type ScallopCacheInstanceParams = ScallopBaseInstanceParams;
|
|
15
|
+
export type ScallopAddressInstanceParams = ScallopBaseInstanceParams & {
|
|
16
|
+
cache?: ScallopCache;
|
|
17
|
+
};
|
|
18
|
+
export type ScallopIndexerInstanceParams = {
|
|
19
|
+
cache?: ScallopCache;
|
|
20
|
+
};
|
|
21
|
+
export type ScallopUtilsInstanceParams = ScallopBaseInstanceParams & {
|
|
9
22
|
address?: ScallopAddress;
|
|
10
|
-
|
|
23
|
+
};
|
|
24
|
+
export type ScallopQueryInstanceParams = ScallopBaseInstanceParams & {
|
|
11
25
|
utils?: ScallopUtils;
|
|
26
|
+
indexer?: ScallopIndexer;
|
|
27
|
+
};
|
|
28
|
+
export type ScallopBuilderInstanceParams = ScallopBaseInstanceParams & {
|
|
29
|
+
query?: ScallopQuery;
|
|
30
|
+
};
|
|
31
|
+
export type ScallopClientInstanceParams = ScallopBaseInstanceParams & {
|
|
12
32
|
builder?: ScallopBuilder;
|
|
13
|
-
cache: ScallopCache;
|
|
14
33
|
};
|
|
15
34
|
export type ScallopAddressParams = {
|
|
16
35
|
id: string;
|
|
@@ -19,17 +38,13 @@ export type ScallopAddressParams = {
|
|
|
19
38
|
};
|
|
20
39
|
export type ScallopParams = {
|
|
21
40
|
addressesId?: string;
|
|
22
|
-
} & SuiKitParams;
|
|
23
|
-
export type ScallopClientParams = ScallopParams & {
|
|
24
41
|
walletAddress?: string;
|
|
25
|
-
};
|
|
42
|
+
} & SuiKitParams;
|
|
43
|
+
export type ScallopClientParams = ScallopParams;
|
|
26
44
|
export type ScallopBuilderParams = ScallopParams & {
|
|
27
|
-
walletAddress?: string;
|
|
28
45
|
pythEndpoints?: string[];
|
|
29
46
|
};
|
|
30
|
-
export type ScallopQueryParams = ScallopParams
|
|
31
|
-
walletAddress?: string;
|
|
32
|
-
};
|
|
47
|
+
export type ScallopQueryParams = ScallopParams;
|
|
33
48
|
export type ScallopUtilsParams = ScallopParams & {
|
|
34
49
|
pythEndpoints?: string[];
|
|
35
50
|
};
|
package/package.json
CHANGED
|
@@ -51,13 +51,13 @@ const requireObligationInfo = async (
|
|
|
51
51
|
typeof obligationId === 'string'
|
|
52
52
|
) {
|
|
53
53
|
const obligationLocked = await getObligationLocked(
|
|
54
|
-
builder.
|
|
54
|
+
builder.cache,
|
|
55
55
|
obligationId
|
|
56
56
|
);
|
|
57
57
|
return { obligationId, obligationKey, obligationLocked };
|
|
58
58
|
}
|
|
59
59
|
const sender = requireSender(txBlock);
|
|
60
|
-
const obligations = await getObligations(builder
|
|
60
|
+
const obligations = await getObligations(builder, sender);
|
|
61
61
|
if (obligations.length === 0) {
|
|
62
62
|
throw new Error(`No obligation found for sender ${sender}`);
|
|
63
63
|
}
|
|
@@ -207,7 +207,7 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
|
207
207
|
stakeObligationQuick: async (obligation, obligationKey) => {
|
|
208
208
|
const {
|
|
209
209
|
obligationId: obligationArg,
|
|
210
|
-
obligationKey:
|
|
210
|
+
obligationKey: obligationKeyArg,
|
|
211
211
|
obligationLocked: obligationLocked,
|
|
212
212
|
} = await requireObligationInfo(
|
|
213
213
|
builder,
|
|
@@ -227,7 +227,7 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
|
227
227
|
);
|
|
228
228
|
|
|
229
229
|
if (!obligationLocked || unstakeObligationBeforeStake) {
|
|
230
|
-
txBlock.stakeObligation(obligationArg,
|
|
230
|
+
txBlock.stakeObligation(obligationArg, obligationKeyArg);
|
|
231
231
|
}
|
|
232
232
|
},
|
|
233
233
|
stakeObligationWithVeScaQuick: async (
|
|
@@ -237,7 +237,7 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
|
237
237
|
) => {
|
|
238
238
|
const {
|
|
239
239
|
obligationId: obligationArg,
|
|
240
|
-
obligationKey:
|
|
240
|
+
obligationKey: obligationKeyArg,
|
|
241
241
|
obligationLocked: obligationLocked,
|
|
242
242
|
} = await requireObligationInfo(
|
|
243
243
|
builder,
|
|
@@ -260,7 +260,7 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
|
260
260
|
const veSca = await requireVeSca(builder, txBlock, veScaKey);
|
|
261
261
|
if (veSca) {
|
|
262
262
|
const bindedObligationId = await getBindedObligationId(
|
|
263
|
-
builder
|
|
263
|
+
builder,
|
|
264
264
|
veSca.keyId
|
|
265
265
|
);
|
|
266
266
|
|
|
@@ -271,21 +271,21 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
|
271
271
|
) {
|
|
272
272
|
txBlock.stakeObligationWithVesca(
|
|
273
273
|
obligationArg,
|
|
274
|
-
|
|
274
|
+
obligationKeyArg,
|
|
275
275
|
veSca.keyId
|
|
276
276
|
);
|
|
277
277
|
} else {
|
|
278
|
-
txBlock.stakeObligation(obligationArg,
|
|
278
|
+
txBlock.stakeObligation(obligationArg, obligationKeyArg);
|
|
279
279
|
}
|
|
280
280
|
} else {
|
|
281
|
-
txBlock.stakeObligation(obligationArg,
|
|
281
|
+
txBlock.stakeObligation(obligationArg, obligationKeyArg);
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
},
|
|
285
285
|
unstakeObligationQuick: async (obligation, obligationKey) => {
|
|
286
286
|
const {
|
|
287
287
|
obligationId: obligationArg,
|
|
288
|
-
obligationKey:
|
|
288
|
+
obligationKey: obligationKeyArg,
|
|
289
289
|
obligationLocked: obligationLocked,
|
|
290
290
|
} = await requireObligationInfo(
|
|
291
291
|
builder,
|
|
@@ -295,7 +295,7 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
|
295
295
|
);
|
|
296
296
|
|
|
297
297
|
if (obligationLocked) {
|
|
298
|
-
txBlock.unstakeObligation(obligationArg,
|
|
298
|
+
txBlock.unstakeObligation(obligationArg, obligationKeyArg);
|
|
299
299
|
}
|
|
300
300
|
},
|
|
301
301
|
claimBorrowIncentiveQuick: async (
|
|
@@ -304,19 +304,17 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
|
304
304
|
obligation,
|
|
305
305
|
obligationKey
|
|
306
306
|
) => {
|
|
307
|
-
const {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
obligationKey
|
|
315
|
-
);
|
|
307
|
+
const { obligationId: obligationArg, obligationKey: obligationKeyArg } =
|
|
308
|
+
await requireObligationInfo(
|
|
309
|
+
builder,
|
|
310
|
+
txBlock,
|
|
311
|
+
obligation,
|
|
312
|
+
obligationKey
|
|
313
|
+
);
|
|
316
314
|
|
|
317
315
|
return txBlock.claimBorrowIncentive(
|
|
318
316
|
obligationArg,
|
|
319
|
-
|
|
317
|
+
obligationKeyArg,
|
|
320
318
|
coinName,
|
|
321
319
|
rewardCoinName
|
|
322
320
|
);
|