SDK for rewriting repayment destinations in router-encoded intent calldata.
Allows external relayers to redirect where they receive repayments when filling or claiming intents through the Rhinestone router.
bun add @rhinestone/relayer-sdk viemimport {
replaceRepaymentDestinations,
parseAddress,
} from '@rhinestone/relayer-sdk'
// Rewrite repayment destination in router calldata
const rewritten = replaceRepaymentDestinations(
routerAddress,
originalCalldata,
{
address: parseAddress('0xYourRelayerAddress'),
// Omit `chain` to preserve per-deposit origin chains (recommended for Across)
// Or specify a chain to redirect all repayments there
},
)By default, the SDK uses production contract addresses from @rhinestone/shared-configs. For dev deployments or custom configurations:
import {
replaceRepaymentDestinations,
parseAddress,
type RebalancingConfig,
} from '@rhinestone/relayer-sdk'
import { contractAddressesDev } from '@rhinestone/shared-configs'
const config: RebalancingConfig = {
routerAddress: parseAddress(contractAddressesDev['*'].router),
intentExecutorAddress: parseAddress(contractAddressesDev['*'].intentExecutor),
}
const rewritten = replaceRepaymentDestinations(
routerAddress,
calldata,
{ address: myAddress },
config,
)Rewrites repayment destinations inside router-encoded intent calldata.
Parameters:
to: EthAddress- Target contract address of the calldata: Hex- ABI-encoded calldata (routeFill / routeClaim / optimized variant)destination: RepaymentDestination- Where to receive repaymentsaddress: EthAddress- The repayment recipientchain?: number- Override repayment chain. Omit to preserve original per-deposit chains.
config?: RebalancingConfig- Optional contract address overrides
Returns: Hex - The calldata with rewritten repayment destinations
Validates and normalizes an address string to an EthAddress.
For advanced use cases:
decodeRouterCall(data)- Decode router calldatafunctionSelectorToAdapterCallMap- Map from selector to adapter metadataAcrossRepaymentsRelayerContext- Across-specific rewrite functionSameChainRepaymentsRelayerContext- SameChain-specific rewrite functionEcoRepaymentsRelayerContext- Eco-specific rewrite functionNoRelayerContext- No-op rewrite function
The SDK supports repayment rewriting for:
- Across - Cross-chain bridge adapter (tuple array of repayments)
- SameChain - Same-chain settlement adapter
- Eco - Eco protocol adapter
- MultiCall - Multi-call adapter (handleFill, handleJITClaim)
MIT