Sign In

plp-contract

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Malware was recently detected in this package.

Affected versions:

2.0.02.0.12.0.2

plp-contract

Python client library for PLP (Protocol Liquidity Pool) smart contract interactions

pipPyPI
Version
2.0.2
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created

plp-contract

Python client library for PLP (Protocol Liquidity Pool) smart contract interactions. Provides typed, async-ready depositor and pool management clients built on web3.py.

Installation

pip install plp-contract

Quick Start

from plp_contract import SimpleDepositor, DepositParams

depositor = SimpleDepositor(
    rpc_url="https://eth.llamarpc.com",
    depositor_address="0x8cad6c2317233D38a3cf4601F4A441f316F77Db3",
    private_key="0x...",
    chain_id=1,
)

# Preview deposit
shares = depositor.preview_deposit(
    pool_address="0x...",
    amount_wei=10**18,
)
print(f"Expected shares: {shares}")

# Execute deposit
result = depositor.deposit(DepositParams(
    pool_address="0x...",
    amount_wei=10**18,
    min_shares=int(shares * 0.995),  # 0.5% slippage
))
print(f"TX: {result.tx_hash}")

Async Usage

import asyncio
from plp_contract import AsyncDepositor, DepositParams

async def main():
    async with AsyncDepositor(
        rpc_url="wss://eth.llamarpc.com",
        depositor_address="0x8cad6c2317233D38a3cf4601F4A441f316F77Db3",
        private_key="0x...",
        chain_id=1,
    ) as depositor:
        info = await depositor.get_pool_info("0x...")
        print(f"TVL: {info.tvl_eth:.2f} ETH")

        result = await depositor.deposit(DepositParams(
            pool_address="0x...",
            amount_wei=5 * 10**17,
        ))
        print(f"TX: {result.tx_hash}, gas: {result.gas_used}")

asyncio.run(main())

Pool Registry

Track and query multiple pools:

from web3 import Web3
from plp_contract import PoolRegistry

w3 = Web3(Web3.HTTPProvider("https://eth.llamarpc.com"))
registry = PoolRegistry(w3, depositor_address="0x8cad6c...")

registry.add("0xPool1...")
registry.add("0xPool2...")

for pool in registry.active():
    print(f"{pool.name}: TVL={pool.tvl_eth:.2f} ETH, price={pool.share_price:.6f}")

API Reference

SimpleDepositor / AsyncDepositor

MethodDescription
deposit(params)Deposit assets into a pool (handles approval)
withdraw(params)Withdraw by burning share tokens
withdraw_all(pool, ...)Withdraw entire share balance
get_pool_info(pool)Fetch on-chain pool state
preview_deposit(pool, amount)Estimate shares for deposit
preview_redeem(pool, shares)Estimate assets for redemption
balance_of(pool, account?)Query share token balance

Models

  • DepositParams — Validated deposit parameters with slippage protection
  • WithdrawParams — Validated withdrawal parameters
  • PoolInfo — Read-only pool state snapshot
  • TransactionResult — On-chain transaction receipt with parsed logs
  • GasConfig — EIP-1559 and legacy gas settings

Exceptions

ExceptionWhen
InsufficientBalanceErrorBalance below requested amount
SlippageExceededErrorOutput below minimum threshold
PoolNotFoundErrorPool address not registered
TransactionRevertedErrorOn-chain revert
RPCErrorProvider communication failure
GasEstimationErrorGas estimation fails

Supported Contracts

ContractAddressChain
ELP Depositor0x8cad6c2317233D38a3cf4601F4A441f316F77Db3Ethereum
Royco Vault0x1F8B025D61Cd54E81B6e4f4fC1A8fc757bc50bcfEthereum

Requirements

  • Python 3.9+
  • web3.py >= 6.0

License

MIT

Keywords

ethereum

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts