Trading and Earn
Borrow against collateral and repay a DeFi loan
Select the lending market for your collateral and debt assets, check the wallet’s borrowing capacity, then reconcile repayment and collateral release.
Workflow
Identify the collateral and debt separately
Use earnPaths to find the available lending workflows, then inspect the live reserve or isolated market on the intended network. For Morpho Blue, save the market ID, collateral token, loan token and loan-to-value limit. Read the wallet’s collateral and outstanding debt before sizing the borrow. A lender’s supply balance is a different position from posted borrowing collateral.
Prepare the collateral and borrow legs
On Morpho Blue, supplyCollateral posts the collateral and borrow draws the loan token. Confirm any required token allowance before rebuilding the next action. A supported borrowBundle combines specific steps and requires a maximum loan-to-value bound. On SparkLend, inspect the reserve and the account’s enabled collateral before preparing borrow. Use the matching adapter and keep its precision and approval requirements.
Reconcile repayment before releasing collateral
Check the current debt in the loan asset and whether an allowance is needed. Morpho Blue’s full repayment uses the current borrow shares; a partial repayment uses an asset amount. After confirmation, re-read remaining debt and collateral. Withdraw only the releasable collateral. A confirmed approval or completed partial repayment can still leave a live loan.
Send the authorized transaction
Use the supported action with executionPrepare in the same workspace. Review the returned signing payload. On the wallet host use bitpont_walletExecute, or sign locally and send executionSubmit. Save the executionId to follow settlement and recover after a timeout.
Find supported Earn workflows and their next tools
curl -fsS "https://www.bitpont.com/api/v1/agent/earn/paths" \
-H 'Content-Type: application/json' \
-d '{"limit":5}'