Overview
How It Works
Quick Start
import { ethers } from 'ethers';
import { ThetanutsClient } from '@thetanuts-finance/thetanuts-client';
const provider = new ethers.JsonRpcProvider('https://mainnet.base.org');
const signer = new ethers.Wallet(process.env.PRIVATE_KEY!, provider);
const client = new ThetanutsClient({ chainId: 8453, provider, signer });
// 1. Browse available strike/expiry combinations
const groups = await client.loan.getStrikeOptions('ETH');
const firstOption = groups[0].options[0];
// 2. Calculate exact loan costs
const calc = client.loan.calculateLoan({
depositAmount: '1.0',
underlying: 'ETH',
strike: firstOption.strike,
expiryTimestamp: firstOption.expiry,
askPrice: firstOption.askPrice,
underlyingPrice: firstOption.underlyingPrice,
});
console.log(`Receive: ${calc.formatted.receive} USDC`);
console.log(`Repay: ${calc.formatted.repay} USDC`);
console.log(`APR: ${calc.formatted.apr}%`);
// 3. Request the loan
const result = await client.loan.requestLoan({
underlying: 'ETH',
collateralAmount: '1.0',
strike: firstOption.strike,
expiryTimestamp: firstOption.expiry,
minSettlementAmount: calc.finalLoanAmount,
});
console.log(`Loan ID: ${result.quotationId}`);Method Overview
Method
Description
Signer
Loan Cost Formula
Promotional Pricing
Contract Addresses (Base)
Contract
Address
See Also
Last updated

