Permaswap recently released an AgentFi demo case based on FusionFi Protocol (FFP) on AO, adding a case of creating an automated market maker agent (AMM Agent) and performing arbitrage operations. Through FFP, developers can create AMM agent pools with just a few lines of code to achieve asset exchange. As a standardized protocol on the AO network, FFP provides interoperability support for different types of Agents.
This article will first clarify core concepts such as AgentFi and sovereign finance, then introduce two typical Agent examples - Orderbook Agent and AMM Agent. It will demonstrate how the FFP protocol integrates two different trading processes. Finally, we will explain the key role that FFP can play in the future financial ecosystems.
AgentFi introduces the concept of "agents" on top of DeFi, allowing users to deploy their own smart contract agents to automatically manage interactions with protocols. Through Agent, users can autonomously execute various financial operations, such as asset management and strategy execution.
Traditional DeFi protocols use smart contracts to implement operations like asset exchange and lending, but these assets are usually locked in a single smart contract. This requires users to entrust their funds to the contract and also limits their flexibility in customizing desired functions and parameters. AgentFi breaks through this limitation. It enables each user to have an independent agent with financial capabilities, then the users can use their agents to conduct personalized financial business. In other words, AgentFi makes users' agents independent financial entities, allowing individuals to set financial rules, such as asset exchange, lending, and asset issuance rules. It helps achieve personalized financial management and break through the limitations of traditional centralization.
This is Sovereign Finance!
Unlike traditional centralized systems where financial rules are controlled by central banks, sovereign finance allows users to establish and control financial rules themselves. They no longer need to rely on smart contracts provided by developers or centralized institutions.
One of the reasons why traditional DeFi protocols centrally manage funds is due to the limitations of Ethereum's performance: it cannot provide independent agent’s computing power for each user. Therefore, platforms like Compound and Uniswap have optimized their code to accommodate the limitations of the blockchain. Additionally, traditional blockchain smart contracts have low flexibility and are difficult to modify or redeploy, which limits the agents’ computational flexibility.
AO, as a decentralized global hyper parallel computer, provides independent computing units (called processes). Each process has its own computing resources, which helps resolve the performance bottleneck. Meanwhile, the smart contract code running in the processes is controlled by the process owners and can be flexibly updated and upgraded, providing a solid foundation for the flexibility of AgentFi.
In AO's decentralized network, AgentFi will be widely adopted. Applications can generate multiple independent financial entities. For example, NPCs in games not only provide gaming services but also financial services. For instance, a pawnshop NPC can accept players' NFTs as collateral and provide lending services, making this NPC an independent Agent, i.e., a sovereign financial entity. All users and processes on AO can create financial agents in this way, and any computing unit can become a "financial institution" providing customized financial services.
If different types of financial agents develop independently, they will inevitably produce different protocol standards, making interaction between agents a major challenge. To address the interoperability issues caused by business differences, the FusionFi Protocol (FFP) was born.
FusionFi Protocol is a specification and development tool designed to connect different financial agents, establish information channels, achieve interoperability, and integrate diverse financial operations. It enables FFP-compatible Agents to interconnect and communicate.
For users who are not interested in delving into financial details, they can also use the FFP SDK to convert their agents into agents with specific financial features. By reducing the implementation difficulty of AgentFi, FFP makes sovereign finance accessible to everyone.
Order Book and AMM (Automated Market Maker) are two different trading mechanisms with significant differences in their trading processes. Order Book records all buy and sell intentions, and trades can only be executed when the prices of buyers and sellers match, thus relying on the participation of counterparties. AMM, on the other hand, does not rely on counterparties. It allows users to trade directly with assets in the pool through liquidity pools and algorithms. Liquidity providers deposit funds into the pool, and AMM uses algorithms (such as constant product formula) to automatically adjust prices, enabling users to complete transactions without waiting for matching.
FFP can handle Orderbook and AMM transactions in a unified manner and process, thereby integrating the liquidity of both.
Please refer to the demo code: https://github.com/permadao/ffp-demo
In the orderbook demo of FFP, developers can create an Orderbook Agent and conduct asset trading:
Create Orderbook Agent: Use the createOrderbookProcess
function to create an orderbook agent process, which deploys an AO process and loads “orderbook” related business code, making it an independent financial entity responsible for recording and managing orders.
Deposit assets: Use the deposit.js
script to deposit tokens into the orderbook agent to provide trading funds for orders.
Create orders: Use the agent.makeOrder
method to create buy or sell orders in the orderbook. All orders are sent to the AO network in a specific FFP Schema, after which the orders will be transparently displayed in a specific format on the blockchain network and await matching.
Take orders: Use the agent.takeOrder
method to take orders, and the system automatically completes the transaction and updates the asset balance.
In the demo of AMM Agent, the Agent created by the user is equivalent to a personal sovereign liquidity pool. Through AgentFi, users can autonomously provide asset exchange functions without relying on centralized platforms or traditional exchanges. The following is the core process of AMM Agent:
Create AMM Agent: Create an AMM Agent process through the createAMMProcess
function, and deploy it as a user-controlled AO process, making it a sovereign financial entity with liquidity management capabilities.
Deposit Assets: Users deposit tokens into the AMM Agent, injecting funds into the liquidity pool.
Add Liquidity: By calling the agent.addLiquidity
method, the deposited assets can be added to the liquidity pool, and users can set the pricing and exchange ratio of the assets in the pool through smart contracts.
Automatic Exchange: The AMM Agent uses algorithms (such as the constant product formula) to automatically calculate the exchange rate. The quote results are returned to the user requesting the transaction in a specific FFP Schema.
Remove Liquidity: When users want to withdraw funds, they can use the agent.removeLiquidity
method to remove liquidity from the pool and withdraw assets.
By creating an AMM Agent, users have full autonomy over liquidity management and can provide asset exchange services without counterparties, thereby establishing a personalized decentralized trading system.
It can be considered that when a user creates an Agent (whether an AMM Agent or an Orderbook Agent), they are essentially creating a personal sovereign decentralized exchange. AgentFi completely breaks the traditional boundaries of exchanges, it allows users to trade without relying on a specific platform. By setting up Agents with specific functions and smart contract rules, users can autonomously provide a "venue" for exchanges, and achieve sovereign financial services. All it takes is just one line of code to create an agent.
FFP Schema is a data format used in FusionFi Protocol (FFP) for standardizing transaction and settlement data. It defines the data format and communication protocol in different trading processes (such as Orderbook and AMM), ensuring smooth interoperability and compatibility between different types of financial agents. This unified data format allows key info such as prices, order status, and asset information to be shared and parsed among various agents during the trading process.
In the fourth step of the Orderbook Agent and AMM Agent, both Orderbook orders and AMM requests adopt a unified FFP Schema to achieve a consistent settlement data format. The FFP Schema standardizes cross-agent interoperability:
Arbitrageurs can directly query Orderbook orders on-chain, comparing quotes between Orderbook and AMM using the FFP Schema to discover price differences.
Arbitrageurs only need to submit uniformly formatted transaction data to the FFP settlement process to achieve atomic transactions across Agents. The FFP specification ensures that multiple hedging orders are either all completed or all failed, avoiding the risk of transaction inconsistency.
In the above use cases, the different trading processes of Orderbook and AMM achieve interoperability. FFP breaks the boundaries between the two types of businesses, achieving collaboration and integration between them.
FFP supports atomic settlement of multiple transactions and provides the following advanced features for DEXs built on FFP:
Large Order Splitting: Traders can split large orders into multiple smaller orders. For example, a trader needs to complete a $1 million transaction, but a single Agent may find it difficult to provide the best quote. FFP allows large orders to be split into multiple smaller ones, executed among different Agents to obtain the best quotes in the network.
Multiple Orders Merging: Scattered orders in the market can be merged into a single atomic order, enhancing the interoperability of the Orderbook and AMM, and making transactions more flexible.
Multi-hop Trading: Multi-hop trading is an extended application of the merging function. For example, if a trader wants to exchange asset A for C, but there is no A-C trading pair in the market, yet there are A-B and B-C trading pairs, FFP can merge the A-B and B-C transactions into one order to achieve the trading goal.
Zero-Capital Arbitrage: Arbitrageurs can profit from the price difference between two hedging orders in the market. Unlike traditional arbitrage methods, FFP's zero-capital arbitrage doesn't require self-owned funds. Arbitrageurs only need to submit the two orders to the settlement process, and the system will automatically complete the asset exchange and distribute the profit to the arbitrageur.
These innovative features brought by FFP not only simplify the trading experience for users and ensure optimal quotes, but also improve capital efficiency for arbitrageurs and guarantee the efficient circulation of value.
In summary, FFP provides a unified framework for financial agents, breaking down barriers between different financial scenarios. Not only for orderbooks and AMM, but various financial operations such as lending, futures, and synthetic assets can also be seamlessly integrated in the future through FFP. It will help build a cross-application, cross-scenario decentralized financial ecosystem.
Through a unified data format (FFP Schema), FFP simplifies communication and settlement between agents, thus enhancing the flexibility and efficiency of transactions. As more types of financial agents emerge, FFP has the potential to become the core protocol for the AgentFi ecosystem on AO, promoting the popularization of truly sovereign finance and personalized financial services.