Raum NetworkDeveloper Docs
RaumFi v2

RaumFi v2 Quickstart

Quickstart guide for building and testing the RaumFi v2 Stellar Soroban AMM contract workspace and local development flow.

Prerequisites

  • Rust and Cargo
  • The wasm32-unknown-unknown target
  • Soroban CLI, for deploying to testnet
rustup target add wasm32-unknown-unknown

Each contract has its own Makefile, and the build order matters: pair imports the compiled rntoken WASM (as the test token) via contractimport!, and factory imports the compiled pair WASM the same way. Building factory pulls the rest in automatically:

cd corecontracts/factory
make build   # builds rntoken -> pair -> factory, then optimizes factory's WASM

# to build and test an individual crate directly
cd ../pair && cargo test
cd ../router && cargo test

This produces raumfi_factory.wasm, raumfi_pair.wasm, and rntoken.wasm under each crate's target/wasm32-unknown-unknown/release/. The router crate has no compile-time dependency on the others - it talks to the factory and pair contracts entirely through cross-contract calls at runtime, so it builds independently:

cd corecontracts/router
cargo build --target wasm32-unknown-unknown --release

Deploying and wiring the contracts

Deployment order follows the same dependency chain as the build:

  1. Deploy raumfi_pair.wasm and note its WASM hash (not its address - the factory deploys new pair instances from this hash, it doesn't call an existing one).
  2. Deploy raumfi_factory.wasm, then call initialize(setter, pair_wasm_hash) with an admin address and the pair hash from step 1.
  3. Deploy raumfi_router.wasm, then call initialize(factory) with the factory's contract address.

From there, calling router.add_liquidity(...) for a new token pair will invoke factory.create_pair internally if that pair doesn't exist yet - pairs don't need to be created as a separate step.