-
Notifications
You must be signed in to change notification settings - Fork 0
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
DEV-7. Balance pool: optimizations, redundant logic removed. ValidDelta bug fix #39
Merged
Conversation
This file contains 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
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
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 <[email protected]> --------- Co-authored-by: AOranov <[email protected]> Co-authored-by: Alex Oranov <[email protected]> Co-authored-by: Ilya <[email protected]>
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 <[email protected]> --------- Co-authored-by: AOranov <[email protected]> Co-authored-by: Alex Oranov <[email protected]> Co-authored-by: Ilya <[email protected]>
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.hs
contract we made the following changes:pDen
is reduced from10
to5
to decrease number of exponentiations and required number of significant figures in the values of the involved state variables;checkLength
function, main additions here are:invariantLength
field is added into theBalancePoolConfig
to explicitly pass the number of significant figures of theinvariant
value;lengths
field is added theBalancePoolRedeemer
to 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
;pow10
for calculating exponents with pre-known power values, i.e. calculated fromlengths
.Bug fixes
validDelta
predicate inside theverifyTExpEquality
function is now calculated taking into account the error from rounding calculations (in consistency withnewInvariantIsCorrect
,correctTokenError
andvalidGEquality
predicates).invariant
value is added into thevalidDepositRedeemAllTokens
function to prevent a possible break of the pool due to an incorrectinvariant
value saved in the datum after malicious redeem/deposit actions.