Portfolio Deposit
A guide to depositing assets into a portfolio
This guide explains how to deposit assets into a Glider portfolio.
Overview
Depositing assets into your portfolio is necessary before you can start using Glider’s automated rebalancing features. Depositing funds involves:
- Getting deposit instructions from the Glider API
- Creating a transaction with these instructions
- Having the user sign and send the transaction
Deposit Process
1. Get Deposit Instructions
First, request deposit instructions from the API:
For ERC-20 tokens, replace the token address with the token’s contract address:
2. Create and Send the Transaction
The response will include transaction data that you can use to create a transaction for the user to sign:
Use this data to create and send a transaction:
3. Verify the Deposit
After the transaction is confirmed, you can verify the deposit by retrieving the portfolio details:
Handling ERC-20 Token Approvals
For ERC-20 tokens, users need to approve the portfolio vault to spend their tokens first. The deposit endpoint handles this for you:
- If the user hasn’t approved the tokens yet, the deposit endpoint will return approval transaction data
- After the approval transaction is confirmed, you need to call the deposit endpoint again to get the deposit transaction data
Best Practices
- Validate inputs: Ensure the token address and amount are valid before sending the request
- Handle network errors: Implement retry logic for network failures
- Verify gas costs: For large deposits, consider using the
simulate: true
parameter to estimate gas costs - Inform users: Display a loading state during transaction confirmation
- Verify balances: Check that the user has sufficient balance before attempting the deposit
Next Steps
After depositing assets, you can:
- Start portfolio automation to enable automatic rebalancing
- Update the portfolio if you want to change its configuration
- Monitor the portfolio’s performance to track its growth