-
Notifications
You must be signed in to change notification settings - Fork 3
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
Bid sort implementation #79
Closed
Closed
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
* New helpers and facade functions (#32) * Helpers Update * fix: returns for helpers * add custom deposit n * More helpers * Helpers refactor internal * Fix other helpers * Typo * Helpers updated * fix bug and left comment for okhai * added helper to vault facade * Testing events (#33) * Formatting scarb fmt + rm whitespace * formatting + comment making note to utilize function calls to returning false/true instead of reverting * formatting + test todo comment * remove unneeded line from test was not removed when implementing accelerator/helper * moved test into correct file * formatting whitespace * updates to utils.cairo (events) - refined imports - updated event testers to search for events on correct contracts - added event test helpers for clearing the event log for a contract * pass contract addresses to event testers * pass contract addresses to event helpers also changed name of test for clarification * formatting, removed removed import * update utils.cairo - cleaned up code lines using loops - modified clear_event_logs to take an array of addresses - removed drop_event, not used anywhere - added some comments * update bidding_tests.cairo - cleaned up imports - added event assertions for bids accepted/rejected - added notes to test_lock_of_bids, function test should be changed - fixed bug in this test as well (eth bal assertions) - added specific test for asserting accepted bid events * remove event assertions these take place in the bidding_tests.cairo file now * added clear event logs for testing, and increased gas limit * increased gas limits * Update option_round.cairo - Changed AuctionSettle to AuctionEnd to match docs better - Refined events to match friday's call - Added function for event testing, can be removed now, or kept for now * update vault.cairo - changed events to match friday's call - added function for event testing, can be removed or kept for now. * update utils.cairo - fixed option_bidders_get() to return option bidder addresses - added generic function to check if 2 events are equal - fixed event assertion functions to correctly check for matches * update bidding tests event assertions * formatting rm whitespace * added test for withdrawing payout event -also cleaned some imports and added note/question about if events should fire if the withdraw fails or is for 0 amount * remove unneccessary eth transfer check * Changed VaultTransfer struct Added balance_before member * rm unneed event tester * added return for collect_premiums facade function Should return the amount collected * added event tester for collecting premiums * changed auction settle to auction end * added notes for tests to add * Add eth transfer and event tests for collect unused bids * update mock emissions to new structure * refined imports and moved event assertion to utils.cairo * formatting * add note for test to add * refine initializing_params_tests.cairo -refined imports - noticed error in test and left notes for it * Added test to check event testers work as expected * cleaned and added notes to option_round contract * moved event definitions into contract * Updated imports for vault event definitions moving * formatting (scarb fmt) * Added note to return to test Check math/precision of following lines. * updated previous note instances where the ratio is used to calculate an account's amount like this should all be double checked, maybe a helper could be added for repeated calcs * refined a note * added test for deposit events * Added note about possibly removing event memeber * commented out previously mention member in tests * added auction start event tests * added auction end event test * added notes about withdraw event tests Should wait to add these once we decide how if we are using just 1 withdraw function, or a withdraw and collect (premiums) functions * removed duplicated event assertion call * added missing event test for collecting unused bids * added comments, reformatted * rm duplicated event assertion call * [test]: option round refactored (#34) * [tests]: acceslerators added for payout tests, also added one accelerator for settling * [test]: unused bids tests refactored * [test]: added liquidity provider utility to the premium tests * [test]: premium tests refactored * formatted the code --------- Co-authored-by: Matt Carter <[email protected]> * Feat/vault test accelerators (#35) * Vault Tests * Remove extra helpers --------- Co-authored-by: Matt Carter <[email protected]> * fixed bugs from sync * Event simplification (#38) * updated vault events/tests * update vault events * remove a market aggregator duplicate * remove mkt agg from round, only needed in vault * formatting/comments * updated withdraw test * remove collect unallocated entry point in vault * updated option round event testers * remove unneeded vault transfer event * updated event testers for option round * update event testers for option round * updated total liquidity to starting liquidity need to work in this logic to all unallocated/collateral tests * update option round contract * remove unneeded helper also added mock market agg getters/setters on vault facade * update market agg interface better aligned with future fossil integration * removed ...settle since ...settled is already here remove duplicated accelerator function * update option round facade added getters for round start and end date * remove duplicated accelerator * update deployment tests worked in market agg facade getter * worked in some accelerators * cleaned mkt agg contracts * Dismantle option round params (#39) * updated vault events/tests * update vault events * remove a market aggregator duplicate * remove mkt agg from round, only needed in vault * formatting/comments * updated withdraw test * remove collect unallocated entry point in vault * updated option round event testers * remove unneeded vault transfer event * updated event testers for option round * update event testers for option round * updated total liquidity to starting liquidity need to work in this logic to all unallocated/collateral tests * update option round contract * remove unneeded helper also added mock market agg getters/setters on vault facade * update market agg interface better aligned with future fossil integration * removed ...settle since ...settled is already here remove duplicated accelerator function * update option round facade added getters for round start and end date * remove duplicated accelerator * update deployment tests worked in market agg facade getter * worked in some accelerators * cleaned mkt agg contracts * broke apart OptionRoundParams added getters for each member instead of a single object * update tests to dropped OptionRoundParams Removed imports for OptionRoundParams from option_round * update test to use facades not dispatchers * added OptionRoundParams for testing purposes Can use the old struct within facade to reduce overhead of switching all tests over. * drop comment * Test Refactored (#36) * accelerator added for event test in payout tests * test refactor for option round unused bids * accelerators added to options sold tests * refactored the tests for accelerate to auctioning * test refactored for clearing price tests * removed warnings * deposit tests updated and comment resolution * resolved comments --------- Co-authored-by: Matt Carter <[email protected]> * fixed sync bugs * Updated funds location and transfers (#41) * added notes for checkout * fixed bug in test should be last OBs bid because they out bid everyone, minting all options * formatting * added simpler facade replacements to work in over time * added simpler entry points to vault can work in over time * update test to use simpler entry points * cleaned up auction start test cairo * formatting and whitespace * Update auction_end_tests.cairo - refined tests with accelerators - added note about a test being in wrong file - added tests for premiums eth transfer to vault - added another test to make sure eth transfers to unlocked pool and for lps * remove unneccessary param in settle option round * refined option settle tests removed complex test helpers and simplified using updated $ location logic added test for eth transfer when round settles (from vault::locked to option round) added tests for checking total and LP locked/unlocked balances update correctly * added note for more complex test todo * cleaned up some tests * remove duplicated test test was previously moved to unused_bids_tests.cairo * formatting * remove unneeded test also added more coverage to test for deposits always into unlocked pool * add comment for clarity * added missing accelerators * updated comment for test * update OptionRound::settle_option_round added input param for settlement_price also added start_auction to option round facade * start tests for option round access control only the vault should be able to start/end an auction and settle and option round * fix bugs vault should always be the target for state transition functions * Withdraw Tests (#40) * Withdraw Tests * Formatting * Rename * Update functions * LP tests * Sort utils (#42) * updated variable names * formatting (scarb fmt) * removed similar entry points, updated facade * added place holder to get lp token tests to compile * moved event testers/helpers to new file and fixed imports * moved more utils to new files and fixed imports * removed unneeded variables * moved variables from utils to new file in utils/ * moved last of utils functions to new file * moved facades & mocks to new location fixed all imports as well * remove old files * move only withdraw test file from unneeded directory * relocated/sorted more files and directories updated imports and package files * updated name for plural helper to match singluar * commented out parts of tests that were throwing errors To return to if we return to lp token route * switch facade to using correct getters * commented out parts of tests to return to if we come back to LP token route * reorganized option round facade * update names of facade functions * comment out unneeded event test * re-organized vault facade * reorganized and stripped unused functions from vault * update vault entry point name * organized option round contract removed unneeded entry points * update contract function name * remove unneeded entry point on vault * more organization for vault contract * added plural versions to functions on facade plus formatting * update accelerators * Result returns (#43) * updated state transition functions to return results * update facades to handle results * updated auction end to also return total options sold * formatting rm unused comment * updated return to results * fixed comments * time skip functions added to accelerators (#44) * time skip functions added to accelerators * removing extra comments --------- Co-authored-by: Mohit Dhattarwal <[email protected]> --------- Co-authored-by: Mohit Dhattarwal <[email protected]> * Overview cleanup matt (#45) * update vault.cairo removed comment moved VaultType into contract refined imports * update option round moved option round: state enum, constructor args struct, and auction start struct into contract fixed/refined imports * formatting * created bystander to call state trans. functions * fix return types for accelerate to running * refine, clean, fix accelerators * update return of accelerator should not return deposit total, should return entry point return added function to calculate sum of a span (used for deposit total) * formatting/remove comments * started sanity checks assert that (write) function returns match their corresponding state-var/getter * update accelerators to make sure all have returns * update return type to make other functions * formatting/rm old comments * moved event testers into sanity checks file * re ordered OR_facade::place_bids params to match place_bid also added helper function to assert two arrays are the same length * updated vault_facade - added bystander as calling account * update vault.cairo clarified that the return of deposit/withdraw is the LP's unlocked balance post txn * modified sanity checks now they happen upon each entry point call, so further tests are not needed * implemented sanity checks into option round facade * implemented sanity checks to vault facade * added helpers to accelerators (they need to be in a separate file) added functions to sum an array of lp spreads, and split an array of spreads into a locked and unlocked array * update function name from span to array * adjusted return for vault::deposit/withdraw now they each return the user's locked/unlocked balance post txn updated facade and sanity checks * updated an auction start test to take advantage of the new deposit returns * move array helpers to utils/utils.cairo updated imports * added erc20 balance helpers get an address's balance or an array of address' balances * update get_lp_balance_spreads now it returns Array<(u256, u256)> instead of two Array<u256>s * refined logic in deposit_tests.cairo * fixed return * update state transition tests instead of testing a random address cannot call state transition functions on option round, we are testing that another vault cannot call on a round it didnt deploy * modified vault deployer now the deployed address is dependent on the time so we can get different deployment addresses if needed * formatting * made params for deposit multiple match deposit single * cleaned and re-organized deposit&withdraw tests * refine test_unlocked_becomes_locked notes for additional test boiler plate for same refinement in auction end tests * started helper for getting portion of an amount an lp owns * refine/re organize auction start tests * added more helpers to accelerators added timeskip and do nothing functions * update comments * fixed ordering of getters to prevent unexpected behavior * refine auction end tests * reorganized accelerators and cleaned comments * refined complex auction end test * cleaned auction start/end event tests * commented out unnecessary test file * refine option_settle_tests * remove old comments * organize withdraw tests * cleaned up deposit/withdraw tests more * added helper for span->array * simplified auction end test * added more coverage to auction end complex spread test * added more coverage to auction end spread complex test * formatting * formatting/comments * optimized option settle spread tests matching format of auction start/end spread tests * commented out sanity checks otherwise all test would return these failure msgs * formatting * added getters for constructor params used in deployment tests * remove old file * added note to deployment tests mock marget agg needs both getter and setter traits * added getter for vault::vault_manager address * reorganized test module * added more array helpers one to multiply each element in an array by scalar and one to multiply each element in an array by the one at the same index in another, returning the multiplied array * moved and optimized bidding tests * added raw entry points to OR facade allow us to bypass the facades default panic for failed bids * comments and formatting * removed raw place bid call within panicable place bid * fixed bid rejected event tests now the event assertions can be reached, an the tests are no longer tagged with should_panic * moved refunding bid test to correct file * cleaned/refined unused_bids test * move comment * cleaned exercise_options_tests * cleaned comments * changed unused bids to pending and refunded bids * updated pending/refunded bid tests started using test setups/helpers for making tests have better readability * updated refunded to refundable amount * restructured tests, they need to be broken up into separate files * cleaned auction start/end tests * updated test names * refined option settle tests * refined deposit and withdraw tests * added comment about initialized state * formatting and variable name updates * update deposit and withdraw return types changed from (updated locked, updated_unlocked) to just updated_unlocked - updated facades - added notes for tasks * remove old comment and test * update test name from refunded to refundable * added notes for actions to test files * update caller_is_not_vault_tests.cairo * added actions note * added notes for todos * added notes for todos * formatting * Mohit/cleanup (#46) * added contracts to sub module * formatted code --------- Co-authored-by: Mohit Dhattarwal <[email protected]> * bid structure updated * obs changed to option_bidders * lps changed to liquidity_providers * rtp changed to round_transition_period * lps changed to liquidity provider v2 * renamed create_default_option_amount_array to create_linear_options_array * Starting away notes/matt (#49) * started notese for implementation * added TODO to clearing price tests * more notes for clearing price tests * added more notes for tasks --------- Co-authored-by: Matt Carter <[email protected]> * Errors and panics Usage (#47) * Errors and panics * Format * Refund test update * Edits * Remove old tests, fix errors * Update" * expanded option round errors and updated tests accordingly (#51) * refactored for already existing function, removed identical function * Update options_minted_tests.cairo Added notes about tasks * New bid structure (#50) * New bid structure * Add function to facade * Update place bids * Compilation errors * Add test * Add flag to bid struct * Hash test * Feat/update bids (#52) * New bid structure * Add function to facade * Update place bids * Compilation errors * Add test * Add flag to bid struct * Hash test * Updates * Feat/task 6 (#53) * Utils * Formatting * resolved issues * refactored code as per the updated bid structure * resolved bugs after conflict resolution * Matt task 4 and 7 (#55) * renamed file * updated options minted tests file name to option distribution tests * added to StartAuctionParmas also added get option balance for to facade * created array gradient helper for decreasing step * cleaned up and added to option distribution tests made it easier to add real number auction testing * added a cleaned a test for clearing price tests need to work continue working on this file * Cleaning clearing price tests (#56) * added another test to option distribution tests * refined clearing price tests * added more real number tests for auction * cleaned up comments * updated comments on option round contract * cleaned bidding tests * foramatting * added 2 pending->refundable bid tests * modified create_linear_array to be for arbitrary types * formatting * update return type for pending bids previously pending bids returned the amount of eth that was pending in the auction now it returns the bid ids for the bids that are pending in the auction * update get nonce to get bidding nonce * task 6.05, moved weth_owner & vault_manager into test accounts from variables * fix comment * update comment * Feat/task 5.2 dhruv (#57) * setup functions * Undo edit * created tokenize_options entry point and tests * scarb fmt * remove unnecessary comments/imports * Update crash course (#58) * created tokenize_options entry point and tests * scarb fmt * remove unnecessary comments/imports * Update documentation.md * update deposit flow (#59) * update deposit flow now anyone can deposit on the behalf of anyone else * update entry point names to be more consistent * remove sum/split spreads (#61) * Fixing missed merges (#62) * formatting * added tests (to discuss later) deals with if a bid is updated to cost more ETH, but lower price or amount what should happen * added default error to update bid errors * started note for Mohit/Dhruv's point about refundable bids Not sure I fully understood the question/edge case, leaving to come back to * old comment removed * re ordered utils file, rm old functions * remove imports for rmed functions * remove sum/split spreads * formatting * remove old file * Update flow (#63) * fixed location when next round deployed event fires * update flow and loop mechanics for state transition tests * adjusted entry point params Preparing for implementation * fixed params for option_round::start_auction * moved custom option round accelerator to accelerators and updated imports * updated start auction entry point params Now the vault passes the total options available and the starting liquidity * change get_lp_balance_spread function name * update the rest of the spread getter names somehow these changes were lost * added notes for tasks * Start auction (#64) * Start auction * Getters * Edits * Bug writes * Remove prints * format and clean * Phase a end auction (#65) * added internal function for asserting caller is the vault * update caller is vault check to throw proper error * quick update for team * fix erc20 dispatcher bugs * finished task * added eth address getter and test * fixed auction end getters * Auction start and end sync fixes (#66) * added internal function for asserting caller is the vault * update caller is vault check to throw proper error * quick update for team * fix erc20 dispatcher bugs * finished task * added eth address getter and test * fixed auction end getters * scarb fmt * Update vault.cairo change calculate_options -> calcualte_total_options_available made start_auction and end_auction logic flow's match * update getter name in facade * update option round matched auction start and auction end formats * deposit liquidity function added * scarb fmt * fixed bug in helper function loop was missing from get_total_bid_amounts * update Vault::deposit_liquidity() Matching similar flow/declarations to start/end auction * update return on deposit to save gas * remove print line * clean up approval setting * remove comments --------- Co-authored-by: mohiiit <[email protected]> Co-authored-by: Mohit Dhattarwal <[email protected]> * Feat/settle auction (#68) * Settle round Updates * Settle round updates round contract * Formatting * Edit, format * Errors * Contract utils, update name * Remove test utils min/max * FMT * Cleaning option settle task (#69) * update contracts - match flow of start/end auction - updated name for & refined deploy_next_round() * updated payout calculation to avoid overflow issues * update variable names * formatting * started event assertion fix not completed, was testing if discord fix works * increased gas limits for test * Liquidity provider balance getters (#70) * added some preliminary notes * update vault.cairo -update internal functions to use contract references when no writing is happening - added notes for withdraw task - started loose implementation for calculating postition values * implemented get_lp_unlocked_liquidity * implement get lp locked balance * refine code logic * GitHub actions on every branch (#72) * Update test.yaml Run test suite on every branch * update branch to match ALL branch names * Fixing deposit tests (#71) * updated mock values to avoid sub overflow until implementation is written all accelerators will throw a u256_sub_overflow error * fixed bug in function calculate_value_of_position_from_round_to_checkpoint had bugs - needed to account for the ending round being 0 - forgot to add i += 1 to loop - needed to account for checkpoint being 0 * uncommented out sanity check for deposits * update the caller of deposit from bystander to each liquidity provider * increase gas limit for test and fix comment * increase gas limits for tests to fix break * increase gas limits to stop tests breaking * added note to fix test helper * moved old test file to misc/ * Fixed bug in function Assert ending round is Settled was lost in the merges * Increase gas limts for tests * Increase gas limits for tests * update vault implementation - re formatted deposit_liquidity - added internal version of get_lp_unlocked_balance to return the balance as its components instead of the full total * formatting * add getter for round's id * add getter for round transition period also added withdraw_raw facade function * increase gas limits for tests * fix infinite loops in accelerators * clean up event helpers dropped need for manual creation * update auction end tests added checks to tests to make sure they fail until later implementation is added * fixed error handling for withdraw tests also added a call to clear event logs before testing events * fixed error handling and bug in auction start tests * fixed bugs and updated option settle tests added assertions to make sure tests fail until later implementation is added * made withdraw sanity check run * rm commented line * Feat/entry params (#74) * Params example * Update time to remove delays * Update error * Remove reads * New params data --------- Co-authored-by: Matt Carter <[email protected]> * Updating comments (#75) * added some preliminary notes * update vault.cairo -update internal functions to use contract references when no writing is happening - added notes for withdraw task - started loose implementation for calculating postition values * implemented get_lp_unlocked_liquidity * implement get lp locked balance * refine code logic * GitHub actions on every branch (#72) * Update test.yaml Run test suite on every branch * update branch to match ALL branch names * Fixing deposit tests (#71) * updated mock values to avoid sub overflow until implementation is written all accelerators will throw a u256_sub_overflow error * fixed bug in function calculate_value_of_position_from_round_to_checkpoint had bugs - needed to account for the ending round being 0 - forgot to add i += 1 to loop - needed to account for checkpoint being 0 * uncommented out sanity check for deposits * update the caller of deposit from bystander to each liquidity provider * increase gas limit for test and fix comment * increase gas limits for tests to fix break * increase gas limits to stop tests breaking * added note to fix test helper * moved old test file to misc/ * Fixed bug in function Assert ending round is Settled was lost in the merges * Increase gas limts for tests * Increase gas limits for tests * update vault implementation - re formatted deposit_liquidity - added internal version of get_lp_unlocked_balance to return the balance as its components instead of the full total * formatting * add getter for round's id * add getter for round transition period also added withdraw_raw facade function * increase gas limits for tests * fix infinite loops in accelerators * clean up event helpers dropped need for manual creation * update auction end tests added checks to tests to make sure they fail until later implementation is added * fixed error handling for withdraw tests also added a call to clear event logs before testing events * fixed error handling and bug in auction start tests * fixed bugs and updated option settle tests added assertions to make sure tests fail until later implementation is added * made withdraw sanity check run * rm commented line * Update vault.cairo -cleaned comments -updated get_upcoming_round_id to take a snapshot of the current round, instead of a reference * added comment * Katana addition (#77) * testing katana on CI * testing script with katana * fixing yaml file * fix script v1 * fix script v2 * fix script v3 * fix script v4 * testing eth deployment v1 * declare and deploy eth contract * added notes * Cleanup sync 7 2 matt (#76) * Update option_round.cairo - update settle option round to use struct for params - de-structure the state transition params to ensure no values are missed - added strike price to StartAuctionParams - Cleaned some comments * Update vault.cairo - fixed reserve price/cap level/strike price fetching to use independent getters - re ordered functions to fit together better * formatting (scarb fmt) * updated imports/input args to updated functions * Update option_round.cairo - add additional bidding error - added comments * Update vault.cairo - added comments - re-org function order to have similar functions together --------- Co-authored-by: Dhruv Gupta <[email protected]> Co-authored-by: Mohit Dhattarwal <[email protected]> Co-authored-by: mohiiit <[email protected]>
Added to use for RB tree component
0xDegenDeveloper
commented
Jul 4, 2024
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.
Checked
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.
Added implementation for PartialOrd & PartialEq for Bids (allows us to use <, <=, >, >=, ==).
This is to be used with the formal bid struct once the RB-tree component is injected into contract.