@typus/typus-perp-sdk 1.0.84 → 1.0.85
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/pyth.d.ts +0 -0
- package/dist/src/pyth.js +1 -0
- package/dist/src/user/order.d.ts +3 -0
- package/dist/src/user/order.js +62 -21
- package/dist/src/user/orderWithBidReceipt.d.ts +2 -0
- package/dist/src/user/orderWithBidReceipt.js +10 -4
- package/dist/src/user/tlp.d.ts +5 -0
- package/dist/src/user/tlp.js +67 -36
- package/package.json +2 -2
|
File without changes
|
package/dist/src/pyth.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/dist/src/user/order.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare function createTradingOrder(config: TypusConfig, tx: Transaction,
|
|
|
13
13
|
isStopOrder: boolean;
|
|
14
14
|
reduceOnly: boolean;
|
|
15
15
|
linkedPositionId: string | null;
|
|
16
|
+
suiCoins?: string[];
|
|
16
17
|
}): Promise<Transaction>;
|
|
17
18
|
export declare function zeroCoin(tx: Transaction, typeArgs: [string]): import("@mysten/sui/transactions").TransactionResult;
|
|
18
19
|
export declare function cancelTradingOrder(config: TypusConfig, tx: Transaction, input: {
|
|
@@ -23,8 +24,10 @@ export declare function increaseCollateral(config: TypusConfig, tx: Transaction,
|
|
|
23
24
|
coins: string[];
|
|
24
25
|
amount: string;
|
|
25
26
|
position: Position;
|
|
27
|
+
suiCoins?: string[];
|
|
26
28
|
}): Promise<Transaction>;
|
|
27
29
|
export declare function releaseCollateral(config: TypusConfig, tx: Transaction, pythClient: PythClient, input: {
|
|
28
30
|
position: Position;
|
|
29
31
|
amount: string;
|
|
32
|
+
suiCoins?: string[];
|
|
30
33
|
}): Promise<Transaction>;
|
package/dist/src/user/order.js
CHANGED
|
@@ -35,6 +35,22 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
39
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
+
if (!m) return o;
|
|
41
|
+
var i = m.call(o), r, ar = [], e;
|
|
42
|
+
try {
|
|
43
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
+
}
|
|
45
|
+
catch (error) { e = { error: error }; }
|
|
46
|
+
finally {
|
|
47
|
+
try {
|
|
48
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
+
}
|
|
50
|
+
finally { if (e) throw e.error; }
|
|
51
|
+
}
|
|
52
|
+
return ar;
|
|
53
|
+
};
|
|
38
54
|
var __values = (this && this.__values) || function(o) {
|
|
39
55
|
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
56
|
if (m) return m.call(o);
|
|
@@ -58,20 +74,31 @@ var utils_1 = require("@typus/typus-sdk/dist/src/utils");
|
|
|
58
74
|
var constants_1 = require("@typus/typus-sdk/dist/src/constants");
|
|
59
75
|
function createTradingOrder(config, tx, pythClient, input) {
|
|
60
76
|
return __awaiter(this, void 0, void 0, function () {
|
|
61
|
-
var TOKEN, BASE_TOKEN, cToken, baseToken, coin,
|
|
62
|
-
var e_1,
|
|
63
|
-
return __generator(this, function (
|
|
64
|
-
switch (
|
|
77
|
+
var TOKEN, BASE_TOKEN, tokens, cToken, baseToken, coin, suiCoin, tokens_1, tokens_1_1, token;
|
|
78
|
+
var _a, e_1, _b;
|
|
79
|
+
return __generator(this, function (_c) {
|
|
80
|
+
switch (_c.label) {
|
|
65
81
|
case 0:
|
|
66
82
|
TOKEN = input.cToken;
|
|
67
83
|
BASE_TOKEN = input.tradingToken;
|
|
84
|
+
tokens = Array.from(new Set([TOKEN, BASE_TOKEN]));
|
|
68
85
|
cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
|
|
69
86
|
baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
87
|
+
if (TOKEN == constants_1.tokenType.MAINNET.SUI && config.sponsored) {
|
|
88
|
+
// split together
|
|
89
|
+
_a = __read((0, utils_1.splitCoins)(tx, constants_1.tokenType.MAINNET.SUI, input.coins, [input.amount, tokens.length.toString()], config.sponsored), 2), coin = _a[0], suiCoin = _a[1];
|
|
90
|
+
}
|
|
91
|
+
else if (config.sponsored) {
|
|
92
|
+
coin = (0, utils_1.splitCoin)(tx, cToken, input.coins, input.amount, config.sponsored);
|
|
93
|
+
suiCoin = (0, utils_1.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), config.sponsored);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
coin = (0, utils_1.splitCoin)(tx, cToken, input.coins, input.amount, config.sponsored);
|
|
97
|
+
// no suiCoin
|
|
98
|
+
}
|
|
99
|
+
return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, tokens, suiCoin)];
|
|
73
100
|
case 1:
|
|
74
|
-
|
|
101
|
+
_c.sent();
|
|
75
102
|
try {
|
|
76
103
|
for (tokens_1 = __values(tokens), tokens_1_1 = tokens_1.next(); !tokens_1_1.done; tokens_1_1 = tokens_1.next()) {
|
|
77
104
|
token = tokens_1_1.value;
|
|
@@ -81,7 +108,7 @@ function createTradingOrder(config, tx, pythClient, input) {
|
|
|
81
108
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
82
109
|
finally {
|
|
83
110
|
try {
|
|
84
|
-
if (tokens_1_1 && !tokens_1_1.done && (
|
|
111
|
+
if (tokens_1_1 && !tokens_1_1.done && (_b = tokens_1.return)) _b.call(tokens_1);
|
|
85
112
|
}
|
|
86
113
|
finally { if (e_1) throw e_1.error; }
|
|
87
114
|
}
|
|
@@ -140,17 +167,31 @@ function cancelTradingOrder(config, tx, input) {
|
|
|
140
167
|
}
|
|
141
168
|
function increaseCollateral(config, tx, pythClient, input) {
|
|
142
169
|
return __awaiter(this, void 0, void 0, function () {
|
|
143
|
-
var TOKEN, BASE_TOKEN, tokens,
|
|
144
|
-
var e_2,
|
|
145
|
-
return __generator(this, function (
|
|
146
|
-
switch (
|
|
170
|
+
var TOKEN, BASE_TOKEN, tokens, cToken, baseToken, coin, suiCoin, tokens_2, tokens_2_1, token;
|
|
171
|
+
var _a, e_2, _b;
|
|
172
|
+
return __generator(this, function (_c) {
|
|
173
|
+
switch (_c.label) {
|
|
147
174
|
case 0:
|
|
148
175
|
TOKEN = (0, constants_1.typeArgToAsset)(input.position.collateralToken.name);
|
|
149
176
|
BASE_TOKEN = (0, constants_1.typeArgToAsset)(input.position.symbol.baseToken.name);
|
|
150
177
|
tokens = Array.from(new Set([TOKEN, BASE_TOKEN]));
|
|
151
|
-
|
|
178
|
+
cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
|
|
179
|
+
baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
|
|
180
|
+
if (TOKEN == constants_1.tokenType.MAINNET.SUI && config.sponsored) {
|
|
181
|
+
// split together
|
|
182
|
+
_a = __read((0, utils_1.splitCoins)(tx, constants_1.tokenType.MAINNET.SUI, input.coins, [input.amount, tokens.length.toString()], config.sponsored), 2), coin = _a[0], suiCoin = _a[1];
|
|
183
|
+
}
|
|
184
|
+
else if (config.sponsored) {
|
|
185
|
+
coin = (0, utils_1.splitCoin)(tx, cToken, input.coins, input.amount, config.sponsored);
|
|
186
|
+
suiCoin = (0, utils_1.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), config.sponsored);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
coin = (0, utils_1.splitCoin)(tx, cToken, input.coins, input.amount, config.sponsored);
|
|
190
|
+
// no suiCoin
|
|
191
|
+
}
|
|
192
|
+
return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, tokens, suiCoin)];
|
|
152
193
|
case 1:
|
|
153
|
-
|
|
194
|
+
_c.sent();
|
|
154
195
|
try {
|
|
155
196
|
for (tokens_2 = __values(tokens), tokens_2_1 = tokens_2.next(); !tokens_2_1.done; tokens_2_1 = tokens_2.next()) {
|
|
156
197
|
token = tokens_2_1.value;
|
|
@@ -160,13 +201,10 @@ function increaseCollateral(config, tx, pythClient, input) {
|
|
|
160
201
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
161
202
|
finally {
|
|
162
203
|
try {
|
|
163
|
-
if (tokens_2_1 && !tokens_2_1.done && (
|
|
204
|
+
if (tokens_2_1 && !tokens_2_1.done && (_b = tokens_2.return)) _b.call(tokens_2);
|
|
164
205
|
}
|
|
165
206
|
finally { if (e_2) throw e_2.error; }
|
|
166
207
|
}
|
|
167
|
-
cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
|
|
168
|
-
baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
|
|
169
|
-
coin = (0, utils_1.splitCoins)(tx, cToken, input.coins, input.amount, config.sponsored);
|
|
170
208
|
(0, functions_1.increaseCollateral)(tx, [cToken, baseToken], {
|
|
171
209
|
version: __1.PERP_VERSION,
|
|
172
210
|
registry: __1.MARKET,
|
|
@@ -186,7 +224,7 @@ function increaseCollateral(config, tx, pythClient, input) {
|
|
|
186
224
|
}
|
|
187
225
|
function releaseCollateral(config, tx, pythClient, input) {
|
|
188
226
|
return __awaiter(this, void 0, void 0, function () {
|
|
189
|
-
var TOKEN, BASE_TOKEN, tokens, tokens_3, tokens_3_1, token, cToken, baseToken, coin;
|
|
227
|
+
var TOKEN, BASE_TOKEN, tokens, suiCoin, tokens_3, tokens_3_1, token, cToken, baseToken, coin;
|
|
190
228
|
var e_3, _a;
|
|
191
229
|
return __generator(this, function (_b) {
|
|
192
230
|
switch (_b.label) {
|
|
@@ -194,7 +232,10 @@ function releaseCollateral(config, tx, pythClient, input) {
|
|
|
194
232
|
TOKEN = (0, constants_1.typeArgToAsset)(input.position.collateralToken.name);
|
|
195
233
|
BASE_TOKEN = (0, constants_1.typeArgToAsset)(input.position.symbol.baseToken.name);
|
|
196
234
|
tokens = Array.from(new Set([TOKEN, BASE_TOKEN]));
|
|
197
|
-
|
|
235
|
+
if (config.sponsored) {
|
|
236
|
+
suiCoin = (0, utils_1.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), config.sponsored);
|
|
237
|
+
}
|
|
238
|
+
return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, tokens, suiCoin)];
|
|
198
239
|
case 1:
|
|
199
240
|
_b.sent();
|
|
200
241
|
try {
|
|
@@ -10,6 +10,7 @@ export declare function createTradingOrderWithBidReceipt(config: TypusConfig, tx
|
|
|
10
10
|
bToken: TOKEN;
|
|
11
11
|
bidReceipts: string[];
|
|
12
12
|
share?: string;
|
|
13
|
+
suiCoins?: string[];
|
|
13
14
|
}): Promise<Transaction>;
|
|
14
15
|
export declare function reduceOptionCollateralPositionSize(config: TypusConfig, tx: Transaction, pythClient: PythClient, input: {
|
|
15
16
|
cToken: TOKEN;
|
|
@@ -17,4 +18,5 @@ export declare function reduceOptionCollateralPositionSize(config: TypusConfig,
|
|
|
17
18
|
bToken: string;
|
|
18
19
|
positionId: string;
|
|
19
20
|
orderSize: string | null;
|
|
21
|
+
suiCoins?: string[];
|
|
20
22
|
}): Promise<Transaction>;
|
|
@@ -56,7 +56,7 @@ var typus_dov_single_v2_1 = require("@typus/typus-sdk/dist/src/typus-dov-single-
|
|
|
56
56
|
var __1 = require("..");
|
|
57
57
|
function createTradingOrderWithBidReceipt(config, tx, pythClient, input) {
|
|
58
58
|
return __awaiter(this, void 0, void 0, function () {
|
|
59
|
-
var TOKEN, BASE_TOKEN, tokens, tokens_1, tokens_1_1, token, collateralBidReceipt, cToken, bToken, baseToken;
|
|
59
|
+
var TOKEN, BASE_TOKEN, tokens, suiCoin, tokens_1, tokens_1_1, token, collateralBidReceipt, cToken, bToken, baseToken;
|
|
60
60
|
var e_1, _a;
|
|
61
61
|
return __generator(this, function (_b) {
|
|
62
62
|
switch (_b.label) {
|
|
@@ -64,7 +64,10 @@ function createTradingOrderWithBidReceipt(config, tx, pythClient, input) {
|
|
|
64
64
|
TOKEN = input.cToken;
|
|
65
65
|
BASE_TOKEN = input.tradingToken;
|
|
66
66
|
tokens = Array.from(new Set([TOKEN, BASE_TOKEN]));
|
|
67
|
-
|
|
67
|
+
if (config.sponsored) {
|
|
68
|
+
suiCoin = (0, utils_1.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), config.sponsored);
|
|
69
|
+
}
|
|
70
|
+
return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, tokens, suiCoin)];
|
|
68
71
|
case 1:
|
|
69
72
|
_b.sent();
|
|
70
73
|
try {
|
|
@@ -115,7 +118,7 @@ function createTradingOrderWithBidReceipt(config, tx, pythClient, input) {
|
|
|
115
118
|
}
|
|
116
119
|
function reduceOptionCollateralPositionSize(config, tx, pythClient, input) {
|
|
117
120
|
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
-
var TOKEN, BASE_TOKEN, tokens, tokens_2, tokens_2_1, token, cToken, bToken, baseToken;
|
|
121
|
+
var TOKEN, BASE_TOKEN, tokens, suiCoin, tokens_2, tokens_2_1, token, cToken, bToken, baseToken;
|
|
119
122
|
var e_2, _a;
|
|
120
123
|
return __generator(this, function (_b) {
|
|
121
124
|
switch (_b.label) {
|
|
@@ -123,7 +126,10 @@ function reduceOptionCollateralPositionSize(config, tx, pythClient, input) {
|
|
|
123
126
|
TOKEN = input.cToken;
|
|
124
127
|
BASE_TOKEN = input.tradingToken;
|
|
125
128
|
tokens = Array.from(new Set([TOKEN, BASE_TOKEN]));
|
|
126
|
-
|
|
129
|
+
if (config.sponsored) {
|
|
130
|
+
suiCoin = (0, utils_1.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), config.sponsored);
|
|
131
|
+
}
|
|
132
|
+
return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, tokens, suiCoin)];
|
|
127
133
|
case 1:
|
|
128
134
|
_b.sent();
|
|
129
135
|
try {
|
package/dist/src/user/tlp.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export declare function mintStakeLp(config: TypusConfig, tx: Transaction, pythCl
|
|
|
15
15
|
userShareId: string | null;
|
|
16
16
|
user: string;
|
|
17
17
|
stake: boolean;
|
|
18
|
+
suiCoins?: string[];
|
|
18
19
|
}): Promise<Transaction>;
|
|
19
20
|
export declare function stakeLp(config: TypusConfig, tx: Transaction, input: {
|
|
20
21
|
stakePool: StakePool;
|
|
@@ -36,18 +37,21 @@ export declare function unstakeRedeem(config: TypusConfig, tx: Transaction, pyth
|
|
|
36
37
|
userShareId: string;
|
|
37
38
|
share: string | null;
|
|
38
39
|
user: string;
|
|
40
|
+
suiCoins?: string[];
|
|
39
41
|
}): Promise<Transaction>;
|
|
40
42
|
export declare function redeemTlp(config: TypusConfig, tx: Transaction, pythClient: PythClient, input: {
|
|
41
43
|
lpPool: LiquidityPool;
|
|
42
44
|
lpCoins: string[];
|
|
43
45
|
share: string | null;
|
|
44
46
|
user: string;
|
|
47
|
+
suiCoins?: string[];
|
|
45
48
|
}): Promise<Transaction>;
|
|
46
49
|
export declare function claim(config: TypusConfig, tx: Transaction, pythClient: PythClient, input: {
|
|
47
50
|
lpPool: LiquidityPool;
|
|
48
51
|
stakePool: StakePool;
|
|
49
52
|
cTOKEN: TOKEN;
|
|
50
53
|
user: string;
|
|
54
|
+
suiCoins?: string[];
|
|
51
55
|
}): Promise<Transaction>;
|
|
52
56
|
export declare function swap(config: TypusConfig, tx: Transaction, pythClient: PythClient, input: {
|
|
53
57
|
coins: string[];
|
|
@@ -55,6 +59,7 @@ export declare function swap(config: TypusConfig, tx: Transaction, pythClient: P
|
|
|
55
59
|
TO_TOKEN: TOKEN;
|
|
56
60
|
amount: string;
|
|
57
61
|
user: string;
|
|
62
|
+
suiCoins?: string[];
|
|
58
63
|
}): Promise<Transaction>;
|
|
59
64
|
export declare function harvestStakeReward(config: TypusConfig, tx: Transaction, input: {
|
|
60
65
|
stakePool: StakePool;
|
package/dist/src/user/tlp.js
CHANGED
|
@@ -35,17 +35,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
var __values = (this && this.__values) || function(o) {
|
|
39
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
-
if (m) return m.call(o);
|
|
41
|
-
if (o && typeof o.length === "number") return {
|
|
42
|
-
next: function () {
|
|
43
|
-
if (o && i >= o.length) o = void 0;
|
|
44
|
-
return { value: o && o[i++], done: !o };
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
-
};
|
|
49
38
|
var __read = (this && this.__read) || function (o, n) {
|
|
50
39
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
51
40
|
if (!m) return o;
|
|
@@ -62,6 +51,17 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
62
51
|
}
|
|
63
52
|
return ar;
|
|
64
53
|
};
|
|
54
|
+
var __values = (this && this.__values) || function(o) {
|
|
55
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
56
|
+
if (m) return m.call(o);
|
|
57
|
+
if (o && typeof o.length === "number") return {
|
|
58
|
+
next: function () {
|
|
59
|
+
if (o && i >= o.length) o = void 0;
|
|
60
|
+
return { value: o && o[i++], done: !o };
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
64
|
+
};
|
|
65
65
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66
66
|
exports.snapshot = snapshot;
|
|
67
67
|
exports.mintStakeLp = mintStakeLp;
|
|
@@ -95,17 +95,28 @@ function snapshot(config, tx, input) {
|
|
|
95
95
|
}
|
|
96
96
|
function mintStakeLp(config, tx, pythClient, input) {
|
|
97
97
|
return __awaiter(this, void 0, void 0, function () {
|
|
98
|
-
var tokens,
|
|
99
|
-
var e_1,
|
|
100
|
-
return __generator(this, function (
|
|
101
|
-
switch (
|
|
98
|
+
var tokens, cToken, coin, suiCoin, tokens_1, tokens_1_1, token, lpCoin;
|
|
99
|
+
var _a, e_1, _b;
|
|
100
|
+
return __generator(this, function (_c) {
|
|
101
|
+
switch (_c.label) {
|
|
102
102
|
case 0:
|
|
103
103
|
tokens = input.lpPool.tokenPools.map(function (p) { return (0, constants_1.typeArgToAsset)("0x" + p.tokenType.name); });
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
cToken = constants_1.tokenType[__1.NETWORK][input.cTOKEN];
|
|
105
|
+
if (input.cTOKEN == constants_1.tokenType.MAINNET.SUI && config.sponsored) {
|
|
106
|
+
// split together
|
|
107
|
+
_a = __read((0, utils_1.splitCoins)(tx, constants_1.tokenType.MAINNET.SUI, input.coins, [input.amount, tokens.length.toString()], config.sponsored), 2), coin = _a[0], suiCoin = _a[1];
|
|
108
|
+
}
|
|
109
|
+
else if (config.sponsored) {
|
|
110
|
+
coin = (0, utils_1.splitCoin)(tx, cToken, input.coins, input.amount, config.sponsored);
|
|
111
|
+
suiCoin = (0, utils_1.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), config.sponsored);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
coin = (0, utils_1.splitCoin)(tx, cToken, input.coins, input.amount, config.sponsored);
|
|
115
|
+
// no suiCoin
|
|
116
|
+
}
|
|
117
|
+
return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, tokens, suiCoin)];
|
|
106
118
|
case 1:
|
|
107
|
-
|
|
108
|
-
_b.sent();
|
|
119
|
+
_c.sent();
|
|
109
120
|
try {
|
|
110
121
|
for (tokens_1 = __values(tokens), tokens_1_1 = tokens_1.next(); !tokens_1_1.done; tokens_1_1 = tokens_1.next()) {
|
|
111
122
|
token = tokens_1_1.value;
|
|
@@ -122,12 +133,10 @@ function mintStakeLp(config, tx, pythClient, input) {
|
|
|
122
133
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
123
134
|
finally {
|
|
124
135
|
try {
|
|
125
|
-
if (tokens_1_1 && !tokens_1_1.done && (
|
|
136
|
+
if (tokens_1_1 && !tokens_1_1.done && (_b = tokens_1.return)) _b.call(tokens_1);
|
|
126
137
|
}
|
|
127
138
|
finally { if (e_1) throw e_1.error; }
|
|
128
139
|
}
|
|
129
|
-
cToken = constants_1.tokenType[__1.NETWORK][input.cTOKEN];
|
|
130
|
-
coin = (0, utils_1.splitCoins)(tx, cToken, input.coins, input.amount, config.sponsored);
|
|
131
140
|
// console.log(iToken);
|
|
132
141
|
if (input.userShareId) {
|
|
133
142
|
harvestStakeReward(config, tx, { stakePool: input.stakePool, userShareId: input.userShareId, user: input.user });
|
|
@@ -212,13 +221,16 @@ function unstake(config, tx, input) {
|
|
|
212
221
|
}
|
|
213
222
|
function unstakeRedeem(config, tx, pythClient, input) {
|
|
214
223
|
return __awaiter(this, void 0, void 0, function () {
|
|
215
|
-
var tokens, tokens_2, tokens_2_1, token, lpCoin, balance;
|
|
224
|
+
var tokens, suiCoin, tokens_2, tokens_2_1, token, lpCoin, balance;
|
|
216
225
|
var e_2, _a;
|
|
217
226
|
return __generator(this, function (_b) {
|
|
218
227
|
switch (_b.label) {
|
|
219
228
|
case 0:
|
|
220
229
|
tokens = input.lpPool.tokenPools.map(function (p) { return (0, constants_1.typeArgToAsset)("0x" + p.tokenType.name); });
|
|
221
|
-
|
|
230
|
+
if (config.sponsored) {
|
|
231
|
+
suiCoin = (0, utils_1.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), config.sponsored);
|
|
232
|
+
}
|
|
233
|
+
return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, tokens, suiCoin)];
|
|
222
234
|
case 1:
|
|
223
235
|
_b.sent();
|
|
224
236
|
try {
|
|
@@ -276,13 +288,16 @@ function unstakeRedeem(config, tx, pythClient, input) {
|
|
|
276
288
|
}
|
|
277
289
|
function redeemTlp(config, tx, pythClient, input) {
|
|
278
290
|
return __awaiter(this, void 0, void 0, function () {
|
|
279
|
-
var tokens, tokens_3, tokens_3_1, token, destination, lpCoin, burnCoin, balance;
|
|
291
|
+
var tokens, suiCoin, tokens_3, tokens_3_1, token, destination, lpCoin, burnCoin, balance;
|
|
280
292
|
var e_3, _a;
|
|
281
293
|
return __generator(this, function (_b) {
|
|
282
294
|
switch (_b.label) {
|
|
283
295
|
case 0:
|
|
284
296
|
tokens = input.lpPool.tokenPools.map(function (p) { return (0, constants_1.typeArgToAsset)("0x" + p.tokenType.name); });
|
|
285
|
-
|
|
297
|
+
if (config.sponsored) {
|
|
298
|
+
suiCoin = (0, utils_1.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), config.sponsored);
|
|
299
|
+
}
|
|
300
|
+
return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, tokens, suiCoin)];
|
|
286
301
|
case 1:
|
|
287
302
|
_b.sent();
|
|
288
303
|
try {
|
|
@@ -335,13 +350,16 @@ function redeemTlp(config, tx, pythClient, input) {
|
|
|
335
350
|
}
|
|
336
351
|
function claim(config, tx, pythClient, input) {
|
|
337
352
|
return __awaiter(this, void 0, void 0, function () {
|
|
338
|
-
var tokens, tokens_4, tokens_4_1, token_1, cToken, token;
|
|
353
|
+
var tokens, suiCoin, tokens_4, tokens_4_1, token_1, cToken, token;
|
|
339
354
|
var e_4, _a;
|
|
340
355
|
return __generator(this, function (_b) {
|
|
341
356
|
switch (_b.label) {
|
|
342
357
|
case 0:
|
|
343
358
|
tokens = input.lpPool.tokenPools.map(function (p) { return (0, constants_1.typeArgToAsset)("0x" + p.tokenType.name); });
|
|
344
|
-
|
|
359
|
+
if (config.sponsored) {
|
|
360
|
+
suiCoin = (0, utils_1.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), config.sponsored);
|
|
361
|
+
}
|
|
362
|
+
return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, tokens, suiCoin)];
|
|
345
363
|
case 1:
|
|
346
364
|
_b.sent();
|
|
347
365
|
try {
|
|
@@ -381,17 +399,30 @@ function claim(config, tx, pythClient, input) {
|
|
|
381
399
|
}
|
|
382
400
|
function swap(config, tx, pythClient, input) {
|
|
383
401
|
return __awaiter(this, void 0, void 0, function () {
|
|
384
|
-
var fromToken, coin,
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
402
|
+
var fromToken, toToken, coin, suiCoin, token;
|
|
403
|
+
var _a;
|
|
404
|
+
return __generator(this, function (_b) {
|
|
405
|
+
switch (_b.label) {
|
|
406
|
+
case 0:
|
|
407
|
+
fromToken = constants_1.tokenType[__1.NETWORK][input.FROM_TOKEN];
|
|
408
|
+
toToken = constants_1.tokenType[__1.NETWORK][input.TO_TOKEN];
|
|
409
|
+
if (input.FROM_TOKEN == constants_1.tokenType.MAINNET.SUI && config.sponsored) {
|
|
410
|
+
// split together
|
|
411
|
+
_a = __read((0, utils_1.splitCoins)(tx, constants_1.tokenType.MAINNET.SUI, input.coins, [input.amount, "2"], config.sponsored), 2), coin = _a[0], suiCoin = _a[1];
|
|
412
|
+
}
|
|
413
|
+
else if (config.sponsored) {
|
|
414
|
+
coin = (0, utils_1.splitCoin)(tx, fromToken, input.coins, input.amount, config.sponsored);
|
|
415
|
+
suiCoin = (0, utils_1.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, "2", config.sponsored);
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
coin = (0, utils_1.splitCoin)(tx, fromToken, input.coins, input.amount, config.sponsored);
|
|
419
|
+
// no suiCoin
|
|
420
|
+
}
|
|
421
|
+
return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, [input.FROM_TOKEN, input.TO_TOKEN], suiCoin)];
|
|
388
422
|
case 1:
|
|
389
|
-
|
|
423
|
+
_b.sent();
|
|
390
424
|
(0, utils_1.updateOracleWithPythUsd)(pythClient, tx, config.package.oracle, input.FROM_TOKEN);
|
|
391
425
|
(0, utils_1.updateOracleWithPythUsd)(pythClient, tx, config.package.oracle, input.TO_TOKEN);
|
|
392
|
-
fromToken = constants_1.tokenType[__1.NETWORK][input.FROM_TOKEN];
|
|
393
|
-
coin = (0, utils_1.splitCoins)(tx, fromToken, input.coins, input.amount, config.sponsored);
|
|
394
|
-
toToken = constants_1.tokenType[__1.NETWORK][input.TO_TOKEN];
|
|
395
426
|
token = (0, functions_1.swap)(tx, [fromToken, toToken], {
|
|
396
427
|
version: __1.PERP_VERSION,
|
|
397
428
|
registry: __1.LP_POOL,
|
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.85",
|
|
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.7.
|
|
9
|
+
"@typus/typus-sdk": "1.7.17"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@types/bs58": "^4.0.1",
|