Plugin Integration
This guide will walk you through the process of integrating your project with Curvance's plugin architecture, allowing your application to interact with Curvance's smart contracts on behalf of users.
Understanding Plugin Delegation
Curvance's plugin system enables third-party applications to perform actions on behalf of users through a secure delegation mechanism. This allows for innovative features like:
Automated portfolio management.
Advanced trading strategies.
Cross-chain operations.
Reward auto-compounding.
Sequential action chaining.
Code Examples
Before your application can act on behalf of users, they must explicitly authorize your contract address as a delegate. This is the critical first step in the integration process.
Enabling Delegation with setDelegateApproval()
Users need to call the setDelegateApproval() function on the appropriate Curvance contract.
Calling setDelegateApproval() is called correctly with these arguments:
address
delegate
The address of your platform's contract.
bool
isApproved
To activate delegation of your platform, this would be true.
Below is an example showing how to implement this using Ethers.js 5.7 for a position that uses PositionManagementSimple (such as pwstETH):
Verification and Security Best Practices
When implementing delegation in your application:
Verify delegation status: Always check if your contract is still approved as a delegate before attempting actions by calling
isDelegate()in the CentralRegistry contract using the following parameters:
address
user
The user's address.
address
delegate
Your platform's contract address.
Handle revocation: Users can revoke delegation at any time, so design your application to gracefully handle this case.
Transparent permissions: Clearly communicate to users which actions your application will perform on their behalf.
Gas optimization: Consider batching multiple delegated actions when possible to reduce gas costs.
Next Steps
After implementing the delegation setup, your application should:
Verify the delegation was successful.
Store the user's delegation status in your application state.
Implement the specific delegated actions your application needs.
Provide a way for users to revoke delegation if desired.
For technical support or to get your plugin featured in Curvance's ecosystem, please contact our developer relations team.
Last updated