Skip to main content

Five Years of Multiswap

· 13 min read

CavalRe is on a mission to bring all capital markets onchain.

In Multiswap, a portfolio is also a market. Investors supply its assets and own shares in it. Traders exchange assets with the portfolio, with each asset’s reserve available against every other asset in the pool. A single order can sell several holdings and buy several others. The whole rebalance settles together.

This is a convergence of capital markets and capital management. The portfolio’s investments are the market’s inventory, and every trade changes how that capital is allocated. New deposits change how ownership is divided. A pool can itself own shares in another pool, making one portfolio part of the next. Getting the prices, ownership and settlement to agree has been the work of the past five years.

The insight that started Multiswap came in September 2021, while CavalRe’s founder, Eric Forgy, was considering how a decentralized insurance protocol could manage its capital. An automated market maker could potentially put a price on illiquid insurance risk and let investors trade it. Insurance involves payments that depend on future events. Building toward that market meant understanding how to price future payments and, underneath those, assets exchanged today.

He began with the balance sheet of a pool. Its assets back the shares held by its owners. A rebalancing rule determines how the portfolio changes. A trade must be self-financing: the assets entering the pool pay for those leaving it, with equal value on both sides at the prices used to settle the trade. From those financial conditions he derived a family of automated market makers capable of holding many assets. The paper appeared in November 2021. The next task was to make the mathematics execute on a blockchain.1

The first Solidity implementation took shape in February 2022. By April, it could execute a swap on Ethereum’s Ropsten testnet. In May, the interface completed a trade with two assets on each side. For a trader, this meant expressing the desired change to a portfolio as one order. All its parts would settle together, or the transaction would fail as a whole.

By July, a pool on Avalanche’s Fuji testnet held 507 test tokens representing the S&P 500. Each stock had one reserve that could serve trades against any of the others. Adding another asset expanded the set of possible exchanges across the portfolio. The design made the connection between an investment fund and an exchange tangible. Investors could own the portfolio while its holdings supplied trading liquidity.2

During 2023, the work moved from proving that a large basket could trade to making an exchange people could use. The interface showed wallet balances, payment and receipt amounts, price impact and tolerances. The contracts gained more extensive tests and audit fixes. Julia simulations followed the wealth of liquidity providers as outside prices changed and arbitrageurs traded with the pool. The research was already asking what trading did to the people supplying the capital.

The Avalanche mainnet beta opened in September. A testnet transaction had already exchanged 340 tokens at once, but running a market exposed more practical requirements. Bots and aggregators needed reliable ways to request quotes and execute trades. Other contracts needed to use the pool’s shares. The subsequent beta revision added onchain quotes and improved composability, while adapters were developed for ParaSwap and Yield Yak.3

Then a small numerical error changed the direction of the work.

While updating the beta, Eric noticed a numerical approximation error that had survived the tests. He considered proceeding with the release because the discrepancy was tiny, around the fourth or fifth decimal place, and could have been accounted for as trading fees. There was no obvious exploit, but he could not be certain the approximation was harmless.

Investigating further meant tightening the tests and pushing much further into very small and very large trades. Those tests exposed broader limitations in the fixed-decimal arithmetic used throughout DeFi. At the extremes, small amounts could lose precision and large amounts could exceed the arithmetic’s representable range.

Rounding and precision loss had already become recurring attack vectors in DeFi. They contributed to the Hundred Finance and KyberSwap Elastic exploits in 2023, and the precision-loss vulnerability behind Hundred Finance reappeared at Sonne Finance in May 2024. Errors in these calculations could let an attacker take more assets than the protocol’s accounting should permit.4

The founder concluded that fixed-point arithmetic was the wrong foundation for financial modeling. In his assessment, no other DeFi protocol could pass the numerical tests he was putting Multiswap through. Meeting that standard required a floating-point implementation of the model, and Solidity had no native floating-point type.

