Adapt protected returns to capital lock duration

This commit is contained in:
Theodore Song
2026-08-22 21:42:47 -04:00
parent 2de28533d8
commit 974a957f58
9 changed files with 148 additions and 61 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ const GAMMA = "https://gamma-api.polymarket.com";
const EVENT_LIMIT = Math.max(20, Math.min(1000, Number(process.env.NEG_RISK_EVENTS || 300)));
const COST_CENTS = Math.max(0, Math.min(5, Number(process.env.NEG_RISK_COST_CENTS || 0.5)));
const MIN_LIQUIDITY = Math.max(0, Number(process.env.NEG_RISK_MIN_LIQUIDITY || 1000));
const MIN_NET_PROFIT = Math.max(0, Number(process.env.NEG_RISK_MIN_NET_PROFIT || 0.003));
const MIN_NET_PROFIT = Math.max(0, Number(process.env.NEG_RISK_MIN_NET_PROFIT || 0.001));
const MIN_NET_RETURN = Math.max(0, Number(process.env.NEG_RISK_MIN_NET_RETURN || 0.0015));
async function fetchJson(url, attempts = 3) {
+22 -6
View File
@@ -16,13 +16,13 @@ const settlementCalibrationAudit = JSON.parse(fs.readFileSync(new URL("../resear
const sportsEvaluator = fs.readFileSync(new URL("./evaluate-sports-favorites.mjs", import.meta.url), "utf8");
const build = Number(index.match(/const BUILD_VERSION = (\d+);/)?.[1]);
assert.equal(build, 125);
assert.equal(build, 126);
assert.equal(vercelConfig.git?.deploymentEnabled?.["runtime-state"], false);
assert.equal(settlementCalibrationAudit.requested_markets, 5000);
assert.equal(settlementCalibrationAudit.train_passed, 0);
assert.equal(settlementCalibrationAudit.validation_selected, 0);
assert.equal(settlementCalibrationAudit.holdout_passed, 0);
assert.match(index, /Adaptive strategy 65 · capital-efficient protected sizing · build 125/);
assert.match(index, /Adaptive strategy 65 · duration-aware protected returns · build 126/);
assert.deepEqual([...ALLOWED_RUNTIME_KEYS].sort(), ["pma_agents_v2", "pma_suggestions_v5"]);
assert.match(index, /function collectPublicRuntimeItems\(\)/);
assert.match(index, /const PUBLIC_RUNTIME_KEYS=Object\.freeze\(\[AGENTS_KEY,SUG_KEY\]\)/);
@@ -72,10 +72,10 @@ assert.match(api, /Buffer\.from\(file\.content/);
assert.match(api, /searchParams\.set\("runtime", `\$\{Date\.now\(\)\}/);
assert.match(workflow, /cron: "2,7,12,17,22,27,32,37,42,47,52,57 \* \* \* \*"/);
assert.match(workflow, /contents: write/);
assert.match(workflow, /EXPECTED_BUILD: "125"/);
assert.match(workflow, /EXPECTED_BUILD: "126"/);
assert.equal((workflow.match(/if: always\(\)/g) || []).length, 2);
assert.match(routingReleaseWorkflow, /name: Release capital-efficient protected sizing after Vercel quota reset/);
assert.match(routingReleaseWorkflow, /bundlePositionCapPct/);
assert.match(routingReleaseWorkflow, /name: Release duration-aware protected returns after Vercel quota reset/);
assert.match(routingReleaseWorkflow, /bundleMinimumDailyReturn/);
assert.match(routingReleaseWorkflow, /cron: "25 1-23\/2 23 8 \*"/);
assert.match(workflow, /actions: write/);
assert.match(workflow, /cancel-in-progress: false/);
@@ -110,7 +110,15 @@ assert.doesNotMatch(index, /\/fee-rate\?token_id=/);
assert.match(index, /function maximizeBundleExecution\(candidate,books,minimumUnits\)/);
assert.match(index, /const BUNDLE_MAX_VERIFIED_NOTIONAL=1000;/);
assert.match(index, /const BUNDLE_EVENT_CAP_PCT=0\.12;/);
assert.match(index, /const BUNDLE_MIN_DAILY_RETURN=0\.0005;/);
assert.match(index, /const NEG_RISK_MIN_NET_PROFIT=0\.001;/);
assert.match(index, /const BUNDLE_MIN_EXECUTION_PROFIT=0\.50;/);
assert.match(index, /const BUNDLE_IMMEDIATE_MIN_DAILY_RETURN=0\.0001;/);
assert.match(index, /const BUNDLE_MIN_DAILY_RETURN=0\.0003;/);
assert.match(index, /const BUNDLE_MEDIUM_MIN_DAILY_RETURN=0\.0004;/);
assert.match(index, /const BUNDLE_LONG_MIN_DAILY_RETURN=0\.0005;/);
assert.match(index, /const BUNDLE_EXTENDED_MIN_DAILY_RETURN=0\.00075;/);
assert.match(index, /function bundleMinimumDailyReturn\(item=\{\}\)/);
assert.match(index, /function bundleClearsExecutionProfit\(item=\{\}\)/);
assert.match(index, /const BUNDLE_BASE_POSITION_CAP_PCT=0\.06;/);
assert.match(index, /const BUNDLE_HIGH_EFFICIENCY_POSITION_CAP_PCT=0\.08;/);
assert.match(index, /const BUNDLE_IMMEDIATE_POSITION_CAP_PCT=0\.10;/);
@@ -118,6 +126,7 @@ assert.match(index, /const BUNDLE_HIGH_EFFICIENCY_DAILY_RETURN=0\.002;/);
assert.match(index, /function bundlePositionCapPct\(item=\{\}\)/);
assert.match(index, /fee_check_eligible_structures:executableAudit\.filter\(candidate=>candidate\.fee_check_attempted\)\.length/);
assert.match(index, /"profit-below-floor"/);
assert.match(index, /"total-profit-below-floor"/);
assert.match(index, /"return-below-floor"/);
assert.match(index, /function compareBundleOpportunities\(a,b\)/);
assert.match(index, /function binaryComplementBundleSuggestions\(event,\{includeUnprofitable=false\}=\{\}\)/);
@@ -150,6 +159,8 @@ assert.match(index, /conversion_candidates_scanned:audited\.filter\(candidate=>c
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, /bundle_min_daily_return: s\.bundle_min_daily_return/);
assert.match(api, /execution_total_profit: s\.execution_total_profit/);
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:/);
@@ -176,6 +187,11 @@ assert.match(index, /atomicallyRecyclesEightySixPercentProfit:/);
assert.match(index, /prioritizesReturnPerLockedDay:/);
assert.match(index, /capsUnderlyingEventExposure:/);
assert.match(index, /blocksLowReturnPerLockedDay:/);
assert.match(index, /shortLocksUseProductiveHurdle:/);
assert.match(index, /longLocksRequireMoreReturn:/);
assert.match(index, /scalesSlimMarginsToMeaningfulProfit:/);
assert.match(index, /rejectsDustProfitDespitePositiveUnitMargin:/);
assert.match(index, /actualOpenedSizeMustPreserveProfitFloor:/);
assert.match(index, /durationAwareSizingScalesProtectedCapital:/);
assert.match(index, /sameCycleEventBurstStaysWithinCap:/);
assert.match(index, /sizesToLargestVerifiedProfitableFill:/);
+6 -2
View File
@@ -39,10 +39,12 @@ const compacted = compactSuggestion({
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" }],
bundle_net_profit_per_unit: 0.05, bundle_capital_efficiency: 0.0025, bundle_min_daily_return: 0.0001,
bundle_legs: [{ market_id: "1", side: "YES" }],
fees_enabled: false, fee_schedule: { rate: 0, exponent: 1, takerOnly: true },
depth_verified: true, fees_verified: true, fee_model: "verified-market-specific", execution_model: "live-order-book-vwap",
execution_units: 250, execution_notional: 237.5, verification_status: "executable", promoted_for_agents: ["value"],
execution_units: 250, execution_notional: 237.5, execution_total_profit: 12.5,
verification_status: "executable", promoted_for_agents: ["value"],
});
assert.equal(compacted.signal_type, "bundle-arb");
assert.equal(compacted.entry_candidate, true);
@@ -60,9 +62,11 @@ 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_min_daily_return, 0.0001);
assert.equal(compacted.bundle_legs.length, 1);
assert.equal(compacted.fee_schedule.rate, 0);
assert.equal(compacted.execution_units, 250);
assert.equal(compacted.execution_total_profit, 12.5);
assert.equal(compacted.verification_status, "executable");
assert.deepEqual(compacted.promoted_for_agents, ["value"]);