@typus/typus-perp-sdk 1.1.32-codegen-exp2 → 1.1.32-codegen-exp4

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,8 +4,7 @@ import { StakePool } from "../../src/generated/typus_stake_pool/stake_pool";
4
4
  import { LiquidityPool } from "../../src/generated/typus_perp/lp_pool";
5
5
  import { TypusClient } from "../../src/client";
6
6
  export declare function snapshot(client: TypusClient, tx: Transaction, input: {
7
- userShareId: string;
8
- perpIndex?: number;
7
+ perpIndex: string;
9
8
  }): Promise<Transaction>;
10
9
  export declare function mintStakeLp(client: TypusClient, tx: Transaction, input: {
11
10
  lpPool: typeof LiquidityPool.$inferType;
@@ -18,7 +17,6 @@ export declare function mintStakeLp(client: TypusClient, tx: Transaction, input:
18
17
  user: string;
19
18
  stake: boolean;
20
19
  suiCoins?: string[];
21
- perpIndex?: number;
22
20
  }): Promise<Transaction>;
23
21
  export declare function stakeLp(client: TypusClient, tx: Transaction, input: {
24
22
  stakePool: typeof StakePool.$inferType;
@@ -26,7 +24,6 @@ export declare function stakeLp(client: TypusClient, tx: Transaction, input: {
26
24
  amount: string;
27
25
  userShareId: string | null;
28
26
  user: string;
29
- perpIndex?: number;
30
27
  }): Promise<Transaction>;
31
28
  export declare function unstake(client: TypusClient, tx: Transaction, input: {
32
29
  lpPool: typeof LiquidityPool.$inferType;
@@ -34,7 +31,6 @@ export declare function unstake(client: TypusClient, tx: Transaction, input: {
34
31
  userShareId: string;
35
32
  share: string | null;
36
33
  user: string;
37
- perpIndex?: number;
38
34
  }): Promise<Transaction>;
39
35
  export declare function unstakeRedeem(client: TypusClient, tx: Transaction, input: {
40
36
  lpPool: typeof LiquidityPool.$inferType;
@@ -43,7 +39,6 @@ export declare function unstakeRedeem(client: TypusClient, tx: Transaction, inpu
43
39
  share: string | null;
44
40
  user: string;
45
41
  suiCoins?: string[];
46
- perpIndex?: number;
47
42
  }): Promise<Transaction>;
48
43
  export declare function redeemTlp(client: TypusClient, tx: Transaction, input: {
49
44
  lpPool: typeof LiquidityPool.$inferType;
@@ -51,7 +46,6 @@ export declare function redeemTlp(client: TypusClient, tx: Transaction, input: {
51
46
  share: string | null;
52
47
  user: string;
53
48
  suiCoins?: string[];
54
- perpIndex?: number;
55
49
  }): Promise<Transaction>;
56
50
  export declare function claim(client: TypusClient, tx: Transaction, input: {
57
51
  lpPool: typeof LiquidityPool.$inferType;
@@ -59,7 +53,6 @@ export declare function claim(client: TypusClient, tx: Transaction, input: {
59
53
  cTOKEN: TOKEN;
60
54
  user: string;
61
55
  suiCoins?: string[];
62
- perpIndex?: number;
63
56
  }): Promise<Transaction>;
64
57
  export declare function swap(client: TypusClient, tx: Transaction, input: {
65
58
  coins: string[];
@@ -67,12 +60,10 @@ export declare function swap(client: TypusClient, tx: Transaction, input: {
67
60
  TO_TOKEN: TOKEN;
68
61
  amount: string;
69
62
  user: string;
63
+ perpIndex: number;
70
64
  suiCoins?: string[];
71
- perpIndex?: number;
72
65
  }): Promise<Transaction>;
73
66
  export declare function harvestStakeReward(client: TypusClient, tx: Transaction, input: {
74
67
  stakePool: typeof StakePool.$inferType;
75
- userShareId: string;
76
68
  user: string;
77
- perpIndex?: number;
78
69
  }): Promise<Transaction>;
@@ -20,8 +20,7 @@ async function snapshot(client, tx, input) {
20
20
  arguments: {
21
21
  version: __1.STAKE_POOL_VERSION,
22
22
  registry: __1.STAKE_POOL,
23
- index: BigInt(input.perpIndex ?? 0),
24
- UserShareId: BigInt(input.userShareId),
23
+ index: BigInt(input.perpIndex),
25
24
  typusEcosystemVersion: client.config.version.typus,
26
25
  typusUserRegistry: client.config.registry.typus.user,
27
26
  },
@@ -54,7 +53,7 @@ async function mintStakeLp(client, tx, input) {
54
53
  arguments: {
55
54
  version: __1.PERP_VERSION,
56
55
  registry: __1.LP_POOL,
57
- index: BigInt(input.perpIndex ?? 0),
56
+ index: BigInt(input.stakePool.pool_info.index),
58
57
  oracle: constants_1.oracle[__1.NETWORK][token],
59
58
  },
60
59
  typeArguments: [constants_1.tokenType[__1.NETWORK][token]],
@@ -62,7 +61,7 @@ async function mintStakeLp(client, tx, input) {
62
61
  }
63
62
  // console.log(iToken);
64
63
  if (input.userShareId) {
65
- harvestStakeReward(client, tx, { stakePool: input.stakePool, userShareId: input.userShareId, user: input.user });
64
+ harvestStakeReward(client, tx, { stakePool: input.stakePool, user: input.user });
66
65
  }
67
66
  let lpToken = (0, utils_1.normalizeStructTag)(input.lpPool.lp_token_type.name);
68
67
  let lpCoin = tx.add((0, lp_pool_1.mintLp)({
@@ -70,7 +69,7 @@ async function mintStakeLp(client, tx, input) {
70
69
  version: __1.PERP_VERSION,
71
70
  registry: __1.LP_POOL,
72
71
  treasuryCaps: __1.TLP_TREASURY_CAP,
73
- index: BigInt(input.perpIndex ?? 0),
72
+ index: BigInt(input.stakePool.pool_info.index),
74
73
  oracle: constants_1.oracle[__1.NETWORK][input.cTOKEN],
75
74
  coin,
76
75
  },
@@ -81,9 +80,8 @@ async function mintStakeLp(client, tx, input) {
81
80
  arguments: {
82
81
  version: __1.STAKE_POOL_VERSION,
83
82
  registry: __1.STAKE_POOL,
84
- index: BigInt(input.perpIndex ?? 0),
83
+ index: BigInt(input.stakePool.pool_info.index),
85
84
  lpToken: lpCoin,
86
- UserShareId: null,
87
85
  },
88
86
  typeArguments: [lpToken],
89
87
  }));
@@ -102,30 +100,28 @@ async function stakeLp(client, tx, input) {
102
100
  [lpCoin] = tx.splitCoins(destination, [input.amount]);
103
101
  // console.log(iToken);
104
102
  if (input.userShareId) {
105
- harvestStakeReward(client, tx, { stakePool: input.stakePool, userShareId: input.userShareId, user: input.user });
103
+ harvestStakeReward(client, tx, { stakePool: input.stakePool, user: input.user });
106
104
  }
107
105
  tx.add((0, stake_pool_1.stake)({
108
106
  arguments: {
109
107
  version: __1.STAKE_POOL_VERSION,
110
108
  registry: __1.STAKE_POOL,
111
- index: BigInt(input.perpIndex ?? 0),
109
+ index: BigInt(input.stakePool.pool_info.index),
112
110
  lpToken: lpCoin,
113
- UserShareId: null,
114
111
  },
115
112
  typeArguments: [(0, utils_1.normalizeStructTag)(input.stakePool.pool_info.stake_token.name)],
116
113
  }));
117
114
  return tx;
118
115
  }
119
116
  async function unstake(client, tx, input) {
120
- harvestStakeReward(client, tx, { stakePool: input.stakePool, userShareId: input.userShareId, user: input.user });
117
+ harvestStakeReward(client, tx, { stakePool: input.stakePool, user: input.user });
121
118
  let lpToken = (0, utils_1.normalizeStructTag)(input.lpPool.lp_token_type.name);
122
119
  tx.add((0, stake_pool_1.unsubscribe)({
123
120
  arguments: {
124
121
  version: __1.STAKE_POOL_VERSION,
125
122
  registry: __1.STAKE_POOL,
126
- index: BigInt(input.perpIndex ?? 0),
123
+ index: BigInt(input.stakePool.pool_info.index),
127
124
  unsubscribedShares: input.share ? BigInt(input.share) : null,
128
- UserShareId: BigInt(input.userShareId),
129
125
  },
130
126
  typeArguments: [lpToken],
131
127
  }));
@@ -133,8 +129,7 @@ async function unstake(client, tx, input) {
133
129
  arguments: {
134
130
  version: __1.STAKE_POOL_VERSION,
135
131
  registry: __1.STAKE_POOL,
136
- index: BigInt(input.perpIndex ?? 0),
137
- UserShareId: BigInt(input.userShareId),
132
+ index: BigInt(input.stakePool.pool_info.index),
138
133
  },
139
134
  typeArguments: [lpToken],
140
135
  }));
@@ -152,19 +147,23 @@ async function unstakeRedeem(client, tx, input) {
152
147
  for (let token of tokens) {
153
148
  (0, utils_2.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
154
149
  (0, lp_pool_1.updateLiquidityValue)({
155
- arguments: { version: __1.PERP_VERSION, registry: __1.LP_POOL, index: BigInt(input.perpIndex ?? 0), oracle: constants_1.oracle[__1.NETWORK][token] },
150
+ arguments: {
151
+ version: __1.PERP_VERSION,
152
+ registry: __1.LP_POOL,
153
+ index: BigInt(input.stakePool.pool_info.index),
154
+ oracle: constants_1.oracle[__1.NETWORK][token],
155
+ },
156
156
  typeArguments: [constants_1.tokenType[__1.NETWORK][token]],
157
157
  })(tx);
158
158
  }
159
- harvestStakeReward(client, tx, { stakePool: input.stakePool, userShareId: input.userShareId, user: input.user });
159
+ harvestStakeReward(client, tx, { stakePool: input.stakePool, user: input.user });
160
160
  let lpToken = (0, utils_1.normalizeStructTag)(input.lpPool.lp_token_type.name);
161
161
  tx.add((0, stake_pool_1.unsubscribe)({
162
162
  arguments: {
163
163
  version: __1.STAKE_POOL_VERSION,
164
164
  registry: __1.STAKE_POOL,
165
- index: BigInt(input.perpIndex ?? 0),
165
+ index: BigInt(input.stakePool.pool_info.index),
166
166
  unsubscribedShares: input.share ? BigInt(input.share) : null,
167
- UserShareId: BigInt(input.userShareId),
168
167
  },
169
168
  typeArguments: [lpToken],
170
169
  }));
@@ -172,8 +171,7 @@ async function unstakeRedeem(client, tx, input) {
172
171
  arguments: {
173
172
  version: __1.STAKE_POOL_VERSION,
174
173
  registry: __1.STAKE_POOL,
175
- index: BigInt(input.perpIndex ?? 0),
176
- UserShareId: BigInt(input.userShareId),
174
+ index: BigInt(input.stakePool.pool_info.index),
177
175
  },
178
176
  typeArguments: [lpToken],
179
177
  }));
@@ -186,7 +184,7 @@ async function unstakeRedeem(client, tx, input) {
186
184
  arguments: {
187
185
  version: __1.PERP_VERSION,
188
186
  registry: __1.LP_POOL,
189
- index: BigInt(input.perpIndex ?? 0),
187
+ index: BigInt(input.stakePool.pool_info.index),
190
188
  balance,
191
189
  },
192
190
  typeArguments: [input.lpPool.lp_token_type.name],
@@ -207,7 +205,7 @@ async function redeemTlp(client, tx, input) {
207
205
  arguments: {
208
206
  version: __1.PERP_VERSION,
209
207
  registry: __1.LP_POOL,
210
- index: BigInt(input.perpIndex ?? 0),
208
+ index: BigInt(input.lpPool.index),
211
209
  oracle: constants_1.oracle[__1.NETWORK][token],
212
210
  },
213
211
  typeArguments: [constants_1.tokenType[__1.NETWORK][token]],
@@ -235,7 +233,7 @@ async function redeemTlp(client, tx, input) {
235
233
  arguments: {
236
234
  version: __1.PERP_VERSION,
237
235
  registry: __1.LP_POOL,
238
- index: BigInt(input.perpIndex ?? 0),
236
+ index: BigInt(input.lpPool.index),
239
237
  balance,
240
238
  },
241
239
  typeArguments: [lpToken],
@@ -253,7 +251,12 @@ async function claim(client, tx, input) {
253
251
  for (let token of tokens) {
254
252
  (0, utils_2.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
255
253
  (0, lp_pool_1.updateLiquidityValue)({
256
- arguments: { version: __1.PERP_VERSION, registry: __1.LP_POOL, index: BigInt(input.perpIndex ?? 0), oracle: constants_1.oracle[__1.NETWORK][token] },
254
+ arguments: {
255
+ version: __1.PERP_VERSION,
256
+ registry: __1.LP_POOL,
257
+ index: BigInt(input.stakePool.pool_info.index),
258
+ oracle: constants_1.oracle[__1.NETWORK][token],
259
+ },
257
260
  typeArguments: [constants_1.tokenType[__1.NETWORK][token]],
258
261
  })(tx);
259
262
  }
@@ -262,7 +265,7 @@ async function claim(client, tx, input) {
262
265
  arguments: {
263
266
  version: __1.PERP_VERSION,
264
267
  registry: __1.LP_POOL,
265
- index: BigInt(input.perpIndex ?? 0),
268
+ index: BigInt(input.stakePool.pool_info.index),
266
269
  treasuryCaps: __1.TLP_TREASURY_CAP,
267
270
  oracle: constants_1.oracle[__1.NETWORK][input.cTOKEN],
268
271
  },
@@ -295,7 +298,7 @@ async function swap(client, tx, input) {
295
298
  arguments: {
296
299
  version: __1.PERP_VERSION,
297
300
  registry: __1.LP_POOL,
298
- index: BigInt(input.perpIndex ?? 0),
301
+ index: BigInt(input.perpIndex),
299
302
  oracleFromToken: constants_1.oracle[__1.NETWORK][input.FROM_TOKEN],
300
303
  oracleToToken: constants_1.oracle[__1.NETWORK][input.TO_TOKEN],
301
304
  fromCoin: coin,
@@ -308,15 +311,14 @@ async function swap(client, tx, input) {
308
311
  }
309
312
  async function harvestStakeReward(client, tx, input) {
310
313
  let iTokens = input.stakePool.incentives.map((i) => i.token_type.name);
311
- snapshot(client, tx, { userShareId: input.userShareId });
314
+ snapshot(client, tx, { perpIndex: input.stakePool.pool_info.index });
312
315
  for (let iToken of iTokens) {
313
316
  // console.log(iToken);
314
317
  let iCoin = tx.add((0, stake_pool_1.harvestPerUserShare)({
315
318
  arguments: {
316
319
  version: __1.STAKE_POOL_VERSION,
317
320
  registry: __1.STAKE_POOL,
318
- index: BigInt(input.perpIndex ?? 0),
319
- UserShareId: BigInt(input.userShareId),
321
+ index: BigInt(input.stakePool.pool_info.index),
320
322
  },
321
323
  typeArguments: [iToken],
322
324
  }));
@@ -326,9 +328,8 @@ async function harvestStakeReward(client, tx, input) {
326
328
  arguments: {
327
329
  version: __1.STAKE_POOL_VERSION,
328
330
  registry: __1.STAKE_POOL,
329
- index: BigInt(input.perpIndex ?? 0),
331
+ index: BigInt(input.stakePool.pool_info.index),
330
332
  lpToken: iCoin,
331
- UserShareId: BigInt(input.userShareId),
332
333
  },
333
334
  typeArguments: [(0, utils_1.normalizeStructTag)(input.stakePool.pool_info.stake_token.name)],
334
335
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typus/typus-perp-sdk",
3
- "version": "1.1.32-codegen-exp2",
3
+ "version": "1.1.32-codegen-exp4",
4
4
  "repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
5
5
  "author": "Typus",
6
6
  "description": "typus perp sdk",
@@ -8,11 +8,12 @@
8
8
  "dependencies": {
9
9
  "@mysten/bcs": "1.9.2",
10
10
  "@mysten/sui": "1.44.0",
11
- "@typus/typus-sdk": "1.8.21"
11
+ "@typus/typus-sdk": "1.8.30"
12
12
  },
13
13
  "resolutions": {
14
14
  "@mysten/bcs": "1.9.2",
15
- "@mysten/sui": "1.44.0"
15
+ "@mysten/sui": "1.44.0",
16
+ "@pythnetwork/pyth-sui-js": "2.3.0"
16
17
  },
17
18
  "devDependencies": {
18
19
  "@types/bs58": "^4.0.1",
@@ -43,4 +44,4 @@
43
44
  },
44
45
  "homepage": "https://github.com/Typus-Lab/typus-perp-sdk#readme",
45
46
  "packageManager": "yarn@4.10.3+sha512.c38cafb5c7bb273f3926d04e55e1d8c9dfa7d9c3ea1f36a4868fa028b9e5f72298f0b7f401ad5eb921749eb012eb1c3bb74bf7503df3ee43fd600d14a018266f"
46
- }
47
+ }