He built an open-source floating-point library for Solidity that let him test swap quotes for amounts as small as 10−100010^{-1000} and as large as 10100010^{1000} while retaining 18 significant digits of accuracy. Token balances continued to use exact integer units, while the quote calculations used floating-point arithmetic. The library, its tests and the later Python reference model gave CavalRe a way to check the calculation independently of the contract executing it.5

The exchange itself was changing too. During 2024, Stable Multiswap developed a more flexible response to inventory. A pool trading dollar stablecoins needed to fill useful orders with small changes in price. The design allowed portfolio weights to move around targets, giving more favorable prices to trades that moved inventory toward the desired composition. The question was how much trading the available capital could support.

Implementing that model brought a broader reconstruction. Quotes, swaps and liquidity operations became separate contract modules behind a common entry point. Pricing could evolve while the rest of the system retained its responsibilities. By late 2024, the revised contracts were connected to a trading interface, and the code was beginning to represent balances inside a token as distinct subaccounts.6

Those subaccounts became one of the most consequential developments of 2025.

An exchange needs to distinguish the assets available to trade from deposits awaiting allocation, shares held by investors and rewards owed to them. The same token can appear in several of those roles. A single balance says how much exists at an address. Running the financial system also requires knowing whose money it is and what claim or obligation it represents.

Over the course of the year, the subaccounts grew into trees of debit and credit accounts. Token supply became an account in the ledger. The pool’s valuation records moved into it. Staking and reward logic used the hierarchy to identify what belonged to each participant. Deposits, trading reserves and separately supplied inventory could be accounted for within the same structure.

This was the foundation that became Omnibus. A shared vault could hold an external asset while internal accounts recorded the claims on it. Applications could organize those accounts into their own financial relationships. Multiswap would use that foundation to operate an exchange. Accounting software could use it to classify activity and prepare statements.7

Alongside the ledger, the quote engine became capable of solving a basket from either end. A trader could specify how much to spend or how much to receive. By December 2025, the Solidity implementation connected those quotes to execution and the resulting transfers. The portfolio, its pricing and its owners were now represented in an increasingly unified system.8

The 2026 launch work put the lifecycle of capital under closer scrutiny. Contracts had to record who contributed which assets, value those contributions, allocate shares and return funds when a launch was stopped. The Ethereum genesis deposit window ran from June 27 to July 4, accepting ETH, USDC and USDT. It closed with a pro-rata return of deposits. The refund was an actual part of the system’s operation, recorded on Ethereum.9

On testnets, the Global Markets portfolios extended the original idea. A dollar pool could hold stablecoins. An equity pool could hold stocks and shares of the dollar pool as its cash position. An aggregate portfolio could then hold shares of the equity, currency, commodity and dollar pools. A share was both ownership of one portfolio and an asset another portfolio could hold. Each pool retained its own reserves and pricing.10

In August 2026, the pricing mathematics underwent a more fundamental revision. The work addressed a question that reached beyond whether the inputs covered the outputs. A trade changes both the quantities held by the pool and the prices assigned to them. Matching the two sides of an order at its quoted prices is only part of accounting for what happens to the portfolio left behind.

The replacement returned to a choice in the original derivation. Every asset in a trade would settle at the price implied by the pool’s inventory after the entire trade. The new model, post-trade elasticity, specifies how prices respond as reserves change. The quote engine solves all the amounts against that completed state, satisfying the self-financing condition at those final prices.

That rule was developed for swaps, share issuance and redemption. An independent reference model tested whole baskets, split trades, round trips and changes in liquidity. The accompanying mathematics established conditions under which those operations preserve or increase reserve backing per share, valued at the pool’s opening prices, in exact arithmetic. The pricing rule and the ownership rule could now be examined together.11

Practical liquidity still needed testing. Historical simulations compared stablecoin execution with Curve and tracked what repeated trading did to the inventory. A setting that offered attractive quotes could leave the pool short of the asset traders kept buying. That made inventory availability a separate design question alongside the mathematical condition on share backing. The work continued into how to fund a pool for the orders it was expected to serve.12

