@gibs/bridge-sdk 1.13.1 → 1.18.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.
Files changed (228) hide show
  1. package/README.md +295 -18
  2. package/abis/package.json +6 -0
  3. package/bridge-limits/package.json +6 -0
  4. package/chain-info/package.json +6 -0
  5. package/chain-names/package.json +6 -0
  6. package/chains/package.json +6 -0
  7. package/claims/package.json +6 -0
  8. package/config/package.json +6 -0
  9. package/consolidated-quote/package.json +6 -0
  10. package/destination-calldata/package.json +6 -0
  11. package/dist/chain-info.d.ts +1 -1
  12. package/dist/chain-info.js +11 -12
  13. package/dist/chains.d.ts +25 -0
  14. package/dist/chains.js +55 -20
  15. package/dist/cjs/abis.d.ts +1 -0
  16. package/dist/cjs/abis.js +19 -0
  17. package/dist/cjs/bridge-limits.d.ts +103 -0
  18. package/dist/cjs/bridge-limits.js +89 -0
  19. package/dist/cjs/chain-info.d.ts +169 -0
  20. package/dist/cjs/chain-info.js +452 -0
  21. package/dist/cjs/chain-names.d.ts +160 -0
  22. package/dist/cjs/chain-names.js +207 -0
  23. package/dist/cjs/chains.d.ts +90 -0
  24. package/dist/cjs/chains.js +357 -0
  25. package/dist/cjs/claims.d.ts +198 -0
  26. package/dist/cjs/claims.js +182 -0
  27. package/dist/cjs/config.d.ts +255 -0
  28. package/dist/cjs/config.js +569 -0
  29. package/dist/cjs/consolidated-quote.d.ts +648 -0
  30. package/dist/cjs/consolidated-quote.js +1048 -0
  31. package/dist/cjs/destination-calldata.d.ts +118 -0
  32. package/dist/cjs/destination-calldata.js +156 -0
  33. package/dist/cjs/ecosystems.d.ts +217 -0
  34. package/dist/cjs/ecosystems.js +298 -0
  35. package/dist/cjs/execution.d.ts +359 -0
  36. package/dist/cjs/execution.js +495 -0
  37. package/dist/cjs/fee-type.d.ts +10 -0
  38. package/dist/cjs/fee-type.js +10 -0
  39. package/dist/cjs/hyperliquid-execution.d.ts +152 -0
  40. package/dist/cjs/hyperliquid-execution.js +175 -0
  41. package/dist/cjs/image-links.d.ts +117 -0
  42. package/dist/cjs/image-links.js +153 -0
  43. package/dist/cjs/index.d.ts +24 -0
  44. package/dist/cjs/index.js +40 -0
  45. package/dist/cjs/lifi-execution-guard.d.ts +210 -0
  46. package/dist/cjs/lifi-execution-guard.js +409 -0
  47. package/dist/cjs/near-intents-conformance.d.ts +85 -0
  48. package/dist/cjs/near-intents-conformance.js +337 -0
  49. package/dist/cjs/near-intents-route.d.ts +47 -0
  50. package/dist/cjs/near-intents-route.js +303 -0
  51. package/dist/cjs/near-intents.d.ts +524 -0
  52. package/dist/cjs/near-intents.js +1071 -0
  53. package/dist/cjs/origin-deposit.d.ts +326 -0
  54. package/dist/cjs/origin-deposit.js +82 -0
  55. package/dist/cjs/package.json +3 -0
  56. package/dist/cjs/pre-quote.d.ts +198 -0
  57. package/dist/cjs/pre-quote.js +180 -0
  58. package/dist/cjs/prices.d.ts +117 -0
  59. package/dist/cjs/prices.js +224 -0
  60. package/dist/cjs/providers.d.ts +238 -0
  61. package/dist/cjs/providers.js +171 -0
  62. package/dist/cjs/quote-fees.d.ts +102 -0
  63. package/dist/cjs/quote-fees.js +201 -0
  64. package/dist/cjs/referral.d.ts +85 -0
  65. package/dist/cjs/referral.js +85 -0
  66. package/dist/cjs/relay-currencies.d.ts +47 -0
  67. package/dist/cjs/relay-currencies.js +95 -0
  68. package/dist/cjs/relay-depository.d.ts +2 -0
  69. package/dist/cjs/relay-depository.js +85 -0
  70. package/dist/cjs/relay-quote.d.ts +301 -0
  71. package/dist/cjs/relay-quote.js +996 -0
  72. package/dist/cjs/route-steps.d.ts +138 -0
  73. package/dist/cjs/route-steps.js +310 -0
  74. package/dist/cjs/routing/amounts.d.ts +80 -0
  75. package/dist/cjs/routing/amounts.js +126 -0
  76. package/dist/cjs/routing/candidate-route.d.ts +43 -0
  77. package/dist/cjs/routing/candidate-route.js +50 -0
  78. package/dist/cjs/routing/candidate.d.ts +237 -0
  79. package/dist/cjs/routing/candidate.js +100 -0
  80. package/dist/cjs/routing/carrier-provider-key.d.ts +31 -0
  81. package/dist/cjs/routing/carrier-provider-key.js +42 -0
  82. package/dist/cjs/routing/carriers/ask-answer.d.ts +77 -0
  83. package/dist/cjs/routing/carriers/ask-answer.js +2 -0
  84. package/dist/cjs/routing/carriers/omnibridge.d.ts +137 -0
  85. package/dist/cjs/routing/carriers/omnibridge.js +459 -0
  86. package/dist/cjs/routing/carriers/pulsex-paths.d.ts +80 -0
  87. package/dist/cjs/routing/carriers/pulsex-paths.js +97 -0
  88. package/dist/cjs/routing/carriers/pulsex-split.d.ts +175 -0
  89. package/dist/cjs/routing/carriers/pulsex-split.js +193 -0
  90. package/dist/cjs/routing/carriers/pulsex.d.ts +184 -0
  91. package/dist/cjs/routing/carriers/pulsex.js +615 -0
  92. package/dist/cjs/routing/carriers/wrap.d.ts +25 -0
  93. package/dist/cjs/routing/carriers/wrap.js +119 -0
  94. package/dist/cjs/routing/composed-route-quality.d.ts +125 -0
  95. package/dist/cjs/routing/composed-route-quality.js +144 -0
  96. package/dist/cjs/routing/entry-chain-anchor.d.ts +88 -0
  97. package/dist/cjs/routing/entry-chain-anchor.js +59 -0
  98. package/dist/cjs/routing/format.d.ts +31 -0
  99. package/dist/cjs/routing/format.js +64 -0
  100. package/dist/cjs/routing/index.d.ts +42 -0
  101. package/dist/cjs/routing/index.js +142 -0
  102. package/dist/cjs/routing/producers.d.ts +770 -0
  103. package/dist/cjs/routing/producers.js +1617 -0
  104. package/dist/cjs/routing/providers.d.ts +31 -0
  105. package/dist/cjs/routing/providers.js +48 -0
  106. package/dist/cjs/routing/route-data.d.ts +397 -0
  107. package/dist/cjs/routing/route-data.js +2 -0
  108. package/dist/cjs/routing/search/compose.d.ts +168 -0
  109. package/dist/cjs/routing/search/compose.js +104 -0
  110. package/dist/cjs/routing/search/graph.d.ts +668 -0
  111. package/dist/cjs/routing/search/graph.js +461 -0
  112. package/dist/cjs/routing/search/plan-route-data.d.ts +285 -0
  113. package/dist/cjs/routing/search/plan-route-data.js +871 -0
  114. package/dist/cjs/routing/search/score.d.ts +356 -0
  115. package/dist/cjs/routing/search/score.js +445 -0
  116. package/dist/cjs/routing/swap-transactions.d.ts +95 -0
  117. package/dist/cjs/routing/swap-transactions.js +133 -0
  118. package/dist/cjs/routing/usd-value.d.ts +17 -0
  119. package/dist/cjs/routing/usd-value.js +29 -0
  120. package/dist/cjs/settings.d.ts +785 -0
  121. package/dist/cjs/settings.js +1074 -0
  122. package/dist/cjs/swap-venues.d.ts +43 -0
  123. package/dist/cjs/swap-venues.js +29 -0
  124. package/dist/cjs/ton-connect.d.ts +98 -0
  125. package/dist/cjs/ton-connect.js +206 -0
  126. package/dist/cjs/ton-execution.d.ts +7 -0
  127. package/dist/cjs/ton-execution.js +23 -0
  128. package/dist/cjs/ton.d.ts +37 -0
  129. package/dist/cjs/ton.js +83 -0
  130. package/dist/cjs/tron-execution.d.ts +146 -0
  131. package/dist/cjs/tron-execution.js +248 -0
  132. package/dist/cjs/types.d.ts +51 -0
  133. package/dist/cjs/types.js +2 -0
  134. package/dist/claims.d.ts +198 -0
  135. package/dist/claims.js +140 -0
  136. package/dist/config.d.ts +42 -3
  137. package/dist/config.js +87 -21
  138. package/dist/consolidated-quote.d.ts +109 -15
  139. package/dist/consolidated-quote.js +310 -52
  140. package/dist/execution.d.ts +359 -0
  141. package/dist/execution.js +455 -0
  142. package/dist/hyperliquid-execution.js +2 -3
  143. package/dist/index.d.ts +4 -0
  144. package/dist/index.js +4 -0
  145. package/dist/lifi-execution-guard.d.ts +13 -2
  146. package/dist/lifi-execution-guard.js +4 -0
  147. package/dist/near-intents.js +2 -3
  148. package/dist/pre-quote.d.ts +6 -6
  149. package/dist/pre-quote.js +10 -14
  150. package/dist/prices.d.ts +10 -0
  151. package/dist/prices.js +52 -1
  152. package/dist/providers.d.ts +17 -0
  153. package/dist/providers.js +6 -0
  154. package/dist/referral.d.ts +12 -4
  155. package/dist/referral.js +12 -4
  156. package/dist/relay-depository.d.ts +2 -0
  157. package/dist/relay-depository.js +82 -0
  158. package/dist/relay-quote.js +2 -3
  159. package/dist/routing/candidate.d.ts +3 -3
  160. package/dist/routing/candidate.js +3 -3
  161. package/dist/routing/carrier-provider-key.d.ts +31 -0
  162. package/dist/routing/carrier-provider-key.js +37 -0
  163. package/dist/routing/carriers/ask-answer.d.ts +17 -0
  164. package/dist/routing/carriers/omnibridge.js +23 -21
  165. package/dist/routing/carriers/pulsex-paths.d.ts +80 -0
  166. package/dist/routing/carriers/pulsex-paths.js +92 -0
  167. package/dist/routing/carriers/pulsex-split.d.ts +175 -0
  168. package/dist/routing/carriers/pulsex-split.js +185 -0
  169. package/dist/routing/carriers/pulsex.d.ts +81 -46
  170. package/dist/routing/carriers/pulsex.js +267 -148
  171. package/dist/routing/composed-route-quality.d.ts +28 -6
  172. package/dist/routing/composed-route-quality.js +36 -5
  173. package/dist/routing/entry-chain-anchor.d.ts +1 -1
  174. package/dist/routing/entry-chain-anchor.js +1 -1
  175. package/dist/routing/index.d.ts +11 -3
  176. package/dist/routing/index.js +8 -2
  177. package/dist/routing/producers.js +1 -1
  178. package/dist/routing/providers.d.ts +5 -0
  179. package/dist/routing/providers.js +5 -0
  180. package/dist/routing/route-data.d.ts +47 -5
  181. package/dist/routing/search/graph.d.ts +15 -0
  182. package/dist/routing/search/plan-route-data.d.ts +42 -1
  183. package/dist/routing/search/plan-route-data.js +68 -9
  184. package/dist/routing/search/score.d.ts +3 -0
  185. package/dist/routing/search/score.js +11 -3
  186. package/dist/routing/swap-transactions.d.ts +95 -0
  187. package/dist/routing/swap-transactions.js +127 -0
  188. package/dist/settings.d.ts +94 -1
  189. package/dist/settings.js +95 -3
  190. package/dist/swap-venues.d.ts +43 -0
  191. package/dist/swap-venues.js +24 -0
  192. package/dist/ton-connect.d.ts +98 -0
  193. package/dist/ton-connect.js +200 -0
  194. package/dist/ton-execution.d.ts +4 -114
  195. package/dist/ton-execution.js +4 -244
  196. package/dist/ton.d.ts +37 -0
  197. package/dist/ton.js +65 -0
  198. package/docs/examples/example-a-ether-to-pulse.ts +300 -0
  199. package/docs/examples/example-b-token-pulsechain-to-ethereum.ts +270 -0
  200. package/docs/examples/shared.ts +261 -0
  201. package/docs/examples/tsconfig.json +18 -0
  202. package/docs/integration-guide.md +617 -0
  203. package/ecosystems/package.json +6 -0
  204. package/execution/package.json +6 -0
  205. package/fee-type/package.json +6 -0
  206. package/hyperliquid-execution/package.json +6 -0
  207. package/image-links/package.json +6 -0
  208. package/lifi-execution-guard/package.json +6 -0
  209. package/llms.txt +75 -10
  210. package/near-intents/package.json +6 -0
  211. package/near-intents-route/package.json +6 -0
  212. package/origin-deposit/package.json +6 -0
  213. package/package.json +817 -10
  214. package/pre-quote/package.json +6 -0
  215. package/prices/package.json +6 -0
  216. package/providers/package.json +6 -0
  217. package/quote-fees/package.json +6 -0
  218. package/referral/package.json +6 -0
  219. package/relay-currencies/package.json +6 -0
  220. package/relay-quote/package.json +6 -0
  221. package/route-steps/package.json +6 -0
  222. package/routing/package.json +6 -0
  223. package/settings/package.json +6 -0
  224. package/ton/package.json +6 -0
  225. package/ton-connect/package.json +6 -0
  226. package/ton-execution/package.json +6 -0
  227. package/tron-execution/package.json +6 -0
  228. package/types/package.json +6 -0
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.totalQuoteCostUsd = exports.lifiQuoteFees = exports.relayQuoteFees = void 0;
4
+ /**
5
+ * What a consolidated route actually charges, normalized across the aggregators.
6
+ *
7
+ * WHY THIS EXISTS. A quote used to carry `fromAmount` and nothing else about
8
+ * cost, so the interface could show the reader only the omnibridge crossing fee
9
+ * — a figure that is real, and on a twenty-five dollar transfer is a rounding
10
+ * error beside what the aggregator takes. Measured on one live route on
11
+ * 2026-09-01: Relay charged 1.466338 USD Coin, or 5.54%, and none of it
12
+ * appeared anywhere on screen.
13
+ *
14
+ * THE FLAG THAT MATTERS IS `includedInFromAmount`. The two providers express
15
+ * cost differently, and the difference is not cosmetic:
16
+ *
17
+ * Relay folds everything into `fromAmount`. You send 26.466338 to receive
18
+ * 25.000000, and the 1.466338 difference IS the fee.
19
+ *
20
+ * LI.FI does not. On the same route it quoted `fromAmount` 25.317074 and a
21
+ * SEPARATE LayerZero fee of 0.000561734871157119 ether — about 1.37 dollars —
22
+ * marked `included: false`, which the sender pays on top in native currency.
23
+ *
24
+ * So comparing the two on `fromAmount` alone reads LI.FI as more than a dollar
25
+ * cheaper when it is in fact slightly dearer. Anything that ranks or displays
26
+ * cost has to add the charges that sit outside `fromAmount`, and that is what
27
+ * this flag is for.
28
+ */
29
+ const asRecord = (value) => typeof value === 'object' && value !== null ? value : null;
30
+ const asNumber = (value) => typeof value === 'number' && Number.isFinite(value) ? value : null;
31
+ /**
32
+ * Reads a provider's currency block into a token descriptor.
33
+ *
34
+ * Returns null rather than filling in defaults: a charge whose token is unknown
35
+ * cannot be formatted, and inventing eighteen decimals for it would print a
36
+ * number wrong by many orders of magnitude.
37
+ */
38
+ const feeToken = (value) => {
39
+ const currency = asRecord(value);
40
+ const decimals = asNumber(currency?.decimals);
41
+ const chainId = asNumber(currency?.chainId);
42
+ if (typeof currency?.symbol !== 'string' || decimals === null || chainId === null) {
43
+ return null;
44
+ }
45
+ return { symbol: currency.symbol, decimals, chainId };
46
+ };
47
+ /** Parses a provider's amount string, dropping a charge that is zero or unreadable. */
48
+ const feeAmount = (value) => {
49
+ if (typeof value !== 'string' && typeof value !== 'number') {
50
+ return null;
51
+ }
52
+ try {
53
+ // Relay reports "0.0" for an unused fee slot, which BigInt rejects; a
54
+ // fractional string here is always zero in practice, and a charge we cannot
55
+ // read exactly is one we must not display.
56
+ const amount = BigInt(String(value).split('.')[0] ?? '');
57
+ return amount > 0n ? amount : null;
58
+ }
59
+ catch {
60
+ return null;
61
+ }
62
+ };
63
+ const usdOf = (value) => typeof value === 'string' || typeof value === 'number' ? String(value) : null;
64
+ /**
65
+ * The charges Relay reports, in the order a reader meets them.
66
+ *
67
+ * `fees.relayer` IS DELIBERATELY SKIPPED. It is the sum of `relayerGas` and
68
+ * `relayerService`, so listing it beside them would count the same money twice
69
+ * and make the breakdown disagree with the amount the sender pays.
70
+ *
71
+ * `fees.gas` is the sender's OWN origin-chain transaction cost. It sits outside
72
+ * `fromAmount` because the wallet pays it directly, which is exactly the case
73
+ * `includedInFromAmount` exists to mark.
74
+ * @param payload - the raw body from Relay's quote endpoint
75
+ * @returns the charges, in display order
76
+ */
77
+ const relayQuoteFees = (payload) => {
78
+ const fees = asRecord(asRecord(payload)?.fees);
79
+ if (!fees) {
80
+ return [];
81
+ }
82
+ const rows = [
83
+ { key: 'relayerGas', label: 'Destination network cost', kind: 'gas', included: true },
84
+ { key: 'relayerService', label: 'Relay service fee', kind: 'service', included: true },
85
+ { key: 'app', label: 'Referral fee', kind: 'integrator', included: true },
86
+ { key: 'gas', label: 'Origin network cost', kind: 'gas', included: false },
87
+ ];
88
+ return rows.flatMap(({ key, label, kind, included }) => {
89
+ const node = asRecord(fees[key]);
90
+ const amount = feeAmount(node?.amount);
91
+ const token = feeToken(node?.currency);
92
+ if (amount === null || token === null) {
93
+ return [];
94
+ }
95
+ return [
96
+ {
97
+ kind,
98
+ label,
99
+ amount,
100
+ token,
101
+ amountUsd: usdOf(node?.amountUsd),
102
+ includedInFromAmount: included,
103
+ },
104
+ ];
105
+ });
106
+ };
107
+ exports.relayQuoteFees = relayQuoteFees;
108
+ /**
109
+ * The charges LI.FI reports.
110
+ *
111
+ * `feeCosts` CARRIES ITS OWN `included` FLAG and it is the whole point of
112
+ * reading this: a fee marked `included: false` is paid on top of `fromAmount`,
113
+ * in that fee's own token, and on a live route it was worth more than a dollar.
114
+ * `gasCosts` is the sender's own origin transaction and is never included.
115
+ * @param payload - the raw body from LI.FI's quote endpoint
116
+ * @returns the charges, in display order
117
+ */
118
+ const lifiQuoteFees = (payload) => {
119
+ const estimate = asRecord(asRecord(payload)?.estimate);
120
+ if (!estimate) {
121
+ return [];
122
+ }
123
+ const feeCosts = Array.isArray(estimate.feeCosts) ? estimate.feeCosts : [];
124
+ const gasCosts = Array.isArray(estimate.gasCosts) ? estimate.gasCosts : [];
125
+ const fromFeeCosts = feeCosts.flatMap((entry) => {
126
+ const fee = asRecord(entry);
127
+ const amount = feeAmount(fee?.amount);
128
+ const token = feeToken(fee?.token);
129
+ if (amount === null || token === null) {
130
+ return [];
131
+ }
132
+ return [
133
+ {
134
+ kind: 'service',
135
+ label: typeof fee?.name === 'string' ? fee.name : 'Provider fee',
136
+ amount,
137
+ token,
138
+ amountUsd: usdOf(fee?.amountUSD),
139
+ // Absent is treated as NOT included. A fee we wrongly call included
140
+ // disappears from the total and understates the route; one we wrongly
141
+ // call excluded overstates it. Overstating is the safe direction.
142
+ includedInFromAmount: fee?.included === true,
143
+ },
144
+ ];
145
+ });
146
+ const fromGasCosts = gasCosts.flatMap((entry) => {
147
+ const gas = asRecord(entry);
148
+ const amount = feeAmount(gas?.amount);
149
+ const token = feeToken(gas?.token);
150
+ if (amount === null || token === null) {
151
+ return [];
152
+ }
153
+ return [
154
+ {
155
+ kind: 'gas',
156
+ label: 'Origin network cost',
157
+ amount,
158
+ token,
159
+ amountUsd: usdOf(gas?.amountUSD),
160
+ includedInFromAmount: false,
161
+ },
162
+ ];
163
+ });
164
+ return [...fromFeeCosts, ...fromGasCosts];
165
+ };
166
+ exports.lifiQuoteFees = lifiQuoteFees;
167
+ /**
168
+ * What the route costs the sender all in, in United States dollars.
169
+ *
170
+ * `fromAmount` already contains every charge marked included, so only the ones
171
+ * marked otherwise are added. This is the figure two providers must be compared
172
+ * on: ranking them on `fromAmount` alone picked LI.FI over Relay by more than a
173
+ * dollar on a route where LI.FI was in fact the dearer of the two, because its
174
+ * LayerZero fee is charged outside the amount.
175
+ *
176
+ * Returns null when the input's own dollar value is unknown — a partial total
177
+ * would rank routes against each other on different bases.
178
+ * @param quote.fromAmountUsd - the provider's dollar value for the input amount
179
+ * @param quote.fees - the route's charges
180
+ * @returns the all-in dollar cost, or null when it cannot be totalled
181
+ */
182
+ const totalQuoteCostUsd = ({ fromAmountUsd, fees, }) => {
183
+ if (fromAmountUsd === null) {
184
+ return null;
185
+ }
186
+ const base = Number(fromAmountUsd);
187
+ if (!Number.isFinite(base)) {
188
+ return null;
189
+ }
190
+ return fees.reduce((total, fee) => {
191
+ if (fee.includedInFromAmount) {
192
+ return total;
193
+ }
194
+ const value = Number(fee.amountUsd);
195
+ // A charge outside the amount whose dollar value we cannot read is left out
196
+ // rather than guessed. It is named in the breakdown either way, so the
197
+ // reader still sees it even when the total cannot count it.
198
+ return Number.isFinite(value) ? total + value : total;
199
+ }, base);
200
+ };
201
+ exports.totalQuoteCostUsd = totalQuoteCostUsd;
@@ -0,0 +1,85 @@
1
+ import type { Hex } from 'viem';
2
+ /**
3
+ * Referral configuration — the one place to set who gets paid.
4
+ *
5
+ * This module exists so the payout address is a single named edit rather than a
6
+ * constant buried among API urls. It deliberately imports nothing but a type, so
7
+ * the interface can read the address without pulling in a quote builder.
8
+ */
9
+ /**
10
+ * Gibs Finance's own integrator identifier with LI.FI and Relay. LI.FI pays its
11
+ * integrator share against this string — the payout account is configured on
12
+ * LI.FI's side, which is why LI.FI needs no address here and Relay does.
13
+ *
14
+ * This is Gibs Finance's identity, not a setting for other consumers. The
15
+ * Relay API key that used to live beside it moved into the Gibs interface's
16
+ * own configuration (`packages/ui/src/lib/config.ts`): this package ships no
17
+ * key. Pass your own identifiers on each request — see the README.
18
+ */
19
+ export declare const referralIntegrator = "gibs.finance";
20
+ /**
21
+ * Resolves one attribution field (a LI.FI `integrator`, a Relay `referrer`)
22
+ * from a caller's override and this package's default for it.
23
+ *
24
+ * Three states, not two:
25
+ * - `undefined` (left out): the package default — which may itself be
26
+ * `undefined`, meaning the field is not sent.
27
+ * - `null`: the field is OMITTED from the request. Never sent as `''`: Relay
28
+ * reads any `referrer`, an empty one included, as "a referrer was supplied".
29
+ * - a string: sent as-is.
30
+ *
31
+ * @param override - the caller's value for the field
32
+ * @param packageDefault - the value used when the caller leaves the field out
33
+ * @returns the value to send, or undefined to omit the field
34
+ */
35
+ export declare const resolveAttribution: (override: string | null | undefined, packageDefault: string | undefined) => string | undefined;
36
+ /**
37
+ * Gibs Finance's payout address for Relay application fees.
38
+ *
39
+ * NO BUILDER APPLIES IT. A Relay request carries an `appFees` entry only when
40
+ * the caller passes `relayAppFee`. The Gibs interface passes this address
41
+ * explicitly; any other caller passes its own, or nothing.
42
+ *
43
+ * Set to the owner's receiving wallet. Setting it back to `null` is a working
44
+ * state rather than a broken one, and is the way to stop collecting: Relay
45
+ * rejects a fee entry that names no recipient, so the fee is omitted from the
46
+ * request entirely and nothing is charged. Every consumer already reads it this
47
+ * way — see {@link referralIsCollectable}.
48
+ *
49
+ * The literal is stored CHECKSUMMED (mixed case). That is not decoration: the
50
+ * mixed case IS the checksum, so a typo in the address fails `getAddress`
51
+ * instead of silently paying a wrong-but-valid account. Verified against viem's
52
+ * `getAddress` before being written here.
53
+ *
54
+ * One address serves every chain: Relay pays application fees on the DESTINATION
55
+ * chain, and every destination this app bridges to is Ethereum-style, so an
56
+ * ordinary Ethereum address receives from all of them.
57
+ */
58
+ export declare const relayReferralRecipient: Hex | null;
59
+ /**
60
+ * The application fee the Gibs interface charges, in basis points. Ten basis
61
+ * points is one tenth of one percent. The interface can override it per
62
+ * provider in stored settings; this is the value a reader who has never touched
63
+ * the setting gets.
64
+ *
65
+ * NO BUILDER APPLIES IT. It reaches a request only when a caller passes it as
66
+ * `relayAppFee.basisPoints` (Relay) or converts it to `lifiFee` (LI.FI).
67
+ */
68
+ export declare const defaultReferralFeeBasisPoints = 10n;
69
+ /**
70
+ * Whether a referral fee will ACTUALLY be collected, as opposed to merely being
71
+ * switched on.
72
+ *
73
+ * The distinction is the point of this helper. Relay's fee needs three things to
74
+ * be true at once, and the interface used to show a percentage whenever the
75
+ * first was true — so the fee row read "0.10%" while the missing recipient meant
76
+ * nothing was charged at all. Ask this rather than reading `enabled` alone.
77
+ *
78
+ * @param options - the switch state, the fee size, and the payout address
79
+ * @returns true only when a fee will reach a recipient
80
+ */
81
+ export declare const referralIsCollectable: ({ enabled, basisPoints, recipient, }: {
82
+ enabled: boolean;
83
+ basisPoints: bigint;
84
+ recipient: Hex | null;
85
+ }) => boolean;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.referralIsCollectable = exports.defaultReferralFeeBasisPoints = exports.relayReferralRecipient = exports.resolveAttribution = exports.referralIntegrator = void 0;
4
+ /**
5
+ * Referral configuration — the one place to set who gets paid.
6
+ *
7
+ * This module exists so the payout address is a single named edit rather than a
8
+ * constant buried among API urls. It deliberately imports nothing but a type, so
9
+ * the interface can read the address without pulling in a quote builder.
10
+ */
11
+ /**
12
+ * Gibs Finance's own integrator identifier with LI.FI and Relay. LI.FI pays its
13
+ * integrator share against this string — the payout account is configured on
14
+ * LI.FI's side, which is why LI.FI needs no address here and Relay does.
15
+ *
16
+ * This is Gibs Finance's identity, not a setting for other consumers. The
17
+ * Relay API key that used to live beside it moved into the Gibs interface's
18
+ * own configuration (`packages/ui/src/lib/config.ts`): this package ships no
19
+ * key. Pass your own identifiers on each request — see the README.
20
+ */
21
+ exports.referralIntegrator = 'gibs.finance';
22
+ /**
23
+ * Resolves one attribution field (a LI.FI `integrator`, a Relay `referrer`)
24
+ * from a caller's override and this package's default for it.
25
+ *
26
+ * Three states, not two:
27
+ * - `undefined` (left out): the package default — which may itself be
28
+ * `undefined`, meaning the field is not sent.
29
+ * - `null`: the field is OMITTED from the request. Never sent as `''`: Relay
30
+ * reads any `referrer`, an empty one included, as "a referrer was supplied".
31
+ * - a string: sent as-is.
32
+ *
33
+ * @param override - the caller's value for the field
34
+ * @param packageDefault - the value used when the caller leaves the field out
35
+ * @returns the value to send, or undefined to omit the field
36
+ */
37
+ const resolveAttribution = (override, packageDefault) => (override === null ? undefined : (override ?? packageDefault));
38
+ exports.resolveAttribution = resolveAttribution;
39
+ /**
40
+ * Gibs Finance's payout address for Relay application fees.
41
+ *
42
+ * NO BUILDER APPLIES IT. A Relay request carries an `appFees` entry only when
43
+ * the caller passes `relayAppFee`. The Gibs interface passes this address
44
+ * explicitly; any other caller passes its own, or nothing.
45
+ *
46
+ * Set to the owner's receiving wallet. Setting it back to `null` is a working
47
+ * state rather than a broken one, and is the way to stop collecting: Relay
48
+ * rejects a fee entry that names no recipient, so the fee is omitted from the
49
+ * request entirely and nothing is charged. Every consumer already reads it this
50
+ * way — see {@link referralIsCollectable}.
51
+ *
52
+ * The literal is stored CHECKSUMMED (mixed case). That is not decoration: the
53
+ * mixed case IS the checksum, so a typo in the address fails `getAddress`
54
+ * instead of silently paying a wrong-but-valid account. Verified against viem's
55
+ * `getAddress` before being written here.
56
+ *
57
+ * One address serves every chain: Relay pays application fees on the DESTINATION
58
+ * chain, and every destination this app bridges to is Ethereum-style, so an
59
+ * ordinary Ethereum address receives from all of them.
60
+ */
61
+ exports.relayReferralRecipient = '0xAF2ce0189f46f5663715b0b9ED2a10eA924AB9B0';
62
+ /**
63
+ * The application fee the Gibs interface charges, in basis points. Ten basis
64
+ * points is one tenth of one percent. The interface can override it per
65
+ * provider in stored settings; this is the value a reader who has never touched
66
+ * the setting gets.
67
+ *
68
+ * NO BUILDER APPLIES IT. It reaches a request only when a caller passes it as
69
+ * `relayAppFee.basisPoints` (Relay) or converts it to `lifiFee` (LI.FI).
70
+ */
71
+ exports.defaultReferralFeeBasisPoints = 10n;
72
+ /**
73
+ * Whether a referral fee will ACTUALLY be collected, as opposed to merely being
74
+ * switched on.
75
+ *
76
+ * The distinction is the point of this helper. Relay's fee needs three things to
77
+ * be true at once, and the interface used to show a percentage whenever the
78
+ * first was true — so the fee row read "0.10%" while the missing recipient meant
79
+ * nothing was charged at all. Ask this rather than reading `enabled` alone.
80
+ *
81
+ * @param options - the switch state, the fee size, and the payout address
82
+ * @returns true only when a fee will reach a recipient
83
+ */
84
+ const referralIsCollectable = ({ enabled, basisPoints, recipient, }) => enabled && basisPoints > 0n && recipient !== null;
85
+ exports.referralIsCollectable = referralIsCollectable;
@@ -0,0 +1,47 @@
1
+ import type { Token } from './types.js';
2
+ /**
3
+ * Relay currencies endpoint. Anonymous access works at the same 50-requests-per-
4
+ * minute tier as the quote endpoint; used to discover the source tokens a
5
+ * non-Ethereum origin chain (Solana, Bitcoin) can bridge from.
6
+ */
7
+ export declare const relayCurrenciesUrl = "https://api.relay.link/currencies/v2";
8
+ /** The JSON body for `POST /currencies/v2`. */
9
+ export type RelayCurrenciesRequestBody = {
10
+ /** Relay chain identifiers to list currencies for. */
11
+ chainIds: number[];
12
+ /** Optional cap on how many currencies Relay returns per chain. */
13
+ limit?: number;
14
+ };
15
+ /**
16
+ * Builds the Relay currencies request body.
17
+ *
18
+ * @returns the request body, or null when no chain ids are supplied
19
+ */
20
+ export declare const buildRelayCurrenciesRequest: ({ chainIds, limit, }: {
21
+ chainIds: number[];
22
+ limit?: number;
23
+ }) => RelayCurrenciesRequestBody | null;
24
+ /**
25
+ * Relay's own chain registry — the provider's word on which chains it
26
+ * supports AT ALL, distinct from `/currencies/v2` (which chains currently
27
+ * have priced currencies). A chain absent here can never be asked about, on
28
+ * `/currencies/v2` or `/quote` alike; see `parseRelayChains`.
29
+ */
30
+ export declare const relayChainsUrl = "https://api.relay.link/chains";
31
+ /**
32
+ * Normalizes a `GET /chains` response body to the chain ids Relay lists.
33
+ * Mirrors `parseLifiChains` (`consolidated-quote.ts`) for LI.FI's own chain
34
+ * list: read the provider's own registry, never a hand-written exclusion.
35
+ *
36
+ * @returns the chain ids Relay lists, or null when the payload shape is unexpected
37
+ */
38
+ export declare const parseRelayChains: (payload: unknown) => number[] | null;
39
+ /**
40
+ * Maps Relay's flat `/currencies/v2` array onto the shared `Token` shape. A
41
+ * Relay currency's `address` is already a string (a Solana mint or a Bitcoin
42
+ * native address), so no widening is needed. Malformed entries are skipped
43
+ * rather than failing the whole list.
44
+ *
45
+ * @returns the tokens, or an empty list when the payload is not an array
46
+ */
47
+ export declare const parseRelayCurrencies: (payload: unknown) => Token[];
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseRelayCurrencies = exports.parseRelayChains = exports.relayChainsUrl = exports.buildRelayCurrenciesRequest = exports.relayCurrenciesUrl = void 0;
4
+ /**
5
+ * Relay currencies endpoint. Anonymous access works at the same 50-requests-per-
6
+ * minute tier as the quote endpoint; used to discover the source tokens a
7
+ * non-Ethereum origin chain (Solana, Bitcoin) can bridge from.
8
+ */
9
+ exports.relayCurrenciesUrl = 'https://api.relay.link/currencies/v2';
10
+ /**
11
+ * Builds the Relay currencies request body.
12
+ *
13
+ * @returns the request body, or null when no chain ids are supplied
14
+ */
15
+ const buildRelayCurrenciesRequest = ({ chainIds, limit, }) => {
16
+ if (chainIds.length === 0) {
17
+ return null;
18
+ }
19
+ return { chainIds, ...(limit === undefined ? {} : { limit }) };
20
+ };
21
+ exports.buildRelayCurrenciesRequest = buildRelayCurrenciesRequest;
22
+ const asRecord = (value) => {
23
+ if (typeof value !== 'object' || value === null) {
24
+ return null;
25
+ }
26
+ return value;
27
+ };
28
+ /**
29
+ * Relay's own chain registry — the provider's word on which chains it
30
+ * supports AT ALL, distinct from `/currencies/v2` (which chains currently
31
+ * have priced currencies). A chain absent here can never be asked about, on
32
+ * `/currencies/v2` or `/quote` alike; see `parseRelayChains`.
33
+ */
34
+ exports.relayChainsUrl = 'https://api.relay.link/chains';
35
+ /**
36
+ * Normalizes a `GET /chains` response body to the chain ids Relay lists.
37
+ * Mirrors `parseLifiChains` (`consolidated-quote.ts`) for LI.FI's own chain
38
+ * list: read the provider's own registry, never a hand-written exclusion.
39
+ *
40
+ * @returns the chain ids Relay lists, or null when the payload shape is unexpected
41
+ */
42
+ const parseRelayChains = (payload) => {
43
+ const body = asRecord(payload);
44
+ if (body === null || !Array.isArray(body.chains)) {
45
+ return null;
46
+ }
47
+ const ids = [];
48
+ for (const chain of body.chains) {
49
+ const record = asRecord(chain);
50
+ if (record !== null && typeof record.id === 'number') {
51
+ ids.push(record.id);
52
+ }
53
+ }
54
+ return ids;
55
+ };
56
+ exports.parseRelayChains = parseRelayChains;
57
+ /**
58
+ * Maps Relay's flat `/currencies/v2` array onto the shared `Token` shape. A
59
+ * Relay currency's `address` is already a string (a Solana mint or a Bitcoin
60
+ * native address), so no widening is needed. Malformed entries are skipped
61
+ * rather than failing the whole list.
62
+ *
63
+ * @returns the tokens, or an empty list when the payload is not an array
64
+ */
65
+ const parseRelayCurrencies = (payload) => {
66
+ if (!Array.isArray(payload)) {
67
+ return [];
68
+ }
69
+ const tokens = [];
70
+ for (const entry of payload) {
71
+ const record = asRecord(entry);
72
+ if (!record) {
73
+ continue;
74
+ }
75
+ const { chainId, address, symbol, name, decimals } = record;
76
+ if (typeof chainId !== 'number' ||
77
+ typeof address !== 'string' ||
78
+ typeof symbol !== 'string' ||
79
+ typeof name !== 'string' ||
80
+ typeof decimals !== 'number') {
81
+ continue;
82
+ }
83
+ const metadata = asRecord(record.metadata);
84
+ tokens.push({
85
+ chainId,
86
+ address,
87
+ symbol,
88
+ name,
89
+ decimals,
90
+ logoURI: typeof metadata?.logoURI === 'string' ? metadata.logoURI : null,
91
+ });
92
+ }
93
+ return tokens;
94
+ };
95
+ exports.parseRelayCurrencies = parseRelayCurrencies;
@@ -0,0 +1,2 @@
1
+ import { type Hex } from 'viem';
2
+ export declare const relayDepositoryByChainId: ReadonlyMap<number, Hex>;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.relayDepositoryByChainId = void 0;
4
+ const viem_1 = require("viem");
5
+ /**
6
+ * Relay's deposit contract (its "depository") on each Ethereum-style chain:
7
+ * the ONLY address a Relay origin deposit may be sent to, and the only
8
+ * address it may ask the reader to approve.
9
+ *
10
+ * WHY A FIXED TABLE. A quote that names its own spender cannot be trusted to
11
+ * name an honest one: a compromised quote host could name any contract. This
12
+ * table ships with the code and changes only through a release.
13
+ *
14
+ * SOURCE. Relay's Chains API, `GET https://api.relay.link/chains`, field
15
+ * `chains[].protocol.v2.depository`, read 2026-10-07 for every chain whose
16
+ * `vmType` is `evm`. Relay's documentation says its depository addresses are
17
+ * published only through that API
18
+ * (https://docs.relay.link/references/protocol/addresses). A live quote the
19
+ * same day (Ethereum USDC to Base, `POST /quote/v2`) approved and deposited to
20
+ * exactly the Ethereum entry below.
21
+ *
22
+ * NOT THE `contracts` BLOCK. The same API also lists `relayReceiver`,
23
+ * `approvalProxy` and `erc20Router` under `chains[].contracts`. The live
24
+ * quote used none of them, so they are left out: an address the quote does
25
+ * not use is not one this table should accept.
26
+ *
27
+ * A CHAIN NOT LISTED IS REFUSED. If Relay adds a chain or moves a depository,
28
+ * deposits there are refused until this table is updated.
29
+ */
30
+ const common = (0, viem_1.getAddress)('0x4cd00e387622c35bddb9b4c962c136462338bc31');
31
+ const alternate = (0, viem_1.getAddress)('0x59916da825d2d2ec1bf878d71c88826f6633ecca');
32
+ exports.relayDepositoryByChainId = new Map([
33
+ [1, common], // ethereum
34
+ [10, common], // optimism
35
+ [25, alternate], // cronos
36
+ [56, common], // bsc
37
+ [100, common], // gnosis
38
+ [130, common], // unichain
39
+ [137, common], // polygon
40
+ [143, common], // monad
41
+ [146, common], // sonic
42
+ [169, common], // manta-pacific
43
+ [196, common], // xlayer
44
+ [288, common], // boba
45
+ [324, common], // zksync
46
+ [360, common], // shape
47
+ [480, common], // world-chain
48
+ [747, common], // flow-evm
49
+ [988, common], // stable
50
+ [999, common], // hyperevm
51
+ [1088, alternate], // metis
52
+ [1135, common], // lisk
53
+ [1868, common], // soneium
54
+ [2020, common], // ronin
55
+ [2741, common], // abstract
56
+ [2818, common], // morph
57
+ [4217, common], // tempo
58
+ [4326, common], // megaeth
59
+ [4663, common], // robinhood
60
+ [5000, alternate], // mantle
61
+ [5031, common], // somnia
62
+ [5042, common], // arc
63
+ [5330, common], // superseed
64
+ [8453, common], // base
65
+ [9745, common], // plasma
66
+ [33139, common], // apechain
67
+ [34443, common], // mode
68
+ [42018, common], // mythos
69
+ [42161, common], // arbitrum
70
+ [42220, common], // celo
71
+ [43114, common], // avalanche
72
+ [48900, common], // zircuit
73
+ [57073, common], // ink
74
+ [59144, alternate], // linea
75
+ [60808, common], // bob
76
+ [80094, common], // berachain
77
+ [81457, common], // blast
78
+ [97477, common], // doma
79
+ [98866, common], // plume
80
+ [534352, common], // scroll
81
+ [685689, common], // gensyn
82
+ [747474, common], // katana
83
+ [5064014, common], // ethereal
84
+ [7777777, common], // zora
85
+ ]);