> For the complete documentation index, see [llms.txt](https://docs.maple.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.maple.finance/technical-resources/sdk/protocol-actors.md).

# Protocol Actors: Maple SDK Reference

## Protocol Actors

There are three actors in the Maple Protocol ecosystem:

* Borrowers
* Lenders
* Pool Delegates

## Borrowers

* Borrowers initiate loan requests by specifying terms and providing collateral if required.
* Borrowers draw down loans after they are approved and funded.
* Borrowers repay principal and interest through associated smart contracts.

**Code Example:** This snippet queries the [`GlobalsV2`](https://maplefinance.gitbook.io/maple/technical-resources/protocol-overview/smart-contract-architecture#maple-globals) contract to check if a given address is an authorized borrower

```js
import { providers } from 'ethers';
import { addresses, mapleGlobalsV2 } from '@maplelabs/maple-js';

const RPC_ENDPOINT = 'https://mainnet.infura.io/v3/{YOUR_KEY}';

async function main() {
  const contract = mapleGlobalsV2.core.connect(
    addresses['mainnet-prod'].MapleGlobalsV2,
    new providers.JsonRpcProvider(RPC_ENDPOINT)
  );

  const isBorrower = await contract.isBorrower('YOUR_ADDRESS');
  console.log({ isBorrower });
}

main();
```

## Lenders

* Lenders deposit specific assets into designated pools.
* Lenders accumulate interest on deposits as borrowers repay loans.
* Lenders withdraw assets from pools using the `WithdrawalManager` contract.

**Code Example:**

```js
import { BigNumber, providers } from 'ethers';
import { addresses, poolV2, erc20 } from '@maplelabs/maple-js';

const RPC_ENDPOINT = 'https://mainnet.infura.io/v3/{YOUR_KEY}';
const POOL_ADDRESS = '{POOL_ID}';

async function main() {
  const provider = new providers.JsonRpcProvider(RPC_ENDPOINT);

  const poolContract = poolV2.core.connect(POOL_ADDRESS, provider.getSigner());
  const usdcContract = erc20.core.connect(addresses['mainnet-prod'].USDC, provider.getSigner());

  const account = '{YOUR_ACCOUNT}';
  const oneDollar = BigNumber.from(1000000);

  await (await usdcContract.approve(POOL_ADDRESS, oneDollar)).wait();

  await (await poolContract.deposit(oneDollar, account)).wait();
}

main();
```

## Delegates

* Delegates evaluate and approve/fund loan requests based on criteria specific to each pool.
* Delegates accept or reject refinance proposals.
* Delegates manage various pool utilities, such as adjusting the liquidity cap or authorizing certain lenders.

**Code Example:** This snippet queries the `poolV2` contract to query the on-chain name of a given pool

```js
import { providers } from 'ethers';
import { poolV2 } from '@maplelabs/maple-js';

const RPC_ENDPOINT = 'https://mainnet.infura.io/v3/{YOUR_KEY}';

async function main() {
  const contract = poolV2.core.connect('{POOL_ID}', new providers.JsonRpcProvider(RPC_ENDPOINT));

  const name = await contract.name();
  console.log({ name });
}

main();
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.maple.finance/technical-resources/sdk/protocol-actors.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
