Skip to content

Commit

Permalink
Feat withdrawl queue (#160)
Browse files Browse the repository at this point in the history
* reorder tests.cairo

* formatting

* added test for bidding when reserve price is 0

* divide with precision in option round

* created divide_with_precision helper

* integrated divide_with_precision into tests/files

* added unsold liquidity to option round instead of vault

* updated precision to 100 points

* formatting

* added withdrawal queueing

started some prelim tests

* formatting

* comment rm

* refactored logic to be simpler

* bug fix and remove old code

* cleaned option contract more

* added additional test for withdraw queues

* remove old comments, added clarity comments

* update entry point names

* added realize position helper function

* updated entry point name and storage var

- withdraw_stashed_liquidity -> claim_queued_liquidity

- lp_stashes: (bool, u256) -> u256

* copied Sameer's GH changes so it will be on dev

* updated queue_withdrawal params

added amount so that the user can select the portion they want stashed once the round settles, and can overwrite if they want to update this value

* formatting

* increase gas limit on test

* added amount to interface for queue_withdrawal

* update vault contract

- re-order functions in impl

- updated queueing to take in the an amount param

- re-defined/re-factored internal helper functions

- simplified external functions

* fix gas usage bug in test

* fix bug in test

* simplify conditional exits

* refine logic

* refine

* bug fix in test

* update storage var names and entry point names

* bug fix

* added range assertions

- assert if a == b +- range

* rm divide with precision

* updated decimals to 0 in option erc20

* added get_lp_queued_balance(s) to facade

* added get_lp_starting_balance to vault

* cleaned vault contract

rm divide with precision

rm old comments

re order logic

* fixed defaul mk agg params in setup

* added withdrawal queue tests

* added error for queueing > 100% position starting value

* updated params for 2 getters

get_lp_queued_balance & get_total_queued_balance now accept round_ids

* added events and event tests

for withdraw_queued & claim_queued_liquidity

* update naming for event

* update ABIs

* added internal helper and fixed / 0 bug

* formatting

* cleaned market agg interface

reserve price, cap level, & volatility are now stored by round instead of time range

TWAP is still time range

* fixed settlement price being too small in tests

* started logic for calculating strike price on chain

added tests as well

* fix general helper to avoid sub overflow

* Update setup.cairo

refined logic for setting default values for mock market aggregator

created function to deploy vault facades with a custom VaultType

* Update contract.cairo

- update connection to mk agg
- broke apart deploying first round vs next round (for now)

* update abis

* Update smoke tests

* Smoke Tests fix

---------

Co-authored-by: Dhruv Gupta <[email protected]>
  • Loading branch information
0xDegenDeveloper and dhruv035 authored Aug 26, 2024
1 parent 7e07335 commit c9a8798
Show file tree
Hide file tree
Showing 54 changed files with 3,230 additions and 1,685 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/rb_tree_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ jobs:
- name: Test the code
run: |
# Run the test and capture the output
output=$(scarb test -f rb_tree_tests --include-ignored)
output=$(scarb test -f rb_tree_tests --include-ignored 2>&1) || true
# Echo the entire output (optional, for debugging purposes)
echo "$output"
# Filter and echo the specific part of the output you are interested in
echo "$output" | grep -E "Error: test result: FAILED. [0-9]+ passed; [0-9]+ failed; [0-9]+ ignored"
# Check if there were any failed tests
if echo "$output" | grep -q "test result: ok"; then
exit 0
else
exit 1
fi
11 changes: 7 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ jobs:
- name: Test the code
run: |
# Run the test and capture the output
output=$(scarb test)
output=$(scarb test 2>&1) || true
# Echo the entire output (optional, for debugging purposes)
echo "$output"
# Filter and echo the specific part of the output you are interested in
echo "$output" | grep -E "Error: test result: FAILED. [0-9]+ passed; [0-9]+ failed; [0-9]+ ignored"
# Check if there were any failed tests
if echo "$output" | grep -q "test result: ok"; then
exit 0
else
exit 1
fi
204 changes: 42 additions & 162 deletions scripts/abi/marketAggregator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,7 @@ export const ABI = [
"items": [
{
"type": "function",
"name": "get_reserve_price_for_time_period",
"inputs": [
{
"name": "from",
"type": "core::integer::u64"
},
{
"name": "to",
"type": "core::integer::u64"
}
],
"outputs": [
{
"type": "core::option::Option::<core::integer::u256>"
}
],
"state_mutability": "view"
},
{
"type": "function",
"name": "get_reserve_price_for_block_period",
"name": "get_TWAP_for_block_period",
"inputs": [
{
"name": "from",
Expand All @@ -92,47 +72,7 @@ export const ABI = [
},
{
"type": "function",
"name": "get_cap_level_for_time_period",
"inputs": [
{
"name": "from",
"type": "core::integer::u64"
},
{
"name": "to",
"type": "core::integer::u64"
}
],
"outputs": [
{
"type": "core::option::Option::<core::integer::u128>"
}
],
"state_mutability": "view"
},
{
"type": "function",
"name": "get_cap_level_for_block_period",
"inputs": [
{
"name": "from",
"type": "core::integer::u64"
},
{
"name": "to",
"type": "core::integer::u64"
}
],
"outputs": [
{
"type": "core::option::Option::<core::integer::u128>"
}
],
"state_mutability": "view"
},
{
"type": "function",
"name": "get_strike_price_for_time_period",
"name": "get_TWAP_for_time_period",
"inputs": [
{
"name": "from",
Expand All @@ -152,15 +92,15 @@ export const ABI = [
},
{
"type": "function",
"name": "get_strike_price_for_block_period",
"name": "get_reserve_price_for_round",
"inputs": [
{
"name": "from",
"type": "core::integer::u64"
"name": "vault_address",
"type": "core::starknet::contract_address::ContractAddress"
},
{
"name": "to",
"type": "core::integer::u64"
"name": "round_id",
"type": "core::integer::u256"
}
],
"outputs": [
Expand All @@ -172,40 +112,40 @@ export const ABI = [
},
{
"type": "function",
"name": "get_TWAP_for_block_period",
"name": "get_volatility_for_round",
"inputs": [
{
"name": "from",
"type": "core::integer::u64"
"name": "vault_address",
"type": "core::starknet::contract_address::ContractAddress"
},
{
"name": "to",
"type": "core::integer::u64"
"name": "round_id",
"type": "core::integer::u256"
}
],
"outputs": [
{
"type": "core::option::Option::<core::integer::u256>"
"type": "core::option::Option::<core::integer::u128>"
}
],
"state_mutability": "view"
},
{
"type": "function",
"name": "get_TWAP_for_time_period",
"name": "get_cap_level_for_round",
"inputs": [
{
"name": "from",
"type": "core::integer::u64"
"name": "vault_address",
"type": "core::starknet::contract_address::ContractAddress"
},
{
"name": "to",
"type": "core::integer::u64"
"name": "round_id",
"type": "core::integer::u256"
}
],
"outputs": [
{
"type": "core::option::Option::<core::integer::u256>"
"type": "core::option::Option::<core::integer::u128>"
}
],
"state_mutability": "view"
Expand All @@ -223,7 +163,7 @@ export const ABI = [
"items": [
{
"type": "function",
"name": "set_reserve_price_for_time_period",
"name": "set_TWAP_for_block_period",
"inputs": [
{
"name": "from",
Expand All @@ -234,7 +174,7 @@ export const ABI = [
"type": "core::integer::u64"
},
{
"name": "reserve_price",
"name": "TWAP",
"type": "core::integer::u256"
}
],
Expand All @@ -243,7 +183,7 @@ export const ABI = [
},
{
"type": "function",
"name": "set_reserve_price_for_block_period",
"name": "set_TWAP_for_time_period",
"inputs": [
{
"name": "from",
Expand All @@ -254,7 +194,7 @@ export const ABI = [
"type": "core::integer::u64"
},
{
"name": "reserve_price",
"name": "TWAP",
"type": "core::integer::u256"
}
],
Expand All @@ -263,78 +203,18 @@ export const ABI = [
},
{
"type": "function",
"name": "set_cap_level_for_time_period",
"inputs": [
{
"name": "from",
"type": "core::integer::u64"
},
{
"name": "to",
"type": "core::integer::u64"
},
{
"name": "cap_level",
"type": "core::integer::u128"
}
],
"outputs": [],
"state_mutability": "external"
},
{
"type": "function",
"name": "set_cap_level_for_block_period",
"inputs": [
{
"name": "from",
"type": "core::integer::u64"
},
{
"name": "to",
"type": "core::integer::u64"
},
{
"name": "cap_level",
"type": "core::integer::u128"
}
],
"outputs": [],
"state_mutability": "external"
},
{
"type": "function",
"name": "set_strike_price_for_time_period",
"name": "set_reserve_price_for_round",
"inputs": [
{
"name": "from",
"type": "core::integer::u64"
},
{
"name": "to",
"type": "core::integer::u64"
"name": "vault_address",
"type": "core::starknet::contract_address::ContractAddress"
},
{
"name": "strike_price",
"name": "round_id",
"type": "core::integer::u256"
}
],
"outputs": [],
"state_mutability": "external"
},
{
"type": "function",
"name": "set_strike_price_for_block_period",
"inputs": [
{
"name": "from",
"type": "core::integer::u64"
},
{
"name": "to",
"type": "core::integer::u64"
},
{
"name": "strike_price",
"name": "reserve_price",
"type": "core::integer::u256"
}
],
Expand All @@ -343,39 +223,39 @@ export const ABI = [
},
{
"type": "function",
"name": "set_TWAP_for_block_period",
"name": "set_volatility_for_round",
"inputs": [
{
"name": "from",
"type": "core::integer::u64"
"name": "vault_address",
"type": "core::starknet::contract_address::ContractAddress"
},
{
"name": "to",
"type": "core::integer::u64"
"name": "round_id",
"type": "core::integer::u256"
},
{
"name": "TWAP",
"type": "core::integer::u256"
"name": "vol",
"type": "core::integer::u128"
}
],
"outputs": [],
"state_mutability": "external"
},
{
"type": "function",
"name": "set_TWAP_for_time_period",
"name": "set_cap_level_for_round",
"inputs": [
{
"name": "from",
"type": "core::integer::u64"
"name": "vault_address",
"type": "core::starknet::contract_address::ContractAddress"
},
{
"name": "to",
"type": "core::integer::u64"
"name": "round_id",
"type": "core::integer::u256"
},
{
"name": "TWAP",
"type": "core::integer::u256"
"name": "cap_level",
"type": "core::integer::u128"
}
],
"outputs": [],
Expand Down
Loading

0 comments on commit c9a8798

Please sign in to comment.