import {
ThetanutsClient,
validateIronCondor,
calculateNumContracts,
calculateCollateralRequired,
calculateReservePrice,
} from '@anthropic/thetanuts-sdk';
async function sellIronCondor(
client: ThetanutsClient,
tradeAmount: number, // USDC to put up as collateral
strikes: number[], // [putLower, putUpper, callLower, callUpper]
expiry: number // Unix timestamp
) {
// 1. Validate strikes
const validation = validateIronCondor(strikes);
if (!validation.valid) {
throw new Error(`Invalid strikes: ${validation.error}`);
}
// 2. Get MM pricing
const condorPricing = await client.mmPricing.getCondorPricing({
underlying: 'ETH',
strike1: strikes[0] * 1e8,
strike2: strikes[1] * 1e8,
strike3: strikes[2] * 1e8,
strike4: strikes[3] * 1e8,
expiry,
type: 'iron',
});
// 3. Calculate number of contracts
const numContracts = calculateNumContracts({
tradeAmount,
product: 'IRON_CONDOR',
strikes,
isBuy: false,
});
// 4. Calculate reserve price (minimum premium to receive)
const spot = await client.api.getSpotPrice('ETH');
const reservePrice = calculateReservePrice(
numContracts,
condorPricing.netMmBidPrice, // Use bid for selling
spot,
'IRON_CONDOR'
);
// 5. Calculate collateral required
const collateral = calculateCollateralRequired(
numContracts,
'IRON_CONDOR',
strikes
);
console.log({
numContracts,
reservePrice,
collateral,
mmBidPrice: condorPricing.netMmBidPrice,
});
// 6. Submit RFQ (example - actual implementation may vary)
// const rfq = await client.optionFactory.buildIronCondorRFQ({
// underlying: 'ETH',
// strikes,
// expiry,
// isLong: false,
// numContracts,
// reservePrice,
// });
}