# Use Lulo

The `Use Lulo` tool, part of AgentiPy, allows users to interact with the Lulo Finance lending and borrowing protocol on Solana. It provides methods to lend assets (specifically USDC in one method, and any SPL token in another) to earn yield, and to withdraw previously lent assets. This tool interacts directly with the Lulo API (which seems to be also referred to as Flexlend).

## Functionality

This tool is implemented in the `LuloManager` class.

### Key Methods:

* `lend_asset(agent: SolanaAgentKit, amount: float) -> str`:
  * Lends a specified `amount` of USDC to Lulo. This method seems to use a Lulo Blink (Solana Action) URL: `https://blink.lulo.fi/actions`.
  * It constructs a payload with the agent's wallet address and makes a POST request.
  * The response contains a serialized transaction which is then signed by the agent's wallet and sent to the Solana network.
  * Returns the transaction signature.
* `lulo_lend(agent: SolanaAgentKit, mint_address: Pubkey, amount: float) -> str`:
  * Lends a specified `amount` of an SPL token (identified by `mint_address`) to Lulo.
  * This method uses the Flexlend API endpoint (`https://api.flexlend.fi/api/v1/deposit`) and requires a Flexlend API key (`agent.FLEXLEND_API_KEY` or `agent.flexland_api_key` - note the typo in the script for the latter).
  * The payload includes the owner's address, mint address, and deposit amount.
  * Similar to `lend_asset`, it processes the transaction returned by the API.
  * Returns the transaction signature.
* `lulo_withdraw(agent: SolanaAgentKit, mint_address: Pubkey, amount: float) -> str`:
  * Withdraws a specified `amount` of a previously lent SPL token (identified by `mint_address`) from Lulo.
  * Uses the Flexlend API endpoint (`https://api.flexlend.fi/api/v1/withdraw`) and requires a Flexlend API key.
  * Parameters and transaction handling are similar to `lulo_lend`.
  * Returns the transaction signature.

##

**Important Considerations:**

* **Direct API Interaction & On-Chain:** This tool interacts directly with Lulo/Flexlend APIs to get transaction details, which are then signed by the agent's wallet and submitted to the Solana blockchain. These are on-chain financial transactions.
* **API Key:** The `lulo_lend` and `lulo_withdraw` methods require a Flexlend API key (`agent.FLEXLEND_API_KEY` or `agent.flexland_api_key`). The `lend_asset` method for USDC might use a more open "blink" endpoint that may not require a user-specific API key.
* **Financial Risks:** Lending assets to DeFi protocols involves risks, including smart contract vulnerabilities and impermanent loss (if the protocol also involves liquidity provision aspects).
* **Token Support:** While `lend_asset` is specific to USDC, `lulo_lend` and `lulo_withdraw` can be used for other SPL tokens supported by Lulo/Flexlend.

## Source Code

You can find the source code for this tool on GitHub: <https://github.com/niceberginc/agentipy/blob/main/agentipy/tools/use_lulo.py>


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.agentipy.fun/tools/use-lulo.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
