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

feat: bonding manager contract #302

Merged
merged 36 commits into from
May 3, 2024

Conversation

0xFable
Copy link
Contributor

@0xFable 0xFable commented Apr 5, 2024

Description and Motivation

Adds the Bonding-Manager contract. A contract which combines 3 previous contracts; the whale lair, fee collector and fee distributor. Handles the onchain bonding and fee distribution model for the dex.

Related Issues


Checklist:

  • I have read Migaloo's contribution guidelines.
  • My pull request has a sound title and description (not something vague like Update index.md)
  • All existing and new tests are passing.
  • I updated/added relevant documentation.
  • The code is formatted properly cargo fmt --all --.
  • Clippy doesn't report any issues cargo clippy -- -D warnings.
  • I have regenerated the schemas if needed cargo schema.

Copy link

Schema generation had missing jobs:

contracts/liquidity_hub/pool-manager/schema/pool-manager.json
contracts/liquidity_hub/pool-manager/schema/raw/execute.json
contracts/liquidity_hub/pool-manager/schema/raw/response_to_pair.json

Please run just schemas locally and upload the generated schemas.

Copy link

codecov bot commented Apr 15, 2024

Codecov Report

Attention: Patch coverage is 90.63346% with 173 lines in your changes are missing coverage. Please review.

Project coverage is 90.09%. Comparing base (deebeee) to head (0f77427).
Report is 5 commits behind head on release/v2_contracts.

Files Patch % Lines
...ntracts/liquidity_hub/bonding-manager/src/state.rs 36.98% 46 Missing ⚠️
...s/liquidity_hub/bonding-manager/src/tests/robot.rs 83.80% 46 Missing ⚠️
...acts/liquidity_hub/bonding-manager/src/contract.rs 82.26% 25 Missing ⚠️
...racts/liquidity_hub/bonding-manager/src/queries.rs 90.34% 14 Missing ⚠️
...racts/liquidity_hub/bonding-manager/src/helpers.rs 91.45% 10 Missing ⚠️
packages/white-whale-std/src/coin.rs 37.50% 10 Missing ⚠️
packages/white-whale-std/src/bonding_manager.rs 40.00% 6 Missing ⚠️
...acts/liquidity_hub/bonding-manager/src/commands.rs 98.44% 3 Missing ⚠️
...s/white-whale-testing/src/integration/contracts.rs 0.00% 3 Missing ⚠️
.../bonding-manager/src/bin/bonding_manager_schema.rs 0.00% 2 Missing ⚠️
... and 5 more
Additional details and impacted files
@@                   Coverage Diff                    @@
##           release/v2_contracts     #302      +/-   ##
========================================================
+ Coverage                 89.86%   90.09%   +0.23%     
========================================================
  Files                       261      278      +17     
  Lines                     27339    29604    +2265     
========================================================
+ Hits                      24569    26673    +2104     
- Misses                     2770     2931     +161     

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

@0xFable 0xFable force-pushed the feat/bonding-manager-whale-lair branch from 08ac9c5 to 5514594 Compare April 15, 2024 11:55
@0xFable 0xFable marked this pull request as ready for review April 15, 2024 16:21
@0xFable
Copy link
Contributor Author

0xFable commented Apr 15, 2024

This branch needs a lil more work before merge but ready for review
Gonna focus now on:

  • More tests to improve coverage
  • LP Withdraw use case
  • Fix any conflicts after other PRs merge

@0xFable 0xFable force-pushed the feat/bonding-manager-whale-lair branch 5 times, most recently from 607b546 to bafcbf1 Compare April 18, 2024 14:42
Copy link

Schema generation had missing jobs:

contracts/liquidity_hub/bonding-manager/schema/raw/response_to_claimable.json
contracts/liquidity_hub/bonding-manager/schema/raw/response_to_claimable_epochs.json
contracts/liquidity_hub/bonding-manager/schema/bonding-manager.json
contracts/liquidity_hub/bonding-manager/schema/raw/execute.json
contracts/liquidity_hub/bonding-manager/schema/raw/query.json

Please run just schemas locally and upload the generated schemas.

0xFable and others added 2 commits April 18, 2024 22:45
wip: EpochChangedMSG and FillRewards full test

style: satisfy clippy (#327)

* ran `just lint`
* ran `cargo clippy --tests --all -- -D warnings`
@0xFable 0xFable force-pushed the feat/bonding-manager-whale-lair branch from bd3bf63 to 01ddd01 Compare April 18, 2024 21:47
Copy link

Schema generation had missing jobs:


Please run just schemas locally and upload the generated schemas.

Copy link
Contributor

@kerber0x kerber0x left a comment

Choose a reason for hiding this comment

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

Well done! there are a few things that need to be addressed though

contracts/liquidity_hub/bonding-manager/README.md Outdated Show resolved Hide resolved
contracts/liquidity_hub/bonding-manager/src/contract.rs Outdated Show resolved Hide resolved
contracts/liquidity_hub/bonding-manager/src/contract.rs Outdated Show resolved Hide resolved
contracts/liquidity_hub/bonding-manager/src/commands.rs Outdated Show resolved Hide resolved
contracts/liquidity_hub/bonding-manager/src/commands.rs Outdated Show resolved Hide resolved
contracts/liquidity_hub/bonding-manager/src/helpers.rs Outdated Show resolved Hide resolved
contracts/liquidity_hub/bonding-manager/src/helpers.rs Outdated Show resolved Hide resolved
operations: swap_routes.swap_route.swap_operations.clone(),
minimum_receive: Some(simulate.amount),
to: None,
max_spread: Some(Decimal::percent(1)),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think here we want to swap regardless, so we might pump this slippage percentage or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do want to swap regardless but this shouldnt need bumping reason is we are querying the simulation same block so the 1% is more of guard to ensure we dont get less than the query. Because its all happening in one set of messages I think it will never exceed 1% of the queried simulation but we could set it to any value.

@0xFable 0xFable requested a review from nseguias as a code owner May 1, 2024 10:08
@0xFable 0xFable requested a review from kerber0x May 2, 2024 17:33
@0xFable 0xFable changed the title Feat/bonding manager whale lair feat: bonding manager contract May 2, 2024
Copy link
Contributor

@kerber0x kerber0x left a comment

Choose a reason for hiding this comment

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

Looks good overall 💪 Let's get it merged so branches don't diverge too much, then we can refactor and cleanup, write more tests and so on. 👏

@0xFable 0xFable merged commit 34a78d2 into release/v2_contracts May 3, 2024
7 checks passed
@0xFable 0xFable deleted the feat/bonding-manager-whale-lair branch May 3, 2024 09:46
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.

4 participants