@typus/typus-perp-sdk 1.2.2 → 1.3.1
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/client.d.ts +22 -3
- package/dist/src/client.js +66 -8
- package/dist/src/fetch.d.ts +61 -17
- package/dist/src/fetch.js +20 -14
- package/dist/src/generated/typus_perp/admin.d.ts +65 -21
- package/dist/src/generated/typus_perp/admin.js +139 -123
- package/dist/src/generated/typus_perp/competition.d.ts +5 -17
- package/dist/src/generated/typus_perp/competition.js +63 -39
- package/dist/src/generated/typus_perp/deps/std/type_name.d.ts +9 -9
- package/dist/src/generated/typus_perp/deps/std/type_name.js +13 -16
- package/dist/src/generated/typus_perp/deps/sui/balance.d.ts +2 -2
- package/dist/src/generated/typus_perp/deps/sui/balance.js +5 -8
- package/dist/src/generated/typus_perp/deps/sui/object.d.ts +8 -0
- package/dist/src/generated/typus_perp/deps/sui/object.js +13 -0
- package/dist/src/generated/typus_perp/deps/sui/object_table.d.ts +5 -3
- package/dist/src/generated/typus_perp/deps/sui/object_table.js +40 -9
- package/dist/src/generated/typus_perp/deps/sui/table.d.ts +5 -3
- package/dist/src/generated/typus_perp/deps/sui/table.js +40 -9
- package/dist/src/generated/typus_perp/deps/sui/vec_set.d.ts +5 -3
- package/dist/src/generated/typus_perp/deps/sui/vec_set.js +5 -8
- package/dist/src/generated/typus_perp/deps/typus/keyed_big_vector.d.ts +4 -2
- package/dist/src/generated/typus_perp/deps/typus/keyed_big_vector.js +9 -12
- package/dist/src/generated/typus_perp/deps/typus/linked_object_table.d.ts +12 -6
- package/dist/src/generated/typus_perp/deps/typus/linked_object_table.js +41 -10
- package/dist/src/generated/typus_perp/deps/typus_framework/vault.d.ts +4 -2
- package/dist/src/generated/typus_perp/deps/typus_framework/vault.js +40 -9
- package/dist/src/generated/typus_perp/error.d.ts +201 -94
- package/dist/src/generated/typus_perp/error.js +300 -273
- package/dist/src/generated/typus_perp/escrow.d.ts +14 -6
- package/dist/src/generated/typus_perp/escrow.js +38 -37
- package/dist/src/generated/typus_perp/lending.d.ts +1 -1
- package/dist/src/generated/typus_perp/lending.js +3 -3
- package/dist/src/generated/typus_perp/lp_pool.d.ts +438 -392
- package/dist/src/generated/typus_perp/lp_pool.js +987 -934
- package/dist/src/generated/typus_perp/math.d.ts +13 -16
- package/dist/src/generated/typus_perp/math.js +51 -50
- package/dist/src/generated/typus_perp/position.d.ts +194 -104
- package/dist/src/generated/typus_perp/position.js +714 -731
- package/dist/src/generated/typus_perp/profit_vault.d.ts +62 -20
- package/dist/src/generated/typus_perp/profit_vault.js +162 -148
- package/dist/src/generated/typus_perp/symbol.d.ts +12 -5
- package/dist/src/generated/typus_perp/symbol.js +28 -25
- package/dist/src/generated/typus_perp/trading.d.ts +955 -133
- package/dist/src/generated/typus_perp/trading.js +1575 -1146
- package/dist/src/generated/typus_perp/treasury_caps.d.ts +16 -7
- package/dist/src/generated/typus_perp/treasury_caps.js +60 -24
- package/dist/src/generated/typus_perp/user_account.d.ts +40 -0
- package/dist/src/generated/typus_perp/user_account.js +66 -0
- package/dist/src/generated/typus_stake_pool/admin.d.ts +144 -10
- package/dist/src/generated/typus_stake_pool/admin.js +132 -49
- package/dist/src/generated/typus_stake_pool/deps/std/type_name.d.ts +9 -9
- package/dist/src/generated/typus_stake_pool/deps/std/type_name.js +13 -16
- package/dist/src/generated/typus_stake_pool/deps/sui/object.d.ts +8 -0
- package/dist/src/generated/typus_stake_pool/deps/sui/object.js +13 -0
- package/dist/src/generated/typus_stake_pool/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/typus_stake_pool/deps/sui/vec_map.js +31 -0
- package/dist/src/generated/typus_stake_pool/deps/sui/vec_set.d.ts +5 -3
- package/dist/src/generated/typus_stake_pool/deps/sui/vec_set.js +5 -8
- package/dist/src/generated/typus_stake_pool/stake_pool.d.ts +180 -79
- package/dist/src/generated/typus_stake_pool/stake_pool.js +446 -414
- package/dist/src/generated/utils/index.d.ts +4 -23
- package/dist/src/generated/utils/index.js +34 -54
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.js +35 -13
- package/dist/src/user/order.d.ts +0 -4
- package/dist/src/user/order.js +31 -74
- package/dist/src/user/orderWithBidReceipt.d.ts +0 -3
- package/dist/src/user/orderWithBidReceipt.js +24 -45
- package/dist/src/user/tlp.d.ts +0 -5
- package/dist/src/user/tlp.js +28 -73
- package/package.json +47 -40
|
@@ -5,7 +5,6 @@ exports.createTradingOrderWithBidReceiptByAutoBid = createTradingOrderWithBidRec
|
|
|
5
5
|
exports.createTradingOrderWithBidReceipt = createTradingOrderWithBidReceipt;
|
|
6
6
|
exports.reduceOptionCollateralPositionSize = reduceOptionCollateralPositionSize;
|
|
7
7
|
const trading_1 = require("../../src/generated/typus_perp/trading");
|
|
8
|
-
const utils_1 = require("@typus/typus-sdk/dist/src/utils");
|
|
9
8
|
const constants_1 = require("@typus/typus-sdk/dist/src/constants");
|
|
10
9
|
const typus_dov_single_v2_1 = require("@typus/typus-sdk/dist/src/typus-dov-single-v2");
|
|
11
10
|
const user_entry_1 = require("@typus/typus-sdk/dist/src/auto-bid/user-entry");
|
|
@@ -37,17 +36,11 @@ function splitBidReceiptTx(client, tx, input) {
|
|
|
37
36
|
return unwrap0;
|
|
38
37
|
}
|
|
39
38
|
async function createTradingOrderWithBidReceiptByAutoBid(client, tx, input) {
|
|
40
|
-
// INPUTS
|
|
41
39
|
let TOKEN = input.cToken;
|
|
42
40
|
let BASE_TOKEN = input.tradingToken;
|
|
43
|
-
let tokens = Array.from(new Set([TOKEN, BASE_TOKEN]));
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
suiCoin = (0, utils_1.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), client.config.sponsored);
|
|
47
|
-
}
|
|
48
|
-
await (0, utils_1.updatePyth)(client.pythClient, tx, tokens, suiCoin);
|
|
49
|
-
for (let token of tokens) {
|
|
50
|
-
(0, utils_1.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
|
|
41
|
+
let tokens = Array.from(new Set([TOKEN, BASE_TOKEN])).filter((t) => t !== "TYPUS");
|
|
42
|
+
if (tokens.length > 0) {
|
|
43
|
+
await client.pythClient.updateOracleV2WithPythLazer(tx, tokens);
|
|
51
44
|
}
|
|
52
45
|
let withdrawBidReceipt = (0, user_entry_1.getWithdrawBidReceiptTx)(client.config, tx, {
|
|
53
46
|
vaultIndex: input.dovIndex,
|
|
@@ -69,40 +62,33 @@ async function createTradingOrderWithBidReceiptByAutoBid(client, tx, input) {
|
|
|
69
62
|
let cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
|
|
70
63
|
let bToken = constants_1.tokenType[__1.NETWORK][input.bToken];
|
|
71
64
|
let baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
|
|
72
|
-
tx.add((0, trading_1.
|
|
65
|
+
tx.add((0, trading_1.createTradingOrderWithBidReceiptV2)({
|
|
73
66
|
arguments: {
|
|
74
67
|
version: __1.PERP_VERSION,
|
|
75
68
|
registry: __1.MARKET,
|
|
76
69
|
poolRegistry: __1.LP_POOL,
|
|
70
|
+
dovRegistry: client.config.registry.dov.dovSingle,
|
|
71
|
+
oracleV2: __1.ORACLE_V2_ID,
|
|
77
72
|
marketIndex: BigInt(input.perpIndex),
|
|
78
73
|
poolIndex: BigInt(input.poolIndex),
|
|
79
|
-
typusOracleCToken: constants_1.oracle[__1.NETWORK][TOKEN],
|
|
80
|
-
typusOracleTradingSymbol: constants_1.oracle[__1.NETWORK][BASE_TOKEN],
|
|
81
74
|
typusEcosystemVersion: client.config.version.typus,
|
|
82
75
|
typusUserRegistry: client.config.registry.typus.user,
|
|
83
76
|
typusLeaderboardRegistry: client.config.registry.typus.leaderboard,
|
|
84
|
-
isLong: input.isLong,
|
|
85
|
-
dovRegistry: client.config.registry.dov.dovSingle,
|
|
86
|
-
collateralBidReceipt,
|
|
87
77
|
tailsStakingRegistry: client.config.registry.typus.tailsStaking,
|
|
88
78
|
competitionConfig: __1.COMPETITION_CONFIG,
|
|
79
|
+
collateralBidReceipt,
|
|
80
|
+
isLong: input.isLong,
|
|
89
81
|
},
|
|
90
82
|
typeArguments: [cToken, bToken, baseToken],
|
|
91
83
|
}));
|
|
92
84
|
return tx;
|
|
93
85
|
}
|
|
94
86
|
async function createTradingOrderWithBidReceipt(client, tx, input) {
|
|
95
|
-
// INPUTS
|
|
96
87
|
let TOKEN = input.cToken;
|
|
97
88
|
let BASE_TOKEN = input.tradingToken;
|
|
98
|
-
let tokens = Array.from(new Set([TOKEN, BASE_TOKEN]));
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
suiCoin = (0, utils_1.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), client.config.sponsored);
|
|
102
|
-
}
|
|
103
|
-
await (0, utils_1.updatePyth)(client.pythClient, tx, tokens, suiCoin);
|
|
104
|
-
for (let token of tokens) {
|
|
105
|
-
(0, utils_1.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
|
|
89
|
+
let tokens = Array.from(new Set([TOKEN, BASE_TOKEN])).filter((t) => t !== "TYPUS");
|
|
90
|
+
if (tokens.length > 0) {
|
|
91
|
+
await client.pythClient.updateOracleV2WithPythLazer(tx, tokens);
|
|
106
92
|
}
|
|
107
93
|
// split bid receipt
|
|
108
94
|
let collateralBidReceipt = (0, typus_dov_single_v2_1.getSplitBidReceiptTx)(client.config, tx, {
|
|
@@ -114,23 +100,22 @@ async function createTradingOrderWithBidReceipt(client, tx, input) {
|
|
|
114
100
|
let cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
|
|
115
101
|
let bToken = constants_1.tokenType[__1.NETWORK][input.bToken];
|
|
116
102
|
let baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
|
|
117
|
-
tx.add((0, trading_1.
|
|
103
|
+
tx.add((0, trading_1.createTradingOrderWithBidReceiptV2)({
|
|
118
104
|
arguments: {
|
|
119
105
|
version: __1.PERP_VERSION,
|
|
120
106
|
registry: __1.MARKET,
|
|
121
107
|
poolRegistry: __1.LP_POOL,
|
|
108
|
+
dovRegistry: client.config.registry.dov.dovSingle,
|
|
109
|
+
oracleV2: __1.ORACLE_V2_ID,
|
|
122
110
|
marketIndex: BigInt(input.perpIndex),
|
|
123
111
|
poolIndex: BigInt(input.poolIndex),
|
|
124
|
-
typusOracleCToken: constants_1.oracle[__1.NETWORK][TOKEN],
|
|
125
|
-
typusOracleTradingSymbol: constants_1.oracle[__1.NETWORK][BASE_TOKEN],
|
|
126
112
|
typusEcosystemVersion: client.config.version.typus,
|
|
127
113
|
typusUserRegistry: client.config.registry.typus.user,
|
|
128
114
|
typusLeaderboardRegistry: client.config.registry.typus.leaderboard,
|
|
129
|
-
isLong: input.isLong,
|
|
130
|
-
dovRegistry: client.config.registry.dov.dovSingle,
|
|
131
|
-
collateralBidReceipt,
|
|
132
115
|
tailsStakingRegistry: client.config.registry.typus.tailsStaking,
|
|
133
116
|
competitionConfig: __1.COMPETITION_CONFIG,
|
|
117
|
+
collateralBidReceipt,
|
|
118
|
+
isLong: input.isLong,
|
|
134
119
|
},
|
|
135
120
|
typeArguments: [cToken, bToken, baseToken],
|
|
136
121
|
}));
|
|
@@ -139,35 +124,29 @@ async function createTradingOrderWithBidReceipt(client, tx, input) {
|
|
|
139
124
|
async function reduceOptionCollateralPositionSize(client, tx, input) {
|
|
140
125
|
let TOKEN = input.cToken;
|
|
141
126
|
let BASE_TOKEN = input.tradingToken;
|
|
142
|
-
let tokens = Array.from(new Set([TOKEN, BASE_TOKEN]));
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
suiCoin = (0, utils_1.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), client.config.sponsored);
|
|
146
|
-
}
|
|
147
|
-
await (0, utils_1.updatePyth)(client.pythClient, tx, tokens, suiCoin);
|
|
148
|
-
for (let token of tokens) {
|
|
149
|
-
(0, utils_1.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
|
|
127
|
+
let tokens = Array.from(new Set([TOKEN, BASE_TOKEN])).filter((t) => t !== "TYPUS");
|
|
128
|
+
if (tokens.length > 0) {
|
|
129
|
+
await client.pythClient.updateOracleV2WithPythLazer(tx, tokens);
|
|
150
130
|
}
|
|
151
131
|
let cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
|
|
152
132
|
let bToken = constants_1.tokenType[__1.NETWORK][input.bToken];
|
|
153
133
|
let baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
|
|
154
|
-
tx.add((0, trading_1.
|
|
134
|
+
tx.add((0, trading_1.reduceOptionCollateralPositionSizeV2)({
|
|
155
135
|
arguments: {
|
|
156
136
|
version: __1.PERP_VERSION,
|
|
157
137
|
registry: __1.MARKET,
|
|
158
138
|
poolRegistry: __1.LP_POOL,
|
|
139
|
+
dovRegistry: client.config.registry.dov.dovSingle,
|
|
140
|
+
oracleV2: __1.ORACLE_V2_ID,
|
|
159
141
|
marketIndex: BigInt(input.perpIndex),
|
|
160
142
|
poolIndex: BigInt(input.perpIndex),
|
|
161
|
-
typusOracleCToken: constants_1.oracle[__1.NETWORK][TOKEN],
|
|
162
|
-
typusOracleTradingSymbol: constants_1.oracle[__1.NETWORK][BASE_TOKEN],
|
|
163
143
|
typusEcosystemVersion: client.config.version.typus,
|
|
164
144
|
typusUserRegistry: client.config.registry.typus.user,
|
|
165
145
|
typusLeaderboardRegistry: client.config.registry.typus.leaderboard,
|
|
166
|
-
dovRegistry: client.config.registry.dov.dovSingle,
|
|
167
|
-
positionId: BigInt(input.positionId),
|
|
168
|
-
orderSize: input.orderSize ? BigInt(input.orderSize) : null,
|
|
169
146
|
tailsStakingRegistry: client.config.registry.typus.tailsStaking,
|
|
170
147
|
competitionConfig: __1.COMPETITION_CONFIG,
|
|
148
|
+
positionId: BigInt(input.positionId),
|
|
149
|
+
orderSize: tx.pure.option("u64", input.orderSize ? BigInt(input.orderSize) : null),
|
|
171
150
|
},
|
|
172
151
|
typeArguments: [cToken, bToken, baseToken],
|
|
173
152
|
}));
|
package/dist/src/user/tlp.d.ts
CHANGED
|
@@ -16,7 +16,6 @@ export declare function mintStakeLp(client: TypusClient, tx: Transaction, input:
|
|
|
16
16
|
isAutoCompound: boolean;
|
|
17
17
|
user: string;
|
|
18
18
|
stake: boolean;
|
|
19
|
-
suiCoins?: string[];
|
|
20
19
|
}): Promise<Transaction>;
|
|
21
20
|
export declare function stakeLp(client: TypusClient, tx: Transaction, input: {
|
|
22
21
|
stakePool: typeof StakePool.$inferType;
|
|
@@ -38,21 +37,18 @@ export declare function unstakeRedeem(client: TypusClient, tx: Transaction, inpu
|
|
|
38
37
|
userShareId: string;
|
|
39
38
|
share: string | null;
|
|
40
39
|
user: string;
|
|
41
|
-
suiCoins?: string[];
|
|
42
40
|
}): Promise<Transaction>;
|
|
43
41
|
export declare function redeemTlp(client: TypusClient, tx: Transaction, input: {
|
|
44
42
|
lpPool: typeof LiquidityPool.$inferType;
|
|
45
43
|
lpCoins: string[];
|
|
46
44
|
share: string | null;
|
|
47
45
|
user: string;
|
|
48
|
-
suiCoins?: string[];
|
|
49
46
|
}): Promise<Transaction>;
|
|
50
47
|
export declare function claim(client: TypusClient, tx: Transaction, input: {
|
|
51
48
|
lpPool: typeof LiquidityPool.$inferType;
|
|
52
49
|
stakePool: typeof StakePool.$inferType;
|
|
53
50
|
cTOKEN: TOKEN;
|
|
54
51
|
user: string;
|
|
55
|
-
suiCoins?: string[];
|
|
56
52
|
}): Promise<Transaction>;
|
|
57
53
|
export declare function swap(client: TypusClient, tx: Transaction, input: {
|
|
58
54
|
coins: string[];
|
|
@@ -61,7 +57,6 @@ export declare function swap(client: TypusClient, tx: Transaction, input: {
|
|
|
61
57
|
amount: string;
|
|
62
58
|
user: string;
|
|
63
59
|
perpIndex: number;
|
|
64
|
-
suiCoins?: string[];
|
|
65
60
|
}): Promise<Transaction>;
|
|
66
61
|
export declare function harvestStakeReward(client: TypusClient, tx: Transaction, input: {
|
|
67
62
|
stakePool: typeof StakePool.$inferType;
|
package/dist/src/user/tlp.js
CHANGED
|
@@ -28,49 +28,35 @@ async function snapshot(client, tx, input) {
|
|
|
28
28
|
return tx;
|
|
29
29
|
}
|
|
30
30
|
async function mintStakeLp(client, tx, input) {
|
|
31
|
-
//
|
|
31
|
+
// tokens in the LP pool
|
|
32
32
|
let tokens = input.lpPool.token_pools.map((p) => (0, constants_1.typeArgToAsset)("0x" + p.token_type.name));
|
|
33
|
-
// console.log("tokens", tokens);
|
|
34
33
|
let cToken = constants_1.tokenType[__1.NETWORK][input.cTOKEN];
|
|
35
|
-
let coin;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// split together
|
|
39
|
-
[coin, suiCoin] = (0, utils_2.splitCoins)(tx, constants_1.tokenType.MAINNET.SUI, input.coins, [input.amount, tokens.length.toString()], client.config.sponsored);
|
|
34
|
+
let coin = (0, utils_2.splitCoin)(tx, cToken, input.coins, input.amount, client.config.sponsored);
|
|
35
|
+
if (tokens.length > 0) {
|
|
36
|
+
await client.pythClient.updateOracleV2WithPythLazer(tx, tokens);
|
|
40
37
|
}
|
|
41
|
-
else if (client.config.sponsored) {
|
|
42
|
-
coin = (0, utils_2.splitCoin)(tx, cToken, input.coins, input.amount, client.config.sponsored);
|
|
43
|
-
suiCoin = (0, utils_2.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), client.config.sponsored);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
coin = (0, utils_2.splitCoin)(tx, cToken, input.coins, input.amount, client.config.sponsored);
|
|
47
|
-
// no suiCoin
|
|
48
|
-
}
|
|
49
|
-
await (0, utils_2.updatePyth)(client.pythClient, tx, tokens, suiCoin);
|
|
50
38
|
for (let token of tokens) {
|
|
51
|
-
(0,
|
|
52
|
-
tx.add((0, lp_pool_1.updateLiquidityValue)({
|
|
39
|
+
tx.add((0, lp_pool_1.updateLiquidityValueV2)({
|
|
53
40
|
arguments: {
|
|
54
41
|
version: __1.PERP_VERSION,
|
|
55
42
|
registry: __1.LP_POOL,
|
|
56
43
|
index: BigInt(input.stakePool.pool_info.index),
|
|
57
|
-
|
|
44
|
+
oracleV2: __1.ORACLE_V2_ID,
|
|
58
45
|
},
|
|
59
46
|
typeArguments: [constants_1.tokenType[__1.NETWORK][token]],
|
|
60
47
|
}));
|
|
61
48
|
}
|
|
62
|
-
// console.log(iToken);
|
|
63
49
|
if (input.userShareId) {
|
|
64
50
|
harvestStakeReward(client, tx, { stakePool: input.stakePool, user: input.user });
|
|
65
51
|
}
|
|
66
52
|
let lpToken = (0, utils_1.normalizeStructTag)(input.lpPool.lp_token_type.name);
|
|
67
|
-
let lpCoin = tx.add((0, lp_pool_1.
|
|
53
|
+
let lpCoin = tx.add((0, lp_pool_1.mintLpV2)({
|
|
68
54
|
arguments: {
|
|
69
55
|
version: __1.PERP_VERSION,
|
|
70
56
|
registry: __1.LP_POOL,
|
|
71
57
|
treasuryCaps: __1.TLP_TREASURY_CAP,
|
|
72
58
|
index: BigInt(input.stakePool.pool_info.index),
|
|
73
|
-
|
|
59
|
+
oracleV2: __1.ORACLE_V2_ID,
|
|
74
60
|
coin,
|
|
75
61
|
},
|
|
76
62
|
typeArguments: [cToken, lpToken],
|
|
@@ -98,7 +84,6 @@ async function stakeLp(client, tx, input) {
|
|
|
98
84
|
tx.mergeCoins(destination, input.lpCoins);
|
|
99
85
|
}
|
|
100
86
|
[lpCoin] = tx.splitCoins(destination, [input.amount]);
|
|
101
|
-
// console.log(iToken);
|
|
102
87
|
if (input.userShareId) {
|
|
103
88
|
harvestStakeReward(client, tx, { stakePool: input.stakePool, user: input.user });
|
|
104
89
|
}
|
|
@@ -121,7 +106,7 @@ async function unstake(client, tx, input) {
|
|
|
121
106
|
version: __1.STAKE_POOL_VERSION,
|
|
122
107
|
registry: __1.STAKE_POOL,
|
|
123
108
|
index: BigInt(input.stakePool.pool_info.index),
|
|
124
|
-
unsubscribedShares: input.share ? BigInt(input.share) : null,
|
|
109
|
+
unsubscribedShares: tx.pure.option("u64", input.share ? BigInt(input.share) : null),
|
|
125
110
|
},
|
|
126
111
|
typeArguments: [lpToken],
|
|
127
112
|
}));
|
|
@@ -137,21 +122,17 @@ async function unstake(client, tx, input) {
|
|
|
137
122
|
return tx;
|
|
138
123
|
}
|
|
139
124
|
async function unstakeRedeem(client, tx, input) {
|
|
140
|
-
// update pyth oracle
|
|
141
125
|
let tokens = input.lpPool.token_pools.map((p) => (0, constants_1.typeArgToAsset)("0x" + p.token_type.name));
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
suiCoin = (0, utils_2.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), client.config.sponsored);
|
|
126
|
+
if (tokens.length > 0) {
|
|
127
|
+
await client.pythClient.updateOracleV2WithPythLazer(tx, tokens);
|
|
145
128
|
}
|
|
146
|
-
await (0, utils_2.updatePyth)(client.pythClient, tx, tokens, suiCoin);
|
|
147
129
|
for (let token of tokens) {
|
|
148
|
-
(0,
|
|
149
|
-
(0, lp_pool_1.updateLiquidityValue)({
|
|
130
|
+
(0, lp_pool_1.updateLiquidityValueV2)({
|
|
150
131
|
arguments: {
|
|
151
132
|
version: __1.PERP_VERSION,
|
|
152
133
|
registry: __1.LP_POOL,
|
|
153
134
|
index: BigInt(input.stakePool.pool_info.index),
|
|
154
|
-
|
|
135
|
+
oracleV2: __1.ORACLE_V2_ID,
|
|
155
136
|
},
|
|
156
137
|
typeArguments: [constants_1.tokenType[__1.NETWORK][token]],
|
|
157
138
|
})(tx);
|
|
@@ -163,7 +144,7 @@ async function unstakeRedeem(client, tx, input) {
|
|
|
163
144
|
version: __1.STAKE_POOL_VERSION,
|
|
164
145
|
registry: __1.STAKE_POOL,
|
|
165
146
|
index: BigInt(input.stakePool.pool_info.index),
|
|
166
|
-
unsubscribedShares: input.share ? BigInt(input.share) : null,
|
|
147
|
+
unsubscribedShares: tx.pure.option("u64", input.share ? BigInt(input.share) : null),
|
|
167
148
|
},
|
|
168
149
|
typeArguments: [lpToken],
|
|
169
150
|
}));
|
|
@@ -192,21 +173,17 @@ async function unstakeRedeem(client, tx, input) {
|
|
|
192
173
|
return tx;
|
|
193
174
|
}
|
|
194
175
|
async function redeemTlp(client, tx, input) {
|
|
195
|
-
// update pyth oracle
|
|
196
176
|
let tokens = input.lpPool.token_pools.map((p) => (0, constants_1.typeArgToAsset)("0x" + p.token_type.name));
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
suiCoin = (0, utils_2.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), client.config.sponsored);
|
|
177
|
+
if (tokens.length > 0) {
|
|
178
|
+
await client.pythClient.updateOracleV2WithPythLazer(tx, tokens);
|
|
200
179
|
}
|
|
201
|
-
await (0, utils_2.updatePyth)(client.pythClient, tx, tokens, suiCoin);
|
|
202
180
|
for (let token of tokens) {
|
|
203
|
-
(0,
|
|
204
|
-
tx.add((0, lp_pool_1.updateLiquidityValue)({
|
|
181
|
+
tx.add((0, lp_pool_1.updateLiquidityValueV2)({
|
|
205
182
|
arguments: {
|
|
206
183
|
version: __1.PERP_VERSION,
|
|
207
184
|
registry: __1.LP_POOL,
|
|
208
185
|
index: BigInt(input.lpPool.index),
|
|
209
|
-
|
|
186
|
+
oracleV2: __1.ORACLE_V2_ID,
|
|
210
187
|
},
|
|
211
188
|
typeArguments: [constants_1.tokenType[__1.NETWORK][token]],
|
|
212
189
|
}));
|
|
@@ -241,33 +218,29 @@ async function redeemTlp(client, tx, input) {
|
|
|
241
218
|
return tx;
|
|
242
219
|
}
|
|
243
220
|
async function claim(client, tx, input) {
|
|
244
|
-
// update pyth oracle
|
|
245
221
|
let tokens = input.lpPool.token_pools.map((p) => (0, constants_1.typeArgToAsset)("0x" + p.token_type.name));
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
suiCoin = (0, utils_2.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), client.config.sponsored);
|
|
222
|
+
if (tokens.length > 0) {
|
|
223
|
+
await client.pythClient.updateOracleV2WithPythLazer(tx, tokens);
|
|
249
224
|
}
|
|
250
|
-
await (0, utils_2.updatePyth)(client.pythClient, tx, tokens, suiCoin);
|
|
251
225
|
for (let token of tokens) {
|
|
252
|
-
(0,
|
|
253
|
-
(0, lp_pool_1.updateLiquidityValue)({
|
|
226
|
+
(0, lp_pool_1.updateLiquidityValueV2)({
|
|
254
227
|
arguments: {
|
|
255
228
|
version: __1.PERP_VERSION,
|
|
256
229
|
registry: __1.LP_POOL,
|
|
257
230
|
index: BigInt(input.stakePool.pool_info.index),
|
|
258
|
-
|
|
231
|
+
oracleV2: __1.ORACLE_V2_ID,
|
|
259
232
|
},
|
|
260
233
|
typeArguments: [constants_1.tokenType[__1.NETWORK][token]],
|
|
261
234
|
})(tx);
|
|
262
235
|
}
|
|
263
236
|
let cToken = constants_1.tokenType[__1.NETWORK][input.cTOKEN];
|
|
264
|
-
let token = (0, lp_pool_1.
|
|
237
|
+
let token = (0, lp_pool_1.claimV2)({
|
|
265
238
|
arguments: {
|
|
266
239
|
version: __1.PERP_VERSION,
|
|
267
240
|
registry: __1.LP_POOL,
|
|
268
241
|
index: BigInt(input.stakePool.pool_info.index),
|
|
269
242
|
treasuryCaps: __1.TLP_TREASURY_CAP,
|
|
270
|
-
|
|
243
|
+
oracleV2: __1.ORACLE_V2_ID,
|
|
271
244
|
},
|
|
272
245
|
typeArguments: [(0, utils_1.normalizeStructTag)(input.lpPool.lp_token_type.name), cToken],
|
|
273
246
|
})(tx);
|
|
@@ -277,30 +250,14 @@ async function claim(client, tx, input) {
|
|
|
277
250
|
async function swap(client, tx, input) {
|
|
278
251
|
let fromToken = constants_1.tokenType[__1.NETWORK][input.FROM_TOKEN];
|
|
279
252
|
let toToken = constants_1.tokenType[__1.NETWORK][input.TO_TOKEN];
|
|
280
|
-
let coin;
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
// split together
|
|
284
|
-
[coin, suiCoin] = (0, utils_2.splitCoins)(tx, constants_1.tokenType.MAINNET.SUI, input.coins, [input.amount, "2"], client.config.sponsored);
|
|
285
|
-
}
|
|
286
|
-
else if (client.config.sponsored) {
|
|
287
|
-
coin = (0, utils_2.splitCoin)(tx, fromToken, input.coins, input.amount, client.config.sponsored);
|
|
288
|
-
suiCoin = (0, utils_2.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, "2", client.config.sponsored);
|
|
289
|
-
}
|
|
290
|
-
else {
|
|
291
|
-
coin = (0, utils_2.splitCoin)(tx, fromToken, input.coins, input.amount, client.config.sponsored);
|
|
292
|
-
// no suiCoin
|
|
293
|
-
}
|
|
294
|
-
await (0, utils_2.updatePyth)(client.pythClient, tx, [input.FROM_TOKEN, input.TO_TOKEN], suiCoin);
|
|
295
|
-
(0, utils_2.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, input.FROM_TOKEN);
|
|
296
|
-
(0, utils_2.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, input.TO_TOKEN);
|
|
297
|
-
let token = (0, lp_pool_1.swap)({
|
|
253
|
+
let coin = (0, utils_2.splitCoin)(tx, fromToken, input.coins, input.amount, client.config.sponsored);
|
|
254
|
+
await client.pythClient.updateOracleV2WithPythLazer(tx, [input.FROM_TOKEN, input.TO_TOKEN]);
|
|
255
|
+
let token = (0, lp_pool_1.swapV2)({
|
|
298
256
|
arguments: {
|
|
299
257
|
version: __1.PERP_VERSION,
|
|
300
258
|
registry: __1.LP_POOL,
|
|
301
259
|
index: BigInt(input.perpIndex),
|
|
302
|
-
|
|
303
|
-
oracleToToken: constants_1.oracle[__1.NETWORK][input.TO_TOKEN],
|
|
260
|
+
oracleV2: __1.ORACLE_V2_ID,
|
|
304
261
|
fromCoin: coin,
|
|
305
262
|
minToAmount: BigInt(0),
|
|
306
263
|
},
|
|
@@ -313,7 +270,6 @@ async function harvestStakeReward(client, tx, input) {
|
|
|
313
270
|
let iTokens = input.stakePool.incentives.map((i) => (0, utils_1.normalizeStructTag)(i.token_type.name));
|
|
314
271
|
snapshot(client, tx, { perpIndex: input.stakePool.pool_info.index });
|
|
315
272
|
for (let iToken of iTokens) {
|
|
316
|
-
// console.log(iToken);
|
|
317
273
|
let iCoin = tx.add((0, stake_pool_1.harvestPerUserShare)({
|
|
318
274
|
arguments: {
|
|
319
275
|
version: __1.STAKE_POOL_VERSION,
|
|
@@ -323,7 +279,6 @@ async function harvestStakeReward(client, tx, input) {
|
|
|
323
279
|
typeArguments: [iToken],
|
|
324
280
|
}));
|
|
325
281
|
if (iToken.endsWith("TLP")) {
|
|
326
|
-
// stake
|
|
327
282
|
tx.add((0, stake_pool_1.stake)({
|
|
328
283
|
arguments: {
|
|
329
284
|
version: __1.STAKE_POOL_VERSION,
|
package/package.json
CHANGED
|
@@ -1,41 +1,48 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
2
|
+
"name": "@typus/typus-perp-sdk",
|
|
3
|
+
"version": "1.3.1",
|
|
4
|
+
"repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
|
|
5
|
+
"author": "Typus",
|
|
6
|
+
"description": "typus perp sdk",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@mysten/bcs": "2.0.3",
|
|
10
|
+
"@mysten/sui": "2.13.2",
|
|
11
|
+
"@pythnetwork/pyth-lazer-sdk": "6.2.2",
|
|
12
|
+
"@typus/typus-sdk": "1.10.1",
|
|
13
|
+
"dotenv": "16.4.5"
|
|
14
|
+
},
|
|
15
|
+
"resolutions": {
|
|
16
|
+
"@pythnetwork/pyth-sui-js": "2.3.0"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/node": "^25.6.0",
|
|
20
|
+
"axios": "1.13.2",
|
|
21
|
+
"bignumber.js": "9.1.2",
|
|
22
|
+
"prettier": "^3.0.0",
|
|
23
|
+
"ts-node": "^10.9.2",
|
|
24
|
+
"tsc-alias": "^1.8.10",
|
|
25
|
+
"tsconfig-paths": "^4.2.0",
|
|
26
|
+
"tslint": "^6.1.3",
|
|
27
|
+
"tslint-config-prettier": "^1.18.0",
|
|
28
|
+
"typescript": "^5.1.6"
|
|
29
|
+
},
|
|
30
|
+
"main": "dist/src/index.js",
|
|
31
|
+
"types": "dist/src/index.d.ts",
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json && tsc-alias"
|
|
37
|
+
},
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/Typus-Lab/typus-perp-sdk/issues"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/Typus-Lab/typus-perp-sdk#readme",
|
|
42
|
+
"packageManager": "pnpm@10.33.2+sha512.a90faf6feeab71ad6c6e57f94e0fe1a12f5dcc22cd754db40ae9593eb6a3e0b6b12e3540218bb37ae083404b1f2ce6db2a4121e979829b4aff94b99f49da1cf8",
|
|
43
|
+
"pnpm": {
|
|
44
|
+
"overrides": {
|
|
45
|
+
"@typus/typus-sdk": "link:../typus-sdk"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|