@glacislabs/stablegenie-zerodelta 4.2.1 → 4.3.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.
@@ -649,6 +649,30 @@ interface BrokenLane {
649
649
  message: string;
650
650
  kind?: string;
651
651
  }
652
+ /**
653
+ * A lane the gateway says is tradeable only up to a measured amount right now — availability state
654
+ * `limited`, as {@link destinationAvailability}'s callers consume it. See `limitedLanes` in
655
+ * `core/route-health.ts`, which is the only producer.
656
+ *
657
+ * The limit names ONE hop of the lane: `bid` is the hop the payer's own amount travels (so the amount
658
+ * field can be checked against it before a quote is asked for); `ask` is the payout hop, which the
659
+ * payer does not type in the same units and which is therefore shown, never enforced, here.
660
+ */
661
+ interface LaneLimit {
662
+ side: "bid" | "ask";
663
+ /** The gateway's name for the hop's token. Untrusted display text — print it through
664
+ * `laneLimitSymbol`, never directly. */
665
+ token: string;
666
+ fromChainId: number;
667
+ toChainId: number;
668
+ /** The most the hop can carry right now, in BASE UNITS of the hop's token (a decimal integer string). */
669
+ maxAmount: string;
670
+ /** Decimals `maxAmount` is denominated in. */
671
+ decimals: number;
672
+ /** The code `/quote` answers the lane with above the limit, e.g. `BRIDGE_RATE_LIMITED`. */
673
+ code: string;
674
+ measuredAt?: string;
675
+ }
652
676
  interface CatalogueContext {
653
677
  /** From {@link sourceKeys}. */
654
678
  source: ReadonlySet<string>;
@@ -695,6 +719,12 @@ type Availability = "available" | "hub-only" | "unreachable";
695
719
  * the destination alone would remove working routes to fix one broken one.
696
720
  */
697
721
  declare function brokenLaneFor(token: Pick<Token, "chainId" | "address">, source: Pick<Token, "chainId" | "address"> | undefined, brokenLanes: ReadonlyMap<string, BrokenLane> | undefined): BrokenLane | undefined;
722
+ /**
723
+ * The published size limit for this exact (source, destination) pair, if the lane is `limited`.
724
+ * Keyed on both ends for the same reason {@link brokenLaneFor} is: a limit is a property of the
725
+ * hops a lane crosses, and the same destination reached from another source crosses other hops.
726
+ */
727
+ declare function laneLimitFor(token: Pick<Token, "chainId" | "address">, source: Pick<Token, "chainId" | "address"> | null | undefined, limitedLanes: ReadonlyMap<string, LaneLimit> | undefined): LaneLimit | undefined;
698
728
  /**
699
729
  * Whether an ask token can actually be delivered on its own chain.
700
730
  *
@@ -729,6 +759,9 @@ interface CatalogueInput {
729
759
  supportedChainIds: ReadonlySet<number>;
730
760
  /** Measured refusals; omit or pass an empty map to suppress nothing. */
731
761
  brokenLanes?: ReadonlyMap<string, BrokenLane>;
762
+ /** Published size limits (`limitedLanes`); omit or pass an empty map to limit nothing. Carried
763
+ * through untouched — a limited lane stays offered, so it changes no verdict here. */
764
+ limitedLanes?: ReadonlyMap<string, LaneLimit>;
732
765
  /** Vault artwork by symbol key (see `core/rwa-icons.ts`). Carried through untouched. */
733
766
  vaultIcons?: ReadonlyMap<string, string>;
734
767
  }
@@ -764,6 +797,12 @@ interface Catalogue extends CatalogueContext {
764
797
  * published none.
765
798
  */
766
799
  vaultIcons: ReadonlyMap<string, string>;
800
+ /**
801
+ * Lanes that are offered but tradeable only up to a measured amount right now, keyed by
802
+ * {@link laneKey}. Read it with {@link laneLimitFor}. Empty when the gateway publishes no
803
+ * availability (an older gateway), is in observe mode, or the health read failed.
804
+ */
805
+ limitedLanes: ReadonlyMap<string, LaneLimit>;
767
806
  }
768
807
  /**
769
808
  * Build the selectable catalogue from the live registry.
@@ -775,6 +814,24 @@ interface Catalogue extends CatalogueContext {
775
814
  */
776
815
  declare function buildCatalogue(input: CatalogueInput): Catalogue;
777
816
 
817
+ /** A lane's availability as the gateway publishes it. Permissive: this is untrusted API data. */
818
+ interface RouteHealthAvailability {
819
+ state?: string;
820
+ code?: string;
821
+ message?: string;
822
+ limit?: {
823
+ side?: string;
824
+ token?: string;
825
+ fromChainId?: number | string;
826
+ toChainId?: number | string;
827
+ /** Base units of the hop's token. */
828
+ maxAmount?: string;
829
+ decimals?: number;
830
+ measuredAt?: string;
831
+ [k: string]: unknown;
832
+ };
833
+ [k: string]: unknown;
834
+ }
778
835
  /** One lane as the gateway reports it. Permissive on purpose — this is untrusted API data and the
779
836
  * projection below reads only what it needs. */
