Merge pull request 'fix: Floor Ratchet 2000-trade oscillation needs a dedicated full-sequence red-team run (#1082)' (#1137) from fix/issue-1082 into master
This commit is contained in:
commit
1b3d0ddd78
4 changed files with 94 additions and 56 deletions
|
|
@ -300,6 +300,7 @@ contract AttackRunner is Script {
|
|||
} else if (_eq(op, "mine")) {
|
||||
uint256 blocks = vm.parseJsonUint(line, ".blocks");
|
||||
vm.roll(block.number + blocks);
|
||||
vm.warp(block.timestamp + blocks * 2);
|
||||
} else {
|
||||
console.log(string.concat("AttackRunner: unknown op '", op, "' -- skipping (check attack file for typos)"));
|
||||
}
|
||||
|
|
@ -336,7 +337,13 @@ contract AttackRunner is Script {
|
|||
uint256 amount = vm.parseUint(vm.parseJsonString(line, ".amount"));
|
||||
|
||||
for (uint256 i = 0; i < count; i++) {
|
||||
// Buy WETH→KRK.
|
||||
// Advance time past recenter cooldown (60s) and TWAP stability
|
||||
// window (30s) so the oracle incorporates the previous buy's price.
|
||||
vm.warp(block.timestamp + 61);
|
||||
vm.roll(block.number + 1);
|
||||
|
||||
// Buy and recenter in one broadcast (recenter is public — any address can call).
|
||||
// Using a single signer avoids multi-key broadcast issues in forge.
|
||||
vm.startBroadcast(ADV_PK);
|
||||
ISwapRouter02(swapRouter).exactInputSingle(
|
||||
ISwapRouter02.ExactInputSingleParams({
|
||||
|
|
@ -349,16 +356,12 @@ contract AttackRunner is Script {
|
|||
sqrtPriceLimitX96: 0
|
||||
})
|
||||
);
|
||||
vm.stopBroadcast();
|
||||
|
||||
// Recenter.
|
||||
vm.startBroadcast(RECENTER_PK);
|
||||
try ILM(lmAddr).recenter() returns (bool isUp) {
|
||||
_lastRecenterIsUp = isUp;
|
||||
_hasRecentered = true;
|
||||
_logSnapshot(_seq++);
|
||||
} catch {
|
||||
console.log("recenter: skipped (amplitude not reached)");
|
||||
// Amplitude not reached or price still deviating — continue loop.
|
||||
}
|
||||
vm.stopBroadcast();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,54 +1,89 @@
|
|||
// schema-version: 1
|
||||
{"op":"buy","amount":"100000000000000000000","token":"WETH"}
|
||||
{"op":"stake","amount":"1000000000000000000000","taxRateIndex":0}
|
||||
{"op":"recenter"}
|
||||
{"op":"mine","blocks":50}
|
||||
{"op":"buy","amount":"100000000000000000000","token":"WETH"}
|
||||
{"op":"recenter"}
|
||||
{"op":"mine","blocks":50}
|
||||
{"op":"buy","amount":"100000000000000000000","token":"WETH"}
|
||||
{"op":"stake","amount":"1000000000000000000000","taxRateIndex":5}
|
||||
{"op":"recenter"}
|
||||
{"op":"mine","blocks":50}
|
||||
{"op":"buy","amount":"100000000000000000000","token":"WETH"}
|
||||
{"op":"recenter"}
|
||||
{"op":"mine","blocks":50}
|
||||
{"op":"buy","amount":"100000000000000000000","token":"WETH"}
|
||||
{"op":"stake","amount":"10000000000000000000000000","taxRateIndex":0}
|
||||
{"op":"recenter"}
|
||||
{"op":"mine","blocks":50}
|
||||
{"op":"buy_recenter_loop","count":200,"amount":"5000000000000000000"}
|
||||
{"op":"unstake","positionId":1}
|
||||
{"op":"buy","amount":"100000000000000000000","token":"WETH"}
|
||||
{"op":"stake","amount":"1000000000000000000000","taxRateIndex":0}
|
||||
{"op":"recenter"}
|
||||
{"op":"mine","blocks":50}
|
||||
{"op":"buy","amount":"100000000000000000000","token":"WETH"}
|
||||
{"op":"sell","amount":"all","token":"KRK"}
|
||||
{"op":"recenter"}
|
||||
{"op":"mine","blocks":50}
|
||||
{"op":"buy","amount":"100000000000000000000","token":"WETH"}
|
||||
{"op":"stake","amount":"10000000000000000000000000","taxRateIndex":5}
|
||||
{"op":"recenter"}
|
||||
{"op":"mine","blocks":50}
|
||||
{"op":"buy_recenter_loop","count":200,"amount":"5000000000000000000"}
|
||||
{"op":"unstake","positionId":2}
|
||||
{"op":"buy","amount":"100000000000000000000","token":"WETH"}
|
||||
{"op":"stake","amount":"1000000000000000000000","taxRateIndex":5}
|
||||
{"op":"sell","amount":"all","token":"KRK"}
|
||||
{"op":"recenter"}
|
||||
{"op":"mine","blocks":50}
|
||||
{"op":"buy_recenter_loop","count":20,"amount":"100000000000000000000"}
|
||||
{"op":"buy","amount":"100000000000000000000","token":"WETH"}
|
||||
{"op":"stake","amount":"10000000000000000000000000","taxRateIndex":0}
|
||||
{"op":"recenter"}
|
||||
{"op":"mine","blocks":50}
|
||||
{"op":"buy_recenter_loop","count":200,"amount":"5000000000000000000"}
|
||||
{"op":"unstake","positionId":3}
|
||||
{"op":"sell","amount":"all","token":"KRK"}
|
||||
{"op":"recenter"}
|
||||
{"op":"mine","blocks":50}
|
||||
{"op":"buy","amount":"100000000000000000000","token":"WETH"}
|
||||
{"op":"stake","amount":"1000000000000000000000","taxRateIndex":0}
|
||||
{"op":"stake","amount":"10000000000000000000000000","taxRateIndex":5}
|
||||
{"op":"recenter"}
|
||||
{"op":"mine","blocks":50}
|
||||
{"op":"buy_recenter_loop","count":20,"amount":"100000000000000000000"}
|
||||
{"op":"buy_recenter_loop","count":200,"amount":"5000000000000000000"}
|
||||
{"op":"unstake","positionId":4}
|
||||
{"op":"sell","amount":"all","token":"KRK"}
|
||||
{"op":"recenter"}
|
||||
{"op":"mine","blocks":50}
|
||||
{"op":"buy","amount":"100000000000000000000","token":"WETH"}
|
||||
{"op":"stake","amount":"1000000000000000000000","taxRateIndex":5}
|
||||
{"op":"stake","amount":"10000000000000000000000000","taxRateIndex":0}
|
||||
{"op":"recenter"}
|
||||
{"op":"mine","blocks":50}
|
||||
{"op":"buy_recenter_loop","count":20,"amount":"100000000000000000000"}
|
||||
{"op":"buy_recenter_loop","count":200,"amount":"5000000000000000000"}
|
||||
{"op":"unstake","positionId":5}
|
||||
{"op":"sell","amount":"all","token":"KRK"}
|
||||
{"op":"recenter"}
|
||||
{"op":"mine","blocks":50}
|
||||
{"op":"buy","amount":"100000000000000000000","token":"WETH"}
|
||||
{"op":"stake","amount":"10000000000000000000000000","taxRateIndex":5}
|
||||
{"op":"recenter"}
|
||||
{"op":"mine","blocks":50}
|
||||
{"op":"buy_recenter_loop","count":200,"amount":"5000000000000000000"}
|
||||
{"op":"unstake","positionId":6}
|
||||
{"op":"sell","amount":"all","token":"KRK"}
|
||||
{"op":"recenter"}
|
||||
{"op":"mine","blocks":50}
|
||||
{"op":"buy","amount":"100000000000000000000","token":"WETH"}
|
||||
{"op":"stake","amount":"10000000000000000000000000","taxRateIndex":0}
|
||||
{"op":"recenter"}
|
||||
{"op":"mine","blocks":50}
|
||||
{"op":"buy_recenter_loop","count":200,"amount":"5000000000000000000"}
|
||||
{"op":"unstake","positionId":7}
|
||||
{"op":"sell","amount":"all","token":"KRK"}
|
||||
{"op":"recenter"}
|
||||
{"op":"mine","blocks":50}
|
||||
{"op":"buy","amount":"100000000000000000000","token":"WETH"}
|
||||
{"op":"stake","amount":"10000000000000000000000000","taxRateIndex":5}
|
||||
{"op":"recenter"}
|
||||
{"op":"mine","blocks":50}
|
||||
{"op":"buy_recenter_loop","count":200,"amount":"5000000000000000000"}
|
||||
{"op":"unstake","positionId":8}
|
||||
{"op":"sell","amount":"all","token":"KRK"}
|
||||
{"op":"recenter"}
|
||||
{"op":"mine","blocks":50}
|
||||
{"op":"buy","amount":"100000000000000000000","token":"WETH"}
|
||||
{"op":"stake","amount":"10000000000000000000000000","taxRateIndex":0}
|
||||
{"op":"recenter"}
|
||||
{"op":"mine","blocks":50}
|
||||
{"op":"buy_recenter_loop","count":200,"amount":"5000000000000000000"}
|
||||
{"op":"unstake","positionId":9}
|
||||
{"op":"sell","amount":"all","token":"KRK"}
|
||||
{"op":"recenter"}
|
||||
{"op":"mine","blocks":50}
|
||||
{"op":"buy","amount":"100000000000000000000","token":"WETH"}
|
||||
{"op":"stake","amount":"10000000000000000000000000","taxRateIndex":5}
|
||||
{"op":"recenter"}
|
||||
{"op":"mine","blocks":50}
|
||||
{"op":"buy_recenter_loop","count":200,"amount":"5000000000000000000"}
|
||||
{"op":"unstake","positionId":10}
|
||||
{"op":"sell","amount":"all","token":"KRK"}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue