@typus/typus-perp-sdk 1.1.3 → 1.1.5-funding-collect
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/api/sentio.js +1 -1
- package/dist/src/fetch.d.ts +10 -1
- package/dist/src/fetch.js +21 -8
- package/dist/src/index.js +1 -1
- package/dist/src/typus_perp/lp-pool/functions.d.ts +34 -0
- package/dist/src/typus_perp/lp-pool/functions.js +56 -0
- package/dist/src/typus_perp/lp-pool/structs.d.ts +774 -0
- package/dist/src/typus_perp/lp-pool/structs.js +1952 -498
- package/dist/src/typus_perp/trading/functions.d.ts +105 -10
- package/dist/src/typus_perp/trading/functions.js +152 -16
- package/dist/src/typus_perp/user-account/functions.d.ts +36 -0
- package/dist/src/typus_perp/user-account/functions.js +70 -0
- package/dist/src/typus_perp/user-account/structs.d.ts +168 -0
- package/dist/src/typus_perp/user-account/structs.js +448 -0
- package/dist/src/user/history.d.ts +1 -1
- package/dist/src/user/history.js +51 -6
- package/dist/src/user/order.d.ts +4 -0
- package/dist/src/user/order.js +48 -0
- package/dist/src/user/orderWithBidReceipt.d.ts +11 -0
- package/dist/src/user/orderWithBidReceipt.js +72 -8
- package/package.json +2 -2
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import * as reified from "../../_framework/reified";
|
|
2
|
+
import { TypeName } from "../../_dependencies/source/0x1/type-name/structs";
|
|
3
|
+
import { ID, UID } from "../../_dependencies/source/0x2/object/structs";
|
|
4
|
+
import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../_framework/reified";
|
|
5
|
+
import { FieldsWithTypes } from "../../_framework/util";
|
|
6
|
+
import { Vector } from "../../_framework/vector";
|
|
7
|
+
import { PKG_V1 } from "../index";
|
|
8
|
+
import { SuiClient, SuiObjectData, SuiParsedData } from "@mysten/sui/client";
|
|
9
|
+
export declare function isUserAccount(type: string): boolean;
|
|
10
|
+
export interface UserAccountFields {
|
|
11
|
+
id: ToField<UID>;
|
|
12
|
+
owner: ToField<"address">;
|
|
13
|
+
delegateUser: ToField<Vector<"address">>;
|
|
14
|
+
symbols: ToField<Vector<TypeName>>;
|
|
15
|
+
u64Padding: ToField<Vector<"u64">>;
|
|
16
|
+
}
|
|
17
|
+
export type UserAccountReified = Reified<UserAccount, UserAccountFields>;
|
|
18
|
+
export declare class UserAccount implements StructClass {
|
|
19
|
+
__StructClass: true;
|
|
20
|
+
static readonly $typeName: string;
|
|
21
|
+
static readonly $numTypeParams = 0;
|
|
22
|
+
static readonly $isPhantom: readonly [];
|
|
23
|
+
readonly $typeName: string;
|
|
24
|
+
readonly $fullTypeName: `${typeof PKG_V1}::user_account::UserAccount`;
|
|
25
|
+
readonly $typeArgs: [];
|
|
26
|
+
readonly $isPhantom: readonly [];
|
|
27
|
+
readonly id: ToField<UID>;
|
|
28
|
+
readonly owner: ToField<"address">;
|
|
29
|
+
readonly delegateUser: ToField<Vector<"address">>;
|
|
30
|
+
readonly symbols: ToField<Vector<TypeName>>;
|
|
31
|
+
readonly u64Padding: ToField<Vector<"u64">>;
|
|
32
|
+
private constructor();
|
|
33
|
+
static reified(): UserAccountReified;
|
|
34
|
+
static get r(): reified.StructClassReified<UserAccount, UserAccountFields>;
|
|
35
|
+
static phantom(): PhantomReified<ToTypeStr<UserAccount>>;
|
|
36
|
+
static get p(): reified.PhantomReified<"0xe27969a70f93034de9ce16e6ad661b480324574e68d15a64b513fd90eb2423e5::user_account::UserAccount" | "0x585924f160f83ef16f8927ec117e4d740abb6f4e571ecfa89ff3e973042cb1b9::user_account::UserAccount">;
|
|
37
|
+
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
38
|
+
id: {
|
|
39
|
+
id: {
|
|
40
|
+
bytes: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
owner: string;
|
|
44
|
+
delegate_user: string[];
|
|
45
|
+
symbols: {
|
|
46
|
+
name: {
|
|
47
|
+
bytes: number[];
|
|
48
|
+
};
|
|
49
|
+
}[];
|
|
50
|
+
u64_padding: string[];
|
|
51
|
+
}, {
|
|
52
|
+
id: {
|
|
53
|
+
id: {
|
|
54
|
+
bytes: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
owner: string;
|
|
58
|
+
delegate_user: Iterable<string> & {
|
|
59
|
+
length: number;
|
|
60
|
+
};
|
|
61
|
+
symbols: Iterable<{
|
|
62
|
+
name: {
|
|
63
|
+
bytes: Iterable<number> & {
|
|
64
|
+
length: number;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
}> & {
|
|
68
|
+
length: number;
|
|
69
|
+
};
|
|
70
|
+
u64_padding: Iterable<string | number | bigint> & {
|
|
71
|
+
length: number;
|
|
72
|
+
};
|
|
73
|
+
}>;
|
|
74
|
+
static fromFields(fields: Record<string, any>): UserAccount;
|
|
75
|
+
static fromFieldsWithTypes(item: FieldsWithTypes): UserAccount;
|
|
76
|
+
static fromBcs(data: Uint8Array): UserAccount;
|
|
77
|
+
toJSONField(): {
|
|
78
|
+
id: string;
|
|
79
|
+
owner: string;
|
|
80
|
+
delegateUser: string[];
|
|
81
|
+
symbols: {
|
|
82
|
+
name: string;
|
|
83
|
+
}[];
|
|
84
|
+
u64Padding: string[];
|
|
85
|
+
};
|
|
86
|
+
toJSON(): {
|
|
87
|
+
id: string;
|
|
88
|
+
owner: string;
|
|
89
|
+
delegateUser: string[];
|
|
90
|
+
symbols: {
|
|
91
|
+
name: string;
|
|
92
|
+
}[];
|
|
93
|
+
u64Padding: string[];
|
|
94
|
+
$typeName: string;
|
|
95
|
+
$typeArgs: [];
|
|
96
|
+
};
|
|
97
|
+
static fromJSONField(field: any): UserAccount;
|
|
98
|
+
static fromJSON(json: Record<string, any>): UserAccount;
|
|
99
|
+
static fromSuiParsedData(content: SuiParsedData): UserAccount;
|
|
100
|
+
static fromSuiObjectData(data: SuiObjectData): UserAccount;
|
|
101
|
+
static fetch(client: SuiClient, id: string): Promise<UserAccount>;
|
|
102
|
+
}
|
|
103
|
+
export declare function isUserAccountCap(type: string): boolean;
|
|
104
|
+
export interface UserAccountCapFields {
|
|
105
|
+
id: ToField<UID>;
|
|
106
|
+
owner: ToField<"address">;
|
|
107
|
+
userAccountId: ToField<ID>;
|
|
108
|
+
}
|
|
109
|
+
export type UserAccountCapReified = Reified<UserAccountCap, UserAccountCapFields>;
|
|
110
|
+
export declare class UserAccountCap implements StructClass {
|
|
111
|
+
__StructClass: true;
|
|
112
|
+
static readonly $typeName: string;
|
|
113
|
+
static readonly $numTypeParams = 0;
|
|
114
|
+
static readonly $isPhantom: readonly [];
|
|
115
|
+
readonly $typeName: string;
|
|
116
|
+
readonly $fullTypeName: `${typeof PKG_V1}::user_account::UserAccountCap`;
|
|
117
|
+
readonly $typeArgs: [];
|
|
118
|
+
readonly $isPhantom: readonly [];
|
|
119
|
+
readonly id: ToField<UID>;
|
|
120
|
+
readonly owner: ToField<"address">;
|
|
121
|
+
readonly userAccountId: ToField<ID>;
|
|
122
|
+
private constructor();
|
|
123
|
+
static reified(): UserAccountCapReified;
|
|
124
|
+
static get r(): reified.StructClassReified<UserAccountCap, UserAccountCapFields>;
|
|
125
|
+
static phantom(): PhantomReified<ToTypeStr<UserAccountCap>>;
|
|
126
|
+
static get p(): reified.PhantomReified<"0xe27969a70f93034de9ce16e6ad661b480324574e68d15a64b513fd90eb2423e5::user_account::UserAccountCap" | "0x585924f160f83ef16f8927ec117e4d740abb6f4e571ecfa89ff3e973042cb1b9::user_account::UserAccountCap">;
|
|
127
|
+
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
128
|
+
id: {
|
|
129
|
+
id: {
|
|
130
|
+
bytes: string;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
owner: string;
|
|
134
|
+
user_account_id: {
|
|
135
|
+
bytes: string;
|
|
136
|
+
};
|
|
137
|
+
}, {
|
|
138
|
+
id: {
|
|
139
|
+
id: {
|
|
140
|
+
bytes: string;
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
owner: string;
|
|
144
|
+
user_account_id: {
|
|
145
|
+
bytes: string;
|
|
146
|
+
};
|
|
147
|
+
}>;
|
|
148
|
+
static fromFields(fields: Record<string, any>): UserAccountCap;
|
|
149
|
+
static fromFieldsWithTypes(item: FieldsWithTypes): UserAccountCap;
|
|
150
|
+
static fromBcs(data: Uint8Array): UserAccountCap;
|
|
151
|
+
toJSONField(): {
|
|
152
|
+
id: string;
|
|
153
|
+
owner: string;
|
|
154
|
+
userAccountId: string;
|
|
155
|
+
};
|
|
156
|
+
toJSON(): {
|
|
157
|
+
id: string;
|
|
158
|
+
owner: string;
|
|
159
|
+
userAccountId: string;
|
|
160
|
+
$typeName: string;
|
|
161
|
+
$typeArgs: [];
|
|
162
|
+
};
|
|
163
|
+
static fromJSONField(field: any): UserAccountCap;
|
|
164
|
+
static fromJSON(json: Record<string, any>): UserAccountCap;
|
|
165
|
+
static fromSuiParsedData(content: SuiParsedData): UserAccountCap;
|
|
166
|
+
static fromSuiObjectData(data: SuiObjectData): UserAccountCap;
|
|
167
|
+
static fetch(client: SuiClient, id: string): Promise<UserAccountCap>;
|
|
168
|
+
}
|
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
+
var ownKeys = function(o) {
|
|
31
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
};
|
|
36
|
+
return ownKeys(o);
|
|
37
|
+
};
|
|
38
|
+
return function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
46
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
47
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
48
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
49
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
50
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
51
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
52
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
56
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
57
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
58
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
59
|
+
function step(op) {
|
|
60
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
61
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
62
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
63
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
64
|
+
switch (op[0]) {
|
|
65
|
+
case 0: case 1: t = op; break;
|
|
66
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
67
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
68
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
69
|
+
default:
|
|
70
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
71
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
72
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
73
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
74
|
+
if (t[2]) _.ops.pop();
|
|
75
|
+
_.trys.pop(); continue;
|
|
76
|
+
}
|
|
77
|
+
op = body.call(thisArg, _);
|
|
78
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
79
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
83
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
84
|
+
if (!m) return o;
|
|
85
|
+
var i = m.call(o), r, ar = [], e;
|
|
86
|
+
try {
|
|
87
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
88
|
+
}
|
|
89
|
+
catch (error) { e = { error: error }; }
|
|
90
|
+
finally {
|
|
91
|
+
try {
|
|
92
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
93
|
+
}
|
|
94
|
+
finally { if (e) throw e.error; }
|
|
95
|
+
}
|
|
96
|
+
return ar;
|
|
97
|
+
};
|
|
98
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
99
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
100
|
+
if (ar || !(i in from)) {
|
|
101
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
102
|
+
ar[i] = from[i];
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
106
|
+
};
|
|
107
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
108
|
+
exports.UserAccountCap = exports.UserAccount = void 0;
|
|
109
|
+
exports.isUserAccount = isUserAccount;
|
|
110
|
+
exports.isUserAccountCap = isUserAccountCap;
|
|
111
|
+
var reified = __importStar(require("../../_framework/reified"));
|
|
112
|
+
var structs_1 = require("../../_dependencies/source/0x1/type-name/structs");
|
|
113
|
+
var structs_2 = require("../../_dependencies/source/0x2/object/structs");
|
|
114
|
+
var reified_1 = require("../../_framework/reified");
|
|
115
|
+
var util_1 = require("../../_framework/util");
|
|
116
|
+
var index_1 = require("../index");
|
|
117
|
+
var bcs_1 = require("@mysten/sui/bcs");
|
|
118
|
+
var utils_1 = require("@mysten/sui/utils");
|
|
119
|
+
/* ============================== UserAccount =============================== */
|
|
120
|
+
function isUserAccount(type) {
|
|
121
|
+
type = (0, util_1.compressSuiType)(type);
|
|
122
|
+
return type === "".concat(index_1.PKG_V1, "::user_account::UserAccount");
|
|
123
|
+
}
|
|
124
|
+
var UserAccount = /** @class */ (function () {
|
|
125
|
+
function UserAccount(typeArgs, fields) {
|
|
126
|
+
this.__StructClass = true;
|
|
127
|
+
this.$typeName = UserAccount.$typeName;
|
|
128
|
+
this.$isPhantom = UserAccount.$isPhantom;
|
|
129
|
+
this.$fullTypeName = util_1.composeSuiType.apply(void 0, __spreadArray([UserAccount.$typeName], __read(typeArgs), false));
|
|
130
|
+
this.$typeArgs = typeArgs;
|
|
131
|
+
this.id = fields.id;
|
|
132
|
+
this.owner = fields.owner;
|
|
133
|
+
this.delegateUser = fields.delegateUser;
|
|
134
|
+
this.symbols = fields.symbols;
|
|
135
|
+
this.u64Padding = fields.u64Padding;
|
|
136
|
+
}
|
|
137
|
+
UserAccount.reified = function () {
|
|
138
|
+
var _this = this;
|
|
139
|
+
return {
|
|
140
|
+
typeName: UserAccount.$typeName,
|
|
141
|
+
fullTypeName: util_1.composeSuiType.apply(void 0, __spreadArray([UserAccount.$typeName], [], false)),
|
|
142
|
+
typeArgs: [],
|
|
143
|
+
isPhantom: UserAccount.$isPhantom,
|
|
144
|
+
reifiedTypeArgs: [],
|
|
145
|
+
fromFields: function (fields) { return UserAccount.fromFields(fields); },
|
|
146
|
+
fromFieldsWithTypes: function (item) { return UserAccount.fromFieldsWithTypes(item); },
|
|
147
|
+
fromBcs: function (data) { return UserAccount.fromBcs(data); },
|
|
148
|
+
bcs: UserAccount.bcs,
|
|
149
|
+
fromJSONField: function (field) { return UserAccount.fromJSONField(field); },
|
|
150
|
+
fromJSON: function (json) { return UserAccount.fromJSON(json); },
|
|
151
|
+
fromSuiParsedData: function (content) { return UserAccount.fromSuiParsedData(content); },
|
|
152
|
+
fromSuiObjectData: function (content) { return UserAccount.fromSuiObjectData(content); },
|
|
153
|
+
fetch: function (client, id) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
154
|
+
return [2 /*return*/, UserAccount.fetch(client, id)];
|
|
155
|
+
}); }); },
|
|
156
|
+
new: function (fields) {
|
|
157
|
+
return new UserAccount([], fields);
|
|
158
|
+
},
|
|
159
|
+
kind: "StructClassReified",
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
Object.defineProperty(UserAccount, "r", {
|
|
163
|
+
get: function () {
|
|
164
|
+
return UserAccount.reified();
|
|
165
|
+
},
|
|
166
|
+
enumerable: false,
|
|
167
|
+
configurable: true
|
|
168
|
+
});
|
|
169
|
+
UserAccount.phantom = function () {
|
|
170
|
+
return (0, reified_1.phantom)(UserAccount.reified());
|
|
171
|
+
};
|
|
172
|
+
Object.defineProperty(UserAccount, "p", {
|
|
173
|
+
get: function () {
|
|
174
|
+
return UserAccount.phantom();
|
|
175
|
+
},
|
|
176
|
+
enumerable: false,
|
|
177
|
+
configurable: true
|
|
178
|
+
});
|
|
179
|
+
Object.defineProperty(UserAccount, "bcs", {
|
|
180
|
+
get: function () {
|
|
181
|
+
return bcs_1.bcs.struct("UserAccount", {
|
|
182
|
+
id: structs_2.UID.bcs,
|
|
183
|
+
owner: bcs_1.bcs.bytes(32).transform({ input: function (val) { return (0, utils_1.fromHEX)(val); }, output: function (val) { return (0, utils_1.toHEX)(val); } }),
|
|
184
|
+
delegate_user: bcs_1.bcs.vector(bcs_1.bcs.bytes(32).transform({ input: function (val) { return (0, utils_1.fromHEX)(val); }, output: function (val) { return (0, utils_1.toHEX)(val); } })),
|
|
185
|
+
symbols: bcs_1.bcs.vector(structs_1.TypeName.bcs),
|
|
186
|
+
u64_padding: bcs_1.bcs.vector(bcs_1.bcs.u64()),
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
enumerable: false,
|
|
190
|
+
configurable: true
|
|
191
|
+
});
|
|
192
|
+
UserAccount.fromFields = function (fields) {
|
|
193
|
+
return UserAccount.reified().new({
|
|
194
|
+
id: (0, reified_1.decodeFromFields)(structs_2.UID.reified(), fields.id),
|
|
195
|
+
owner: (0, reified_1.decodeFromFields)("address", fields.owner),
|
|
196
|
+
delegateUser: (0, reified_1.decodeFromFields)(reified.vector("address"), fields.delegate_user),
|
|
197
|
+
symbols: (0, reified_1.decodeFromFields)(reified.vector(structs_1.TypeName.reified()), fields.symbols),
|
|
198
|
+
u64Padding: (0, reified_1.decodeFromFields)(reified.vector("u64"), fields.u64_padding),
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
UserAccount.fromFieldsWithTypes = function (item) {
|
|
202
|
+
if (!isUserAccount(item.type)) {
|
|
203
|
+
throw new Error("not a UserAccount type");
|
|
204
|
+
}
|
|
205
|
+
return UserAccount.reified().new({
|
|
206
|
+
id: (0, reified_1.decodeFromFieldsWithTypes)(structs_2.UID.reified(), item.fields.id),
|
|
207
|
+
owner: (0, reified_1.decodeFromFieldsWithTypes)("address", item.fields.owner),
|
|
208
|
+
delegateUser: (0, reified_1.decodeFromFieldsWithTypes)(reified.vector("address"), item.fields.delegate_user),
|
|
209
|
+
symbols: (0, reified_1.decodeFromFieldsWithTypes)(reified.vector(structs_1.TypeName.reified()), item.fields.symbols),
|
|
210
|
+
u64Padding: (0, reified_1.decodeFromFieldsWithTypes)(reified.vector("u64"), item.fields.u64_padding),
|
|
211
|
+
});
|
|
212
|
+
};
|
|
213
|
+
UserAccount.fromBcs = function (data) {
|
|
214
|
+
return UserAccount.fromFields(UserAccount.bcs.parse(data));
|
|
215
|
+
};
|
|
216
|
+
UserAccount.prototype.toJSONField = function () {
|
|
217
|
+
return {
|
|
218
|
+
id: this.id,
|
|
219
|
+
owner: this.owner,
|
|
220
|
+
delegateUser: (0, reified_1.fieldToJSON)("vector<address>", this.delegateUser),
|
|
221
|
+
symbols: (0, reified_1.fieldToJSON)("vector<".concat(structs_1.TypeName.$typeName, ">"), this.symbols),
|
|
222
|
+
u64Padding: (0, reified_1.fieldToJSON)("vector<u64>", this.u64Padding),
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
UserAccount.prototype.toJSON = function () {
|
|
226
|
+
return __assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
|
|
227
|
+
};
|
|
228
|
+
UserAccount.fromJSONField = function (field) {
|
|
229
|
+
return UserAccount.reified().new({
|
|
230
|
+
id: (0, reified_1.decodeFromJSONField)(structs_2.UID.reified(), field.id),
|
|
231
|
+
owner: (0, reified_1.decodeFromJSONField)("address", field.owner),
|
|
232
|
+
delegateUser: (0, reified_1.decodeFromJSONField)(reified.vector("address"), field.delegateUser),
|
|
233
|
+
symbols: (0, reified_1.decodeFromJSONField)(reified.vector(structs_1.TypeName.reified()), field.symbols),
|
|
234
|
+
u64Padding: (0, reified_1.decodeFromJSONField)(reified.vector("u64"), field.u64Padding),
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
UserAccount.fromJSON = function (json) {
|
|
238
|
+
if (json.$typeName !== UserAccount.$typeName) {
|
|
239
|
+
throw new Error("not a WithTwoGenerics json object");
|
|
240
|
+
}
|
|
241
|
+
return UserAccount.fromJSONField(json);
|
|
242
|
+
};
|
|
243
|
+
UserAccount.fromSuiParsedData = function (content) {
|
|
244
|
+
if (content.dataType !== "moveObject") {
|
|
245
|
+
throw new Error("not an object");
|
|
246
|
+
}
|
|
247
|
+
if (!isUserAccount(content.type)) {
|
|
248
|
+
throw new Error("object at ".concat(content.fields.id, " is not a UserAccount object"));
|
|
249
|
+
}
|
|
250
|
+
return UserAccount.fromFieldsWithTypes(content);
|
|
251
|
+
};
|
|
252
|
+
UserAccount.fromSuiObjectData = function (data) {
|
|
253
|
+
if (data.bcs) {
|
|
254
|
+
if (data.bcs.dataType !== "moveObject" || !isUserAccount(data.bcs.type)) {
|
|
255
|
+
throw new Error("object at is not a UserAccount object");
|
|
256
|
+
}
|
|
257
|
+
return UserAccount.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
|
|
258
|
+
}
|
|
259
|
+
if (data.content) {
|
|
260
|
+
return UserAccount.fromSuiParsedData(data.content);
|
|
261
|
+
}
|
|
262
|
+
throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
|
|
263
|
+
};
|
|
264
|
+
UserAccount.fetch = function (client, id) {
|
|
265
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
266
|
+
var res;
|
|
267
|
+
var _a, _b;
|
|
268
|
+
return __generator(this, function (_c) {
|
|
269
|
+
switch (_c.label) {
|
|
270
|
+
case 0: return [4 /*yield*/, client.getObject({ id: id, options: { showBcs: true } })];
|
|
271
|
+
case 1:
|
|
272
|
+
res = _c.sent();
|
|
273
|
+
if (res.error) {
|
|
274
|
+
throw new Error("error fetching UserAccount object at id ".concat(id, ": ").concat(res.error.code));
|
|
275
|
+
}
|
|
276
|
+
if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" || !isUserAccount(res.data.bcs.type)) {
|
|
277
|
+
throw new Error("object at id ".concat(id, " is not a UserAccount object"));
|
|
278
|
+
}
|
|
279
|
+
return [2 /*return*/, UserAccount.fromSuiObjectData(res.data)];
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
};
|
|
284
|
+
UserAccount.$typeName = "".concat(index_1.PKG_V1, "::user_account::UserAccount");
|
|
285
|
+
UserAccount.$numTypeParams = 0;
|
|
286
|
+
UserAccount.$isPhantom = [];
|
|
287
|
+
return UserAccount;
|
|
288
|
+
}());
|
|
289
|
+
exports.UserAccount = UserAccount;
|
|
290
|
+
/* ============================== UserAccountCap =============================== */
|
|
291
|
+
function isUserAccountCap(type) {
|
|
292
|
+
type = (0, util_1.compressSuiType)(type);
|
|
293
|
+
return type === "".concat(index_1.PKG_V1, "::user_account::UserAccountCap");
|
|
294
|
+
}
|
|
295
|
+
var UserAccountCap = /** @class */ (function () {
|
|
296
|
+
function UserAccountCap(typeArgs, fields) {
|
|
297
|
+
this.__StructClass = true;
|
|
298
|
+
this.$typeName = UserAccountCap.$typeName;
|
|
299
|
+
this.$isPhantom = UserAccountCap.$isPhantom;
|
|
300
|
+
this.$fullTypeName = util_1.composeSuiType.apply(void 0, __spreadArray([UserAccountCap.$typeName], __read(typeArgs), false));
|
|
301
|
+
this.$typeArgs = typeArgs;
|
|
302
|
+
this.id = fields.id;
|
|
303
|
+
this.owner = fields.owner;
|
|
304
|
+
this.userAccountId = fields.userAccountId;
|
|
305
|
+
}
|
|
306
|
+
UserAccountCap.reified = function () {
|
|
307
|
+
var _this = this;
|
|
308
|
+
return {
|
|
309
|
+
typeName: UserAccountCap.$typeName,
|
|
310
|
+
fullTypeName: util_1.composeSuiType.apply(void 0, __spreadArray([UserAccountCap.$typeName], [], false)),
|
|
311
|
+
typeArgs: [],
|
|
312
|
+
isPhantom: UserAccountCap.$isPhantom,
|
|
313
|
+
reifiedTypeArgs: [],
|
|
314
|
+
fromFields: function (fields) { return UserAccountCap.fromFields(fields); },
|
|
315
|
+
fromFieldsWithTypes: function (item) { return UserAccountCap.fromFieldsWithTypes(item); },
|
|
316
|
+
fromBcs: function (data) { return UserAccountCap.fromBcs(data); },
|
|
317
|
+
bcs: UserAccountCap.bcs,
|
|
318
|
+
fromJSONField: function (field) { return UserAccountCap.fromJSONField(field); },
|
|
319
|
+
fromJSON: function (json) { return UserAccountCap.fromJSON(json); },
|
|
320
|
+
fromSuiParsedData: function (content) { return UserAccountCap.fromSuiParsedData(content); },
|
|
321
|
+
fromSuiObjectData: function (content) { return UserAccountCap.fromSuiObjectData(content); },
|
|
322
|
+
fetch: function (client, id) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
323
|
+
return [2 /*return*/, UserAccountCap.fetch(client, id)];
|
|
324
|
+
}); }); },
|
|
325
|
+
new: function (fields) {
|
|
326
|
+
return new UserAccountCap([], fields);
|
|
327
|
+
},
|
|
328
|
+
kind: "StructClassReified",
|
|
329
|
+
};
|
|
330
|
+
};
|
|
331
|
+
Object.defineProperty(UserAccountCap, "r", {
|
|
332
|
+
get: function () {
|
|
333
|
+
return UserAccountCap.reified();
|
|
334
|
+
},
|
|
335
|
+
enumerable: false,
|
|
336
|
+
configurable: true
|
|
337
|
+
});
|
|
338
|
+
UserAccountCap.phantom = function () {
|
|
339
|
+
return (0, reified_1.phantom)(UserAccountCap.reified());
|
|
340
|
+
};
|
|
341
|
+
Object.defineProperty(UserAccountCap, "p", {
|
|
342
|
+
get: function () {
|
|
343
|
+
return UserAccountCap.phantom();
|
|
344
|
+
},
|
|
345
|
+
enumerable: false,
|
|
346
|
+
configurable: true
|
|
347
|
+
});
|
|
348
|
+
Object.defineProperty(UserAccountCap, "bcs", {
|
|
349
|
+
get: function () {
|
|
350
|
+
return bcs_1.bcs.struct("UserAccountCap", {
|
|
351
|
+
id: structs_2.UID.bcs,
|
|
352
|
+
owner: bcs_1.bcs.bytes(32).transform({ input: function (val) { return (0, utils_1.fromHEX)(val); }, output: function (val) { return (0, utils_1.toHEX)(val); } }),
|
|
353
|
+
user_account_id: structs_2.ID.bcs,
|
|
354
|
+
});
|
|
355
|
+
},
|
|
356
|
+
enumerable: false,
|
|
357
|
+
configurable: true
|
|
358
|
+
});
|
|
359
|
+
UserAccountCap.fromFields = function (fields) {
|
|
360
|
+
return UserAccountCap.reified().new({
|
|
361
|
+
id: (0, reified_1.decodeFromFields)(structs_2.UID.reified(), fields.id),
|
|
362
|
+
owner: (0, reified_1.decodeFromFields)("address", fields.owner),
|
|
363
|
+
userAccountId: (0, reified_1.decodeFromFields)(structs_2.ID.reified(), fields.user_account_id),
|
|
364
|
+
});
|
|
365
|
+
};
|
|
366
|
+
UserAccountCap.fromFieldsWithTypes = function (item) {
|
|
367
|
+
if (!isUserAccountCap(item.type)) {
|
|
368
|
+
throw new Error("not a UserAccountCap type");
|
|
369
|
+
}
|
|
370
|
+
return UserAccountCap.reified().new({
|
|
371
|
+
id: (0, reified_1.decodeFromFieldsWithTypes)(structs_2.UID.reified(), item.fields.id),
|
|
372
|
+
owner: (0, reified_1.decodeFromFieldsWithTypes)("address", item.fields.owner),
|
|
373
|
+
userAccountId: (0, reified_1.decodeFromFieldsWithTypes)(structs_2.ID.reified(), item.fields.user_account_id),
|
|
374
|
+
});
|
|
375
|
+
};
|
|
376
|
+
UserAccountCap.fromBcs = function (data) {
|
|
377
|
+
return UserAccountCap.fromFields(UserAccountCap.bcs.parse(data));
|
|
378
|
+
};
|
|
379
|
+
UserAccountCap.prototype.toJSONField = function () {
|
|
380
|
+
return {
|
|
381
|
+
id: this.id,
|
|
382
|
+
owner: this.owner,
|
|
383
|
+
userAccountId: this.userAccountId,
|
|
384
|
+
};
|
|
385
|
+
};
|
|
386
|
+
UserAccountCap.prototype.toJSON = function () {
|
|
387
|
+
return __assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
|
|
388
|
+
};
|
|
389
|
+
UserAccountCap.fromJSONField = function (field) {
|
|
390
|
+
return UserAccountCap.reified().new({
|
|
391
|
+
id: (0, reified_1.decodeFromJSONField)(structs_2.UID.reified(), field.id),
|
|
392
|
+
owner: (0, reified_1.decodeFromJSONField)("address", field.owner),
|
|
393
|
+
userAccountId: (0, reified_1.decodeFromJSONField)(structs_2.ID.reified(), field.userAccountId),
|
|
394
|
+
});
|
|
395
|
+
};
|
|
396
|
+
UserAccountCap.fromJSON = function (json) {
|
|
397
|
+
if (json.$typeName !== UserAccountCap.$typeName) {
|
|
398
|
+
throw new Error("not a WithTwoGenerics json object");
|
|
399
|
+
}
|
|
400
|
+
return UserAccountCap.fromJSONField(json);
|
|
401
|
+
};
|
|
402
|
+
UserAccountCap.fromSuiParsedData = function (content) {
|
|
403
|
+
if (content.dataType !== "moveObject") {
|
|
404
|
+
throw new Error("not an object");
|
|
405
|
+
}
|
|
406
|
+
if (!isUserAccountCap(content.type)) {
|
|
407
|
+
throw new Error("object at ".concat(content.fields.id, " is not a UserAccountCap object"));
|
|
408
|
+
}
|
|
409
|
+
return UserAccountCap.fromFieldsWithTypes(content);
|
|
410
|
+
};
|
|
411
|
+
UserAccountCap.fromSuiObjectData = function (data) {
|
|
412
|
+
if (data.bcs) {
|
|
413
|
+
if (data.bcs.dataType !== "moveObject" || !isUserAccountCap(data.bcs.type)) {
|
|
414
|
+
throw new Error("object at is not a UserAccountCap object");
|
|
415
|
+
}
|
|
416
|
+
return UserAccountCap.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
|
|
417
|
+
}
|
|
418
|
+
if (data.content) {
|
|
419
|
+
return UserAccountCap.fromSuiParsedData(data.content);
|
|
420
|
+
}
|
|
421
|
+
throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
|
|
422
|
+
};
|
|
423
|
+
UserAccountCap.fetch = function (client, id) {
|
|
424
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
425
|
+
var res;
|
|
426
|
+
var _a, _b;
|
|
427
|
+
return __generator(this, function (_c) {
|
|
428
|
+
switch (_c.label) {
|
|
429
|
+
case 0: return [4 /*yield*/, client.getObject({ id: id, options: { showBcs: true } })];
|
|
430
|
+
case 1:
|
|
431
|
+
res = _c.sent();
|
|
432
|
+
if (res.error) {
|
|
433
|
+
throw new Error("error fetching UserAccountCap object at id ".concat(id, ": ").concat(res.error.code));
|
|
434
|
+
}
|
|
435
|
+
if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" || !isUserAccountCap(res.data.bcs.type)) {
|
|
436
|
+
throw new Error("object at id ".concat(id, " is not a UserAccountCap object"));
|
|
437
|
+
}
|
|
438
|
+
return [2 /*return*/, UserAccountCap.fromSuiObjectData(res.data)];
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
});
|
|
442
|
+
};
|
|
443
|
+
UserAccountCap.$typeName = "".concat(index_1.PKG_V1, "::user_account::UserAccountCap");
|
|
444
|
+
UserAccountCap.$numTypeParams = 0;
|
|
445
|
+
UserAccountCap.$isPhantom = [];
|
|
446
|
+
return UserAccountCap;
|
|
447
|
+
}());
|
|
448
|
+
exports.UserAccountCap = UserAccountCap;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TOKEN } from "@typus/typus-sdk/dist/src/constants";
|
|
2
|
-
export type actionType = "Place Order" | "Cancel Order" | "Order Filled (Open Position)" | "Order Filled (Close Position)" | "Realized PnL" | "Modify Collateral" | "Exercise Position" | "Liquidation" | "Force Close Position" | "Swap";
|
|
2
|
+
export type actionType = "Place Order" | "Cancel Order" | "Order Filled (Open Position)" | "Order Filled (Close Position)" | "Realized PnL" | "Modify Collateral" | "Exercise Position" | "Liquidation" | "Force Close Position" | "Swap" | "Realized Funding";
|
|
3
3
|
export type sideType = "Long" | "Short";
|
|
4
4
|
export type orderType = "Market" | "Limit" | "Take Profit" | "Stop Loss";
|
|
5
5
|
export type statusType = "Open" | "Filled" | "Canceled";
|