@typus/typus-perp-sdk 1.1.32-codegen-exp7 → 1.1.32-codegen-exp9
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.js +34 -3
- package/dist/src/fetch.d.ts +2 -2
- package/dist/src/fetch.js +42 -40
- package/dist/src/generated/typus_perp/admin.d.ts +158 -1
- package/dist/src/generated/typus_perp/admin.js +211 -0
- package/dist/src/generated/typus_perp/competition.d.ts +39 -1
- package/dist/src/generated/typus_perp/competition.js +46 -0
- package/dist/src/generated/typus_perp/deps/sui/table.d.ts +31 -0
- package/dist/src/generated/typus_perp/{tlp.js → deps/sui/table.js} +28 -13
- package/dist/src/generated/typus_perp/deps/typus_framework/vault.d.ts +0 -8
- package/dist/src/generated/typus_perp/deps/typus_framework/vault.js +3 -11
- package/dist/src/generated/typus_perp/error.d.ts +443 -0
- package/dist/src/generated/typus_perp/error.js +788 -0
- package/dist/src/generated/typus_perp/escrow.d.ts +51 -1
- package/dist/src/generated/typus_perp/escrow.js +63 -0
- package/dist/src/generated/typus_perp/lp_pool.d.ts +2 -476
- package/dist/src/generated/typus_perp/lp_pool.js +19 -492
- package/dist/src/generated/typus_perp/position.d.ts +1016 -1
- package/dist/src/generated/typus_perp/position.js +1187 -0
- package/dist/src/generated/typus_perp/profit_vault.d.ts +272 -0
- package/dist/src/generated/typus_perp/profit_vault.js +321 -0
- package/dist/src/generated/typus_perp/symbol.d.ts +30 -1
- package/dist/src/generated/typus_perp/symbol.js +42 -0
- package/dist/src/generated/typus_perp/trading.d.ts +56 -418
- package/dist/src/generated/typus_perp/trading.js +124 -552
- package/dist/src/generated/typus_perp/treasury_caps.d.ts +32 -1
- package/dist/src/generated/typus_perp/treasury_caps.js +40 -0
- package/dist/src/generated/typus_perp/user_account.d.ts +107 -1
- package/dist/src/generated/typus_perp/user_account.js +149 -0
- package/dist/src/generated/typus_stake_pool/admin.d.ts +9 -25
- package/dist/src/generated/typus_stake_pool/admin.js +11 -36
- package/dist/src/generated/typus_stake_pool/stake_pool.d.ts +56 -4
- package/dist/src/generated/typus_stake_pool/stake_pool.js +68 -4
- package/dist/src/generated/utils/index.js +3 -0
- package/dist/src/grpc/graphql.d.ts +6 -6
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.js +13 -19
- package/dist/src/user/order.js +1 -6
- package/dist/src/user/orderWithBidReceipt.js +3 -3
- package/package.json +2 -2
- package/dist/src/generated/typus_perp/lending.d.ts +0 -47
- package/dist/src/generated/typus_perp/lending.js +0 -50
- package/dist/src/generated/typus_perp/tlp.d.ts +0 -13
package/dist/src/client.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TypusClient = void 0;
|
|
4
|
+
const latest_1 = require("@mysten/sui/graphql/schemas/latest");
|
|
4
5
|
const graphql_1 = require("@mysten/sui/graphql");
|
|
5
6
|
const grpc_1 = require("@mysten/sui/grpc");
|
|
6
7
|
const client_1 = require("@mysten/sui/client");
|
|
7
8
|
const utils_1 = require("@typus/typus-sdk/dist/src/utils");
|
|
8
|
-
const src_1 = require("../src");
|
|
9
9
|
const grpcweb_transport_1 = require("@protobuf-ts/grpcweb-transport");
|
|
10
10
|
class TypusClient {
|
|
11
11
|
// user: string;
|
|
@@ -16,8 +16,8 @@ class TypusClient {
|
|
|
16
16
|
const mvr = {
|
|
17
17
|
overrides: {
|
|
18
18
|
packages: {
|
|
19
|
-
"@typus/perp":
|
|
20
|
-
"@typus/stake-pool":
|
|
19
|
+
"@typus/perp": config.package.perp.perp,
|
|
20
|
+
"@typus/stake-pool": config.package.perp.stakePool,
|
|
21
21
|
},
|
|
22
22
|
// types: {
|
|
23
23
|
// "@typus/perp": PERP_PACKAGE_ID,
|
|
@@ -138,3 +138,34 @@ class TypusClient {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
exports.TypusClient = TypusClient;
|
|
141
|
+
const dynamicFieldsQuery = (0, latest_1.graphql)(`
|
|
142
|
+
query ($id: SuiAddress!) {
|
|
143
|
+
address(address: $id) {
|
|
144
|
+
dynamicFields {
|
|
145
|
+
nodes {
|
|
146
|
+
name {
|
|
147
|
+
...Value
|
|
148
|
+
}
|
|
149
|
+
value {
|
|
150
|
+
__typename
|
|
151
|
+
... on MoveValue {
|
|
152
|
+
...Value
|
|
153
|
+
}
|
|
154
|
+
... on MoveObject {
|
|
155
|
+
contents {
|
|
156
|
+
...Value
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
fragment Value on MoveValue {
|
|
166
|
+
type {
|
|
167
|
+
repr
|
|
168
|
+
}
|
|
169
|
+
json
|
|
170
|
+
}
|
|
171
|
+
`);
|
package/dist/src/fetch.d.ts
CHANGED
|
@@ -341,7 +341,7 @@ export declare function getMarkets(client: TypusClient, input: {
|
|
|
341
341
|
u64_padding: string[];
|
|
342
342
|
};
|
|
343
343
|
}[]][]>;
|
|
344
|
-
export type TradingOrder =
|
|
344
|
+
export type TradingOrder = typeof TradingOrder.$inferType;
|
|
345
345
|
export type TradingOrderWithMarketIndex = TradingOrder & {
|
|
346
346
|
marketIndex: number;
|
|
347
347
|
};
|
|
@@ -349,7 +349,7 @@ export declare function getUserOrders(client: TypusClient, input: {
|
|
|
349
349
|
user: string;
|
|
350
350
|
indexes: string[];
|
|
351
351
|
}): Promise<TradingOrderWithMarketIndex[]>;
|
|
352
|
-
export type Position =
|
|
352
|
+
export type Position = typeof Position.$inferType;
|
|
353
353
|
export type PositionWithMarketIndex = Position & {
|
|
354
354
|
marketIndex: number;
|
|
355
355
|
};
|
package/dist/src/fetch.js
CHANGED
|
@@ -35,54 +35,56 @@ async function getLpPools(client) {
|
|
|
35
35
|
// // console.log(lpPool);
|
|
36
36
|
// lpPools.push(lpPool);
|
|
37
37
|
// }
|
|
38
|
-
// return lpPools;
|
|
38
|
+
// return lpPools.sort((a, b) => Number(a.index) - Number(b.index));
|
|
39
39
|
return (await client.getDynamicObjectFieldsBcs(_1.LIQUIDITY_POOL).then((x) => x.map((x) => lp_pool_2.LiquidityPool.parse(x)))).sort((a, b) => Number(a.index) - Number(b.index));
|
|
40
40
|
}
|
|
41
41
|
async function getLpPool(client, objectId) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
const bcs = await client.getObjectBcs(objectId);
|
|
55
|
-
return
|
|
42
|
+
const data = await client.getObject({
|
|
43
|
+
id: objectId,
|
|
44
|
+
options: {
|
|
45
|
+
// request the bcs data when loading your object
|
|
46
|
+
showBcs: true,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
if (data.data?.bcs?.dataType !== "moveObject") {
|
|
50
|
+
throw new Error("Expected a move object");
|
|
51
|
+
}
|
|
52
|
+
// console.log(data.data.bcs.bcsBytes);
|
|
53
|
+
return lp_pool_2.LiquidityPool.fromBase64(data.data.bcs.bcsBytes);
|
|
54
|
+
// const bcs = await client.getObjectBcs(objectId);
|
|
55
|
+
// return LiquidityPool.parse(bcs!);
|
|
56
56
|
}
|
|
57
57
|
// getLpPool(client).then((x) => console.log(x));
|
|
58
58
|
async function getStakePools(client) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return (await client.getDynamicObjectFieldsBcs(
|
|
59
|
+
let dynamicFields = await client.getDynamicFields({
|
|
60
|
+
parentId: _1.STAKE_POOL,
|
|
61
|
+
});
|
|
62
|
+
let stakePools = [];
|
|
63
|
+
for (const field of dynamicFields.data) {
|
|
64
|
+
let stakePool = await getStakePool(client, field.objectId);
|
|
65
|
+
// console.log(stakePool);
|
|
66
|
+
stakePools.push(stakePool);
|
|
67
|
+
}
|
|
68
|
+
return stakePools.sort((a, b) => Number(a.pool_info.index) - Number(b.pool_info.index));
|
|
69
|
+
// return (await client.getDynamicObjectFieldsBcs(STAKE_POOL).then((x) => x.map((x) => StakePool.parse(x)))).sort(
|
|
70
|
+
// (a, b) => Number(a.pool_info.index) - Number(b.pool_info.index)
|
|
71
|
+
// );
|
|
70
72
|
}
|
|
71
73
|
async function getStakePool(client, objectId) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
const bcs = await client.getObjectBcs(objectId);
|
|
85
|
-
return
|
|
74
|
+
const data = await client.getObject({
|
|
75
|
+
id: objectId,
|
|
76
|
+
options: {
|
|
77
|
+
// request the bcs data when loading your object
|
|
78
|
+
showBcs: true,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
if (data.data?.bcs?.dataType !== "moveObject") {
|
|
82
|
+
throw new Error("Expected a move object");
|
|
83
|
+
}
|
|
84
|
+
// console.log(data.data.bcs.bcsBytes);
|
|
85
|
+
return stake_pool_1.StakePool.fromBase64(data.data.bcs.bcsBytes);
|
|
86
|
+
// const bcs = await client.getObjectBcs(objectId);
|
|
87
|
+
// return StakePool.parse(bcs!);
|
|
86
88
|
}
|
|
87
89
|
/**
|
|
88
90
|
* @returns [Markets, SymbolMarket[]][]
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* Perpetual Protocol. It includes version management, authority control, and fee
|
|
7
7
|
* handling.
|
|
8
8
|
*/
|
|
9
|
-
import { MoveStruct } from "../utils/index";
|
|
9
|
+
import { MoveStruct, type RawTransactionArgument } from "../utils/index";
|
|
10
|
+
import { type Transaction } from "@mysten/sui/transactions";
|
|
10
11
|
export declare const FeeInfo: MoveStruct<{
|
|
11
12
|
/** The type name of the token. */
|
|
12
13
|
token: MoveStruct<{
|
|
@@ -115,3 +116,159 @@ export declare const PutInsuranceFundEvent: MoveStruct<{
|
|
|
115
116
|
/** The amount of funds put into the insurance fund. */
|
|
116
117
|
amount: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
117
118
|
}, "@typus/perp::admin::PutInsuranceFundEvent">;
|
|
119
|
+
export interface VersionCheckArguments {
|
|
120
|
+
version: RawTransactionArgument<string>;
|
|
121
|
+
}
|
|
122
|
+
export interface VersionCheckOptions {
|
|
123
|
+
package?: string;
|
|
124
|
+
arguments: VersionCheckArguments | [version: RawTransactionArgument<string>];
|
|
125
|
+
}
|
|
126
|
+
/** Checks if the contract version is valid. */
|
|
127
|
+
export declare function versionCheck(options: VersionCheckOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
128
|
+
export interface UpgradeArguments {
|
|
129
|
+
version: RawTransactionArgument<string>;
|
|
130
|
+
}
|
|
131
|
+
export interface UpgradeOptions {
|
|
132
|
+
package?: string;
|
|
133
|
+
arguments: UpgradeArguments | [version: RawTransactionArgument<string>];
|
|
134
|
+
}
|
|
135
|
+
/** Upgrades the contract version. WARNING: no authority check inside */
|
|
136
|
+
export declare function upgrade(options: UpgradeOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
137
|
+
export interface InitOptions {
|
|
138
|
+
package?: string;
|
|
139
|
+
arguments?: [];
|
|
140
|
+
}
|
|
141
|
+
export declare function init(options?: InitOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
142
|
+
export interface VerifyArguments {
|
|
143
|
+
version: RawTransactionArgument<string>;
|
|
144
|
+
}
|
|
145
|
+
export interface VerifyOptions {
|
|
146
|
+
package?: string;
|
|
147
|
+
arguments: VerifyArguments | [version: RawTransactionArgument<string>];
|
|
148
|
+
}
|
|
149
|
+
/** [Authorized Function] Verifies if the sender is an authorized user. */
|
|
150
|
+
export declare function verify(options: VerifyOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
151
|
+
export interface AddAuthorizedUserArguments {
|
|
152
|
+
version: RawTransactionArgument<string>;
|
|
153
|
+
userAddress: RawTransactionArgument<string>;
|
|
154
|
+
}
|
|
155
|
+
export interface AddAuthorizedUserOptions {
|
|
156
|
+
package?: string;
|
|
157
|
+
arguments: AddAuthorizedUserArguments | [version: RawTransactionArgument<string>, userAddress: RawTransactionArgument<string>];
|
|
158
|
+
}
|
|
159
|
+
/** [Authorized Function] Adds an authorized user. */
|
|
160
|
+
export declare function addAuthorizedUser(options: AddAuthorizedUserOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
161
|
+
export interface RemoveAuthorizedUserArguments {
|
|
162
|
+
version: RawTransactionArgument<string>;
|
|
163
|
+
userAddress: RawTransactionArgument<string>;
|
|
164
|
+
}
|
|
165
|
+
export interface RemoveAuthorizedUserOptions {
|
|
166
|
+
package?: string;
|
|
167
|
+
arguments: RemoveAuthorizedUserArguments | [version: RawTransactionArgument<string>, userAddress: RawTransactionArgument<string>];
|
|
168
|
+
}
|
|
169
|
+
/** [Authorized Function] Removes an authorized user. */
|
|
170
|
+
export declare function removeAuthorizedUser(options: RemoveAuthorizedUserOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
171
|
+
export interface InstallEcosystemManagerCapEntryArguments {
|
|
172
|
+
version: RawTransactionArgument<string>;
|
|
173
|
+
typusEcosystemVersion: RawTransactionArgument<string>;
|
|
174
|
+
}
|
|
175
|
+
export interface InstallEcosystemManagerCapEntryOptions {
|
|
176
|
+
package?: string;
|
|
177
|
+
arguments: InstallEcosystemManagerCapEntryArguments | [version: RawTransactionArgument<string>, typusEcosystemVersion: RawTransactionArgument<string>];
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* [Authorized Function] Installs the ecosystem manager cap. TODO: can be remove
|
|
181
|
+
* after install
|
|
182
|
+
*/
|
|
183
|
+
export declare function installEcosystemManagerCapEntry(options: InstallEcosystemManagerCapEntryOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
184
|
+
export interface AddTailsExpAndLeaderboardArguments {
|
|
185
|
+
version: RawTransactionArgument<string>;
|
|
186
|
+
typusEcosystemVersion: RawTransactionArgument<string>;
|
|
187
|
+
typusUserRegistry: RawTransactionArgument<string>;
|
|
188
|
+
typusLeaderboardRegistry: RawTransactionArgument<string>;
|
|
189
|
+
user: RawTransactionArgument<string>;
|
|
190
|
+
tradingFeeUsd: RawTransactionArgument<number | bigint>;
|
|
191
|
+
expMultiplier: RawTransactionArgument<number | bigint>;
|
|
192
|
+
}
|
|
193
|
+
export interface AddTailsExpAndLeaderboardOptions {
|
|
194
|
+
package?: string;
|
|
195
|
+
arguments: AddTailsExpAndLeaderboardArguments | [
|
|
196
|
+
version: RawTransactionArgument<string>,
|
|
197
|
+
typusEcosystemVersion: RawTransactionArgument<string>,
|
|
198
|
+
typusUserRegistry: RawTransactionArgument<string>,
|
|
199
|
+
typusLeaderboardRegistry: RawTransactionArgument<string>,
|
|
200
|
+
user: RawTransactionArgument<string>,
|
|
201
|
+
tradingFeeUsd: RawTransactionArgument<number | bigint>,
|
|
202
|
+
expMultiplier: RawTransactionArgument<number | bigint>
|
|
203
|
+
];
|
|
204
|
+
}
|
|
205
|
+
export declare function addTailsExpAndLeaderboard(options: AddTailsExpAndLeaderboardOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
206
|
+
export interface AddCompetitionLeaderboardArguments {
|
|
207
|
+
version: RawTransactionArgument<string>;
|
|
208
|
+
typusEcosystemVersion: RawTransactionArgument<string>;
|
|
209
|
+
typusLeaderboardRegistry: RawTransactionArgument<string>;
|
|
210
|
+
leaderboardKey: RawTransactionArgument<string>;
|
|
211
|
+
user: RawTransactionArgument<string>;
|
|
212
|
+
score: RawTransactionArgument<number | bigint>;
|
|
213
|
+
}
|
|
214
|
+
export interface AddCompetitionLeaderboardOptions {
|
|
215
|
+
package?: string;
|
|
216
|
+
arguments: AddCompetitionLeaderboardArguments | [
|
|
217
|
+
version: RawTransactionArgument<string>,
|
|
218
|
+
typusEcosystemVersion: RawTransactionArgument<string>,
|
|
219
|
+
typusLeaderboardRegistry: RawTransactionArgument<string>,
|
|
220
|
+
leaderboardKey: RawTransactionArgument<string>,
|
|
221
|
+
user: RawTransactionArgument<string>,
|
|
222
|
+
score: RawTransactionArgument<number | bigint>
|
|
223
|
+
];
|
|
224
|
+
}
|
|
225
|
+
/** Adds a score to the competition leaderboard. */
|
|
226
|
+
export declare function addCompetitionLeaderboard(options: AddCompetitionLeaderboardOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
227
|
+
export interface SendFeeArguments {
|
|
228
|
+
version: RawTransactionArgument<string>;
|
|
229
|
+
}
|
|
230
|
+
export interface SendFeeOptions {
|
|
231
|
+
package?: string;
|
|
232
|
+
arguments: SendFeeArguments | [version: RawTransactionArgument<string>];
|
|
233
|
+
typeArguments: [string];
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Sends the collected fees to the fee address. Safe with constant address as
|
|
237
|
+
* receiver
|
|
238
|
+
*/
|
|
239
|
+
export declare function sendFee(options: SendFeeOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
240
|
+
export interface ChargeFeeArguments {
|
|
241
|
+
version: RawTransactionArgument<string>;
|
|
242
|
+
balance: RawTransactionArgument<string>;
|
|
243
|
+
}
|
|
244
|
+
export interface ChargeFeeOptions {
|
|
245
|
+
package?: string;
|
|
246
|
+
arguments: ChargeFeeArguments | [version: RawTransactionArgument<string>, balance: RawTransactionArgument<string>];
|
|
247
|
+
typeArguments: [string];
|
|
248
|
+
}
|
|
249
|
+
/** Charges a protocol fee. */
|
|
250
|
+
export declare function chargeFee(options: ChargeFeeOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
251
|
+
export interface SendLiquidatorFeeArguments {
|
|
252
|
+
version: RawTransactionArgument<string>;
|
|
253
|
+
}
|
|
254
|
+
export interface SendLiquidatorFeeOptions {
|
|
255
|
+
package?: string;
|
|
256
|
+
arguments: SendLiquidatorFeeArguments | [version: RawTransactionArgument<string>];
|
|
257
|
+
typeArguments: [string];
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Sends the liquidator fees to the fee address. Safe with constant address as
|
|
261
|
+
* receiver
|
|
262
|
+
*/
|
|
263
|
+
export declare function sendLiquidatorFee(options: SendLiquidatorFeeOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
264
|
+
export interface ChargeLiquidatorFeeArguments {
|
|
265
|
+
version: RawTransactionArgument<string>;
|
|
266
|
+
balance: RawTransactionArgument<string>;
|
|
267
|
+
}
|
|
268
|
+
export interface ChargeLiquidatorFeeOptions {
|
|
269
|
+
package?: string;
|
|
270
|
+
arguments: ChargeLiquidatorFeeArguments | [version: RawTransactionArgument<string>, balance: RawTransactionArgument<string>];
|
|
271
|
+
typeArguments: [string];
|
|
272
|
+
}
|
|
273
|
+
/** Charges a liquidator fee. */
|
|
274
|
+
export declare function chargeLiquidatorFee(options: ChargeLiquidatorFeeOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
@@ -37,6 +37,19 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.PutInsuranceFundEvent = exports.ProtocolFeeEvent = exports.SendFeeEvent = exports.Version = exports.FeePool = exports.FeeInfo = void 0;
|
|
40
|
+
exports.versionCheck = versionCheck;
|
|
41
|
+
exports.upgrade = upgrade;
|
|
42
|
+
exports.init = init;
|
|
43
|
+
exports.verify = verify;
|
|
44
|
+
exports.addAuthorizedUser = addAuthorizedUser;
|
|
45
|
+
exports.removeAuthorizedUser = removeAuthorizedUser;
|
|
46
|
+
exports.installEcosystemManagerCapEntry = installEcosystemManagerCapEntry;
|
|
47
|
+
exports.addTailsExpAndLeaderboard = addTailsExpAndLeaderboard;
|
|
48
|
+
exports.addCompetitionLeaderboard = addCompetitionLeaderboard;
|
|
49
|
+
exports.sendFee = sendFee;
|
|
50
|
+
exports.chargeFee = chargeFee;
|
|
51
|
+
exports.sendLiquidatorFee = sendLiquidatorFee;
|
|
52
|
+
exports.chargeLiquidatorFee = chargeLiquidatorFee;
|
|
40
53
|
/**
|
|
41
54
|
* The `admin` module provides administrative functionalities for the Typus
|
|
42
55
|
* Perpetual Protocol. It includes version management, authority control, and fee
|
|
@@ -108,3 +121,201 @@ exports.PutInsuranceFundEvent = new index_1.MoveStruct({
|
|
|
108
121
|
amount: bcs_1.bcs.u64(),
|
|
109
122
|
},
|
|
110
123
|
});
|
|
124
|
+
/** Checks if the contract version is valid. */
|
|
125
|
+
function versionCheck(options) {
|
|
126
|
+
const packageAddress = options.package ?? "@typus/perp";
|
|
127
|
+
const argumentsTypes = [`${packageAddress}::admin::Version`];
|
|
128
|
+
const parameterNames = ["version"];
|
|
129
|
+
return (tx) => tx.moveCall({
|
|
130
|
+
package: packageAddress,
|
|
131
|
+
module: "admin",
|
|
132
|
+
function: "version_check",
|
|
133
|
+
arguments: (0, index_1.normalizeMoveArguments)(options.arguments, argumentsTypes, parameterNames),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/** Upgrades the contract version. WARNING: no authority check inside */
|
|
137
|
+
function upgrade(options) {
|
|
138
|
+
const packageAddress = options.package ?? "@typus/perp";
|
|
139
|
+
const argumentsTypes = [`${packageAddress}::admin::Version`];
|
|
140
|
+
const parameterNames = ["version"];
|
|
141
|
+
return (tx) => tx.moveCall({
|
|
142
|
+
package: packageAddress,
|
|
143
|
+
module: "admin",
|
|
144
|
+
function: "upgrade",
|
|
145
|
+
arguments: (0, index_1.normalizeMoveArguments)(options.arguments, argumentsTypes, parameterNames),
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function init(options = {}) {
|
|
149
|
+
const packageAddress = options.package ?? "@typus/perp";
|
|
150
|
+
return (tx) => tx.moveCall({
|
|
151
|
+
package: packageAddress,
|
|
152
|
+
module: "admin",
|
|
153
|
+
function: "init",
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/** [Authorized Function] Verifies if the sender is an authorized user. */
|
|
157
|
+
function verify(options) {
|
|
158
|
+
const packageAddress = options.package ?? "@typus/perp";
|
|
159
|
+
const argumentsTypes = [`${packageAddress}::admin::Version`];
|
|
160
|
+
const parameterNames = ["version"];
|
|
161
|
+
return (tx) => tx.moveCall({
|
|
162
|
+
package: packageAddress,
|
|
163
|
+
module: "admin",
|
|
164
|
+
function: "verify",
|
|
165
|
+
arguments: (0, index_1.normalizeMoveArguments)(options.arguments, argumentsTypes, parameterNames),
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
/** [Authorized Function] Adds an authorized user. */
|
|
169
|
+
function addAuthorizedUser(options) {
|
|
170
|
+
const packageAddress = options.package ?? "@typus/perp";
|
|
171
|
+
const argumentsTypes = [`${packageAddress}::admin::Version`, "address"];
|
|
172
|
+
const parameterNames = ["version", "userAddress"];
|
|
173
|
+
return (tx) => tx.moveCall({
|
|
174
|
+
package: packageAddress,
|
|
175
|
+
module: "admin",
|
|
176
|
+
function: "add_authorized_user",
|
|
177
|
+
arguments: (0, index_1.normalizeMoveArguments)(options.arguments, argumentsTypes, parameterNames),
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
/** [Authorized Function] Removes an authorized user. */
|
|
181
|
+
function removeAuthorizedUser(options) {
|
|
182
|
+
const packageAddress = options.package ?? "@typus/perp";
|
|
183
|
+
const argumentsTypes = [`${packageAddress}::admin::Version`, "address"];
|
|
184
|
+
const parameterNames = ["version", "userAddress"];
|
|
185
|
+
return (tx) => tx.moveCall({
|
|
186
|
+
package: packageAddress,
|
|
187
|
+
module: "admin",
|
|
188
|
+
function: "remove_authorized_user",
|
|
189
|
+
arguments: (0, index_1.normalizeMoveArguments)(options.arguments, argumentsTypes, parameterNames),
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* [Authorized Function] Installs the ecosystem manager cap. TODO: can be remove
|
|
194
|
+
* after install
|
|
195
|
+
*/
|
|
196
|
+
function installEcosystemManagerCapEntry(options) {
|
|
197
|
+
const packageAddress = options.package ?? "@typus/perp";
|
|
198
|
+
const argumentsTypes = [
|
|
199
|
+
`${packageAddress}::admin::Version`,
|
|
200
|
+
"0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277::ecosystem::Version",
|
|
201
|
+
];
|
|
202
|
+
const parameterNames = ["version", "typusEcosystemVersion"];
|
|
203
|
+
return (tx) => tx.moveCall({
|
|
204
|
+
package: packageAddress,
|
|
205
|
+
module: "admin",
|
|
206
|
+
function: "install_ecosystem_manager_cap_entry",
|
|
207
|
+
arguments: (0, index_1.normalizeMoveArguments)(options.arguments, argumentsTypes, parameterNames),
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
function addTailsExpAndLeaderboard(options) {
|
|
211
|
+
const packageAddress = options.package ?? "@typus/perp";
|
|
212
|
+
const argumentsTypes = [
|
|
213
|
+
`${packageAddress}::admin::Version`,
|
|
214
|
+
"0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277::ecosystem::Version",
|
|
215
|
+
"0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277::user::TypusUserRegistry",
|
|
216
|
+
"0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277::leaderboard::TypusLeaderboardRegistry",
|
|
217
|
+
"address",
|
|
218
|
+
"u64",
|
|
219
|
+
"u64",
|
|
220
|
+
"0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock",
|
|
221
|
+
];
|
|
222
|
+
const parameterNames = [
|
|
223
|
+
"version",
|
|
224
|
+
"typusEcosystemVersion",
|
|
225
|
+
"typusUserRegistry",
|
|
226
|
+
"typusLeaderboardRegistry",
|
|
227
|
+
"user",
|
|
228
|
+
"tradingFeeUsd",
|
|
229
|
+
"expMultiplier",
|
|
230
|
+
];
|
|
231
|
+
return (tx) => tx.moveCall({
|
|
232
|
+
package: packageAddress,
|
|
233
|
+
module: "admin",
|
|
234
|
+
function: "add_tails_exp_and_leaderboard",
|
|
235
|
+
arguments: (0, index_1.normalizeMoveArguments)(options.arguments, argumentsTypes, parameterNames),
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
/** Adds a score to the competition leaderboard. */
|
|
239
|
+
function addCompetitionLeaderboard(options) {
|
|
240
|
+
const packageAddress = options.package ?? "@typus/perp";
|
|
241
|
+
const argumentsTypes = [
|
|
242
|
+
`${packageAddress}::admin::Version`,
|
|
243
|
+
"0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277::ecosystem::Version",
|
|
244
|
+
"0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277::leaderboard::TypusLeaderboardRegistry",
|
|
245
|
+
"0x0000000000000000000000000000000000000000000000000000000000000001::ascii::String",
|
|
246
|
+
"address",
|
|
247
|
+
"u64",
|
|
248
|
+
"0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock",
|
|
249
|
+
];
|
|
250
|
+
const parameterNames = ["version", "typusEcosystemVersion", "typusLeaderboardRegistry", "leaderboardKey", "user", "score"];
|
|
251
|
+
return (tx) => tx.moveCall({
|
|
252
|
+
package: packageAddress,
|
|
253
|
+
module: "admin",
|
|
254
|
+
function: "add_competition_leaderboard",
|
|
255
|
+
arguments: (0, index_1.normalizeMoveArguments)(options.arguments, argumentsTypes, parameterNames),
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Sends the collected fees to the fee address. Safe with constant address as
|
|
260
|
+
* receiver
|
|
261
|
+
*/
|
|
262
|
+
function sendFee(options) {
|
|
263
|
+
const packageAddress = options.package ?? "@typus/perp";
|
|
264
|
+
const argumentsTypes = [`${packageAddress}::admin::Version`];
|
|
265
|
+
const parameterNames = ["version"];
|
|
266
|
+
return (tx) => tx.moveCall({
|
|
267
|
+
package: packageAddress,
|
|
268
|
+
module: "admin",
|
|
269
|
+
function: "send_fee",
|
|
270
|
+
arguments: (0, index_1.normalizeMoveArguments)(options.arguments, argumentsTypes, parameterNames),
|
|
271
|
+
typeArguments: options.typeArguments,
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
/** Charges a protocol fee. */
|
|
275
|
+
function chargeFee(options) {
|
|
276
|
+
const packageAddress = options.package ?? "@typus/perp";
|
|
277
|
+
const argumentsTypes = [
|
|
278
|
+
`${packageAddress}::admin::Version`,
|
|
279
|
+
`0x0000000000000000000000000000000000000000000000000000000000000002::balance::Balance<${options.typeArguments[0]}>`,
|
|
280
|
+
];
|
|
281
|
+
const parameterNames = ["version", "balance"];
|
|
282
|
+
return (tx) => tx.moveCall({
|
|
283
|
+
package: packageAddress,
|
|
284
|
+
module: "admin",
|
|
285
|
+
function: "charge_fee",
|
|
286
|
+
arguments: (0, index_1.normalizeMoveArguments)(options.arguments, argumentsTypes, parameterNames),
|
|
287
|
+
typeArguments: options.typeArguments,
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Sends the liquidator fees to the fee address. Safe with constant address as
|
|
292
|
+
* receiver
|
|
293
|
+
*/
|
|
294
|
+
function sendLiquidatorFee(options) {
|
|
295
|
+
const packageAddress = options.package ?? "@typus/perp";
|
|
296
|
+
const argumentsTypes = [`${packageAddress}::admin::Version`];
|
|
297
|
+
const parameterNames = ["version"];
|
|
298
|
+
return (tx) => tx.moveCall({
|
|
299
|
+
package: packageAddress,
|
|
300
|
+
module: "admin",
|
|
301
|
+
function: "send_liquidator_fee",
|
|
302
|
+
arguments: (0, index_1.normalizeMoveArguments)(options.arguments, argumentsTypes, parameterNames),
|
|
303
|
+
typeArguments: options.typeArguments,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
/** Charges a liquidator fee. */
|
|
307
|
+
function chargeLiquidatorFee(options) {
|
|
308
|
+
const packageAddress = options.package ?? "@typus/perp";
|
|
309
|
+
const argumentsTypes = [
|
|
310
|
+
`${packageAddress}::admin::Version`,
|
|
311
|
+
`0x0000000000000000000000000000000000000000000000000000000000000002::balance::Balance<${options.typeArguments[0]}>`,
|
|
312
|
+
];
|
|
313
|
+
const parameterNames = ["version", "balance"];
|
|
314
|
+
return (tx) => tx.moveCall({
|
|
315
|
+
package: packageAddress,
|
|
316
|
+
module: "admin",
|
|
317
|
+
function: "charge_liquidator_fee",
|
|
318
|
+
arguments: (0, index_1.normalizeMoveArguments)(options.arguments, argumentsTypes, parameterNames),
|
|
319
|
+
typeArguments: options.typeArguments,
|
|
320
|
+
});
|
|
321
|
+
}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
3
|
**************************************************************/
|
|
4
4
|
/** The `competition` module defines the logic for trading competitions. */
|
|
5
|
-
import { MoveStruct } from "../utils/index";
|
|
5
|
+
import { MoveStruct, type RawTransactionArgument } from "../utils/index";
|
|
6
|
+
import { type Transaction } from "@mysten/sui/transactions";
|
|
6
7
|
export declare const CompetitionConfig: MoveStruct<{
|
|
7
8
|
id: MoveStruct<{
|
|
8
9
|
id: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
@@ -20,3 +21,40 @@ export declare const CompetitionConfig: MoveStruct<{
|
|
|
20
21
|
length: number;
|
|
21
22
|
}, string>;
|
|
22
23
|
}, "@typus/perp::competition::CompetitionConfig">;
|
|
24
|
+
export interface NewCompetitionConfigArguments {
|
|
25
|
+
version: RawTransactionArgument<string>;
|
|
26
|
+
boostBp: RawTransactionArgument<number | bigint[]>;
|
|
27
|
+
programName: RawTransactionArgument<string>;
|
|
28
|
+
}
|
|
29
|
+
export interface NewCompetitionConfigOptions {
|
|
30
|
+
package?: string;
|
|
31
|
+
arguments: NewCompetitionConfigArguments | [
|
|
32
|
+
version: RawTransactionArgument<string>,
|
|
33
|
+
boostBp: RawTransactionArgument<number | bigint[]>,
|
|
34
|
+
programName: RawTransactionArgument<string>
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
export declare function newCompetitionConfig(options: NewCompetitionConfigOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
38
|
+
export interface AddScoreArguments {
|
|
39
|
+
version: RawTransactionArgument<string>;
|
|
40
|
+
ecosystemVersion: RawTransactionArgument<string>;
|
|
41
|
+
typusLeaderboardRegistry: RawTransactionArgument<string>;
|
|
42
|
+
tailsStakingRegistry: RawTransactionArgument<string>;
|
|
43
|
+
competitionConfig: RawTransactionArgument<string>;
|
|
44
|
+
volumeUsd: RawTransactionArgument<number | bigint>;
|
|
45
|
+
user: RawTransactionArgument<string>;
|
|
46
|
+
}
|
|
47
|
+
export interface AddScoreOptions {
|
|
48
|
+
package?: string;
|
|
49
|
+
arguments: AddScoreArguments | [
|
|
50
|
+
version: RawTransactionArgument<string>,
|
|
51
|
+
ecosystemVersion: RawTransactionArgument<string>,
|
|
52
|
+
typusLeaderboardRegistry: RawTransactionArgument<string>,
|
|
53
|
+
tailsStakingRegistry: RawTransactionArgument<string>,
|
|
54
|
+
competitionConfig: RawTransactionArgument<string>,
|
|
55
|
+
volumeUsd: RawTransactionArgument<number | bigint>,
|
|
56
|
+
user: RawTransactionArgument<string>
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
/** Adds a score to the competition leaderboard. WARNING: no authority check inside */
|
|
60
|
+
export declare function addScore(options: AddScoreOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
@@ -37,6 +37,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.CompetitionConfig = void 0;
|
|
40
|
+
exports.newCompetitionConfig = newCompetitionConfig;
|
|
41
|
+
exports.addScore = addScore;
|
|
40
42
|
/** The `competition` module defines the logic for trading competitions. */
|
|
41
43
|
const index_1 = require("../utils/index");
|
|
42
44
|
const bcs_1 = require("@mysten/sui/bcs");
|
|
@@ -56,3 +58,47 @@ exports.CompetitionConfig = new index_1.MoveStruct({
|
|
|
56
58
|
u64_padding: bcs_1.bcs.vector(bcs_1.bcs.u64()),
|
|
57
59
|
},
|
|
58
60
|
});
|
|
61
|
+
function newCompetitionConfig(options) {
|
|
62
|
+
const packageAddress = options.package ?? "@typus/perp";
|
|
63
|
+
const argumentsTypes = [
|
|
64
|
+
`${packageAddress}::admin::Version`,
|
|
65
|
+
"vector<u64>",
|
|
66
|
+
"0x0000000000000000000000000000000000000000000000000000000000000001::ascii::String",
|
|
67
|
+
];
|
|
68
|
+
const parameterNames = ["version", "boostBp", "programName"];
|
|
69
|
+
return (tx) => tx.moveCall({
|
|
70
|
+
package: packageAddress,
|
|
71
|
+
module: "competition",
|
|
72
|
+
function: "new_competition_config",
|
|
73
|
+
arguments: (0, index_1.normalizeMoveArguments)(options.arguments, argumentsTypes, parameterNames),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/** Adds a score to the competition leaderboard. WARNING: no authority check inside */
|
|
77
|
+
function addScore(options) {
|
|
78
|
+
const packageAddress = options.package ?? "@typus/perp";
|
|
79
|
+
const argumentsTypes = [
|
|
80
|
+
`${packageAddress}::admin::Version`,
|
|
81
|
+
"0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277::ecosystem::Version",
|
|
82
|
+
"0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277::leaderboard::TypusLeaderboardRegistry",
|
|
83
|
+
"0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277::tails_staking::TailsStakingRegistry",
|
|
84
|
+
`${packageAddress}::competition::CompetitionConfig`,
|
|
85
|
+
"u64",
|
|
86
|
+
"address",
|
|
87
|
+
"0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock",
|
|
88
|
+
];
|
|
89
|
+
const parameterNames = [
|
|
90
|
+
"version",
|
|
91
|
+
"ecosystemVersion",
|
|
92
|
+
"typusLeaderboardRegistry",
|
|
93
|
+
"tailsStakingRegistry",
|
|
94
|
+
"competitionConfig",
|
|
95
|
+
"volumeUsd",
|
|
96
|
+
"user",
|
|
97
|
+
];
|
|
98
|
+
return (tx) => tx.moveCall({
|
|
99
|
+
package: packageAddress,
|
|
100
|
+
module: "competition",
|
|
101
|
+
function: "add_score",
|
|
102
|
+
arguments: (0, index_1.normalizeMoveArguments)(options.arguments, argumentsTypes, parameterNames),
|
|
103
|
+
});
|
|
104
|
+
}
|