Documentation Index
Fetch the complete documentation index at: https://docs.lfg.land/llms.txt
Use this file to discover all available pages before exploring further.
Common Errors
Insufficient Funds
Error: "insufficient funds"
Cause: Not enough USDC in wallet or subaccount
Solution:
// Check balance before operations
const balances = await client.validatorClient.get.getAccountBalances(address);
const usdcBalance = balances.find((b) => b.denom.includes("usdc"));
Insufficient Collateral
Error: "insufficient collateral"
Cause: Not enough free collateral to place order
Solution:
const account = await client.indexerClient.account.getParentSubaccount(
address,
0
);
const freeCollateral = parseFloat(account.subaccount.freeCollateral);
if (freeCollateral < orderCost) {
// Deposit more or reduce order size
}
Order Expired
Error: Order expired or goodTilBlock in the past
Cause: Block height has passed goodTilBlock
Solution:
const currentBlock = await client.validatorClient.get.latestBlockHeight();
const goodTilBlock = currentBlock + 20; // Add buffer
Network Errors
Error: "network request failed", "timeout"
Cause: Network connectivity issues
Solution:
async function withRetry<T>(fn: () => Promise<T>, maxRetries = 3): Promise<T> {
for (let i = 0; i < maxRetries; i++) {
try {
return await fn();
} catch (error) {
if (i === maxRetries - 1) throw error;
await new Promise((resolve) => setTimeout(resolve, 1000 * (i + 1)));
}
}
throw new Error("Max retries exceeded");
}
Error Handling Patterns
Try-Catch Wrapper
async function safeOperation() {
try {
const tx = await client.placeShortTermOrder(/* ... */);
return { success: true, txHash: tx.hash };
} catch (error: any) {
console.error("Operation failed:", error.message);
return { success: false, error: error.message };
}
}
Specific Error Handling
try {
await client.depositToSubaccount(subaccount, amount);
} catch (error: any) {
if (error.message?.includes("insufficient funds")) {
console.error("Not enough USDC in wallet");
} else if (error.message?.includes("gas")) {
console.error("Insufficient gas");
} else {
console.error("Unknown error:", error);
}
}
Security
Security best practices
FAQ
Frequently asked questions