Skip to main content
Quarantined

This project has been quarantined by PyPI admins. It cannot be installed or modified until a security review is complete.

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

Method Description
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

Exception When
InsufficientBalanceError Balance below requested amount
SlippageExceededError Output below minimum threshold
PoolNotFoundError Pool address not registered
TransactionRevertedError On-chain revert
RPCError Provider communication failure
GasEstimationError Gas estimation fails

Supported Contracts

Contract Address Chain
ELP Depositor 0x8cad6c2317233D38a3cf4601F4A441f316F77Db3 Ethereum
Royco Vault 0x1F8B025D61Cd54E81B6e4f4fC1A8fc757bc50bcf Ethereum

Requirements

  • Python 3.9+
  • web3.py >= 6.0

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plp_contract-2.0.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

plp_contract-2.0.0-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file plp_contract-2.0.0.tar.gz.

File metadata

  • Download URL: plp_contract-2.0.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.12

File hashes

Hashes for plp_contract-2.0.0.tar.gz
Algorithm Hash digest
SHA256 a3ced8776ef31f538c57b4a9cf4a99038086995b8ebb25ff59fd77124c2e561e
MD5 05c67d5542be35259d22b6df32b73256
BLAKE2b-256 4d9c347828a1378ee218ba8c7ccd3f4e6369d91d01c79ec198a00a92c9e050b9

See more details on using hashes here.

File details

Details for the file plp_contract-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: plp_contract-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.12

File hashes

Hashes for plp_contract-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ca66957a8990e8c6a0e3b0875beb2b55387fdf804029abb8ba6fd314eb5c18bd
MD5 49bda415d913b44e3718126460f00323
BLAKE2b-256 0bfc7fd1d1c4ad833b9ed934455179e7f48b340ef61bde9689721708eccbaeac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page