import { evaluateSwapPolicy } from '@moi/policy-engine';
import { TextileAdapter } from '@moi/textile-adapter';
// 1. Initialize adapter
const adapter = new TextileAdapter();
// 2. Fetch firm RFQ quote from Textile FX v2
const quote = await adapter.requestFirmQuote({
sellToken: '0xF6829D7393dAe24509eb1E52eE8e572e2E271a4f', // cNGN
buyToken: '0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e', // USDT
sellAmountAtomic: '50000000000', // 50,000 cNGN
takerAddress: agentWalletAddress,
});
// 3. Evaluate 18 deterministic rules
const evaluation = evaluateSwapPolicy({
mandate,
quote,
settledExecutionsCount: 5,
});
if (evaluation.passed) {
console.log('Policy approved! Attestation token:', evaluation.attestationToken);
} else {
console.error('Policy rejected:', evaluation.checks.filter(c => !c.passed));
}Integration Examples
TypeScript code snippets demonstrating end-to-end quote retrieval and policy verification.