Skip to content

Comments

Supernova AMO#2800

Open
sparrowDom wants to merge 30 commits intomasterfrom
sparrowDom/supernovaAMO
Open

Supernova AMO#2800
sparrowDom wants to merge 30 commits intomasterfrom
sparrowDom/supernovaAMO

Conversation

@sparrowDom
Copy link
Member

@sparrowDom sparrowDom commented Feb 14, 2026

Supernova AMO

TODO:

  • the sonic deploy script should be removed once fork testing Swapx amo is not needed anymore
  • delete the deployOETHSupernovaAMOStrategyPoolAndGauge from the deploy script once the pool and the gauge are created

What was done

  • Refactored the Sonic SwapXAMO strategy into a generalized Algebra-based strategy.
  • Updated strategy behavior to accept pool tokens in any order, removing token-order assumptions.
  • Kept strategy behavior consistent while improving flexibility and reuse across Algebra-style pools.

Test fixes and updates

  • Fixed existing Sonic fork tests that were broken or outdated after the refactor.
  • Adjusted fork test setup and assertions to match the new generalized strategy interface/flow.
  • Updated test cases to validate compatibility with the refactored format and token-order handling.

Why this change

  • The prior SwapXAMO implementation was too specialized and was expecting ws / OS tokens in specific order. Also the strategy was named SwapX even though the pool engine underneath was Algebra
  • Ensuring token-order-agnostic handling prevents integration issues across pools with varying token ordering.

What isn't done

  • The strategy still expects both tokens to have 18 decimal format. Additional work is required to make strategy support non 18 decimal tokens.

Code review suggestions

A couple of files have been moved still they should be compared with their old versions:

  • StableSwapAMMStrategy.sol with the SonicSwapXAMOStrategy.sol example code-diff as of 03e81d9 commit : https://www.diffchecker.com/MdOvAfVf/
  • algebraAmoStrategy.js with the swapx-amo.sonic.fork-test.js online diff tools do a terrible job here
  • Compare of SwapX Pair contract with Supernova's sol2uml diff 0x6509f770B83856Ac51613AEe73D1E7bFaD032784 -bn sonic 0xcfE67b6c7B65c8d038e666b3241a161888B7f2b0

@sparrowDom sparrowDom marked this pull request as draft February 14, 2026 12:46
@codecov
Copy link

codecov bot commented Feb 16, 2026

Codecov Report

❌ Patch coverage is 0% with 227 lines in your changes missing coverage. Please review.
✅ Project coverage is 41.24%. Comparing base (db6d806) to head (15bc2af).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...racts/strategies/algebra/StableSwapAMMStrategy.sol 0.00% 226 Missing ⚠️
...ts/strategies/algebra/OETHSupernovaAMOStrategy.sol 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2800      +/-   ##
==========================================
- Coverage   43.61%   41.24%   -2.37%     
==========================================
  Files         104      106       +2     
  Lines        4464     4485      +21     
  Branches     1218     1225       +7     
