DeFi Guide

Swap & Liquidity

The ILAL DeFi API builds unsigned Uniswap V4 transactions for you. Your institution signs and broadcasts them using its own wallet — ILAL never touches your private key.

How it works

  1. 1Call the ILAL API with your API key and trade parameters.
  2. 2ILAL encodes the Uniswap V4 calldata, applies the ComplianceHook, and returns an unsigned transaction object.
  3. 3Your wallet signs and broadcasts the transaction to Base Sepolia.
  4. 4The ComplianceHook verifies your on-chain compliance session and routes the trade.
Network
Base Sepolia (chainId: 84532)
RPC
https://sepolia.base.org

Token Addresses (Base Sepolia)

TokenAddress
WETH (Wrapped Ether)0x4200000000000000000000000000000000000006
USDC (Circle)0x036CbD53842c5426634e7929541eC2318f3dCF7e

Note: token0 must be lexicographically less than token1. WETH < USDC by address.

Execute a Swap

Sell 0.001 ETH for USDC — WETH → USDC (zeroForOne: true).

1. Build the transaction

curl
curl -X POST https://ilalapi-production.up.railway.app/api/v1/defi/swap \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tokenIn":     "0x4200000000000000000000000000000000000006",
    "tokenOut":    "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
    "amount":      "1000000000000000",
    "zeroForOne":  true,
    "userAddress": "YOUR_WALLET_ADDRESS"
  }'

2. Sign and send (ethers.js v6)

TypeScript
import { ethers } from 'ethers';

const provider = new ethers.JsonRpcProvider('https://sepolia.base.org');
const wallet   = new ethers.Wallet(process.env.PRIVATE_KEY!, provider);

// Build
const res = await fetch('https://ilalapi-production.up.railway.app/api/v1/defi/swap', {
  method:  'POST',
  headers: { 'X-API-Key': 'YOUR_API_KEY', 'Content-Type': 'application/json' },
  body: JSON.stringify({
    tokenIn:     '0x4200000000000000000000000000000000000006',
    tokenOut:    '0x036CbD53842c5426634e7929541eC2318f3dCF7e',
    amount:      '1000000000000000',
    zeroForOne:  true,
    userAddress: wallet.address,
  }),
});
const { transaction } = await res.json();

// Sign & broadcast — your key, never shared
const tx = await wallet.sendTransaction(transaction);
console.log('Tx submitted:', tx.hash);

const receipt = await tx.wait();
console.log('Swap confirmed in block', receipt.blockNumber);

2. Sign and send (viem)

TypeScript
import { createWalletClient, http } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';
import { baseSepolia } from 'viem/chains';

const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
const client  = createWalletClient({ account, chain: baseSepolia, transport: http() });

// Build
const res = await fetch('https://ilalapi-production.up.railway.app/api/v1/defi/swap', {
  method:  'POST',
  headers: { 'X-API-Key': 'YOUR_API_KEY', 'Content-Type': 'application/json' },
  body: JSON.stringify({
    tokenIn:     '0x4200000000000000000000000000000000000006',
    tokenOut:    '0x036CbD53842c5426634e7929541eC2318f3dCF7e',
    amount:      '1000000000000000',
    zeroForOne:  true,
    userAddress: account.address,
  }),
});
const { transaction } = await res.json();

// Sign & broadcast
const hash = await client.sendTransaction({
  to:    transaction.to,
  data:  transaction.data,
  value: BigInt(transaction.value),
  gas:   BigInt(transaction.gas),
});
console.log('Swap hash:', hash);

Add Liquidity

Provide liquidity to the WETH/USDC pool.

curl
curl -X POST https://ilalapi-production.up.railway.app/api/v1/defi/liquidity \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "token0":      "0x4200000000000000000000000000000000000006",
    "token1":      "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
    "amount0":     "1000000000000000",
    "amount1":     "1000000000000000",
    "tickLower":   -600,
    "tickUpper":    600,
    "userAddress": "YOUR_WALLET_ADDRESS"
  }'
Note: token0 must have a lower address value than token1. For WETH/USDC on Base Sepolia, WETH is token0.