DEV-7. Balance pool: optimizations, redundant logic removed. ValidDelta bug fix#39
Merged
Bromel777 merged 6 commits intodev-7-weighted-pools-cleanupfrom Jun 2, 2024
Merged
Conversation
DEV-7 Weighted pool contracts (Balancer)
Weighted math - easy read Balancer white paper** - hard read** |
f76aea5 to
2fb75ba
Compare
AOranov
approved these changes
Apr 15, 2024
Collaborator
Author
|
waiting audit complete before merge |
…c-flow-in-depositredeem-contracts Dev 567. Fix incorrect logic flow in deposit, redeem contracts
* New approach for balance pools * remove invariant * fix balance contract
Bromel777
added a commit
that referenced
this pull request
Jun 2, 2024
* Balance Pool. Swap, Deposit, Redeem, DepositSingleAsset operations * cleanup * fix treasury validation * Redeem & Swap for random weights and fees fixes. * Fixes and looped test example fixed. * DEV-7. Balance pool. Optimizations (#36) * DEV-7. Balance pools. Deposit, Redeem balance orders contracts (#30) * add daoBalanceMintPolicyValidator * DEV-7. Balance pool: optimizations, redundant logic removed. ValidDelta bug fix (#39) * Balance pool. Optimizations, redundant logic removed, validDelta bug fix * update balanceFeeSwitch * remove redundant variable in ppow10 * Fix incorrect flow in deposit, redeem contracts * Balance pool. New approach (#43) * New approach for balance pools * remove invariant * fix balance contract --------- Co-authored-by: Ilya <ilya.arcadich@gmail.com> --------- Co-authored-by: AOranov <a.oranov@spectrumlabs.fi> Co-authored-by: Alex Oranov <114924866+AOranov@users.noreply.github.com> Co-authored-by: Ilya <ilya.arcadich@gmail.com>
AOranov
added a commit
that referenced
this pull request
Oct 2, 2024
* Balance Pool. Swap, Deposit, Redeem, DepositSingleAsset operations * cleanup * fix treasury validation * Redeem & Swap for random weights and fees fixes. * Fixes and looped test example fixed. * DEV-7. Balance pool. Optimizations (#36) * DEV-7. Balance pools. Deposit, Redeem balance orders contracts (#30) * add daoBalanceMintPolicyValidator * DEV-7. Balance pool: optimizations, redundant logic removed. ValidDelta bug fix (#39) * Balance pool. Optimizations, redundant logic removed, validDelta bug fix * update balanceFeeSwitch * remove redundant variable in ppow10 * Fix incorrect flow in deposit, redeem contracts * Balance pool. New approach (#43) * New approach for balance pools * remove invariant * fix balance contract --------- Co-authored-by: Ilya <ilya.arcadich@gmail.com> --------- Co-authored-by: AOranov <a.oranov@spectrumlabs.fi> Co-authored-by: Alex Oranov <114924866+AOranov@users.noreply.github.com> Co-authored-by: Ilya <ilya.arcadich@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Optimizations
To optimize cpu and memory costs of the swap action validation in the main
PBalancePool.hscontract we made the following changes:pDenis reduced from10to5to decrease number of exponentiations and required number of significant figures in the values of the involved state variables;checkLengthfunction, main additions here are:invariantLengthfield is added into theBalancePoolConfigto explicitly pass the number of significant figures of theinvariantvalue;lengthsfield is added theBalancePoolRedeemerto explicitly pass the number of significant figures of the pool's state variables and off-chain calculated values, namely:gXgYLength,newXBalanceLength,newGXLength,newTxPowLength,newTxPowWeightLength,leftSideLengthX,rightSideLengthX,newYBalanceLength,newGYLength,newTyPowLength,newTyPowWeightLength,leftSideLengthY,rightSideLengthY;pow10for calculating exponents with pre-known power values, i.e. calculated fromlengths.Bug fixes
validDeltapredicate inside theverifyTExpEqualityfunction is now calculated taking into account the error from rounding calculations (in consistency withnewInvariantIsCorrect,correctTokenErrorandvalidGEqualitypredicates).invariantvalue is added into thevalidDepositRedeemAllTokensfunction to prevent a possible break of the pool due to an incorrectinvariantvalue saved in the datum after malicious redeem/deposit actions.