Basic Blueprint
The Basic Blueprint is a pre-designed template that helps you quickly build a basic version of an Agent, which can then be customized as needed.
Overview of the Basic Blueprint
Core Features of the Basic Blueprint:
Withdraw Operation: Allows the Agent owner to withdraw specified assets from the Agent.
Take Order Settlement: Enables acquiring specific notes from the FFP system, validating their validity, and submitting them for settlement.
Settlement Completion Notification: Monitors settlement notifications from the FFP settlement center and updates the notes and settlement status accordingly.
Code Structure of the Basic Blueprint
Below is an outline of the basic.lua file:
Code Explanation
1. Withdraw Operation
This function allows the Agent's owner to withdraw specified assets from the Agent.
Typical Scenarios:
The Agent owner withdraws profits.
Periodically clearing out remaining assets in the Agent.
2. Take Order and Settle
This function enables the Agent to fetch a specific set of notes (Notes) from the FFP protocol, validate them, and submit them to the FFP protocol to create Settlement orders.
Key Code Logic:
Validate the notes (e.g., status, source, expiration date).
Call the StartSettle interface in the FFP protocol to generate settlement orders.
Execute settlement order logic (e.g., funds transfer).
3. Settlement Completion Notification
This function listens for settlement completion notifications sent by the FFP protocol and updates the status of notes and settlement orders.
Main Purpose: To ensure that the status of notes and settlement orders saved by the Agent remains consistent with the status in the FFP protocol.
Full Code
How to Build a Custom FFP Agent Based on the Blueprint
1. Clone the Blueprint
Copy the basic.lua and utils.lua code into your development environment.
2. Add Custom Logic
Generally, there’s no need to modify the core functionality already implemented in basic.lua. Simply add additional functionality based on your specific business requirements.
For example, you can build a lossless arbitrage Agent within the FFP protocol.
Summary
The Basic Blueprint is the standard template for building FFP Agents. All FFP Agents are built on this foundation and extended with additional features to meet specific business needs. Through customized Agents, developers can easily integrate into the FusionFi protocol ecosystem and participate in various financial activities.
Last updated
Was this helpful?