@scallop-io/sui-scallop-sdk 0.47.2 → 0.47.3

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.
@@ -4,7 +4,7 @@ import { ScallopClient } from './scallopClient';
4
4
  import { ScallopBuilder } from './scallopBuilder';
5
5
  import { ScallopQuery } from './scallopQuery';
6
6
  import { ScallopUtils } from './scallopUtils';
7
- import type { ScallopParams } from '../types/';
7
+ import type { ScallopBuilderParams, ScallopClientParams, ScallopParams, ScallopQueryParams, ScallopUtilsParams } from '../types/';
8
8
  import { ScallopIndexer } from './scallopIndexer';
9
9
  import { ScallopCache } from './scallopCache';
10
10
  import { QueryClientConfig } from '@tanstack/query-core';
@@ -44,20 +44,20 @@ export declare class Scallop {
44
44
  *
45
45
  * @return Scallop Builder.
46
46
  */
47
- createScallopBuilder(): Promise<ScallopBuilder>;
47
+ createScallopBuilder(params?: ScallopBuilderParams): Promise<ScallopBuilder>;
48
48
  /**
49
49
  * Create a scallop client instance that already has initial data.
50
50
  *
51
51
  * @param walletAddress - When user cannot provide a secret key or mnemonic, the scallop client cannot directly derive the address of the transaction the user wants to sign. This argument specifies the wallet address for signing the transaction.
52
52
  * @return Scallop Client.
53
53
  */
54
- createScallopClient(walletAddress?: string): Promise<ScallopClient>;
54
+ createScallopClient(params?: ScallopClientParams): Promise<ScallopClient>;
55
55
  /**
56
56
  * Create a scallop query instance.
57
57
  *
58
58
  * @return Scallop Query.
59
59
  */
60
- createScallopQuery(): Promise<ScallopQuery>;
60
+ createScallopQuery(params?: ScallopQueryParams): Promise<ScallopQuery>;
61
61
  /**
62
62
  * Create a scallop indexer instance.
63
63
  *
@@ -69,5 +69,5 @@ export declare class Scallop {
69
69
  *
70
70
  * @return Scallop Utils.
71
71
  */
72
- createScallopUtils(): Promise<ScallopUtils>;
72
+ createScallopUtils(params?: ScallopUtilsParams): Promise<ScallopUtils>;
73
73
  }
@@ -40,11 +40,12 @@ export type ScallopParams = {
40
40
  addressesId?: string;
41
41
  walletAddress?: string;
42
42
  } & SuiKitParams;
43
- export type ScallopClientParams = ScallopParams;
43
+ export type ScallopClientParams = ScallopParams & ScallopBuilderParams & ScallopQueryParams & ScallopUtilsParams;
44
44
  export type ScallopBuilderParams = ScallopParams & {
45
45
  pythEndpoints?: string[];
46
- };
47
- export type ScallopQueryParams = ScallopParams;
46
+ usePythPullModel?: boolean;
47
+ } & ScallopQueryParams;
48
+ export type ScallopQueryParams = ScallopParams & ScallopUtilsParams;
48
49
  export type ScallopUtilsParams = ScallopParams & {
49
50
  pythEndpoints?: string[];
50
51
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "0.47.2",
3
+ "version": "0.47.3",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -255,19 +255,14 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
255
255
  const bindedVeScaKey =
256
256
  await builder.query.getBindedVeScaKey(obligationArg);
257
257
 
258
- if (veScaKey && veScaKey !== bindedVeScaKey) {
259
- throw new Error(
260
- 'Binded veScaKey is not equal to the provided veScaKey'
261
- );
262
- }
263
- if (bindedVeScaKey) {
258
+ if ((veScaKey && veScaKey !== bindedVeScaKey) || !bindedVeScaKey) {
259
+ txBlock.stakeObligation(obligationArg, obligationKeyArg);
260
+ } else {
264
261
  txBlock.stakeObligationWithVesca(
265
262
  obligationArg,
266
263
  obligationKeyArg,
267
264
  bindedVeScaKey
268
265
  );
269
- } else {
270
- txBlock.stakeObligation(obligationArg, obligationKeyArg);
271
266
  }
272
267
  }
273
268
  },
@@ -16,17 +16,23 @@ import { PYTH_ENDPOINTS } from 'src/constants/pyth';
16
16
  * @param builder - The scallop builder.
17
17
  * @param txBlock - TxBlock created by SuiKit.
18
18
  * @param assetCoinNames - Specific an array of support asset coin name.
19
+ * @param options - The options for update oracles.
19
20
  */
