@typus/typus-perp-sdk 1.2.2 → 1.3.0
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 -20
- 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 -106
- package/dist/src/generated/typus_perp/position.js +714 -733
- 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 +956 -139
- package/dist/src/generated/typus_perp/trading.js +1577 -1151
- 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 +42 -40
|
@@ -1,30 +1,11 @@
|
|
|
1
|
-
import { BcsType, TypeTag, BcsStruct, BcsEnum, BcsTuple } from
|
|
2
|
-
import { TransactionArgument } from
|
|
3
|
-
import { ClientWithCoreApi, SuiClientTypes } from "@mysten/sui/client";
|
|
1
|
+
import { BcsType, TypeTag, BcsStruct, BcsEnum, BcsTuple } from '@mysten/sui/bcs';
|
|
2
|
+
import { TransactionArgument } from '@mysten/sui/transactions';
|
|
4
3
|
export type RawTransactionArgument<T> = T | TransactionArgument;
|
|
5
|
-
export interface GetOptions<Include extends Omit<SuiClientTypes.ObjectInclude, "content"> = {}> extends SuiClientTypes.GetObjectOptions<Include> {
|
|
6
|
-
client: ClientWithCoreApi;
|
|
7
|
-
}
|
|
8
|
-
export interface GetManyOptions<Include extends Omit<SuiClientTypes.ObjectInclude, "content"> = {}> extends SuiClientTypes.GetObjectsOptions<Include> {
|
|
9
|
-
client: ClientWithCoreApi;
|
|
10
|
-
}
|
|
11
4
|
export declare function getPureBcsSchema(typeTag: string | TypeTag): BcsType<any> | null;
|
|
12
|
-
export declare function normalizeMoveArguments(args: unknown[] | object, argTypes:
|
|
5
|
+
export declare function normalizeMoveArguments(args: unknown[] | object, argTypes: (string | null)[], parameterNames?: string[]): TransactionArgument[];
|
|
13
6
|
export declare class MoveStruct<T extends Record<string, BcsType<any>>, const Name extends string = string> extends BcsStruct<T, Name> {
|
|
14
|
-
get<Include extends Omit<SuiClientTypes.ObjectInclude, "content" | "json"> = {}>({ objectId, ...options }: GetOptions<Include>): Promise<SuiClientTypes.Object<Include & {
|
|
15
|
-
content: true;
|
|
16
|
-
json: true;
|
|
17
|
-
}> & {
|
|
18
|
-
json: BcsStruct<T>["$inferType"];
|
|
19
|
-
}>;
|
|
20
|
-
getMany<Include extends Omit<SuiClientTypes.ObjectInclude, "content" | "json"> = {}>({ client, ...options }: GetManyOptions<Include>): Promise<Array<SuiClientTypes.Object<Include & {
|
|
21
|
-
content: true;
|
|
22
|
-
json: true;
|
|
23
|
-
}> & {
|
|
24
|
-
json: BcsStruct<T>["$inferType"];
|
|
25
|
-
}>>;
|
|
26
7
|
}
|
|
27
8
|
export declare class MoveEnum<T extends Record<string, BcsType<any> | null>, const Name extends string> extends BcsEnum<T, Name> {
|
|
28
9
|
}
|
|
29
|
-
export declare class MoveTuple<
|
|
10
|
+
export declare class MoveTuple<T extends readonly BcsType<any>[], const Name extends string> extends BcsTuple<T, Name> {
|
|
30
11
|
}
|
|
@@ -6,56 +6,61 @@ exports.normalizeMoveArguments = normalizeMoveArguments;
|
|
|
6
6
|
const bcs_1 = require("@mysten/sui/bcs");
|
|
7
7
|
const utils_1 = require("@mysten/sui/utils");
|
|
8
8
|
const transactions_1 = require("@mysten/sui/transactions");
|
|
9
|
-
const MOVE_STDLIB_ADDRESS = (0, utils_1.normalizeSuiAddress)(
|
|
10
|
-
const SUI_FRAMEWORK_ADDRESS = (0, utils_1.normalizeSuiAddress)(
|
|
9
|
+
const MOVE_STDLIB_ADDRESS = (0, utils_1.normalizeSuiAddress)('0x1');
|
|
10
|
+
const SUI_FRAMEWORK_ADDRESS = (0, utils_1.normalizeSuiAddress)('0x2');
|
|
11
|
+
const SUI_SYSTEM_ADDRESS = (0, utils_1.normalizeSuiAddress)('0x3');
|
|
11
12
|
function getPureBcsSchema(typeTag) {
|
|
12
|
-
const parsedTag = typeof typeTag ===
|
|
13
|
-
if (
|
|
13
|
+
const parsedTag = typeof typeTag === 'string' ? bcs_1.TypeTagSerializer.parseFromStr(typeTag) : typeTag;
|
|
14
|
+
if ('u8' in parsedTag) {
|
|
14
15
|
return bcs_1.bcs.U8;
|
|
15
16
|
}
|
|
16
|
-
else if (
|
|
17
|
+
else if ('u16' in parsedTag) {
|
|
17
18
|
return bcs_1.bcs.U16;
|
|
18
19
|
}
|
|
19
|
-
else if (
|
|
20
|
+
else if ('u32' in parsedTag) {
|
|
20
21
|
return bcs_1.bcs.U32;
|
|
21
22
|
}
|
|
22
|
-
else if (
|
|
23
|
+
else if ('u64' in parsedTag) {
|
|
23
24
|
return bcs_1.bcs.U64;
|
|
24
25
|
}
|
|
25
|
-
else if (
|
|
26
|
+
else if ('u128' in parsedTag) {
|
|
26
27
|
return bcs_1.bcs.U128;
|
|
27
28
|
}
|
|
28
|
-
else if (
|
|
29
|
+
else if ('u256' in parsedTag) {
|
|
29
30
|
return bcs_1.bcs.U256;
|
|
30
31
|
}
|
|
31
|
-
else if (
|
|
32
|
+
else if ('address' in parsedTag) {
|
|
32
33
|
return bcs_1.bcs.Address;
|
|
33
34
|
}
|
|
34
|
-
else if (
|
|
35
|
+
else if ('bool' in parsedTag) {
|
|
35
36
|
return bcs_1.bcs.Bool;
|
|
36
37
|
}
|
|
37
|
-
else if (
|
|
38
|
+
else if ('vector' in parsedTag) {
|
|
38
39
|
const type = getPureBcsSchema(parsedTag.vector);
|
|
39
40
|
return type ? bcs_1.bcs.vector(type) : null;
|
|
40
41
|
}
|
|
41
|
-
else if (
|
|
42
|
+
else if ('struct' in parsedTag) {
|
|
42
43
|
const structTag = parsedTag.struct;
|
|
43
|
-
const pkg = (0, utils_1.normalizeSuiAddress)(
|
|
44
|
+
const pkg = (0, utils_1.normalizeSuiAddress)(parsedTag.struct.address);
|
|
44
45
|
if (pkg === MOVE_STDLIB_ADDRESS) {
|
|
45
|
-
if ((structTag.module ===
|
|
46
|
+
if ((structTag.module === 'ascii' || structTag.module === 'string') &&
|
|
47
|
+
structTag.name === 'String') {
|
|
46
48
|
return bcs_1.bcs.String;
|
|
47
49
|
}
|
|
48
|
-
if (structTag.module ===
|
|
50
|
+
if (structTag.module === 'option' && structTag.name === 'Option') {
|
|
49
51
|
const type = getPureBcsSchema(structTag.typeParams[0]);
|
|
50
52
|
return type ? bcs_1.bcs.option(type) : null;
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
|
-
if (pkg === SUI_FRAMEWORK_ADDRESS && structTag.module ===
|
|
55
|
+
if (pkg === SUI_FRAMEWORK_ADDRESS && structTag.module === 'Object' && structTag.name === 'ID') {
|
|
54
56
|
return bcs_1.bcs.Address;
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
return null;
|
|
58
60
|
}
|
|
61
|
+
// argTypes carries `null` for parameters whose type the codegen could not
|
|
62
|
+
// resolve (external packages, e.g. Scallop in lending.ts). Only string equality
|
|
63
|
+
// is ever tested below, so a null just falls through to the default branch.
|
|
59
64
|
function normalizeMoveArguments(args, argTypes, parameterNames) {
|
|
60
65
|
const argLen = Array.isArray(args) ? args.length : Object.keys(args).length;
|
|
61
66
|
if (parameterNames && argLen !== parameterNames.length) {
|
|
@@ -64,19 +69,19 @@ function normalizeMoveArguments(args, argTypes, parameterNames) {
|
|
|
64
69
|
const normalizedArgs = [];
|
|
65
70
|
let index = 0;
|
|
66
71
|
for (const [i, argType] of argTypes.entries()) {
|
|
67
|
-
if (argType ===
|
|
68
|
-
normalizedArgs.push((tx) => tx.object.
|
|
72
|
+
if (argType === `${SUI_FRAMEWORK_ADDRESS}::deny_list::DenyList`) {
|
|
73
|
+
normalizedArgs.push((tx) => tx.object.denyList());
|
|
69
74
|
continue;
|
|
70
75
|
}
|
|
71
|
-
if (argType ===
|
|
76
|
+
if (argType === `${SUI_FRAMEWORK_ADDRESS}::random::Random`) {
|
|
72
77
|
normalizedArgs.push((tx) => tx.object.random());
|
|
73
78
|
continue;
|
|
74
79
|
}
|
|
75
|
-
if (argType ===
|
|
76
|
-
normalizedArgs.push((tx) => tx.object.
|
|
80
|
+
if (argType === `${SUI_FRAMEWORK_ADDRESS}::clock::Clock`) {
|
|
81
|
+
normalizedArgs.push((tx) => tx.object.clock());
|
|
77
82
|
continue;
|
|
78
83
|
}
|
|
79
|
-
if (argType ===
|
|
84
|
+
if (argType === `${SUI_SYSTEM_ADDRESS}::sui_system::SuiSystemState`) {
|
|
80
85
|
normalizedArgs.push((tx) => tx.object.system());
|
|
81
86
|
continue;
|
|
82
87
|
}
|
|
@@ -93,23 +98,23 @@ function normalizeMoveArguments(args, argTypes, parameterNames) {
|
|
|
93
98
|
}
|
|
94
99
|
const name = parameterNames[index];
|
|
95
100
|
arg = args[name];
|
|
96
|
-
if (arg
|
|
101
|
+
if (arg == null) {
|
|
97
102
|
throw new Error(`Parameter ${name} is required`);
|
|
98
103
|
}
|
|
99
104
|
}
|
|
100
105
|
index += 1;
|
|
101
|
-
if (typeof arg ===
|
|
106
|
+
if (typeof arg === 'function' || (0, transactions_1.isArgument)(arg)) {
|
|
102
107
|
normalizedArgs.push(arg);
|
|
103
108
|
continue;
|
|
104
109
|
}
|
|
105
110
|
const type = argTypes[i];
|
|
106
|
-
const bcsType =
|
|
111
|
+
const bcsType = getPureBcsSchema(type);
|
|
107
112
|
if (bcsType) {
|
|
108
113
|
const bytes = bcsType.serialize(arg);
|
|
109
114
|
normalizedArgs.push((tx) => tx.pure(bytes));
|
|
110
115
|
continue;
|
|
111
116
|
}
|
|
112
|
-
else if (typeof arg ===
|
|
117
|
+
else if (typeof arg === 'string') {
|
|
113
118
|
normalizedArgs.push((tx) => tx.object(arg));
|
|
114
119
|
continue;
|
|
115
120
|
}
|
|
@@ -118,31 +123,6 @@ function normalizeMoveArguments(args, argTypes, parameterNames) {
|
|
|
118
123
|
return normalizedArgs;
|
|
119
124
|
}
|
|
120
125
|
class MoveStruct extends bcs_1.BcsStruct {
|
|
121
|
-
async get({ objectId, ...options }) {
|
|
122
|
-
const [res] = await this.getMany({
|
|
123
|
-
...options,
|
|
124
|
-
objectIds: [objectId],
|
|
125
|
-
});
|
|
126
|
-
return res;
|
|
127
|
-
}
|
|
128
|
-
async getMany({ client, ...options }) {
|
|
129
|
-
const response = (await client.core.getObjects({
|
|
130
|
-
...options,
|
|
131
|
-
include: {
|
|
132
|
-
...options.include,
|
|
133
|
-
content: true,
|
|
134
|
-
},
|
|
135
|
-
}));
|
|
136
|
-
return response.objects.map((obj) => {
|
|
137
|
-
if (obj instanceof Error) {
|
|
138
|
-
throw obj;
|
|
139
|
-
}
|
|
140
|
-
return {
|
|
141
|
-
...obj,
|
|
142
|
-
json: this.parse(obj.content),
|
|
143
|
-
};
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
126
|
}
|
|
147
127
|
exports.MoveStruct = MoveStruct;
|
|
148
128
|
class MoveEnum extends bcs_1.BcsEnum {
|
|
@@ -152,10 +132,10 @@ class MoveTuple extends bcs_1.BcsTuple {
|
|
|
152
132
|
}
|
|
153
133
|
exports.MoveTuple = MoveTuple;
|
|
154
134
|
function stringify(val) {
|
|
155
|
-
if (typeof val ===
|
|
135
|
+
if (typeof val === 'object') {
|
|
156
136
|
return JSON.stringify(val, (val) => val);
|
|
157
137
|
}
|
|
158
|
-
if (typeof val ===
|
|
138
|
+
if (typeof val === 'bigint') {
|
|
159
139
|
return val.toString();
|
|
160
140
|
}
|
|
161
141
|
return val;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -13,3 +13,8 @@ export declare const STAKE_POOL_VERSION: string;
|
|
|
13
13
|
export declare const COMPETITION_CONFIG: string;
|
|
14
14
|
export declare const PROFIT_VAULT: string;
|
|
15
15
|
export declare const LOCK_VAULT: string;
|
|
16
|
+
export declare const ORACLE_PACKAGE_ID: string;
|
|
17
|
+
export declare const ORACLE_V2_ID: string;
|
|
18
|
+
export declare const PYTH_LAZER_PACKAGE_ID: string;
|
|
19
|
+
export declare const PYTH_LAZER_STATE_ID: string;
|
|
20
|
+
export declare const DOV_SINGLE_REGISTRY: string;
|
package/dist/src/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.LOCK_VAULT = exports.PROFIT_VAULT = exports.COMPETITION_CONFIG = exports.STAKE_POOL_VERSION = exports.STAKE_POOL = exports.TLP_TREASURY_CAP = exports.PERP_VERSION = exports.MARKET = exports.LIQUIDITY_POOL = exports.LP_POOL = exports.STAKE_PACKAGE_ID = exports.PERP_PACKAGE_ID = exports.NETWORK = void 0;
|
|
20
|
+
exports.DOV_SINGLE_REGISTRY = exports.PYTH_LAZER_STATE_ID = exports.PYTH_LAZER_PACKAGE_ID = exports.ORACLE_V2_ID = exports.ORACLE_PACKAGE_ID = exports.LOCK_VAULT = exports.PROFIT_VAULT = exports.COMPETITION_CONFIG = exports.STAKE_POOL_VERSION = exports.STAKE_POOL = exports.TLP_TREASURY_CAP = exports.PERP_VERSION = exports.MARKET = exports.LIQUIDITY_POOL = exports.LP_POOL = exports.STAKE_PACKAGE_ID = exports.PERP_PACKAGE_ID = exports.NETWORK = void 0;
|
|
21
21
|
__exportStar(require("./fetch"), exports);
|
|
22
22
|
__exportStar(require("./user"), exports);
|
|
23
23
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
@@ -25,30 +25,34 @@ const dotenv_1 = __importDefault(require("dotenv"));
|
|
|
25
25
|
dotenv_1.default.config();
|
|
26
26
|
// default MAINNET
|
|
27
27
|
exports.NETWORK = process.env.NEXT_PUBLIC_CLUSTER == "testnet" ? "TESTNET" : "MAINNET";
|
|
28
|
+
// Mainnet is the CVersion-7 package: the only one carrying `create_trading_order_v2`
|
|
29
|
+
// / `match_trading_order_v2` (the OracleV2 readers). Verified on-chain — the
|
|
30
|
+
// previously pinned 0xf60e3542 exposes no `_v2` order entries at all, and
|
|
31
|
+
// typus-config@main still advertises the older 0x8e4743f2.
|
|
28
32
|
exports.PERP_PACKAGE_ID = exports.NETWORK == "MAINNET"
|
|
29
|
-
? "
|
|
30
|
-
: "
|
|
33
|
+
? "0xb78db3bf6aff87ae8aa6b1b5d4718d475d46b74734727889f2b4c300d79e8970"
|
|
34
|
+
: "0x228f1823a2daf15cf2d5031e47bd7c26ae1d19ea89160df29d351c6e56134c61";
|
|
31
35
|
exports.STAKE_PACKAGE_ID = exports.NETWORK == "MAINNET"
|
|
32
36
|
? "0xd280f3a072bca4b7b5b450f40c82a30b3935cd1d12d927eb9d1f790520a83d3b"
|
|
33
|
-
: "
|
|
37
|
+
: "0x11ca35c03a2f3ba157a8f605613bcb70eb22da5fcb9dbb00966db745ed6427e6";
|
|
34
38
|
// lp_pool::Registry
|
|
35
39
|
exports.LP_POOL = exports.NETWORK == "MAINNET"
|
|
36
40
|
? "0x46ef530d3ad13037ac54b77be324e5ab063124af8a119e86f1f59be8a16a22a2"
|
|
37
|
-
: "
|
|
38
|
-
// liquidity_pool_registry
|
|
41
|
+
: "0x7870f1a8f1a4750f2b8b2c9e62b2770eb717aec185b85156d8a3ac503920de57";
|
|
42
|
+
// inner liquidity_pool_registry (Registry.liquidity_pool_registry, parent of pool dynamic fields)
|
|
39
43
|
exports.LIQUIDITY_POOL = exports.NETWORK == "MAINNET"
|
|
40
44
|
? "0x9090a55fea75d0b135dfa53e6bbe234c0b0e9d0e0b21c615f32f0048bc35aca4"
|
|
41
|
-
: "
|
|
45
|
+
: "0x4ef2f9562737beaba55fe03fd0d9da21af0d2277e0e802d3660afbc7ca4c073f";
|
|
42
46
|
// MarketRegistry
|
|
43
47
|
exports.MARKET = exports.NETWORK == "MAINNET"
|
|
44
48
|
? "0x327c8a176055400e9aacde8553a897898b5da969d6dcdb55eee268bb501a2c3a"
|
|
45
|
-
: "
|
|
49
|
+
: "0x56e899ecc6a8b801b027a096a59aeef65be9a57a8c5380f0b93631c42e346706";
|
|
46
50
|
exports.PERP_VERSION = exports.NETWORK == "MAINNET"
|
|
47
51
|
? "0x7c30204bd3f4dc37918281907308e0d7d09a75a6826473aec0caa1712ee149e5"
|
|
48
|
-
: "
|
|
52
|
+
: "0xe456c2b305e64a7add716dec6fa0c2ea459cf5148313c01fb98468707dae06b3";
|
|
49
53
|
exports.TLP_TREASURY_CAP = exports.NETWORK == "MAINNET"
|
|
50
54
|
? "0x99071a9fb7e40546d3279dffac2ff15a278ab90229c3fe06610e1540dcafa7af"
|
|
51
|
-
: "
|
|
55
|
+
: "0x63afeecd08a372b623d2b0170303dcad285f3485833fac6218ea770cd032e762";
|
|
52
56
|
// StakePoolRegistry
|
|
53
57
|
exports.STAKE_POOL = exports.NETWORK == "MAINNET"
|
|
54
58
|
? "0xdbd23ed1bfe214a61bce1ba711b86e62048913f2069e845c9ff69119628f41a3"
|
|
@@ -58,10 +62,28 @@ exports.STAKE_POOL_VERSION = exports.NETWORK == "MAINNET"
|
|
|
58
62
|
: "0x02b94b340a8810f6c451bc244dc2dd8d9d50cf86d727798969ca2c287c3186aa";
|
|
59
63
|
exports.COMPETITION_CONFIG = exports.NETWORK == "MAINNET"
|
|
60
64
|
? "0xe896530a778adedc1b38e4fc31059a6557146caa7b1da56950b671a433de5f08"
|
|
61
|
-
: "
|
|
65
|
+
: "0x05c3fd5ed8d9b8ca62b370e375dd555c174cfe6c573ba06ec22eb22f31c79ba3";
|
|
62
66
|
exports.PROFIT_VAULT = exports.NETWORK == "MAINNET"
|
|
63
67
|
? "0xd24222307ba17ee1a08fe46ac587b1106e585e53f314ffffb525a4d4158b64c3"
|
|
64
|
-
: "
|
|
68
|
+
: "0xdf6973935e107c091d8bb5aaef2d2bdf4987e496a880ae7e664d6ceb062f43a7";
|
|
65
69
|
exports.LOCK_VAULT = exports.NETWORK == "MAINNET"
|
|
66
70
|
? "0x585355900351dd1915b77f31c06ae9e6d58b187de848d4e6e6a55d3789e281d6"
|
|
67
|
-
: "
|
|
71
|
+
: "0x8d3c497b2b0e7b8a7633422e8da780ba83ea6709d81ba7b0ca6935d58692cc96";
|
|
72
|
+
// Pyth Lazer + OracleV2. Mainnet values mirror typus-rust
|
|
73
|
+
// src/config/mainnet/pyth.json (oracle v16 / Lazer state), which the crankers
|
|
74
|
+
// already run against — the OracleV2 object below holds 24 registered tokens.
|
|
75
|
+
exports.ORACLE_PACKAGE_ID = exports.NETWORK == "MAINNET"
|
|
76
|
+
? "0xb52c1b617cf5c9a6f911907be7d4b7bc12c618050b6421ee9801a4011617dcbe"
|
|
77
|
+
: "0xd2e030ab7f0fc956c7e683cf3c6faf3d22868dee81a4aae9f4a10a6d998a8a02";
|
|
78
|
+
exports.ORACLE_V2_ID = exports.NETWORK == "MAINNET"
|
|
79
|
+
? "0xcd03806a638885c18d9866b9704cb53487c51df8642e95059a6984673b9fa211"
|
|
80
|
+
: "0x6378d4a139475984613344077a862972756e2bd0cb2aab7018e7f48eeee0742d";
|
|
81
|
+
exports.PYTH_LAZER_PACKAGE_ID = exports.NETWORK == "MAINNET"
|
|
82
|
+
? "0xefbfd064480777699fd9c557a5804d72ace7bc82661fdc8d1f1a44ea6d92ee10"
|
|
83
|
+
: "0xacb76cbd636b83839153feff75b83157c400075717ce8c979fbbe88cf3564901";
|
|
84
|
+
exports.PYTH_LAZER_STATE_ID = exports.NETWORK == "MAINNET"
|
|
85
|
+
? "0xd0db9c1e9212a98120384bf78d8b8c985d87b9ee6921dffcf9d1394062911573"
|
|
86
|
+
: "0x7b570126bfdcc7f7b2b4028445d4ac1d35c41da498606a2b097c3973425698d3";
|
|
87
|
+
// DOV single-collateral Registry that the new typus_perp pkg links against
|
|
88
|
+
// (origin 0x02821e55). typus-config@main still advertises the old 0x6c9a394a DOV.
|
|
89
|
+
exports.DOV_SINGLE_REGISTRY = exports.NETWORK == "MAINNET" ? "" : "0x43db5b91c8af6cf7a2a3b624e97aa35eef40adff4a22e2b59571b9eb89ded084";
|
package/dist/src/user/order.d.ts
CHANGED
|
@@ -20,7 +20,6 @@ export declare function createTradingOrder(client: TypusClient, tx: Transaction,
|
|
|
20
20
|
isStopOrder: boolean;
|
|
21
21
|
reduceOnly: boolean;
|
|
22
22
|
linkedPositionId: string | null;
|
|
23
|
-
suiCoins?: string[];
|
|
24
23
|
}): Promise<Transaction>;
|
|
25
24
|
export declare function zeroCoin(tx: Transaction, typeArgs: [string]): import("@mysten/sui/transactions", { with: { "resolution-mode": "import" } }).TransactionResult;
|
|
26
25
|
export declare function cancelTradingOrder(client: TypusClient, tx: Transaction, input: {
|
|
@@ -32,16 +31,13 @@ export declare function increaseCollateral(client: TypusClient, tx: Transaction,
|
|
|
32
31
|
coins: string[];
|
|
33
32
|
amount: string;
|
|
34
33
|
position: typeof Position.$inferType;
|
|
35
|
-
suiCoins?: string[];
|
|
36
34
|
}): Promise<Transaction>;
|
|
37
35
|
export declare function releaseCollateral(client: TypusClient, tx: Transaction, input: {
|
|
38
36
|
oracleContract?: string;
|
|
39
37
|
position: typeof Position.$inferType;
|
|
40
38
|
amount: string;
|
|
41
|
-
suiCoins?: string[];
|
|
42
39
|
}): Promise<Transaction>;
|
|
43
40
|
export declare function collectPositionFundingFee(client: TypusClient, tx: Transaction, input: {
|
|
44
41
|
oracleContract?: string;
|
|
45
42
|
position: typeof Position.$inferType;
|
|
46
|
-
suiCoins?: string[];
|
|
47
43
|
}): Promise<Transaction>;
|
package/dist/src/user/order.js
CHANGED
|
@@ -10,14 +10,13 @@ exports.collectPositionFundingFee = collectPositionFundingFee;
|
|
|
10
10
|
const trading_1 = require("../../src/generated/typus_perp/trading");
|
|
11
11
|
const __1 = require("..");
|
|
12
12
|
const utils_1 = require("@typus/typus-sdk/dist/src/utils");
|
|
13
|
-
const utils_2 = require("@typus/typus-sdk/dist/src/utils");
|
|
14
13
|
const constants_1 = require("@typus/typus-sdk/dist/src/constants");
|
|
15
|
-
const
|
|
14
|
+
const utils_2 = require("@mysten/sui/utils");
|
|
16
15
|
function findMarketIndex(client, input) {
|
|
17
16
|
let target = constants_1.tokenType[client.config.network][input.tradingToken];
|
|
18
17
|
for (let i = 0; i < input.markets.length; i++) {
|
|
19
18
|
for (let symbol of input.markets[i].symbols) {
|
|
20
|
-
if ((0,
|
|
19
|
+
if ((0, utils_2.normalizeStructTag)(symbol.name) == target) {
|
|
21
20
|
return i;
|
|
22
21
|
}
|
|
23
22
|
}
|
|
@@ -30,44 +29,29 @@ async function createTradingOrder(client, tx, input) {
|
|
|
30
29
|
let tokens = Array.from(new Set([TOKEN, BASE_TOKEN]));
|
|
31
30
|
let cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
|
|
32
31
|
let baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
|
|
33
|
-
let coin;
|
|
34
|
-
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
[coin, suiCoin] = (0, utils_2.splitCoins)(tx, constants_1.tokenType.MAINNET.SUI, input.coins, [input.amount, tokens.length.toString()], client.config.sponsored);
|
|
38
|
-
}
|
|
39
|
-
else if (client.config.sponsored) {
|
|
40
|
-
coin = (0, utils_2.splitCoin)(tx, cToken, input.coins, input.amount, client.config.sponsored);
|
|
41
|
-
suiCoin = (0, utils_2.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), client.config.sponsored);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
coin = (0, utils_2.splitCoin)(tx, cToken, input.coins, input.amount, client.config.sponsored);
|
|
45
|
-
// no suiCoin
|
|
46
|
-
}
|
|
47
|
-
const tokensWithoutTypus = Array.from(new Set([TOKEN, BASE_TOKEN])).filter((token) => token !== "TYPUS");
|
|
48
|
-
await (0, utils_2.updatePyth)(client.pythClient, tx, tokensWithoutTypus, suiCoin);
|
|
49
|
-
for (let token of tokensWithoutTypus) {
|
|
50
|
-
(0, utils_2.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
|
|
32
|
+
let coin = (0, utils_1.splitCoin)(tx, cToken, input.coins, input.amount, client.config.sponsored);
|
|
33
|
+
const tokensWithoutTypus = tokens.filter((token) => token !== "TYPUS");
|
|
34
|
+
if (tokensWithoutTypus.length > 0) {
|
|
35
|
+
await client.pythClient.updateOracleV2WithPythLazer(tx, tokensWithoutTypus);
|
|
51
36
|
}
|
|
52
37
|
if (tokens.includes("TYPUS")) {
|
|
53
38
|
tx = await (0, utils_1.updateOracleWithSignatureTx)(__1.NETWORK, tx, client.config.package.oracle, constants_1.tokenType[__1.NETWORK]["TYPUS"]);
|
|
54
39
|
}
|
|
55
|
-
tx.add((0, trading_1.
|
|
40
|
+
tx.add((0, trading_1.createTradingOrderV2)({
|
|
56
41
|
arguments: {
|
|
57
42
|
version: __1.PERP_VERSION,
|
|
58
43
|
registry: __1.MARKET,
|
|
59
44
|
poolRegistry: __1.LP_POOL,
|
|
45
|
+
oracleV2: __1.ORACLE_V2_ID,
|
|
60
46
|
marketIndex: BigInt(input.perpIndex),
|
|
61
47
|
poolIndex: BigInt(input.poolIndex),
|
|
62
|
-
|
|
63
|
-
typusOracleTradingSymbol: constants_1.oracle[__1.NETWORK][BASE_TOKEN],
|
|
48
|
+
linkedPositionId: tx.pure.option("u64", input.linkedPositionId ? BigInt(input.linkedPositionId) : null),
|
|
64
49
|
collateral: coin,
|
|
65
|
-
|
|
66
|
-
triggerPrice: BigInt(input.triggerPrice),
|
|
50
|
+
reduceOnly: input.reduceOnly,
|
|
67
51
|
isLong: input.isLong,
|
|
68
52
|
isStopOrder: input.isStopOrder,
|
|
69
|
-
|
|
70
|
-
|
|
53
|
+
size: BigInt(input.size),
|
|
54
|
+
triggerPrice: BigInt(input.triggerPrice),
|
|
71
55
|
},
|
|
72
56
|
typeArguments: [cToken, baseToken],
|
|
73
57
|
}));
|
|
@@ -81,8 +65,8 @@ function zeroCoin(tx, typeArgs) {
|
|
|
81
65
|
});
|
|
82
66
|
}
|
|
83
67
|
async function cancelTradingOrder(client, tx, input) {
|
|
84
|
-
let cToken = (0,
|
|
85
|
-
let BASE_TOKEN = (0,
|
|
68
|
+
let cToken = (0, utils_2.normalizeStructTag)(input.order.collateral_token.name);
|
|
69
|
+
let BASE_TOKEN = (0, utils_2.normalizeStructTag)(input.order.symbol.base_token.name);
|
|
86
70
|
let coin = tx.add((0, trading_1.cancelTradingOrder)({
|
|
87
71
|
arguments: {
|
|
88
72
|
version: __1.PERP_VERSION,
|
|
@@ -91,7 +75,7 @@ async function cancelTradingOrder(client, tx, input) {
|
|
|
91
75
|
marketIndex: BigInt(input.order.marketIndex),
|
|
92
76
|
orderId: BigInt(input.order.order_id),
|
|
93
77
|
triggerPrice: BigInt(input.order.trigger_price),
|
|
94
|
-
orderUser: null,
|
|
78
|
+
orderUser: tx.pure.option("address", null),
|
|
95
79
|
},
|
|
96
80
|
typeArguments: [cToken, BASE_TOKEN],
|
|
97
81
|
}));
|
|
@@ -105,24 +89,10 @@ async function increaseCollateral(client, tx, input) {
|
|
|
105
89
|
let tokens = Array.from(new Set([TOKEN, BASE_TOKEN]));
|
|
106
90
|
let cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
|
|
107
91
|
let baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
|
|
108
|
-
let coin;
|
|
109
|
-
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
[coin, suiCoin] = (0, utils_2.splitCoins)(tx, constants_1.tokenType.MAINNET.SUI, input.coins, [input.amount, tokens.length.toString()], client.config.sponsored);
|
|
113
|
-
}
|
|
114
|
-
else if (client.config.sponsored) {
|
|
115
|
-
coin = (0, utils_2.splitCoin)(tx, cToken, input.coins, input.amount, client.config.sponsored);
|
|
116
|
-
suiCoin = (0, utils_2.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), client.config.sponsored);
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
coin = (0, utils_2.splitCoin)(tx, cToken, input.coins, input.amount, client.config.sponsored);
|
|
120
|
-
// no suiCoin
|
|
121
|
-
}
|
|
122
|
-
const tokensWithoutTypus = Array.from(new Set([TOKEN, BASE_TOKEN])).filter((token) => token !== "TYPUS");
|
|
123
|
-
await (0, utils_2.updatePyth)(client.pythClient, tx, tokensWithoutTypus, suiCoin);
|
|
124
|
-
for (let token of tokensWithoutTypus) {
|
|
125
|
-
(0, utils_2.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
|
|
92
|
+
let coin = (0, utils_1.splitCoin)(tx, cToken, input.coins, input.amount, client.config.sponsored);
|
|
93
|
+
const tokensWithoutTypus = tokens.filter((token) => token !== "TYPUS");
|
|
94
|
+
if (tokensWithoutTypus.length > 0) {
|
|
95
|
+
await client.pythClient.updateOracleV2WithPythLazer(tx, tokensWithoutTypus);
|
|
126
96
|
}
|
|
127
97
|
if (tokens.includes("TYPUS")) {
|
|
128
98
|
const oracleContract = input.oracleContract ?? client.config.package.oracle;
|
|
@@ -130,15 +100,14 @@ async function increaseCollateral(client, tx, input) {
|
|
|
130
100
|
}
|
|
131
101
|
// @ts-ignore
|
|
132
102
|
let marketIndex = BigInt(input.position.marketIndex);
|
|
133
|
-
tx.add((0, trading_1.
|
|
103
|
+
tx.add((0, trading_1.increaseCollateralV2)({
|
|
134
104
|
arguments: {
|
|
135
105
|
version: __1.PERP_VERSION,
|
|
136
106
|
registry: __1.MARKET,
|
|
137
107
|
poolRegistry: __1.LP_POOL,
|
|
108
|
+
oracleV2: __1.ORACLE_V2_ID,
|
|
138
109
|
marketIndex: marketIndex,
|
|
139
110
|
poolIndex: marketIndex,
|
|
140
|
-
typusOracleCToken: constants_1.oracle[__1.NETWORK][TOKEN],
|
|
141
|
-
typusOracleTradingSymbol: constants_1.oracle[__1.NETWORK][BASE_TOKEN],
|
|
142
111
|
positionId: BigInt(input.position.position_id),
|
|
143
112
|
collateral: coin,
|
|
144
113
|
},
|
|
@@ -151,14 +120,9 @@ async function releaseCollateral(client, tx, input) {
|
|
|
151
120
|
let TOKEN = (0, constants_1.typeArgToAsset)(input.position.collateral_token.name);
|
|
152
121
|
let BASE_TOKEN = (0, constants_1.typeArgToAsset)(input.position.symbol.base_token.name);
|
|
153
122
|
let tokens = Array.from(new Set([TOKEN, BASE_TOKEN]));
|
|
154
|
-
|
|
155
|
-
if (
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
const tokensWithoutTypus = Array.from(new Set([TOKEN, BASE_TOKEN])).filter((token) => token !== "TYPUS");
|
|
159
|
-
await (0, utils_2.updatePyth)(client.pythClient, tx, tokensWithoutTypus, suiCoin);
|
|
160
|
-
for (let token of tokensWithoutTypus) {
|
|
161
|
-
(0, utils_2.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
|
|
123
|
+
const tokensWithoutTypus = tokens.filter((token) => token !== "TYPUS");
|
|
124
|
+
if (tokensWithoutTypus.length > 0) {
|
|
125
|
+
await client.pythClient.updateOracleV2WithPythLazer(tx, tokensWithoutTypus);
|
|
162
126
|
}
|
|
163
127
|
if (tokens.includes("TYPUS")) {
|
|
164
128
|
const oracleContract = input.oracleContract ?? client.config.package.oracle;
|
|
@@ -168,15 +132,14 @@ async function releaseCollateral(client, tx, input) {
|
|
|
168
132
|
let baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
|
|
169
133
|
// @ts-ignore
|
|
170
134
|
let marketIndex = BigInt(input.position.marketIndex);
|
|
171
|
-
let coin = tx.add((0, trading_1.
|
|
135
|
+
let coin = tx.add((0, trading_1.releaseCollateralV2)({
|
|
172
136
|
arguments: {
|
|
173
137
|
version: __1.PERP_VERSION,
|
|
174
138
|
registry: __1.MARKET,
|
|
175
139
|
poolRegistry: __1.LP_POOL,
|
|
140
|
+
oracleV2: __1.ORACLE_V2_ID,
|
|
176
141
|
marketIndex: marketIndex,
|
|
177
142
|
poolIndex: marketIndex,
|
|
178
|
-
typusOracleCToken: constants_1.oracle[__1.NETWORK][TOKEN],
|
|
179
|
-
typusOracleTradingSymbol: constants_1.oracle[__1.NETWORK][BASE_TOKEN],
|
|
180
143
|
positionId: BigInt(input.position.position_id),
|
|
181
144
|
releaseAmount: BigInt(input.amount),
|
|
182
145
|
},
|
|
@@ -190,14 +153,9 @@ async function collectPositionFundingFee(client, tx, input) {
|
|
|
190
153
|
let TOKEN = (0, constants_1.typeArgToAsset)(input.position.collateral_token.name);
|
|
191
154
|
let BASE_TOKEN = (0, constants_1.typeArgToAsset)(input.position.symbol.base_token.name);
|
|
192
155
|
let tokens = Array.from(new Set([TOKEN, BASE_TOKEN]));
|
|
193
|
-
|
|
194
|
-
if (
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
const tokensWithoutTypus = Array.from(new Set([TOKEN, BASE_TOKEN])).filter((token) => token !== "TYPUS");
|
|
198
|
-
await (0, utils_2.updatePyth)(client.pythClient, tx, tokensWithoutTypus, suiCoin);
|
|
199
|
-
for (let token of tokensWithoutTypus) {
|
|
200
|
-
(0, utils_2.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
|
|
156
|
+
const tokensWithoutTypus = tokens.filter((token) => token !== "TYPUS");
|
|
157
|
+
if (tokensWithoutTypus.length > 0) {
|
|
158
|
+
await client.pythClient.updateOracleV2WithPythLazer(tx, tokensWithoutTypus);
|
|
201
159
|
}
|
|
202
160
|
if (tokens.includes("TYPUS")) {
|
|
203
161
|
const oracleContract = input.oracleContract ?? client.config.package.oracle;
|
|
@@ -207,15 +165,14 @@ async function collectPositionFundingFee(client, tx, input) {
|
|
|
207
165
|
let baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
|
|
208
166
|
// @ts-ignore
|
|
209
167
|
let marketIndex = BigInt(input.position.marketIndex);
|
|
210
|
-
tx.add((0, trading_1.
|
|
168
|
+
tx.add((0, trading_1.collectPositionFundingFeeV2)({
|
|
211
169
|
arguments: {
|
|
212
170
|
version: __1.PERP_VERSION,
|
|
213
171
|
registry: __1.MARKET,
|
|
214
172
|
poolRegistry: __1.LP_POOL,
|
|
173
|
+
oracleV2: __1.ORACLE_V2_ID,
|
|
215
174
|
marketIndex: marketIndex,
|
|
216
175
|
poolIndex: marketIndex,
|
|
217
|
-
typusOracleCToken: constants_1.oracle[__1.NETWORK][TOKEN],
|
|
218
|
-
typusOracleTradingSymbol: constants_1.oracle[__1.NETWORK][BASE_TOKEN],
|
|
219
176
|
positionId: BigInt(input.position.position_id),
|
|
220
177
|
},
|
|
221
178
|
typeArguments: [cToken, baseToken],
|
|
@@ -19,7 +19,6 @@ export declare function createTradingOrderWithBidReceiptByAutoBid(client: TypusC
|
|
|
19
19
|
signalIndex: string;
|
|
20
20
|
strategyIndex: string;
|
|
21
21
|
share?: string;
|
|
22
|
-
suiCoins?: string[];
|
|
23
22
|
}): Promise<Transaction>;
|
|
24
23
|
export declare function createTradingOrderWithBidReceipt(client: TypusClient, tx: Transaction, input: {
|
|
25
24
|
perpIndex: string;
|
|
@@ -32,7 +31,6 @@ export declare function createTradingOrderWithBidReceipt(client: TypusClient, tx
|
|
|
32
31
|
bToken: TOKEN;
|
|
33
32
|
bidReceipts: string[];
|
|
34
33
|
share?: string;
|
|
35
|
-
suiCoins?: string[];
|
|
36
34
|
}): Promise<Transaction>;
|
|
37
35
|
export declare function reduceOptionCollateralPositionSize(client: TypusClient, tx: Transaction, input: {
|
|
38
36
|
perpIndex: string;
|
|
@@ -41,5 +39,4 @@ export declare function reduceOptionCollateralPositionSize(client: TypusClient,
|
|
|
41
39
|
bToken: string;
|
|
42
40
|
positionId: string;
|
|
43
41
|
orderSize: string | null;
|
|
44
|
-
suiCoins?: string[];
|
|
45
42
|
}): Promise<Transaction>;
|