@typus/typus-perp-sdk 1.0.2 → 1.0.4
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/fetch.d.ts +2 -0
- package/dist/src/fetch.js +28 -13
- package/dist/src/index.d.ts +8 -0
- package/dist/src/index.js +12 -2
- package/dist/src/typus_perp/admin/structs.d.ts +66 -4
- package/dist/src/typus_perp/admin/structs.js +155 -1
- package/dist/src/typus_perp/error/functions.d.ts +1 -0
- package/dist/src/typus_perp/error/functions.js +4 -0
- package/dist/src/typus_perp/escrow/structs.d.ts +1 -1
- package/dist/src/typus_perp/index.js +3 -3
- package/dist/src/typus_perp/init.js +2 -1
- package/dist/src/typus_perp/lp-pool/structs.d.ts +26 -26
- package/dist/src/typus_perp/oracle/structs.d.ts +2 -2
- package/dist/src/typus_perp/position/functions.d.ts +3 -0
- package/dist/src/typus_perp/position/functions.js +7 -1
- package/dist/src/typus_perp/position/structs.d.ts +24 -164
- package/dist/src/typus_perp/position/structs.js +19 -209
- package/dist/src/typus_perp/symbol/structs.d.ts +1 -1
- package/dist/src/typus_perp/tlp/structs.d.ts +2 -2
- package/dist/src/typus_perp/trading/structs.d.ts +173 -29
- package/dist/src/typus_perp/trading/structs.js +221 -1
- package/dist/src/typus_perp/treasury-caps/structs.d.ts +1 -1
- package/dist/src/typus_stake_pool/admin/structs.d.ts +4 -4
- package/dist/src/typus_stake_pool/index.js +3 -3
- package/dist/src/typus_stake_pool/stake-pool/structs.d.ts +22 -22
- package/dist/src/user/history.js +94 -14
- package/dist/src/user/order.js +17 -11
- package/dist/src/user/orderWithBidReceipt.d.ts +2 -4
- package/dist/src/user/orderWithBidReceipt.js +9 -20
- package/dist/src/user/tlp.js +18 -18
- package/package.json +2 -1
package/dist/src/user/history.js
CHANGED
|
@@ -42,6 +42,7 @@ var constants_1 = require("@typus/typus-sdk/dist/src/constants");
|
|
|
42
42
|
var index_1 = require("../typus_perp/index");
|
|
43
43
|
var structs_1 = require("../typus_perp/position/structs");
|
|
44
44
|
var structs_2 = require("../typus_perp/trading/structs");
|
|
45
|
+
var structs_3 = require("../../src/typus_perp/lp-pool/structs");
|
|
45
46
|
function getUserHistory(sender) {
|
|
46
47
|
return __awaiter(this, void 0, void 0, function () {
|
|
47
48
|
var raw_events, pageInfo, events;
|
|
@@ -67,10 +68,18 @@ function getUserHistory(sender) {
|
|
|
67
68
|
// console.log(timestamp);
|
|
68
69
|
switch (type) {
|
|
69
70
|
case structs_2.CreateTradingOrderEvent.$typeName:
|
|
71
|
+
case structs_2.CreateTradingOrderWithBidReceiptsEvent.$typeName:
|
|
70
72
|
var base_token = (0, constants_1.typeArgToToken)(json.base_token.name);
|
|
71
73
|
var collateral_token = (0, constants_1.typeArgToToken)(json.collateral_token.name);
|
|
74
|
+
var market = "".concat(base_token, "/USD");
|
|
72
75
|
var size = Number(json.size) / Math.pow(10, (0, constants_1.assetToDecimal)(base_token));
|
|
73
|
-
var collateral
|
|
76
|
+
var collateral;
|
|
77
|
+
if (json.collateral_amount) {
|
|
78
|
+
collateral = Number(json.collateral_amount) / Math.pow(10, (0, constants_1.assetToDecimal)(collateral_token));
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
collateral = Number(json.collateral_in_deposit_token) / Math.pow(10, (0, constants_1.assetToDecimal)(collateral_token));
|
|
82
|
+
}
|
|
74
83
|
var order_type = "Limit";
|
|
75
84
|
var price = json.trigger_price;
|
|
76
85
|
if (json.filled) {
|
|
@@ -85,9 +94,9 @@ function getUserHistory(sender) {
|
|
|
85
94
|
}
|
|
86
95
|
var e = {
|
|
87
96
|
action: "Place Order",
|
|
88
|
-
order_id:
|
|
97
|
+
order_id: json.order_id,
|
|
89
98
|
position_id: json.linked_position_id,
|
|
90
|
-
market:
|
|
99
|
+
market: market,
|
|
91
100
|
side: json.is_long ? "Long" : "Short",
|
|
92
101
|
order_type: order_type,
|
|
93
102
|
status: json.filled ? "Filled" : "Open",
|
|
@@ -105,47 +114,62 @@ function getUserHistory(sender) {
|
|
|
105
114
|
case structs_1.OrderFilledEvent.$typeName:
|
|
106
115
|
var base_token = (0, constants_1.typeArgToToken)(json.symbol.base_token.name);
|
|
107
116
|
var collateral_token = (0, constants_1.typeArgToToken)(json.collateral_token.name);
|
|
117
|
+
var market = "".concat(base_token, "/USD");
|
|
108
118
|
var size = Number(json.filled_size) / Math.pow(10, (0, constants_1.assetToDecimal)(base_token));
|
|
109
119
|
var price = json.filled_price;
|
|
110
120
|
var action;
|
|
121
|
+
var related;
|
|
111
122
|
if (json.linked_position_id) {
|
|
112
123
|
action = "Order Filled (Close Position)";
|
|
124
|
+
related = events.findLast(function (e) { return e.position_id === json.linked_position_id && e.market === market; });
|
|
125
|
+
// the "Place Order" is emit after Order Filled if filled immediately
|
|
113
126
|
}
|
|
114
127
|
else {
|
|
115
128
|
action = "Order Filled (Open Position)";
|
|
129
|
+
related = events.findLast(function (e) { return e.order_id === json.order_id && e.market === market; });
|
|
116
130
|
}
|
|
117
|
-
var realized_trading_fee = Number(json.realized_trading_fee) + Number(json.realized_borrow_fee);
|
|
131
|
+
// var realized_trading_fee = Number(json.realized_trading_fee) + Number(json.realized_borrow_fee);
|
|
132
|
+
var realized_fee_in_usd = Number(json.realized_fee_in_usd) / Math.pow(10, 9);
|
|
118
133
|
var e = {
|
|
119
134
|
action: action,
|
|
120
135
|
order_id: json.order_id,
|
|
121
136
|
position_id: (_a = json.linked_position_id) !== null && _a !== void 0 ? _a : json.new_position_id,
|
|
122
|
-
market:
|
|
123
|
-
side: "Long"
|
|
124
|
-
order_type:
|
|
125
|
-
status:
|
|
137
|
+
market: market,
|
|
138
|
+
side: json.position_side ? "Long" : "Short",
|
|
139
|
+
order_type: related === null || related === void 0 ? void 0 : related.order_type,
|
|
140
|
+
status: "Filled",
|
|
126
141
|
size: size,
|
|
127
142
|
base_token: base_token,
|
|
128
|
-
collateral: 0
|
|
143
|
+
collateral: related === null || related === void 0 ? void 0 : related.collateral,
|
|
129
144
|
collateral_token: collateral_token,
|
|
130
145
|
price: Number(price) / Math.pow(10, 8), // WARNING: fixed decimal
|
|
131
|
-
realized_pnl:
|
|
146
|
+
realized_pnl: 0 - realized_fee_in_usd,
|
|
132
147
|
timestamp: timestamp,
|
|
133
148
|
tx_digest: tx_digest,
|
|
134
149
|
};
|
|
135
150
|
events.push(e);
|
|
136
151
|
break;
|
|
152
|
+
case structs_1.RealizeFundingEvent.$typeName:
|
|
153
|
+
// same tx with order filled
|
|
154
|
+
related = events.findLast(function (e) { return e.tx_digest === json.tx_digest; });
|
|
155
|
+
if (related) {
|
|
156
|
+
var x = json.realized_funding_sign ? json.realized_funding_fee : -json.realized_funding_fee;
|
|
157
|
+
related.realized_pnl = related.realized_pnl + x;
|
|
158
|
+
}
|
|
137
159
|
case structs_2.CancelTradingOrderEvent.$typeName:
|
|
138
160
|
var base_token = (0, constants_1.typeArgToToken)(json.base_token.name);
|
|
139
161
|
var collateral_token = (0, constants_1.typeArgToToken)(json.collateral_token.name);
|
|
162
|
+
var market = "".concat(base_token, "/USD");
|
|
163
|
+
var related = events.findLast(function (e) { return e.order_id === json.order_id && e.market === market; });
|
|
140
164
|
var e = {
|
|
141
165
|
action: "Cancel Order",
|
|
142
166
|
order_id: json.order_id,
|
|
143
167
|
position_id: undefined,
|
|
144
|
-
market:
|
|
145
|
-
side:
|
|
146
|
-
order_type:
|
|
168
|
+
market: market,
|
|
169
|
+
side: related === null || related === void 0 ? void 0 : related.side,
|
|
170
|
+
order_type: related === null || related === void 0 ? void 0 : related.order_type,
|
|
147
171
|
status: "Canceled",
|
|
148
|
-
size: 0,
|
|
172
|
+
size: related === null || related === void 0 ? void 0 : related.size,
|
|
149
173
|
base_token: base_token,
|
|
150
174
|
collateral: Number(json.released_collateral_amount) / Math.pow(10, (0, constants_1.assetToDecimal)(collateral_token)), // WARNING: fixed decimal
|
|
151
175
|
collateral_token: collateral_token,
|
|
@@ -156,6 +180,62 @@ function getUserHistory(sender) {
|
|
|
156
180
|
};
|
|
157
181
|
events.push(e);
|
|
158
182
|
break;
|
|
183
|
+
case structs_2.IncreaseCollateralEvent.$typeName:
|
|
184
|
+
case structs_2.ReleaseCollateralEvent.$typeName:
|
|
185
|
+
var base_token = (0, constants_1.typeArgToToken)(json.base_token.name);
|
|
186
|
+
var collateral_token = (0, constants_1.typeArgToToken)(json.collateral_token.name);
|
|
187
|
+
var market = "".concat(base_token, "/USD");
|
|
188
|
+
var related = events.findLast(function (e) { return e.position_id === json.position_id && e.market === market; });
|
|
189
|
+
var collateral;
|
|
190
|
+
if (json.increased_collateral_amount) {
|
|
191
|
+
collateral = Number(json.increased_collateral_amount);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
collateral = Number(json.released_collateral_amount) * -1;
|
|
195
|
+
}
|
|
196
|
+
var e = {
|
|
197
|
+
action: "Modify Collateral",
|
|
198
|
+
order_id: undefined,
|
|
199
|
+
position_id: json.position_id,
|
|
200
|
+
market: market,
|
|
201
|
+
side: related === null || related === void 0 ? void 0 : related.side,
|
|
202
|
+
order_type: related === null || related === void 0 ? void 0 : related.order_type,
|
|
203
|
+
status: "Filled",
|
|
204
|
+
size: related === null || related === void 0 ? void 0 : related.size,
|
|
205
|
+
base_token: base_token,
|
|
206
|
+
collateral: collateral / Math.pow(10, (0, constants_1.assetToDecimal)(collateral_token)), // WARNING: fixed decimal
|
|
207
|
+
collateral_token: collateral_token,
|
|
208
|
+
price: related === null || related === void 0 ? void 0 : related.price,
|
|
209
|
+
realized_pnl: undefined,
|
|
210
|
+
timestamp: timestamp,
|
|
211
|
+
tx_digest: tx_digest,
|
|
212
|
+
};
|
|
213
|
+
events.push(e);
|
|
214
|
+
break;
|
|
215
|
+
case structs_3.SwapEvent.$typeName:
|
|
216
|
+
var from_token = (0, constants_1.typeArgToToken)(json.from_token_type.name);
|
|
217
|
+
var to_token = (0, constants_1.typeArgToToken)(json.to_token_type.name);
|
|
218
|
+
var from_price = Number(json.oracle_price_from_token);
|
|
219
|
+
var to_price = Number(json.oracle_price_to_token);
|
|
220
|
+
var e = {
|
|
221
|
+
action: "Swap",
|
|
222
|
+
order_id: undefined,
|
|
223
|
+
position_id: undefined,
|
|
224
|
+
market: "".concat(from_token, "/").concat(to_token),
|
|
225
|
+
side: undefined,
|
|
226
|
+
order_type: "Market",
|
|
227
|
+
status: "Filled",
|
|
228
|
+
size: Number(json.actual_to_amount) / Math.pow(10, (0, constants_1.assetToDecimal)(to_token)),
|
|
229
|
+
base_token: to_token,
|
|
230
|
+
collateral: Number(json.from_amount) / Math.pow(10, (0, constants_1.assetToDecimal)(from_token)),
|
|
231
|
+
collateral_token: from_token,
|
|
232
|
+
price: from_price / to_price,
|
|
233
|
+
realized_pnl: -Number(json.fee_amount_usd) / Math.pow(10, 6),
|
|
234
|
+
timestamp: timestamp,
|
|
235
|
+
tx_digest: tx_digest,
|
|
236
|
+
};
|
|
237
|
+
events.push(e);
|
|
238
|
+
break;
|
|
159
239
|
}
|
|
160
240
|
});
|
|
161
241
|
console.log(events);
|
package/dist/src/user/order.js
CHANGED
|
@@ -85,9 +85,9 @@ function createTradingOrder(config, tx, pythClient, input) {
|
|
|
85
85
|
_b = __read(tx.splitCoins(destination, [input.amount]), 1), coin = _b[0];
|
|
86
86
|
}
|
|
87
87
|
(0, functions_1.createTradingOrder)(tx, [cToken, baseToken], {
|
|
88
|
-
version:
|
|
89
|
-
registry:
|
|
90
|
-
poolRegistry:
|
|
88
|
+
version: __1.PERP_VERSION,
|
|
89
|
+
registry: __1.MARKET,
|
|
90
|
+
poolRegistry: __1.LP_POOL,
|
|
91
91
|
marketIndex: BigInt(0),
|
|
92
92
|
poolIndex: BigInt(0),
|
|
93
93
|
pythState: utils_1.pythStateId[__1.NETWORK],
|
|
@@ -117,8 +117,8 @@ function cancelTradingOrder(config, tx, input) {
|
|
|
117
117
|
cToken = "0x" + input.order.collateralToken.name;
|
|
118
118
|
BASE_TOKEN = "0x" + input.order.symbol.baseToken.name;
|
|
119
119
|
coin = (0, functions_1.cancelTradingOrder)(tx, [cToken, BASE_TOKEN], {
|
|
120
|
-
version:
|
|
121
|
-
registry:
|
|
120
|
+
version: __1.PERP_VERSION,
|
|
121
|
+
registry: __1.MARKET,
|
|
122
122
|
marketIndex: BigInt(0),
|
|
123
123
|
orderId: input.order.orderId,
|
|
124
124
|
triggerPrice: input.order.triggerPrice,
|
|
@@ -137,6 +137,9 @@ function increaseCollateral(config, tx, pythClient, input) {
|
|
|
137
137
|
switch (_c.label) {
|
|
138
138
|
case 0:
|
|
139
139
|
TOKEN = (0, constants_1.typeArgToToken)(input.position.collateralToken.name);
|
|
140
|
+
if (TOKEN == "USDC") {
|
|
141
|
+
TOKEN = "wUSDC";
|
|
142
|
+
}
|
|
140
143
|
BASE_TOKEN = (0, constants_1.typeArgToToken)(input.position.symbol.baseToken.name);
|
|
141
144
|
return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, [TOKEN, BASE_TOKEN])];
|
|
142
145
|
case 1:
|
|
@@ -154,9 +157,9 @@ function increaseCollateral(config, tx, pythClient, input) {
|
|
|
154
157
|
_b = __read(tx.splitCoins(destination, [input.amount]), 1), coin = _b[0];
|
|
155
158
|
}
|
|
156
159
|
(0, functions_1.increaseCollateral)(tx, [cToken, baseToken], {
|
|
157
|
-
version:
|
|
158
|
-
registry:
|
|
159
|
-
poolRegistry:
|
|
160
|
+
version: __1.PERP_VERSION,
|
|
161
|
+
registry: __1.MARKET,
|
|
162
|
+
poolRegistry: __1.LP_POOL,
|
|
160
163
|
marketIndex: BigInt(0),
|
|
161
164
|
poolIndex: BigInt(0),
|
|
162
165
|
pythState: utils_1.pythStateId[__1.NETWORK],
|
|
@@ -178,6 +181,9 @@ function releaseCollateral(config, tx, pythClient, input) {
|
|
|
178
181
|
switch (_a.label) {
|
|
179
182
|
case 0:
|
|
180
183
|
TOKEN = (0, constants_1.typeArgToToken)(input.position.collateralToken.name);
|
|
184
|
+
if (TOKEN == "USDC") {
|
|
185
|
+
TOKEN = "wUSDC";
|
|
186
|
+
}
|
|
181
187
|
BASE_TOKEN = (0, constants_1.typeArgToToken)(input.position.symbol.baseToken.name);
|
|
182
188
|
return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, [TOKEN, BASE_TOKEN])];
|
|
183
189
|
case 1:
|
|
@@ -185,9 +191,9 @@ function releaseCollateral(config, tx, pythClient, input) {
|
|
|
185
191
|
cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
|
|
186
192
|
baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
|
|
187
193
|
coin = (0, functions_1.releaseCollateral)(tx, [cToken, baseToken], {
|
|
188
|
-
version:
|
|
189
|
-
registry:
|
|
190
|
-
poolRegistry:
|
|
194
|
+
version: __1.PERP_VERSION,
|
|
195
|
+
registry: __1.MARKET,
|
|
196
|
+
poolRegistry: __1.LP_POOL,
|
|
191
197
|
marketIndex: BigInt(0),
|
|
192
198
|
poolIndex: BigInt(0),
|
|
193
199
|
pythState: utils_1.pythStateId[__1.NETWORK],
|
|
@@ -15,8 +15,6 @@ export declare function reduceOptionCollateralPositionSize(config: TypusConfig,
|
|
|
15
15
|
cToken: TOKEN;
|
|
16
16
|
tradingToken: TOKEN;
|
|
17
17
|
bToken: string;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
user: string;
|
|
21
|
-
bidReceipt: string;
|
|
18
|
+
positionId: string;
|
|
19
|
+
orderSize: string | null;
|
|
22
20
|
}): Promise<Transaction>;
|
|
@@ -70,9 +70,9 @@ function createTradingOrderWithBidReceipt(config, tx, pythClient, input) {
|
|
|
70
70
|
collateralBidReceipt = input.bidReceipt;
|
|
71
71
|
}
|
|
72
72
|
(0, functions_1.createTradingOrderWithBidReceipt)(tx, [cToken, bToken, baseToken], {
|
|
73
|
-
version:
|
|
74
|
-
registry:
|
|
75
|
-
poolRegistry:
|
|
73
|
+
version: __1.PERP_VERSION,
|
|
74
|
+
registry: __1.MARKET,
|
|
75
|
+
poolRegistry: __1.LP_POOL,
|
|
76
76
|
marketIndex: BigInt(0),
|
|
77
77
|
poolIndex: BigInt(0),
|
|
78
78
|
pythState: utils_1.pythStateId[__1.NETWORK],
|
|
@@ -95,7 +95,7 @@ function createTradingOrderWithBidReceipt(config, tx, pythClient, input) {
|
|
|
95
95
|
}
|
|
96
96
|
function reduceOptionCollateralPositionSize(config, tx, pythClient, input) {
|
|
97
97
|
return __awaiter(this, void 0, void 0, function () {
|
|
98
|
-
var TOKEN, BASE_TOKEN, cToken, bToken, baseToken
|
|
98
|
+
var TOKEN, BASE_TOKEN, cToken, bToken, baseToken;
|
|
99
99
|
return __generator(this, function (_a) {
|
|
100
100
|
switch (_a.label) {
|
|
101
101
|
case 0:
|
|
@@ -108,21 +108,10 @@ function reduceOptionCollateralPositionSize(config, tx, pythClient, input) {
|
|
|
108
108
|
bToken = constants_1.tokenType[__1.NETWORK][input.bToken];
|
|
109
109
|
baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
|
|
110
110
|
(0, utils_1.updateOracleWithPyth)(pythClient, tx, config.package.oracle, config.oracle[BASE_TOKEN.toLocaleLowerCase()], BASE_TOKEN, "USDC");
|
|
111
|
-
if (input.share) {
|
|
112
|
-
collateralBidReceipt = (0, typus_dov_single_v2_1.getSplitBidReceiptTx)(config, tx, {
|
|
113
|
-
index: input.index,
|
|
114
|
-
receipts: [input.bidReceipt],
|
|
115
|
-
share: input.share,
|
|
116
|
-
recipient: input.user,
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
collateralBidReceipt = input.bidReceipt;
|
|
121
|
-
}
|
|
122
111
|
(0, functions_1.reduceOptionCollateralPositionSize)(tx, [cToken, bToken, baseToken], {
|
|
123
|
-
version:
|
|
124
|
-
registry:
|
|
125
|
-
poolRegistry:
|
|
112
|
+
version: __1.PERP_VERSION,
|
|
113
|
+
registry: __1.MARKET,
|
|
114
|
+
poolRegistry: __1.LP_POOL,
|
|
126
115
|
marketIndex: BigInt(0),
|
|
127
116
|
poolIndex: BigInt(0),
|
|
128
117
|
pythState: utils_1.pythStateId[__1.NETWORK],
|
|
@@ -134,8 +123,8 @@ function reduceOptionCollateralPositionSize(config, tx, pythClient, input) {
|
|
|
134
123
|
typusLeaderboardRegistry: config.registry.typus.leaderboard,
|
|
135
124
|
dovRegistry: config.registry.dov.dovSingle,
|
|
136
125
|
typusOracle: config.oracle[BASE_TOKEN.toLocaleLowerCase()],
|
|
137
|
-
positionId: BigInt(
|
|
138
|
-
orderSize: null,
|
|
126
|
+
positionId: BigInt(input.positionId),
|
|
127
|
+
orderSize: input.orderSize ? BigInt(input.orderSize) : null,
|
|
139
128
|
});
|
|
140
129
|
return [2 /*return*/, tx];
|
|
141
130
|
}
|
package/dist/src/user/tlp.js
CHANGED
|
@@ -91,8 +91,8 @@ function mintStakeLp(config, tx, pythClient, input) {
|
|
|
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;
|
|
93
93
|
(0, functions_1.updateLiquidityValue)(tx, constants_1.tokenType[__1.NETWORK][token], {
|
|
94
|
-
version:
|
|
95
|
-
registry:
|
|
94
|
+
version: __1.PERP_VERSION,
|
|
95
|
+
registry: __1.LP_POOL,
|
|
96
96
|
index: BigInt(0),
|
|
97
97
|
pythState: utils_1.pythStateId[__1.NETWORK],
|
|
98
98
|
oracle: utils_1.priceInfoObjectIds[__1.NETWORK][token],
|
|
@@ -118,8 +118,8 @@ function mintStakeLp(config, tx, pythClient, input) {
|
|
|
118
118
|
_c = __read(tx.splitCoins(destination, [input.amount]), 1), coin = _c[0];
|
|
119
119
|
}
|
|
120
120
|
lpCoin = (0, functions_1.mintLp)(tx, [cToken, config.token.tlp], {
|
|
121
|
-
version:
|
|
122
|
-
registry:
|
|
121
|
+
version: __1.PERP_VERSION,
|
|
122
|
+
registry: __1.LP_POOL,
|
|
123
123
|
treasuryCaps: config.object.tlpTreasuryCap,
|
|
124
124
|
index: BigInt(0),
|
|
125
125
|
pythState: utils_1.pythStateId[__1.NETWORK],
|
|
@@ -128,8 +128,8 @@ function mintStakeLp(config, tx, pythClient, input) {
|
|
|
128
128
|
clock: constants_1.CLOCK,
|
|
129
129
|
});
|
|
130
130
|
(0, functions_2.stake)(tx, config.token.tlp, {
|
|
131
|
-
version:
|
|
132
|
-
registry:
|
|
131
|
+
version: __1.STAKE_POOL_VERSION,
|
|
132
|
+
registry: __1.STAKE_POOL,
|
|
133
133
|
index: BigInt(0),
|
|
134
134
|
lpToken: lpCoin,
|
|
135
135
|
clock: constants_1.CLOCK,
|
|
@@ -157,8 +157,8 @@ function unstakeBurn(config, tx, pythClient, input) {
|
|
|
157
157
|
for (tokens_2 = __values(tokens), tokens_2_1 = tokens_2.next(); !tokens_2_1.done; tokens_2_1 = tokens_2.next()) {
|
|
158
158
|
token = tokens_2_1.value;
|
|
159
159
|
(0, functions_1.updateLiquidityValue)(tx, constants_1.tokenType[__1.NETWORK][token], {
|
|
160
|
-
version:
|
|
161
|
-
registry:
|
|
160
|
+
version: __1.PERP_VERSION,
|
|
161
|
+
registry: __1.LP_POOL,
|
|
162
162
|
index: BigInt(0),
|
|
163
163
|
pythState: utils_1.pythStateId[__1.NETWORK],
|
|
164
164
|
oracle: utils_1.priceInfoObjectIds[__1.NETWORK][token],
|
|
@@ -174,16 +174,16 @@ function unstakeBurn(config, tx, pythClient, input) {
|
|
|
174
174
|
finally { if (e_2) throw e_2.error; }
|
|
175
175
|
}
|
|
176
176
|
lpCoin = (0, functions_2.unstake)(tx, config.token.tlp, {
|
|
177
|
-
version:
|
|
178
|
-
registry:
|
|
177
|
+
version: __1.STAKE_POOL_VERSION,
|
|
178
|
+
registry: __1.STAKE_POOL,
|
|
179
179
|
index: BigInt(0),
|
|
180
180
|
userShareId: BigInt(input.userShareId),
|
|
181
181
|
clock: constants_1.CLOCK,
|
|
182
182
|
unstakedShares: input.share ? BigInt(input.share) : null,
|
|
183
183
|
});
|
|
184
184
|
coin = (0, functions_1.burnLp)(tx, [cToken, config.token.tlp], {
|
|
185
|
-
version:
|
|
186
|
-
registry:
|
|
185
|
+
version: __1.PERP_VERSION,
|
|
186
|
+
registry: __1.LP_POOL,
|
|
187
187
|
treasuryCaps: config.object.tlpTreasuryCap,
|
|
188
188
|
index: BigInt(0),
|
|
189
189
|
pythState: utils_1.pythStateId[__1.NETWORK],
|
|
@@ -219,8 +219,8 @@ function swap(config, tx, pythClient, input) {
|
|
|
219
219
|
_b = __read(tx.splitCoins(destination, [input.amount]), 1), coin = _b[0];
|
|
220
220
|
}
|
|
221
221
|
token = (0, functions_1.swap)(tx, [fromToken, toToken], {
|
|
222
|
-
version:
|
|
223
|
-
registry:
|
|
222
|
+
version: __1.PERP_VERSION,
|
|
223
|
+
registry: __1.LP_POOL,
|
|
224
224
|
pythState: utils_1.pythStateId[__1.NETWORK],
|
|
225
225
|
clock: constants_1.CLOCK,
|
|
226
226
|
index: BigInt(0),
|
|
@@ -239,8 +239,8 @@ function unsubscribe(config, tx, input) {
|
|
|
239
239
|
return __awaiter(this, void 0, void 0, function () {
|
|
240
240
|
return __generator(this, function (_a) {
|
|
241
241
|
(0, functions_2.unsubscribe)(tx, config.token.tlp, {
|
|
242
|
-
version:
|
|
243
|
-
registry:
|
|
242
|
+
version: __1.STAKE_POOL_VERSION,
|
|
243
|
+
registry: __1.STAKE_POOL,
|
|
244
244
|
index: BigInt(0),
|
|
245
245
|
userShareId: BigInt(input.userShareId),
|
|
246
246
|
clock: constants_1.CLOCK,
|
|
@@ -254,8 +254,8 @@ function harvest(config, tx, input) {
|
|
|
254
254
|
return __awaiter(this, void 0, void 0, function () {
|
|
255
255
|
return __generator(this, function (_a) {
|
|
256
256
|
(0, functions_2.harvestPerUserShare)(tx, "0x2::sui::SUI", {
|
|
257
|
-
version:
|
|
258
|
-
registry:
|
|
257
|
+
version: __1.STAKE_POOL_VERSION,
|
|
258
|
+
registry: __1.STAKE_POOL,
|
|
259
259
|
index: BigInt(0),
|
|
260
260
|
userShareId: BigInt(input.userShareId),
|
|
261
261
|
clock: constants_1.CLOCK,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typus/typus-perp-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
|
|
5
5
|
"author": "Typus",
|
|
6
6
|
"description": "typus perp sdk",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"prettier": "^3.0.0",
|
|
18
18
|
"ts-node": "^10.9.2",
|
|
19
19
|
"tsc-alias": "^1.8.10",
|
|
20
|
+
"tsconfig-paths": "^4.2.0",
|
|
20
21
|
"tslint": "^6.1.3",
|
|
21
22
|
"tslint-config-prettier": "^1.18.0",
|
|
22
23
|
"typescript": "^5.1.6"
|