@xoxno/sdk-js 1.0.226 → 1.0.228
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/cjs/sdk/stellar/__tests__/amount.test.d.ts +1 -0
- package/dist/cjs/sdk/stellar/lending.d.ts +9 -0
- package/dist/cjs/sdk/stellar/read/schemas.d.ts +5 -0
- package/dist/cjs/sdk/stellar/read/types.d.ts +2 -0
- package/dist/esm/sdk/stellar/lending.js +22 -1
- package/dist/esm/sdk/stellar/read/schemas.js +5 -0
- package/dist/index.cjs +1 -1
- package/dist/sdk/stellar/__tests__/amount.test.d.ts +1 -0
- package/dist/sdk/stellar/index.cjs +1 -1
- package/dist/sdk/stellar/index.esm.js +1 -1
- package/dist/sdk/stellar/lending.d.ts +9 -0
- package/dist/sdk/stellar/read/index.cjs +1 -1
- package/dist/sdk/stellar/read/index.esm.js +1 -1
- package/dist/sdk/stellar/read/schemas.d.ts +5 -0
- package/dist/sdk/stellar/read/types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -19,6 +19,15 @@
|
|
|
19
19
|
import { xdr } from '@stellar/stellar-sdk';
|
|
20
20
|
import { type StellarNetwork } from './contracts.js';
|
|
21
21
|
import { type StellarSeizeModeInput, type StellarStrategySwapHopInput, type StellarStrategySwapInput, type StellarStrategySwapPathInput } from './scval-encode.js';
|
|
22
|
+
/**
|
|
23
|
+
* Convert a positive decimal token amount into a builder-ready base-unit string.
|
|
24
|
+
* Uses Stellar's exact string parser; never rounds excess precision or uses floats.
|
|
25
|
+
* @param amount - Plain decimal text, for example '1.25'; no sign or exponent.
|
|
26
|
+
* @param decimals - Token decimal places, from 0 to 18; null metadata is rejected.
|
|
27
|
+
* @throws If the input is invalid, non-positive, over-precise, or exceeds i128.
|
|
28
|
+
* @example parseStellarTokenAmount('1.25', 7) // '12500000'
|
|
29
|
+
*/
|
|
30
|
+
export declare function parseStellarTokenAmount(amount: string, decimals: number | null): string;
|
|
22
31
|
/**
|
|
23
32
|
* Stellar `G...` public key of the caller (tx source account).
|
|
24
33
|
*/
|
|
@@ -1 +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:()=>
|
|
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:()=>b,lendingAssetsSchema:()=>y,lendingPositionsSchema:()=>h});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}),m=d({amountRaw:o,amount:o,usd:i}),w=d({spokeId:n,spokeName:r,ltvBps:n,supplyCapacity:m,borrowCapacity:m,canSupply:a,canBeCollateral:a,canBorrow:a,canOpenAccount:{...a,description:"Spoke admits new accounts; other entry gates still apply."}}),h={type:"array",items:d({accountId:r,nftContract:r,nftImage:{...r,format:"uri",description:"Dynamic position SVG served by the network's XOXNO API."},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:w},dataStatus:l,indexedAt:{...n,description:"Pool state timestamp. Capacities are indexed snapshot estimates; prepare/simulate before signing."},indexedLedger:n})};function f(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 b(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=f(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})();
|
|
@@ -1 +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"]},
|
|
1
|
+
const e={type:"string"},t={type:"number"},r={type:"boolean"},n={...e,nullable:!0},a={...t,nullable:!0},o={...e,enum:["mainnet","testnet"]},i={...e,enum:["ready","stale","incomplete"]};function s(e){return{type:"object",required:Object.keys(e),properties:e}}const l={sac:e,symbol:e,name:e,decimals:a,logoUrl:n},p=s({valid:r,stale:r,deviation:r,timestamp:a}),c=s({...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=s({amountRaw:n,amount:n,usd:a}),u=s({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:s({accountId:e,nftContract:e,nftImage:{...e,format:"uri",description:"Dynamic position SVG served by the network's XOXNO API."},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:i})},h={type:"array",items:s({...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:i,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,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 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 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=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 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)}}}export{y as createStellarLendingReadClient,h as lendingAssetsSchema,w as lendingPositionsSchema};
|
|
@@ -32,6 +32,8 @@ export interface PositionAsset extends LendingToken {
|
|
|
32
32
|
export interface LendingPosition {
|
|
33
33
|
accountId: string;
|
|
34
34
|
nftContract: string;
|
|
35
|
+
/** Dynamic position SVG served by the network's XOXNO API. */
|
|
36
|
+
nftImage: string;
|
|
35
37
|
network: 'mainnet' | 'testnet';
|
|
36
38
|
spokeId: number | null;
|
|
37
39
|
spokeName: string | null;
|