@suilend/sdk 1.1.99 → 2.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.
- package/_generated/_dependencies/source/0x1/ascii/structs.d.ts +7 -7
- package/_generated/_dependencies/source/0x1/ascii/structs.js +35 -75
- package/_generated/_dependencies/source/0x1/index.js +3 -6
- package/_generated/_dependencies/source/0x1/option/structs.d.ts +3 -3
- package/_generated/_dependencies/source/0x1/option/structs.js +31 -69
- package/_generated/_dependencies/source/0x1/type-name/structs.d.ts +5 -5
- package/_generated/_dependencies/source/0x1/type-name/structs.js +20 -25
- package/_generated/_dependencies/source/0x2/bag/structs.d.ts +7 -7
- package/_generated/_dependencies/source/0x2/bag/structs.js +24 -29
- package/_generated/_dependencies/source/0x2/balance/structs.d.ts +7 -7
- package/_generated/_dependencies/source/0x2/balance/structs.js +49 -56
- package/_generated/_dependencies/source/0x2/index.js +3 -6
- package/_generated/_dependencies/source/0x2/object/structs.d.ts +8 -8
- package/_generated/_dependencies/source/0x2/object/structs.js +34 -41
- package/_generated/_dependencies/source/0x2/object-table/structs.d.ts +7 -7
- package/_generated/_dependencies/source/0x2/object-table/structs.js +31 -36
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.d.ts +5 -5
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.js +23 -28
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/index.js +4 -7
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.d.ts +11 -11
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.js +32 -37
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.d.ts +23 -23
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.js +29 -34
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.d.ts +4 -4
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js +21 -59
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.d.ts +55 -55
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.js +46 -53
- package/_generated/_framework/reified.d.ts +2 -2
- package/_generated/_framework/reified.js +27 -40
- package/_generated/_framework/util.js +26 -40
- package/_generated/_framework/vector.d.ts +4 -4
- package/_generated/_framework/vector.js +16 -21
- package/_generated/suilend/cell/structs.d.ts +4 -4
- package/_generated/suilend/cell/structs.js +31 -36
- package/_generated/suilend/decimal/structs.d.ts +4 -4
- package/_generated/suilend/decimal/structs.js +19 -24
- package/_generated/suilend/index.js +8 -12
- package/_generated/suilend/lending-market/functions.d.ts +1 -0
- package/_generated/suilend/lending-market/functions.js +271 -302
- package/_generated/suilend/lending-market/structs.d.ts +146 -146
- package/_generated/suilend/lending-market/structs.js +549 -617
- package/_generated/suilend/lending-market-registry/functions.js +7 -11
- package/_generated/suilend/liquidity-mining/structs.d.ts +50 -50
- package/_generated/suilend/liquidity-mining/structs.js +159 -205
- package/_generated/suilend/obligation/structs.d.ts +106 -106
- package/_generated/suilend/obligation/structs.js +313 -363
- package/_generated/suilend/rate-limiter/functions.js +23 -31
- package/_generated/suilend/rate-limiter/structs.d.ts +15 -15
- package/_generated/suilend/rate-limiter/structs.js +49 -56
- package/_generated/suilend/reserve/structs.d.ts +139 -139
- package/_generated/suilend/reserve/structs.js +397 -451
- package/_generated/suilend/reserve-config/functions.js +149 -190
- package/_generated/suilend/reserve-config/structs.d.ts +33 -33
- package/_generated/suilend/reserve-config/structs.js +109 -149
- package/api/events.js +1 -5
- package/api/index.js +1 -17
- package/client.d.ts +10 -10
- package/client.js +118 -128
- package/index.js +7 -23
- package/lib/constants.js +3 -9
- package/lib/index.js +5 -21
- package/lib/initialize.d.ts +3 -3
- package/lib/initialize.js +103 -140
- package/lib/liquidityMining.d.ts +3 -3
- package/lib/liquidityMining.js +57 -72
- package/lib/pyth.js +9 -14
- package/lib/strategyOwnerCap.js +106 -119
- package/lib/transactions.js +2 -7
- package/lib/types.js +4 -7
- package/mmt.js +2 -5
- package/package.json +1 -1
- package/parsers/apiReserveAssetDataEvent.js +25 -33
- package/parsers/index.js +5 -21
- package/parsers/lendingMarket.d.ts +1 -1
- package/parsers/lendingMarket.js +12 -19
- package/parsers/obligation.js +19 -26
- package/parsers/rateLimiter.js +11 -19
- package/parsers/reserve.d.ts +1 -1
- package/parsers/reserve.js +42 -85
- package/strategies.d.ts +11 -11
- package/strategies.js +547 -586
- package/swap/index.js +2 -18
- package/swap/quote.js +57 -65
- package/swap/transaction.d.ts +2 -2
- package/swap/transaction.js +40 -35
- package/utils/events.d.ts +3 -3
- package/utils/events.js +18 -35
- package/utils/index.js +16 -40
- package/utils/obligation.d.ts +4 -4
- package/utils/obligation.js +17 -60
- package/utils/simulate.js +118 -143
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,26 +7,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const index_1 = require("../index");
|
|
18
|
-
const bcs_1 = require("@mysten/sui/bcs");
|
|
19
|
-
const utils_1 = require("@mysten/sui/utils");
|
|
10
|
+
import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified";
|
|
11
|
+
import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
|
|
12
|
+
import { I64 } from "../i64/structs";
|
|
13
|
+
import { PKG_V1 } from "../index";
|
|
14
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
15
|
+
import { fromBase64 } from "@mysten/sui/utils";
|
|
20
16
|
/* ============================== Price =============================== */
|
|
21
|
-
function isPrice(type) {
|
|
22
|
-
type =
|
|
23
|
-
return type === `${
|
|
17
|
+
export function isPrice(type) {
|
|
18
|
+
type = compressSuiType(type);
|
|
19
|
+
return type === `${PKG_V1}::price::Price`;
|
|
24
20
|
}
|
|
25
|
-
class Price {
|
|
21
|
+
export class Price {
|
|
26
22
|
constructor(typeArgs, fields) {
|
|
27
23
|
this.__StructClass = true;
|
|
28
24
|
this.$typeName = Price.$typeName;
|
|
29
25
|
this.$isPhantom = Price.$isPhantom;
|
|
30
|
-
this.$fullTypeName =
|
|
26
|
+
this.$fullTypeName = composeSuiType(Price.$typeName, ...typeArgs);
|
|
31
27
|
this.$typeArgs = typeArgs;
|
|
32
28
|
this.price = fields.price;
|
|
33
29
|
this.conf = fields.conf;
|
|
@@ -37,7 +33,7 @@ class Price {
|
|
|
37
33
|
static reified() {
|
|
38
34
|
return {
|
|
39
35
|
typeName: Price.$typeName,
|
|
40
|
-
fullTypeName:
|
|
36
|
+
fullTypeName: composeSuiType(Price.$typeName, ...[]),
|
|
41
37
|
typeArgs: [],
|
|
42
38
|
isPhantom: Price.$isPhantom,
|
|
43
39
|
reifiedTypeArgs: [],
|
|
@@ -60,25 +56,25 @@ class Price {
|
|
|
60
56
|
return Price.reified();
|
|
61
57
|
}
|
|
62
58
|
static phantom() {
|
|
63
|
-
return
|
|
59
|
+
return phantom(Price.reified());
|
|
64
60
|
}
|
|
65
61
|
static get p() {
|
|
66
62
|
return Price.phantom();
|
|
67
63
|
}
|
|
68
64
|
static get bcs() {
|
|
69
|
-
return
|
|
70
|
-
price:
|
|
71
|
-
conf:
|
|
72
|
-
expo:
|
|
73
|
-
timestamp:
|
|
65
|
+
return bcs.struct("Price", {
|
|
66
|
+
price: I64.bcs,
|
|
67
|
+
conf: bcs.u64(),
|
|
68
|
+
expo: I64.bcs,
|
|
69
|
+
timestamp: bcs.u64(),
|
|
74
70
|
});
|
|
75
71
|
}
|
|
76
72
|
static fromFields(fields) {
|
|
77
73
|
return Price.reified().new({
|
|
78
|
-
price:
|
|
79
|
-
conf:
|
|
80
|
-
expo:
|
|
81
|
-
timestamp:
|
|
74
|
+
price: decodeFromFields(I64.reified(), fields.price),
|
|
75
|
+
conf: decodeFromFields("u64", fields.conf),
|
|
76
|
+
expo: decodeFromFields(I64.reified(), fields.expo),
|
|
77
|
+
timestamp: decodeFromFields("u64", fields.timestamp),
|
|
82
78
|
});
|
|
83
79
|
}
|
|
84
80
|
static fromFieldsWithTypes(item) {
|
|
@@ -86,10 +82,10 @@ class Price {
|
|
|
86
82
|
throw new Error("not a Price type");
|
|
87
83
|
}
|
|
88
84
|
return Price.reified().new({
|
|
89
|
-
price:
|
|
90
|
-
conf:
|
|
91
|
-
expo:
|
|
92
|
-
timestamp:
|
|
85
|
+
price: decodeFromFieldsWithTypes(I64.reified(), item.fields.price),
|
|
86
|
+
conf: decodeFromFieldsWithTypes("u64", item.fields.conf),
|
|
87
|
+
expo: decodeFromFieldsWithTypes(I64.reified(), item.fields.expo),
|
|
88
|
+
timestamp: decodeFromFieldsWithTypes("u64", item.fields.timestamp),
|
|
93
89
|
});
|
|
94
90
|
}
|
|
95
91
|
static fromBcs(data) {
|
|
@@ -108,10 +104,10 @@ class Price {
|
|
|
108
104
|
}
|
|
109
105
|
static fromJSONField(field) {
|
|
110
106
|
return Price.reified().new({
|
|
111
|
-
price:
|
|
112
|
-
conf:
|
|
113
|
-
expo:
|
|
114
|
-
timestamp:
|
|
107
|
+
price: decodeFromJSONField(I64.reified(), field.price),
|
|
108
|
+
conf: decodeFromJSONField("u64", field.conf),
|
|
109
|
+
expo: decodeFromJSONField(I64.reified(), field.expo),
|
|
110
|
+
timestamp: decodeFromJSONField("u64", field.timestamp),
|
|
115
111
|
});
|
|
116
112
|
}
|
|
117
113
|
static fromJSON(json) {
|
|
@@ -134,7 +130,7 @@ class Price {
|
|
|
134
130
|
if (data.bcs.dataType !== "moveObject" || !isPrice(data.bcs.type)) {
|
|
135
131
|
throw new Error(`object at is not a Price object`);
|
|
136
132
|
}
|
|
137
|
-
return Price.fromBcs((
|
|
133
|
+
return Price.fromBcs(fromBase64(data.bcs.bcsBytes));
|
|
138
134
|
}
|
|
139
135
|
if (data.content) {
|
|
140
136
|
return Price.fromSuiParsedData(data.content);
|
|
@@ -156,7 +152,6 @@ class Price {
|
|
|
156
152
|
});
|
|
157
153
|
}
|
|
158
154
|
}
|
|
159
|
-
|
|
160
|
-
Price.$typeName = `${index_1.PKG_V1}::price::Price`;
|
|
155
|
+
Price.$typeName = `${PKG_V1}::price::Price`;
|
|
161
156
|
Price.$numTypeParams = 0;
|
|
162
157
|
Price.$isPhantom = [];
|
|
@@ -3,7 +3,7 @@ import { FieldsWithTypes } from "../../../../_framework/util";
|
|
|
3
3
|
import { PKG_V1 } from "../index";
|
|
4
4
|
import { PriceIdentifier } from "../price-identifier/structs";
|
|
5
5
|
import { Price } from "../price/structs";
|
|
6
|
-
import {
|
|
6
|
+
import { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
|
|
7
7
|
export declare function isPriceFeed(type: string): boolean;
|
|
8
8
|
export interface PriceFeedFields {
|
|
9
9
|
priceIdentifier: ToField<PriceIdentifier>;
|
|
@@ -28,35 +28,35 @@ export declare class PriceFeed implements StructClass {
|
|
|
28
28
|
static get r(): import("../../../../_framework/reified").StructClassReified<PriceFeed, PriceFeedFields>;
|
|
29
29
|
static phantom(): PhantomReified<ToTypeStr<PriceFeed>>;
|
|
30
30
|
static get p(): PhantomReified<"0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price_feed::PriceFeed">;
|
|
31
|
-
static get bcs(): import("@mysten/
|
|
32
|
-
price_identifier: import("@mysten/
|
|
33
|
-
bytes: import("@mysten/
|
|
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
34
|
length: number;
|
|
35
35
|
}, string>;
|
|
36
36
|
}, string>;
|
|
37
|
-
price: import("@mysten/
|
|
38
|
-
price: import("@mysten/
|
|
39
|
-
negative: import("@mysten/
|
|
40
|
-
magnitude: import("@mysten/
|
|
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
41
|
}, string>;
|
|
42
|
-
conf: import("@mysten/
|
|
43
|
-
expo: import("@mysten/
|
|
44
|
-
negative: import("@mysten/
|
|
45
|
-
magnitude: import("@mysten/
|
|
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
46
|
}, string>;
|
|
47
|
-
timestamp: import("@mysten/
|
|
47
|
+
timestamp: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
48
48
|
}, string>;
|
|
49
|
-
ema_price: import("@mysten/
|
|
50
|
-
price: import("@mysten/
|
|
51
|
-
negative: import("@mysten/
|
|
52
|
-
magnitude: import("@mysten/
|
|
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
53
|
}, string>;
|
|
54
|
-
conf: import("@mysten/
|
|
55
|
-
expo: import("@mysten/
|
|
56
|
-
negative: import("@mysten/
|
|
57
|
-
magnitude: import("@mysten/
|
|
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
58
|
}, string>;
|
|
59
|
-
timestamp: import("@mysten/
|
|
59
|
+
timestamp: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
60
60
|
}, string>;
|
|
61
61
|
}, string>;
|
|
62
62
|
static fromFields(fields: Record<string, any>): PriceFeed;
|
|
@@ -126,5 +126,5 @@ export declare class PriceFeed implements StructClass {
|
|
|
126
126
|
static fromJSON(json: Record<string, any>): PriceFeed;
|
|
127
127
|
static fromSuiParsedData(content: SuiParsedData): PriceFeed;
|
|
128
128
|
static fromSuiObjectData(data: SuiObjectData): PriceFeed;
|
|
129
|
-
static fetch(client:
|
|
129
|
+
static fetch(client: SuiJsonRpcClient, id: string): Promise<PriceFeed>;
|
|
130
130
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,27 +7,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const structs_2 = require("../price/structs");
|
|
19
|
-
const bcs_1 = require("@mysten/sui/bcs");
|
|
20
|
-
const utils_1 = require("@mysten/sui/utils");
|
|
10
|
+
import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified";
|
|
11
|
+
import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
|
|
12
|
+
import { PKG_V1 } from "../index";
|
|
13
|
+
import { PriceIdentifier } from "../price-identifier/structs";
|
|
14
|
+
import { Price } from "../price/structs";
|
|
15
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
16
|
+
import { fromBase64 } from "@mysten/sui/utils";
|
|
21
17
|
/* ============================== PriceFeed =============================== */
|
|
22
|
-
function isPriceFeed(type) {
|
|
23
|
-
type =
|
|
24
|
-
return type === `${
|
|
18
|
+
export function isPriceFeed(type) {
|
|
19
|
+
type = compressSuiType(type);
|
|
20
|
+
return type === `${PKG_V1}::price_feed::PriceFeed`;
|
|
25
21
|
}
|
|
26
|
-
class PriceFeed {
|
|
22
|
+
export class PriceFeed {
|
|
27
23
|
constructor(typeArgs, fields) {
|
|
28
24
|
this.__StructClass = true;
|
|
29
25
|
this.$typeName = PriceFeed.$typeName;
|
|
30
26
|
this.$isPhantom = PriceFeed.$isPhantom;
|
|
31
|
-
this.$fullTypeName =
|
|
27
|
+
this.$fullTypeName = composeSuiType(PriceFeed.$typeName, ...typeArgs);
|
|
32
28
|
this.$typeArgs = typeArgs;
|
|
33
29
|
this.priceIdentifier = fields.priceIdentifier;
|
|
34
30
|
this.price = fields.price;
|
|
@@ -37,7 +33,7 @@ class PriceFeed {
|
|
|
37
33
|
static reified() {
|
|
38
34
|
return {
|
|
39
35
|
typeName: PriceFeed.$typeName,
|
|
40
|
-
fullTypeName:
|
|
36
|
+
fullTypeName: composeSuiType(PriceFeed.$typeName, ...[]),
|
|
41
37
|
typeArgs: [],
|
|
42
38
|
isPhantom: PriceFeed.$isPhantom,
|
|
43
39
|
reifiedTypeArgs: [],
|
|
@@ -60,23 +56,23 @@ class PriceFeed {
|
|
|
60
56
|
return PriceFeed.reified();
|
|
61
57
|
}
|
|
62
58
|
static phantom() {
|
|
63
|
-
return
|
|
59
|
+
return phantom(PriceFeed.reified());
|
|
64
60
|
}
|
|
65
61
|
static get p() {
|
|
66
62
|
return PriceFeed.phantom();
|
|
67
63
|
}
|
|
68
64
|
static get bcs() {
|
|
69
|
-
return
|
|
70
|
-
price_identifier:
|
|
71
|
-
price:
|
|
72
|
-
ema_price:
|
|
65
|
+
return bcs.struct("PriceFeed", {
|
|
66
|
+
price_identifier: PriceIdentifier.bcs,
|
|
67
|
+
price: Price.bcs,
|
|
68
|
+
ema_price: Price.bcs,
|
|
73
69
|
});
|
|
74
70
|
}
|
|
75
71
|
static fromFields(fields) {
|
|
76
72
|
return PriceFeed.reified().new({
|
|
77
|
-
priceIdentifier:
|
|
78
|
-
price:
|
|
79
|
-
emaPrice:
|
|
73
|
+
priceIdentifier: decodeFromFields(PriceIdentifier.reified(), fields.price_identifier),
|
|
74
|
+
price: decodeFromFields(Price.reified(), fields.price),
|
|
75
|
+
emaPrice: decodeFromFields(Price.reified(), fields.ema_price),
|
|
80
76
|
});
|
|
81
77
|
}
|
|
82
78
|
static fromFieldsWithTypes(item) {
|
|
@@ -84,9 +80,9 @@ class PriceFeed {
|
|
|
84
80
|
throw new Error("not a PriceFeed type");
|
|
85
81
|
}
|
|
86
82
|
return PriceFeed.reified().new({
|
|
87
|
-
priceIdentifier:
|
|
88
|
-
price:
|
|
89
|
-
emaPrice:
|
|
83
|
+
priceIdentifier: decodeFromFieldsWithTypes(PriceIdentifier.reified(), item.fields.price_identifier),
|
|
84
|
+
price: decodeFromFieldsWithTypes(Price.reified(), item.fields.price),
|
|
85
|
+
emaPrice: decodeFromFieldsWithTypes(Price.reified(), item.fields.ema_price),
|
|
90
86
|
});
|
|
91
87
|
}
|
|
92
88
|
static fromBcs(data) {
|
|
@@ -104,9 +100,9 @@ class PriceFeed {
|
|
|
104
100
|
}
|
|
105
101
|
static fromJSONField(field) {
|
|
106
102
|
return PriceFeed.reified().new({
|
|
107
|
-
priceIdentifier:
|
|
108
|
-
price:
|
|
109
|
-
emaPrice:
|
|
103
|
+
priceIdentifier: decodeFromJSONField(PriceIdentifier.reified(), field.priceIdentifier),
|
|
104
|
+
price: decodeFromJSONField(Price.reified(), field.price),
|
|
105
|
+
emaPrice: decodeFromJSONField(Price.reified(), field.emaPrice),
|
|
110
106
|
});
|
|
111
107
|
}
|
|
112
108
|
static fromJSON(json) {
|
|
@@ -129,7 +125,7 @@ class PriceFeed {
|
|
|
129
125
|
if (data.bcs.dataType !== "moveObject" || !isPriceFeed(data.bcs.type)) {
|
|
130
126
|
throw new Error(`object at is not a PriceFeed object`);
|
|
131
127
|
}
|
|
132
|
-
return PriceFeed.fromBcs((
|
|
128
|
+
return PriceFeed.fromBcs(fromBase64(data.bcs.bcsBytes));
|
|
133
129
|
}
|
|
134
130
|
if (data.content) {
|
|
135
131
|
return PriceFeed.fromSuiParsedData(data.content);
|
|
@@ -151,7 +147,6 @@ class PriceFeed {
|
|
|
151
147
|
});
|
|
152
148
|
}
|
|
153
149
|
}
|
|
154
|
-
|
|
155
|
-
PriceFeed.$typeName = `${index_1.PKG_V1}::price_feed::PriceFeed`;
|
|
150
|
+
PriceFeed.$typeName = `${PKG_V1}::price_feed::PriceFeed`;
|
|
156
151
|
PriceFeed.$numTypeParams = 0;
|
|
157
152
|
PriceFeed.$isPhantom = [];
|
|
@@ -3,7 +3,7 @@ import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../
|
|
|
3
3
|
import { FieldsWithTypes } from "../../../../_framework/util";
|
|
4
4
|
import { Vector } from "../../../../_framework/vector";
|
|
5
5
|
import { PKG_V1 } from "../index";
|
|
6
|
-
import {
|
|
6
|
+
import { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
|
|
7
7
|
export declare function isPriceIdentifier(type: string): boolean;
|
|
8
8
|
export interface PriceIdentifierFields {
|
|
9
9
|
bytes: ToField<Vector<"u8">>;
|
|
@@ -24,8 +24,8 @@ export declare class PriceIdentifier implements StructClass {
|
|
|
24
24
|
static get r(): reified.StructClassReified<PriceIdentifier, PriceIdentifierFields>;
|
|
25
25
|
static phantom(): PhantomReified<ToTypeStr<PriceIdentifier>>;
|
|
26
26
|
static get p(): reified.PhantomReified<"0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price_identifier::PriceIdentifier">;
|
|
27
|
-
static get bcs(): import("@mysten/
|
|
28
|
-
bytes: import("@mysten/
|
|
27
|
+
static get bcs(): import("@mysten/bcs").BcsStruct<{
|
|
28
|
+
bytes: import("@mysten/bcs").BcsType<number[], Iterable<number> & {
|
|
29
29
|
length: number;
|
|
30
30
|
}, string>;
|
|
31
31
|
}, string>;
|
|
@@ -44,5 +44,5 @@ export declare class PriceIdentifier implements StructClass {
|
|
|
44
44
|
static fromJSON(json: Record<string, any>): PriceIdentifier;
|
|
45
45
|
static fromSuiParsedData(content: SuiParsedData): PriceIdentifier;
|
|
46
46
|
static fromSuiObjectData(data: SuiObjectData): PriceIdentifier;
|
|
47
|
-
static fetch(client:
|
|
47
|
+
static fetch(client: SuiJsonRpcClient, id: string): Promise<PriceIdentifier>;
|
|
48
48
|
}
|
|
@@ -1,37 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -41,33 +7,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
41
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
8
|
});
|
|
43
9
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const index_1 = require("../index");
|
|
51
|
-
const bcs_1 = require("@mysten/sui/bcs");
|
|
52
|
-
const utils_1 = require("@mysten/sui/utils");
|
|
10
|
+
import * as reified from "../../../../_framework/reified";
|
|
11
|
+
import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, fieldToJSON, phantom, } from "../../../../_framework/reified";
|
|
12
|
+
import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
|
|
13
|
+
import { PKG_V1 } from "../index";
|
|
14
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
15
|
+
import { fromBase64 } from "@mysten/sui/utils";
|
|
53
16
|
/* ============================== PriceIdentifier =============================== */
|
|
54
|
-
function isPriceIdentifier(type) {
|
|
55
|
-
type =
|
|
56
|
-
return type === `${
|
|
17
|
+
export function isPriceIdentifier(type) {
|
|
18
|
+
type = compressSuiType(type);
|
|
19
|
+
return type === `${PKG_V1}::price_identifier::PriceIdentifier`;
|
|
57
20
|
}
|
|
58
|
-
class PriceIdentifier {
|
|
21
|
+
export class PriceIdentifier {
|
|
59
22
|
constructor(typeArgs, fields) {
|
|
60
23
|
this.__StructClass = true;
|
|
61
24
|
this.$typeName = PriceIdentifier.$typeName;
|
|
62
25
|
this.$isPhantom = PriceIdentifier.$isPhantom;
|
|
63
|
-
this.$fullTypeName =
|
|
26
|
+
this.$fullTypeName = composeSuiType(PriceIdentifier.$typeName, ...typeArgs);
|
|
64
27
|
this.$typeArgs = typeArgs;
|
|
65
28
|
this.bytes = fields.bytes;
|
|
66
29
|
}
|
|
67
30
|
static reified() {
|
|
68
31
|
return {
|
|
69
32
|
typeName: PriceIdentifier.$typeName,
|
|
70
|
-
fullTypeName:
|
|
33
|
+
fullTypeName: composeSuiType(PriceIdentifier.$typeName, ...[]),
|
|
71
34
|
typeArgs: [],
|
|
72
35
|
isPhantom: PriceIdentifier.$isPhantom,
|
|
73
36
|
reifiedTypeArgs: [],
|
|
@@ -90,19 +53,19 @@ class PriceIdentifier {
|
|
|
90
53
|
return PriceIdentifier.reified();
|
|
91
54
|
}
|
|
92
55
|
static phantom() {
|
|
93
|
-
return
|
|
56
|
+
return phantom(PriceIdentifier.reified());
|
|
94
57
|
}
|
|
95
58
|
static get p() {
|
|
96
59
|
return PriceIdentifier.phantom();
|
|
97
60
|
}
|
|
98
61
|
static get bcs() {
|
|
99
|
-
return
|
|
100
|
-
bytes:
|
|
62
|
+
return bcs.struct("PriceIdentifier", {
|
|
63
|
+
bytes: bcs.vector(bcs.u8()),
|
|
101
64
|
});
|
|
102
65
|
}
|
|
103
66
|
static fromFields(fields) {
|
|
104
67
|
return PriceIdentifier.reified().new({
|
|
105
|
-
bytes:
|
|
68
|
+
bytes: decodeFromFields(reified.vector("u8"), fields.bytes),
|
|
106
69
|
});
|
|
107
70
|
}
|
|
108
71
|
static fromFieldsWithTypes(item) {
|
|
@@ -110,7 +73,7 @@ class PriceIdentifier {
|
|
|
110
73
|
throw new Error("not a PriceIdentifier type");
|
|
111
74
|
}
|
|
112
75
|
return PriceIdentifier.reified().new({
|
|
113
|
-
bytes:
|
|
76
|
+
bytes: decodeFromFieldsWithTypes(reified.vector("u8"), item.fields.bytes),
|
|
114
77
|
});
|
|
115
78
|
}
|
|
116
79
|
static fromBcs(data) {
|
|
@@ -118,7 +81,7 @@ class PriceIdentifier {
|
|
|
118
81
|
}
|
|
119
82
|
toJSONField() {
|
|
120
83
|
return {
|
|
121
|
-
bytes:
|
|
84
|
+
bytes: fieldToJSON(`vector<u8>`, this.bytes),
|
|
122
85
|
};
|
|
123
86
|
}
|
|
124
87
|
toJSON() {
|
|
@@ -126,7 +89,7 @@ class PriceIdentifier {
|
|
|
126
89
|
}
|
|
127
90
|
static fromJSONField(field) {
|
|
128
91
|
return PriceIdentifier.reified().new({
|
|
129
|
-
bytes:
|
|
92
|
+
bytes: decodeFromJSONField(reified.vector("u8"), field.bytes),
|
|
130
93
|
});
|
|
131
94
|
}
|
|
132
95
|
static fromJSON(json) {
|
|
@@ -150,7 +113,7 @@ class PriceIdentifier {
|
|
|
150
113
|
!isPriceIdentifier(data.bcs.type)) {
|
|
151
114
|
throw new Error(`object at is not a PriceIdentifier object`);
|
|
152
115
|
}
|
|
153
|
-
return PriceIdentifier.fromBcs((
|
|
116
|
+
return PriceIdentifier.fromBcs(fromBase64(data.bcs.bcsBytes));
|
|
154
117
|
}
|
|
155
118
|
if (data.content) {
|
|
156
119
|
return PriceIdentifier.fromSuiParsedData(data.content);
|
|
@@ -172,7 +135,6 @@ class PriceIdentifier {
|
|
|
172
135
|
});
|
|
173
136
|
}
|
|
174
137
|
}
|
|
175
|
-
|
|
176
|
-
PriceIdentifier.$typeName = `${index_1.PKG_V1}::price_identifier::PriceIdentifier`;
|
|
138
|
+
PriceIdentifier.$typeName = `${PKG_V1}::price_identifier::PriceIdentifier`;
|
|
177
139
|
PriceIdentifier.$numTypeParams = 0;
|
|
178
140
|
PriceIdentifier.$isPhantom = [];
|