All projects

DeFi Strategy Profiler

Trustless DeFi strategy simulations on a real mainnet fork, with DON-signed on-chain proofs.

DeFi & Tokenization Tenderly

What it is

DeFi Strategy Profiler is a developer tool that proves whether a DeFi strategy actually works, using a real Ethereum mainnet fork and a Chainlink CRE workflow that writes a DON-signed proof on-chain.
Today, most strategy “proof” is screenshots, private scripts, or localhost forks that no one else can verify. There is no standardized, trustless way to show that a strategy executed under real liquidity and real prices, and to share that proof with other teams, auditors, or users.
In DeFi Strategy Profiler, a developer implements a single execute function strategy interface in Solidity, for example “swap WETH → DAI → USDC via Uniswap V3”. The CLI deploys this strategy to a Tenderly Virtual TestNet fork of Ethereum mainnet, then calls requestSimulation on a shared SimulationRegistry contract on Sepolia. The registry assigns a runId and emits a SimulationQueued event.
A Chainlink CRE listener workflow picks up SimulationQueued, validates the inputs, and writes a DON-attested job into a SimulationJobQueue contract via the CRE Forwarder. This emits a JobEnqueued event that only the DON can produce. A second CRE executor workflow listens for JobEnqueued, decodes the job, calls strategy.execute on the Tenderly mainnet fork, and captures token flow, gas metrics, and transaction details. It then signs the result with the DON key and calls writeReport / onReport on SimulationRegistry, which stores a permanent, DON-signed SimulationReport on Sepolia keyed by runId.
A minimal React frontend lets anyone view the result for a given runId: status (success or reverted), token in/out amounts and effective rate, gas used and cost, links to Sepolia Etherscan (for the on-chain proof) and Tenderly (for the full mainnet-fork transaction trace). The same pattern works not only for swaps, but also for more complex strategies like Aave lend/borrow → Uniswap swap → repay, or cross-chain flows using CCIP.

How it Works

Smart contracts (Foundry / Solidity 0.8.24)

SimulationRegistry: assigns runIds, emits SimulationQueued, and stores final SimulationReports on Sepolia.

SimulationJobQueue: receives DON-attested jobs from CRE via the Forwarder, enforces simple replay protection, and emits JobEnqueued.

Strategy contracts: a simple IDeFiStrategy interface with execute(address receiver, bytes params) implemented by example strategies like EthToUsdcSwapStrategy, EthToUsdcDaiMultiHopStrategy, and a failing slippage strategy.

Chainlink CRE workflows (TypeScript → WASM)

wf-listener: log-triggered on SimulationQueued from Sepolia. Validates strategy and explorerUrl, encodes a job payload, and calls SimulationJobQueue.onReport via the CRE Forwarder so only the DON can enqueue jobs.

wf-executor: log-triggered on JobEnqueued. Reads job details from SimulationJobQueue, executes strategy.execute on the Tenderly Virtual TestNet via Admin RPC, captures token flow and gas metrics, signs the report with the DON key, and calls SimulationRegistry.writeReport / onReport on Sepolia.

Tenderly Virtual TestNet

A mainnet fork network created and managed by the CLI, with Uniswap V3 liquidity and real token prices.

CRE workflows use the vNet Admin RPC to perform the strategy execution against real protocol state.

CLI (TypeScript + viem)

cli:setup: creates or reuses a Tenderly Virtual TestNet, funds accounts, and syncs RPC URLs and executor address into CRE config and .env.

cli:provision:: deploys the chosen strategy to vNet, then calls requestSimulation on Sepolia and prints the runId and transaction hashes.

Frontend (React + Vite + viem)

Route /run/:runId fetches the SimulationReport from SimulationRegistry and renders: status, token flow, gas metrics, links to Sepolia Etherscan and Tenderly Explorer.

Everything is wired to focus on one core flow: requestSimulation() on Sepolia → SimulationQueued → CRE listener → JobEnqueued → CRE executor → writeReport() on Sepolia → verifiable UI + Tenderly trace.

Links

Created by

  • Mohd Muzammil