feat: Enhance fuzzing with staking integration and configurable parameters
- Add staking/unstaking actions to fuzzing scenarios (stake every 3rd trade) - Implement snatching logic when stake pool reaches capacity (uses max tax rate) - Add configurable parameters: - buyBias: Control buy vs sell ratio (0-100%) - stakingBias: Control stake vs unstake ratio (0-100%) - tradesPerRun: Configure number of trades per scenario - staking: Enable/disable staking entirely - Simplify to single trading strategy (_executeRandomLargeTrades) - Fix memory issues by recording only every 5th trade to CSV - Track staking metrics (stakes attempted/succeeded, snatches attempted/succeeded) - Update CLAUDE.md with new fuzzing parameters and usage examples - Clean up old TODO files and unused code 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
27a8998a82
commit
10702f5aa3
10 changed files with 110 additions and 343 deletions
|
|
@ -288,6 +288,10 @@
|
|||
const discoveryTickUpper = parseFloat(row.discoveryTickUpper);
|
||||
const discoveryLiquidity = parseFloat(row.discoveryLiquidity || 0);
|
||||
|
||||
// Extract staking metrics if available
|
||||
const percentageStaked = row.percentageStaked ? parseFloat(row.percentageStaked) : 0;
|
||||
const avgTaxRate = row.avgTaxRate ? parseFloat(row.avgTaxRate) : 0;
|
||||
|
||||
// Calculate token amounts from liquidity
|
||||
const floorAmounts = getAmountsForLiquidity(floorLiquidity, floorTickLower, floorTickUpper, currentTick);
|
||||
const anchorAmounts = getAmountsForLiquidity(anchorLiquidity, anchorTickLower, anchorTickUpper, currentTick);
|
||||
|
|
@ -383,7 +387,7 @@
|
|||
simulateEnhanced(headline, currentTick,
|
||||
floorTickLower, floorTickUpper, floorEth, floorKraiken, floorLiquidity,
|
||||
anchorTickLower, anchorTickUpper, anchorEth, anchorKraiken, anchorLiquidity,
|
||||
discoveryTickLower, discoveryTickUpper, discoveryEth, discoveryKraiken, discoveryLiquidity, token0isWeth, index, precedingAction);
|
||||
discoveryTickLower, discoveryTickUpper, discoveryEth, discoveryKraiken, discoveryLiquidity, token0isWeth, index, precedingAction, percentageStaked, avgTaxRate);
|
||||
|
||||
// Add navigation buttons below
|
||||
const bottomNavDiv = document.createElement('div');
|
||||
|
|
@ -569,7 +573,7 @@
|
|||
function simulateEnhanced(precedingAction, currentTick,
|
||||
floorTickLower, floorTickUpper, floorEth, floorKraiken, floorLiquidity,
|
||||
anchorTickLower, anchorTickUpper, anchorEth, anchorKraiken, anchorLiquidity,
|
||||
discoveryTickLower, discoveryTickUpper, discoveryEth, discoveryKraiken, discoveryLiquidity, token0isWeth, index, originalAction) {
|
||||
discoveryTickLower, discoveryTickUpper, discoveryEth, discoveryKraiken, discoveryLiquidity, token0isWeth, index, originalAction, percentageStaked = 0, avgTaxRate = 0) {
|
||||
|
||||
// Position data structure with liquidity calculations
|
||||
const positions = {
|
||||
|
|
@ -635,7 +639,7 @@
|
|||
scenarioContainer.appendChild(chartsContainer);
|
||||
|
||||
// Create summary panel
|
||||
const summaryPanel = createSummaryPanel(positions, currentTick, token0isWeth, originalAction || precedingAction, index);
|
||||
const summaryPanel = createSummaryPanel(positions, currentTick, token0isWeth, originalAction || precedingAction, index, percentageStaked, avgTaxRate);
|
||||
scenarioContainer.appendChild(summaryPanel);
|
||||
|
||||
// Add to page
|
||||
|
|
@ -1097,7 +1101,7 @@
|
|||
});
|
||||
}
|
||||
|
||||
function createSummaryPanel(positions, currentTick, token0isWeth, precedingAction, index) {
|
||||
function createSummaryPanel(positions, currentTick, token0isWeth, precedingAction, index, percentageStaked = 0, avgTaxRate = 0) {
|
||||
const panel = document.createElement('div');
|
||||
panel.className = 'summary-panel';
|
||||
|
||||
|
|
@ -1172,6 +1176,25 @@
|
|||
1 KRAIKEN = ${kraikenPriceInEth.toExponential(3)} ETH
|
||||
`;
|
||||
grid.appendChild(priceItem);
|
||||
|
||||
// Add staking metrics if available
|
||||
if (percentageStaked > 0 || avgTaxRate > 0) {
|
||||
const stakingItem = document.createElement('div');
|
||||
stakingItem.className = 'summary-item';
|
||||
|
||||
// Format percentageStaked (it's in 1e18 format, so divide by 1e16 to get percentage)
|
||||
const stakingPercent = (percentageStaked / 1e16).toFixed(2);
|
||||
|
||||
// Format avgTaxRate (also in 1e18 format, normalized to max tax rate)
|
||||
const taxRatePercent = (avgTaxRate / 1e16).toFixed(2);
|
||||
|
||||
stakingItem.innerHTML = `
|
||||
<strong>Staking Metrics</strong><br>
|
||||
Staked: ${stakingPercent}%<br>
|
||||
Avg Tax Rate: ${taxRatePercent}%
|
||||
`;
|
||||
grid.appendChild(stakingItem);
|
||||
}
|
||||
|
||||
panel.appendChild(grid);
|
||||
return panel;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue