stable-layer-sdk 0.0.3 → 1.0.1
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/client.test.d.ts +1 -0
- package/dist/client.test.js +146 -0
- package/dist/generated/stable_layer/deps/bucket_v2_framework/liability.d.ts +11 -0
- package/dist/generated/stable_layer/deps/bucket_v2_framework/liability.js +13 -0
- package/dist/generated/stable_layer/deps/bucket_v2_framework/sheet.d.ts +57 -0
- package/dist/generated/stable_layer/deps/bucket_v2_framework/sheet.js +16 -0
- package/dist/generated/stable_layer/deps/std/type_name.d.ts +17 -0
- package/dist/generated/stable_layer/deps/std/type_name.js +19 -0
- package/dist/generated/stable_layer/deps/sui/balance.d.ts +12 -0
- package/dist/generated/stable_layer/deps/sui/balance.js +14 -0
- package/dist/generated/stable_layer/deps/sui/coin.d.ts +16 -0
- package/dist/generated/stable_layer/deps/sui/coin.js +15 -0
- package/dist/generated/stable_layer/deps/sui/object.d.ts +8 -0
- package/dist/generated/stable_layer/deps/sui/object.js +10 -0
- package/dist/generated/stable_layer/deps/sui/vec_map.d.ts +36 -0
- package/dist/generated/stable_layer/deps/sui/vec_map.js +27 -0
- package/dist/generated/stable_layer/deps/sui/vec_set.d.ts +20 -0
- package/dist/generated/stable_layer/deps/sui/vec_set.js +19 -0
- package/dist/generated/stable_layer/stable_layer.d.ts +427 -0
- package/dist/generated/stable_layer/stable_layer.js +365 -0
- package/dist/generated/stable_vault_farm/deps/bucket_v2_framework/liability.d.ts +11 -0
- package/dist/generated/stable_vault_farm/deps/bucket_v2_framework/liability.js +13 -0
- package/dist/generated/stable_vault_farm/deps/bucket_v2_framework/sheet.d.ts +57 -0
- package/dist/generated/stable_vault_farm/deps/bucket_v2_framework/sheet.js +16 -0
- package/dist/generated/stable_vault_farm/deps/std/type_name.d.ts +17 -0
- package/dist/generated/stable_vault_farm/deps/std/type_name.js +19 -0
- package/dist/generated/stable_vault_farm/deps/sui/balance.d.ts +12 -0
- package/dist/generated/stable_vault_farm/deps/sui/balance.js +14 -0
- package/dist/generated/stable_vault_farm/deps/sui/object.d.ts +8 -0
- package/dist/generated/stable_vault_farm/deps/sui/object.js +10 -0
- package/dist/generated/stable_vault_farm/deps/sui/table.d.ts +31 -0
- package/dist/generated/stable_vault_farm/deps/sui/table.js +32 -0
- package/dist/generated/stable_vault_farm/deps/sui/vec_map.d.ts +36 -0
- package/dist/generated/stable_vault_farm/deps/sui/vec_map.js +27 -0
- package/dist/generated/stable_vault_farm/deps/sui/vec_set.d.ts +20 -0
- package/dist/generated/stable_vault_farm/deps/sui/vec_set.js +19 -0
- package/dist/generated/stable_vault_farm/stable_vault_farm.d.ts +242 -0
- package/dist/generated/stable_vault_farm/stable_vault_farm.js +163 -0
- package/dist/generated/utils/index.d.ts +11 -0
- package/dist/generated/utils/index.js +131 -0
- package/dist/generated/yield_usdb/buffer.d.ts +137 -0
- package/dist/generated/yield_usdb/buffer.js +157 -0
- package/dist/generated/yield_usdb/deps/bucket_v2_framework/account.d.ts +11 -0
- package/dist/generated/yield_usdb/deps/bucket_v2_framework/account.js +12 -0
- package/dist/generated/yield_usdb/deps/bucket_v2_framework/double.d.ts +8 -0
- package/dist/generated/yield_usdb/deps/bucket_v2_framework/double.js +10 -0
- package/dist/generated/yield_usdb/deps/sui/balance.d.ts +15 -0
- package/dist/generated/yield_usdb/deps/sui/balance.js +17 -0
- package/dist/generated/yield_usdb/deps/sui/coin.d.ts +16 -0
- package/dist/generated/yield_usdb/deps/sui/coin.js +15 -0
- package/dist/generated/yield_usdb/deps/sui/object.d.ts +8 -0
- package/dist/generated/yield_usdb/deps/sui/object.js +10 -0
- package/dist/generated/yield_usdb/deps/sui/vec_set.d.ts +20 -0
- package/dist/generated/yield_usdb/deps/sui/vec_set.js +19 -0
- package/dist/generated/yield_usdb/yield_usdb.d.ts +475 -0
- package/dist/generated/yield_usdb/yield_usdb.js +444 -0
- package/dist/index.d.ts +16 -19
- package/dist/index.js +235 -30
- package/dist/interface.d.ts +25 -0
- package/dist/interface.js +1 -0
- package/dist/libs/constants.d.ts +15 -0
- package/dist/libs/constants.js +18 -0
- package/package.json +19 -4
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
5
|
+
import { MoveStruct } from '../../../utils/index.js';
|
|
6
|
+
const $moduleName = '0x2::vec_map';
|
|
7
|
+
/** An entry in the map */
|
|
8
|
+
export function Entry(...typeParameters) {
|
|
9
|
+
return new MoveStruct({ name: `${$moduleName}::Entry<${typeParameters[0].name}, ${typeParameters[1].name}>`, fields: {
|
|
10
|
+
key: typeParameters[0],
|
|
11
|
+
value: typeParameters[1]
|
|
12
|
+
} });
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A map data structure backed by a vector. The map is guaranteed not to contain
|
|
16
|
+
* duplicate keys, but entries are _not_ sorted by key--entries are included in
|
|
17
|
+
* insertion order. All operations are O(N) in the size of the map--the intention
|
|
18
|
+
* of this data structure is only to provide the convenience of programming against
|
|
19
|
+
* a map API. Large maps should use handwritten parent/child relationships instead.
|
|
20
|
+
* Maps that need sorted iteration rather than insertion order iteration should
|
|
21
|
+
* also be handwritten.
|
|
22
|
+
*/
|
|
23
|
+
export function VecMap(...typeParameters) {
|
|
24
|
+
return new MoveStruct({ name: `${$moduleName}::VecMap<${typeParameters[0].name}, ${typeParameters[1].name}>`, fields: {
|
|
25
|
+
contents: bcs.vector(Entry(typeParameters[0], typeParameters[1]))
|
|
26
|
+
} });
|
|
27
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { type BcsType } from '@mysten/sui/bcs';
|
|
5
|
+
import { MoveStruct } from '../../../utils/index.js';
|
|
6
|
+
/**
|
|
7
|
+
* A set data structure backed by a vector. The set is guaranteed not to contain
|
|
8
|
+
* duplicate keys. All operations are O(N) in the size of the set
|
|
9
|
+
*
|
|
10
|
+
* - the intention of this data structure is only to provide the convenience of
|
|
11
|
+
* programming against a set API. Sets that need sorted iteration rather than
|
|
12
|
+
* insertion order iteration should be handwritten.
|
|
13
|
+
*/
|
|
14
|
+
export declare function VecSet<K extends BcsType<any>>(...typeParameters: [
|
|
15
|
+
K
|
|
16
|
+
]): MoveStruct<{
|
|
17
|
+
contents: BcsType<import("@mysten/bcs").InferBcsType<K>[], Iterable<import("@mysten/bcs").InferBcsInput<K>> & {
|
|
18
|
+
length: number;
|
|
19
|
+
}, string>;
|
|
20
|
+
}, `0x2::vec_set::VecSet<${K["name"]}>`>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
5
|
+
import { MoveStruct } from '../../../utils/index.js';
|
|
6
|
+
const $moduleName = '0x2::vec_set';
|
|
7
|
+
/**
|
|
8
|
+
* A set data structure backed by a vector. The set is guaranteed not to contain
|
|
9
|
+
* duplicate keys. All operations are O(N) in the size of the set
|
|
10
|
+
*
|
|
11
|
+
* - the intention of this data structure is only to provide the convenience of
|
|
12
|
+
* programming against a set API. Sets that need sorted iteration rather than
|
|
13
|
+
* insertion order iteration should be handwritten.
|
|
14
|
+
*/
|
|
15
|
+
export function VecSet(...typeParameters) {
|
|
16
|
+
return new MoveStruct({ name: `${$moduleName}::VecSet<${typeParameters[0].name}>`, fields: {
|
|
17
|
+
contents: bcs.vector(typeParameters[0])
|
|
18
|
+
} });
|
|
19
|
+
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { MoveStruct, type RawTransactionArgument } from '../utils/index.js';
|
|
5
|
+
import { type Transaction } from '@mysten/sui/transactions';
|
|
6
|
+
export declare const Claim: MoveStruct<{
|
|
7
|
+
reward_type: import("@mysten/bcs").BcsType<string, string, "string">;
|
|
8
|
+
amount: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
9
|
+
claimer: import("@mysten/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
10
|
+
}, "@local-pkg/stable_vault_farm.move::stable_vault_farm::Claim">;
|
|
11
|
+
export declare const StableVaultFarmEntity: MoveStruct<{
|
|
12
|
+
dummy_field: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
13
|
+
}, "@local-pkg/stable_vault_farm.move::stable_vault_farm::StableVaultFarmEntity">;
|
|
14
|
+
export declare const StableVaultFarmWitness: MoveStruct<{
|
|
15
|
+
dummy_field: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
16
|
+
}, "@local-pkg/stable_vault_farm.move::stable_vault_farm::StableVaultFarmWitness">;
|
|
17
|
+
export declare const StableVaultFarm: MoveStruct<{
|
|
18
|
+
id: MoveStruct<{
|
|
19
|
+
id: import("@mysten/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
20
|
+
}, "0x2::object::UID">;
|
|
21
|
+
sheet: MoveStruct<{
|
|
22
|
+
credits: MoveStruct<{
|
|
23
|
+
contents: import("@mysten/bcs").BcsType<{
|
|
24
|
+
key: {
|
|
25
|
+
name: string;
|
|
26
|
+
}[];
|
|
27
|
+
value: {
|
|
28
|
+
value: string;
|
|
29
|
+
};
|
|
30
|
+
}[], Iterable<{
|
|
31
|
+
key: {
|
|
32
|
+
name: string;
|
|
33
|
+
}[];
|
|
34
|
+
value: {
|
|
35
|
+
value: string | number | bigint;
|
|
36
|
+
};
|
|
37
|
+
}> & {
|
|
38
|
+
length: number;
|
|
39
|
+
}, string>;
|
|
40
|
+
}, "0x2::vec_map::VecMap<bucket_v2_framework::sheet::Entity, bucket_v2_framework::liability::Credit>">;
|
|
41
|
+
debts: MoveStruct<{
|
|
42
|
+
contents: import("@mysten/bcs").BcsType<{
|
|
43
|
+
key: {
|
|
44
|
+
name: string;
|
|
45
|
+
}[];
|
|
46
|
+
value: {
|
|
47
|
+
value: string;
|
|
48
|
+
};
|
|
49
|
+
}[], Iterable<{
|
|
50
|
+
key: {
|
|
51
|
+
name: string;
|
|
52
|
+
}[];
|
|
53
|
+
value: {
|
|
54
|
+
value: string | number | bigint;
|
|
55
|
+
};
|
|
56
|
+
}> & {
|
|
57
|
+
length: number;
|
|
58
|
+
}, string>;
|
|
59
|
+
}, "0x2::vec_map::VecMap<bucket_v2_framework::sheet::Entity, bucket_v2_framework::liability::Debt>">;
|
|
60
|
+
blacklist: MoveStruct<{
|
|
61
|
+
contents: import("@mysten/bcs").BcsType<{
|
|
62
|
+
name: string;
|
|
63
|
+
}[][], Iterable<{
|
|
64
|
+
name: string;
|
|
65
|
+
}[]> & {
|
|
66
|
+
length: number;
|
|
67
|
+
}, string>;
|
|
68
|
+
}, "0x2::vec_set::VecSet<bucket_v2_framework::sheet::Entity>">;
|
|
69
|
+
}, "bucket_v2_framework::sheet::Sheet">;
|
|
70
|
+
yield_table: MoveStruct<{
|
|
71
|
+
id: MoveStruct<{
|
|
72
|
+
id: import("@mysten/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
73
|
+
}, "0x2::object::UID">;
|
|
74
|
+
size: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
75
|
+
}, "0x2::table::Table">;
|
|
76
|
+
u_surplus: MoveStruct<{
|
|
77
|
+
value: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
78
|
+
}, "0x2::balance::Balance">;
|
|
79
|
+
}, "@local-pkg/stable_vault_farm.move::stable_vault_farm::StableVaultFarm">;
|
|
80
|
+
export declare const AdminCap: MoveStruct<{
|
|
81
|
+
id: MoveStruct<{
|
|
82
|
+
id: import("@mysten/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
83
|
+
}, "0x2::object::UID">;
|
|
84
|
+
}, "@local-pkg/stable_vault_farm.move::stable_vault_farm::AdminCap">;
|
|
85
|
+
export interface NewArguments {
|
|
86
|
+
Cap: RawTransactionArgument<string>;
|
|
87
|
+
initUCoin: RawTransactionArgument<string>;
|
|
88
|
+
}
|
|
89
|
+
export interface NewOptions {
|
|
90
|
+
package?: string;
|
|
91
|
+
arguments: NewArguments | [
|
|
92
|
+
Cap: RawTransactionArgument<string>,
|
|
93
|
+
initUCoin: RawTransactionArgument<string>
|
|
94
|
+
];
|
|
95
|
+
typeArguments: [
|
|
96
|
+
string,
|
|
97
|
+
string
|
|
98
|
+
];
|
|
99
|
+
}
|
|
100
|
+
export declare function _new(options: NewOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
101
|
+
export interface DefaultArguments {
|
|
102
|
+
cap: RawTransactionArgument<string>;
|
|
103
|
+
initUCoin: RawTransactionArgument<string>;
|
|
104
|
+
}
|
|
105
|
+
export interface DefaultOptions {
|
|
106
|
+
package?: string;
|
|
107
|
+
arguments: DefaultArguments | [
|
|
108
|
+
cap: RawTransactionArgument<string>,
|
|
109
|
+
initUCoin: RawTransactionArgument<string>
|
|
110
|
+
];
|
|
111
|
+
typeArguments: [
|
|
112
|
+
string,
|
|
113
|
+
string
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
export declare function _default(options: DefaultOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
117
|
+
export interface ReceiveArguments {
|
|
118
|
+
farm: RawTransactionArgument<string>;
|
|
119
|
+
loan: RawTransactionArgument<string>;
|
|
120
|
+
stableVault: RawTransactionArgument<string>;
|
|
121
|
+
usdbTreasury: RawTransactionArgument<string>;
|
|
122
|
+
psmPool: RawTransactionArgument<string>;
|
|
123
|
+
savingPool: RawTransactionArgument<string>;
|
|
124
|
+
yieldVault: RawTransactionArgument<string>;
|
|
125
|
+
uPrice: RawTransactionArgument<string>;
|
|
126
|
+
}
|
|
127
|
+
export interface ReceiveOptions {
|
|
128
|
+
package?: string;
|
|
129
|
+
arguments: ReceiveArguments | [
|
|
130
|
+
farm: RawTransactionArgument<string>,
|
|
131
|
+
loan: RawTransactionArgument<string>,
|
|
132
|
+
stableVault: RawTransactionArgument<string>,
|
|
133
|
+
usdbTreasury: RawTransactionArgument<string>,
|
|
134
|
+
psmPool: RawTransactionArgument<string>,
|
|
135
|
+
savingPool: RawTransactionArgument<string>,
|
|
136
|
+
yieldVault: RawTransactionArgument<string>,
|
|
137
|
+
uPrice: RawTransactionArgument<string>
|
|
138
|
+
];
|
|
139
|
+
typeArguments: [
|
|
140
|
+
string,
|
|
141
|
+
string,
|
|
142
|
+
string,
|
|
143
|
+
string,
|
|
144
|
+
string
|
|
145
|
+
];
|
|
146
|
+
}
|
|
147
|
+
export declare function receive(options: ReceiveOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
148
|
+
export interface PayArguments {
|
|
149
|
+
farm: RawTransactionArgument<string>;
|
|
150
|
+
request: RawTransactionArgument<string>;
|
|
151
|
+
stableVault: RawTransactionArgument<string>;
|
|
152
|
+
usdbTreasury: RawTransactionArgument<string>;
|
|
153
|
+
psmPool: RawTransactionArgument<string>;
|
|
154
|
+
savingPool: RawTransactionArgument<string>;
|
|
155
|
+
yieldVault: RawTransactionArgument<string>;
|
|
156
|
+
uPrice: RawTransactionArgument<string>;
|
|
157
|
+
}
|
|
158
|
+
export interface PayOptions {
|
|
159
|
+
package?: string;
|
|
160
|
+
arguments: PayArguments | [
|
|
161
|
+
farm: RawTransactionArgument<string>,
|
|
162
|
+
request: RawTransactionArgument<string>,
|
|
163
|
+
stableVault: RawTransactionArgument<string>,
|
|
164
|
+
usdbTreasury: RawTransactionArgument<string>,
|
|
165
|
+
psmPool: RawTransactionArgument<string>,
|
|
166
|
+
savingPool: RawTransactionArgument<string>,
|
|
167
|
+
yieldVault: RawTransactionArgument<string>,
|
|
168
|
+
uPrice: RawTransactionArgument<string>
|
|
169
|
+
];
|
|
170
|
+
typeArguments: [
|
|
171
|
+
string,
|
|
172
|
+
string,
|
|
173
|
+
string,
|
|
174
|
+
string,
|
|
175
|
+
string
|
|
176
|
+
];
|
|
177
|
+
}
|
|
178
|
+
export declare function pay(options: PayOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
179
|
+
export interface ClaimArguments {
|
|
180
|
+
farm: RawTransactionArgument<string>;
|
|
181
|
+
stableRegistry: RawTransactionArgument<string>;
|
|
182
|
+
stableVault: RawTransactionArgument<string>;
|
|
183
|
+
usdbTreasury: RawTransactionArgument<string>;
|
|
184
|
+
savingPool: RawTransactionArgument<string>;
|
|
185
|
+
yieldVault: RawTransactionArgument<string>;
|
|
186
|
+
}
|
|
187
|
+
export interface ClaimOptions {
|
|
188
|
+
package?: string;
|
|
189
|
+
arguments: ClaimArguments | [
|
|
190
|
+
farm: RawTransactionArgument<string>,
|
|
191
|
+
stableRegistry: RawTransactionArgument<string>,
|
|
192
|
+
stableVault: RawTransactionArgument<string>,
|
|
193
|
+
usdbTreasury: RawTransactionArgument<string>,
|
|
194
|
+
savingPool: RawTransactionArgument<string>,
|
|
195
|
+
yieldVault: RawTransactionArgument<string>
|
|
196
|
+
];
|
|
197
|
+
typeArguments: [
|
|
198
|
+
string,
|
|
199
|
+
string,
|
|
200
|
+
string,
|
|
201
|
+
string,
|
|
202
|
+
string
|
|
203
|
+
];
|
|
204
|
+
}
|
|
205
|
+
export declare function claim(options: ClaimOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
206
|
+
export interface ClaimableAmountArguments {
|
|
207
|
+
farm: RawTransactionArgument<string>;
|
|
208
|
+
savingPool: RawTransactionArgument<string>;
|
|
209
|
+
yieldVault: RawTransactionArgument<string>;
|
|
210
|
+
}
|
|
211
|
+
export interface ClaimableAmountOptions {
|
|
212
|
+
package?: string;
|
|
213
|
+
arguments: ClaimableAmountArguments | [
|
|
214
|
+
farm: RawTransactionArgument<string>,
|
|
215
|
+
savingPool: RawTransactionArgument<string>,
|
|
216
|
+
yieldVault: RawTransactionArgument<string>
|
|
217
|
+
];
|
|
218
|
+
typeArguments: [
|
|
219
|
+
string,
|
|
220
|
+
string,
|
|
221
|
+
string,
|
|
222
|
+
string,
|
|
223
|
+
string
|
|
224
|
+
];
|
|
225
|
+
}
|
|
226
|
+
export declare function claimableAmount(options: ClaimableAmountOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
227
|
+
export interface AddSurplusArguments {
|
|
228
|
+
farm: RawTransactionArgument<string>;
|
|
229
|
+
coin: RawTransactionArgument<string>;
|
|
230
|
+
}
|
|
231
|
+
export interface AddSurplusOptions {
|
|
232
|
+
package?: string;
|
|
233
|
+
arguments: AddSurplusArguments | [
|
|
234
|
+
farm: RawTransactionArgument<string>,
|
|
235
|
+
coin: RawTransactionArgument<string>
|
|
236
|
+
];
|
|
237
|
+
typeArguments: [
|
|
238
|
+
string,
|
|
239
|
+
string
|
|
240
|
+
];
|
|
241
|
+
}
|
|
242
|
+
export declare function addSurplus(options: AddSurplusOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { MoveStruct, normalizeMoveArguments } from '../utils/index.js';
|
|
5
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
6
|
+
import * as object from './deps/sui/object.js';
|
|
7
|
+
import * as sheet from './deps/bucket_v2_framework/sheet.js';
|
|
8
|
+
import * as table from './deps/sui/table.js';
|
|
9
|
+
import * as balance from './deps/sui/balance.js';
|
|
10
|
+
const $moduleName = '@local-pkg/stable_vault_farm.move::stable_vault_farm';
|
|
11
|
+
export const Claim = new MoveStruct({ name: `${$moduleName}::Claim`, fields: {
|
|
12
|
+
reward_type: bcs.string(),
|
|
13
|
+
amount: bcs.u64(),
|
|
14
|
+
claimer: bcs.Address
|
|
15
|
+
} });
|
|
16
|
+
export const StableVaultFarmEntity = new MoveStruct({ name: `${$moduleName}::StableVaultFarmEntity`, fields: {
|
|
17
|
+
dummy_field: bcs.bool()
|
|
18
|
+
} });
|
|
19
|
+
export const StableVaultFarmWitness = new MoveStruct({ name: `${$moduleName}::StableVaultFarmWitness`, fields: {
|
|
20
|
+
dummy_field: bcs.bool()
|
|
21
|
+
} });
|
|
22
|
+
export const StableVaultFarm = new MoveStruct({ name: `${$moduleName}::StableVaultFarm`, fields: {
|
|
23
|
+
id: object.UID,
|
|
24
|
+
sheet: sheet.Sheet,
|
|
25
|
+
yield_table: table.Table,
|
|
26
|
+
u_surplus: balance.Balance
|
|
27
|
+
} });
|
|
28
|
+
export const AdminCap = new MoveStruct({ name: `${$moduleName}::AdminCap`, fields: {
|
|
29
|
+
id: object.UID
|
|
30
|
+
} });
|
|
31
|
+
export function _new(options) {
|
|
32
|
+
var _a;
|
|
33
|
+
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_vault_farm.move';
|
|
34
|
+
const argumentsTypes = [
|
|
35
|
+
`${packageAddress}::stable_vault_farm::AdminCap`,
|
|
36
|
+
`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${options.typeArguments[1]}>`
|
|
37
|
+
];
|
|
38
|
+
const parameterNames = ["Cap", "initUCoin"];
|
|
39
|
+
return (tx) => tx.moveCall({
|
|
40
|
+
package: packageAddress,
|
|
41
|
+
module: 'stable_vault_farm',
|
|
42
|
+
function: 'new',
|
|
43
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
44
|
+
typeArguments: options.typeArguments
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
export function _default(options) {
|
|
48
|
+
var _a;
|
|
49
|
+
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_vault_farm.move';
|
|
50
|
+
const argumentsTypes = [
|
|
51
|
+
`${packageAddress}::stable_vault_farm::AdminCap`,
|
|
52
|
+
`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${options.typeArguments[1]}>`
|
|
53
|
+
];
|
|
54
|
+
const parameterNames = ["cap", "initUCoin"];
|
|
55
|
+
return (tx) => tx.moveCall({
|
|
56
|
+
package: packageAddress,
|
|
57
|
+
module: 'stable_vault_farm',
|
|
58
|
+
function: 'default',
|
|
59
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
60
|
+
typeArguments: options.typeArguments
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
export function receive(options) {
|
|
64
|
+
var _a;
|
|
65
|
+
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_vault_farm.move';
|
|
66
|
+
const argumentsTypes = [
|
|
67
|
+
`${packageAddress}::stable_vault_farm::StableVaultFarm<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
68
|
+
`${packageAddress}::sheet::Loan<${options.typeArguments[1]}, ${packageAddress}::stable_layer::StableFactoryEntity<${options.typeArguments[2]}, ${options.typeArguments[1]}>, ${packageAddress}::stable_vault_farm::StableVaultFarmEntity<${options.typeArguments[0]}, ${options.typeArguments[1]}>>`,
|
|
69
|
+
`${packageAddress}::stable_vault::StableVault<${options.typeArguments[0]}, ${options.typeArguments[1]}, ${options.typeArguments[3]}>`,
|
|
70
|
+
`${packageAddress}::usdb::Treasury`,
|
|
71
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[1]}>`,
|
|
72
|
+
`${packageAddress}::saving::SavingPool<${options.typeArguments[4]}>`,
|
|
73
|
+
`${packageAddress}::yield_usdb::YieldVault<${options.typeArguments[3]}, ${options.typeArguments[4]}>`,
|
|
74
|
+
`${packageAddress}::result::PriceResult<${options.typeArguments[1]}>`,
|
|
75
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock'
|
|
76
|
+
];
|
|
77
|
+
const parameterNames = ["farm", "loan", "stableVault", "usdbTreasury", "psmPool", "savingPool", "yieldVault", "uPrice"];
|
|
78
|
+
return (tx) => tx.moveCall({
|
|
79
|
+
package: packageAddress,
|
|
80
|
+
module: 'stable_vault_farm',
|
|
81
|
+
function: 'receive',
|
|
82
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
83
|
+
typeArguments: options.typeArguments
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
export function pay(options) {
|
|
87
|
+
var _a;
|
|
88
|
+
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_vault_farm.move';
|
|
89
|
+
const argumentsTypes = [
|
|
90
|
+
`${packageAddress}::stable_vault_farm::StableVaultFarm<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
91
|
+
`${packageAddress}::sheet::Request<${options.typeArguments[1]}, ${packageAddress}::stable_layer::StableFactoryEntity<${options.typeArguments[2]}, ${options.typeArguments[1]}>>`,
|
|
92
|
+
`${packageAddress}::stable_vault::StableVault<${options.typeArguments[0]}, ${options.typeArguments[1]}, ${options.typeArguments[3]}>`,
|
|
93
|
+
`${packageAddress}::usdb::Treasury`,
|
|
94
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[1]}>`,
|
|
95
|
+
`${packageAddress}::saving::SavingPool<${options.typeArguments[4]}>`,
|
|
96
|
+
`${packageAddress}::yield_usdb::YieldVault<${options.typeArguments[3]}, ${options.typeArguments[4]}>`,
|
|
97
|
+
`${packageAddress}::result::PriceResult<${options.typeArguments[1]}>`,
|
|
98
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock'
|
|
99
|
+
];
|
|
100
|
+
const parameterNames = ["farm", "request", "stableVault", "usdbTreasury", "psmPool", "savingPool", "yieldVault", "uPrice"];
|
|
101
|
+
return (tx) => tx.moveCall({
|
|
102
|
+
package: packageAddress,
|
|
103
|
+
module: 'stable_vault_farm',
|
|
104
|
+
function: 'pay',
|
|
105
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
106
|
+
typeArguments: options.typeArguments
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
export function claim(options) {
|
|
110
|
+
var _a;
|
|
111
|
+
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_vault_farm.move';
|
|
112
|
+
const argumentsTypes = [
|
|
113
|
+
`${packageAddress}::stable_vault_farm::StableVaultFarm<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
114
|
+
`${packageAddress}::stable_layer::StableRegistry`,
|
|
115
|
+
`${packageAddress}::stable_vault::StableVault<${options.typeArguments[0]}, ${options.typeArguments[1]}, ${options.typeArguments[3]}>`,
|
|
116
|
+
`${packageAddress}::usdb::Treasury`,
|
|
117
|
+
`${packageAddress}::saving::SavingPool<${options.typeArguments[4]}>`,
|
|
118
|
+
`${packageAddress}::yield_usdb::YieldVault<${options.typeArguments[3]}, ${options.typeArguments[4]}>`,
|
|
119
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock'
|
|
120
|
+
];
|
|
121
|
+
const parameterNames = ["farm", "stableRegistry", "stableVault", "usdbTreasury", "savingPool", "yieldVault"];
|
|
122
|
+
return (tx) => tx.moveCall({
|
|
123
|
+
package: packageAddress,
|
|
124
|
+
module: 'stable_vault_farm',
|
|
125
|
+
function: 'claim',
|
|
126
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
127
|
+
typeArguments: options.typeArguments
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
export function claimableAmount(options) {
|
|
131
|
+
var _a;
|
|
132
|
+
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_vault_farm.move';
|
|
133
|
+
const argumentsTypes = [
|
|
134
|
+
`${packageAddress}::stable_vault_farm::StableVaultFarm<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
135
|
+
`${packageAddress}::saving::SavingPool<${options.typeArguments[4]}>`,
|
|
136
|
+
`${packageAddress}::yield_usdb::YieldVault<${options.typeArguments[3]}, ${options.typeArguments[4]}>`,
|
|
137
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock'
|
|
138
|
+
];
|
|
139
|
+
const parameterNames = ["farm", "savingPool", "yieldVault"];
|
|
140
|
+
return (tx) => tx.moveCall({
|
|
141
|
+
package: packageAddress,
|
|
142
|
+
module: 'stable_vault_farm',
|
|
143
|
+
function: 'claimable_amount',
|
|
144
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
145
|
+
typeArguments: options.typeArguments
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
export function addSurplus(options) {
|
|
149
|
+
var _a;
|
|
150
|
+
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '@local-pkg/stable_vault_farm.move';
|
|
151
|
+
const argumentsTypes = [
|
|
152
|
+
`${packageAddress}::stable_vault_farm::StableVaultFarm<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
153
|
+
`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${options.typeArguments[1]}>`
|
|
154
|
+
];
|
|
155
|
+
const parameterNames = ["farm", "coin"];
|
|
156
|
+
return (tx) => tx.moveCall({
|
|
157
|
+
package: packageAddress,
|
|
158
|
+
module: 'stable_vault_farm',
|
|
159
|
+
function: 'add_surplus',
|
|
160
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
161
|
+
typeArguments: options.typeArguments
|
|
162
|
+
});
|
|
163
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BcsType, TypeTag, BcsStruct, BcsEnum, BcsTuple } from '@mysten/sui/bcs';
|
|
2
|
+
import { TransactionArgument } from '@mysten/sui/transactions';
|
|
3
|
+
export type RawTransactionArgument<T> = T | TransactionArgument;
|
|
4
|
+
export declare function getPureBcsSchema(typeTag: string | TypeTag): BcsType<any> | null;
|
|
5
|
+
export declare function normalizeMoveArguments(args: unknown[] | object, argTypes: string[], parameterNames?: string[]): TransactionArgument[];
|
|
6
|
+
export declare class MoveStruct<T extends Record<string, BcsType<any>>, const Name extends string = string> extends BcsStruct<T, Name> {
|
|
7
|
+
}
|
|
8
|
+
export declare class MoveEnum<T extends Record<string, BcsType<any> | null>, const Name extends string> extends BcsEnum<T, Name> {
|
|
9
|
+
}
|
|
10
|
+
export declare class MoveTuple<T extends readonly BcsType<any>[], const Name extends string> extends BcsTuple<T, Name> {
|
|
11
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { bcs, TypeTagSerializer, BcsStruct, BcsEnum, BcsTuple } from '@mysten/sui/bcs';
|
|
2
|
+
import { normalizeSuiAddress } from '@mysten/sui/utils';
|
|
3
|
+
import { isArgument } from '@mysten/sui/transactions';
|
|
4
|
+
const MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1');
|
|
5
|
+
const SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');
|
|
6
|
+
const SUI_SYSTEM_ADDRESS = normalizeSuiAddress('0x3');
|
|
7
|
+
export function getPureBcsSchema(typeTag) {
|
|
8
|
+
const parsedTag = typeof typeTag === 'string' ? TypeTagSerializer.parseFromStr(typeTag) : typeTag;
|
|
9
|
+
if ('u8' in parsedTag) {
|
|
10
|
+
return bcs.U8;
|
|
11
|
+
}
|
|
12
|
+
else if ('u16' in parsedTag) {
|
|
13
|
+
return bcs.U16;
|
|
14
|
+
}
|
|
15
|
+
else if ('u32' in parsedTag) {
|
|
16
|
+
return bcs.U32;
|
|
17
|
+
}
|
|
18
|
+
else if ('u64' in parsedTag) {
|
|
19
|
+
return bcs.U64;
|
|
20
|
+
}
|
|
21
|
+
else if ('u128' in parsedTag) {
|
|
22
|
+
return bcs.U128;
|
|
23
|
+
}
|
|
24
|
+
else if ('u256' in parsedTag) {
|
|
25
|
+
return bcs.U256;
|
|
26
|
+
}
|
|
27
|
+
else if ('address' in parsedTag) {
|
|
28
|
+
return bcs.Address;
|
|
29
|
+
}
|
|
30
|
+
else if ('bool' in parsedTag) {
|
|
31
|
+
return bcs.Bool;
|
|
32
|
+
}
|
|
33
|
+
else if ('vector' in parsedTag) {
|
|
34
|
+
const type = getPureBcsSchema(parsedTag.vector);
|
|
35
|
+
return type ? bcs.vector(type) : null;
|
|
36
|
+
}
|
|
37
|
+
else if ('struct' in parsedTag) {
|
|
38
|
+
const structTag = parsedTag.struct;
|
|
39
|
+
const pkg = normalizeSuiAddress(parsedTag.struct.address);
|
|
40
|
+
if (pkg === MOVE_STDLIB_ADDRESS) {
|
|
41
|
+
if ((structTag.module === 'ascii' || structTag.module === 'string') &&
|
|
42
|
+
structTag.name === 'String') {
|
|
43
|
+
return bcs.String;
|
|
44
|
+
}
|
|
45
|
+
if (structTag.module === 'option' && structTag.name === 'Option') {
|
|
46
|
+
const type = getPureBcsSchema(structTag.typeParams[0]);
|
|
47
|
+
return type ? bcs.option(type) : null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (pkg === SUI_FRAMEWORK_ADDRESS && structTag.module === 'Object' && structTag.name === 'ID') {
|
|
51
|
+
return bcs.Address;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
export function normalizeMoveArguments(args, argTypes, parameterNames) {
|
|
57
|
+
const argLen = Array.isArray(args) ? args.length : Object.keys(args).length;
|
|
58
|
+
if (parameterNames && argLen !== parameterNames.length) {
|
|
59
|
+
throw new Error(`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`);
|
|
60
|
+
}
|
|
61
|
+
const normalizedArgs = [];
|
|
62
|
+
let index = 0;
|
|
63
|
+
for (const [i, argType] of argTypes.entries()) {
|
|
64
|
+
if (argType === `${SUI_FRAMEWORK_ADDRESS}::deny_list::DenyList`) {
|
|
65
|
+
normalizedArgs.push((tx) => tx.object.denyList());
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (argType === `${SUI_FRAMEWORK_ADDRESS}::random::Random`) {
|
|
69
|
+
normalizedArgs.push((tx) => tx.object.random());
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (argType === `${SUI_FRAMEWORK_ADDRESS}::clock::Clock`) {
|
|
73
|
+
normalizedArgs.push((tx) => tx.object.clock());
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (argType === `${SUI_SYSTEM_ADDRESS}::sui_system::SuiSystemState`) {
|
|
77
|
+
normalizedArgs.push((tx) => tx.object.system());
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
let arg;
|
|
81
|
+
if (Array.isArray(args)) {
|
|
82
|
+
if (index >= args.length) {
|
|
83
|
+
throw new Error(`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`);
|
|
84
|
+
}
|
|
85
|
+
arg = args[index];
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
if (!parameterNames) {
|
|
89
|
+
throw new Error(`Expected arguments to be passed as an array`);
|
|
90
|
+
}
|
|
91
|
+
const name = parameterNames[index];
|
|
92
|
+
arg = args[name];
|
|
93
|
+
if (arg == null) {
|
|
94
|
+
throw new Error(`Parameter ${name} is required`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
index += 1;
|
|
98
|
+
if (typeof arg === 'function' || isArgument(arg)) {
|
|
99
|
+
normalizedArgs.push(arg);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const type = argTypes[i];
|
|
103
|
+
const bcsType = getPureBcsSchema(type);
|
|
104
|
+
if (bcsType) {
|
|
105
|
+
const bytes = bcsType.serialize(arg);
|
|
106
|
+
normalizedArgs.push((tx) => tx.pure(bytes));
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
else if (typeof arg === 'string') {
|
|
110
|
+
normalizedArgs.push((tx) => tx.object(arg));
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
throw new Error(`Invalid argument ${stringify(arg)} for type ${type}`);
|
|
114
|
+
}
|
|
115
|
+
return normalizedArgs;
|
|
116
|
+
}
|
|
117
|
+
export class MoveStruct extends BcsStruct {
|
|
118
|
+
}
|
|
119
|
+
export class MoveEnum extends BcsEnum {
|
|
120
|
+
}
|
|
121
|
+
export class MoveTuple extends BcsTuple {
|
|
122
|
+
}
|
|
123
|
+
function stringify(val) {
|
|
124
|
+
if (typeof val === 'object') {
|
|
125
|
+
return JSON.stringify(val, (val) => val);
|
|
126
|
+
}
|
|
127
|
+
if (typeof val === 'bigint') {
|
|
128
|
+
return val.toString();
|
|
129
|
+
}
|
|
130
|
+
return val;
|
|
131
|
+
}
|