Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/integrations/solder-cortex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Solder Cortex Integration for Clodds
*
* Adds conviction scoring for prediction market bets.
* Before placing bets, check conviction of wallets making similar bets.
*
* Demo: http://76.13.193.103/
* GitHub: https://github.com/metalmcclaw/solder-cortex
*/

const CORTEX_API = process.env.CORTEX_API_URL || 'http://76.13.193.103/api';

export interface ConvictionData {
wallet: string;
score: number;
defiActivity: number;
predictionMarketActivity: number;
}

export async function getWalletConviction(wallet: string): Promise<ConvictionData | null> {
try {
const res = await fetch(`${CORTEX_API}/conviction/${wallet}`);
return res.ok ? await res.json() : null;
} catch { return null; }
}

export async function findInformedBettors(wallets: string[]): Promise<ConvictionData[]> {
const results = await Promise.all(wallets.map(getWalletConviction));
return results
.filter((c): c is ConvictionData => c !== null && c.score >= 0.7)
.sort((a, b) => b.score - a.score);
}

export async function shouldFollowBet(wallet: string): Promise<{ follow: boolean; reason: string }> {
const conviction = await getWalletConviction(wallet);
if (!conviction) return { follow: false, reason: 'Could not fetch conviction' };
return conviction.score >= 0.7
? { follow: true, reason: `High conviction (${conviction.score.toFixed(2)}) - informed bettor` }
: { follow: false, reason: `Low conviction (${conviction.score.toFixed(2)})` };
}