@suilend/sdk 7.0.1 → 8.0.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.
@@ -1,128 +0,0 @@
1
- import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../../../_framework/reified";
2
- import { FieldsWithTypes } from "../../../../_framework/util";
3
- import { PKG_V1 } from "../index";
4
- import { PriceIdentifier } from "../price-identifier/structs";
5
- import { Price } from "../price/structs";
6
- import { SuiGrpcClient } from "@mysten/sui/grpc";
7
- export declare function isPriceFeed(type: string): boolean;
8
- export interface PriceFeedFields {
9
- priceIdentifier: ToField<PriceIdentifier>;
10
- price: ToField<Price>;
11
- emaPrice: ToField<Price>;
12
- }
13
- export type PriceFeedReified = Reified<PriceFeed, PriceFeedFields>;
14
- export declare class PriceFeed implements StructClass {
15
- __StructClass: true;
16
- static readonly $typeName = "0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price_feed::PriceFeed";
17
- static readonly $numTypeParams = 0;
18
- static readonly $isPhantom: readonly [];
19
- readonly $typeName = "0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price_feed::PriceFeed";
20
- readonly $fullTypeName: `${typeof PKG_V1}::price_feed::PriceFeed`;
21
- readonly $typeArgs: [];
22
- readonly $isPhantom: readonly [];
23
- readonly priceIdentifier: ToField<PriceIdentifier>;
24
- readonly price: ToField<Price>;
25
- readonly emaPrice: ToField<Price>;
26
- private constructor();
27
- static reified(): PriceFeedReified;
28
- static get r(): import("../../../../_framework/reified").StructClassReified<PriceFeed, PriceFeedFields>;
29
- static phantom(): PhantomReified<ToTypeStr<PriceFeed>>;
30
- static get p(): PhantomReified<"0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price_feed::PriceFeed">;
31
- static get bcs(): import("@mysten/bcs").BcsStruct<{
32
- price_identifier: import("@mysten/bcs").BcsStruct<{
33
- bytes: import("@mysten/bcs").BcsType<number[], Iterable<number> & {
34
- length: number;
35
- }, string>;
36
- }, string>;
37
- price: import("@mysten/bcs").BcsStruct<{
38
- price: import("@mysten/bcs").BcsStruct<{
39
- negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
40
- magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
41
- }, string>;
42
- conf: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
43
- expo: import("@mysten/bcs").BcsStruct<{
44
- negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
45
- magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
46
- }, string>;
47
- timestamp: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
48
- }, string>;
49
- ema_price: import("@mysten/bcs").BcsStruct<{
50
- price: import("@mysten/bcs").BcsStruct<{
51
- negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
52
- magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
53
- }, string>;
54
- conf: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
55
- expo: import("@mysten/bcs").BcsStruct<{
56
- negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
57
- magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
58
- }, string>;
59
- timestamp: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
60
- }, string>;
61
- }, string>;
62
- static fromFields(fields: Record<string, any>): PriceFeed;
63
- static fromFieldsWithTypes(item: FieldsWithTypes): PriceFeed;
64
- static fromBcs(data: Uint8Array): PriceFeed;
65
- toJSONField(): {
66
- priceIdentifier: {
67
- bytes: number[];
68
- };
69
- price: {
70
- price: {
71
- negative: boolean;
72
- magnitude: string;
73
- };
74
- conf: string;
75
- expo: {
76
- negative: boolean;
77
- magnitude: string;
78
- };
79
- timestamp: string;
80
- };
81
- emaPrice: {
82
- price: {
83
- negative: boolean;
84
- magnitude: string;
85
- };
86
- conf: string;
87
- expo: {
88
- negative: boolean;
89
- magnitude: string;
90
- };
91
- timestamp: string;
92
- };
93
- };
94
- toJSON(): {
95
- priceIdentifier: {
96
- bytes: number[];
97
- };
98
- price: {
99
- price: {
100
- negative: boolean;
101
- magnitude: string;
102
- };
103
- conf: string;
104
- expo: {
105
- negative: boolean;
106
- magnitude: string;
107
- };
108
- timestamp: string;
109
- };
110
- emaPrice: {
111
- price: {
112
- negative: boolean;
113
- magnitude: string;
114
- };
115
- conf: string;
116
- expo: {
117
- negative: boolean;
118
- magnitude: string;
119
- };
120
- timestamp: string;
121
- };
122
- $typeName: string;
123
- $typeArgs: [];
124
- };
125
- static fromJSONField(field: any): PriceFeed;
126
- static fromJSON(json: Record<string, any>): PriceFeed;
127
- static fetch(client: SuiGrpcClient, id: string): Promise<PriceFeed>;
128
- }
@@ -1,121 +0,0 @@
1
- import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified.js";
2
- import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
3
- import { PKG_V1 } from "../index.js";
4
- import { PriceIdentifier } from "../price-identifier/structs.js";
5
- import { Price } from "../price/structs.js";
6
- import { bcs } from "@mysten/sui/bcs";
7
- /* ============================== PriceFeed =============================== */
8
- export function isPriceFeed(type) {
9
- type = compressSuiType(type);
10
- return type === `${PKG_V1}::price_feed::PriceFeed`;
11
- }
12
- export class PriceFeed {
13
- __StructClass = true;
14
- static $typeName = `${PKG_V1}::price_feed::PriceFeed`;
15
- static $numTypeParams = 0;
16
- static $isPhantom = [];
17
- $typeName = PriceFeed.$typeName;
18
- $fullTypeName;
19
- $typeArgs;
20
- $isPhantom = PriceFeed.$isPhantom;
21
- priceIdentifier;
22
- price;
23
- emaPrice;
24
- constructor(typeArgs, fields) {
25
- this.$fullTypeName = composeSuiType(PriceFeed.$typeName, ...typeArgs);
26
- this.$typeArgs = typeArgs;
27
- this.priceIdentifier = fields.priceIdentifier;
28
- this.price = fields.price;
29
- this.emaPrice = fields.emaPrice;
30
- }
31
- static reified() {
32
- return {
33
- typeName: PriceFeed.$typeName,
34
- fullTypeName: composeSuiType(PriceFeed.$typeName, ...[]),
35
- typeArgs: [],
36
- isPhantom: PriceFeed.$isPhantom,
37
- reifiedTypeArgs: [],
38
- fromFields: (fields) => PriceFeed.fromFields(fields),
39
- fromFieldsWithTypes: (item) => PriceFeed.fromFieldsWithTypes(item),
40
- fromBcs: (data) => PriceFeed.fromBcs(data),
41
- bcs: PriceFeed.bcs,
42
- fromJSONField: (field) => PriceFeed.fromJSONField(field),
43
- fromJSON: (json) => PriceFeed.fromJSON(json),
44
- fetch: async (client, id) => PriceFeed.fetch(client, id),
45
- new: (fields) => {
46
- return new PriceFeed([], fields);
47
- },
48
- kind: "StructClassReified",
49
- };
50
- }
51
- static get r() {
52
- return PriceFeed.reified();
53
- }
54
- static phantom() {
55
- return phantom(PriceFeed.reified());
56
- }
57
- static get p() {
58
- return PriceFeed.phantom();
59
- }
60
- static get bcs() {
61
- return bcs.struct("PriceFeed", {
62
- price_identifier: PriceIdentifier.bcs,
63
- price: Price.bcs,
64
- ema_price: Price.bcs,
65
- });
66
- }
67
- static fromFields(fields) {
68
- return PriceFeed.reified().new({
69
- priceIdentifier: decodeFromFields(PriceIdentifier.reified(), fields.price_identifier),
70
- price: decodeFromFields(Price.reified(), fields.price),
71
- emaPrice: decodeFromFields(Price.reified(), fields.ema_price),
72
- });
73
- }
74
- static fromFieldsWithTypes(item) {
75
- if (!isPriceFeed(item.type)) {
76
- throw new Error("not a PriceFeed type");
77
- }
78
- return PriceFeed.reified().new({
79
- priceIdentifier: decodeFromFieldsWithTypes(PriceIdentifier.reified(), item.fields.price_identifier),
80
- price: decodeFromFieldsWithTypes(Price.reified(), item.fields.price),
81
- emaPrice: decodeFromFieldsWithTypes(Price.reified(), item.fields.ema_price),
82
- });
83
- }
84
- static fromBcs(data) {
85
- return PriceFeed.fromFields(PriceFeed.bcs.parse(data));
86
- }
87
- toJSONField() {
88
- return {
89
- priceIdentifier: this.priceIdentifier.toJSONField(),
90
- price: this.price.toJSONField(),
91
- emaPrice: this.emaPrice.toJSONField(),
92
- };
93
- }
94
- toJSON() {
95
- return {
96
- $typeName: this.$typeName,
97
- $typeArgs: this.$typeArgs,
98
- ...this.toJSONField(),
99
- };
100
- }
101
- static fromJSONField(field) {
102
- return PriceFeed.reified().new({
103
- priceIdentifier: decodeFromJSONField(PriceIdentifier.reified(), field.priceIdentifier),
104
- price: decodeFromJSONField(Price.reified(), field.price),
105
- emaPrice: decodeFromJSONField(Price.reified(), field.emaPrice),
106
- });
107
- }
108
- static fromJSON(json) {
109
- if (json.$typeName !== PriceFeed.$typeName) {
110
- throw new Error("not a WithTwoGenerics json object");
111
- }
112
- return PriceFeed.fromJSONField(json);
113
- }
114
- static async fetch(client, id) {
115
- const { object } = await client.getObject({ objectId: id, include: { content: true } });
116
- if (!isPriceFeed(object.type)) {
117
- throw new Error(`object at id ${id} is not a PriceFeed object`);
118
- }
119
- return PriceFeed.fromBcs(object.content);
120
- }
121
- }
@@ -1,285 +0,0 @@
1
- import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../../../_framework/reified";
2
- import { FieldsWithTypes } from "../../../../_framework/util";
3
- import { UID } from "../../0x2/object/structs";
4
- import { PKG_V1 } from "../index";
5
- import { PriceFeed } from "../price-feed/structs";
6
- import { SuiGrpcClient } from "@mysten/sui/grpc";
7
- export declare function isPriceInfo(type: string): boolean;
8
- export interface PriceInfoFields {
9
- attestationTime: ToField<"u64">;
10
- arrivalTime: ToField<"u64">;
11
- priceFeed: ToField<PriceFeed>;
12
- }
13
- export type PriceInfoReified = Reified<PriceInfo, PriceInfoFields>;
14
- export declare class PriceInfo implements StructClass {
15
- __StructClass: true;
16
- static readonly $typeName = "0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price_info::PriceInfo";
17
- static readonly $numTypeParams = 0;
18
- static readonly $isPhantom: readonly [];
19
- readonly $typeName = "0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price_info::PriceInfo";
20
- readonly $fullTypeName: `${typeof PKG_V1}::price_info::PriceInfo`;
21
- readonly $typeArgs: [];
22
- readonly $isPhantom: readonly [];
23
- readonly attestationTime: ToField<"u64">;
24
- readonly arrivalTime: ToField<"u64">;
25
- readonly priceFeed: ToField<PriceFeed>;
26
- private constructor();
27
- static reified(): PriceInfoReified;
28
- static get r(): import("../../../../_framework/reified").StructClassReified<PriceInfo, PriceInfoFields>;
29
- static phantom(): PhantomReified<ToTypeStr<PriceInfo>>;
30
- static get p(): PhantomReified<"0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price_info::PriceInfo">;
31
- static get bcs(): import("@mysten/bcs").BcsStruct<{
32
- attestation_time: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
33
- arrival_time: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
34
- price_feed: import("@mysten/bcs").BcsStruct<{
35
- price_identifier: import("@mysten/bcs").BcsStruct<{
36
- bytes: import("@mysten/bcs").BcsType<number[], Iterable<number> & {
37
- length: number;
38
- }, string>;
39
- }, string>;
40
- price: import("@mysten/bcs").BcsStruct<{
41
- price: import("@mysten/bcs").BcsStruct<{
42
- negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
43
- magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
44
- }, string>;
45
- conf: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
46
- expo: import("@mysten/bcs").BcsStruct<{
47
- negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
48
- magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
49
- }, string>;
50
- timestamp: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
51
- }, string>;
52
- ema_price: import("@mysten/bcs").BcsStruct<{
53
- price: import("@mysten/bcs").BcsStruct<{
54
- negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
55
- magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
56
- }, string>;
57
- conf: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
58
- expo: import("@mysten/bcs").BcsStruct<{
59
- negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
60
- magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
61
- }, string>;
62
- timestamp: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
63
- }, string>;
64
- }, string>;
65
- }, string>;
66
- static fromFields(fields: Record<string, any>): PriceInfo;
67
- static fromFieldsWithTypes(item: FieldsWithTypes): PriceInfo;
68
- static fromBcs(data: Uint8Array): PriceInfo;
69
- toJSONField(): {
70
- attestationTime: string;
71
- arrivalTime: string;
72
- priceFeed: {
73
- priceIdentifier: {
74
- bytes: number[];
75
- };
76
- price: {
77
- price: {
78
- negative: boolean;
79
- magnitude: string;
80
- };
81
- conf: string;
82
- expo: {
83
- negative: boolean;
84
- magnitude: string;
85
- };
86
- timestamp: string;
87
- };
88
- emaPrice: {
89
- price: {
90
- negative: boolean;
91
- magnitude: string;
92
- };
93
- conf: string;
94
- expo: {
95
- negative: boolean;
96
- magnitude: string;
97
- };
98
- timestamp: string;
99
- };
100
- };
101
- };
102
- toJSON(): {
103
- attestationTime: string;
104
- arrivalTime: string;
105
- priceFeed: {
106
- priceIdentifier: {
107
- bytes: number[];
108
- };
109
- price: {
110
- price: {
111
- negative: boolean;
112
- magnitude: string;
113
- };
114
- conf: string;
115
- expo: {
116
- negative: boolean;
117
- magnitude: string;
118
- };
119
- timestamp: string;
120
- };
121
- emaPrice: {
122
- price: {
123
- negative: boolean;
124
- magnitude: string;
125
- };
126
- conf: string;
127
- expo: {
128
- negative: boolean;
129
- magnitude: string;
130
- };
131
- timestamp: string;
132
- };
133
- };
134
- $typeName: string;
135
- $typeArgs: [];
136
- };
137
- static fromJSONField(field: any): PriceInfo;
138
- static fromJSON(json: Record<string, any>): PriceInfo;
139
- static fetch(client: SuiGrpcClient, id: string): Promise<PriceInfo>;
140
- }
141
- export declare function isPriceInfoObject(type: string): boolean;
142
- export interface PriceInfoObjectFields {
143
- id: ToField<UID>;
144
- priceInfo: ToField<PriceInfo>;
145
- }
146
- export type PriceInfoObjectReified = Reified<PriceInfoObject, PriceInfoObjectFields>;
147
- export declare class PriceInfoObject implements StructClass {
148
- __StructClass: true;
149
- static readonly $typeName = "0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price_info::PriceInfoObject";
150
- static readonly $numTypeParams = 0;
151
- static readonly $isPhantom: readonly [];
152
- readonly $typeName = "0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price_info::PriceInfoObject";
153
- readonly $fullTypeName: `${typeof PKG_V1}::price_info::PriceInfoObject`;
154
- readonly $typeArgs: [];
155
- readonly $isPhantom: readonly [];
156
- readonly id: ToField<UID>;
157
- readonly priceInfo: ToField<PriceInfo>;
158
- private constructor();
159
- static reified(): PriceInfoObjectReified;
160
- static get r(): import("../../../../_framework/reified").StructClassReified<PriceInfoObject, PriceInfoObjectFields>;
161
- static phantom(): PhantomReified<ToTypeStr<PriceInfoObject>>;
162
- static get p(): PhantomReified<"0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price_info::PriceInfoObject">;
163
- static get bcs(): import("@mysten/bcs").BcsStruct<{
164
- id: import("@mysten/bcs").BcsStruct<{
165
- id: import("@mysten/bcs").BcsStruct<{
166
- bytes: import("@mysten/bcs").BcsType<string, string, string>;
167
- }, string>;
168
- }, string>;
169
- price_info: import("@mysten/bcs").BcsStruct<{
170
- attestation_time: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
171
- arrival_time: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
172
- price_feed: import("@mysten/bcs").BcsStruct<{
173
- price_identifier: import("@mysten/bcs").BcsStruct<{
174
- bytes: import("@mysten/bcs").BcsType<number[], Iterable<number> & {
175
- length: number;
176
- }, string>;
177
- }, string>;
178
- price: import("@mysten/bcs").BcsStruct<{
179
- price: import("@mysten/bcs").BcsStruct<{
180
- negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
181
- magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
182
- }, string>;
183
- conf: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
184
- expo: import("@mysten/bcs").BcsStruct<{
185
- negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
186
- magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
187
- }, string>;
188
- timestamp: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
189
- }, string>;
190
- ema_price: import("@mysten/bcs").BcsStruct<{
191
- price: import("@mysten/bcs").BcsStruct<{
192
- negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
193
- magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
194
- }, string>;
195
- conf: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
196
- expo: import("@mysten/bcs").BcsStruct<{
197
- negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
198
- magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
199
- }, string>;
200
- timestamp: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
201
- }, string>;
202
- }, string>;
203
- }, string>;
204
- }, string>;
205
- static fromFields(fields: Record<string, any>): PriceInfoObject;
206
- static fromFieldsWithTypes(item: FieldsWithTypes): PriceInfoObject;
207
- static fromBcs(data: Uint8Array): PriceInfoObject;
208
- toJSONField(): {
209
- id: string;
210
- priceInfo: {
211
- attestationTime: string;
212
- arrivalTime: string;
213
- priceFeed: {
214
- priceIdentifier: {
215
- bytes: number[];
216
- };
217
- price: {
218
- price: {
219
- negative: boolean;
220
- magnitude: string;
221
- };
222
- conf: string;
223
- expo: {
224
- negative: boolean;
225
- magnitude: string;
226
- };
227
- timestamp: string;
228
- };
229
- emaPrice: {
230
- price: {
231
- negative: boolean;
232
- magnitude: string;
233
- };
234
- conf: string;
235
- expo: {
236
- negative: boolean;
237
- magnitude: string;
238
- };
239
- timestamp: string;
240
- };
241
- };
242
- };
243
- };
244
- toJSON(): {
245
- id: string;
246
- priceInfo: {
247
- attestationTime: string;
248
- arrivalTime: string;
249
- priceFeed: {
250
- priceIdentifier: {
251
- bytes: number[];
252
- };
253
- price: {
254
- price: {
255
- negative: boolean;
256
- magnitude: string;
257
- };
258
- conf: string;
259
- expo: {
260
- negative: boolean;
261
- magnitude: string;
262
- };
263
- timestamp: string;
264
- };
265
- emaPrice: {
266
- price: {
267
- negative: boolean;
268
- magnitude: string;
269
- };
270
- conf: string;
271
- expo: {
272
- negative: boolean;
273
- magnitude: string;
274
- };
275
- timestamp: string;
276
- };
277
- };
278
- };
279
- $typeName: string;
280
- $typeArgs: [];
281
- };
282
- static fromJSONField(field: any): PriceInfoObject;
283
- static fromJSON(json: Record<string, any>): PriceInfoObject;
284
- static fetch(client: SuiGrpcClient, id: string): Promise<PriceInfoObject>;
285
- }