By autumn, the implementation was moving into Rust. The accounting core was separated from the code that connected it to a particular blockchain. On Solana, the adapter would handle accounts, signatures and external token movement, while the core retained the financial rules.

The port created an opportunity to check whether two implementations actually did the same thing. A replay of 108 Solidity quote and settlement cases against Solana compared amounts, rounding, final balances and rejected transactions. The rejected cases checked that failed operations left the balances intact. Later, Lean proofs checked properties of the extracted Rust accounting functions used to plan transfers and authorize custody operations. Runtime tests exercised the surrounding transaction behavior.13

There was also a separate line of work on execution order. A Commonware-based experiment let validators fix the order of encrypted trades before revealing their contents. It explored how the market’s execution environment could support the financial design. Solana became the immediate deployment target for Omnibus and Multiswap.14

Omnibus reached Solana mainnet on November 13. The next day, CavalRe submitted its Seeker app to the Solana dApp Store. A user could deposit native SOL or supported tokens, organize balances in ledgers, transfer them internally and withdraw them. Years of work on account structures and custody had acquired a direct interface.

Multiswap development continued on Solana devnet, using Omnibus to settle pool operations. By November 18, the funding code could deposit USDC and issue USD.cav shares in one transaction. Making ordinary operations such as creating and funding a pool straightforward is part of the remaining engineering work.15

The insurance question has continued to inform the research. Fixed-income work extends the portfolio across payment dates, so a dollar today and a dollar due next year can trade as distinct instruments. A Python simulator follows those claims through trading, maturity and funded redemption. Prediction-market research examines claims that pay when an outcome occurs. These remain research extensions, with their own questions about funding, pricing and settlement.

The next market will have to use those pieces together. An investor should be able to supply capital, own a clearly defined claim on it and trade that claim under rules that account for the resulting obligations. Extending that ability from assets held today to payments due in the future, including payments contingent on insured events, is how the work connects back to CavalRe’s mission.

Footnotes​

  1. The September 2021 insight and initial development are recorded in Reinventing Myself. The paper, A Family of Multi-Asset Automated Market Makers, was submitted on November 15, 2021. ↩

  2. The April and May transactions and July 2022 pool are documented in the original development account. ↩

  3. Avalanche documented the 340-token testnet trade. The code history records onchain quotes, the ParaSwap adapter and the Yield Yak adapter. ↩

  4. The protocol teams documented rounding errors in the Hundred Finance post-mortem and the KyberSwap Elastic post-mortem. CertiK’s Sonne Finance incident analysis describes the recurrence of the precision-loss vulnerability. ↩

  5. The founder described the error, expanded tests, numerical range and library in Mathematical Modeling with Floating Point Numbers in Solidity, published in May 2024. ↩

  6. The June 2024 contracts implemented target-weight receive quotes. ERC-20 subaccounts followed in November. ↩

  7. The ledger development includes debit and credit handling and token supply represented as an account. ↩

  8. December 2025 commits implement exact-output basket quotes and swap execution. ↩

  9. The deposit phase was described in The First Multiswap Market Is Live. The refund transaction records the return of funds. ↩

  10. The July 2026 hierarchy deployment scripts implement the Global Markets structure. Composable Pools explains the ownership relationships. ↩

  11. The August 2026 reference model and Solidity pricing revision record the change to post-trade elasticity. ↩

  12. The September 2026 historical comparison scripts examine quotes and inventory through time. ↩

  13. The Solidity-to-Solana replay records 66 successful cases and 42 rejected cases. The Omnibus proof documentation specifies the scope of the Lean results. ↩

  14. The experimental execution work is recorded in the Commonware integration and subsequent Multimmit implementation. ↩

  15. The code includes the mainnet deployer, native SOL custody and atomic USD.cav funding. ↩