Verify negative-risk conversions on chain

This commit is contained in:
Theodore Song
2026-08-22 19:55:15 -04:00
parent c15dc12323
commit 6853821dc9
5 changed files with 201 additions and 59 deletions
+16
View File
@@ -81,12 +81,19 @@ assert.match(index, /const NEG_RISK_EVENT_SCAN_LIMIT=1000;/);
assert.match(index, /bundleOpportunityTelemetry:true/);
assert.match(index, /const BUNDLE_DEPTH_CANDIDATE_LIMIT=80;/);
assert.match(index, /const BINARY_COMPLEMENT_DEPTH_RESERVE=20;/);
assert.match(index, /const NEG_RISK_CONVERSION_DEPTH_RESERVE=20;/);
assert.match(index, /bundleRequiresDepthVerification:true/);
assert.match(index, /bundleRequiresClobFeeVerification:true/);
assert.match(index, /function bundleExecutableLeg\(book,units,feeSchedule\)/);
assert.match(index, /function generalAdaptiveLearningExclusion\(trade\)/);
assert.match(index, /specializedUnsafeTradesCannotBiasDirectionalLearning:/);
assert.match(index, /function fetchBundleFeeSchedules\(conditionIds\)/);
assert.match(index, /function fetchNegativeRiskConversionTerms\(marketIds\)/);
assert.match(index, /const NEG_RISK_ADAPTER_ADDRESS="0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296";/);
assert.match(index, /const NEG_RISK_FEE_BIPS_SELECTOR="0x2582cb5e";/);
assert.match(index, /const NEG_RISK_QUESTION_COUNT_SELECTOR="0xb7f75d2c";/);
assert.match(index, /const NEG_RISK_RPC_BATCH_CALL_LIMIT=10;/);
assert.match(index, /function applyNegativeRiskConversionTerms\(candidate,terms\)/);
assert.match(index, /function bundleFeeSchedulesMatch\(expected,reported\)/);
assert.match(index, /rejectsMismatchedClobFeeCurve:/);
assert.doesNotMatch(index, /\/fee-rate\?token_id=/);
@@ -102,14 +109,23 @@ assert.match(index, /rejectsCrossMarketBinaryMerge:/);
assert.match(index, /immediateMergeMetadataSurvivesSync:/);
assert.match(api, /bundle_immediate_merge: s\.bundle_immediate_merge/);
assert.match(index, /function convertCompleteNegativeRiskNoBundle\(p,bundleId\)/);
assert.match(index, /function negativeRiskBundleSuggestions\(event,\{includeUnprofitable=false,conversionTerms=null\}=\{\}\)/);
assert.match(index, /preservesBothCompleteSidesThroughAudit:/);
assert.match(index, /discoversExactCompleteNoConversion:/);
assert.match(index, /deductsAdapterFeeFromConversionPayout:/);
assert.match(index, /atomicallyConvertsCompleteNoSet:/);
assert.match(index, /blocksImmediateConversionOnMismatchedMetadata:/);
assert.match(index, /blocksImmediateConversionOnQuestionCountMismatch:/);
assert.match(index, /blocksImmediateConversionOnMetadataFeeMismatch:/);
assert.match(index, /doesNotInventConversionWithoutAdapterMetadata:/);
assert.match(index, /conversion_structures:conversions\.length/);
assert.match(index, /conversion_candidates_scanned:audited\.filter\(candidate=>candidate\.bundle_conversion_candidate\)\.length/);
assert.match(index, /actionable_conversions:unique\.filter\(candidate=>candidate\.bundle_immediate_convert\)\.length/);
assert.match(index, /Exact complete-NO conversion:/);
assert.match(api, /bundle_immediate_convert: s\.bundle_immediate_convert/);
assert.match(api, /neg_risk_market_id: s\.neg_risk_market_id, neg_risk_fee_bips: s\.neg_risk_fee_bips/);
assert.match(index, /reservesBinaryComplementDepthChecks:/);
assert.match(index, /reservesExactConversionDepthChecks:/);
assert.match(index, /function bundleVerificationShortlist\(candidates\)/);
assert.match(index, /function prioritizeIndependentBundles\(candidates,limit=Infinity\)/);
assert.match(index, /prioritizesIndependentEventsBeforeAlternates:/);
+9 -2
View File
@@ -34,8 +34,10 @@ else process.env.NEON_DATABASE_URL = originalNeonUrl;
const compacted = compactSuggestion({
market_id: "bundle:1:yes", side: "YES", signal_type: "bundle-arb", signal_confidence: 1,
entry_candidate: true, adaptive_promotion: false, requires_live: true, bundle_id: "bundle:1:yes", bundle_event_id: "1",
bundle_side: "NO", bundle_logic: "neg-risk-complete-no", bundle_immediate_convert: true,
neg_risk_market_id: "0xmarket", neg_risk_fee_bips: 25, bundle_cost_per_unit: 1.95,
bundle_side: "NO", bundle_logic: "neg-risk-complete-no", bundle_conversion_candidate: true,
bundle_conversion_terms_verified: true, bundle_immediate_convert: true,
neg_risk_market_id: "0xmarket", neg_risk_fee_bips: 25, neg_risk_metadata_fee_bips: 25,
neg_risk_question_count: 3, conversion_verification_status: "verified-onchain", bundle_cost_per_unit: 1.95,
bundle_payout_per_unit: 1.995, bundle_settlement_payout_per_unit: 2,
bundle_net_profit_per_unit: 0.05, bundle_capital_efficiency: 0.0025, bundle_legs: [{ market_id: "1", side: "YES" }],
fees_enabled: false, fee_schedule: { rate: 0, exponent: 1, takerOnly: true },
@@ -48,9 +50,14 @@ assert.equal(compacted.requires_live, true);
assert.equal(compacted.bundle_side, "NO");
assert.equal(compacted.bundle_event_id, "1");
assert.equal(compacted.bundle_logic, "neg-risk-complete-no");
assert.equal(compacted.bundle_conversion_candidate, true);
assert.equal(compacted.bundle_conversion_terms_verified, true);
assert.equal(compacted.bundle_immediate_convert, true);
assert.equal(compacted.neg_risk_market_id, "0xmarket");
assert.equal(compacted.neg_risk_fee_bips, 25);
assert.equal(compacted.neg_risk_metadata_fee_bips, 25);
assert.equal(compacted.neg_risk_question_count, 3);
assert.equal(compacted.conversion_verification_status, "verified-onchain");
assert.equal(compacted.bundle_settlement_payout_per_unit, 2);
assert.equal(compacted.bundle_capital_efficiency, 0.0025);
assert.equal(compacted.bundle_legs.length, 1);