ObscuraFinance

Inspiration

DeFi promised financial freedom, but it delivered a glass box. Every deposit you make, every reward you claim, every wallet interaction is permanently public on most chains. For retail users that's uncomfortable; for serious participants managing real capital, it's a genuine risk.

We wanted to build a yield platform where privacy isn't a feature you pay extra for, it's the default. Midnight Network's ZK-privacy model made that possible in a way EVM chains simply can't match.

What we built

ObscuraFinance is a multi-vault yield platform on Midnight Network. Users deposit into risk-segmented vaults (Low / Medium / High), earn OBSCURA token rewards, and every critical action, deposit, withdrawal, reward claim, is verified by a ZK-SNARK proof. Your participation is private on-chain, with selective disclosure when you need it.

The platform has three layers:

  • Compact smart contracts: ObscuraVault for vault lifecycle, OBSCURA as the mintable reward token
  • Owner tooling: TypeScript scripts for deployment and vault management
  • Next.js frontend: role-aware UI with separate pages for Vaults, Profile, Admin, and Analytics

How we built it

We wrote two Compact contracts compiled to ZK circuits. The vault contract handles multi-vault storage, deposit/withdraw/claim circuits, APY configuration, and vault lifecycle controls. The token contract is a mintable FungibleToken for OBSCURA rewards.

The frontend is a Next.js app built around a single useObscuraVault hook that wraps the Midnight.js SDK. Contract discovery uses a NeonDB registry so any wallet can find deployed contracts without hardcoding addresses. The 1AM browser wallet handles proving, fee sponsorship, and DUST, no CLI required for end users.

Yield accrues as:

$$\text{reward} = \text{principal} \times \frac{\text{APY}}{10000} \times \frac{\Delta t}{365 \times 86400}$$

where APY is stored in basis points and $\Delta t$ is elapsed time in seconds.

Challenges

Compact is not Solidity. The ZK compilation model requires thinking about circuit constraints from the start, you can't just write logic and assume it'll prove. We had to restructure several contract functions to stay within provable bounds.

Guaranteed vs. fallible transaction phases. Midnight separates transaction execution into phases where partial success is possible. Getting the frontend to handle this gracefully — without leaving users confused about their vault state, took significant iteration.

Browser-native proving. Offloading ZK proof generation to the 1AM wallet in-browser is powerful, but debugging proving failures during development required careful coordination between contract logic and wallet behavior.

What we learned

  • Midnight's privacy model is genuinely different from ZK rollups, it's not about scaling, it's about selective disclosure at the application layer
  • Compact contract design requires a different mental model than EVM development: think in circuits, not functions
  • Browser-native proving via 1AM is a real UX unlock, removing the CLI barrier makes ZK DeFi accessible to normal users

What's next

  • Mainnet deployment via 1AM
  • Multi-token vault support beyond tNIGHT
  • On-chain governance for APY band updates
  • Private yield strategies with verifiable allocation proofs

Built With

Share this project:

Updates