20
21
  export const updateOracles = async (
21
22
  builder: ScallopBuilder,
22
23
  txBlock: SuiKitTxBlock,
23
- assetCoinNames?: SupportAssetCoins[]
24
+ assetCoinNames?: SupportAssetCoins[],
25
+ options: {
26
+ usePythPullModel: boolean;
27
+ } = { usePythPullModel: true }
24
28
  ) => {
29
+ const usePythPullModel =
30
+ builder.params.usePythPullModel ?? options.usePythPullModel;
25
31
  assetCoinNames = assetCoinNames ?? [
26
32
  ...new Set([...SUPPORT_POOLS, ...SUPPORT_COLLATERALS]),
27
33
  ];
28
34
  const rules: SupportOracleType[] = builder.isTestnet ? ['pyth'] : ['pyth'];
29
- if (rules.includes('pyth')) {
35
+ if (usePythPullModel && rules.includes('pyth')) {
30
36
  const pythClient = new SuiPythClient(
31
37
  builder.suiKit.client(),
32
38
  builder.address.get('core.oracles.pyth.state'),
@@ -5,7 +5,13 @@ import { ScallopBuilder } from './scallopBuilder';
5
5
  import { ScallopQuery } from './scallopQuery';
6
6
  import { ScallopUtils } from './scallopUtils';
7
7
  import { ADDRESSES_ID } from '../constants';
8
- import type { ScallopParams } from '../types/';
8
+ import type {
9
+ ScallopBuilderParams,
10
+ ScallopClientParams,
11
+ ScallopParams,
12
+ ScallopQueryParams,
13
+ ScallopUtilsParams,
14
+ } from '../types/';
9
15
  import { ScallopIndexer } from './scallopIndexer';
10
16
  import { ScallopCache } from './scallopCache';
11
17
  import { QueryClientConfig } from '@tanstack/query-core';
@@ -80,10 +86,14 @@ export class Scallop {
80
86
  *
81
87
  * @return Scallop Builder.
82
88
  */
83
- public async createScallopBuilder() {
89
+ public async createScallopBuilder(params?: ScallopBuilderParams) {
84
90
  if (!this.address.getAddresses()) await this.address.read();
85
- const scallopBuilder = new ScallopBuilder(this.params, {
86
- query: await this.createScallopQuery(),
91
+ const builderParams = {
92
+ ...this.params,
93
+ ...params,
94
+ };
95
+ const scallopBuilder = new ScallopBuilder(builderParams, {
96
+ query: await this.createScallopQuery(builderParams),
87
97
  });
88
98
 
89
99
  return scallopBuilder;
@@ -95,12 +105,15 @@ export class Scallop {
95
105
  * @param walletAddress - When user cannot provide a secret key or mnemonic, the scallop client cannot directly derive the address of the transaction the user wants to sign. This argument specifies the wallet address for signing the transaction.
96
106
  * @return Scallop Client.
97
107
  */
98
- public async createScallopClient(walletAddress?: string) {
108
+ public async createScallopClient(params?: ScallopClientParams) {
99
109
  if (!this.address.getAddresses()) await this.address.read();
100
- const scallopClient = new ScallopClient(
101
- { ...this.params, walletAddress },
102
- { builder: await this.createScallopBuilder() }
103
- );
110
+ const clientParams = {
111
+ ...this.params,
112
+ ...params,
113
+ };
114
+ const scallopClient = new ScallopClient(clientParams, {
115
+ builder: await this.createScallopBuilder(clientParams),
116
+ });
104
117
 
105
118
  return scallopClient;
106
119
  }
@@ -110,10 +123,14 @@ export class Scallop {
110
123
  *
111
124
  * @return Scallop Query.
112
125
  */
113
- public async createScallopQuery() {
126
+ public async createScallopQuery(params?: ScallopQueryParams) {
114
127
  if (!this.address.getAddresses()) await this.address.read();
115
- const scallopQuery = new ScallopQuery(this.params, {
116
- utils: await this.createScallopUtils(),
128
+ const queryParams = {
129
+ ...this.params,
130
+ ...params,
131
+ };
132
+ const scallopQuery = new ScallopQuery(queryParams, {
133
+ utils: await this.createScallopUtils(queryParams),
117
134
  });
118
135
 
119
136
  return scallopQuery;
@@ -137,11 +154,17 @@ export class Scallop {
137
154
  *
138
155
  * @return Scallop Utils.
139
156
  */
140
- public async createScallopUtils() {
157
+ public async createScallopUtils(params?: ScallopUtilsParams) {
141
158
  if (!this.address.getAddresses()) await this.address.read();
142
- const scallopUtils = new ScallopUtils(this.params, {
143
- address: this.address,
144
- });
159
+ const scallopUtils = new ScallopUtils(
160
+ {
161
+ ...this.params,
162
+ ...params,
163
+ },
164
+ {
165
+ address: this.address,
166
+ }
167
+ );
145
168
 
146
169
  return scallopUtils;
147
170
  }
@@ -66,13 +66,17 @@ export type ScallopParams = {
66
66
  walletAddress?: string;
67
67
  } & SuiKitParams;
68
68
 
69
- export type ScallopClientParams = ScallopParams;
69
+ export type ScallopClientParams = ScallopParams &
70
+ ScallopBuilderParams &
71
+ ScallopQueryParams &
72
+ ScallopUtilsParams;
70
73
 
71
74
  export type ScallopBuilderParams = ScallopParams & {
72
75
  pythEndpoints?: string[];
73
- };
76
+ usePythPullModel?: boolean;
77
+ } & ScallopQueryParams;
74
78
 
75
- export type ScallopQueryParams = ScallopParams;
79
+ export type ScallopQueryParams = ScallopParams & ScallopUtilsParams;
76
80
 
77
81
  export type ScallopUtilsParams = ScallopParams & {
78
82
  pythEndpoints?: string[];