Custodian Capabilities and Standalone Swaps

How Econia v2 Takes DeFi Composability to the Next Level

Econia Labs
Econia Labs
4 min readAug 8, 2022

--

When Econia Labs published its most recent article, “Introducing Econia’s Atomic Matching Engine: A Breakthrough in On-Chain Trading,” it had just released Econia v1 on the Aptos devnet, marking the historic rollout of the Aptos blockchain’s first fully-functioning on-chain order book. Complete with a revolutionary atomic matching engine that settles market orders during the transaction in which they are placed, Econia set the standard for a new era of decentralized finance (DeFi). And as of last week, Econia Labs has raised the bar once more, because Econia v2 just shipped the holy grail of DeFi composability.

Delegated custody

In Econia v1, users were restricted to placing or canceling trades, depositing or withdrawing funds, during transactions that included their digital signature (e.g. express permission). But users are no longer required to sign such digital transactions again, and again, and again, whenever they want to place a trade because Econia v2 allows them to simply delegate custody of their account to a registered custodian, who then has authority to manage collateral and orders on their behalf. With such access restricted to specific market accounts for which users must first approve delegated custody, custodians are limited to managing only select portions of any given user’s trading activity.

This new user-centric delegated custody paradigm is made possible by Move, an innovative new programming language that runs on the Aptos blockchain, through the use of a novel “capability” paradigm: After a custodian has registered with a unique custodian ID, any user can open up a market-specific trading account that lists the custodian’s ID and thereby grants access control to the holder of the corresponding capability. For instance, a user can open up a market account trading asset A denominated in B for which they must sign every transaction, a separate market account for C/D where only custodian 8 can approve trades, and a separate E/F market account where only custodian 25 is granted access. Here, the user is restricted to trading on the A/B account, custodian 8 is restricted to the C/D account, and custodian 25 to the E/F account.

This novel custodian architecture was designed in collaboration with Aries Markets, a margin trading platform currently building on top of Econia, with platforms like Aries having the unique requirement of being able to withdraw collateral from users’ trading accounts during liquidation events. Returning borrowed funds to the lenders that enabled such leverage in the first place, Aries Markets integrates its own borrow/lending pools with Econia’s order book in a modular way, providing the guarantees necessary to connect lenders, borrowers, buyers, and sellers in a robust marketplace. But margin trading is not the only use case for delegated custody.

With the emergence of cross-chain messaging protocols, for instance, it is now even possible to place a trade on Econia from another blockchain, once custody has been delegated to the corresponding cross-chain intermediary. Moreover, since Econia settles market orders during the transaction in which they are placed, custodians can now string together delegated trades back-to-back, managing funds for entire user bases all at once. There is no limit to the kind of composable financial applications enabled through Econia’s delegated custody, and now it is up to the Aptos developer community to push the limits of such extensibility.

Standalone swaps

But that is not all. Econia v2 introduces another new feature that unlocks even more composability: Standalone order book swaps. Unlike account-based market sells and buys, which require users to register a market-specific trading account, optionally delegate a custodian, deposit collateral, and place a trade in the corresponding market using their collateral, Econia v2 now allows users to settle market orders directly against the book, without any overhead.

What’s more, these standalone swaps do not even require a user, since they operate through a public function call that simply takes in one asset and outputs another. Like an open-source software library without any restrictions on who gets to use it, Econia’s standalone swap interface can be called by any other decentralized application in the Aptos blockchain, and here again the possibilities are endless. Multiple order book swaps can be chained together, the outputs sent across protocols, without ever having to register a trading account, all within a single transaction.

The Econia ecosystem takes off

Hippo Labs, an Aptos-native group currently building out a trading aggregator, has already included Econia-powered swaps in its user-friendly front-end, and Hippo’s open source contributions to Econia are helping other groups do the same. Martian Wallet, for example, another Aptos-native project, is leveraging the integration support made possible by Hippo’s tooling to incorporate Econia-powered swaps into its sleek wallet interface too. Both Hippo Labs and Martian Wallet have worked with Econia Labs to plan out new useful features, ranging from off-chain order book indexing to swap simulation implementations, and both projects are reaping the benefits of helping to build the protocol in their image. By developers, for developers, and with developer feedback, the Econia integration layer is picking up momentum and more projects are getting on board.

From building fully-fledged hybrid exchanges on top of Econia, to simply exploring integrations and providing thoughtful feedback, additional Aptos-native groups, including Pontem Network, are contributing in their own way to the emerging Econia ecosystem, and there is so much more to come. As rich front-ends spring up and developer interest continues to snowball, Econia is set to provide the core back-end infrastructure necessary for a thriving DeFi ecosystem on Aptos, which grows in complexity and scope daily.

Econia Labs is not done building, though, and Econia v3 is already underway.

Links from above, in order of mention

Econia Labs’ last article: https://medium.com/econialabs/introducing-econias-atomic-matching-engine-a337924b560f

Aptos Labs: https://aptoslabs.com/

Move: https://move-language.github.io/move/

Aries Markets: https://ariesmarkets.xyz/

Hippo Labs: https://hippo.space

Martian Wallet: https://martianwallet.xyz/

Pontem Network: https://pontem.network/

--

--