@typus/typus-perp-sdk 1.1.3 → 1.1.5
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
CHANGED
|
@@ -100,7 +100,7 @@ function getRecentTradesFromSentio(base_token) {
|
|
|
100
100
|
}
|
|
101
101
|
requestData = {
|
|
102
102
|
sqlQuery: {
|
|
103
|
-
sql: "\n SELECT * FROM (\n SELECT\n PlaceOrder.timestamp as timestamp,\n PlaceOrder.base_token as base_token,\n PlaceOrder.collateral_token as collateral_token,\n PlaceOrder.order_type as order_type,\n OrderFilled.order_type as status,\n PlaceOrder.side as side,\n PlaceOrder.distinct_id as distinct_id,\n price,\n size,\n realized_amount-realized_fee-RealizeFunding.realized_funding_fee as realized_pnl,\n OrderFilled.realized_pnl-RealizeFunding.realized_funding_fee_usd as realized_pnl_usd,\n
|
|
103
|
+
sql: "\n SELECT * FROM (\n SELECT\n PlaceOrder.timestamp as timestamp,\n PlaceOrder.base_token as base_token,\n PlaceOrder.collateral_token as collateral_token,\n PlaceOrder.order_type as order_type,\n OrderFilled.order_type as status,\n PlaceOrder.side as side,\n PlaceOrder.distinct_id as distinct_id,\n price,\n size,\n realized_amount-realized_fee-RealizeFunding.realized_funding_fee as realized_pnl,\n OrderFilled.realized_pnl-RealizeFunding.realized_funding_fee_usd as realized_pnl_usd,\n CASE\n WHEN PlaceOrder.collateral > 0 THEN PlaceOrder.collateral\n WHEN RemovePosition.remaining_collateral_amount > 0 AND realized_pnl_usd >= 0 THEN RemovePosition.remaining_collateral_amount\n WHEN RemovePosition.remaining_collateral_amount > 0 AND realized_pnl_usd < 0 THEN RemovePosition.remaining_collateral_amount - realized_pnl_usd\n ELSE 0\n END AS collateral_amount,\n PlaceOrder.transaction_hash as transaction_hash\n FROM PlaceOrder\n LEFT JOIN OrderFilled ON OrderFilled.order_id == PlaceOrder.order_id AND OrderFilled.base_token == PlaceOrder.base_token\n LEFT JOIN RealizeFunding ON RealizeFunding.position_id == OrderFilled.position_id AND RealizeFunding.base_token == OrderFilled.base_token AND RealizeFunding.transaction_hash == OrderFilled.transaction_hash\n LEFT JOIN RealizeOption ON RealizeOption.position_id == OrderFilled.position_id AND RealizeOption.base_token == OrderFilled.base_token AND RealizeOption.transaction_hash == OrderFilled.transaction_hash\n LEFT JOIN RemovePosition ON RemovePosition.transaction_hash == OrderFilled.transaction_hash\n ".concat(tokenFilter, "\n UNION ALL\n SELECT\n PlaceOrderWithBidReceipt.timestamp as timestamp,\n PlaceOrderWithBidReceipt.base_token as base_token,\n PlaceOrderWithBidReceipt.collateral_token as collateral_token,\n PlaceOrderWithBidReceipt.order_type as order_type,\n OrderFilled.order_type as status,\n PlaceOrderWithBidReceipt.side as side,\n PlaceOrderWithBidReceipt.distinct_id as distinct_id,\n price,\n size,\n realized_amount-realized_fee-RealizeFunding.realized_funding_fee as realized_pnl,\n OrderFilled.realized_pnl-RealizeFunding.realized_funding_fee_usd as realized_pnl_usd,\n RealizeOption.exercise_balance_value as collateral_amount,\n PlaceOrderWithBidReceipt.transaction_hash as transaction_hash\n FROM PlaceOrderWithBidReceipt\n JOIN OrderFilled ON OrderFilled.order_id == PlaceOrderWithBidReceipt.order_id AND OrderFilled.base_token == PlaceOrderWithBidReceipt.base_token\n LEFT JOIN RealizeFunding ON RealizeFunding.position_id == OrderFilled.position_id AND RealizeFunding.base_token == OrderFilled.base_token AND RealizeFunding.transaction_hash == OrderFilled.transaction_hash\n LEFT JOIN RealizeOption ON RealizeOption.position_id == OrderFilled.position_id AND RealizeOption.base_token == OrderFilled.base_token AND RealizeOption.transaction_hash == OrderFilled.transaction_hash\n ").concat(tokenFilter, "\n ) AS combined\n ORDER BY timestamp DESC\n "),
|
|
104
104
|
size: 100,
|
|
105
105
|
},
|
|
106
106
|
};
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { Transaction } from "@mysten/sui/transactions";
|
|
2
2
|
import { PythClient, TypusConfig } from "@typus/typus-sdk/dist/src/utils";
|
|
3
3
|
import { TOKEN } from "@typus/typus-sdk/dist/src/constants";
|
|
4
|
+
export declare function createTradingOrderWithBidReceiptByAutoBid(config: TypusConfig, tx: Transaction, pythClient: PythClient, input: {
|
|
5
|
+
cToken: TOKEN;
|
|
6
|
+
tradingToken: TOKEN;
|
|
7
|
+
isLong: boolean;
|
|
8
|
+
user: string;
|
|
9
|
+
index: string;
|
|
10
|
+
bToken: TOKEN;
|
|
11
|
+
signalIndex: string;
|
|
12
|
+
strategyIndex: string;
|
|
13
|
+
suiCoins?: string[];
|
|
14
|
+
}): Promise<Transaction>;
|
|
4
15
|
export declare function createTradingOrderWithBidReceipt(config: TypusConfig, tx: Transaction, pythClient: PythClient, input: {
|
|
5
16
|
cToken: TOKEN;
|
|
6
17
|
tradingToken: TOKEN;
|
|
@@ -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",
|
|
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",
|