@yieldpay/sdk
v1.1.1
Published
YieldPay SDK — Zero-loss AI agent payments powered by AAVE yield on Base L2
Downloads
479
Maintainers
Readme
@yieldpay/sdk
Zero-loss AI agent payments powered by AAVE yield on Base L2.
Agents pay for mutual services using only the yield generated by capital locked in AAVE V3. Principal is never spent.
Version 1.1.0 adds the V9.7 sidecar rail on Base Mainnet:
A2AMicroYieldLaneManagerA2AVaultFactoryV8.7A2AVaultDeployerV97- SDK helpers for opening lanes, signing vouchers, and settling ultra-micro yield payments
Install
npm install @yieldpay/sdk ethersQuick Start
import { A2AYieldClient, NETWORKS } from '@yieldpay/sdk';
import { ethers } from 'ethers';
const client = new A2AYieldClient(
process.env.AGENT_PRIVATE_KEY,
vaultAddress,
NETWORKS.BASE_MAINNET
);
await client.syncNonce();
// Discover available services
const services = await client.discoverServices();
// Pay instantly from yield float (if available)
await client.fastPay(services[0].address, ethers.parseUnits('0.50', 6));
// Or use smart routing (auto-chooses fastPay vs delegateYield)
await client.buyService(serviceAgent, priceWei, principalWei);Micro-Yield Lane (V9.7)
import { A2AYieldClient, NETWORKS } from '@yieldpay/sdk';
import { ethers } from 'ethers';
const client = new A2AYieldClient(
process.env.AGENT_PRIVATE_KEY,
vaultAddress,
NETWORKS.BASE_MAINNET
);
const lanePrincipal = ethers.parseUnits('25', 6);
await client.openMicroYieldLane(buyerAgent, lanePrincipal, 7 * 24 * 3600);
const signed = await client.signMicroYieldVoucher({
laneId: 1,
serviceAgent,
amountWei: ethers.parseUnits('0.001', 6),
deadline: 0,
});
const preview = await client.canSettleMicroYieldVoucher(signed.voucher, signed.signature);
if (preview.canSettle) {
await client.settleMicroYieldVoucher(signed.voucher, signed.signature);
}How It Works
- Deposit USDC into a Vault (locked in AAVE V3)
- Yield accrues automatically (2-8% APY)
- Pay agents from the yield — principal stays intact
- 96/2/2 split: 96% to service agent, 2% gas tank, 2% foundation
Payment Modes
| Mode | When | Speed | Gas |
|------|------|-------|-----|
| fastPay() | Yield float available | Instant | 1 tx |
| delegateYield() | Lock principal for duration | Deferred | 1 tx |
| buyService() | Auto-routes | Smart | 1 tx |
| signServiceRequest() | Off-chain batch | Zero gas | 0 tx |
| openMicroYieldLane() + vouchers | Yield-only ultra-micro rail | Deferred / batched | caller pays gas, buyer 0 ETH |
API
new A2AYieldClient(privateKey, vaultAddress, network)
Create a client for an agent.
privateKey— Agent wallet private keyvaultAddress— Deployed A2AYieldVault addressnetwork— UseNETWORKS.BASE_MAINNETorNETWORKS.BASE_SEPOLIA
Core Methods
| Method | Description |
|--------|-------------|
| syncNonce() | Sync on-chain nonce (call once at startup) |
| discoverServices() | List all active services from the Registry |
| fastPay(agent, amount) | Instant payment from yield float |
| delegateYield(agent, principal, duration) | Lock capital to generate yield |
| buyService(agent, price, principal) | Smart router (fastPay if float, else delegate) |
| signServiceRequest(agent, amount) | Sign off-chain for batch settlement |
| getLiveApy() | Read current AAVE APY |
| getAvailableFloat() | Check available yield balance |
| getMyAllowance() | Check agent allowance on vault |
| getMyFastPayBudget() | Check fastPay spending limit |
V9.7 Micro-Yield Lane Methods
| Method | Description |
|--------|-------------|
| openMicroYieldLane(buyerAgent, principalWei, maxDurationSec) | Open a new sidecar lane against the current vault |
| getMicroYieldLaneNonce(laneId) | Read the current monotonic nonce for a lane |
| getMicroYieldLaneAvailableYield(laneId) | Quote spendable accrued yield for a lane |
| signMicroYieldVoucher({ laneId, serviceAgent, amountWei, deadline, nonce }) | Sign a voucher in the A2AMicroYieldLaneManager EIP-712 domain |
| canSettleMicroYieldVoucher(voucher, signature) | Dry-run validation before on-chain settlement |
| settleMicroYieldVoucher(voucher, signature) | Submit one voucher to the sidecar manager |
| closeMicroYieldLane(laneId) | Release principal and sweep residual yield |
ABIs
import { VAULT_ABI, REGISTRY_ABI, FACTORY_ABI, MICRO_YIELD_LANE_MANAGER_ABI } from '@yieldpay/sdk/abi';Networks
import { NETWORKS } from '@yieldpay/sdk';
NETWORKS.BASE_MAINNET // chainId 8453
NETWORKS.BASE_SEPOLIA // chainId 84532
NETWORKS.LOCAL // chainId 31337Mainnet Addresses (Base L2)
| Contract | Address |
|----------|---------|
| Registry (V3 Proxy) | 0x687B266CD70e0Eac6Ba1fbebc2697BB2f37f303c |
| Factory (V8.7 current) | 0x7964202c49Da27b820E7d7B756c472F5cbD154D2 |
| Factory (V8.6 legacy) | 0x86B43842317B5426bb0fb1E778D23B9ECa0e4932 |
| MicroYieldLaneManager | 0x4d8dF53f7bbd1Db3ae68dd2f1CA259CC0a2A3623 |
| VaultDeployerV97 | 0xab12852277944FF7A6Df8fa19E3649A9ae87BF07 |
| USDC | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 |
License
MIT
