A NestJS service that automatically claims yield from the CoopStable lending protocol when yield distribution is available.
- Automated Yield Claiming: Runs a cron job that monitors the yield distributor contract and automatically claims yield when distribution is available
- Stellar Integration: Built with Stellar SDK for seamless blockchain interactions
- Health Monitoring: Provides REST endpoints to check service status and distribution information
- Manual Triggering: Allows manual yield claiming via API endpoint
- Node.js 20.x or higher
- PNPM 10.11.1 or higher
- Docker and Docker Compose (for containerized deployment)
- Stellar wallet with appropriate permissions
- Clone the repository:
git clone <repository-url>
cd yield-claimer- Install dependencies:
pnpm install- Configure environment variables:
cp .env.example .envEdit .env file with your configuration:
# Server Configuration
NODE_ENV=development
PORT=3001
# Stellar Network Configuration
NETWORK=TESTNET # or PUBLIC for mainnet
# Wallet Configuration (Required)
WALLET_SECRET_KEY=your_wallet_secret_key
WALLET_PUBLIC_KEY=your_wallet_public_keyDevelopment mode (with hot-reload):
pnpm start:devProduction mode:
pnpm build
pnpm start:prodDebug mode:
pnpm start:debug-
Create a
.envfile with your configuration (see above) -
Build and run the container:
docker-compose up -d- View logs:
docker-compose logs -f yield-claimer- Stop the service:
docker-compose down- Build the image:
docker build -t yield-claimer .- Run the container:
docker run -d \
--name yield-claimer \
-p 3001:3001 \
-e NODE_ENV=production \
-e NETWORK=TESTNET \
-e WALLET_SECRET_KEY=your_secret_key \
-e WALLET_PUBLIC_KEY=your_public_key \
yield-claimerGET /health- Health check endpointGET /yield-claimer/status- Get current distribution statusPOST /yield-claimer/claim- Manually trigger yield claim
Check service health:
curl http://localhost:3001/healthGet distribution status:
curl http://localhost:3001/yield-claimer/statusManually trigger claim:
curl -X POST http://localhost:3001/yield-claimer/claim- The service runs a cron job (default: every 12 hours, configurable)
- Checks if yield distribution is available via
is_distribution_available()on the yield distributor contract - If available, calls
claim_yield()on the lending yield controller contract - The contract automatically:
- Claims yield from lending protocols
- Issues cUSD tokens to the distributor
- Distributes tokens to members and treasury
- Updates distribution timestamps
- Yield Distributor:
CDUZHDM7EBTK7MSHAFJH57UXCBUXEJ6AAL555Y2P7ZQDJKAH4POGD3VW - Lending Yield Controller:
CAAKQRIPSVYCLM2JRJPAMIDUHN47VQPV7YI3RGT2C7HNJ45H7XZIK3F5
Configure these in your environment or update src/config/config.ts
# Format code
pnpm format
# Lint code
pnpm lint
# Run tests
pnpm test
# Run tests with coverage
pnpm test:covThe service logs all operations and provides detailed status information through the REST API. Use the /yield-claimer/status endpoint to monitor:
- Distribution availability
- Time until next distribution
- Current distribution round
- Total members
- Treasury share percentage
- Total distributed amount
- Connection refused: Ensure the service is running and the port is not blocked
- Invalid wallet keys: Verify your Stellar wallet keys are correct
- Contract not found: Ensure you're using the correct network (TESTNET/PUBLIC)
- If the container exits immediately, check logs:
docker-compose logs yield-claimer - Ensure all required environment variables are set in
.env - Verify Docker daemon is running
MIT License