780
837
  interface RouteHealthLane {
@@ -784,6 +841,8 @@ interface RouteHealthLane {
784
841
  kind?: string;
785
842
  code?: string;
786
843
  message?: string;
844
+ /** Absent on a gateway that predates lane availability. */
845
+ availability?: RouteHealthAvailability;
787
846
  [k: string]: unknown;
788
847
  }
789
848
  interface RouteHealth {
@@ -795,6 +854,9 @@ interface RouteHealth {
795
854
  degraded?: number;
796
855
  broken?: number;
797
856
  unknown?: number;
857
+ available?: number;
858
+ limited?: number;
859
+ unavailable?: number;
798
860
  total?: number;
799
861
  };
800
862
  measuredAt?: string;
@@ -802,6 +864,16 @@ interface RouteHealth {
802
864
  lanes?: RouteHealthLane[];
803
865
  [k: string]: unknown;
804
866
  }
867
+ /** The three availability states a lane can publish. */
868
+ type LaneAvailabilityState = "available" | "limited" | "unavailable";
869
+ /**
870
+ * The availability state a lane publishes, or `null` when it publishes none this client understands.
871
+ *
872
+ * `null` covers an absent field (an older gateway) AND a malformed or unrecognised one. Both fall back
873
+ * to the status rule rather than to "available": a garbled field must not quietly un-hide a lane its
874
+ * status still condemns, and a state this build has never heard of is not an answer it can act on.
875
+ */
876
+ declare function laneAvailabilityState(lane: RouteHealthLane | undefined | null): LaneAvailabilityState | null;
805
877
  /**
806
878
  * The lanes the picker must stop offering, keyed by `laneKey`.
807
879
  *
@@ -810,16 +882,66 @@ interface RouteHealth {
810
882
  * - the response arrived;
811
883
  * - the gateway says `mode: "enforce"`. In observe mode the data exists for operators, and acting
812
884
  * on it would defeat the shadow-period rollout the mode flag exists to provide;
813
- * - the lane's status is `broken`, OR it is `unknown` with kind `firewalled`. DEGRADED lanes stay
814
- * SELECTABLE — the measured answer there is "it works, but mind the size", and removing it would
815
- * take a working route away. Every OTHER unknown stays selectable too: "we have not measured it"
816
- * is not evidence. The firewalled kind is the one unknown that is a certainty rather than an
817
- * absence of one — an operator is refusing the lane through the route firewall, the gateway
818
- * answers "not tradeable" on sight, and the prober files it as unknown only so that lifting the
819
- * rule does not leave a demotion behind. Until 2026-09-09 that status kept every such lane
820
- * selectable here: 139 lanes into USDtb on prod, each one an error when picked.
885
+ * - the lane is withheld by ONE of two rules, chosen per lane:
886
+ *
887
+ * • it publishes `availability` → withheld iff `availability.state === "unavailable"`. A `limited`
888
+ * lane stays selectable and is offered with its limit (see {@link limitedLanes}).
889
+ *
890
+ * • it does not (a gateway that predates the field) → the original rule, unchanged: the status is
891
+ * `broken`, OR it is `unknown` with kind `firewalled`. DEGRADED lanes stay SELECTABLE — the
892
+ * measured answer there is "it works, but mind the size", and removing it would take a working
893
+ * route away. Every OTHER unknown stays selectable too: "we have not measured it" is not
894
+ * evidence. The firewalled kind is the one unknown that is a certainty rather than an absence of
895
+ * one — an operator is refusing the lane through the route firewall, the gateway answers "not
896
+ * tradeable" on sight, and the prober files it as unknown only so that lifting the rule does not
897
+ * leave a demotion behind. Until 2026-09-09 that status kept every such lane selectable here:
898
+ * 139 lanes into USDtb on prod, each one an error when picked.
821
899
  */
822
900
  declare function suppressedLanes(health: RouteHealth | undefined | null): ReadonlyMap<string, BrokenLane>;
901
+ /**
902
+ * Lanes that are offered, but tradeable only up to a measured amount right now, keyed by `laneKey`.
903
+ *
904
+ * Empty — limit nothing — unless the response arrived, the gateway says `mode: "enforce"` (observe
905
+ * mode publishes the same objects, and they are not to be acted on), and the lane's availability is
906
+ * `limited` with a well-formed `limit`. A limited lane whose limit cannot be read is left OUT rather
907
+ * than guessed at: a limit this client invented would refuse amounts the gateway would quote, and
908
+ * the gateway refuses a genuinely oversized order on its own, with the limit in `fieldErrors`.
909
+ */
910
+ declare function limitedLanes(health: RouteHealth | undefined | null): ReadonlyMap<string, LaneLimit>;
911
+ /**
912
+ * Whether `amount` — decimal text as the payer typed it, in the BID token's own units — is above a
913
+ * bid-side limit.
914
+ *
915
+ * `false` whenever it cannot tell: no limit, a payout-side (`ask`) limit, which is not denominated in
916
+ * what the payer types, or an amount that does not parse. Calling an amount this client could not
917
+ * read "over the limit" would withhold a quote the gateway might serve; the gateway refuses a
918
+ * genuinely oversized order on its own.
919
+ *
920
+ * Compared at the finer of the two scales, so neither side is rounded: the limit is denominated in
921
+ * the hop token's decimals, which are not guaranteed to be the bid deployment's.
922
+ */
923
+ declare function exceedsLaneLimit(limit: LaneLimit | undefined | null, amount: string, bidDecimals: number): boolean;
924
+ /** The limit as a human amount, rounded DOWN — a displayed maximum must never exceed the real one. */
925
+ declare function laneLimitAmount(limit: LaneLimit): string;
926
+ /**
927
+ * The symbol to print beside a limit.
928
+ *
929
+ * A bid-side limit is on the payer's own token, so the caller's ticker for the bid deployment wins —
930
+ * it is the name already printed on the amount field. Otherwise the gateway's `token` is printed only
931
+ * if it is a plain ticker (see `safeTicker`); a value that is not is dropped rather than rendered.
932
+ */
933
+ declare function laneLimitSymbol(limit: LaneLimit, bidTicker?: string): string;
934
+ /** The line a picker row and the amount field show for a limited lane: `Max 14 USDtb right now`. */
935
+ declare function laneLimitHint(limit: LaneLimit, symbol: string): string;
936
+ /**
937
+ * The inline amount error for an amount above a bid-side limit: `Maximum: 14 USDtb right now`.
938
+ *
939
+ * Worded as the gateway's own `fieldErrors` entry for the same refusal, so a payer reads the same
940
+ * sentence whether the widget caught the amount first or `/quote` did. The one difference is the
941
+ * amount: the gateway prints every decimal of the raw limit (an 18-decimal limiter reading can run to
942
+ * twenty digits), this rounds it DOWN to six — see {@link laneLimitAmount}.
943
+ */
944
+ declare function laneLimitError(limit: LaneLimit, symbol: string): string;
823
945
  /** A one-line reason a pair is hidden, for the picker row and the refusal panel. Never the raw
824
946
  * gateway message: that text is untrusted and can carry infrastructure detail. */
825
947
  declare function brokenLaneReason(lane: BrokenLane | undefined): string;
@@ -855,9 +977,14 @@ interface ApiError extends Error {
855
977
  code?: string;
856
978
  status?: number;
857
979
  reasons?: string[];
980
+ /** Per-field validation errors. `field` names the request field, e.g. `fromAmount` for a trade
981
+ * below the minimum size (`BELOW_MIN_TRADE_SIZE`) or above a bridge's current limit (`BRIDGE_RATE_LIMITED`). */
858
982
  fieldErrors?: Array<{
983
+ field?: string;
859
984
  message?: string;
860
985
  }>;
986
+ /** The size limits behind a `BRIDGE_RATE_LIMITED` refusal, as the gateway reports them. Untrusted. */
987
+ limits?: unknown[];
861
988
  blocked?: boolean;
862
989
  blockedCategory?: string;
863
990
  blockedReason?: string;
@@ -870,6 +997,16 @@ interface QuoteBlock {
870
997
  message: string;
871
998
  }
872
999
  declare function classifyQuoteError(error: any): QuoteBlock | null;
1000
+ /**
1001
+ * The gateway's error for the AMOUNT the payer typed, if the refusal names it — for rendering inline
1002
+ * under the amount field instead of as a generic quote failure.
1003
+ *
1004
+ * Answers the `fieldErrors` entry on `fromAmount`: a trade below the minimum size, or above a bridge's
1005
+ * current limit ("Maximum: 14 USDtb right now"). Either one is fixed by changing the amount and by
1006
+ * nothing else, so a "try again" affordance next to it would only re-ask the same question. The text is
1007
+ * untrusted and passes the same scrub as every other displayed message; null when there is none.
1008
+ */
1009
+ declare function amountFieldError(error: unknown): string | null;
873
1010
  interface ApiClient {
874
1011
  apiRequest: <T = any>(path: string, init?: RequestInit & {
875
1012
  timeoutMs?: number;
@@ -943,4 +1080,4 @@ interface Verifier {
943
1080
  }
944
1081
  declare function createVerifier(api: ApiClient, fetchImpl: typeof fetch, rpcOverrides?: Record<number, string>): Verifier;
945
1082
 
946
- export { type Hex as $, type Availability as A, type BrokenLane as B, type Compliance as C, type Address as D, type EngineConfig as E, type FetchQuoteFn as F, type ApiError as G, BLOCK_LABEL_DEFAULT as H, COMPLIANCE_CHECK_ORDER as I, COMPLIANCE_DENY_LABEL as J, type CatalogueContext as K, type CatalogueInput as L, type ComplianceCheckId as M, type NormalizedOrder as N, type OrderRequest as O, type Plan as P, type Quote as Q, type Route as R, type SanitizedTxEntry as S, type Token as T, type ComplianceDecision as U, type VerifyResult as V, type WalletScreen as W, DIRECT_CHECK_IDS as X, DIRECT_SCOPE_NOTE as Y, type Destination as Z, FLOOR_CATEGORIES as _, type Catalogue as a, type PlannedTxKind as a0, type QuoteBlock as a1, type ResolvedConfig as a2, type RouteHealth as a3, type RouteHealthLane as a4, SCREENING_BUCKETS as a5, type ScreenProvider as a6, type ScreeningBucket as a7, type ScreeningOutcome as a8, TUNABLE_CATEGORIES as a9, parseAllowedApiBase as aA, productAssets as aB, registryRpc as aC, resolveApiBase as aD, resolveConfig as aE, screeningOutcomeOf as aF, sourceKeys as aG, suppressedLanes as aH, tokenKey as aI, txMatchesPlan as aJ, unattributedComplianceReasons as aK, type TxPlan as aa, apiError as ab, blockLabelFor as ac, brokenLaneFor as ad, buildCatalogue as ae, canAttachApiKey as af, categoryLabel as ag, classifyQuoteError as ah, complianceControlsEvaluated as ai, complianceReasonHead as aj, complianceReasonTag as ak, complianceTagOf as al, createApiClient as am, createVerifier as an, destinationKeys as ao, directComplianceFromScreens as ap, distinctScreenedWallets as aq, executableRoutes as ar, executionChainIds as as, hasReachableDestination as at, hubDeliverableSymbols as au, isExecutableBridge as av, isKnownUnbridgeable as aw, isSourceToken as ax, laneKey as ay, laneKeys as az, type Chain as b, type ComplianceCheck as c, type ComplianceTone as d, type ComplianceView as e, type ExchangeProduct as f, type RouteLeg as g, type RouteResult as h, type TxHistoryEntry as i, assetClassOf as j, brokenLaneReason as k, complianceChecks as l, complianceControlsLine as m, complianceView as n, counterpartTokens as o, destinationAvailability as p, humanizeComplianceReason as q, type PayOption as r, type RwaVault as s, type SolveResult as t, type BalanceTarget as u, type BalanceEntry as v, type ApiClient as w, type SwapInput as x, type PlannedTx as y, type Verifier as z };
1083
+ export { FLOOR_CATEGORIES as $, type Availability as A, type BrokenLane as B, type Compliance as C, type Address as D, type EngineConfig as E, type FetchQuoteFn as F, type ApiError as G, BLOCK_LABEL_DEFAULT as H, COMPLIANCE_CHECK_ORDER as I, COMPLIANCE_DENY_LABEL as J, type CatalogueContext as K, type LaneLimit as L, type CatalogueInput as M, type NormalizedOrder as N, type OrderRequest as O, type Plan as P, type Quote as Q, type Route as R, type SanitizedTxEntry as S, type Token as T, type ComplianceCheckId as U, type VerifyResult as V, type WalletScreen as W, type ComplianceDecision as X, DIRECT_CHECK_IDS as Y, DIRECT_SCOPE_NOTE as Z, type Destination as _, type Catalogue as a, type Hex as a0, type LaneAvailabilityState as a1, type PlannedTxKind as a2, type QuoteBlock as a3, type ResolvedConfig as a4, type RouteHealth as a5, type RouteHealthAvailability as a6, type RouteHealthLane as a7, SCREENING_BUCKETS as a8, type ScreenProvider as a9, isExecutableBridge as aA, isKnownUnbridgeable as aB, isSourceToken as aC, laneAvailabilityState as aD, laneKey as aE, laneKeys as aF, laneLimitAmount as aG, laneLimitError as aH, laneLimitFor as aI, laneLimitHint as aJ, laneLimitSymbol as aK, limitedLanes as aL, parseAllowedApiBase as aM, productAssets as aN, registryRpc as aO, resolveApiBase as aP, resolveConfig as aQ, screeningOutcomeOf as aR, sourceKeys as aS, suppressedLanes as aT, tokenKey as aU, txMatchesPlan as aV, unattributedComplianceReasons as aW, type ScreeningBucket as aa, type ScreeningOutcome as ab, TUNABLE_CATEGORIES as ac, type TxPlan as ad, amountFieldError as ae, apiError as af, blockLabelFor as ag, brokenLaneFor as ah, buildCatalogue as ai, canAttachApiKey as aj, categoryLabel as ak, classifyQuoteError as al, complianceControlsEvaluated as am, complianceReasonHead as an, complianceReasonTag as ao, complianceTagOf as ap, createApiClient as aq, createVerifier as ar, destinationKeys as as, directComplianceFromScreens as at, distinctScreenedWallets as au, exceedsLaneLimit as av, executableRoutes as aw, executionChainIds as ax, hasReachableDestination as ay, hubDeliverableSymbols as az, type Chain as b, type ComplianceCheck as c, type ComplianceTone as d, type ComplianceView as e, type ExchangeProduct as f, type RouteLeg as g, type RouteResult as h, type TxHistoryEntry as i, assetClassOf as j, brokenLaneReason as k, complianceChecks as l, complianceControlsLine as m, complianceView as n, counterpartTokens as o, destinationAvailability as p, humanizeComplianceReason as q, type PayOption as r, type RwaVault as s, type SolveResult as t, type BalanceTarget as u, type BalanceEntry as v, type ApiClient as w, type SwapInput as x, type PlannedTx as y, type Verifier as z };
@@ -649,6 +649,30 @@ interface BrokenLane {
649
649
  message: string;
650
650
  kind?: string;
651
651
  }
652
+ /**
653
+ * A lane the gateway says is tradeable only up to a measured amount right now — availability state
654
+ * `limited`, as {@link destinationAvailability}'s callers consume it. See `limitedLanes` in
655
+ * `core/route-health.ts`, which is the only producer.
656
+ *
657
+ * The limit names ONE hop of the lane: `bid` is the hop the payer's own amount travels (so the amount
658
+ * field can be checked against it before a quote is asked for); `ask` is the payout hop, which the
659
+ * payer does not type in the same units and which is therefore shown, never enforced, here.
660
+ */
661
+ interface LaneLimit {
662
+ side: "bid" | "ask";
663
+ /** The gateway's name for the hop's token. Untrusted display text — print it through
664
+ * `laneLimitSymbol`, never directly. */
665
+ token: string;
666
+ fromChainId: number;
667
+ toChainId: number;
668
+ /** The most the hop can carry right now, in BASE UNITS of the hop's token (a decimal integer string). */
669
+ maxAmount: string;
670
+ /** Decimals `maxAmount` is denominated in. */
671
+ decimals: number;
672
+ /** The code `/quote` answers the lane with above the limit, e.g. `BRIDGE_RATE_LIMITED`. */
673
+ code: string;
674
+ measuredAt?: string;
675
+ }
652
676
  interface CatalogueContext {
653
677
  /** From {@link sourceKeys}. */
654
678
  source: ReadonlySet<string>;
@@ -695,6 +719,12 @@ type Availability = "available" | "hub-only" | "unreachable";
695
719
  * the destination alone would remove working routes to fix one broken one.
696
720
  */
697
721
  declare function brokenLaneFor(token: Pick<Token, "chainId" | "address">, source: Pick<Token, "chainId" | "address"> | undefined, brokenLanes: ReadonlyMap<string, BrokenLane> | undefined): BrokenLane | undefined;
722
+ /**
723
+ * The published size limit for this exact (source, destination) pair, if the lane is `limited`.
724
+ * Keyed on both ends for the same reason {@link brokenLaneFor} is: a limit is a property of the
725
+ * hops a lane crosses, and the same destination reached from another source crosses other hops.
726
+ */
727
+ declare function laneLimitFor(token: Pick<Token, "chainId" | "address">, source: Pick<Token, "chainId" | "address"> | null | undefined, limitedLanes: ReadonlyMap<string, LaneLimit> | undefined): LaneLimit | undefined;
698
728
  /**
699
729
  * Whether an ask token can actually be delivered on its own chain.
700
730
  *
@@ -729,6 +759,9 @@ interface CatalogueInput {
729
759
  supportedChainIds: ReadonlySet<number>;
730
760
  /** Measured refusals; omit or pass an empty map to suppress nothing. */
731
761
  brokenLanes?: ReadonlyMap<string, BrokenLane>;
762
+ /** Published size limits (`limitedLanes`); omit or pass an empty map to limit nothing. Carried
763
+ * through untouched — a limited lane stays offered, so it changes no verdict here. */
764
+ limitedLanes?: ReadonlyMap<string, LaneLimit>;
732
765
  /** Vault artwork by symbol key (see `core/rwa-icons.ts`). Carried through untouched. */
733
766
  vaultIcons?: ReadonlyMap<string, string>;
734
767
  }
@@ -764,6 +797,12 @@ interface Catalogue extends CatalogueContext {
764
797
  * published none.
765
798
  */
766
799
  vaultIcons: ReadonlyMap<string, string>;
800
+ /**
801
+ * Lanes that are offered but tradeable only up to a measured amount right now, keyed by
802
+ * {@link laneKey}. Read it with {@link laneLimitFor}. Empty when the gateway publishes no
803
+ * availability (an older gateway), is in observe mode, or the health read failed.
804
+ */
805
+ limitedLanes: ReadonlyMap<string, LaneLimit>;
767
806
  }
768
807
  /**
769
808
  * Build the selectable catalogue from the live registry.
@@ -775,6 +814,24 @@ interface Catalogue extends CatalogueContext {
775
814
  */
776
815
  declare function buildCatalogue(input: CatalogueInput): Catalogue;
777
816
 
817
+ /** A lane's availability as the gateway publishes it. Permissive: this is untrusted API data. */
818
+ interface RouteHealthAvailability {
819
+ state?: string;
820
+ code?: string;
821
+ message?: string;
822
+ limit?: {
823
+ side?: string;
824
+ token?: string;
825
+ fromChainId?: number | string;
826
+ toChainId?: number | string;
827
+ /** Base units of the hop's token. */
828
+ maxAmount?: string;
829
+ decimals?: number;
830
+ measuredAt?: string;
831
+ [k: string]: unknown;
832
+ };
833
+ [k: string]: unknown;
834
+ }
778
835
  /** One lane as the gateway reports it. Permissive on purpose — this is untrusted API data and the
779
836
  * projection below reads only what it needs. */
780
837
  interface RouteHealthLane {
@@ -784,6 +841,8 @@ interface RouteHealthLane {
784
841
  kind?: string;
785
842
  code?: string;
786
843
  message?: string;
844
+ /** Absent on a gateway that predates lane availability. */
845
+ availability?: RouteHealthAvailability;
787
846
  [k: string]: unknown;
788
847
  }
789
848
  interface RouteHealth {
@@ -795,6 +854,9 @@ interface RouteHealth {
795
854
  degraded?: number;
796
855
  broken?: number;
797
856
  unknown?: number;
857
+ available?: number;
858
+ limited?: number;
859
+ unavailable?: number;
798
860
  total?: number;
799
861
  };
800
862
  measuredAt?: string;
@@ -802,6 +864,16 @@ interface RouteHealth {
802
864
  lanes?: RouteHealthLane[];
803
865
  [k: string]: unknown;
804
866
  }
867
+ /** The three availability states a lane can publish. */
868
+ type LaneAvailabilityState = "available" | "limited" | "unavailable";
869
+ /**
870
+ * The availability state a lane publishes, or `null` when it publishes none this client understands.
871
+ *
872
+ * `null` covers an absent field (an older gateway) AND a malformed or unrecognised one. Both fall back
873
+ * to the status rule rather than to "available": a garbled field must not quietly un-hide a lane its
874
+ * status still condemns, and a state this build has never heard of is not an answer it can act on.
875
+ */
876
+ declare function laneAvailabilityState(lane: RouteHealthLane | undefined | null): LaneAvailabilityState | null;
805
877
  /**
806
878
  * The lanes the picker must stop offering, keyed by `laneKey`.
807
879
  *
@@ -810,16 +882,66 @@ interface RouteHealth {
810
882
  * - the response arrived;
811
883
  * - the gateway says `mode: "enforce"`. In observe mode the data exists for operators, and acting
812
884
  * on it would defeat the shadow-period rollout the mode flag exists to provide;
813
- * - the lane's status is `broken`, OR it is `unknown` with kind `firewalled`. DEGRADED lanes stay
814
- * SELECTABLE — the measured answer there is "it works, but mind the size", and removing it would
815
- * take a working route away. Every OTHER unknown stays selectable too: "we have not measured it"
816
- * is not evidence. The firewalled kind is the one unknown that is a certainty rather than an
817
- * absence of one — an operator is refusing the lane through the route firewall, the gateway
818
- * answers "not tradeable" on sight, and the prober files it as unknown only so that lifting the
819
- * rule does not leave a demotion behind. Until 2026-09-09 that status kept every such lane
820
- * selectable here: 139 lanes into USDtb on prod, each one an error when picked.
885
+ * - the lane is withheld by ONE of two rules, chosen per lane:
886
+ *
887
+ * • it publishes `availability` → withheld iff `availability.state === "unavailable"`. A `limited`
888
+ * lane stays selectable and is offered with its limit (see {@link limitedLanes}).
889
+ *
890
+ * • it does not (a gateway that predates the field) → the original rule, unchanged: the status is
891
+ * `broken`, OR it is `unknown` with kind `firewalled`. DEGRADED lanes stay SELECTABLE — the
892
+ * measured answer there is "it works, but mind the size", and removing it would take a working
893
+ * route away. Every OTHER unknown stays selectable too: "we have not measured it" is not
894
+ * evidence. The firewalled kind is the one unknown that is a certainty rather than an absence of
895
+ * one — an operator is refusing the lane through the route firewall, the gateway answers "not
896
+ * tradeable" on sight, and the prober files it as unknown only so that lifting the rule does not
897
+ * leave a demotion behind. Until 2026-09-09 that status kept every such lane selectable here:
898
+ * 139 lanes into USDtb on prod, each one an error when picked.
821
899
  */
822
900
  declare function suppressedLanes(health: RouteHealth | undefined | null): ReadonlyMap<string, BrokenLane>;
901
+ /**
902
+ * Lanes that are offered, but tradeable only up to a measured amount right now, keyed by `laneKey`.
903
+ *
904
+ * Empty — limit nothing — unless the response arrived, the gateway says `mode: "enforce"` (observe
905
+ * mode publishes the same objects, and they are not to be acted on), and the lane's availability is
906
+ * `limited` with a well-formed `limit`. A limited lane whose limit cannot be read is left OUT rather
907
+ * than guessed at: a limit this client invented would refuse amounts the gateway would quote, and
908
+ * the gateway refuses a genuinely oversized order on its own, with the limit in `fieldErrors`.
909
+ */
910
+ declare function limitedLanes(health: RouteHealth | undefined | null): ReadonlyMap<string, LaneLimit>;
911
+ /**
912
+ * Whether `amount` — decimal text as the payer typed it, in the BID token's own units — is above a
913
+ * bid-side limit.
914
+ *
915
+ * `false` whenever it cannot tell: no limit, a payout-side (`ask`) limit, which is not denominated in
916
+ * what the payer types, or an amount that does not parse. Calling an amount this client could not
917
+ * read "over the limit" would withhold a quote the gateway might serve; the gateway refuses a
918
+ * genuinely oversized order on its own.
919
+ *
920
+ * Compared at the finer of the two scales, so neither side is rounded: the limit is denominated in
921
+ * the hop token's decimals, which are not guaranteed to be the bid deployment's.
922
+ */
923
+ declare function exceedsLaneLimit(limit: LaneLimit | undefined | null, amount: string, bidDecimals: number): boolean;
924
+ /** The limit as a human amount, rounded DOWN — a displayed maximum must never exceed the real one. */
925
+ declare function laneLimitAmount(limit: LaneLimit): string;
926
+ /**
927
+ * The symbol to print beside a limit.
928
+ *
929
+ * A bid-side limit is on the payer's own token, so the caller's ticker for the bid deployment wins —
930
+ * it is the name already printed on the amount field. Otherwise the gateway's `token` is printed only
931
+ * if it is a plain ticker (see `safeTicker`); a value that is not is dropped rather than rendered.
932
+ */
933
+ declare function laneLimitSymbol(limit: LaneLimit, bidTicker?: string): string;
934
+ /** The line a picker row and the amount field show for a limited lane: `Max 14 USDtb right now`. */
935
+ declare function laneLimitHint(limit: LaneLimit, symbol: string): string;
936
+ /**
937
+ * The inline amount error for an amount above a bid-side limit: `Maximum: 14 USDtb right now`.
938
+ *
939
+ * Worded as the gateway's own `fieldErrors` entry for the same refusal, so a payer reads the same
940
+ * sentence whether the widget caught the amount first or `/quote` did. The one difference is the
941
+ * amount: the gateway prints every decimal of the raw limit (an 18-decimal limiter reading can run to
942
+ * twenty digits), this rounds it DOWN to six — see {@link laneLimitAmount}.
943
+ */
944
+ declare function laneLimitError(limit: LaneLimit, symbol: string): string;
823
945
  /** A one-line reason a pair is hidden, for the picker row and the refusal panel. Never the raw
824
946
  * gateway message: that text is untrusted and can carry infrastructure detail. */
825
947
  declare function brokenLaneReason(lane: BrokenLane | undefined): string;
@@ -855,9 +977,14 @@ interface ApiError extends Error {
855
977
  code?: string;
856
978
  status?: number;
857
979
  reasons?: string[];
980
+ /** Per-field validation errors. `field` names the request field, e.g. `fromAmount` for a trade
981
+ * below the minimum size (`BELOW_MIN_TRADE_SIZE`) or above a bridge's current limit (`BRIDGE_RATE_LIMITED`). */
858
982
  fieldErrors?: Array<{
983
+ field?: string;
859
984
  message?: string;
860
985
  }>;
986
+ /** The size limits behind a `BRIDGE_RATE_LIMITED` refusal, as the gateway reports them. Untrusted. */
987
+ limits?: unknown[];
861
988
  blocked?: boolean;
862
989
  blockedCategory?: string;
863
990
  blockedReason?: string;
@@ -870,6 +997,16 @@ interface QuoteBlock {
870
997
  message: string;
871
998
  }
872
999
  declare function classifyQuoteError(error: any): QuoteBlock | null;
1000
+ /**
1001
+ * The gateway's error for the AMOUNT the payer typed, if the refusal names it — for rendering inline
1002
+ * under the amount field instead of as a generic quote failure.
1003
+ *
1004
+ * Answers the `fieldErrors` entry on `fromAmount`: a trade below the minimum size, or above a bridge's
1005
+ * current limit ("Maximum: 14 USDtb right now"). Either one is fixed by changing the amount and by
1006
+ * nothing else, so a "try again" affordance next to it would only re-ask the same question. The text is
1007
+ * untrusted and passes the same scrub as every other displayed message; null when there is none.
1008
+ */
1009
+ declare function amountFieldError(error: unknown): string | null;
873
1010
  interface ApiClient {
874
1011
  apiRequest: <T = any>(path: string, init?: RequestInit & {
875
1012
  timeoutMs?: number;
@@ -943,4 +1080,4 @@ interface Verifier {
943
1080
  }
944
1081
  declare function createVerifier(api: ApiClient, fetchImpl: typeof fetch, rpcOverrides?: Record<number, string>): Verifier;
945
1082
 
946
- export { type Hex as $, type Availability as A, type BrokenLane as B, type Compliance as C, type Address as D, type EngineConfig as E, type FetchQuoteFn as F, type ApiError as G, BLOCK_LABEL_DEFAULT as H, COMPLIANCE_CHECK_ORDER as I, COMPLIANCE_DENY_LABEL as J, type CatalogueContext as K, type CatalogueInput as L, type ComplianceCheckId as M, type NormalizedOrder as N, type OrderRequest as O, type Plan as P, type Quote as Q, type Route as R, type SanitizedTxEntry as S, type Token as T, type ComplianceDecision as U, type VerifyResult as V, type WalletScreen as W, DIRECT_CHECK_IDS as X, DIRECT_SCOPE_NOTE as Y, type Destination as Z, FLOOR_CATEGORIES as _, type Catalogue as a, type PlannedTxKind as a0, type QuoteBlock as a1, type ResolvedConfig as a2, type RouteHealth as a3, type RouteHealthLane as a4, SCREENING_BUCKETS as a5, type ScreenProvider as a6, type ScreeningBucket as a7, type ScreeningOutcome as a8, TUNABLE_CATEGORIES as a9, parseAllowedApiBase as aA, productAssets as aB, registryRpc as aC, resolveApiBase as aD, resolveConfig as aE, screeningOutcomeOf as aF, sourceKeys as aG, suppressedLanes as aH, tokenKey as aI, txMatchesPlan as aJ, unattributedComplianceReasons as aK, type TxPlan as aa, apiError as ab, blockLabelFor as ac, brokenLaneFor as ad, buildCatalogue as ae, canAttachApiKey as af, categoryLabel as ag, classifyQuoteError as ah, complianceControlsEvaluated as ai, complianceReasonHead as aj, complianceReasonTag as ak, complianceTagOf as al, createApiClient as am, createVerifier as an, destinationKeys as ao, directComplianceFromScreens as ap, distinctScreenedWallets as aq, executableRoutes as ar, executionChainIds as as, hasReachableDestination as at, hubDeliverableSymbols as au, isExecutableBridge as av, isKnownUnbridgeable as aw, isSourceToken as ax, laneKey as ay, laneKeys as az, type Chain as b, type ComplianceCheck as c, type ComplianceTone as d, type ComplianceView as e, type ExchangeProduct as f, type RouteLeg as g, type RouteResult as h, type TxHistoryEntry as i, assetClassOf as j, brokenLaneReason as k, complianceChecks as l, complianceControlsLine as m, complianceView as n, counterpartTokens as o, destinationAvailability as p, humanizeComplianceReason as q, type PayOption as r, type RwaVault as s, type SolveResult as t, type BalanceTarget as u, type BalanceEntry as v, type ApiClient as w, type SwapInput as x, type PlannedTx as y, type Verifier as z };
1083
+ export { FLOOR_CATEGORIES as $, type Availability as A, type BrokenLane as B, type Compliance as C, type Address as D, type EngineConfig as E, type FetchQuoteFn as F, type ApiError as G, BLOCK_LABEL_DEFAULT as H, COMPLIANCE_CHECK_ORDER as I, COMPLIANCE_DENY_LABEL as J, type CatalogueContext as K, type LaneLimit as L, type CatalogueInput as M, type NormalizedOrder as N, type OrderRequest as O, type Plan as P, type Quote as Q, type Route as R, type SanitizedTxEntry as S, type Token as T, type ComplianceCheckId as U, type VerifyResult as V, type WalletScreen as W, type ComplianceDecision as X, DIRECT_CHECK_IDS as Y, DIRECT_SCOPE_NOTE as Z, type Destination as _, type Catalogue as a, type Hex as a0, type LaneAvailabilityState as a1, type PlannedTxKind as a2, type QuoteBlock as a3, type ResolvedConfig as a4, type RouteHealth as a5, type RouteHealthAvailability as a6, type RouteHealthLane as a7, SCREENING_BUCKETS as a8, type ScreenProvider as a9, isExecutableBridge as aA, isKnownUnbridgeable as aB, isSourceToken as aC, laneAvailabilityState as aD, laneKey as aE, laneKeys as aF, laneLimitAmount as aG, laneLimitError as aH, laneLimitFor as aI, laneLimitHint as aJ, laneLimitSymbol as aK, limitedLanes as aL, parseAllowedApiBase as aM, productAssets as aN, registryRpc as aO, resolveApiBase as aP, resolveConfig as aQ, screeningOutcomeOf as aR, sourceKeys as aS, suppressedLanes as aT, tokenKey as aU, txMatchesPlan as aV, unattributedComplianceReasons as aW, type ScreeningBucket as aa, type ScreeningOutcome as ab, TUNABLE_CATEGORIES as ac, type TxPlan as ad, amountFieldError as ae, apiError as af, blockLabelFor as ag, brokenLaneFor as ah, buildCatalogue as ai, canAttachApiKey as aj, categoryLabel as ak, classifyQuoteError as al, complianceControlsEvaluated as am, complianceReasonHead as an, complianceReasonTag as ao, complianceTagOf as ap, createApiClient as aq, createVerifier as ar, destinationKeys as as, directComplianceFromScreens as at, distinctScreenedWallets as au, exceedsLaneLimit as av, executableRoutes as aw, executionChainIds as ax, hasReachableDestination as ay, hubDeliverableSymbols as az, type Chain as b, type ComplianceCheck as c, type ComplianceTone as d, type ComplianceView as e, type ExchangeProduct as f, type RouteLeg as g, type RouteResult as h, type TxHistoryEntry as i, assetClassOf as j, brokenLaneReason as k, complianceChecks as l, complianceControlsLine as m, complianceView as n, counterpartTokens as o, destinationAvailability as p, humanizeComplianceReason as q, type PayOption as r, type RwaVault as s, type SolveResult as t, type BalanceTarget as u, type BalanceEntry as v, type ApiClient as w, type SwapInput as x, type PlannedTx as y, type Verifier as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glacislabs/stablegenie-zerodelta",
3
- "version": "4.2.1",
3
+ "version": "4.3.0",
4
4
  "description": "Lightweight embeddable ZeroDelta payment + swap widget (exact-receive Pay and exact-in Swap). Wallet always owns the final signature.",
5
5
  "type": "module",
6
6
  "license": "MIT",