Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@ name: CI

on:
push:
branches: [main]
pull_request:
workflow_dispatch:

env:
FOUNDRY_PROFILE: ci

jobs:
check:
name: Foundry project
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -19,22 +15,28 @@ jobs:

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: stable

- name: Show Forge version
- name: Print versions
run: |
forge --version
forge solc --version

- name: Run Forge fmt
run: |
forge fmt --check
id: fmt
- name: Build
run: forge build --sizes

- name: Run Forge build
run: |
forge build --sizes
id: build
- name: Run tests
run: forge test -vvv

- name: Run Forge tests
run: |
forge test -vvv
id: test
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: foundry-rs/foundry-toolchain@v1

- name: Check formatting
run: forge fmt --check
7 changes: 5 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ libs = ["lib"]
solc_version = '0.8.26'
evm_versoin = 'cancun'
optimizer_runs = 800
via_ir = false
ffi = true
via_ir = false


[profile.ci]
ffi = false
optimizer = true
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
10 changes: 3 additions & 7 deletions src/OscillonHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ contract OscillonHook is BaseHook {

// ── Depeg thresholds (bps) ────────────────────────────────────────────────

uint256 public constant SMALL_DEPEG_BPS = 7;
uint256 public constant SMALL_DEPEG_BPS = 5;

// ── Timing ───────────────────────────────────────────────────────────────

Expand Down Expand Up @@ -241,7 +241,7 @@ contract OscillonHook is BaseHook {
address oracle1,
uint8 stableDecimals0,
uint8 stableDecimals1
) external {
) external onlyOwner {
// [CHANGE 9] Stable-only enforcement via tick spacing
if (key.tickSpacing != 1) revert NotStablePool();

Expand Down Expand Up @@ -399,9 +399,7 @@ contract OscillonHook is BaseHook {
if (nowTs == last.blockTimestamp) return; // dedupe within same second

int56 delta = int56(uint56(nowTs - last.blockTimestamp));
int56 newCumulative = last.tickCumulative +
int56(currentTick) *
delta;
int56 newCumulative = last.tickCumulative + int56(currentTick) * delta;

uint16 nextIdx = (lastIdx + 1) % OBS_CARDINALITY;
observations[poolId][nextIdx] = Observation({
Expand Down Expand Up @@ -442,7 +440,6 @@ contract OscillonHook is BaseHook {
bool pegBelow,
bool usingFallback
) = _readDepegWithFallback(key, feed, dec);

uint256 swapSize = params.amountSpecified < 0
? uint256(-params.amountSpecified)
: uint256(params.amountSpecified);
Expand Down Expand Up @@ -649,7 +646,6 @@ contract OscillonHook is BaseHook {
uint256 updatedAt,
uint80 answeredInRound
) = IAggregatorV3Interface(oracle).latestRoundData();

if (answer <= 0) revert OracleAnswerInvalid();
if (answeredInRound < roundId)
revert OracleRoundIncomplete(roundId, answeredInRound);
Expand Down
Loading