Steer Protocol
Developer Guide

SDK Reference

Function-level API map for the Collateral Rail SDK.

Purpose

@steerprotocol/collateral-rail-sdk is designed around two guarantees:

  • Typed runtime paths for browser and Node.js.
  • No hidden transaction signing assumptions (clients are explicit inputs).

This page is a practical lookup for what to use in production code.

Public exports

The package root exports:

  • client helpers (src/client.ts)
  • swap helpers (src/swap.ts)
  • contracts helpers (src/contracts.ts)
  • onboarding helpers (src/onboarding.ts)
  • events parsing (src/events.ts)
  • errors decoding (src/errors.ts)
  • generated typed wagmi actions (src/generated/contracts.ts)
  • protocolTypes for all major payload shapes

Client construction

HelperCategoryWhat it returns
createProtocolPublicClientcorePublicClient
createProtocolWalletClientcoreWalletClient
createProtocolClientscore{ publicClient, walletClient }
clientsFromWagmiConfigbrowser{ publicClient, walletClient }
customProviderTransportintegrationviem Transport

Example

import { createProtocolClients } from "@steerprotocol/collateral-rail-sdk";
import { optimismSepolia } from "viem/chains";

const { publicClient, walletClient } = createProtocolClients({
  chain: optimismSepolia,
  rpcUrl: "https://rpc.example",
});

Swap utilities

HelperInputOutput
inferSwapDirectionSwapParams{ direction, absoluteAmount }
resolveHookDatahookData?raw hookData or empty bytes
previewCollateralSwapFromParamsSwapParams{ intent, shouldSettle, hookData }
buildSwapIntentSwapParams, hookData?, signedSwapQuote?{ intent, shouldSettle, hookData }
buildSwapCallDescriptorSwapExecutionInputviem call descriptor
buildExactInputSignedQuoteCallDescriptorExactInputSignedQuoteExecutionInputexecutor call descriptor
buildExactOutputSignedQuoteCallDescriptorExactOutputSignedQuoteExecutionInputexecutor call descriptor
buildTargetOutputSignedQuoteCallDescriptorTargetOutputSignedQuoteExecutionInputexecutor call descriptor
buildSignedSwapQuotePayload(walletClient, collateralManager, chainId, quote, account)signed quote payload Hex
buildSignedSwapQuoteDigest(collateralManager, chainId, quote)signed quote digest Hex
simulateSwapPublicClient, SwapExecutionInputsimulation result
executeSwapWalletClient, SwapExecutionInput (+ optional account)tx hash
defaultSwapDeadlineoffset (seconds)unix epoch bigint
isSignedSwapQuoteDataHex payloadboolean
encodeSignedSwapQuotePayloadSignedSwapQuoteHex
splitSignatureECDSA signature Hex{ v, r, s }
signSignedSwapQuote(walletClient, collateralManager, chainId, quote, account)SignedSwapQuote

Signing controls vault settlement

buildSwapIntent and buildSwapCallDescriptor support empty or explicit hook data. Quote-price-only legacy metadata is intentionally not generated by the SDK. If signedSwapQuote is supplied, its encoded payload is used directly as hookData for signed quote vault settlement.

Signed quote execution

Production signed quote vault swaps should use the SignedCollateralSwapRouter helpers with signed quote hook data. They expose sqrtPriceLimitX96 as a first-class native v4 price boundary; 0n means the executor will apply the direction-based unbounded default. Final slippage remains amountOutMin or amountInMax, and non-signed hookData remains pure AMM metadata only.

Signed quote types

signedQuote.ts exports:

  • SignedSwapQuote (fully signed quote payload)
  • SignedSwapQuoteBase (unsigned quote values)
  • SignedSwapQuoteSignature (v, r, s)
  • SIGNED_SWAP_QUOTE_ENCODED_LENGTH_BYTES

Signed quote schema (normative)

FieldTypeUnit / formatNotes
poolIdbytes32exact on-chain pool idMust match the pool for this swap
traderaddressEIP-55 addressMust match swap sender/trader binding
maxAbsAmountuint256token base unitsMust be >= abs(amountSpecified)
quotedPriceE18uint2561e18 fixed-pointChecked against oracle policy envelope
expiryuint64Unix timestamp (seconds)Expired quotes revert
vuint827 or 28Signature recovery id
rbytes32hexSignature component
sbytes32hexSignature component

Encoding notes:

  • SDK payload version is 1.
  • Encoded signed quote payload length is 288 bytes (SIGNED_SWAP_QUOTE_ENCODED_LENGTH_BYTES).
  • Replay keys are derived on-chain from the signed envelope, recovered signer, chain id, and collateral manager address.

EIP-712 domain and typed data

Signed quote helpers (signSignedSwapQuote, buildSignedSwapQuoteDigest) use:

  • domain.name = "CollateralManager"
  • domain.version = "1"
  • domain.chainId = <target chain id>
  • domain.verifyingContract = <collateral manager address>
  • primaryType = "SignedSwapQuote"

