Note Scripts
The rules the vault enforces are note scripts. This page lists every script the vault allowlists, read from the chain, and how to check the roots against source.
The scripts the relay uses
| Script | Source | Does |
|---|---|---|
| In-kind deposit v2 | darwin-relay/asm/nav_deposit_inkind_bluechip_v2.masm | Binds the consumer to the vault, checks the sender is the vault's owner, reads Pragma, mints Δ·S/V BLUEDW into the payout note, moves the coins into the vault |
| In-kind redeem v2 | darwin-relay/asm/nav_redeem_inkind_bluechip_v2.masm | Checks the shares are this vault's BLUEDW, releases s·Hᵢ/S of each coin to the recipients in the note, burns the shares. No price, no sender restriction |
| P2ID (standard) | miden-standards | The notes you send and accept |
| PSWAP (standard) | miden-standards | The relay's DEX orders |
The relay logs which scripts it runs at start-up; production reports the v2 deposit and redeem below.
The vault's full allowlist
Read from the vault's allowed_note_scripts storage map on Miden mainnet. Ten roots:
| Root | Script | Status |
|---|---|---|
0x7451d73cb18ed93229bf89a878192fa2e4edef16b5a063f3275a133154dc4950 | In-kind deposit v2 | In use |
0xb79a9db5e3ee5adc9a641329b4e03ace07332a399e1123688b8a7c6be5071537 | In-kind redeem v2 | In use |
0xfe561747b95f9be5337d125ce81c6072ba434b444c096eafba582ee2bbeef34f | In-kind deposit v1 | Launch version, still allowlisted. Owner-only like v2 |
0x2ff1b50cd8f87b53f5e54a6e432753dac033606411374447c08fbef199b9b109 | In-kind redeem v1 | Launch version, still allowlisted. Same pro-rata logic as v2 |
0xfb8052cf499c8923513fe112e2a4812b005738194759903e1aa6cab3f7334ada | P2ID (standard) | A P2ID note to the vault can only add assets to it |
0x1419b08e675d46ee9d93cc01ce23cc33548057de714fb0d48b82b55bcfe2e915 | NetworkAccountConfigNote (standard) | How the owner adds or removes a root |
0x4e63bb63c621ab9b2bf9afd7e27915ec3a70b16573b1d602475282511a7a72a1 | ConstantFeePolicyConfigNote (standard) | How the owner prices a new root |
0x595a98a56dc7bc62047b0fd9af7e81805f30e0320c6c0eca044826d34abe595c | FeeSponsorshipNote (standard) | Network fee sponsorship |
0x72e2097647f429768a8dcf441c247d76f169f7d3c6cf3c8edf273695cd7451ae | seed_note (legacy) | Accepts only sender 0x8bcc83686a22f1117b4f98c790f851, an account that does not exist on mainnet. Only adds assets |
0xef70c003099131c69e57a04c86301b8811d028c2d408daaab1dd3a945a2833bd | set_feed_note (legacy) | Same sender lock. Writes a price slot the in-kind scripts do not read |
What v2 changed
From a security review and an adversarial test run on 5 November 2026:
| Change | Stops |
|---|---|
Checked multiplication for Δ and V | A field-overflow that let a huge, mispriced deposit mint far too many shares |
| Every Pragma price must be non-zero | A zero price dropping a coin out of V and over-minting |
V == 0 while S > 0 reverts | Gifting part of a deposit to existing holders |
| First deposit into an empty vault: at least $10, with 1,000 base units of shares locked forever | The first-depositor share-inflation attack (for a new vault; the live vault already had supply when v2 was allowlisted) |
| Redeem: the sender consuming its own redeem note gets its shares back | Shares stuck in a redeem note the network gave up on |
Unchanged from v1: consumer bound to the vault, sender must be the vault's on-chain owner, only WBTC/ETH/SOL each at most once, Δ == 0 and s == 0 revert, the deposit's own reclaim branch, coins-only V.
The deposit script's checks
| Check | Stops |
|---|---|
Sender must be the vault's on-chain owner (read via ownable2step::get_owner, not a constant) | Anyone depositing coins at a stale or favourable moment |
| Consumer must be the account named in the note's network target | A look-alike account consuming the public note and keeping the coins |
| Only WBTC, ETH, SOL, each at most once | Depositing a worthless token and minting against it |
V counts coins only, not the vault's USDCx fee float | Mispricing shares on a small vault |
| Sender consuming its own note gets every asset back | Coins stuck in a note the vault refused |
Libraries
| Library | Provides |
|---|---|
darwin::math, darwin::math_checked | mul_div with exact 128-bit intermediate; overflow-checked multiplication |
darwin::nav_coins | The coins-only vault value |
darwin::price_oracle | Account procedures: holdings_3 (reads balances), move_out (releases an asset) |
darwin::pragma_fpi | The foreign procedure call into Pragma's oracle and the scale handling |
A note script must not call basic::move_asset_to_note directly: the authentication origin would be wrong. Moving an asset out of the vault goes through price_oracle::move_out, registered as an account procedure.
Verifying a root
A MAST root is a hash of compiled code, so it is reproducible: compile the script from source for Miden mainnet, read the root, compare it with the vault's allowlist. The roots are network-templated (oracle and faucet ids differ between networks).
The scripts are the audit surface, with one caveat
The vault is a network account, so what it can be made to do is what its allowlisted scripts do. The caveat: the vault's owner can add a root to the allowlist, through the standard configuration notes above. That keeps the vault repairable when Miden or Pragma change. It also means the audit surface is "these scripts, plus whatever the owner adds later", and any addition is a public transaction against the vault. An emergency drain script exists in darwin-relay/asm/emergency/, tested, and not allowlisted.