Skip to content

Stability Pool / Emissions Controller#134

Merged
piesrtasty merged 45 commits into
devfrom
feat/stability-pool-and-emissions-controller
Jun 19, 2026
Merged

Stability Pool / Emissions Controller#134
piesrtasty merged 45 commits into
devfrom
feat/stability-pool-and-emissions-controller

Conversation

@piesrtasty

@piesrtasty piesrtasty commented Jan 12, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds the Stability Pool, Emissions Controller, and strategy-step framework.

At a high level, users can now deposit HAI into the Stability Pool and receive sHAI, the pool can participate in collateral auctions and route purchased collateral back into HAI through configurable onchain strategy pipelines, and

KITE emissions are distributed through a standalone controller with dynamic splits between stability-side rewards and minting-side rewards.

This gives the protocol a dedicated HAI backstop with configurable liquidation routing, instead of relying on a single hardcoded unwind path per collateral.

It also decouples emissions logic from the pool itself, which makes reward distribution easier to reason about and easier to evolve over time.

What’s included

Stability Pool

  • new StabilityPool ERC4626 vault for depositing HAI and minting sHAI
  • KITE reward accounting for stakers
  • auction-cover flow via coverAndRepayDebt
  • SAFEEngine / CoinJoin / CollateralJoin integration for handling internal/external coin flows
  • initial non-transferable sHAI lifecycle, with one-way transfer enablement once governance wants to cut emissions over

Emissions Controller

  • new EmissionsController contract to manage KITE emissions separately from the pool
  • configurable stability vs minting rewards split
  • split updates based on onchain price deviation / redemption price context
  • explicit tracking for minting-side rewards distribution
  • support for custom emission durations and extending emissions later

Strategy Steps

  • new pluggable strategy-step system for liquidation routes
  • onchain preview + minOut enforcement before execution
  • support for multi-step pipelines instead of one fixed swap path per collateral
  • initial strategy-step implementations for:
    • Velodrome swap
    • Velodrome CL swap
    • Velodrome LP removal
    • Velodrome LP remove + swap
    • Curve swap
    • Balancer swap
    • Beefy vault withdrawal
    • Yearn / ERC4626 vault withdrawal

Notes

This PR is a pretty large feature drop and touches:

  • vault/share accounting
  • emissions distribution
  • liquidation flows
  • strategy execution / preview logic
  • SAFEEngine accounting boundaries

Most of the work here is around making those pieces compose cleanly.

Testing

Covered with unit + E2E tests across:

  • Stability Pool
  • Emissions Controller
  • strategy steps / strategy pipelines
  • auction cover flows
  • emissions accrual / cutover behavior
forge test --match-path 'test/unit/stability-pool/*.t.sol' -vv
forge test --match-path 'test/unit/stability-pool/strategy-steps/*.t.sol' -vv
forge test --match-path 'test/unit/jobs/StabilityPool*.t.sol' -vv
forge test --match-path 'test/e2e/stability-pool/*' -vv

In Depth Guide: https://hackmd.io/@lets-get-hai/stability-pool-auditor-guide

Comment thread src/contracts/StabilityPool.sol Outdated
Adds a new oracle relayer that allows reading from a CurveStableSwapNG pool.

We will use the relayer to return a price of HAI / BOLD from the HAI / BOLD curve pool at https://www.curve.finance/dex/optimism/pools/factory-stable-ng-81

This feed will then be combined with the existing BOLD / USD Chainlink compatible Pyth feed to produce a HAI / USD price.

The pool's `price_oracle(i)` returns an EMA, however because HAI has an external rate oracle configured for the pool, the redemption price, we need to adjust the raw value by the rate to get the actual HAI / BOLD exchange rate.

Additional Changes

- bumped `evm_version` to `shanghai` because needed the `PUSH0` opcode
- updated fork block in end to end oracle tests and fixed broken beefy / yearn tests in that file
@piesrtasty

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: da810f7c0e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/contracts/stability-pool/StabilityPool.sol
Comment thread src/contracts/stability-pool/StabilityPool.sol Outdated
@piesrtasty

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 45a3b1a442

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/contracts/stability-pool/StabilityPool.sol Outdated
@piesrtasty

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 16ae80726f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/contracts/stability-pool/StabilityPool.sol
@piesrtasty

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6ecd98880b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/contracts/stability-pool/StabilityPool.sol Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@piesrtasty

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1a8c119388

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/contracts/stability-pool/EmissionsController.sol Outdated
@piesrtasty

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@piesrtasty

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7814edc4e4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/contracts/stability-pool/StabilityPool.sol Outdated
@piesrtasty

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Feat: StakingManager cooldown
* chore: repo cleanup (#142)

* Merge pull request #144 from hai-on-op/feat/staking-manager-cooldown

Feat: StakingManager cooldown

* feat: tenderly tooling

* chore: formatting

* Stability Pool Audit Fixes (#146)

* fix: ECR-01S: Inexistent Sanitization of Input Addresses

* fix: MHT-01S: Illegible Numeric Value Representation

* fix: SPL-01S: Illegible Numeric Value Representations

* fix: SPL-02S: Inexistent Sanitization of Input Addresses

* fix: BVS-01M: Redundant Deadline Buffers

* fix: BVS-03M: Insecure On-Chain Preview

* fix: BVS-03M - scripts

* fix: CSS-01M: Insecure On-Chain Preview

* update: BVS-01M / CSS-01M - useOracleFloor config

* fix: ECR-01M: Emission Rate Truncations

* fix: ECR-02M: Uniform Deviation Direction

* fix: EGN-01M: Inexistent Validation of Length

* fix: MHT-01M: Insecure Negation of Signed Integers

* fix: SPL-01M: First-Depositor Attack Susceptibility

* fix: SPL-03M: Inexistent Validation of Step Sequence

* fix: VCL-01M: Potentially Lingering Approval

* fix: VCL-02M: Insecure On-Chain Preview

* fix: VLP-01M: Redundant Deadline Buffer

* fix: VLP-02M: Insecure On-Chain Preview

* feat: remove instances of OZ Math

* fix: VLR-01M: Redundant Deadline Buffer

* fix: VLR-02M: Insecure Preview Assumption

* fix: VLR-03M: Insecure On-Chain Preview

* fix: VSS-01M: Redundant Deadline Buffers

* fix: VSS-02M: Insecure On-Chain Preview

* fix: BVS-01C: Function Selector Value Literal
…s-controller' into feat/stability-pool-and-emissions-controller

# Conflicts:
#	script/tenderly/bootstrap-stability-pool.mjs
#	script/tenderly/stability-pool-config.mjs
#	script/tenderly/verify-stability-pool-manifest.mjs
@piesrtasty piesrtasty merged commit 1f8c199 into dev Jun 19, 2026
1 of 2 checks passed
@piesrtasty piesrtasty deleted the feat/stability-pool-and-emissions-controller branch June 19, 2026 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants