@xoxno/sdk-js 1.0.224 → 1.0.226

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.
Files changed (67) hide show
  1. package/README.md +39 -0
  2. package/dist/cjs/sdk/stellar/index.d.ts +1 -0
  3. package/dist/cjs/sdk/stellar/read/__tests__/client.test.d.ts +1 -0
  4. package/dist/cjs/sdk/stellar/read/client.d.ts +19 -0
  5. package/dist/cjs/sdk/stellar/read/index.d.ts +4 -0
  6. package/dist/cjs/sdk/stellar/read/schemas.d.ts +370 -0
  7. package/dist/cjs/sdk/stellar/read/types.d.ts +83 -0
  8. package/dist/esm/index.js +3 -0
  9. package/dist/esm/sdk/index.js +198 -0
  10. package/dist/esm/sdk/stellar/admin.js +385 -0
  11. package/dist/esm/sdk/stellar/auth-policy.js +310 -0
  12. package/dist/esm/sdk/stellar/cctp.js +23 -0
  13. package/dist/esm/sdk/stellar/contracts.js +49 -0
  14. package/dist/esm/sdk/stellar/events/decode.js +415 -0
  15. package/dist/esm/sdk/stellar/events/id.js +62 -0
  16. package/dist/esm/sdk/stellar/events/index.js +2 -0
  17. package/dist/esm/sdk/stellar/governance.js +403 -0
  18. package/dist/esm/sdk/stellar/index.js +26 -0
  19. package/dist/esm/sdk/stellar/lending-api-types.js +3 -0
  20. package/dist/esm/sdk/stellar/lending-read-types.js +1 -0
  21. package/dist/esm/sdk/stellar/lending-read.js +341 -0
  22. package/dist/esm/sdk/stellar/lending.js +358 -0
  23. package/dist/esm/sdk/stellar/math/account.js +256 -0
  24. package/dist/esm/sdk/stellar/math/index.js +11 -0
  25. package/dist/esm/sdk/stellar/math/limits.js +273 -0
  26. package/dist/esm/sdk/stellar/math/projection.js +130 -0
  27. package/dist/esm/sdk/stellar/math/rates.js +62 -0
  28. package/dist/esm/sdk/stellar/math/scaled.js +156 -0
  29. package/dist/esm/sdk/stellar/position-mode.js +11 -0
  30. package/dist/esm/sdk/stellar/prepare.js +47 -0
  31. package/dist/esm/sdk/stellar/quote.js +87 -0
  32. package/dist/esm/sdk/stellar/read/client.js +82 -0
  33. package/dist/esm/sdk/stellar/read/index.js +3 -0
  34. package/dist/esm/sdk/stellar/read/schemas.js +158 -0
  35. package/dist/esm/sdk/stellar/read/types.js +1 -0
  36. package/dist/esm/sdk/stellar/repay-swap.js +12 -0
  37. package/dist/esm/sdk/stellar/route-verify.js +285 -0
  38. package/dist/esm/sdk/stellar/scval-encode.js +464 -0
  39. package/dist/esm/sdk/stellar/swap-history.js +46 -0
  40. package/dist/esm/sdk/stellar/swap-index.js +1 -0
  41. package/dist/esm/sdk/stellar/swap.js +117 -0
  42. package/dist/esm/sdk/stellar/xdr-compat.js +17 -0
  43. package/dist/esm/sdk/stellar-schema.js +129 -0
  44. package/dist/esm/sdk/swagger.js +1957 -0
  45. package/dist/esm/sdk/types.js +1 -0
  46. package/dist/esm/sdk/utils.js +21 -0
  47. package/dist/esm/utils/api.js +169 -0
  48. package/dist/esm/utils/const.js +11 -0
  49. package/dist/esm/utils/errors.js +20 -0
  50. package/dist/esm/utils/guards.js +29 -0
  51. package/dist/esm/utils/helpers.js +20 -0
  52. package/dist/esm/utils/regex.js +14 -0
  53. package/dist/esm/utils/soroban-errors.js +149 -0
  54. package/dist/index.cjs +1 -1
  55. package/dist/index.esm.js +1 -2
  56. package/dist/sdk/stellar/index.cjs +1 -1
  57. package/dist/sdk/stellar/index.d.ts +1 -0
  58. package/dist/sdk/stellar/index.esm.js +1 -1
  59. package/dist/sdk/stellar/read/__tests__/client.test.d.ts +1 -0
  60. package/dist/sdk/stellar/read/client.d.ts +19 -0
  61. package/dist/sdk/stellar/read/index.cjs +1 -0
  62. package/dist/sdk/stellar/read/index.d.ts +4 -0
  63. package/dist/sdk/stellar/read/index.esm.js +1 -0
  64. package/dist/sdk/stellar/read/schemas.d.ts +370 -0
  65. package/dist/sdk/stellar/read/types.d.ts +83 -0
  66. package/package.json +20 -4
  67. package/dist/index.esm.js.LICENSE.txt +0 -8
