Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding swap v2 to generic router #40

Merged
merged 9 commits into from
Sep 23, 2024
Merged

Conversation

SocksNFlops
Copy link
Contributor

@SocksNFlops SocksNFlops commented Jun 7, 2024

Merge pending

  • v2 core being set to public

Changes:

Adding V2 integration into GenericRouter

  • Swap
  • Add
  • Remove

How bytes data is encoded:

bytes memory data = abi.encodePacked(V2, plBps, feeBps);

No matter the representation, the first 8 bits will be used to encode the version.

How bytes data is decoded for V1:

        assembly {
            version := mload(add(data, 0x01))
        }

How bytes data is decoded for V2

function decodeData(bytes memory data) internal pure returns (uint8 version, uint16 plBps, uint16 feeBps) {
        assembly {
            version := mload(add(data, 0x01))
            plBps := mload(add(data, 0x03))
            feeBps := mload(add(data, 0x05))
        }
    }
  • Added V2 support to SWAP and USDM_SWAP operations

Testing:

  • Unit tests for Swap_V2
  • Unit tests for Add Liquidity V2
  • Unit tests for Remove Liquidity V2

Reviewers:

@Fiddlekins

@SocksNFlops SocksNFlops marked this pull request as ready for review September 23, 2024 10:31
@SocksNFlops
Copy link
Contributor Author

forge coverage is failing because of a foundry-issue where forge coverage recompiles the lib-dependencies with different optimizations than they were pre-computed with, whereas forge test and forge create does not.

@SocksNFlops SocksNFlops merged commit 89be756 into main Sep 23, 2024
1 check failed
@SocksNFlops SocksNFlops deleted the adding-swap-v2-to-generic-router branch September 23, 2024 11:20
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.

1 participant