@typus/typus-perp-sdk 1.0.37 → 1.0.39
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/src/user/tlp.js +24 -64
- package/package.json +2 -2
package/dist/src/user/tlp.js
CHANGED
|
@@ -76,17 +76,17 @@ var constants_1 = require("@typus/typus-sdk/dist/src/constants");
|
|
|
76
76
|
var __1 = require("..");
|
|
77
77
|
function mintStakeLp(config, tx, pythClient, input) {
|
|
78
78
|
return __awaiter(this, void 0, void 0, function () {
|
|
79
|
-
var tokens, tokens_1, tokens_1_1, token, coin, destination,
|
|
80
|
-
var e_1, _a, _b, _c
|
|
81
|
-
return __generator(this, function (
|
|
82
|
-
switch (
|
|
79
|
+
var tokens, tokens_1, tokens_1_1, token, coin, destination, cToken, lpCoin;
|
|
80
|
+
var e_1, _a, _b, _c;
|
|
81
|
+
return __generator(this, function (_d) {
|
|
82
|
+
switch (_d.label) {
|
|
83
83
|
case 0:
|
|
84
84
|
tokens = input.lpPool.tokenPools.map(function (p) { return (0, constants_1.typeArgToAsset)("0x" + p.tokenType.name); });
|
|
85
85
|
// console.log("tokens", tokens);
|
|
86
86
|
return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, tokens)];
|
|
87
87
|
case 1:
|
|
88
88
|
// console.log("tokens", tokens);
|
|
89
|
-
|
|
89
|
+
_d.sent();
|
|
90
90
|
try {
|
|
91
91
|
for (tokens_1 = __values(tokens), tokens_1_1 = tokens_1.next(); !tokens_1_1.done; tokens_1_1 = tokens_1.next()) {
|
|
92
92
|
token = tokens_1_1.value;
|
|
@@ -119,27 +119,7 @@ function mintStakeLp(config, tx, pythClient, input) {
|
|
|
119
119
|
}
|
|
120
120
|
// console.log(iToken);
|
|
121
121
|
if (input.userShareId) {
|
|
122
|
-
|
|
123
|
-
try {
|
|
124
|
-
for (iTokens_1 = __values(iTokens), iTokens_1_1 = iTokens_1.next(); !iTokens_1_1.done; iTokens_1_1 = iTokens_1.next()) {
|
|
125
|
-
iToken = iTokens_1_1.value;
|
|
126
|
-
iCoin = (0, functions_2.harvestPerUserShare)(tx, iToken, {
|
|
127
|
-
version: __1.STAKE_POOL_VERSION,
|
|
128
|
-
registry: __1.STAKE_POOL,
|
|
129
|
-
index: BigInt(0),
|
|
130
|
-
userShareId: BigInt(input.userShareId),
|
|
131
|
-
clock: constants_1.CLOCK,
|
|
132
|
-
});
|
|
133
|
-
tx.transferObjects([iCoin], input.user);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
137
|
-
finally {
|
|
138
|
-
try {
|
|
139
|
-
if (iTokens_1_1 && !iTokens_1_1.done && (_d = iTokens_1.return)) _d.call(iTokens_1);
|
|
140
|
-
}
|
|
141
|
-
finally { if (e_2) throw e_2.error; }
|
|
142
|
-
}
|
|
122
|
+
harvestStakeReward(config, tx, { stakePool: input.stakePool, userShareId: input.userShareId, user: input.user });
|
|
143
123
|
}
|
|
144
124
|
cToken = constants_1.tokenType[__1.NETWORK][input.cTOKEN];
|
|
145
125
|
lpCoin = (0, functions_1.mintLp)(tx, [cToken, __1.TLP_TOKEN], {
|
|
@@ -166,15 +146,15 @@ function mintStakeLp(config, tx, pythClient, input) {
|
|
|
166
146
|
}
|
|
167
147
|
function unstakeBurn(config, tx, pythClient, input) {
|
|
168
148
|
return __awaiter(this, void 0, void 0, function () {
|
|
169
|
-
var tokens, tokens_2, tokens_2_1, token,
|
|
170
|
-
var
|
|
171
|
-
return __generator(this, function (
|
|
172
|
-
switch (
|
|
149
|
+
var tokens, tokens_2, tokens_2_1, token, lpCoin, burnCoin, cToken, coin;
|
|
150
|
+
var e_2, _a;
|
|
151
|
+
return __generator(this, function (_b) {
|
|
152
|
+
switch (_b.label) {
|
|
173
153
|
case 0:
|
|
174
154
|
tokens = input.lpPool.tokenPools.map(function (p) { return (0, constants_1.typeArgToAsset)("0x" + p.tokenType.name); });
|
|
175
155
|
return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, tokens)];
|
|
176
156
|
case 1:
|
|
177
|
-
|
|
157
|
+
_b.sent();
|
|
178
158
|
try {
|
|
179
159
|
for (tokens_2 = __values(tokens), tokens_2_1 = tokens_2.next(); !tokens_2_1.done; tokens_2_1 = tokens_2.next()) {
|
|
180
160
|
token = tokens_2_1.value;
|
|
@@ -188,35 +168,15 @@ function unstakeBurn(config, tx, pythClient, input) {
|
|
|
188
168
|
});
|
|
189
169
|
}
|
|
190
170
|
}
|
|
191
|
-
catch (
|
|
171
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
192
172
|
finally {
|
|
193
173
|
try {
|
|
194
174
|
if (tokens_2_1 && !tokens_2_1.done && (_a = tokens_2.return)) _a.call(tokens_2);
|
|
195
175
|
}
|
|
196
|
-
finally { if (
|
|
176
|
+
finally { if (e_2) throw e_2.error; }
|
|
197
177
|
}
|
|
198
178
|
if (input.userShareId) {
|
|
199
|
-
|
|
200
|
-
try {
|
|
201
|
-
for (iTokens_2 = __values(iTokens), iTokens_2_1 = iTokens_2.next(); !iTokens_2_1.done; iTokens_2_1 = iTokens_2.next()) {
|
|
202
|
-
iToken = iTokens_2_1.value;
|
|
203
|
-
iCoin = (0, functions_2.harvestPerUserShare)(tx, iToken, {
|
|
204
|
-
version: __1.STAKE_POOL_VERSION,
|
|
205
|
-
registry: __1.STAKE_POOL,
|
|
206
|
-
index: BigInt(0),
|
|
207
|
-
userShareId: BigInt(input.userShareId),
|
|
208
|
-
clock: constants_1.CLOCK,
|
|
209
|
-
});
|
|
210
|
-
tx.transferObjects([iCoin], input.user);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
214
|
-
finally {
|
|
215
|
-
try {
|
|
216
|
-
if (iTokens_2_1 && !iTokens_2_1.done && (_b = iTokens_2.return)) _b.call(iTokens_2);
|
|
217
|
-
}
|
|
218
|
-
finally { if (e_4) throw e_4.error; }
|
|
219
|
-
}
|
|
179
|
+
harvestStakeReward(config, tx, { stakePool: input.stakePool, userShareId: input.userShareId, user: input.user });
|
|
220
180
|
}
|
|
221
181
|
lpCoin = (0, functions_2.unstake)(tx, __1.TLP_TOKEN, {
|
|
222
182
|
version: __1.STAKE_POOL_VERSION,
|
|
@@ -251,7 +211,7 @@ function unstakeBurn(config, tx, pythClient, input) {
|
|
|
251
211
|
function burnTlp(config, tx, pythClient, input) {
|
|
252
212
|
return __awaiter(this, void 0, void 0, function () {
|
|
253
213
|
var tokens, tokens_3, tokens_3_1, token, lpCoin, burnCoin, cToken, coin;
|
|
254
|
-
var
|
|
214
|
+
var e_3, _a;
|
|
255
215
|
return __generator(this, function (_b) {
|
|
256
216
|
switch (_b.label) {
|
|
257
217
|
case 0:
|
|
@@ -272,12 +232,12 @@ function burnTlp(config, tx, pythClient, input) {
|
|
|
272
232
|
});
|
|
273
233
|
}
|
|
274
234
|
}
|
|
275
|
-
catch (
|
|
235
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
276
236
|
finally {
|
|
277
237
|
try {
|
|
278
238
|
if (tokens_3_1 && !tokens_3_1.done && (_a = tokens_3.return)) _a.call(tokens_3);
|
|
279
239
|
}
|
|
280
|
-
finally { if (
|
|
240
|
+
finally { if (e_3) throw e_3.error; }
|
|
281
241
|
}
|
|
282
242
|
lpCoin = tx.object(input.lpCoin);
|
|
283
243
|
if (input.share) {
|
|
@@ -358,13 +318,13 @@ function unsubscribe(config, tx, input) {
|
|
|
358
318
|
}
|
|
359
319
|
function harvestStakeReward(config, tx, input) {
|
|
360
320
|
return __awaiter(this, void 0, void 0, function () {
|
|
361
|
-
var iTokens,
|
|
362
|
-
var
|
|
321
|
+
var iTokens, iTokens_1, iTokens_1_1, iToken, iCoin;
|
|
322
|
+
var e_4, _a;
|
|
363
323
|
return __generator(this, function (_b) {
|
|
364
324
|
iTokens = input.stakePool.incentives.map(function (i) { return i.tokenType.name; });
|
|
365
325
|
try {
|
|
366
|
-
for (
|
|
367
|
-
iToken =
|
|
326
|
+
for (iTokens_1 = __values(iTokens), iTokens_1_1 = iTokens_1.next(); !iTokens_1_1.done; iTokens_1_1 = iTokens_1.next()) {
|
|
327
|
+
iToken = iTokens_1_1.value;
|
|
368
328
|
iCoin = (0, functions_2.harvestPerUserShare)(tx, iToken, {
|
|
369
329
|
version: __1.STAKE_POOL_VERSION,
|
|
370
330
|
registry: __1.STAKE_POOL,
|
|
@@ -388,12 +348,12 @@ function harvestStakeReward(config, tx, input) {
|
|
|
388
348
|
}
|
|
389
349
|
}
|
|
390
350
|
}
|
|
391
|
-
catch (
|
|
351
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
392
352
|
finally {
|
|
393
353
|
try {
|
|
394
|
-
if (
|
|
354
|
+
if (iTokens_1_1 && !iTokens_1_1.done && (_a = iTokens_1.return)) _a.call(iTokens_1);
|
|
395
355
|
}
|
|
396
|
-
finally { if (
|
|
356
|
+
finally { if (e_4) throw e_4.error; }
|
|
397
357
|
}
|
|
398
358
|
return [2 /*return*/, tx];
|
|
399
359
|
});
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typus/typus-perp-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.39",
|
|
4
4
|
"repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
|
|
5
5
|
"author": "Typus",
|
|
6
6
|
"description": "typus perp sdk",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@typus/typus-sdk": "1.6.
|
|
9
|
+
"@typus/typus-sdk": "1.6.15"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@types/bs58": "^4.0.1",
|