SignedSwapQuote typed fields:

  • poolId: bytes32
  • trader: address
  • maxAbsAmount: uint256
  • quotedPrice: uint256
  • expiry: uint64

Core collateral flow

HelperFunction
getCollateralManagerMaxMintableRead max mint for account
getCollateralManagerBalanceRead collateral or debt balance
totalDebtRead protocol debt denominator
getCollateralManagerConfigRead config bundle from manager
depositCollateralWrite collateral in
withdrawCollateralWrite collateral out
mintStableForAccountMint stable on behalf of user
redeemStableForAccountRedeem stable to collateral
previewCollateralManagerSwapRead settlement intent
settleCollateralManagerSwapWrite post-swap settlement

Helper safety classification

Helper groupIntended audienceNotes
client + signed quote swap builders (create*Client, buildExactInputSignedQuoteCallDescriptor, buildExactOutputSignedQuoteCallDescriptor, buildTargetOutputSignedQuoteCallDescriptor)app integratorsStandard production integration path
read helpers (get*, previewCollateralManagerSwap)app integrators, operatorsSafe for read-only planning and monitoring
admin writers (set*, guardian helpers)operators/governanceRequire privileged roles
settleCollateralManagerSwaphook-authorized contexts onlyFor protocol callback flows, simulations, and specialized operator tooling; not normal end-user app execution

Settlement preview vs. settle

  • Use previewCollateralManagerSwap to get deterministic settlement direction.
  • Use settleCollateralManagerSwap with the actual callback poolDelta from the swap execution.
  • Any preview and settlement mismatches should be treated as runtime observability events, not hidden failures.

Risk and governance

RiskConfig

  • getRiskConfigCollateral, setRiskConfigCollateral
  • getRiskConfigGlobal, setRiskConfigGlobal, setRiskConfigSafeMode
  • guardianSetSafeMode

Hook controls

  • getHookPoolRiskConfig, setHookPoolRiskConfig
  • setHookOracleAdapter
  • setHookGlobalSafeMode

CollateralManager controls

  • setCollateralManagerOracleAdapter
  • setCollateralManagerSettlementHook
  • setCollateralManagerDegradedHaircut

Oracle controls

  • getOracleCollateralConfig, setOracleCollateralConfig
  • getOracleEffectivePrice
  • setOracleGlobalPaused

Stablecoin controls

  • setStablecoinMinter, getStablecoinIsMinter

Launch automation

The launch helpers compose and validate the operational sequence before you broadcast:

  • withDefaultsCollateralConfig
  • withDefaultsGlobalConfig
  • withDefaultsPoolRiskConfig
  • withDefaultsOracleConfig
  • validateLaunchInput
  • buildLaunchSteps
  • buildLaunchCallDescriptors

Use these with a multisig flow and a pre-transaction dry-run checklist.

Events and errors

HelperPurpose
parseHookRiskEvaluatedLogsDecode risk gating events from a list of logs
parseHookSettlementLogsDecode settlement callback outcomes
parseAfterSwapSettlementLogsDecode post-settlement AMM reconciliation
parseEventsFromReceiptGroup all protocol events from tx receipt
parseErrorDecode reverted protocol error reason
getErrorMessageReturn compact {source}.{name} string

Generated wagmi actions

The generated namespace contains optional typed read/write/simulate/watch helpers for all contracts.

Use it for:

  • React apps already on wagmi action typing
  • Explicit generated contracts in schema-heavy codebases

Use plain viem-first helpers when you need transport-level control or non-wagmi runtimes.

Type references

Commonly-used protocol shapes:

  • SwapParams
  • SwapIntent
  • SwapExecutionInput
  • CallDescriptor
  • ContractAddresses
  • CollateralConfig
  • GlobalConfig
  • PoolRiskConfig
  • OracleCollateralConfig
  • HookRiskLog
  • HookSettlementLog
  • SettlementEvent
  • LaunchConfig / LaunchPlan
  • RiskMode, OracleModeValue, OracleReasonCode
  • SignedSwapQuote
  • SignedSwapQuoteBase
  • SignedSwapQuoteSignature
  1. Start from this SDK Integration page.
  2. Then step into Swap lifecycle walkthrough.
  3. For deployment prep, follow New Market Onboarding.

Explicit risk mode changes

setRiskConfigGlobal retains the current mode and reverts if its supplied mode is stale. Use setRiskConfigSafeMode(walletClient, riskConfig, expectedMode, nextMode, account?) for an explicit admin mode transition without rewriting limits. Refresh and review a mode mismatch before retrying. Guardian emergency changes continue to use guardianSetSafeMode. The new helper requires a registry that implements the new entrypoint; older deployments retain their existing API.

On this page