In Railnet smart contracts, a Yield Source is connected via a Vehicle adapter. See Glossary for all terminology.
create() is called, the query transitions directly from EMPTY to UNLOCKING, meaning assets are immediately deposited and ready for the user to claim.
Prerequisites
- A deployed
ERC4626VehicleFactory(or the factory for your adapter type) — see Supported protocols for factory addresses per chain - An underlying yield source (e.g., an ERC-4626 vault address)
- Underlying assets (e.g., USDC) for the initial deposit
- Foundry installed and configured
Tutorial
Understand the deployment model
Adapters are deployed through factory contracts. The factory handles deterministic
CREATE2 deployment, performs an initial deposit to protect against inflation attacks, burns the initial shares, and enables the adapter for public use.You call the factory’s spawn function with a SpawnParams struct that configures your adapter.Prepare spawn parameters
Define the configuration for your adapter deployment. This includes references to your yield source, access control, fee management, and initial deposit sizing.
The
initialDepositSize bootstraps the adapter with real liquidity. The factory burns the shares minted from this deposit to prevent inflation attacks on the share price.Deploy the adapter
Call the factory’s The factory emits a
spawn function. This deploys the Vehicle proxy, initializes it, performs the initial deposit, burns shares, validates supply, and enables the adapter.SpawnedERC4626Vehicle event with the new adapter address.Create a deposit query
In STEAM, every operation starts with a Query. Define your deposit query with the owner, receiver, mode, input assets, and a unique salt.
Execute the deposit
The deposit follows the STEAM two-step lifecycle: Because this is a synchronous adapter, The query transitions to
create then unlock.First, approve the Vehicle to pull your assets, then create the query:create() immediately deposits the assets into the underlying vault and transitions the query to UNLOCKING.Then settle the query to receive your shares:SETTLED, and you receive Vehicle shares.Execute a redemption
To redeem, create a new query with The Vehicle burns your shares, withdraws assets from the underlying vault, and transfers the underlying assets to your receiver address.
Mode.REDEEM and provide your Vehicle shares as input.Sync adapter state flow
In a synchronous adapter, the query lifecycle is straightforward:PROCESSING or WAITING state because the underlying protocol completes the operation immediately within the create() transaction.
What your adapter implements
When building a custom sync adapter (rather than using the built-in ERC4626Vehicle), you inherit fromSingleAssetBaseVehicle and implement:
| Method | Purpose |
|---|---|
_create() | Execute the deposit or redeem on your protocol. Return UNLOCKING for sync. |
_unlock() | Transfer output assets to the receiver. Return SETTLED. |
_maxDeposit() | Return the maximum depositable amount based on protocol constraints. |
_maxRedeem() | Return the maximum redeemable amount based on protocol liquidity. |
_totalAssets() | Return the total underlying assets managed by this adapter. |
Next steps
Build a custom adapter
Handle protocols with withdrawal delays or cooldown periods.
Write adapter tests
Validate your adapter with the STEAM testing framework.