Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions typescript/.changeset/basedloans-action-provider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@coinbase/agentkit": patch
---

Added the Based Loans action provider: borrow USDC against Base tokens with no liquidations, buy collateral back, and lend USDC against chosen tokens.
61 changes: 61 additions & 0 deletions typescript/agentkit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,67 @@ const agent = createAgent({
</table>
</details>
<details>
<summary><strong>Based Loans</strong></summary>
<table width="100%">
<tr>
<td width="200"><code>get_protocol_info</code></td>
<td width="768">Gets Based Loans' live loan fee, loan terms, buyback costs and size limits.</td>
</tr>
<tr>
<td width="200"><code>list_markets</code></td>
<td width="768">Lists tokens accepted as collateral with price, max loan-to-value and USDC available to borrow.</td>
</tr>
<tr>
<td width="200"><code>get_risk_report</code></td>
<td width="768">Gets a token's price sources, pool history and the trading needed to move its price, with plain-language flags.</td>
</tr>
<tr>
<td width="200"><code>quote_borrow</code></td>
<td width="768">Quotes the USDC received, fixed buyback cost and due date for a loan, without sending anything.</td>
</tr>
<tr>
<td width="200"><code>get_my_loans</code></td>
<td width="768">Lists the wallet's loans with status, buyback remaining and due date.</td>
</tr>
<tr>
<td width="200"><code>get_my_lending</code></td>
<td width="768">Gets the wallet's deposit, USDC in active loans, per-token limits and anything ready to claim.</td>
</tr>
<tr>
<td width="200"><code>request_token_listing</code></td>
<td width="768">Checks whether a token is accepted and, if not, returns a link to request it.</td>
</tr>
<tr>
<td width="200"><code>borrow</code></td>
<td width="768">Deposits a token as collateral and receives USDC, with no liquidations, approving the token first if needed.</td>
</tr>
<tr>
<td width="200"><code>buyback</code></td>
<td width="768">Pays USDC on a loan to get collateral back, in full or in part.</td>
</tr>
<tr>
<td width="200"><code>lend</code></td>
<td width="768">Deposits USDC to lend, optionally setting per-token lending limits.</td>
</tr>
<tr>
<td width="200"><code>set_lending_limits</code></td>
<td width="768">Adds, changes or removes per-token lending limits.</td>
</tr>
<tr>
<td width="200"><code>withdraw</code></td>
<td width="768">Withdraws USDC that is not in active loans.</td>
</tr>
<tr>
<td width="200"><code>claim_proceeds</code></td>
<td width="768">Claims repaid USDC from funded loans, or puts it back into lending.</td>
</tr>
<tr>
<td width="200"><code>claim_collateral</code></td>
<td width="768">Claims collateral from funded loans that passed their due date without a buyback.</td>
</tr>
</table>
</details>
<details>
<summary><strong>Basename</strong></summary>
<table width="100%">
<tr>
Expand Down
1 change: 1 addition & 0 deletions typescript/agentkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@across-protocol/app-sdk": "^0.2.0",
"@alloralabs/allora-sdk": "^0.1.0",
"@base-org/account": "^2.2.0",
"@basedloans/sdk": "^0.1.1",
"@coinbase/cdp-sdk": "^1.45.0",
"@dtelecom/x402-client": "^0.1.3",
"@ensofinance/sdk": "^2.0.6",
Expand Down
54 changes: 54 additions & 0 deletions typescript/agentkit/src/action-providers/basedloans/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Based Loans Action Provider

This provider integrates [Based Loans](https://based.loans) into AgentKit. Based Loans is a fixed-term lending protocol on Base with no liquidations.

- **Borrowers** deposit a token as collateral and receive USDC right away. They can buy the collateral back at a fixed price any time before the due date. If they don't, they keep the USDC and the lenders receive the collateral. Price moves during the loan never sell the collateral early.
- **Lenders** deposit USDC and choose which tokens they lend against, with a USDC limit per token. They earn the buyback cost when borrowers repay, or the collateral when they don't.

The provider wraps the [`@basedloans/sdk`](https://www.npmjs.com/package/@basedloans/sdk) package. Every number is read live from Base mainnet, and contract addresses are read from the protocol at runtime. Write actions are signed by the agent's own wallet; the SDK never holds keys.

## Setup

No API key is needed. By default the SDK reads from Base's public RPC; pass your own for production use.

```typescript
import { AgentKit, basedLoansActionProvider } from "@coinbase/agentkit";

const agentkit = await AgentKit.from({
walletProvider,
actionProviders: [basedLoansActionProvider({ rpcUrl: process.env.BASE_RPC_URL })],
});
```

## Actions

| Action | Description |
| --- | --- |
| `get_protocol_info` | Live loan fee, loan terms, buyback costs and size limits |
| `list_markets` | Tokens accepted as collateral, with price, max loan-to-value and USDC available |
| `get_risk_report` | A token's price sources, pool history and cost to move its price, with plain-language flags |
| `quote_borrow` | USDC received, fixed buyback cost and due date for a loan, without sending anything |
| `get_my_loans` | The wallet's loans with status, buyback remaining and due date |
| `get_my_lending` | The wallet's deposit, active loans, per-token limits and claimables |
| `request_token_listing` | Whether a token is accepted, and a link to request it if not |
| `borrow` | Deposit collateral and receive USDC (approves the token first if needed) |
| `buyback` | Pay USDC to get collateral back, in full or in part |
| `lend` | Deposit USDC to lend, optionally setting per-token limits |
| `set_lending_limits` | Add, change or remove per-token lending limits |
| `withdraw` | Withdraw USDC that is not in active loans |
| `claim_proceeds` | Claim repaid USDC from funded loans, or re-lend it |
| `claim_collateral` | Claim collateral from funded loans that passed their due date without a buyback |

Tokens can be passed by contract address (preferred) or symbol. Amounts are decimal strings in whole token units, e.g. `"0.5"` WETH or `"500"` USDC.

## Notes

- Supported network: `base-mainnet`.
- Agents should run `quote_borrow` and confirm the buyback cost and due date with the user before `borrow`, and run `get_risk_report` on each token before lending against it.
- `borrow` refuses loans the contracts would reject (for example below the minimum loan size) and explains why instead of sending a transaction.

## Links

- [Based Loans](https://based.loans)
- [Docs for AI agents](https://docs.based.loans/ai-agents)
- [SDK source](https://github.com/0xVarius/basedloans-agents)
Loading