Documentation Index
Fetch the complete documentation index at: https://docs.kynesys.xyz/llms.txt
Use this file to discover all available pages before exploring further.
Crosschain SWAP
RubicBridge is a thin SDK client for the node-side Rubic bridge integration. It exposes two methods — getTrade for quoting a swap, and executeTrade for committing it — both of which proxy through the connected DEMOS RPC.
How to SWAP from one chain to another
1. Connect to the network
2. Create a RubicBridge instance
RubicBridge is stateless — there are no constructor arguments. The chain and payload are passed per call.
3. Build the trade payload
BridgeTradePayload.amount and the chain IDs refer to the source chain’s native units, not Demos OS. For example, an EVM swap of 10 USDT uses amount: 10 because Rubic itself handles the on-chain decimal conversion.
fromToken / toToken values are "NATIVE", "USDC", and "USDT". "NATIVE" refers to the source chain’s native token (e.g. ETH on Ethereum, MATIC on Polygon) — not Demos DEM.
SupportedChains is exported as a string-valued object with these keys:
getTrade / executeTrade is the source chain key (SupportedChains.POLYGON in this example).
4. Quote the trade
getTrade returns the standard RPCResponse. Inspect trade.response for the quoted route and pricing before committing.
5. Execute the trade
If the quote looks good, commit the swap withexecuteTrade. The same payload is passed — there is no separate “trade object” to forward.
For local development against an unfunded source chain,
RubicBridge.executeMockTrade(demos, chain, wrappedTrade) accepts a WrappedCrossChainTrade (from rubic-sdk) and exercises the same RPC path without broadcasting on the foreign chain.