Skip to content

Pi-Defi-world/Liquiditypools-test

Repository files navigation

Pool Management Scripts

This folder contains comprehensive scripts for managing pi network liquidity pools with MEME tokens on the Pi Testnet. note that this tokens are already created so its best you change the config.json files credentials and use the tokenization repo to create your own set of tokens

📁 Available Scripts

1. checkPools.js - Pool Discovery

Check for existing liquidity pools across all accounts.

node checkPools.js

Features:

  • ✅ Scans all configured accounts for pool shares
  • ✅ Shows pool details (reserves, fees, total shares)
  • ✅ Identifies pools involving MEME tokens
  • ✅ Displays global pool statistics

2. poolTrade.js - Trading Against Pools

Trade against the existing MEME-Test-π liquidity pool.

# Buy MEME tokens with Test-π
node poolTrade.js buy 10

# Sell MEME tokens for Test-π  
node poolTrade.js sell 5

Features:

  • ✅ Buy MEME tokens using Test-π
  • ✅ Sell MEME tokens for Test-π
  • ✅ Real-time price checking
  • ✅ Automatic slippage protection
  • ✅ Balance updates after trades

3. poolStats.js - Pool Analytics

Get comprehensive statistics and trading history for pools.

# Get full pool statistics
node poolStats.js

# Get trading analytics only
node poolStats.js analytics

Features:

  • ✅ Current pool reserves and prices
  • ✅ Total Value Locked (TVL) calculations
  • ✅ Trading history and volume analytics
  • ✅ Pool effects and operations history
  • ✅ Participant share percentages

4. poolLiquidity.js - Liquidity Management

Add or remove liquidity from existing pools.

# Add liquidity (Test-π + MEME)
node poolLiquidity.js add 10 100

# Add liquidity using buyer account
node poolLiquidity.js add 5 50 buyer

# Remove liquidity (shares)
node poolLiquidity.js remove 50

Features:

  • ✅ Add liquidity with optimal ratio calculations
  • ✅ Remove liquidity by burning shares
  • ✅ Support for multiple accounts
  • ✅ Automatic trustline establishment
  • ✅ Balance validation and updates

5. createPool.js - Pool Creation

Create new liquidity pools with custom parameters.

# Create predefined pools
node createPool.js predefined

# Create custom pool
node createPool.js custom MEME USPI 30 100 100

# Create high-fee pool
node createPool.js custom Test-π MEME 500 20 200 buyer

Features:

  • ✅ Create pools with custom fee structures
  • ✅ Support for different asset pairs
  • ✅ Predefined pool configurations
  • ✅ Initial liquidity deposits
  • ✅ Multiple account support

🏊 Current Pool Information

Pool ID: 2ec65214cd58c6322cb1937e8f1305592040ae30f0132b3d30832d2428b93fa8

Current Reserves:

  • Test-π: 90.0000000
  • MEME: 900.0000000
  • Total Shares: 284.6049894
  • Fee: 30 basis points (0.3%)

Current Price: 1 MEME = 0.1 Test-π

🔧 Configuration

All scripts use the configuration from ../config.json:

  • Network: Pi Testnet (https://api.testnet.minepi.com)
  • Token: MEME (issued by GCVLDIHANOSGP2WMQXIEOEXQ7BW3TUB3ZVOCFQGO3AMFSRTJS7S63YAJ)
  • Accounts: Issuer, Distributor, Buyer

📊 Usage Examples

Complete Pool Workflow

# 1. Check existing pools
node checkPools.js

# 2. View pool statistics
node poolStats.js

# 3. Trade against pool
node poolTrade.js buy 5

# 4. Add more liquidity
node poolLiquidity.js add 20 200

# 5. Check updated statistics
node poolStats.js

# 6. Create additional pools
node createPool.js predefined

Advanced Trading

# Check current prices before trading
node poolTrade.js buy 0  # Shows prices without trading

# Trade with specific amounts
node poolTrade.js buy 10
node poolTrade.js sell 5

Liquidity Management

# Add liquidity maintaining current ratio
node poolLiquidity.js add 10 100

# Remove liquidity
node poolLiquidity.js remove 25

# Use different account
node poolLiquidity.js add 5 50 buyer

⚠️ Important Notes

  1. Account Balances: Ensure accounts have sufficient balances before operations
  2. Trustlines: Scripts automatically establish required trustlines
  3. Fees: All operations include network fees (typically 0.00001 XLM)
  4. Slippage: Pool trades may experience slippage based on pool size
  5. Minimum Balances: Accounts must maintain minimum balances for operations

🔍 Troubleshooting

Common Issues

  1. "tx_bad_auth" errors: Account authentication issues
  2. "op_no_trust" errors: Missing trustlines (auto-handled by scripts)
  3. Insufficient balance: Check account balances before operations
  4. Pool not found: Verify pool ID is correct

Debug Commands

# Check account balances
node ../balances.js

# Verify pool exists
node checkPools.js

# Test account authentication
node ../testBuyerAccount.js

📈 Pool Economics

Fee Structure

  • Standard Pool: 30 basis points (0.3%)
  • High Fee Pool: 500 basis points (5%)
  • Custom Pools: Configurable fees

Liquidity Provider Rewards

  • Earn fees from trades proportional to share ownership
  • Automatic compound growth through pool operations
  • Withdraw rewards by removing liquidity

Price Impact

  • Larger trades have higher price impact
  • Pool depth affects slippage
  • Optimal trading sizes depend on pool reserves

Happy Pool Trading! 🏊‍♂️

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published