==========================================
- Hits         1947     1850      -97     
- Misses       2514     2632     +118     
  Partials        3        3              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

} else {
amount0 = amountOut;
amount1 = 0;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: There might be a way to simplify the above code

Copy link
Member Author

Choose a reason for hiding this comment

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

Could be expressed as:

(uint256 amount0, uint256 amount1) = (_tokenIn == asset && oTokenPoolIndex == 1) ||
    (_tokenIn == oToken && oTokenPoolIndex == 0)
  ? (uint256(0), amountOut)
  : (amountOut, 0);

While that is more condensed I think it is less readable

@sparrowDom sparrowDom marked this pull request as ready for review February 22, 2026 00:55
@naddison36 naddison36 requested a review from Copilot February 23, 2026 12:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the Sonic SwapXAMO strategy into a generalized Algebra-based AMO strategy and introduces a new Supernova AMO strategy for OETH on mainnet. The refactoring enables code reuse across different Algebra-style DEX pools while making the strategy token-order agnostic.

Changes:

  • Extracted a generalized StableSwapAMMStrategy base contract that works with any Algebra-style stable swap pool
  • Refactored SonicSwapXAMOStrategy to inherit from the base contract, removing ~850 lines of duplicated code
  • Added new OETHSupernovaAMOStrategy for OETH/WETH pool on mainnet
  • Created comprehensive behavior-driven tests that can be reused across different Algebra AMO implementations
  • Updated deployment scripts and fixtures to support the new strategy architecture

Reviewed changes

Copilot reviewed 13 out of 15 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
contracts/contracts/strategies/algebra/StableSwapAMMStrategy.sol New generalized base strategy for Algebra stable pools with token-order-agnostic handling
contracts/contracts/strategies/sonic/SonicSwapXAMOStrategy.sol Refactored to inherit from base, reducing from ~850 to ~5 lines
contracts/contracts/strategies/algebra/OETHSupernovaAMOStrategy.sol New OETH Supernova AMO strategy implementation
contracts/test/behaviour/algebraAmoStrategy.js Comprehensive reusable behavior tests for Algebra AMO strategies
contracts/test/strategies/sonic/swapx-amo.sonic.fork-test.js Refactored to use behavior tests
contracts/test/strategies/oeth-supernova-amo.mainnet.fork-test.js New tests for OETH Supernova strategy
contracts/deploy/mainnet/178_supernova_AMO.js Deployment script for mainnet Supernova AMO
contracts/deploy/deployActions.js Helper functions for pool/gauge creation and strategy deployment
contracts/test/_fixture.js New fixture for OETH Supernova AMO testing
contracts/test/_fixture-sonic.js Enhanced fixture with auto-allocate handling
contracts/contracts/interfaces/algebra/* New interfaces for Algebra pair and gauge contracts
contracts/utils/addresses.js Added Supernova protocol addresses

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1377 to +1384
log(`Adding ${config.poolAddOethAmount} WETH to the pool`);
const wethAmount = parseUnits(cfg.poolAddWethAmount.toString(), 18);
await weth.connect(josh).transfer(supernovaPool.address, wethAmount);
}

// Add OETH to the pool directly.
if (cfg.poolAddOethAmount > 0) {
log(`Adding ${config.poolAddOethAmount} OETH to the pool`);
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

The log message says "Adding ${config.poolAddOethAmount} OETH to the pool" but should say "Adding ${cfg.poolAddOethAmount} OETH to the pool". The variable reference is incorrect - it should use cfg instead of config.

Suggested change
log(`Adding ${config.poolAddOethAmount} WETH to the pool`);
const wethAmount = parseUnits(cfg.poolAddWethAmount.toString(), 18);
await weth.connect(josh).transfer(supernovaPool.address, wethAmount);
}
// Add OETH to the pool directly.
if (cfg.poolAddOethAmount > 0) {
log(`Adding ${config.poolAddOethAmount} OETH to the pool`);
log(`Adding ${cfg.poolAddWethAmount} WETH to the pool`);
const wethAmount = parseUnits(cfg.poolAddWethAmount.toString(), 18);
await weth.connect(josh).transfer(supernovaPool.address, wethAmount);
}
// Add OETH to the pool directly.
if (cfg.poolAddOethAmount > 0) {
log(`Adding ${cfg.poolAddOethAmount} OETH to the pool`);

Copilot uses AI. Check for mistakes.
}
}

// Add ETH to the Metapool
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

The comment says "Add ETH to the Metapool" but this is actually adding wS (Wrapped S) to a Sonic SwapX pool, not ETH to a Metapool. The comment should be updated to reflect the actual operation being performed.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

@copilot can you check if this has been fixed? If so, add a comment with the commit

Comment on lines +1377 to +1384
log(`Adding ${config.poolAddOethAmount} WETH to the pool`);
const wethAmount = parseUnits(cfg.poolAddWethAmount.toString(), 18);
await weth.connect(josh).transfer(supernovaPool.address, wethAmount);
}

// Add OETH to the pool directly.
if (cfg.poolAddOethAmount > 0) {
log(`Adding ${config.poolAddOethAmount} OETH to the pool`);
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

The log message says "Adding ${config.poolAddOethAmount} WETH to the pool" but should say "Adding ${cfg.poolAddWethAmount} WETH to the pool". The variable reference is also incorrect - it should use cfg instead of config, and should reference the poolAddWethAmount field instead of poolAddOethAmount.

Suggested change
log(`Adding ${config.poolAddOethAmount} WETH to the pool`);
const wethAmount = parseUnits(cfg.poolAddWethAmount.toString(), 18);
await weth.connect(josh).transfer(supernovaPool.address, wethAmount);
}
// Add OETH to the pool directly.
if (cfg.poolAddOethAmount > 0) {
log(`Adding ${config.poolAddOethAmount} OETH to the pool`);
log(`Adding ${cfg.poolAddWethAmount} WETH to the pool`);
const wethAmount = parseUnits(cfg.poolAddWethAmount.toString(), 18);
await weth.connect(josh).transfer(supernovaPool.address, wethAmount);
}
// Add OETH to the pool directly.
if (cfg.poolAddOethAmount > 0) {
log(`Adding ${cfg.poolAddOethAmount} OETH to the pool`);

Copilot uses AI. Check for mistakes.
naddison36 and others added 5 commits February 24, 2026 09:36
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link

Copilot AI commented Feb 23, 2026

@naddison36 I've opened a new pull request, #2810, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Collaborator

@naddison36 naddison36 left a comment

Choose a reason for hiding this comment

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

I have a separate PR with some changes #2811

*/
constructor(
BaseStrategyConfig memory _baseConfig,
address _oToken,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could add a call to the Vault's oToken to check the _oToken param. The IVault interface is missing the oToken function so that would need to be added.
It also greats a dependency on the OETH Vault upgrade but I don't think that's a bad thing. The Vault could be upgrade at the same time the Supernova Strategy is deployed

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd done this change in PR #2811

/**
* @dev Skim the Algebra pool in case any extra asset or OToken tokens were added
*/
modifier skimPool() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

On Sonic we skimmed the pool on every transaction with value to avoid complications with donation attacks. Gas was not an issue on Sonic so this was an easy tradeoff.

On Ethereum we need to be more careful with gas. Testing
against a Supernova stable pair, skim only used 52k in gas. With gas costs less than 1 Gwei currently on Ethereum, I think this extra call is fine.

test tx 0x5f17572d31f07af38e3cd774103ae33aced687d0f68fb66bc029b3f6899dcf3d

Image

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.

3 participants