@typus/typus-perp-sdk 1.2.1 → 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
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* The `math` module provides mathematical utility functions for the Typus
|
|
6
6
|
* Perpetual Protocol.
|
|
7
7
|
*/
|
|
8
|
-
import { type Transaction } from
|
|
9
|
-
import { type RawTransactionArgument } from
|
|
8
|
+
import { type Transaction } from '@mysten/sui/transactions';
|
|
9
|
+
import { type RawTransactionArgument } from '../utils/index';
|
|
10
10
|
export interface SetU64VectorValueArguments {
|
|
11
11
|
u64Vector: RawTransactionArgument<number | bigint[]>;
|
|
12
12
|
i: RawTransactionArgument<number | bigint>;
|
|
@@ -31,7 +31,10 @@ export interface GetU64VectorValueArguments {
|
|
|
31
31
|
}
|
|
32
32
|
export interface GetU64VectorValueOptions {
|
|
33
33
|
package?: string;
|
|
34
|
-
arguments: GetU64VectorValueArguments | [
|
|
34
|
+
arguments: GetU64VectorValueArguments | [
|
|
35
|
+
u64Vector: RawTransactionArgument<number | bigint[]>,
|
|
36
|
+
i: RawTransactionArgument<number | bigint>
|
|
37
|
+
];
|
|
35
38
|
}
|
|
36
39
|
/**
|
|
37
40
|
* Gets a value from a `vector<u64>` at a specific index. It will return 0 if the
|
|
@@ -43,7 +46,9 @@ export interface MultiplierArguments {
|
|
|
43
46
|
}
|
|
44
47
|
export interface MultiplierOptions {
|
|
45
48
|
package?: string;
|
|
46
|
-
arguments: MultiplierArguments | [
|
|
49
|
+
arguments: MultiplierArguments | [
|
|
50
|
+
decimal: RawTransactionArgument<number | bigint>
|
|
51
|
+
];
|
|
47
52
|
}
|
|
48
53
|
/** Calculates a multiplier for a given number of decimals. */
|
|
49
54
|
export declare function multiplier(options: MultiplierOptions): (tx: Transaction) => import("@mysten/sui/transactions", { with: { "resolution-mode": "import" } }).TransactionResult;
|
|
@@ -83,23 +88,15 @@ export interface UsdToAmountOptions {
|
|
|
83
88
|
export declare function usdToAmount(options: UsdToAmountOptions): (tx: Transaction) => import("@mysten/sui/transactions", { with: { "resolution-mode": "import" } }).TransactionResult;
|
|
84
89
|
export interface GetUsdDecimalOptions {
|
|
85
90
|
package?: string;
|
|
86
|
-
arguments?: [
|
|
91
|
+
arguments?: [
|
|
92
|
+
];
|
|
87
93
|
}
|
|
88
94
|
/** Returns the number of decimals for USD. */
|
|
89
95
|
export declare function getUsdDecimal(options?: GetUsdDecimalOptions): (tx: Transaction) => import("@mysten/sui/transactions", { with: { "resolution-mode": "import" } }).TransactionResult;
|
|
90
96
|
export interface GetFundingRateDecimalOptions {
|
|
91
97
|
package?: string;
|
|
92
|
-
arguments?: [
|
|
98
|
+
arguments?: [
|
|
99
|
+
];
|
|
93
100
|
}
|
|
94
101
|
/** Returns the number of decimals for the funding rate. */
|
|
95
102
|
export declare function getFundingRateDecimal(options?: GetFundingRateDecimalOptions): (tx: Transaction) => import("@mysten/sui/transactions", { with: { "resolution-mode": "import" } }).TransactionResult;
|
|
96
|
-
export interface GetMbpScaleOptions {
|
|
97
|
-
package?: string;
|
|
98
|
-
arguments?: [];
|
|
99
|
-
}
|
|
100
|
-
export declare function getMbpScale(options?: GetMbpScaleOptions): (tx: Transaction) => import("@mysten/sui/transactions", { with: { "resolution-mode": "import" } }).TransactionResult;
|
|
101
|
-
export interface GetBpScaleOptions {
|
|
102
|
-
package?: string;
|
|
103
|
-
arguments?: [];
|
|
104
|
-
}
|
|
105
|
-
export declare function getBpScale(options?: GetBpScaleOptions): (tx: Transaction) => import("@mysten/sui/transactions", { with: { "resolution-mode": "import" } }).TransactionResult;
|
|
@@ -10,22 +10,24 @@ exports.amountToUsd = amountToUsd;
|
|
|
10
10
|
exports.usdToAmount = usdToAmount;
|
|
11
11
|
exports.getUsdDecimal = getUsdDecimal;
|
|
12
12
|
exports.getFundingRateDecimal = getFundingRateDecimal;
|
|
13
|
-
|
|
14
|
-
exports.getBpScale = getBpScale;
|
|
15
|
-
const index_js_1 = require("../utils/index.js");
|
|
13
|
+
const index_1 = require("../utils/index");
|
|
16
14
|
/**
|
|
17
15
|
* Sets a value in a `vector<u64>` at a specific index. It will extend the vector
|
|
18
16
|
* with zeros if the index is out of bounds.
|
|
19
17
|
*/
|
|
20
18
|
function setU64VectorValue(options) {
|
|
21
|
-
const packageAddress = options.package ??
|
|
22
|
-
const argumentsTypes = [
|
|
19
|
+
const packageAddress = options.package ?? '@typus/perp';
|
|
20
|
+
const argumentsTypes = [
|
|
21
|
+
'vector<u64>',
|
|
22
|
+
'u64',
|
|
23
|
+
'u64'
|
|
24
|
+
];
|
|
23
25
|
const parameterNames = ["u64Vector", "i", "value"];
|
|
24
26
|
return (tx) => tx.moveCall({
|
|
25
27
|
package: packageAddress,
|
|
26
|
-
module:
|
|
27
|
-
function:
|
|
28
|
-
arguments: (0,
|
|
28
|
+
module: 'math',
|
|
29
|
+
function: 'set_u64_vector_value',
|
|
30
|
+
arguments: (0, index_1.normalizeMoveArguments)(options.arguments, argumentsTypes, parameterNames),
|
|
29
31
|
});
|
|
30
32
|
}
|
|
31
33
|
/**
|
|
@@ -33,83 +35,82 @@ function setU64VectorValue(options) {
|
|
|
33
35
|
* index is out of bounds.
|
|
34
36
|
*/
|
|
35
37
|
function getU64VectorValue(options) {
|
|
36
|
-
const packageAddress = options.package ??
|
|
37
|
-
const argumentsTypes = [
|
|
38
|
+
const packageAddress = options.package ?? '@typus/perp';
|
|
39
|
+
const argumentsTypes = [
|
|
40
|
+
'vector<u64>',
|
|
41
|
+
'u64'
|
|
42
|
+
];
|
|
38
43
|
const parameterNames = ["u64Vector", "i"];
|
|
39
44
|
return (tx) => tx.moveCall({
|
|
40
45
|
package: packageAddress,
|
|
41
|
-
module:
|
|
42
|
-
function:
|
|
43
|
-
arguments: (0,
|
|
46
|
+
module: 'math',
|
|
47
|
+
function: 'get_u64_vector_value',
|
|
48
|
+
arguments: (0, index_1.normalizeMoveArguments)(options.arguments, argumentsTypes, parameterNames),
|
|
44
49
|
});
|
|
45
50
|
}
|
|
46
51
|
/** Calculates a multiplier for a given number of decimals. */
|
|
47
52
|
function multiplier(options) {
|
|
48
|
-
const packageAddress = options.package ??
|
|
49
|
-
const argumentsTypes = [
|
|
53
|
+
const packageAddress = options.package ?? '@typus/perp';
|
|
54
|
+
const argumentsTypes = [
|
|
55
|
+
'u64'
|
|
56
|
+
];
|
|
50
57
|
const parameterNames = ["decimal"];
|
|
51
58
|
return (tx) => tx.moveCall({
|
|
52
59
|
package: packageAddress,
|
|
53
|
-
module:
|
|
54
|
-
function:
|
|
55
|
-
arguments: (0,
|
|
60
|
+
module: 'math',
|
|
61
|
+
function: 'multiplier',
|
|
62
|
+
arguments: (0, index_1.normalizeMoveArguments)(options.arguments, argumentsTypes, parameterNames),
|
|
56
63
|
});
|
|
57
64
|
}
|
|
58
65
|
/** Converts an amount of a token to USD. */
|
|
59
66
|
function amountToUsd(options) {
|
|
60
|
-
const packageAddress = options.package ??
|
|
61
|
-
const argumentsTypes = [
|
|
67
|
+
const packageAddress = options.package ?? '@typus/perp';
|
|
68
|
+
const argumentsTypes = [
|
|
69
|
+
'u64',
|
|
70
|
+
'u64',
|
|
71
|
+
'u64',
|
|
72
|
+
'u64'
|
|
73
|
+
];
|
|
62
74
|
const parameterNames = ["amount", "amountDecimal", "price", "priceDecimal"];
|
|
63
75
|
return (tx) => tx.moveCall({
|
|
64
76
|
package: packageAddress,
|
|
65
|
-
module:
|
|
66
|
-
function:
|
|
67
|
-
arguments: (0,
|
|
77
|
+
module: 'math',
|
|
78
|
+
function: 'amount_to_usd',
|
|
79
|
+
arguments: (0, index_1.normalizeMoveArguments)(options.arguments, argumentsTypes, parameterNames),
|
|
68
80
|
});
|
|
69
81
|
}
|
|
70
82
|
/** Converts an amount of USD to a token. */
|
|
71
83
|
function usdToAmount(options) {
|
|
72
|
-
const packageAddress = options.package ??
|
|
73
|
-
const argumentsTypes = [
|
|
84
|
+
const packageAddress = options.package ?? '@typus/perp';
|
|
85
|
+
const argumentsTypes = [
|
|
86
|
+
'u64',
|
|
87
|
+
'u64',
|
|
88
|
+
'u64',
|
|
89
|
+
'u64'
|
|
90
|
+
];
|
|
74
91
|
const parameterNames = ["usd", "amountDecimal", "price", "priceDecimal"];
|
|
75
92
|
return (tx) => tx.moveCall({
|
|
76
93
|
package: packageAddress,
|
|
77
|
-
module:
|
|
78
|
-
function:
|
|
79
|
-
arguments: (0,
|
|
94
|
+
module: 'math',
|
|
95
|
+
function: 'usd_to_amount',
|
|
96
|
+
arguments: (0, index_1.normalizeMoveArguments)(options.arguments, argumentsTypes, parameterNames),
|
|
80
97
|
});
|
|
81
98
|
}
|
|
82
99
|
/** Returns the number of decimals for USD. */
|
|
83
100
|
function getUsdDecimal(options = {}) {
|
|
84
|
-
const packageAddress = options.package ??
|
|
101
|
+
const packageAddress = options.package ?? '@typus/perp';
|
|
85
102
|
return (tx) => tx.moveCall({
|
|
86
103
|
package: packageAddress,
|
|
87
|
-
module:
|
|
88
|
-
function:
|
|
104
|
+
module: 'math',
|
|
105
|
+
function: 'get_usd_decimal',
|
|
89
106
|
});
|
|
90
107
|
}
|
|
91
108
|
/** Returns the number of decimals for the funding rate. */
|
|
92
109
|
function getFundingRateDecimal(options = {}) {
|
|
93
|
-
const packageAddress = options.package ??
|
|
110
|
+
const packageAddress = options.package ?? '@typus/perp';
|
|
94
111
|
return (tx) => tx.moveCall({
|
|
95
112
|
package: packageAddress,
|
|
96
|
-
module:
|
|
97
|
-
function:
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
function getMbpScale(options = {}) {
|
|
101
|
-
const packageAddress = options.package ?? "@typus/perp";
|
|
102
|
-
return (tx) => tx.moveCall({
|
|
103
|
-
package: packageAddress,
|
|
104
|
-
module: "math",
|
|
105
|
-
function: "get_mbp_scale",
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
function getBpScale(options = {}) {
|
|
109
|
-
const packageAddress = options.package ?? "@typus/perp";
|
|
110
|
-
return (tx) => tx.moveCall({
|
|
111
|
-
package: packageAddress,
|
|
112
|
-
module: "math",
|
|
113
|
-
function: "get_bp_scale",
|
|
113
|
+
module: 'math',
|
|
114
|
+
function: 'get_funding_rate_decimal',
|
|
114
115
|
});
|
|
115
116
|
}
|