-
Notifications
You must be signed in to change notification settings - Fork 12
Scalable usdc-spot univ3 strategy #231
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
Conversation
Scalable usdc-spot univ3 strategy
🚨 Report Summary
For more details view the full report in OpenZeppelin Code Inspector |
f96c1cb to
fd2a105
Compare
| // IMPORTANT: The deviation percentage, to ticks conversion isn't precise. | ||
| // In the worst case, there might be liquidity up to 2% outside the active zone definition. | ||
| VAULT.setBaseThreshold(deviationToTicks(concBandDeviationWidth)); | ||
| VAULT.setLimitThreshold(deviationToTicks(limitBandDeviationWidth)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can consider removing the limit ranges completely when it's buying above fmv and selling below. It does slightly reduce the opportunity of getting back to 50/50 in the long run, however it also eliminates IL.
But considering the active zone is quite tight to begin with maybe it doesn't matter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we can, we should have the logic make sense independent of configuration. At this stage, it's best if we don't make any assumptions about how tight the active zone is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, rethinking this framing re IL. I think the original implementation makes the most sense. We keep concentrated/limit liquidity when in the active zone and revert to bounded infinite band when outside.
6a626c2 to
d91e547
Compare
e69fd34 to
0e371bc
Compare
d91e547 to
30d1298
Compare
0e371bc to
5f9abfc
Compare
30d1298 to
46ab8dd
Compare
5f9abfc to
56a002d
Compare
2bbb039 to
11487f4
Compare
56a002d to
5689d1e
Compare
11487f4 to
fa33d8a
Compare
| function rebalance() public { | ||
| (uint256 deviation, bool deviationValid) = oracle.spotPriceDeviation(); | ||
| bool withinActiveZone = (deviationValid && activeZone(deviation)); | ||
| bool withinActiveZoneBefore = activeZone(prevDeviation); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider caching the boolean withinActiveZoneBefore, rather than recomputing it from the cached prevDeviation each time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
brandoniles
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Apply suggestions from code review Co-authored-by: Brandon Iles <brandon@fragments.org> review fix caching bool instead of prev deviation
bf2433a to
c9f8780
Compare
* Bump coverallsapp/github-action from 2.3.0 to 2.3.3 (#228) Bumps [coverallsapp/github-action](https://github.com/coverallsapp/github-action) from 2.3.0 to 2.3.3. - [Release notes](https://github.com/coverallsapp/github-action/releases) - [Commits](coverallsapp/github-action@v2.3.0...v2.3.3) --- updated-dependencies: - dependency-name: coverallsapp/github-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * updated cdr pricer (#229) * Deployed v4.1.0 implementations * Bump coverallsapp/github-action from 2.3.3 to 2.3.4 (#230) Bumps [coverallsapp/github-action](https://github.com/coverallsapp/github-action) from 2.3.3 to 2.3.4. - [Release notes](https://github.com/coverallsapp/github-action/releases) - [Commits](coverallsapp/github-action@v2.3.3...v2.3.4) --- updated-dependencies: - dependency-name: coverallsapp/github-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * updated spot subgraph to keep track of vault swap volume * Vault Refactor & Meta Oracle (#224) * removed pricing strategies in favor of meta oracle * Bill broker refactor, using new meta oracle * Charm vault refactor, using new meta oracle * Updated Interfaces and Errors * updated unit tests * code review changes * Scalable usdc spot strategy (#231) Apply suggestions from code review Co-authored-by: Brandon Iles <brandon@fragments.org> review fix caching bool instead of prev deviation * billy subgraph (#234) * Deployed new oracle contract and managers (#233) * deployed new oracle and managers * updated readme * Staking subgraph (#235) * staking subgraph, refreshing store on rebase * charm wampl vault subgraph * adds timestamp to swap events subgraph (#236) * adds timestamp to swap events subgraph Signed-off-by: nms-7 <nixon.ubud@gmail.com> * linting Signed-off-by: nms-7 <nixon.ubud@gmail.com> * fixed null swap creation with 0 timestamp Signed-off-by: nms-7 <nixon.ubud@gmail.com> --------- Signed-off-by: nms-7 <nixon.ubud@gmail.com> * Bump coverallsapp/github-action from 2.3.4 to 2.3.6 (#238) Bumps [coverallsapp/github-action](https://github.com/coverallsapp/github-action) from 2.3.4 to 2.3.6. - [Release notes](https://github.com/coverallsapp/github-action/releases) - [Commits](coverallsapp/github-action@v2.3.4...v2.3.6) --- updated-dependencies: - dependency-name: coverallsapp/github-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bill broker fee curve change (#237) * using fee factor instead of percentages to support -ve fees * unit tests * code review * convergent fee curve * updated charm fee yield logic (#239) * Fee curve update (#232) * fee curve update * code review fixes * Rollover fee curve update (#240) * rollover fee handles undersubscribed vault * bumped up hardhat * code review comments * DR based flash swap fees * comment updates * updated unit tests to use ethers v6, using custom mocking library * updated tasks and deps * updated perp mint fees to be paid to the vault * removed perp share of fees from flash swaps, all fees go to the vault * added configurable dr soft bounds (curve cutoff point) to flash swap fees * updated unit tests * removed rollover fees from perp * Daily Rebalance * updated unit tests * constant rate enrichment/debasement * mint2, redeem2 * added linked library to limit contract size * unit tests * melding perps immediately after rebalance * Apply suggestions from code review Suggestions Co-authored-by: Brandon Iles <brandon@fragments.org> * Update spot-contracts/contracts/FeePolicy.sol Co-authored-by: Brandon Iles <brandon@fragments.org> * code review fixes * code review fixes v2 * code review fixes v3 * code review v4 * during rebalance, vault pays perps by transferring tranches into perp's reserve * rebalance eql * configurable rebalance freq * code review v5 * Apply suggestions from code review Co-authored-by: Brandon Iles <brandon@fragments.org> * code review fixes * Code review fixes Co-authored-by: Brandon Iles <brandon@fragments.org> * bill broker single sided deposit fix (#253) * Dev Audit Changes (#252) * fee policy restructure * updated perp fee and rebalance handling, audit cleanup * updated vault fee and rebalance handling, audit cleanup * interface and lib updates * updated unit tests * code review fixes #1 * code review fixes #2 * code review fix #3 * Removed subscription ratio for a global vault:perp tvl (or system ratio) (#254) * Using a system ratio target * using system state to calculate fees * using system state for fees and removed subscription liquidity check * interface updates * unit test updates * rename * updated deps --------- Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: nms-7 <nixon.ubud@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: nms-7 <57442379+nms-7@users.noreply.github.com> Co-authored-by: Brandon Iles <brandon@fragments.org>
An new alpha vault strategy for spot-usdc which is scalable and can provide deep concentrated liquidity around SPOT's fmv.