@gibs/bridge-sdk 1.13.0 → 1.17.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.
- package/README.md +244 -18
- package/abis/package.json +6 -0
- package/bridge-limits/package.json +6 -0
- package/chain-info/package.json +6 -0
- package/chain-names/package.json +6 -0
- package/chains/package.json +6 -0
- package/claims/package.json +6 -0
- package/config/package.json +6 -0
- package/consolidated-quote/package.json +6 -0
- package/destination-calldata/package.json +6 -0
- package/dist/chain-info.d.ts +1 -1
- package/dist/chain-info.js +11 -12
- package/dist/chains.d.ts +25 -0
- package/dist/chains.js +55 -20
- package/dist/cjs/abis.d.ts +1 -0
- package/dist/cjs/abis.js +19 -0
- package/dist/cjs/bridge-limits.d.ts +103 -0
- package/dist/cjs/bridge-limits.js +89 -0
- package/dist/cjs/chain-info.d.ts +169 -0
- package/dist/cjs/chain-info.js +452 -0
- package/dist/cjs/chain-names.d.ts +160 -0
- package/dist/cjs/chain-names.js +207 -0
- package/dist/cjs/chains.d.ts +90 -0
- package/dist/cjs/chains.js +357 -0
- package/dist/cjs/claims.d.ts +198 -0
- package/dist/cjs/claims.js +182 -0
- package/dist/cjs/config.d.ts +240 -0
- package/dist/cjs/config.js +537 -0
- package/dist/cjs/consolidated-quote.d.ts +648 -0
- package/dist/cjs/consolidated-quote.js +1048 -0
- package/dist/cjs/destination-calldata.d.ts +118 -0
- package/dist/cjs/destination-calldata.js +156 -0
- package/dist/cjs/ecosystems.d.ts +217 -0
- package/dist/cjs/ecosystems.js +298 -0
- package/dist/cjs/execution.d.ts +346 -0
- package/dist/cjs/execution.js +468 -0
- package/dist/cjs/fee-type.d.ts +10 -0
- package/dist/cjs/fee-type.js +10 -0
- package/dist/cjs/hyperliquid-execution.d.ts +152 -0
- package/dist/cjs/hyperliquid-execution.js +175 -0
- package/dist/cjs/image-links.d.ts +117 -0
- package/dist/cjs/image-links.js +153 -0
- package/dist/cjs/index.d.ts +23 -0
- package/dist/cjs/index.js +39 -0
- package/dist/cjs/lifi-execution-guard.d.ts +210 -0
- package/dist/cjs/lifi-execution-guard.js +409 -0
- package/dist/cjs/near-intents-conformance.d.ts +85 -0
- package/dist/cjs/near-intents-conformance.js +337 -0
- package/dist/cjs/near-intents-route.d.ts +47 -0
- package/dist/cjs/near-intents-route.js +303 -0
- package/dist/cjs/near-intents.d.ts +524 -0
- package/dist/cjs/near-intents.js +1071 -0
- package/dist/cjs/origin-deposit.d.ts +326 -0
- package/dist/cjs/origin-deposit.js +82 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/pre-quote.d.ts +198 -0
- package/dist/cjs/pre-quote.js +180 -0
- package/dist/cjs/prices.d.ts +107 -0
- package/dist/cjs/prices.js +172 -0
- package/dist/cjs/providers.d.ts +238 -0
- package/dist/cjs/providers.js +171 -0
- package/dist/cjs/quote-fees.d.ts +102 -0
- package/dist/cjs/quote-fees.js +201 -0
- package/dist/cjs/referral.d.ts +85 -0
- package/dist/cjs/referral.js +85 -0
- package/dist/cjs/relay-currencies.d.ts +47 -0
- package/dist/cjs/relay-currencies.js +95 -0
- package/dist/cjs/relay-depository.d.ts +2 -0
- package/dist/cjs/relay-depository.js +85 -0
- package/dist/cjs/relay-quote.d.ts +301 -0
- package/dist/cjs/relay-quote.js +996 -0
- package/dist/cjs/route-steps.d.ts +138 -0
- package/dist/cjs/route-steps.js +310 -0
- package/dist/cjs/routing/amounts.d.ts +80 -0
- package/dist/cjs/routing/amounts.js +126 -0
- package/dist/cjs/routing/candidate-route.d.ts +43 -0
- package/dist/cjs/routing/candidate-route.js +50 -0
- package/dist/cjs/routing/candidate.d.ts +237 -0
- package/dist/cjs/routing/candidate.js +100 -0
- package/dist/cjs/routing/carriers/ask-answer.d.ts +77 -0
- package/dist/cjs/routing/carriers/ask-answer.js +2 -0
- package/dist/cjs/routing/carriers/omnibridge.d.ts +137 -0
- package/dist/cjs/routing/carriers/omnibridge.js +459 -0
- package/dist/cjs/routing/carriers/pulsex-paths.d.ts +80 -0
- package/dist/cjs/routing/carriers/pulsex-paths.js +97 -0
- package/dist/cjs/routing/carriers/pulsex-split.d.ts +175 -0
- package/dist/cjs/routing/carriers/pulsex-split.js +193 -0
- package/dist/cjs/routing/carriers/pulsex.d.ts +159 -0
- package/dist/cjs/routing/carriers/pulsex.js +565 -0
- package/dist/cjs/routing/carriers/wrap.d.ts +25 -0
- package/dist/cjs/routing/carriers/wrap.js +119 -0
- package/dist/cjs/routing/composed-route-quality.d.ts +125 -0
- package/dist/cjs/routing/composed-route-quality.js +144 -0
- package/dist/cjs/routing/entry-chain-anchor.d.ts +88 -0
- package/dist/cjs/routing/entry-chain-anchor.js +59 -0
- package/dist/cjs/routing/format.d.ts +31 -0
- package/dist/cjs/routing/format.js +64 -0
- package/dist/cjs/routing/index.d.ts +38 -0
- package/dist/cjs/routing/index.js +134 -0
- package/dist/cjs/routing/producers.d.ts +770 -0
- package/dist/cjs/routing/producers.js +1617 -0
- package/dist/cjs/routing/providers.d.ts +31 -0
- package/dist/cjs/routing/providers.js +48 -0
- package/dist/cjs/routing/route-data.d.ts +355 -0
- package/dist/cjs/routing/route-data.js +2 -0
- package/dist/cjs/routing/search/compose.d.ts +168 -0
- package/dist/cjs/routing/search/compose.js +104 -0
- package/dist/cjs/routing/search/graph.d.ts +668 -0
- package/dist/cjs/routing/search/graph.js +461 -0
- package/dist/cjs/routing/search/plan-route-data.d.ts +269 -0
- package/dist/cjs/routing/search/plan-route-data.js +848 -0
- package/dist/cjs/routing/search/score.d.ts +356 -0
- package/dist/cjs/routing/search/score.js +445 -0
- package/dist/cjs/routing/swap-transactions.d.ts +91 -0
- package/dist/cjs/routing/swap-transactions.js +131 -0
- package/dist/cjs/routing/usd-value.d.ts +17 -0
- package/dist/cjs/routing/usd-value.js +29 -0
- package/dist/cjs/settings.d.ts +785 -0
- package/dist/cjs/settings.js +1074 -0
- package/dist/cjs/ton-connect.d.ts +98 -0
- package/dist/cjs/ton-connect.js +206 -0
- package/dist/cjs/ton-execution.d.ts +7 -0
- package/dist/cjs/ton-execution.js +23 -0
- package/dist/cjs/ton.d.ts +37 -0
- package/dist/cjs/ton.js +83 -0
- package/dist/cjs/tron-execution.d.ts +146 -0
- package/dist/cjs/tron-execution.js +248 -0
- package/dist/cjs/types.d.ts +51 -0
- package/dist/cjs/types.js +2 -0
- package/dist/claims.d.ts +198 -0
- package/dist/claims.js +140 -0
- package/dist/config.d.ts +24 -0
- package/dist/config.js +39 -5
- package/dist/consolidated-quote.d.ts +109 -15
- package/dist/consolidated-quote.js +310 -52
- package/dist/execution.d.ts +346 -0
- package/dist/execution.js +428 -0
- package/dist/hyperliquid-execution.js +2 -3
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/lifi-execution-guard.d.ts +13 -2
- package/dist/lifi-execution-guard.js +4 -0
- package/dist/near-intents.js +2 -3
- package/dist/pre-quote.d.ts +6 -6
- package/dist/pre-quote.js +10 -14
- package/dist/providers.d.ts +17 -0
- package/dist/providers.js +6 -0
- package/dist/referral.d.ts +12 -4
- package/dist/referral.js +12 -4
- package/dist/relay-depository.d.ts +2 -0
- package/dist/relay-depository.js +82 -0
- package/dist/relay-quote.js +2 -3
- package/dist/routing/candidate.d.ts +3 -3
- package/dist/routing/candidate.js +3 -3
- package/dist/routing/carriers/ask-answer.d.ts +19 -0
- package/dist/routing/carriers/omnibridge.js +23 -21
- package/dist/routing/carriers/pulsex-paths.d.ts +80 -0
- package/dist/routing/carriers/pulsex-paths.js +92 -0
- package/dist/routing/carriers/pulsex-split.d.ts +175 -0
- package/dist/routing/carriers/pulsex-split.js +185 -0
- package/dist/routing/carriers/pulsex.d.ts +69 -21
- package/dist/routing/carriers/pulsex.js +184 -65
- package/dist/routing/composed-route-quality.d.ts +28 -6
- package/dist/routing/composed-route-quality.js +36 -5
- package/dist/routing/entry-chain-anchor.d.ts +1 -1
- package/dist/routing/entry-chain-anchor.js +1 -1
- package/dist/routing/index.d.ts +7 -3
- package/dist/routing/index.js +7 -3
- package/dist/routing/producers.js +1 -1
- package/dist/routing/providers.d.ts +5 -0
- package/dist/routing/providers.js +5 -0
- package/dist/routing/search/graph.d.ts +29 -0
- package/dist/routing/search/plan-route-data.d.ts +25 -0
- package/dist/routing/search/plan-route-data.js +43 -7
- package/dist/routing/search/score.d.ts +33 -1
- package/dist/routing/search/score.js +41 -6
- package/dist/routing/swap-transactions.d.ts +91 -0
- package/dist/routing/swap-transactions.js +125 -0
- package/dist/settings.d.ts +94 -1
- package/dist/settings.js +95 -3
- package/dist/ton-connect.d.ts +98 -0
- package/dist/ton-connect.js +200 -0
- package/dist/ton-execution.d.ts +4 -114
- package/dist/ton-execution.js +4 -244
- package/dist/ton.d.ts +37 -0
- package/dist/ton.js +65 -0
- package/docs/examples/example-a-ether-to-pulse.ts +300 -0
- package/docs/examples/example-b-token-pulsechain-to-ethereum.ts +270 -0
- package/docs/examples/shared.ts +261 -0
- package/docs/examples/tsconfig.json +18 -0
- package/docs/integration-guide.md +617 -0
- package/ecosystems/package.json +6 -0
- package/execution/package.json +6 -0
- package/fee-type/package.json +6 -0
- package/hyperliquid-execution/package.json +6 -0
- package/image-links/package.json +6 -0
- package/lifi-execution-guard/package.json +6 -0
- package/llms.txt +234 -0
- package/near-intents/package.json +6 -0
- package/near-intents-route/package.json +6 -0
- package/origin-deposit/package.json +6 -0
- package/package.json +818 -10
- package/pre-quote/package.json +6 -0
- package/prices/package.json +6 -0
- package/providers/package.json +6 -0
- package/quote-fees/package.json +6 -0
- package/referral/package.json +6 -0
- package/relay-currencies/package.json +6 -0
- package/relay-quote/package.json +6 -0
- package/route-steps/package.json +6 -0
- package/routing/package.json +6 -0
- package/settings/package.json +6 -0
- package/ton/package.json +6 -0
- package/ton-connect/package.json +6 -0
- package/ton-execution/package.json +6 -0
- package/tron-execution/package.json +6 -0
- package/types/package.json +6 -0
package/llms.txt
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# @gibs/bridge-sdk
|
|
2
|
+
|
|
3
|
+
> A TypeScript library that prices and builds transfers across the Gibs
|
|
4
|
+
> Finance omnibridges (PulseChain with Ethereum, PulseChain with BNB Smart
|
|
5
|
+
> Chain). It also builds the requests for the aggregator routes (LI.FI,
|
|
6
|
+
> Relay, NEAR Intents) that reach those bridges from other chains. It does
|
|
7
|
+
> not sign or send anything. You bring a viem client and a wallet.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
- Run `npm install @gibs/bridge-sdk viem`.
|
|
12
|
+
- It runs on Node 20 or later (`engines.node` is `>=20`), in browsers, and in React Native under Hermes.
|
|
13
|
+
- viem is a peer dependency. The range is `>=2.35.0 <3`.
|
|
14
|
+
- Version note: 1.12.0 and older on npm are broken. 1.13.0 is the first usable version.
|
|
15
|
+
|
|
16
|
+
## Ways to use the package
|
|
17
|
+
|
|
18
|
+
The `exports` map picks the build. No consumer configuration is needed.
|
|
19
|
+
|
|
20
|
+
- ECMAScript modules: `import { pathway } from '@gibs/bridge-sdk/config'` loads `dist/config.js`.
|
|
21
|
+
- CommonJS: `require('@gibs/bridge-sdk/config')` loads `dist/cjs/config.js`, with its own declaration files.
|
|
22
|
+
- React Native 0.77 or later, default `metro.config.js`. Add no `resolveRequest` hook. In 0.79 or later, Metro reads `exports`: the `react-native` condition gives an `import` statement the ECMAScript module build and a `require` call the CommonJS build. The SDK then shares your build of viem, so Metro bundles viem once.
|
|
23
|
+
- React Native jest preset: loads the CommonJS build. Do not add `transformIgnorePatterns` for these packages.
|
|
24
|
+
- Metro with package exports off (the default in React Native 0.77 and 0.78): every subpath resolves through a folder the package ships for it, such as `config/package.json`, which points at the CommonJS build. Import the subpath as usual, never a `dist` path.
|
|
25
|
+
- No entry point except `@gibs/bridge-sdk/ton` needs a polyfill. That includes a `URL` polyfill: React Native 0.77's own `URL` and `URLSearchParams` are partial, and no entry point reads them.
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { Chains, pathway, Providers } from '@gibs/bridge-sdk/config'
|
|
29
|
+
import { amountAfterBridgeFee, bridgeCost } from '@gibs/bridge-sdk/settings'
|
|
30
|
+
|
|
31
|
+
const route = pathway([Providers.PULSECHAIN, Chains.PLS, Chains.ETH], true)
|
|
32
|
+
const cost = bridgeCost({ amountToBridge: 10n ** 18n, bridgeFee: 3n * 10n ** 15n })
|
|
33
|
+
console.log(route?.from, amountAfterBridgeFee({ amountToBridge: 10n ** 18n, bridgeCost: cost }))
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Bundle weight. Metro does not drop unused exports, so the entry point decides the weight. Measured in a React Native 0.87.1 production bundle that already holds viem:
|
|
37
|
+
|
|
38
|
+
- `/config` and `/settings` (offline quoting): about 24 kB.
|
|
39
|
+
- `/chain-info` (live fee reads) with the above: about 1.16 MB, because it loads `viem/chains` (1.12 MB). About 41 kB if the app already imports `viem/chains`.
|
|
40
|
+
- The root entry point: about 1.29 MB. About 164 kB if the app already imports `viem/chains`.
|
|
41
|
+
|
|
42
|
+
TON:
|
|
43
|
+
|
|
44
|
+
- `@gibs/bridge-sdk/ton-connect`: TON Connect requests and address re-encoding. No TON library, no `Buffer`.
|
|
45
|
+
- `@gibs/bridge-sdk/ton`: the same, plus `tonExternalMessageHash`, which needs `@ton/core`. Set `globalThis.Buffer` (the `buffer` package) before importing it in a browser or React Native. In React Native, Metro also needs `expo-crypto` installed, because `@ton/crypto` requires it there.
|
|
46
|
+
- `@gibs/bridge-sdk/ton-execution`: the old name of `@gibs/bridge-sdk/ton`.
|
|
47
|
+
|
|
48
|
+
## Entry points
|
|
49
|
+
|
|
50
|
+
Import from the narrowest subpath. The root `@gibs/bridge-sdk` exports everything except TON.
|
|
51
|
+
|
|
52
|
+
- `@gibs/bridge-sdk/config`: chains, providers, pathways, native-asset tables.
|
|
53
|
+
- `@gibs/bridge-sdk/types`: shared types such as `BridgeKey` and `Token`.
|
|
54
|
+
- `@gibs/bridge-sdk/chains`: viem chain objects with logos and public RPC URLs. `demoRpcUrls` is for demos only.
|
|
55
|
+
- `@gibs/bridge-sdk/chain-info`: on-chain reads (token mappings, fees, minimum amounts).
|
|
56
|
+
- `@gibs/bridge-sdk/settings`: fee and amount arithmetic.
|
|
57
|
+
- `@gibs/bridge-sdk/consolidated-quote`: LI.FI request builders and parsers.
|
|
58
|
+
- `@gibs/bridge-sdk/relay-quote`: Relay request builders and parsers.
|
|
59
|
+
- `@gibs/bridge-sdk/near-intents`: NEAR Intents requests and parsers.
|
|
60
|
+
- `@gibs/bridge-sdk/pre-quote`: price checks before a binding quote.
|
|
61
|
+
- `@gibs/bridge-sdk/routing`: route search across carriers.
|
|
62
|
+
- `@gibs/bridge-sdk/execution`: execution plans (`planExecution`, `planCandidateExecution`, `PlannedTx`, `DeliveryChoice`, `AllowanceReader`, `assumeNoAllowance`).
|
|
63
|
+
- `@gibs/bridge-sdk/claims`: manual claim transactions (`buildClaimTransaction`, `claimCall`, `packSignatures`, `signatureToVRS`, `encodeReleaseWithoutTipData`, `encodeReleaseToRouterData`).
|
|
64
|
+
- `@gibs/bridge-sdk/image-links`: image URLs from gib.show.
|
|
65
|
+
- `@gibs/bridge-sdk/abis`: contract ABIs.
|
|
66
|
+
- `@gibs/bridge-sdk/ton-connect`: TON Connect requests, with no TON library.
|
|
67
|
+
- `@gibs/bridge-sdk/ton`: TON Connect requests and the external message hash (needs `@ton/core`).
|
|
68
|
+
|
|
69
|
+
## Chains and pathways
|
|
70
|
+
|
|
71
|
+
A chain is a hex id from the `Chains` enum. A route is a `BridgeKey`:
|
|
72
|
+
`[provider, fromChain, toChain]`. `pathway` returns the contract addresses
|
|
73
|
+
for a key, or `undefined` when no pathway exists.
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
import { Chains, Providers, pathway } from '@gibs/bridge-sdk/config'
|
|
77
|
+
import type { BridgeKey } from '@gibs/bridge-sdk/types'
|
|
78
|
+
|
|
79
|
+
const bridgeKey: BridgeKey = [Providers.PULSECHAIN, Chains.ETH, Chains.PLS]
|
|
80
|
+
const route = pathway(bridgeKey, true) // true: mainnet only
|
|
81
|
+
if (route) {
|
|
82
|
+
route.from // the mediator on Ethereum, where funds enter
|
|
83
|
+
route.feeManager // 'to': the PulseChain mediator owns the fee manager
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Fees: direction and units
|
|
88
|
+
|
|
89
|
+
These rules must hold in every integration.
|
|
90
|
+
|
|
91
|
+
- PulseChain is the home side of both omnibridges.
|
|
92
|
+
- Foreign to home (`feeF2H`) means entering PulseChain.
|
|
93
|
+
- Home to foreign (`feeH2F`) means leaving PulseChain.
|
|
94
|
+
- Use the fee for your direction. Do not use one fee for both.
|
|
95
|
+
- Bridge fees are a rate per `1e18`. `1e18` is one hundred percent.
|
|
96
|
+
- Aggregator referral fees are basis points. `10_000n` is one hundred percent.
|
|
97
|
+
- LI.FI takes its fee as a decimal fraction (`0.001` is a tenth of a percent).
|
|
98
|
+
- Fees are on-chain settings. Read them. Do not hard-code them.
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
import { loadBridgeFees } from '@gibs/bridge-sdk/chain-info'
|
|
102
|
+
import { Chains, pathway, Providers } from '@gibs/bridge-sdk/config'
|
|
103
|
+
import { amountAfterBridgeFee, bridgeCost } from '@gibs/bridge-sdk/settings'
|
|
104
|
+
import type { PublicClient } from 'viem'
|
|
105
|
+
|
|
106
|
+
declare const ethereumClient: PublicClient
|
|
107
|
+
declare const pulsechainClient: PublicClient
|
|
108
|
+
|
|
109
|
+
const route = pathway([Providers.PULSECHAIN, Chains.ETH, Chains.PLS], true)
|
|
110
|
+
if (route) {
|
|
111
|
+
const { feeF2H } = await loadBridgeFees({
|
|
112
|
+
pathway: route,
|
|
113
|
+
fromChainClient: ethereumClient,
|
|
114
|
+
toChainClient: pulsechainClient,
|
|
115
|
+
})
|
|
116
|
+
const amountToBridge = 1_000_000n
|
|
117
|
+
const cost = bridgeCost({ amountToBridge, bridgeFee: feeF2H })
|
|
118
|
+
const received = amountAfterBridgeFee({ amountToBridge, bridgeCost: cost })
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
`loadBridgeFees` reads the default rate. It does not read per-token rates.
|
|
123
|
+
|
|
124
|
+
## Tokens that are not bridged yet
|
|
125
|
+
|
|
126
|
+
`tokenBridgeInfo` asks both mediators how a token maps across the bridge.
|
|
127
|
+
A `null` `assetOutAddress` is a normal answer. The token gets an address on
|
|
128
|
+
the far side when its first transfer arrives. Always check for `null`.
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
import { tokenBridgeInfo } from '@gibs/bridge-sdk/chain-info'
|
|
132
|
+
import { Chains, Providers } from '@gibs/bridge-sdk/config'
|
|
133
|
+
import type { Token } from '@gibs/bridge-sdk/types'
|
|
134
|
+
import type { PublicClient } from 'viem'
|
|
135
|
+
|
|
136
|
+
declare const assetIn: Token
|
|
137
|
+
declare const ethereumClient: PublicClient
|
|
138
|
+
declare const pulsechainClient: PublicClient
|
|
139
|
+
|
|
140
|
+
const info = await tokenBridgeInfo({
|
|
141
|
+
bridgeKey: [Providers.PULSECHAIN, Chains.ETH, Chains.PLS],
|
|
142
|
+
assetIn,
|
|
143
|
+
isProd: true,
|
|
144
|
+
fromChainClient: ethereumClient,
|
|
145
|
+
toChainClient: pulsechainClient,
|
|
146
|
+
})
|
|
147
|
+
if (info && info.assetOutAddress === null) {
|
|
148
|
+
// Not bridged yet. Do not treat this as an error.
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Aggregator identity: pass your own
|
|
153
|
+
|
|
154
|
+
The package ships no API key. Pass your own.
|
|
155
|
+
|
|
156
|
+
- Relay: pass your own `apiKey` to `relayRequestHeaders`. Name your own `relayReferrer`. The package sends no referrer by default, because Relay rejects a referrer without a key.
|
|
157
|
+
- LI.FI: set your own `lifiIntegrator`. The package sends no integrator by default. A positive `lifiFee` without your own integrator throws.
|
|
158
|
+
- NEAR Intents: no key is needed. No `referral` is sent unless you pass one. The `User-Agent` names Gibs Finance unless you pass your own `userAgent`, or `null` for none. Browsers drop it; Node and React Native send it.
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
import {
|
|
162
|
+
buildLifiContractCallsRequest,
|
|
163
|
+
type ConsolidatedQuoteRequest,
|
|
164
|
+
} from '@gibs/bridge-sdk/consolidated-quote'
|
|
165
|
+
import { nearIntentsRequestHeaders } from '@gibs/bridge-sdk/near-intents'
|
|
166
|
+
import { buildRelayQuoteRequest, relayQuoteUrl, relayRequestHeaders } from '@gibs/bridge-sdk/relay-quote'
|
|
167
|
+
|
|
168
|
+
declare const baseRequest: ConsolidatedQuoteRequest
|
|
169
|
+
declare const myRelayApiKey: string
|
|
170
|
+
|
|
171
|
+
const request: ConsolidatedQuoteRequest = {
|
|
172
|
+
...baseRequest,
|
|
173
|
+
lifiIntegrator: 'your-app.example',
|
|
174
|
+
lifiFee: 0.001,
|
|
175
|
+
relayReferrer: 'your-app.example',
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const lifiBody = buildLifiContractCallsRequest(request)
|
|
179
|
+
const relayBody = buildRelayQuoteRequest(request)
|
|
180
|
+
if (relayBody) {
|
|
181
|
+
await fetch(relayQuoteUrl, {
|
|
182
|
+
method: 'POST',
|
|
183
|
+
body: JSON.stringify(relayBody),
|
|
184
|
+
headers: relayRequestHeaders(myRelayApiKey),
|
|
185
|
+
})
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const nearHeaders = nearIntentsRequestHeaders(undefined, { userAgent: 'your-app/1.0' })
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Fees: nothing is added for you
|
|
192
|
+
|
|
193
|
+
- No builder adds a fee, a payout address or a Gibs Finance label. A request carries one only when you pass it.
|
|
194
|
+
- Bridge fee: on-chain, on every direct crossing. Read it with `loadBridgeFees`. You cannot turn it off.
|
|
195
|
+
- Delivery fee: only with `shouldDeliver: true` and a fee director. See it with `deliveryFee`.
|
|
196
|
+
- LI.FI fee: only with `lifiFee` and your own `lifiIntegrator`.
|
|
197
|
+
- Relay application fee: only with `relayAppFee: { recipient, basisPoints }`.
|
|
198
|
+
- Provider fees (gas, solver, protocol): charged by LI.FI, Relay or NEAR Intents. Read them with `lifiQuoteFees`, `relayQuoteFees` and the NEAR Intents quote parser.
|
|
199
|
+
- NEAR Intents adds 25 basis points to a quote sent without a partner key.
|
|
200
|
+
- `@gibs/bridge-sdk/referral` holds Gibs Finance's own values (`referralIntegrator`, `relayReferralRecipient`, `defaultReferralFeeBasisPoints`). They pay Gibs Finance. Do not pass them from your own app.
|
|
201
|
+
|
|
202
|
+
## RPC endpoints: the defaults are for demos only
|
|
203
|
+
|
|
204
|
+
- Every reader takes your viem clients. None builds its own.
|
|
205
|
+
- `chainsMetadata` carries public endpoints only.
|
|
206
|
+
- `demoRpcUrls` and `demoRpcUrlsFor` add a shared valve.city key, `vk_demo`. They are for demos only. The key is public, but its rate budget is shared and the Gibs Finance operator runs the proxy.
|
|
207
|
+
- In production, use your own RPC provider.
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
import { demoRpcUrlsFor } from '@gibs/bridge-sdk/chains'
|
|
211
|
+
import { createPublicClient, fallback, http } from 'viem'
|
|
212
|
+
import { mainnet } from 'viem/chains'
|
|
213
|
+
|
|
214
|
+
const ethereumClient = createPublicClient({ chain: mainnet, transport: http('https://your-rpc.example') })
|
|
215
|
+
const demoOnly = createPublicClient({
|
|
216
|
+
chain: mainnet,
|
|
217
|
+
transport: fallback(demoRpcUrlsFor(mainnet.id).map((url) => http(url))),
|
|
218
|
+
})
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Nulls and throws
|
|
222
|
+
|
|
223
|
+
- A question the package cannot answer returns `null`, `undefined` or `false`.
|
|
224
|
+
- A caller mistake or a failed chain read throws.
|
|
225
|
+
- Every request builder returns `null` for a request its provider cannot express.
|
|
226
|
+
- Every response parser returns `null` for an unexpected response shape.
|
|
227
|
+
- Check each return value before you use it.
|
|
228
|
+
|
|
229
|
+
## Links
|
|
230
|
+
|
|
231
|
+
- [Integrate Gibs into a wallet or app](https://next.gibs.finance/docs/): search, plan, send, track and claim, with two complete examples. The same guide ships in this package as `docs/integration-guide.md`.
|
|
232
|
+
- [README](https://www.npmjs.com/package/@gibs/bridge-sdk): the full reference.
|
|
233
|
+
- [Gibs Finance llms.txt](https://next.gibs.finance/llms.txt): the whole platform.
|
|
234
|
+
- [@gibs/quotes](https://next.gibs.finance/docs/packages/quotes/llms.txt): live multi-provider quotes.
|