@typus/typus-perp-sdk 1.1.3 → 1.1.5-pnl
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/api/sentio.js +1 -1
- package/dist/src/fetch.d.ts +10 -1
- package/dist/src/fetch.js +21 -8
- package/dist/src/typus_perp/lp-pool/functions.d.ts +34 -0
- package/dist/src/typus_perp/lp-pool/functions.js +56 -0
- package/dist/src/typus_perp/lp-pool/structs.d.ts +774 -0
- package/dist/src/typus_perp/lp-pool/structs.js +1952 -498
- package/dist/src/typus_perp/trading/functions.d.ts +64 -2
- package/dist/src/typus_perp/trading/functions.js +93 -3
- package/dist/src/typus_perp/user-account/functions.d.ts +36 -0
- package/dist/src/typus_perp/user-account/functions.js +70 -0
- package/dist/src/typus_perp/user-account/structs.d.ts +168 -0
- package/dist/src/typus_perp/user-account/structs.js +448 -0
- package/dist/src/user/history.d.ts +1 -1
- package/dist/src/user/history.js +51 -6
- package/dist/src/user/orderWithBidReceipt.d.ts +11 -0
- package/dist/src/user/orderWithBidReceipt.js +72 -8
- package/package.json +2 -2
|
@@ -47,14 +47,16 @@ var __values = (this && this.__values) || function(o) {
|
|
|
47
47
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
48
|
};
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.createTradingOrderWithBidReceiptByAutoBid = createTradingOrderWithBidReceiptByAutoBid;
|
|
50
51
|
exports.createTradingOrderWithBidReceipt = createTradingOrderWithBidReceipt;
|
|
51
52
|
exports.reduceOptionCollateralPositionSize = reduceOptionCollateralPositionSize;
|
|
52
53
|
var functions_1 = require("../typus_perp/trading/functions");
|
|
53
54
|
var utils_1 = require("@typus/typus-sdk/dist/src/utils");
|
|
54
55
|
var constants_1 = require("@typus/typus-sdk/dist/src/constants");
|
|
55
56
|
var typus_dov_single_v2_1 = require("@typus/typus-sdk/dist/src/typus-dov-single-v2");
|
|
57
|
+
var user_entry_1 = require("@typus/typus-sdk/dist/src/auto-bid/user-entry");
|
|
56
58
|
var __1 = require("..");
|
|
57
|
-
function
|
|
59
|
+
function createTradingOrderWithBidReceiptByAutoBid(config, tx, pythClient, input) {
|
|
58
60
|
return __awaiter(this, void 0, void 0, function () {
|
|
59
61
|
var TOKEN, BASE_TOKEN, tokens, suiCoin, tokens_1, tokens_1_1, token, collateralBidReceipt, cToken, bToken, baseToken;
|
|
60
62
|
var e_1, _a;
|
|
@@ -83,11 +85,11 @@ function createTradingOrderWithBidReceipt(config, tx, pythClient, input) {
|
|
|
83
85
|
}
|
|
84
86
|
finally { if (e_1) throw e_1.error; }
|
|
85
87
|
}
|
|
86
|
-
collateralBidReceipt = (0,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
collateralBidReceipt = (0, user_entry_1.getWithdrawBidReceiptTx)(config, tx, {
|
|
89
|
+
vaultIndex: input.index,
|
|
90
|
+
signalIndex: input.signalIndex,
|
|
91
|
+
strategyIndex: input.strategyIndex,
|
|
92
|
+
user: input.user,
|
|
91
93
|
});
|
|
92
94
|
cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
|
|
93
95
|
bToken = constants_1.tokenType[__1.NETWORK][input.bToken];
|
|
@@ -116,9 +118,9 @@ function createTradingOrderWithBidReceipt(config, tx, pythClient, input) {
|
|
|
116
118
|
});
|
|
117
119
|
});
|
|
118
120
|
}
|
|
119
|
-
function
|
|
121
|
+
function createTradingOrderWithBidReceipt(config, tx, pythClient, input) {
|
|
120
122
|
return __awaiter(this, void 0, void 0, function () {
|
|
121
|
-
var TOKEN, BASE_TOKEN, tokens, suiCoin, tokens_2, tokens_2_1, token, cToken, bToken, baseToken;
|
|
123
|
+
var TOKEN, BASE_TOKEN, tokens, suiCoin, tokens_2, tokens_2_1, token, collateralBidReceipt, cToken, bToken, baseToken;
|
|
122
124
|
var e_2, _a;
|
|
123
125
|
return __generator(this, function (_b) {
|
|
124
126
|
switch (_b.label) {
|
|
@@ -145,6 +147,68 @@ function reduceOptionCollateralPositionSize(config, tx, pythClient, input) {
|
|
|
145
147
|
}
|
|
146
148
|
finally { if (e_2) throw e_2.error; }
|
|
147
149
|
}
|
|
150
|
+
collateralBidReceipt = (0, typus_dov_single_v2_1.getSplitBidReceiptTx)(config, tx, {
|
|
151
|
+
index: input.index,
|
|
152
|
+
receipts: input.bidReceipts,
|
|
153
|
+
share: input.share, // if undefined, merge all receipts
|
|
154
|
+
recipient: input.user,
|
|
155
|
+
});
|
|
156
|
+
cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
|
|
157
|
+
bToken = constants_1.tokenType[__1.NETWORK][input.bToken];
|
|
158
|
+
baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
|
|
159
|
+
(0, functions_1.createTradingOrderWithBidReceiptV2)(tx, [cToken, bToken, baseToken], {
|
|
160
|
+
version: __1.PERP_VERSION,
|
|
161
|
+
registry: __1.MARKET,
|
|
162
|
+
poolRegistry: __1.LP_POOL,
|
|
163
|
+
marketIndex: BigInt(0),
|
|
164
|
+
poolIndex: BigInt(0),
|
|
165
|
+
typusOracleCToken: constants_1.oracle[__1.NETWORK][TOKEN],
|
|
166
|
+
typusOracleTradingSymbol: constants_1.oracle[__1.NETWORK][BASE_TOKEN],
|
|
167
|
+
clock: constants_1.CLOCK,
|
|
168
|
+
typusEcosystemVersion: config.version.typus,
|
|
169
|
+
typusUserRegistry: config.registry.typus.user,
|
|
170
|
+
typusLeaderboardRegistry: config.registry.typus.leaderboard,
|
|
171
|
+
isLong: input.isLong,
|
|
172
|
+
dovRegistry: config.registry.dov.dovSingle,
|
|
173
|
+
collateralBidReceipt: collateralBidReceipt,
|
|
174
|
+
user: input.user,
|
|
175
|
+
tailsStakingRegistry: config.registry.typus.tailsStaking,
|
|
176
|
+
competitionConfig: __1.COMPETITION_CONFIG,
|
|
177
|
+
});
|
|
178
|
+
return [2 /*return*/, tx];
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
function reduceOptionCollateralPositionSize(config, tx, pythClient, input) {
|
|
184
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
185
|
+
var TOKEN, BASE_TOKEN, tokens, suiCoin, tokens_3, tokens_3_1, token, cToken, bToken, baseToken;
|
|
186
|
+
var e_3, _a;
|
|
187
|
+
return __generator(this, function (_b) {
|
|
188
|
+
switch (_b.label) {
|
|
189
|
+
case 0:
|
|
190
|
+
TOKEN = input.cToken;
|
|
191
|
+
BASE_TOKEN = input.tradingToken;
|
|
192
|
+
tokens = Array.from(new Set([TOKEN, BASE_TOKEN]));
|
|
193
|
+
if (config.sponsored) {
|
|
194
|
+
suiCoin = (0, utils_1.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), config.sponsored);
|
|
195
|
+
}
|
|
196
|
+
return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, tokens, suiCoin)];
|
|
197
|
+
case 1:
|
|
198
|
+
_b.sent();
|
|
199
|
+
try {
|
|
200
|
+
for (tokens_3 = __values(tokens), tokens_3_1 = tokens_3.next(); !tokens_3_1.done; tokens_3_1 = tokens_3.next()) {
|
|
201
|
+
token = tokens_3_1.value;
|
|
202
|
+
(0, utils_1.updateOracleWithPythUsd)(pythClient, tx, config.package.oracle, token);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
206
|
+
finally {
|
|
207
|
+
try {
|
|
208
|
+
if (tokens_3_1 && !tokens_3_1.done && (_a = tokens_3.return)) _a.call(tokens_3);
|
|
209
|
+
}
|
|
210
|
+
finally { if (e_3) throw e_3.error; }
|
|
211
|
+
}
|
|
148
212
|
cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
|
|
149
213
|
bToken = constants_1.tokenType[__1.NETWORK][input.bToken];
|
|
150
214
|
baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typus/typus-perp-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5-pnl",
|
|
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.8.
|
|
9
|
+
"@typus/typus-sdk": "1.8.6"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@types/bs58": "^4.0.1",
|