This article describes how the DeFi API process works in general. To see detailed guides for a specific protocol, refer to the Protocols Supported section.
transactions/steps/craft method serving as the primary interface for transaction creation—handling approximately 95% of operations. The data part with endpoints for getting details on earnings, positions, and rewards is also provided.
Action types
Currently, each vault integration supports the following operations:approvePermit2: Allow the P2P.ORG smart contract to manage tokens by obtaining approval.deposit: Initiate a deposit transaction to delegate the assets.withdraw: Withdraw the assets to the wallet.
General flow
- Get a schema with the step list. To retrieve a schema describing which transactions are required for a specified action, protocol, chain, and strategy, send a GET request to /api/defi/v1/transactions/schema.
- Upon the schema retrieved, construct the required transactions. Depending on the action type and the request data, a schema may include up to 3 transactions. To initiate the constructing process, send a POST request to /api/defi/v1/transactions/steps/craft. Upon each request, a raw unsigned transaction is generated.
- Sign each transaction using the transaction-type-specific libraries.
- Check the status of the constructed transaction by using the /api/defi/v1/transactions/steps/result endpoint. If the schema contains several transactions, for intermediate transactions, you may use a /api/defi/v1/transactions/steps/status endpoint.
- Broadcast the final transaction to the network by sending a POST request to /api/defi/v1/transactions/broadcast.