Stake with Jupiter (JUP)

The Stake with Jup tool, part of AgentiPy, allows users to stake SOL tokens with the JUP validator via a Jupiter API endpoint. This process typically involves swapping SOL for jupSOL (a liquid staking token representing staked SOL with Jupiter's validator) or directly staking SOL into Jupiter's LST pool.

Functionality

This tool is implemented in the StakeManager class.

Key Methods:

  • stake_with_jup(agent: SolanaAgentKit, amount: float) -> str:

    • Takes a SolanaAgentKit instance (which provides the wallet and connection) and the amount of SOL to stake.

    • Constructs a URL to interact with Jupiter's worker API (https://worker.jup.ag/blinks/swap/...) to get a transaction for staking SOL (specifically, it seems to target a swap/stake into jupSoLaHXQiZZTSfEWMTRRgpnyFm8f6sZdosWBjx93v, which is jupSOL).

    • The agent's wallet address is sent as the account in the payload.

    • Retrieves the serialized transaction from the API response.

    • Signs the transaction with the agent's wallet.

    • Sends and confirms the transaction on the Solana network.

    • Returns the transaction signature as a string.

Important Note: This tool performs on-chain transactions that will spend SOL from the agent's wallet. Staking mechanisms can have associated risks, including smart contract vulnerabilities or changes in staking reward rates. Always ensure you understand the specifics of the JUP staking program before using this tool with significant funds.

Source Code

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

Last updated