@typus/typus-perp-sdk 1.0.59-leaderboard-b → 1.0.59-ut
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.d.ts +2 -2
- package/dist/src/api/sentio.js +8 -8
- package/dist/src/fetch.d.ts +6 -0
- package/dist/src/fetch.js +46 -0
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +4 -5
- package/dist/src/typus_perp/error/functions.d.ts +2 -0
- package/dist/src/typus_perp/error/functions.js +10 -0
- package/dist/src/typus_perp/lp-pool/functions.d.ts +44 -31
- package/dist/src/typus_perp/lp-pool/functions.js +69 -56
- package/dist/src/typus_perp/lp-pool/structs.d.ts +161 -210
- package/dist/src/typus_perp/lp-pool/structs.js +384 -284
- package/dist/src/typus_perp/trading/functions.d.ts +30 -0
- package/dist/src/typus_perp/trading/functions.js +47 -0
- package/dist/src/typus_stake_pool/stake-pool/functions.d.ts +9 -0
- package/dist/src/typus_stake_pool/stake-pool/functions.js +20 -0
- package/dist/src/user/order.js +1 -3
- package/dist/src/user/orderWithBidReceipt.js +2 -6
- package/dist/src/user/tlp.d.ts +16 -9
- package/dist/src/user/tlp.js +121 -61
- package/package.json +1 -1
|
@@ -13,6 +13,11 @@ export interface AddTradingSymbolArgs {
|
|
|
13
13
|
basicFundingRate: bigint | TransactionArgument;
|
|
14
14
|
fundingIntervalTsMs: bigint | TransactionArgument;
|
|
15
15
|
expMultiplier: bigint | TransactionArgument;
|
|
16
|
+
maxBuyOpenInterest: bigint | TransactionArgument;
|
|
17
|
+
maxSellOpenInterest: bigint | TransactionArgument;
|
|
18
|
+
maintenanceMarginRateBp: bigint | TransactionArgument;
|
|
19
|
+
optionMaintenanceMarginRateBp: bigint | TransactionArgument;
|
|
20
|
+
optionTradingFeeConfig: Array<bigint | TransactionArgument> | TransactionArgument;
|
|
16
21
|
clock: TransactionObjectInput;
|
|
17
22
|
}
|
|
18
23
|
export declare function addTradingSymbol(tx: Transaction, typeArg: string, args: AddTradingSymbolArgs, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
|
|
@@ -238,6 +243,14 @@ export interface GetActiveOrdersByOrderTagAndCtokenArgs {
|
|
|
238
243
|
orderTypeTag: number | TransactionArgument;
|
|
239
244
|
}
|
|
240
245
|
export declare function getActiveOrdersByOrderTagAndCtoken(tx: Transaction, typeArgs: [string, string], args: GetActiveOrdersByOrderTagAndCtokenArgs, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
|
|
246
|
+
export interface GetAllPositionsArgs {
|
|
247
|
+
version: TransactionObjectInput;
|
|
248
|
+
registry: TransactionObjectInput;
|
|
249
|
+
marketIndex: bigint | TransactionArgument;
|
|
250
|
+
slice: bigint | TransactionArgument;
|
|
251
|
+
page: bigint | TransactionArgument;
|
|
252
|
+
}
|
|
253
|
+
export declare function getAllPositions(tx: Transaction, typeArg: string, args: GetAllPositionsArgs, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
|
|
241
254
|
export interface GetEstimatedLiquidationPriceAndPnlArgs {
|
|
242
255
|
version: TransactionObjectInput;
|
|
243
256
|
registry: TransactionObjectInput;
|
|
@@ -395,6 +408,12 @@ export interface ManagerCloseOptionPositionV2Args {
|
|
|
395
408
|
positionId: bigint | TransactionArgument;
|
|
396
409
|
}
|
|
397
410
|
export declare function managerCloseOptionPositionV2(tx: Transaction, typeArgs: [string, string, string], args: ManagerCloseOptionPositionV2Args, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
|
|
411
|
+
export interface ManagerHotfixRemoveMarketSymbolArgs {
|
|
412
|
+
version: TransactionObjectInput;
|
|
413
|
+
registry: TransactionObjectInput;
|
|
414
|
+
marketIndex: bigint | TransactionArgument;
|
|
415
|
+
}
|
|
416
|
+
export declare function managerHotfixRemoveMarketSymbol(tx: Transaction, typeArg: string, args: ManagerHotfixRemoveMarketSymbolArgs, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
|
|
398
417
|
export interface ManagerReducePositionArgs {
|
|
399
418
|
version: TransactionObjectInput;
|
|
400
419
|
registry: TransactionObjectInput;
|
|
@@ -592,6 +611,14 @@ export interface ReleaseCollateralArgs {
|
|
|
592
611
|
releaseAmount: bigint | TransactionArgument;
|
|
593
612
|
}
|
|
594
613
|
export declare function releaseCollateral(tx: Transaction, typeArgs: [string, string], args: ReleaseCollateralArgs, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
|
|
614
|
+
export interface RemoveLinkedOrder_Args {
|
|
615
|
+
version: TransactionObjectInput;
|
|
616
|
+
marketIndex: bigint | TransactionArgument;
|
|
617
|
+
symbolMarket: TransactionObjectInput;
|
|
618
|
+
order: TransactionObjectInput;
|
|
619
|
+
user: string | TransactionArgument;
|
|
620
|
+
}
|
|
621
|
+
export declare function removeLinkedOrder_(tx: Transaction, typeArg: string, args: RemoveLinkedOrder_Args, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
|
|
595
622
|
export interface RemoveLinkedOrdersArgs {
|
|
596
623
|
version: TransactionObjectInput;
|
|
597
624
|
marketIndex: bigint | TransactionArgument;
|
|
@@ -676,6 +703,9 @@ export interface UpdateMarketConfigArgs {
|
|
|
676
703
|
expMultiplier: bigint | TransactionArgument | TransactionArgument | null;
|
|
677
704
|
maxBuyOpenInterest: bigint | TransactionArgument | TransactionArgument | null;
|
|
678
705
|
maxSellOpenInterest: bigint | TransactionArgument | TransactionArgument | null;
|
|
706
|
+
maintenanceMarginRateBp: bigint | TransactionArgument | TransactionArgument | null;
|
|
707
|
+
optionCollateralMaintenanceMarginRateBp: bigint | TransactionArgument | TransactionArgument | null;
|
|
708
|
+
optionCollateralTradingFeeConfig: Array<bigint | TransactionArgument> | TransactionArgument | TransactionArgument | null;
|
|
679
709
|
}
|
|
680
710
|
export declare function updateMarketConfig(tx: Transaction, typeArg: string, args: UpdateMarketConfigArgs, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
|
|
681
711
|
export interface UpdateProtocolFeeShareBpArgs {
|
|
@@ -19,6 +19,7 @@ exports.executeOrder_ = executeOrder_;
|
|
|
19
19
|
exports.exerciseBidReceipts = exerciseBidReceipts;
|
|
20
20
|
exports.getActiveOrdersByOrderTag = getActiveOrdersByOrderTag;
|
|
21
21
|
exports.getActiveOrdersByOrderTagAndCtoken = getActiveOrdersByOrderTagAndCtoken;
|
|
22
|
+
exports.getAllPositions = getAllPositions;
|
|
22
23
|
exports.getEstimatedLiquidationPriceAndPnl = getEstimatedLiquidationPriceAndPnl;
|
|
23
24
|
exports.getExpiredPositionInfo = getExpiredPositionInfo;
|
|
24
25
|
exports.getLinkedPosition = getLinkedPosition;
|
|
@@ -35,6 +36,7 @@ exports.liquidate = liquidate;
|
|
|
35
36
|
exports.managerCancelOrderByOpenInterestLimit = managerCancelOrderByOpenInterestLimit;
|
|
36
37
|
exports.managerCloseOptionPosition = managerCloseOptionPosition;
|
|
37
38
|
exports.managerCloseOptionPositionV2 = managerCloseOptionPositionV2;
|
|
39
|
+
exports.managerHotfixRemoveMarketSymbol = managerHotfixRemoveMarketSymbol;
|
|
38
40
|
exports.managerReducePosition = managerReducePosition;
|
|
39
41
|
exports.managerReducePositionV2 = managerReducePositionV2;
|
|
40
42
|
exports.managerRemoveOrder = managerRemoveOrder;
|
|
@@ -48,6 +50,7 @@ exports.newMarkets = newMarkets;
|
|
|
48
50
|
exports.reduceOptionCollateralPositionSize = reduceOptionCollateralPositionSize;
|
|
49
51
|
exports.reduceOptionCollateralPositionSizeV2 = reduceOptionCollateralPositionSizeV2;
|
|
50
52
|
exports.releaseCollateral = releaseCollateral;
|
|
53
|
+
exports.removeLinkedOrder_ = removeLinkedOrder_;
|
|
51
54
|
exports.removeLinkedOrders = removeLinkedOrders;
|
|
52
55
|
exports.removeTradingSymbol = removeTradingSymbol;
|
|
53
56
|
exports.resumeMarket = resumeMarket;
|
|
@@ -83,6 +86,11 @@ function addTradingSymbol(tx, typeArg, args, published_at) {
|
|
|
83
86
|
(0, util_1.pure)(tx, args.basicFundingRate, "u64"),
|
|
84
87
|
(0, util_1.pure)(tx, args.fundingIntervalTsMs, "u64"),
|
|
85
88
|
(0, util_1.pure)(tx, args.expMultiplier, "u64"),
|
|
89
|
+
(0, util_1.pure)(tx, args.maxBuyOpenInterest, "u64"),
|
|
90
|
+
(0, util_1.pure)(tx, args.maxSellOpenInterest, "u64"),
|
|
91
|
+
(0, util_1.pure)(tx, args.maintenanceMarginRateBp, "u64"),
|
|
92
|
+
(0, util_1.pure)(tx, args.optionMaintenanceMarginRateBp, "u64"),
|
|
93
|
+
(0, util_1.pure)(tx, args.optionTradingFeeConfig, "vector<u64>"),
|
|
86
94
|
(0, util_1.obj)(tx, args.clock),
|
|
87
95
|
],
|
|
88
96
|
});
|
|
@@ -398,6 +406,20 @@ function getActiveOrdersByOrderTagAndCtoken(tx, typeArgs, args, published_at) {
|
|
|
398
406
|
arguments: [(0, util_1.obj)(tx, args.version), (0, util_1.obj)(tx, args.registry), (0, util_1.pure)(tx, args.marketIndex, "u64"), (0, util_1.pure)(tx, args.orderTypeTag, "u8")],
|
|
399
407
|
});
|
|
400
408
|
}
|
|
409
|
+
function getAllPositions(tx, typeArg, args, published_at) {
|
|
410
|
+
if (published_at === void 0) { published_at = __1.PUBLISHED_AT; }
|
|
411
|
+
return tx.moveCall({
|
|
412
|
+
target: "".concat(published_at, "::trading::get_all_positions"),
|
|
413
|
+
typeArguments: [typeArg],
|
|
414
|
+
arguments: [
|
|
415
|
+
(0, util_1.obj)(tx, args.version),
|
|
416
|
+
(0, util_1.obj)(tx, args.registry),
|
|
417
|
+
(0, util_1.pure)(tx, args.marketIndex, "u64"),
|
|
418
|
+
(0, util_1.pure)(tx, args.slice, "u64"),
|
|
419
|
+
(0, util_1.pure)(tx, args.page, "u64"),
|
|
420
|
+
],
|
|
421
|
+
});
|
|
422
|
+
}
|
|
401
423
|
function getEstimatedLiquidationPriceAndPnl(tx, typeArgs, args, published_at) {
|
|
402
424
|
if (published_at === void 0) { published_at = __1.PUBLISHED_AT; }
|
|
403
425
|
return tx.moveCall({
|
|
@@ -620,6 +642,14 @@ function managerCloseOptionPositionV2(tx, typeArgs, args, published_at) {
|
|
|
620
642
|
],
|
|
621
643
|
});
|
|
622
644
|
}
|
|
645
|
+
function managerHotfixRemoveMarketSymbol(tx, typeArg, args, published_at) {
|
|
646
|
+
if (published_at === void 0) { published_at = __1.PUBLISHED_AT; }
|
|
647
|
+
return tx.moveCall({
|
|
648
|
+
target: "".concat(published_at, "::trading::manager_hotfix_remove_market_symbol"),
|
|
649
|
+
typeArguments: [typeArg],
|
|
650
|
+
arguments: [(0, util_1.obj)(tx, args.version), (0, util_1.obj)(tx, args.registry), (0, util_1.pure)(tx, args.marketIndex, "u64")],
|
|
651
|
+
});
|
|
652
|
+
}
|
|
623
653
|
function managerReducePosition(tx, typeArgs, args, published_at) {
|
|
624
654
|
if (published_at === void 0) { published_at = __1.PUBLISHED_AT; }
|
|
625
655
|
return tx.moveCall({
|
|
@@ -891,6 +921,20 @@ function releaseCollateral(tx, typeArgs, args, published_at) {
|
|
|
891
921
|
],
|
|
892
922
|
});
|
|
893
923
|
}
|
|
924
|
+
function removeLinkedOrder_(tx, typeArg, args, published_at) {
|
|
925
|
+
if (published_at === void 0) { published_at = __1.PUBLISHED_AT; }
|
|
926
|
+
return tx.moveCall({
|
|
927
|
+
target: "".concat(published_at, "::trading::remove_linked_order_"),
|
|
928
|
+
typeArguments: [typeArg],
|
|
929
|
+
arguments: [
|
|
930
|
+
(0, util_1.obj)(tx, args.version),
|
|
931
|
+
(0, util_1.pure)(tx, args.marketIndex, "u64"),
|
|
932
|
+
(0, util_1.obj)(tx, args.symbolMarket),
|
|
933
|
+
(0, util_1.obj)(tx, args.order),
|
|
934
|
+
(0, util_1.pure)(tx, args.user, "address"),
|
|
935
|
+
],
|
|
936
|
+
});
|
|
937
|
+
}
|
|
894
938
|
function removeLinkedOrders(tx, typeArg, args, published_at) {
|
|
895
939
|
if (published_at === void 0) { published_at = __1.PUBLISHED_AT; }
|
|
896
940
|
return tx.moveCall({
|
|
@@ -1018,6 +1062,9 @@ function updateMarketConfig(tx, typeArg, args, published_at) {
|
|
|
1018
1062
|
(0, util_1.pure)(tx, args.expMultiplier, "".concat(structs_1.Option.$typeName, "<u64>")),
|
|
1019
1063
|
(0, util_1.pure)(tx, args.maxBuyOpenInterest, "".concat(structs_1.Option.$typeName, "<u64>")),
|
|
1020
1064
|
(0, util_1.pure)(tx, args.maxSellOpenInterest, "".concat(structs_1.Option.$typeName, "<u64>")),
|
|
1065
|
+
(0, util_1.pure)(tx, args.maintenanceMarginRateBp, "".concat(structs_1.Option.$typeName, "<u64>")),
|
|
1066
|
+
(0, util_1.pure)(tx, args.optionCollateralMaintenanceMarginRateBp, "".concat(structs_1.Option.$typeName, "<u64>")),
|
|
1067
|
+
(0, util_1.pure)(tx, args.optionCollateralTradingFeeConfig, "".concat(structs_1.Option.$typeName, "<vector<u64>>")),
|
|
1021
1068
|
],
|
|
1022
1069
|
});
|
|
1023
1070
|
}
|
|
@@ -45,6 +45,7 @@ export interface DepositIncentiveArgs {
|
|
|
45
45
|
coin: TransactionObjectInput;
|
|
46
46
|
}
|
|
47
47
|
export declare function depositIncentive(tx: Transaction, typeArg: string, args: DepositIncentiveArgs, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
|
|
48
|
+
export declare function deprecated(tx: Transaction, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
|
|
48
49
|
export interface GetIncentiveArgs {
|
|
49
50
|
stakePool: TransactionObjectInput;
|
|
50
51
|
tokenType: TransactionObjectInput;
|
|
@@ -196,3 +197,11 @@ export interface WithdrawIncentiveArgs {
|
|
|
196
197
|
amount: bigint | TransactionArgument | TransactionArgument | null;
|
|
197
198
|
}
|
|
198
199
|
export declare function withdrawIncentive(tx: Transaction, typeArg: string, args: WithdrawIncentiveArgs, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
|
|
200
|
+
export interface WithdrawIncentiveV2Args {
|
|
201
|
+
version: TransactionObjectInput;
|
|
202
|
+
registry: TransactionObjectInput;
|
|
203
|
+
index: bigint | TransactionArgument;
|
|
204
|
+
amount: bigint | TransactionArgument | TransactionArgument | null;
|
|
205
|
+
clock: TransactionObjectInput;
|
|
206
|
+
}
|
|
207
|
+
export declare function withdrawIncentiveV2(tx: Transaction, typeArg: string, args: WithdrawIncentiveV2Args, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
|
|
@@ -7,6 +7,7 @@ exports.calculateIncentive = calculateIncentive;
|
|
|
7
7
|
exports.createUserLastIncentiveTsMs = createUserLastIncentiveTsMs;
|
|
8
8
|
exports.deactivateIncentiveToken = deactivateIncentiveToken;
|
|
9
9
|
exports.depositIncentive = depositIncentive;
|
|
10
|
+
exports.deprecated = deprecated;
|
|
10
11
|
exports.getIncentive = getIncentive;
|
|
11
12
|
exports.getIncentiveTokens = getIncentiveTokens;
|
|
12
13
|
exports.getLastIncentivePriceIndex = getLastIncentivePriceIndex;
|
|
@@ -33,6 +34,7 @@ exports.updateIncentiveConfig = updateIncentiveConfig;
|
|
|
33
34
|
exports.updatePoolInfoU64Padding = updatePoolInfoU64Padding;
|
|
34
35
|
exports.updateUnlockCountdownTsMs = updateUnlockCountdownTsMs;
|
|
35
36
|
exports.withdrawIncentive = withdrawIncentive;
|
|
37
|
+
exports.withdrawIncentiveV2 = withdrawIncentiveV2;
|
|
36
38
|
var __1 = require("..");
|
|
37
39
|
var structs_1 = require("../../_dependencies/source/0x1/option/structs");
|
|
38
40
|
var util_1 = require("../../_framework/util");
|
|
@@ -97,6 +99,10 @@ function depositIncentive(tx, typeArg, args, published_at) {
|
|
|
97
99
|
arguments: [(0, util_1.obj)(tx, args.version), (0, util_1.obj)(tx, args.registry), (0, util_1.pure)(tx, args.index, "u64"), (0, util_1.obj)(tx, args.coin)],
|
|
98
100
|
});
|
|
99
101
|
}
|
|
102
|
+
function deprecated(tx, published_at) {
|
|
103
|
+
if (published_at === void 0) { published_at = __1.PUBLISHED_AT; }
|
|
104
|
+
return tx.moveCall({ target: "".concat(published_at, "::stake_pool::deprecated"), arguments: [] });
|
|
105
|
+
}
|
|
100
106
|
function getIncentive(tx, args, published_at) {
|
|
101
107
|
if (published_at === void 0) { published_at = __1.PUBLISHED_AT; }
|
|
102
108
|
return tx.moveCall({
|
|
@@ -329,3 +335,17 @@ function withdrawIncentive(tx, typeArg, args, published_at) {
|
|
|
329
335
|
],
|
|
330
336
|
});
|
|
331
337
|
}
|
|
338
|
+
function withdrawIncentiveV2(tx, typeArg, args, published_at) {
|
|
339
|
+
if (published_at === void 0) { published_at = __1.PUBLISHED_AT; }
|
|
340
|
+
return tx.moveCall({
|
|
341
|
+
target: "".concat(published_at, "::stake_pool::withdraw_incentive_v2"),
|
|
342
|
+
typeArguments: [typeArg],
|
|
343
|
+
arguments: [
|
|
344
|
+
(0, util_1.obj)(tx, args.version),
|
|
345
|
+
(0, util_1.obj)(tx, args.registry),
|
|
346
|
+
(0, util_1.pure)(tx, args.index, "u64"),
|
|
347
|
+
(0, util_1.pure)(tx, args.amount, "".concat(structs_1.Option.$typeName, "<u64>")),
|
|
348
|
+
(0, util_1.obj)(tx, args.clock),
|
|
349
|
+
],
|
|
350
|
+
});
|
|
351
|
+
}
|
package/dist/src/user/order.js
CHANGED
|
@@ -122,7 +122,7 @@ function createTradingOrder(config, tx, pythClient, input) {
|
|
|
122
122
|
}
|
|
123
123
|
finally { if (e_1) throw e_1.error; }
|
|
124
124
|
}
|
|
125
|
-
(0, functions_1.
|
|
125
|
+
(0, functions_1.createTradingOrder)(tx, [cToken, baseToken], {
|
|
126
126
|
version: __1.PERP_VERSION,
|
|
127
127
|
registry: __1.MARKET,
|
|
128
128
|
poolRegistry: __1.LP_POOL,
|
|
@@ -141,8 +141,6 @@ function createTradingOrder(config, tx, pythClient, input) {
|
|
|
141
141
|
isStopOrder: input.isStopOrder,
|
|
142
142
|
reduceOnly: input.reduceOnly,
|
|
143
143
|
linkedPositionId: input.linkedPositionId ? BigInt(input.linkedPositionId) : null,
|
|
144
|
-
tailsStakingRegistry: config.registry.typus.tailsStaking,
|
|
145
|
-
competitionConfig: __1.COMPETITION_CONFIG,
|
|
146
144
|
});
|
|
147
145
|
return [2 /*return*/, tx];
|
|
148
146
|
}
|
|
@@ -89,7 +89,7 @@ function createTradingOrderWithBidReceipt(config, tx, pythClient, input) {
|
|
|
89
89
|
cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
|
|
90
90
|
bToken = constants_1.tokenType[__1.NETWORK][input.bToken];
|
|
91
91
|
baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
|
|
92
|
-
(0, functions_1.
|
|
92
|
+
(0, functions_1.createTradingOrderWithBidReceipt)(tx, [cToken, bToken, baseToken], {
|
|
93
93
|
version: __1.PERP_VERSION,
|
|
94
94
|
registry: __1.MARKET,
|
|
95
95
|
poolRegistry: __1.LP_POOL,
|
|
@@ -105,8 +105,6 @@ function createTradingOrderWithBidReceipt(config, tx, pythClient, input) {
|
|
|
105
105
|
dovRegistry: config.registry.dov.dovSingle,
|
|
106
106
|
collateralBidReceipt: collateralBidReceipt,
|
|
107
107
|
user: input.user,
|
|
108
|
-
tailsStakingRegistry: config.registry.typus.tailsStaking,
|
|
109
|
-
competitionConfig: __1.COMPETITION_CONFIG,
|
|
110
108
|
});
|
|
111
109
|
return [2 /*return*/, tx];
|
|
112
110
|
}
|
|
@@ -142,7 +140,7 @@ function reduceOptionCollateralPositionSize(config, tx, pythClient, input) {
|
|
|
142
140
|
cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
|
|
143
141
|
bToken = constants_1.tokenType[__1.NETWORK][input.bToken];
|
|
144
142
|
baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
|
|
145
|
-
(0, functions_1.
|
|
143
|
+
(0, functions_1.reduceOptionCollateralPositionSize)(tx, [cToken, bToken, baseToken], {
|
|
146
144
|
version: __1.PERP_VERSION,
|
|
147
145
|
registry: __1.MARKET,
|
|
148
146
|
poolRegistry: __1.LP_POOL,
|
|
@@ -157,8 +155,6 @@ function reduceOptionCollateralPositionSize(config, tx, pythClient, input) {
|
|
|
157
155
|
dovRegistry: config.registry.dov.dovSingle,
|
|
158
156
|
positionId: BigInt(input.positionId),
|
|
159
157
|
orderSize: input.orderSize ? BigInt(input.orderSize) : null,
|
|
160
|
-
tailsStakingRegistry: config.registry.typus.tailsStaking,
|
|
161
|
-
competitionConfig: __1.COMPETITION_CONFIG,
|
|
162
158
|
});
|
|
163
159
|
return [2 /*return*/, tx];
|
|
164
160
|
}
|
package/dist/src/user/tlp.d.ts
CHANGED
|
@@ -14,23 +14,34 @@ export declare function mintStakeLp(config: TypusConfig, tx: Transaction, pythCl
|
|
|
14
14
|
amount: string;
|
|
15
15
|
userShareId: string | null;
|
|
16
16
|
user: string;
|
|
17
|
+
stake: boolean;
|
|
17
18
|
}): Promise<Transaction>;
|
|
18
|
-
export declare function
|
|
19
|
+
export declare function unstake(config: TypusConfig, tx: Transaction, input: {
|
|
19
20
|
lpPool: LiquidityPool;
|
|
20
21
|
stakePool: StakePool;
|
|
21
|
-
cTOKEN: TOKEN;
|
|
22
22
|
userShareId: string;
|
|
23
23
|
share: string | null;
|
|
24
24
|
user: string;
|
|
25
25
|
}): Promise<Transaction>;
|
|
26
|
-
export declare function
|
|
26
|
+
export declare function unstakeRedeem(config: TypusConfig, tx: Transaction, pythClient: PythClient, input: {
|
|
27
27
|
lpPool: LiquidityPool;
|
|
28
28
|
stakePool: StakePool;
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
userShareId: string;
|
|
30
|
+
share: string | null;
|
|
31
|
+
user: string;
|
|
32
|
+
}): Promise<Transaction>;
|
|
33
|
+
export declare function redeemTlp(config: TypusConfig, tx: Transaction, pythClient: PythClient, input: {
|
|
34
|
+
lpPool: LiquidityPool;
|
|
35
|
+
lpCoins: string[];
|
|
31
36
|
share: string | null;
|
|
32
37
|
user: string;
|
|
33
38
|
}): Promise<Transaction>;
|
|
39
|
+
export declare function claim(config: TypusConfig, tx: Transaction, pythClient: PythClient, input: {
|
|
40
|
+
lpPool: LiquidityPool;
|
|
41
|
+
stakePool: StakePool;
|
|
42
|
+
cTOKEN: TOKEN;
|
|
43
|
+
user: string;
|
|
44
|
+
}): Promise<Transaction>;
|
|
34
45
|
export declare function swap(config: TypusConfig, tx: Transaction, pythClient: PythClient, input: {
|
|
35
46
|
coins: string[];
|
|
36
47
|
FROM_TOKEN: TOKEN;
|
|
@@ -38,10 +49,6 @@ export declare function swap(config: TypusConfig, tx: Transaction, pythClient: P
|
|
|
38
49
|
amount: string;
|
|
39
50
|
user: string;
|
|
40
51
|
}): Promise<Transaction>;
|
|
41
|
-
export declare function unsubscribe(config: TypusConfig, tx: Transaction, input: {
|
|
42
|
-
userShareId: string;
|
|
43
|
-
share: string | null;
|
|
44
|
-
}): Promise<Transaction>;
|
|
45
52
|
export declare function harvestStakeReward(config: TypusConfig, tx: Transaction, input: {
|
|
46
53
|
stakePool: StakePool;
|
|
47
54
|
userShareId: string;
|
package/dist/src/user/tlp.js
CHANGED
|
@@ -65,10 +65,11 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
65
65
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66
66
|
exports.snapshot = snapshot;
|
|
67
67
|
exports.mintStakeLp = mintStakeLp;
|
|
68
|
-
exports.
|
|
69
|
-
exports.
|
|
68
|
+
exports.unstake = unstake;
|
|
69
|
+
exports.unstakeRedeem = unstakeRedeem;
|
|
70
|
+
exports.redeemTlp = redeemTlp;
|
|
71
|
+
exports.claim = claim;
|
|
70
72
|
exports.swap = swap;
|
|
71
|
-
exports.unsubscribe = unsubscribe;
|
|
72
73
|
exports.harvestStakeReward = harvestStakeReward;
|
|
73
74
|
var functions_1 = require("../typus_perp/lp-pool/functions");
|
|
74
75
|
var functions_2 = require("../typus_stake_pool/stake-pool/functions");
|
|
@@ -148,22 +149,52 @@ function mintStakeLp(config, tx, pythClient, input) {
|
|
|
148
149
|
coin: coin,
|
|
149
150
|
clock: constants_1.CLOCK,
|
|
150
151
|
});
|
|
151
|
-
(
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
152
|
+
if (input.stake) {
|
|
153
|
+
(0, functions_2.stake)(tx, __1.TLP_TOKEN, {
|
|
154
|
+
version: __1.STAKE_POOL_VERSION,
|
|
155
|
+
registry: __1.STAKE_POOL,
|
|
156
|
+
index: BigInt(0),
|
|
157
|
+
lpToken: lpCoin,
|
|
158
|
+
clock: constants_1.CLOCK,
|
|
159
|
+
userShareId: input.userShareId ? BigInt(input.userShareId) : null,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
tx.transferObjects([lpCoin], input.user);
|
|
164
|
+
}
|
|
159
165
|
return [2 /*return*/, tx];
|
|
160
166
|
}
|
|
161
167
|
});
|
|
162
168
|
});
|
|
163
169
|
}
|
|
164
|
-
function
|
|
170
|
+
function unstake(config, tx, input) {
|
|
171
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
172
|
+
var lpCoin;
|
|
173
|
+
return __generator(this, function (_a) {
|
|
174
|
+
harvestStakeReward(config, tx, { stakePool: input.stakePool, userShareId: input.userShareId, user: input.user });
|
|
175
|
+
(0, functions_2.unsubscribe)(tx, __1.TLP_TOKEN, {
|
|
176
|
+
version: __1.STAKE_POOL_VERSION,
|
|
177
|
+
registry: __1.STAKE_POOL,
|
|
178
|
+
index: BigInt(0),
|
|
179
|
+
userShareId: BigInt(input.userShareId),
|
|
180
|
+
clock: constants_1.CLOCK,
|
|
181
|
+
unsubscribedShares: input.share ? BigInt(input.share) : null,
|
|
182
|
+
});
|
|
183
|
+
lpCoin = (0, functions_2.unstake)(tx, __1.TLP_TOKEN, {
|
|
184
|
+
version: __1.STAKE_POOL_VERSION,
|
|
185
|
+
registry: __1.STAKE_POOL,
|
|
186
|
+
index: BigInt(0),
|
|
187
|
+
userShareId: BigInt(input.userShareId),
|
|
188
|
+
clock: constants_1.CLOCK,
|
|
189
|
+
});
|
|
190
|
+
tx.transferObjects([lpCoin], input.user);
|
|
191
|
+
return [2 /*return*/, tx];
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
function unstakeRedeem(config, tx, pythClient, input) {
|
|
165
196
|
return __awaiter(this, void 0, void 0, function () {
|
|
166
|
-
var tokens, tokens_2, tokens_2_1, token, lpCoin,
|
|
197
|
+
var tokens, tokens_2, tokens_2_1, token, lpCoin, balance;
|
|
167
198
|
var e_2, _a;
|
|
168
199
|
return __generator(this, function (_b) {
|
|
169
200
|
switch (_b.label) {
|
|
@@ -193,6 +224,14 @@ function unstakeBurn(config, tx, pythClient, input) {
|
|
|
193
224
|
finally { if (e_2) throw e_2.error; }
|
|
194
225
|
}
|
|
195
226
|
harvestStakeReward(config, tx, { stakePool: input.stakePool, userShareId: input.userShareId, user: input.user });
|
|
227
|
+
(0, functions_2.unsubscribe)(tx, __1.TLP_TOKEN, {
|
|
228
|
+
version: __1.STAKE_POOL_VERSION,
|
|
229
|
+
registry: __1.STAKE_POOL,
|
|
230
|
+
index: BigInt(0),
|
|
231
|
+
userShareId: BigInt(input.userShareId),
|
|
232
|
+
clock: constants_1.CLOCK,
|
|
233
|
+
unsubscribedShares: input.share ? BigInt(input.share) : null,
|
|
234
|
+
});
|
|
196
235
|
lpCoin = (0, functions_2.unstake)(tx, __1.TLP_TOKEN, {
|
|
197
236
|
version: __1.STAKE_POOL_VERSION,
|
|
198
237
|
registry: __1.STAKE_POOL,
|
|
@@ -200,32 +239,26 @@ function unstakeBurn(config, tx, pythClient, input) {
|
|
|
200
239
|
userShareId: BigInt(input.userShareId),
|
|
201
240
|
clock: constants_1.CLOCK,
|
|
202
241
|
});
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
cToken = constants_1.tokenType[__1.NETWORK][input.cTOKEN];
|
|
211
|
-
coin = (0, functions_1.burnLp)(tx, [cToken, __1.TLP_TOKEN], {
|
|
242
|
+
balance = tx.moveCall({
|
|
243
|
+
target: "0x2::coin::into_balance",
|
|
244
|
+
typeArguments: [__1.TLP_TOKEN],
|
|
245
|
+
arguments: [lpCoin],
|
|
246
|
+
});
|
|
247
|
+
(0, functions_1.redeem)(tx, __1.TLP_TOKEN, {
|
|
212
248
|
version: __1.PERP_VERSION,
|
|
213
249
|
registry: __1.LP_POOL,
|
|
214
|
-
treasuryCaps: __1.TLP_TREASURY_CAP,
|
|
215
250
|
index: BigInt(0),
|
|
216
|
-
oracle: constants_1.oracle[__1.NETWORK][input.cTOKEN],
|
|
217
|
-
coin: burnCoin,
|
|
218
251
|
clock: constants_1.CLOCK,
|
|
252
|
+
balance: balance,
|
|
219
253
|
});
|
|
220
|
-
tx.transferObjects([coin], input.user);
|
|
221
254
|
return [2 /*return*/, tx];
|
|
222
255
|
}
|
|
223
256
|
});
|
|
224
257
|
});
|
|
225
258
|
}
|
|
226
|
-
function
|
|
259
|
+
function redeemTlp(config, tx, pythClient, input) {
|
|
227
260
|
return __awaiter(this, void 0, void 0, function () {
|
|
228
|
-
var tokens, tokens_3, tokens_3_1, token, lpCoin, burnCoin,
|
|
261
|
+
var tokens, tokens_3, tokens_3_1, token, destination, lpCoin, burnCoin, balance;
|
|
229
262
|
var e_3, _a;
|
|
230
263
|
return __generator(this, function (_b) {
|
|
231
264
|
switch (_b.label) {
|
|
@@ -254,24 +287,75 @@ function burnTlp(config, tx, pythClient, input) {
|
|
|
254
287
|
}
|
|
255
288
|
finally { if (e_3) throw e_3.error; }
|
|
256
289
|
}
|
|
257
|
-
|
|
290
|
+
destination = input.lpCoins.pop();
|
|
291
|
+
if (input.lpCoins.length > 0) {
|
|
292
|
+
tx.mergeCoins(destination, input.lpCoins);
|
|
293
|
+
}
|
|
294
|
+
lpCoin = tx.object(destination);
|
|
258
295
|
if (input.share) {
|
|
259
296
|
burnCoin = tx.splitCoins(lpCoin, [input.share]);
|
|
260
297
|
}
|
|
261
298
|
else {
|
|
262
299
|
burnCoin = lpCoin;
|
|
263
300
|
}
|
|
301
|
+
balance = tx.moveCall({
|
|
302
|
+
target: "0x2::coin::into_balance",
|
|
303
|
+
typeArguments: [__1.TLP_TOKEN],
|
|
304
|
+
arguments: [burnCoin],
|
|
305
|
+
});
|
|
306
|
+
(0, functions_1.redeem)(tx, __1.TLP_TOKEN, {
|
|
307
|
+
version: __1.PERP_VERSION,
|
|
308
|
+
registry: __1.LP_POOL,
|
|
309
|
+
index: BigInt(0),
|
|
310
|
+
clock: constants_1.CLOCK,
|
|
311
|
+
balance: balance,
|
|
312
|
+
});
|
|
313
|
+
return [2 /*return*/, tx];
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
function claim(config, tx, pythClient, input) {
|
|
319
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
320
|
+
var tokens, tokens_4, tokens_4_1, token_1, cToken, token;
|
|
321
|
+
var e_4, _a;
|
|
322
|
+
return __generator(this, function (_b) {
|
|
323
|
+
switch (_b.label) {
|
|
324
|
+
case 0:
|
|
325
|
+
tokens = input.lpPool.tokenPools.map(function (p) { return (0, constants_1.typeArgToAsset)("0x" + p.tokenType.name); });
|
|
326
|
+
return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, tokens)];
|
|
327
|
+
case 1:
|
|
328
|
+
_b.sent();
|
|
329
|
+
try {
|
|
330
|
+
for (tokens_4 = __values(tokens), tokens_4_1 = tokens_4.next(); !tokens_4_1.done; tokens_4_1 = tokens_4.next()) {
|
|
331
|
+
token_1 = tokens_4_1.value;
|
|
332
|
+
(0, utils_1.updateOracleWithPythUsd)(pythClient, tx, config.package.oracle, token_1);
|
|
333
|
+
(0, functions_1.updateLiquidityValue)(tx, constants_1.tokenType[__1.NETWORK][token_1], {
|
|
334
|
+
version: __1.PERP_VERSION,
|
|
335
|
+
registry: __1.LP_POOL,
|
|
336
|
+
index: BigInt(0),
|
|
337
|
+
oracle: constants_1.oracle[__1.NETWORK][token_1],
|
|
338
|
+
clock: constants_1.CLOCK,
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
343
|
+
finally {
|
|
344
|
+
try {
|
|
345
|
+
if (tokens_4_1 && !tokens_4_1.done && (_a = tokens_4.return)) _a.call(tokens_4);
|
|
346
|
+
}
|
|
347
|
+
finally { if (e_4) throw e_4.error; }
|
|
348
|
+
}
|
|
264
349
|
cToken = constants_1.tokenType[__1.NETWORK][input.cTOKEN];
|
|
265
|
-
|
|
350
|
+
token = (0, functions_1.claim)(tx, [__1.TLP_TOKEN, cToken], {
|
|
266
351
|
version: __1.PERP_VERSION,
|
|
267
352
|
registry: __1.LP_POOL,
|
|
268
|
-
treasuryCaps: __1.TLP_TREASURY_CAP,
|
|
269
353
|
index: BigInt(0),
|
|
270
|
-
oracle: constants_1.oracle[__1.NETWORK][input.cTOKEN],
|
|
271
|
-
coin: burnCoin,
|
|
272
354
|
clock: constants_1.CLOCK,
|
|
355
|
+
treasuryCaps: __1.TLP_TREASURY_CAP,
|
|
356
|
+
oracle: constants_1.oracle[__1.NETWORK][input.cTOKEN],
|
|
273
357
|
});
|
|
274
|
-
tx.transferObjects([
|
|
358
|
+
tx.transferObjects([token], input.user);
|
|
275
359
|
return [2 /*return*/, tx];
|
|
276
360
|
}
|
|
277
361
|
});
|
|
@@ -316,34 +400,10 @@ function swap(config, tx, pythClient, input) {
|
|
|
316
400
|
});
|
|
317
401
|
});
|
|
318
402
|
}
|
|
319
|
-
function unsubscribe(config, tx, input) {
|
|
320
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
321
|
-
return __generator(this, function (_a) {
|
|
322
|
-
(0, functions_2.snapshot)(tx, {
|
|
323
|
-
version: __1.STAKE_POOL_VERSION,
|
|
324
|
-
registry: __1.STAKE_POOL,
|
|
325
|
-
index: BigInt(0),
|
|
326
|
-
clock: constants_1.CLOCK,
|
|
327
|
-
userShareId: BigInt(input.userShareId),
|
|
328
|
-
typusEcosystemVersion: config.version.typus,
|
|
329
|
-
typusUserRegistry: config.registry.typus.user,
|
|
330
|
-
});
|
|
331
|
-
(0, functions_2.unsubscribe)(tx, __1.TLP_TOKEN, {
|
|
332
|
-
version: __1.STAKE_POOL_VERSION,
|
|
333
|
-
registry: __1.STAKE_POOL,
|
|
334
|
-
index: BigInt(0),
|
|
335
|
-
userShareId: BigInt(input.userShareId),
|
|
336
|
-
clock: constants_1.CLOCK,
|
|
337
|
-
unsubscribedShares: input.share ? BigInt(input.share) : null,
|
|
338
|
-
});
|
|
339
|
-
return [2 /*return*/, tx];
|
|
340
|
-
});
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
403
|
function harvestStakeReward(config, tx, input) {
|
|
344
404
|
return __awaiter(this, void 0, void 0, function () {
|
|
345
405
|
var iTokens, iTokens_1, iTokens_1_1, iToken, iCoin;
|
|
346
|
-
var
|
|
406
|
+
var e_5, _a;
|
|
347
407
|
return __generator(this, function (_b) {
|
|
348
408
|
iTokens = input.stakePool.incentives.map(function (i) { return i.tokenType.name; });
|
|
349
409
|
(0, functions_2.snapshot)(tx, {
|
|
@@ -381,12 +441,12 @@ function harvestStakeReward(config, tx, input) {
|
|
|
381
441
|
}
|
|
382
442
|
}
|
|
383
443
|
}
|
|
384
|
-
catch (
|
|
444
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
385
445
|
finally {
|
|
386
446
|
try {
|
|
387
447
|
if (iTokens_1_1 && !iTokens_1_1.done && (_a = iTokens_1.return)) _a.call(iTokens_1);
|
|
388
448
|
}
|
|
389
|
-
finally { if (
|
|
449
|
+
finally { if (e_5) throw e_5.error; }
|
|
390
450
|
}
|
|
391
451
|
return [2 /*return*/, tx];
|
|
392
452
|
});
|