@huma-finance/soroban-pool 0.0.8-beta.2

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.
@@ -0,0 +1,421 @@
1
+ import { AssembledTransaction, ContractClient, ContractClientOptions } from '@stellar/stellar-sdk/lib/contract_client/index.js';
2
+ import type { u32, u64, u128, Option } from '@stellar/stellar-sdk/lib/contract_client';
3
+ export * from '@stellar/stellar-sdk';
4
+ export * from '@stellar/stellar-sdk/lib/contract_client/index.js';
5
+ export * from '@stellar/stellar-sdk/lib/rust_types/index.js';
6
+ export declare const networks: {
7
+ readonly testnet: {
8
+ readonly networkPassphrase: "Test SDF Network ; September 2015";
9
+ readonly contractId: "CC2GGLIHX5E75QIXB7G27EOC47V74PXA33KGYDQH4DFISIVZPWQRBVJV";
10
+ };
11
+ };
12
+ export type ClientDataKey = {
13
+ tag: 'HumaConfig';
14
+ values: void;
15
+ } | {
16
+ tag: 'PoolStorage';
17
+ values: void;
18
+ } | {
19
+ tag: 'Credit';
20
+ values: void;
21
+ } | {
22
+ tag: 'PoolManager';
23
+ values: void;
24
+ };
25
+ /**
26
+ * Event for the distribution of profit in the pool.
27
+ * # Fields:
28
+ * * `profit` - The amount of profit distributed.
29
+ * * `senior_total_assets` - The total amount of senior assets post profit distribution.
30
+ * * `junior_total_assets` - The total amount of junior assets post profit distribution.
31
+ */
32
+ export interface ProfitDistributedEvent {
33
+ junior_total_assets: u128;
34
+ profit: u128;
35
+ senior_total_assets: u128;
36
+ }
37
+ /**
38
+ * Event for the distribution of loss in the pool.
39
+ * # Fields:
40
+ * * `loss` - The amount of loss distributed.
41
+ * * `senior_total_assets` - The total amount of senior assets post loss distribution.
42
+ * * `junior_total_assets` - The total amount of junior assets post loss distribution.
43
+ * * `senior_total_loss` - The total amount of loss the senior tranche suffered post loss distribution.
44
+ * * `junior_total_loss` - The total amount of loss the junior tranche suffered post loss distribution.
45
+ */
46
+ export interface LossDistributedEvent {
47
+ junior_total_assets: u128;
48
+ junior_total_loss: u128;
49
+ loss: u128;
50
+ senior_total_assets: u128;
51
+ senior_total_loss: u128;
52
+ }
53
+ /**
54
+ * Event for the distribution of loss recovery in the pool.
55
+ * # Fields:
56
+ * * `loss_recovery` - The amount of loss recovery distributed.
57
+ * * `senior_total_assets` - The total amount of senior assets post loss recovery distribution.
58
+ * * `junior_total_assets` - The total amount of junior assets post loss recovery distribution.
59
+ * * `senior_total_loss` - The remaining amount of loss the senior tranche suffered post loss recovery distribution.
60
+ * * `junior_total_loss` - The remaining amount of loss the junior tranche suffered post loss recovery distribution.
61
+ */
62
+ export interface LossRecoveryDistributedEvent {
63
+ junior_total_assets: u128;
64
+ junior_total_loss: u128;
65
+ loss_recovery: u128;
66
+ senior_total_assets: u128;
67
+ senior_total_loss: u128;
68
+ }
69
+ export interface TranchesPolicyTypeChangedEvent {
70
+ policy_type: TranchesPolicyType;
71
+ }
72
+ /**
73
+ * The senior yield tracker has been refreshed.
74
+ * # Fields:
75
+ * * `total_assets` - The total assets in the senior tranche after the refresh.
76
+ * * `unpaid_yield` - The amount of unpaid yield to the senior tranche after the refresh.
77
+ * * `last_updated_date` - The last time the tracker was updated after the refresh.
78
+ */
79
+ export interface YieldTrackerRefreshedEvent {
80
+ last_updated_date: u64;
81
+ total_assets: u128;
82
+ unpaid_yield: u128;
83
+ }
84
+ export type FixedSeniorYieldTranchesPolicyDataKey = {
85
+ tag: 'SeniorYieldTracker';
86
+ values: void;
87
+ };
88
+ export interface SeniorYieldTracker {
89
+ last_updated_date: u64;
90
+ total_assets: u128;
91
+ unpaid_yield: u128;
92
+ }
93
+ export interface FixedSeniorYieldTranchesPolicy {
94
+ placeholder: boolean;
95
+ }
96
+ export interface RiskAdjustedTranchesPolicy {
97
+ placeholder: boolean;
98
+ }
99
+ export type TranchesPolicyType = {
100
+ tag: 'FixedSeniorYield';
101
+ values: void;
102
+ } | {
103
+ tag: 'RiskAdjusted';
104
+ values: void;
105
+ };
106
+ export interface TrancheLosses {
107
+ losses: Array<u128>;
108
+ }
109
+ export interface AccruedIncomes {
110
+ ea_income: u128;
111
+ pool_owner_income: u128;
112
+ protocol_income: u128;
113
+ }
114
+ export type PayPeriodDuration = {
115
+ tag: 'Monthly';
116
+ values: void;
117
+ } | {
118
+ tag: 'Quarterly';
119
+ values: void;
120
+ } | {
121
+ tag: 'SemiAnnually';
122
+ values: void;
123
+ };
124
+ export interface PoolSettings {
125
+ default_grace_period_days: u32;
126
+ late_payment_grace_period_days: u32;
127
+ max_credit_line: u128;
128
+ min_deposit_amount: u128;
129
+ pay_period_duration: PayPeriodDuration;
130
+ principal_only_payment_allowed: boolean;
131
+ }
132
+ export interface LPConfig {
133
+ fixed_senior_yield_bps: u32;
134
+ liquidity_cap: u128;
135
+ max_senior_junior_ratio: u32;
136
+ tranches_risk_adjustment_bps: u32;
137
+ withdrawal_lockout_period_days: u32;
138
+ }
139
+ export interface FeeStructure {
140
+ front_loading_fee_bps: u32;
141
+ front_loading_fee_flat: u128;
142
+ late_fee_bps: u32;
143
+ yield_bps: u32;
144
+ }
145
+ export type PoolStatus = {
146
+ tag: 'Off';
147
+ values: void;
148
+ } | {
149
+ tag: 'On';
150
+ values: void;
151
+ } | {
152
+ tag: 'Closed';
153
+ values: void;
154
+ };
155
+ export interface CurrentEpoch {
156
+ end_time: u64;
157
+ id: u64;
158
+ }
159
+ export interface AdminRnR {
160
+ liquidity_rate_bps_ea: u32;
161
+ liquidity_rate_bps_pool_owner: u32;
162
+ reward_rate_bps_ea: u32;
163
+ reward_rate_bps_pool_owner: u32;
164
+ }
165
+ export interface TrancheAddresses {
166
+ addrs: Array<Option<string>>;
167
+ }
168
+ export interface TrancheAssets {
169
+ assets: Array<u128>;
170
+ }
171
+ export interface Client {
172
+ /**
173
+ * Construct and simulate a initialize transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
174
+ */
175
+ initialize: ({ huma_config, pool_manager, pool_storage, credit, tranches_policy, }: {
176
+ huma_config: string;
177
+ pool_manager: string;
178
+ pool_storage: string;
179
+ credit: string;
180
+ tranches_policy: TranchesPolicyType;
181
+ }, options?: {
182
+ /**
183
+ * The fee to pay for the transaction. Default: BASE_FEE
184
+ */
185
+ fee?: number;
186
+ /**
187
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
188
+ */
189
+ timeoutInSeconds?: number;
190
+ /**
191
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
192
+ */
193
+ simulate?: boolean;
194
+ }) => Promise<AssembledTransaction<null>>;
195
+ /**
196
+ * Construct and simulate a set_huma_config transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
197
+ */
198
+ set_huma_config: ({ addr, caller }: {
199
+ addr: string;
200
+ caller: string;
201
+ }, options?: {
202
+ /**
203
+ * The fee to pay for the transaction. Default: BASE_FEE
204
+ */
205
+ fee?: number;
206
+ /**
207
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
208
+ */
209
+ timeoutInSeconds?: number;
210
+ /**
211
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
212
+ */
213
+ simulate?: boolean;
214
+ }) => Promise<AssembledTransaction<null>>;
215
+ /**
216
+ * Construct and simulate a set_pool_storage transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
217
+ */
218
+ set_pool_storage: ({ addr, caller }: {
219
+ addr: string;
220
+ caller: string;
221
+ }, options?: {
222
+ /**
223
+ * The fee to pay for the transaction. Default: BASE_FEE
224
+ */
225
+ fee?: number;
226
+ /**
227
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
228
+ */
229
+ timeoutInSeconds?: number;
230
+ /**
231
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
232
+ */
233
+ simulate?: boolean;
234
+ }) => Promise<AssembledTransaction<null>>;
235
+ /**
236
+ * Construct and simulate a set_credit transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
237
+ */
238
+ set_credit: ({ addr, caller }: {
239
+ addr: string;
240
+ caller: string;
241
+ }, options?: {
242
+ /**
243
+ * The fee to pay for the transaction. Default: BASE_FEE
244
+ */
245
+ fee?: number;
246
+ /**
247
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
248
+ */
249
+ timeoutInSeconds?: number;
250
+ /**
251
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
252
+ */
253
+ simulate?: boolean;
254
+ }) => Promise<AssembledTransaction<null>>;
255
+ /**
256
+ * Construct and simulate a set_pool_manager transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
257
+ */
258
+ set_pool_manager: ({ addr, caller }: {
259
+ addr: string;
260
+ caller: string;
261
+ }, options?: {
262
+ /**
263
+ * The fee to pay for the transaction. Default: BASE_FEE
264
+ */
265
+ fee?: number;
266
+ /**
267
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
268
+ */
269
+ timeoutInSeconds?: number;
270
+ /**
271
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
272
+ */
273
+ simulate?: boolean;
274
+ }) => Promise<AssembledTransaction<null>>;
275
+ /**
276
+ * Construct and simulate a set_tranches_policy_type transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
277
+ */
278
+ set_tranches_policy_type: ({ caller, policy_type, }: {
279
+ caller: string;
280
+ policy_type: TranchesPolicyType;
281
+ }, options?: {
282
+ /**
283
+ * The fee to pay for the transaction. Default: BASE_FEE
284
+ */
285
+ fee?: number;
286
+ /**
287
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
288
+ */
289
+ timeoutInSeconds?: number;
290
+ /**
291
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
292
+ */
293
+ simulate?: boolean;
294
+ }) => Promise<AssembledTransaction<null>>;
295
+ /**
296
+ * Construct and simulate a distribute_profit transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
297
+ */
298
+ distribute_profit: ({ profit }: {
299
+ profit: u128;
300
+ }, options?: {
301
+ /**
302
+ * The fee to pay for the transaction. Default: BASE_FEE
303
+ */
304
+ fee?: number;
305
+ /**
306
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
307
+ */
308
+ timeoutInSeconds?: number;
309
+ /**
310
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
311
+ */
312
+ simulate?: boolean;
313
+ }) => Promise<AssembledTransaction<null>>;
314
+ /**
315
+ * Construct and simulate a distribute_loss transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
316
+ */
317
+ distribute_loss: ({ loss }: {
318
+ loss: u128;
319
+ }, options?: {
320
+ /**
321
+ * The fee to pay for the transaction. Default: BASE_FEE
322
+ */
323
+ fee?: number;
324
+ /**
325
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
326
+ */
327
+ timeoutInSeconds?: number;
328
+ /**
329
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
330
+ */
331
+ simulate?: boolean;
332
+ }) => Promise<AssembledTransaction<null>>;
333
+ /**
334
+ * Construct and simulate a distribute_loss_recovery transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
335
+ */
336
+ distribute_loss_recovery: ({ loss_recovery }: {
337
+ loss_recovery: u128;
338
+ }, options?: {
339
+ /**
340
+ * The fee to pay for the transaction. Default: BASE_FEE
341
+ */
342
+ fee?: number;
343
+ /**
344
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
345
+ */
346
+ timeoutInSeconds?: number;
347
+ /**
348
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
349
+ */
350
+ simulate?: boolean;
351
+ }) => Promise<AssembledTransaction<null>>;
352
+ /**
353
+ * Construct and simulate a get_protocol_income_accrued transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
354
+ */
355
+ get_protocol_income_accrued: (options?: {
356
+ /**
357
+ * The fee to pay for the transaction. Default: BASE_FEE
358
+ */
359
+ fee?: number;
360
+ /**
361
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
362
+ */
363
+ timeoutInSeconds?: number;
364
+ /**
365
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
366
+ */
367
+ simulate?: boolean;
368
+ }) => Promise<AssembledTransaction<u128>>;
369
+ /**
370
+ * Construct and simulate a get_pool_owner_income_accrued transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
371
+ */
372
+ get_pool_owner_income_accrued: (options?: {
373
+ /**
374
+ * The fee to pay for the transaction. Default: BASE_FEE
375
+ */
376
+ fee?: number;
377
+ /**
378
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
379
+ */
380
+ timeoutInSeconds?: number;
381
+ /**
382
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
383
+ */
384
+ simulate?: boolean;
385
+ }) => Promise<AssembledTransaction<u128>>;
386
+ /**
387
+ * Construct and simulate a get_ea_income_accrued transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
388
+ */
389
+ get_ea_income_accrued: (options?: {
390
+ /**
391
+ * The fee to pay for the transaction. Default: BASE_FEE
392
+ */
393
+ fee?: number;
394
+ /**
395
+ * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT
396
+ */
397
+ timeoutInSeconds?: number;
398
+ /**
399
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
400
+ */
401
+ simulate?: boolean;
402
+ }) => Promise<AssembledTransaction<u128>>;
403
+ }
404
+ export declare class Client extends ContractClient {
405
+ readonly options: ContractClientOptions;
406
+ constructor(options: ContractClientOptions);
407
+ readonly fromJSON: {
408
+ initialize: (json: string) => AssembledTransaction<null>;
409
+ set_huma_config: (json: string) => AssembledTransaction<null>;
410
+ set_pool_storage: (json: string) => AssembledTransaction<null>;
411
+ set_credit: (json: string) => AssembledTransaction<null>;
412
+ set_pool_manager: (json: string) => AssembledTransaction<null>;
413
+ set_tranches_policy_type: (json: string) => AssembledTransaction<null>;
414
+ distribute_profit: (json: string) => AssembledTransaction<null>;
415
+ distribute_loss: (json: string) => AssembledTransaction<null>;
416
+ distribute_loss_recovery: (json: string) => AssembledTransaction<null>;
417
+ get_protocol_income_accrued: (json: string) => AssembledTransaction<bigint>;
418
+ get_pool_owner_income_accrued: (json: string) => AssembledTransaction<bigint>;
419
+ get_ea_income_accrued: (json: string) => AssembledTransaction<bigint>;
420
+ };
421
+ }
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "version": "0.0.8-beta.2+79432b6",
3
+ "name": "@huma-finance/soroban-pool",
4
+ "dependencies": {
5
+ "@stellar/freighter-api": "2.0.0",
6
+ "@stellar/stellar-sdk": "11.3.0",
7
+ "buffer": "6.0.3"
8
+ },
9
+ "scripts": {
10
+ "build": "node ./scripts/build.mjs"
11
+ },
12
+ "exports": {
13
+ "require": "./dist/cjs/index.js",
14
+ "import": "./dist/esm/index.js"
15
+ },
16
+ "typings": "dist/types/index.d.ts",
17
+ "devDependencies": {
18
+ "typescript": "5.3.3"
19
+ },
20
+ "publishConfig": {
21
+ "access": "public",
22
+ "registry": "https://registry.npmjs.org/"
23
+ },
24
+ "gitHead": "79432b60d3d0c755634737e635699aab90be53f0"
25
+ }
@@ -0,0 +1,37 @@
1
+ import { spawnSync } from "node:child_process"
2
+ import fs from "node:fs"
3
+ import path from "node:path"
4
+
5
+ const buildDir = "./dist"
6
+
7
+ const { error, stderr } = spawnSync("tsc", ["-b", "./scripts/tsconfig.cjs.json", "./scripts/tsconfig.esm.json", "./scripts/tsconfig.types.json"], { stdio: "inherit" })
8
+
9
+ if (error) {
10
+ console.error(stderr)
11
+ console.error(error)
12
+ throw error
13
+ }
14
+
15
+ function createEsmModulePackageJson() {
16
+ fs.readdir(buildDir, function (err, dirs) {
17
+ if (err) {
18
+ throw err
19
+ }
20
+ dirs.forEach(function (dir) {
21
+ if (dir === "esm") {
22
+ // 1. add package.json file with "type": "module"
23
+ var packageJsonFile = path.join(buildDir, dir, "/package.json")
24
+ if (!fs.existsSync(packageJsonFile)) {
25
+ fs.writeFileSync(
26
+ packageJsonFile,
27
+ '{"type": "module"}',
28
+ 'utf8',
29
+ err => { if (err) throw err }
30
+ )
31
+ }
32
+ }
33
+ })
34
+ })
35
+ }
36
+
37
+ createEsmModulePackageJson()
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../dist/cjs",
5
+ "module": "commonjs"
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../dist/esm",
5
+ "module": "esnext"
6
+ }
7
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../dist/types",
5
+ "declaration": true,
6
+ "emitDeclarationOnly": true
7
+ }
8
+ }