@@ -0,0 +1 @@
1
+ (()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{createStellarLendingReadClient:()=>f,lendingAssetsSchema:()=>y,lendingPositionsSchema:()=>m});const r={type:"string"},n={type:"number"},a={type:"boolean"},o={...r,nullable:!0},i={...n,nullable:!0},s={...r,enum:["mainnet","testnet"]},l={...r,enum:["ready","stale","incomplete"]};function d(e){return{type:"object",required:Object.keys(e),properties:e}}const c={sac:r,symbol:r,name:r,decimals:i,logoUrl:o},p=d({valid:a,stale:a,deviation:a,timestamp:i}),u=d({...c,hubId:n,hubName:r,amountRaw:{...o,description:"Integer token base units, never scaled shares."},amount:o,apy:{...i,description:"Fraction: 0.05 means 5%."},priceUsd:i,valueUsd:i,priceStatus:p,indexRay:o,indexedAt:n,indexedLedger:n}),w=d({amountRaw:o,amount:o,usd:i}),h=d({spokeId:n,spokeName:r,ltvBps:n,supplyCapacity:w,borrowCapacity:w,canSupply:a,canBeCollateral:a,canBorrow:a,canOpenAccount:{...a,description:"Spoke admits new accounts; other entry gates still apply."}}),m={type:"array",items:d({accountId:r,nftContract:r,network:s,spokeId:i,spokeName:o,supplied:{type:"array",items:u},borrow:{type:"array",items:u},hasDebt:{...a,nullable:!0,description:"Null when account rows are unavailable."},healthFactor:{...i,description:"Null without debt or when risk inputs are unavailable."},borrowLimitUsd:i,availableBorrowUsd:{...i,description:"Account headroom, before per-market constraints."},netApy:{...i,description:"Net annual yield divided by positive net equity; fraction."},dataStatus:l})},y={type:"array",items:d({...c,hubId:n,hubName:r,network:s,supplyApy:{...i,description:"Fraction: 0.05 means 5%."},borrowApy:{...i,description:"Fraction: 0.05 means 5%."},priceUsd:i,priceStatus:p,spokes:{type:"array",items:h},dataStatus:l,indexedAt:{...n,description:"Pool state timestamp. Capacities are indexed snapshot estimates; prepare/simulate before signing."},indexedLedger:n})};function b(e){if(!e)return;const t=/\s*<([^<>\s]+)>\s*((?:;\s*[\w!#$%&'*+.^`|~-]+\s*=\s*(?:"(?:[^"\\\r\n]|\\.)*"|[\w!#$%&'*+.^`|~:/-]+)\s*)*)(,|$)/gy;let r,n=0;for(;n<e.length;){const a=t.exec(e);if(!a||a[3]&&t.lastIndex===e.length)throw new Error("Invalid pagination Link header");let o=!1,i=!1;for(const e of a[2].matchAll(/;\s*([\w!#$%&'*+.^`|~-]+)\s*=\s*(?:"((?:[^"\\\r\n]|\\.)*)"|([\w!#$%&'*+.^`|~:/-]+))\s*/g))if("rel"===e[1].toLowerCase()){if(i)throw new Error("Duplicate pagination link relation");i=!0,o=(e[2]??e[3]).replace(/\\(.)/g,"$1").toLowerCase().split(/\s+/).includes("next")}if(o){if(void 0!==r)throw new Error("Multiple next pagination links");r=a[1]}n=t.lastIndex}return r}function f(e){const t=new URL(e.baseUrl.trim());if(!["https:","http:"].includes(t.protocol)||t.username||t.password||t.search||t.hash)throw new Error("baseUrl must be an HTTP API root without credentials, query or fragment");t.pathname=`${t.pathname.replace(/\/+$/,"")}/`;const r=e.fetch??globalThis.fetch?.bind(globalThis);if(!r)throw new Error("A fetch implementation is required");async function n(e,n){const a=new URL(`stellar-lending/v1/${e}`,t);let o=a;const i=new Set,s=[];for(;;){if(i.has(o.href))throw new Error("Pagination Link cycle");i.add(o.href);const e=await r(o.href,{signal:n,redirect:"error"});if(e.redirected||e.url&&new URL(e.url).href!==o.href)throw new Error("Stellar lending redirects are not allowed");if(!e.ok)throw new Error(`Stellar lending request failed: HTTP ${e.status}`);const t=await e.json();if(!Array.isArray(t))throw new Error("Stellar lending response must be an array");s.push(...t);const l=b(e.headers.get("Link"));if(!l)break;const d=new URL(l,o);if(d.origin!==a.origin||d.pathname!==a.pathname||d.username||d.password||d.hash)throw new Error("Pagination Link must stay on the same API endpoint");o=d}return s}return{assets:({usage:e,signal:t}={})=>{if(void 0!==e&&"collateral"!==e&&"borrow"!==e)throw new Error("usage must be collateral or borrow");return n("assets"+(e?`?usage=${e}`:""),t)},positions:(e,{signal:t}={})=>{if(!e.trim()||"."===e||".."===e)throw new Error("owner is required");return n(`users/${encodeURIComponent(e)}/positions`,t)}}}module.exports=t})();
@@ -0,0 +1,4 @@
1
+ /** Dependency-free Stellar lending REST reads and public response contracts. */
2
+ export * from './types.js';
3
+ export * from './schemas.js';
4
+ export * from './client.js';
@@ -0,0 +1 @@
1
+ const e={type:"string"},t={type:"number"},r={type:"boolean"},n={...e,nullable:!0},a={...t,nullable:!0},o={...e,enum:["mainnet","testnet"]},s={...e,enum:["ready","stale","incomplete"]};function i(e){return{type:"object",required:Object.keys(e),properties:e}}const l={sac:e,symbol:e,name:e,decimals:a,logoUrl:n},p=i({valid:r,stale:r,deviation:r,timestamp:a}),c=i({...l,hubId:t,hubName:e,amountRaw:{...n,description:"Integer token base units, never scaled shares."},amount:n,apy:{...a,description:"Fraction: 0.05 means 5%."},priceUsd:a,valueUsd:a,priceStatus:p,indexRay:n,indexedAt:t,indexedLedger:t}),d=i({amountRaw:n,amount:n,usd:a}),u=i({spokeId:t,spokeName:e,ltvBps:t,supplyCapacity:d,borrowCapacity:d,canSupply:r,canBeCollateral:r,canBorrow:r,canOpenAccount:{...r,description:"Spoke admits new accounts; other entry gates still apply."}}),w={type:"array",items:i({accountId:e,nftContract:e,network:o,spokeId:a,spokeName:n,supplied:{type:"array",items:c},borrow:{type:"array",items:c},hasDebt:{...r,nullable:!0,description:"Null when account rows are unavailable."},healthFactor:{...a,description:"Null without debt or when risk inputs are unavailable."},borrowLimitUsd:a,availableBorrowUsd:{...a,description:"Account headroom, before per-market constraints."},netApy:{...a,description:"Net annual yield divided by positive net equity; fraction."},dataStatus:s})},h={type:"array",items:i({...l,hubId:t,hubName:e,network:o,supplyApy:{...a,description:"Fraction: 0.05 means 5%."},borrowApy:{...a,description:"Fraction: 0.05 means 5%."},priceUsd:a,priceStatus:p,spokes:{type:"array",items:u},dataStatus:s,indexedAt:{...t,description:"Pool state timestamp. Capacities are indexed snapshot estimates; prepare/simulate before signing."},indexedLedger:t})};function m(e){if(!e)return;const t=/\s*<([^<>\s]+)>\s*((?:;\s*[\w!#$%&'*+.^`|~-]+\s*=\s*(?:"(?:[^"\\\r\n]|\\.)*"|[\w!#$%&'*+.^`|~:/-]+)\s*)*)(,|$)/gy;let r,n=0;for(;n<e.length;){const a=t.exec(e);if(!a||a[3]&&t.lastIndex===e.length)throw new Error("Invalid pagination Link header");let o=!1,s=!1;for(const e of a[2].matchAll(/;\s*([\w!#$%&'*+.^`|~-]+)\s*=\s*(?:"((?:[^"\\\r\n]|\\.)*)"|([\w!#$%&'*+.^`|~:/-]+))\s*/g))if("rel"===e[1].toLowerCase()){if(s)throw new Error("Duplicate pagination link relation");s=!0,o=(e[2]??e[3]).replace(/\\(.)/g,"$1").toLowerCase().split(/\s+/).includes("next")}if(o){if(void 0!==r)throw new Error("Multiple next pagination links");r=a[1]}n=t.lastIndex}return r}function y(e){const t=new URL(e.baseUrl.trim());if(!["https:","http:"].includes(t.protocol)||t.username||t.password||t.search||t.hash)throw new Error("baseUrl must be an HTTP API root without credentials, query or fragment");t.pathname=`${t.pathname.replace(/\/+$/,"")}/`;const r=e.fetch??globalThis.fetch?.bind(globalThis);if(!r)throw new Error("A fetch implementation is required");async function n(e,n){const a=new URL(`stellar-lending/v1/${e}`,t);let o=a;const s=new Set,i=[];for(;;){if(s.has(o.href))throw new Error("Pagination Link cycle");s.add(o.href);const e=await r(o.href,{signal:n,redirect:"error"});if(e.redirected||e.url&&new URL(e.url).href!==o.href)throw new Error("Stellar lending redirects are not allowed");if(!e.ok)throw new Error(`Stellar lending request failed: HTTP ${e.status}`);const t=await e.json();if(!Array.isArray(t))throw new Error("Stellar lending response must be an array");i.push(...t);const l=m(e.headers.get("Link"));if(!l)break;const p=new URL(l,o);if(p.origin!==a.origin||p.pathname!==a.pathname||p.username||p.password||p.hash)throw new Error("Pagination Link must stay on the same API endpoint");o=p}return i}return{assets:({usage:e,signal:t}={})=>{if(void 0!==e&&"collateral"!==e&&"borrow"!==e)throw new Error("usage must be collateral or borrow");return n("assets"+(e?`?usage=${e}`:""),t)},positions:(e,{signal:t}={})=>{if(!e.trim()||"."===e||".."===e)throw new Error("owner is required");return n(`users/${encodeURIComponent(e)}/positions`,t)}}}export{y as createStellarLendingReadClient,h as lendingAssetsSchema,w as lendingPositionsSchema};
@@ -0,0 +1,370 @@
1
+ /** OpenAPI response schema for LendingPosition[]. Every property is required; nullable data remains explicit. */
2
+ export declare const lendingPositionsSchema: {
3
+ type: "array";
4
+ items: {
5
+ type: "object";
6
+ required: string[];
7
+ properties: {
8
+ accountId: {
9
+ type: "string";
10
+ };
11
+ nftContract: {
12
+ type: "string";
13
+ };
14
+ network: {
15
+ enum: string[];
16
+ type: "string";
17
+ };
18
+ spokeId: {
19
+ nullable: boolean;
20
+ type: "number";
21
+ };
22
+ spokeName: {
23
+ nullable: boolean;
24
+ type: "string";
25
+ };
26
+ supplied: {
27
+ type: "array";
28
+ items: {
29
+ type: "object";
30
+ required: string[];
31
+ properties: {
32
+ hubId: {
33
+ type: "number";
34
+ };
35
+ hubName: {
36
+ type: "string";
37
+ };
38
+ amountRaw: {
39
+ description: string;
40
+ nullable: boolean;
41
+ type: "string";
42
+ };
43
+ amount: {
44
+ nullable: boolean;
45
+ type: "string";
46
+ };
47
+ apy: {
48
+ description: string;
49
+ nullable: boolean;
50
+ type: "number";
51
+ };
52
+ priceUsd: {
53
+ nullable: boolean;
54
+ type: "number";
55
+ };
56
+ valueUsd: {
57
+ nullable: boolean;
58
+ type: "number";
59
+ };
60
+ priceStatus: {
61
+ type: "object";
62
+ required: string[];
63
+ properties: {
64
+ valid: {
65
+ type: "boolean";
66
+ };
67
+ stale: {
68
+ type: "boolean";
69
+ };
70
+ deviation: {
71
+ type: "boolean";
72
+ };
73
+ timestamp: {
74
+ nullable: boolean;
75
+ type: "number";
76
+ };
77
+ };
78
+ };
79
+ indexRay: {
80
+ nullable: boolean;
81
+ type: "string";
82
+ };
83
+ indexedAt: {
84
+ type: "number";
85
+ };
86
+ indexedLedger: {
87
+ type: "number";
88
+ };
89
+ sac: {
90
+ type: "string";
91
+ };
92
+ symbol: {
93
+ type: "string";
94
+ };
95
+ name: {
96
+ type: "string";
97
+ };
98
+ decimals: {
99
+ nullable: boolean;
100
+ type: "number";
101
+ };
102
+ logoUrl: {
103
+ nullable: boolean;
104
+ type: "string";
105
+ };
106
+ };
107
+ };
108
+ };
109
+ borrow: {
110
+ type: "array";
111
+ items: {
112
+ type: "object";
113
+ required: string[];
114
+ properties: {
115
+ hubId: {
116
+ type: "number";
117
+ };
118
+ hubName: {
119
+ type: "string";
120
+ };
121
+ amountRaw: {
122
+ description: string;
123
+ nullable: boolean;
124
+ type: "string";
125
+ };
126
+ amount: {
127
+ nullable: boolean;
128
+ type: "string";
129
+ };
130
+ apy: {
131
+ description: string;
132
+ nullable: boolean;
133
+ type: "number";
134
+ };
135
+ priceUsd: {
136
+ nullable: boolean;
137
+ type: "number";
138
+ };
139
+ valueUsd: {
140
+ nullable: boolean;
141
+ type: "number";
142
+ };
143
+ priceStatus: {
144
+ type: "object";
145
+ required: string[];
146
+ properties: {
147
+ valid: {
148
+ type: "boolean";
149
+ };
150
+ stale: {
151
+ type: "boolean";
152
+ };
153
+ deviation: {
154
+ type: "boolean";
155
+ };
156
+ timestamp: {
157
+ nullable: boolean;
158
+ type: "number";
159
+ };
160
+ };
161
+ };
162
+ indexRay: {
163
+ nullable: boolean;
164
+ type: "string";
165
+ };
166
+ indexedAt: {
167
+ type: "number";
168
+ };
169
+ indexedLedger: {
170
+ type: "number";
171
+ };
172
+ sac: {
173
+ type: "string";
174
+ };
175
+ symbol: {
176
+ type: "string";
177
+ };
178
+ name: {
179
+ type: "string";
180
+ };
181
+ decimals: {
182
+ nullable: boolean;
183
+ type: "number";
184
+ };
185
+ logoUrl: {
186
+ nullable: boolean;
187
+ type: "string";
188
+ };
189
+ };
190
+ };
191
+ };
192
+ hasDebt: {
193
+ nullable: boolean;
194
+ description: string;
195
+ type: "boolean";
196
+ };
197
+ healthFactor: {
198
+ description: string;
199
+ nullable: boolean;
200
+ type: "number";
201
+ };
202
+ borrowLimitUsd: {
203
+ nullable: boolean;
204
+ type: "number";
205
+ };
206
+ availableBorrowUsd: {
207
+ description: string;
208
+ nullable: boolean;
209
+ type: "number";
210
+ };
211
+ netApy: {
212
+ description: string;
213
+ nullable: boolean;
214
+ type: "number";
215
+ };
216
+ dataStatus: {
217
+ enum: string[];
218
+ type: "string";
219
+ };
220
+ };
221
+ };
222
+ };
223
+ /** OpenAPI response schema for LendingAsset[]. Capacities are indexed estimates. */
224
+ export declare const lendingAssetsSchema: {
225
+ type: "array";
226
+ items: {
227
+ type: "object";
228
+ required: string[];
229
+ properties: {
230
+ hubId: {
231
+ type: "number";
232
+ };
233
+ hubName: {
234
+ type: "string";
235
+ };
236
+ network: {
237
+ enum: string[];
238
+ type: "string";
239
+ };
240
+ supplyApy: {
241
+ description: string;
242
+ nullable: boolean;
243
+ type: "number";
244
+ };
245
+ borrowApy: {
246
+ description: string;
247
+ nullable: boolean;
248
+ type: "number";
249
+ };
250
+ priceUsd: {
251
+ nullable: boolean;
252
+ type: "number";
253
+ };
254
+ priceStatus: {
255
+ type: "object";
256
+ required: string[];
257
+ properties: {
258
+ valid: {
259
+ type: "boolean";
260
+ };
261
+ stale: {
262
+ type: "boolean";
263
+ };
264
+ deviation: {
265
+ type: "boolean";
266
+ };
267
+ timestamp: {
268
+ nullable: boolean;
269
+ type: "number";
270
+ };
271
+ };
272
+ };
273
+ spokes: {
274
+ type: "array";
275
+ items: {
276
+ type: "object";
277
+ required: string[];
278
+ properties: {
279
+ spokeId: {
280
+ type: "number";
281
+ };
282
+ spokeName: {
283
+ type: "string";
284
+ };
285
+ ltvBps: {
286
+ type: "number";
287
+ };
288
+ supplyCapacity: {
289
+ type: "object";
290
+ required: string[];
291
+ properties: {
292
+ amountRaw: {
293
+ nullable: boolean;
294
+ type: "string";
295
+ };
296
+ amount: {
297
+ nullable: boolean;
298
+ type: "string";
299
+ };
300
+ usd: {
301
+ nullable: boolean;
302
+ type: "number";
303
+ };
304
+ };
305
+ };
306
+ borrowCapacity: {
307
+ type: "object";
308
+ required: string[];
309
+ properties: {
310
+ amountRaw: {
311
+ nullable: boolean;
312
+ type: "string";
313
+ };
314
+ amount: {
315
+ nullable: boolean;
316
+ type: "string";
317
+ };
318
+ usd: {
319
+ nullable: boolean;
320
+ type: "number";
321
+ };
322
+ };
323
+ };
324
+ canSupply: {
325
+ type: "boolean";
326
+ };
327
+ canBeCollateral: {
328
+ type: "boolean";
329
+ };
330
+ canBorrow: {
331
+ type: "boolean";
332
+ };
333
+ canOpenAccount: {
334
+ description: string;
335
+ type: "boolean";
336
+ };
337
+ };
338
+ };
339
+ };
340
+ dataStatus: {
341
+ enum: string[];
342
+ type: "string";
343
+ };
344
+ indexedAt: {
345
+ description: string;
346
+ type: "number";
347
+ };
348
+ indexedLedger: {
349
+ type: "number";
350
+ };
351
+ sac: {
352
+ type: "string";
353
+ };
354
+ symbol: {
355
+ type: "string";
356
+ };
357
+ name: {
358
+ type: "string";
359
+ };
360
+ decimals: {
361
+ nullable: boolean;
362
+ type: "number";
363
+ };
364
+ logoUrl: {
365
+ nullable: boolean;
366
+ type: "string";
367
+ };
368
+ };
369
+ };
370
+ };
@@ -0,0 +1,83 @@
1
+ /** Render-ready REST data. Null means unavailable, never an inferred zero. */
2
+ export type LendingAssetUsage = 'collateral' | 'borrow';
3
+ export type LendingDataStatus = 'ready' | 'stale' | 'incomplete';
4
+ export interface LendingToken {
5
+ sac: string;
6
+ symbol: string;
7
+ name: string;
8
+ decimals: number | null;
9
+ logoUrl: string | null;
10
+ }
11
+ export interface LendingPriceStatus {
12
+ valid: boolean;
13
+ stale: boolean;
14
+ deviation: boolean;
15
+ timestamp: number | null;
16
+ }
17
+ export interface PositionAsset extends LendingToken {
18
+ hubId: number;
19
+ hubName: string;
20
+ /** Integer token base units, never scaled shares. */
21
+ amountRaw: string | null;
22
+ amount: string | null;
23
+ /** Fraction: 0.05 means 5%. */
24
+ apy: number | null;
25
+ priceUsd: number | null;
26
+ valueUsd: number | null;
27
+ priceStatus: LendingPriceStatus;
28
+ indexRay: string | null;
29
+ indexedAt: number;
30
+ indexedLedger: number;
31
+ }
32
+ export interface LendingPosition {
33
+ accountId: string;
34
+ nftContract: string;
35
+ network: 'mainnet' | 'testnet';
36
+ spokeId: number | null;
37
+ spokeName: string | null;
38
+ supplied: PositionAsset[];
39
+ borrow: PositionAsset[];
40
+ /** Null when account rows are unavailable. */
41
+ hasDebt: boolean | null;
42
+ /** Null without debt or when risk inputs are unavailable. */
43
+ healthFactor: number | null;
44
+ borrowLimitUsd: number | null;
45
+ /** Account headroom, before per-market constraints. */
46
+ availableBorrowUsd: number | null;
47
+ /** Net annual yield divided by positive net equity; fraction. */
48
+ netApy: number | null;
49
+ dataStatus: LendingDataStatus;
50
+ }
51
+ export interface Capacity {
52
+ amountRaw: string | null;
53
+ amount: string | null;
54
+ usd: number | null;
55
+ }
56
+ export interface AssetSpoke {
57
+ spokeId: number;
58
+ spokeName: string;
59
+ ltvBps: number;
60
+ supplyCapacity: Capacity;
61
+ borrowCapacity: Capacity;
62
+ canSupply: boolean;
63
+ canBeCollateral: boolean;
64
+ canBorrow: boolean;
65
+ /** Spoke admits new accounts; other entry gates still apply. */
66
+ canOpenAccount: boolean;
67
+ }
68
+ export interface LendingAsset extends LendingToken {
69
+ hubId: number;
70
+ hubName: string;
71
+ network: 'mainnet' | 'testnet';
72
+ /** Fraction: 0.05 means 5%. */
73
+ supplyApy: number | null;
74
+ /** Fraction: 0.05 means 5%. */
75
+ borrowApy: number | null;
76
+ priceUsd: number | null;
77
+ priceStatus: LendingPriceStatus;
78
+ spokes: AssetSpoke[];
79
+ dataStatus: LendingDataStatus;
80
+ /** Pool timestamp. Capacities are indexed estimates; prepare/simulate before signing. */
81
+ indexedAt: number;
82
+ indexedLedger: number;
83
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xoxno/sdk-js",
3
- "version": "1.0.224",
3
+ "version": "1.0.226",
4
4
  "description": "The SDK to interact with the XOXNO Protocol!",
5
5
  "type": "module",
6
6
  "exports": {
@@ -24,6 +24,16 @@
24
24
  "default": "./dist/sdk/stellar/index.cjs"
25
25
  }
26
26
  },
27
+ "./stellar-lending/read": {
28
+ "import": {
29
+ "types": "./dist/sdk/stellar/read/index.d.ts",
30
+ "default": "./dist/sdk/stellar/read/index.esm.js"
31
+ },
32
+ "require": {
33
+ "types": "./dist/cjs/sdk/stellar/read/index.d.ts",
34
+ "default": "./dist/sdk/stellar/read/index.cjs"
35
+ }
36
+ },
27
37
  "./stellar-swap": {
28
38
  "import": {
29
39
  "types": "./dist/sdk/stellar/swap-index.d.ts",
@@ -46,11 +56,11 @@
46
56
  "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
47
57
  "build:sdk": "npx bun run src/sdk/parseSwagger.ts --offline && npx oxlint src/sdk/swagger.ts --fix && npx bun run md/extract.ts",
48
58
  "build:types": "tsc --emitDeclarationOnly && node scripts/emit-cjs-dts.mjs",
49
- "build:esm": "webpack --config webpack-esm.config.mjs",
59
+ "build:esm": "swc src -d dist/esm --strip-leading-paths --config-file swc-esm.json -C jsc.baseUrl=$PWD/src && node scripts/emit-esm-entries.mjs && webpack --config webpack-esm.config.mjs",
50
60
  "build:cjs": "webpack --config webpack-cjs.config.mjs",
51
61
  "build": "npm run build:sdk && npm run build:types && npm run build:esm && npm run build:cjs",
52
62
  "verify:dist": "node -e \"const m=require('./dist/index.cjs'); if(typeof m.decodeStellarLendingEvent!=='function')throw new Error('CJS require broken'); console.log('CJS ok')\" && node --input-type=module -e \"import('./dist/index.esm.js').then(m=>{if(typeof m.decodeStellarLendingEvent!=='function')throw new Error('ESM import broken'); console.log('ESM ok')})\" && npm run test:swap",
53
- "prepublishOnly": "npm run verify:dist",
63
+ "prepublishOnly": "npm run verify:dist && npm run test:read",
54
64
  "lint": "oxlint src",
55
65
  "format": "oxlint src --fix",
56
66
  "commit": "git-cz",
@@ -60,7 +70,8 @@
60
70
  "docs:stellar": "typedoc --options typedoc.stellar.json",
61
71
  "check:examples": "tsc --project tsconfig.examples.json",
62
72
  "test:browser": "node --experimental-vm-modules scripts/check-stellar-browser.mjs",
63
- "test:swap": "node scripts/check-stellar-swap.mjs"
73
+ "test:swap": "node scripts/check-stellar-swap.mjs",
74
+ "test:read": "node --experimental-vm-modules scripts/check-stellar-read.mjs"
64
75
  },
65
76
  "config": {
66
77
  "commitizen": {
@@ -134,5 +145,10 @@
134
145
  },
135
146
  "peerDependencies": {
136
147
  "@stellar/stellar-sdk": ">=15.0.0 <18.0.0"
148
+ },
149
+ "peerDependenciesMeta": {
150
+ "@stellar/stellar-sdk": {
151
+ "optional": true
152
+ }
137
153
  }
138
154
  }
@@ -1,8 +0,0 @@
1
- /*!
2
- * The buffer module from node.js, for the browser.
3
- *
4
- * @author Feross Aboukhadijeh <https://feross.org>
5
- * @license MIT
6
- */
7
-
8
- /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */