@gibs/bridge-sdk
A TypeScript library that prices and builds transfers across the Gibs Finance omnibridges (PulseChain with Ethereum, PulseChain with BNB Smart Chain). It also builds the requests for the aggregator routes (LI.FI, Relay, NEAR Intents) that reach those bridges from other chains. It does not sign or send anything. You bring a viem client and a wallet.
Install
- Run
npm install @gibs/bridge-sdk viem. - It runs on Node 20 or later (
engines.nodeis>=20), in browsers, and in React Native under Hermes. - viem is a peer dependency. The range is
>=2.35.0 <3. - Version note: 1.12.0 and older on npm are broken. 1.13.0 is the first usable version.
Ways to use the package
The exports map picks the build. No consumer configuration is needed.
- ECMAScript modules:
import { pathway } from '@gibs/bridge-sdk/config'loadsdist/config.js. - CommonJS:
require('@gibs/bridge-sdk/config')loadsdist/cjs/config.js, with its own declaration files. - React Native 0.77 or later, default
metro.config.js. Add noresolveRequesthook. In 0.79 or later, Metro readsexports: thereact-nativecondition gives animportstatement the ECMAScript module build and arequirecall the CommonJS build. The SDK then shares your build of viem, so Metro bundles viem once. - React Native jest preset: loads the CommonJS build. Do not add
transformIgnorePatternsfor these packages. - 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 adistpath. - No entry point except
@gibs/bridge-sdk/tonneeds a polyfill. That includes aURLpolyfill: React Native 0.77's ownURLandURLSearchParamsare partial, and no entry point reads them.
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:
/configand/settings(offline quoting): about 24 kB./chain-info(live fee reads) with the above: about 1.16 MB, because it loadsviem/chains(1.12 MB). About 41 kB if the app already importsviem/chains.- The root entry point: about 1.29 MB. About 164 kB if the app already imports
viem/chains.
TON:
@gibs/bridge-sdk/ton-connect: TON Connect requests and address re-encoding. No TON library, noBuffer.@gibs/bridge-sdk/ton: the same, plustonExternalMessageHash, which needs@ton/core. SetglobalThis.Buffer(thebufferpackage) before importing it in a browser or React Native. In React Native, Metro also needsexpo-cryptoinstalled, because@ton/cryptorequires it there.@gibs/bridge-sdk/ton-execution: the old name of@gibs/bridge-sdk/ton.
Entry points
Import from the narrowest subpath. The root @gibs/bridge-sdk exports everything except TON.
@gibs/bridge-sdk/config: chains, providers, pathways, native-asset tables.@gibs/bridge-sdk/types: shared types such asBridgeKeyandToken.@gibs/bridge-sdk/chains: viem chain objects with logos and public RPC URLs.demoRpcUrlsis for demos only.@gibs/bridge-sdk/chain-info: on-chain reads (token mappings, fees, minimum amounts).@gibs/bridge-sdk/settings: fee and amount arithmetic (bridgeCost,amountAfterBridgeFee,deliveryFee,directedDeliveryFee,feeTypeSettings,estimatedAmountOut).@gibs/bridge-sdk/consolidated-quote: LI.FI request builders and parsers.@gibs/bridge-sdk/relay-quote: Relay request builders and parsers.@gibs/bridge-sdk/near-intents: NEAR Intents requests and parsers.@gibs/bridge-sdk/pre-quote: price checks before a binding quote.@gibs/bridge-sdk/routing: route search across carriers (createOmnibridgeCarrier,amountAfterDeliveryFee,OmnibridgeDeliveryChoice).@gibs/bridge-sdk/execution: execution plans (planExecution,planCandidateExecution,PlannedTx,DeliveryChoice,AllowanceReader,assumeNoAllowance).@gibs/bridge-sdk/claims: manual claim transactions (buildClaimTransaction,claimCall,packSignatures,signatureToVRS,encodeReleaseWithoutTipData,encodeReleaseToRouterData).@gibs/bridge-sdk/journey: one transfer as a journey of steps, its first unfinished step, its status and its one action (groupStagesIntoSteps,stepProgressFromStages,haltedStepFailure,journeyStatus,journeyAction,journeyTotalCount).@gibs/bridge-sdk/image-links: image URLs from gib.show.@gibs/bridge-sdk/abis: contract ABIs.@gibs/bridge-sdk/ton-connect: TON Connect requests, with no TON library.@gibs/bridge-sdk/ton: TON Connect requests and the external message hash (needs@ton/core).
Chains and pathways
A chain is a hex id from the Chains enum. A route is a BridgeKey:
[provider, fromChain, toChain]. pathway returns the contract addresses
for a key, or undefined when no pathway exists.
Fees: direction and units
These rules must hold in every integration.
- PulseChain is the home side of both omnibridges.
- Foreign to home (
feeF2H) means entering PulseChain. - Home to foreign (
feeH2F) means leaving PulseChain. - Use the fee for your direction. Do not use one fee for both.
- Bridge fees are a rate per
1e18.1e18is one hundred percent. - Aggregator referral fees are basis points.
10_000nis one hundred percent. - LI.FI takes its fee as a decimal fraction (
0.001is a tenth of a percent). - Fees are on-chain settings. Read them. Do not hard-code them.
loadBridgeFees reads the default rate. It does not read per-token rates.
Tokens that are not bridged yet
tokenBridgeInfo asks both mediators how a token maps across the bridge.
A null assetOutAddress is a normal answer. The token gets an address on
the far side when its first transfer arrives. Always check for null.
Aggregator identity: pass your own
The package ships no API key. Pass your own.
- Relay: pass your own
apiKeytorelayRequestHeaders. Name your ownrelayReferrer. The package sends no referrer by default, because Relay rejects a referrer without a key. - LI.FI: set your own
lifiIntegrator. The package sends no integrator by default. A positivelifiFeewithout your own integrator throws. - NEAR Intents: no key is needed. No
referralis sent unless you pass one. TheUser-Agentnames Gibs Finance unless you pass your ownuserAgent, ornullfor none. Browsers drop it; Node and React Native send it.
Fees: nothing is added for you
- No builder adds a fee, a payout address or a Gibs Finance label. A request carries one only when you pass it.
- Bridge fee: on-chain, on every direct crossing. Read it with
loadBridgeFees. You cannot turn it off. - Delivery fee: only with
shouldDeliver: trueand a fee director. Quote it withdeliveryFee. Read what a fee director takes withdirectedDeliveryFee({ settings, limit, multiplier, value }). directedDeliveryFeereturns{ kind: 'exact' | 'at-most', fee }. Fixed mode (settings bit 0) wins over percent mode (bit 3). A percent fee is not capped bylimit. Gas-tip mode returnsat-most, because only the delivery transaction knows the gas cost. Every fee is capped atvalue. Bit 1 asks the router to unwrap, and bit 2 excludes the priority fee.- What the recipient receives is the amount after the bridge fee, minus the delivery fee.
amountAfterDeliveryFee({ amountAfterBridgeFee, terms })in@gibs/bridge-sdk/routingcomputes it from aQuotedDeliveryFee. - Native landing: a delivered crossing whose router unwraps can land on the destination native coin. The planner refuses an unwrap without bought delivery (
unwrap-needs-delivery). - LI.FI fee: only with
lifiFeeand your ownlifiIntegrator. - Relay application fee: only with
relayAppFee: { recipient, basisPoints }. - Provider fees (gas, solver, protocol): charged by LI.FI, Relay or NEAR Intents. Read them with
lifiQuoteFees,relayQuoteFeesand the NEAR Intents quote parser. - NEAR Intents adds 25 basis points to a quote sent without a partner key.
@gibs/bridge-sdk/referralholds Gibs Finance's own values (referralIntegrator,relayReferralRecipient,defaultReferralFeeBasisPoints). They pay Gibs Finance. Do not pass them from your own app.
RPC endpoints: the defaults are for demos only
- Every reader takes your viem clients. None builds its own.
chainsMetadatacarries public endpoints only.demoRpcUrlsanddemoRpcUrlsForadd 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.- In production, use your own RPC provider.
Nulls and throws
- A question the package cannot answer returns
null,undefinedorfalse. - A caller mistake or a failed chain read throws.
- Every request builder returns
nullfor a request its provider cannot express. - Every response parser returns
nullfor an unexpected response shape. - Check each return value before you use it.
Links
- Integrate Gibs into a wallet or app: search, plan, send, track and claim, with two complete examples. The same guide ships in this package as
docs/integration-guide.md. - README: the full reference.
- Gibs Finance llms.txt: the whole platform.
- @gibs/quotes: live multi-provider quotes.