Rust Stylus Architecture
Why Rust via Stylus?
Traditional Solidity contracts on Ethereum suffer from high gas costs for complex computation. While suitable for simple token transfers, they struggle with heavy mathematical loops (like calculating daily compound interest for 10 years).
LegacyVault solves this by utilizing Arbitrum Stylus, allowing us to write our "Heavy Logic" in Rust.
The Hybrid Model
The Brain (Rust Logic)
The core intelligence (vault-logic) resides in a single compiled WASM binary.
Performance: Rust compiles to WebAssembly (WASM), which executes much faster and cheaper than EVM bytecode.
Safety: Rust's memory safety features prevent common vulnerabilities like Reentrancy and Overflow at the compiler level.
The Loop Architecture
The "Ping" Check
Instead of relying on an external Keeper network to check "Is Alive?", the logic is embedded directly in the contract state.
// vault-logic/src/lib.rs
// Direct, type-safe comparison
if msg::sender() != self.owner.get() {
return Err(b"Unauthorized".to_vec());
}
self.last_ping.set(block::timestamp());