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

Add Inverted Quoter for AMO fork test. #2210

Merged
merged 31 commits into from
Sep 30, 2024
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d29dc6f
feat: add inverted quoter for rebalancing.
clement-ux Aug 29, 2024
4e9d161
test: use quoter for AMO rebalancing.
clement-ux Aug 29, 2024
8810a77
chore: increase gas limit for test for AMO quoter.
clement-ux Aug 29, 2024
5e7df11
fix: remove arguments from quoter call.
clement-ux Aug 30, 2024
9b91a6a
fix: set strategist back to origin strategist for quoter.
clement-ux Aug 31, 2024
585b40a
feat: add AMO quoter for `amountToSwapToReachPrice`.
clement-ux Aug 31, 2024
4390da3
feat: add quoter for moving price in AMO tests and upgrade swap funct…
clement-ux Aug 31, 2024
aea2198
docs: add descriptions to functions.
clement-ux Sep 4, 2024
bf51ef9
feat: add `overrideWethShare` on `quoteAmountToSwapBeforeRebalance`.
clement-ux Sep 4, 2024
c502ed6
fix: use dictionnary syntax to call function that has same name as an…
clement-ux Sep 4, 2024
7383e79
fix: increase max iteration for quoter.
clement-ux Sep 9, 2024
ffa2d8e
fix: failling test.
clement-ux Sep 9, 2024
280f6b4
fix: move AMOQuoter to fixture.
clement-ux Sep 11, 2024
8abb412
feat: add more comments.
clement-ux Sep 11, 2024
3e076b9
fix: rethink variance calculation for AMO Quoter.
clement-ux Sep 11, 2024
a4d585b
fix: give more WETH at start and simplifies swap.
clement-ux Sep 11, 2024
ef2bf26
fix: remove unused import.
clement-ux Sep 11, 2024
2d663be
fix: _minTokenReceived is 99% of amountToSwap.
clement-ux Sep 11, 2024
80d115b
fix: refactor % comparison.
clement-ux Sep 11, 2024
6b72dc9
fix: change public into internal.
clement-ux Sep 16, 2024
944bb28
fix: adjust quoteAmountToSwapBeforeRebalance for custom shares.
clement-ux Sep 16, 2024
26035cc
fix: split boundaries for quoter.
clement-ux Sep 16, 2024
ea44472
fix: fetch governor before impersonning.
clement-ux Sep 16, 2024
d6d386a
fix: increase tolereance eth remaining in AMO after withdraw.
clement-ux Sep 16, 2024
aa3bb5b
fix: fix failing test and add description.
clement-ux Sep 16, 2024
29c18b5
fix: add doc for edge case in withdraw.
clement-ux Sep 17, 2024
f1c84b0
Merge branch 'master' into clement/add-quoter-for-AMO-fork-tests
clement-ux Sep 18, 2024
10e1ba8
fix: adjust test with latest values.
clement-ux Sep 18, 2024
920099b
Merge remote-tracking branch 'origin/master' into clement/add-quoter-…
sparrowDom Sep 24, 2024
8dce05e
Fix issues with fork testing (#2255)
sparrowDom Sep 30, 2024
d146df8
Merge remote-tracking branch 'origin/master' into clement/add-quoter-…
sparrowDom Sep 30, 2024
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
13 changes: 6 additions & 7 deletions contracts/contracts/utils/AerodromeAMOQuoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ contract QuoterHelper {
uint256 public constant BINARY_MIN_AMOUNT = 0.000_000_01 ether;
uint256 public constant BINARY_MAX_AMOUNT = 1_000 ether;
uint256 public constant BINARY_MAX_ITERATIONS = 100;
uint256 public constant PERCENTAGE_BASE = 1e27; // 100%
uint256 public constant ALLOWED_VARIANCE_PERCENTAGE = 1e18; // 1%
uint256 public constant PERCENTAGE_BASE = 1e18; // 100%
uint256 public constant ALLOWED_VARIANCE_PERCENTAGE = 1e16; // 1%

////////////////////////////////////////////////////////////////
/// --- VARIABLES STORAGE
Expand Down Expand Up @@ -390,13 +390,12 @@ contract QuoterHelper {
function isWithinAllowedVariance(
uint160 sqrtPriceCurrentX96,
uint160 sqrtPriceTargetX96
) public pure returns (bool) {
uint256 allowedVariance = (sqrtPriceTargetX96 *
ALLOWED_VARIANCE_PERCENTAGE) / PERCENTAGE_BASE;
) public view returns (bool) {
uint160 range = strategy.sqrtRatioX96TickHigher() - strategy.sqrtRatioX96TickLower();
if (sqrtPriceCurrentX96 > sqrtPriceTargetX96) {
return sqrtPriceCurrentX96 - sqrtPriceTargetX96 <= allowedVariance;
return (sqrtPriceCurrentX96 - sqrtPriceTargetX96) * PERCENTAGE_BASE <= ALLOWED_VARIANCE_PERCENTAGE * range;
Copy link
Member

Choose a reason for hiding this comment

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

cool that makes sense.
nit: Maybe a slightly more "natural" way to express it would be:

return (sqrtPriceCurrentX96 - sqrtPriceTargetX96)  <=  range * ALLOWED_VARIANCE_PERCENTAGE / PERCENTAGE_BASE;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I agree, I was to avoid rounding issue. But I've no problem to change it.

} else {
return sqrtPriceTargetX96 - sqrtPriceCurrentX96 <= allowedVariance;
return (sqrtPriceTargetX96 - sqrtPriceCurrentX96) * PERCENTAGE_BASE <= ALLOWED_VARIANCE_PERCENTAGE * range;
}
}

sparrowDom marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading