diff --git a/.env.example b/.env.example index 27e866e7..10bbe160 100644 --- a/.env.example +++ b/.env.example @@ -1,13 +1,17 @@ FOSSIL_PROCESSOR_ADDRESS=0x0768D44B56fD0F6f660A449697c906391b1aE682B30086F4d521c4c414d399d9 -VAULT_ROUND_DURATION=5555 +VAULT_ALPHA=2500 +VAULT_STRIKE=0 +ROUND_TRANSITION_DURATION=180 # 3 min +AUCTION_DURATION=180 # 3 min +ROUND_DURATION=720 # 12 min SIGNER_PRIVATE_KEY=0x2bff1b26236b72d8a930be1dfbee09f79a536a49482a4c8b8f1030e2ab3bf1b SIGNER_ADDRESS=0x101 STRK_TOKEN=0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7 -DEVNET_RPC=http://host.docker.internal:6060 +DEVNET_RPC=http://localhost:6060 -# Copy this from the Argent extension -ARGENT_WALLET_ADDRESS=0x0768d44b56fd0f6f660a449697c906391b1ae682b30086f4d521c4c414d399d9 +# Copy this from the Argent extension +ARGENT_WALLET_ADDRESS= # These 2 can be found in the Argent extenstion: Settings -> Developer Settings -> Deployment Data -ARGENT_WALLET_SALT=0x15337fc442ab75a3589746a426987f9dfb49b3abd8d447dab3550c3ead971b -ARGENT_WALLET_CONSTRUCTOR_ARG1=37459222005894634870375857944293937532221532474070351093573957772534191899 \ No newline at end of file +ARGENT_WALLET_SALT= +ARGENT_WALLET_CONSTRUCTOR_ARG1= diff --git a/Dockerfile b/Dockerfile index dc0f5cdb..02fd5a73 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,40 +6,8 @@ SHELL ["/bin/bash", "-c"] ENV SCARB_VERSION=2.8.4 ENV STARKLI_VERSION=0.3.5 -# Define build-time arguments -ARG SIGNER_PRIVATE_KEY -ARG DEVNET_RPC -ARG SIGNER_ADDRESS -ARG FOSSIL_PROCESSOR_ADDRESS -ARG VAULT_ROUND_DURATION -ARG ARGENT_ADDRESS -ARG ARGENT_SALT -ARG ARGENT_CONSTRUCTOR_ARG1 - -# Check if all required arguments are provided -RUN if [ -z "$SIGNER_PRIVATE_KEY" ] || \ - [ -z "$DEVNET_RPC" ] || \ - [ -z "$SIGNER_ADDRESS" ] || \ - [ -z "$FOSSIL_PROCESSOR_ADDRESS" ] || \ - [ -z "$VAULT_ROUND_DURATION" ] || \ - [ -z "$ARGENT_ADDRESS" ] || \ - [ -z "$ARGENT_SALT" ] || \ - [ -z "$ARGENT_CONSTRUCTOR_ARG1" ]; then \ - echo "Error: All build arguments must be provided."; \ - exit 1; \ -fi - # Starkli environment variables ENV STARKNET_ACCOUNT=/root/starkli_deployer_account.json -ENV STARKNET_PRIVATE_KEY=$SIGNER_PRIVATE_KEY -ENV STARKNET_RPC=$DEVNET_RPC - -ENV SIGNER_ADDRESS=$SIGNER_ADDRESS -ENV FOSSIL_PROCESSOR_ADDRESS=$FOSSIL_PROCESSOR_ADDRESS -ENV VAULT_ROUND_DURATION=$VAULT_ROUND_DURATION -ENV ARGENT_ADDRESS=$ARGENT_ADDRESS -ENV ARGENT_SALT=$ARGENT_SALT -ENV ARGENT_CONSTRUCTOR_ARG1=$ARGENT_CONSTRUCTOR_ARG1 # Install necessary dependencies RUN apt-get update && apt-get install -y \ @@ -68,5 +36,5 @@ RUN scarb build CMD bash -c " cd katana && \ chmod +x ./deploy_contracts_devnet.sh && \ chmod +x ./deploy_and_fund_argent_wallet.sh && \ - ./deploy_contracts_devnet.sh $SIGNER_ADDRESS $FOSSIL_PROCESSOR_ADDRESS $VAULT_ROUND_DURATION && \ - ./deploy_and_fund_argent_wallet.sh $ARGENT_ADDRESS $ARGENT_SALT $ARGENT_CONSTRUCTOR_ARG1" \ No newline at end of file + ./deploy_contracts_devnet.sh $SIGNER_ADDRESS $FOSSIL_PROCESSOR_ADDRESS $VAULT_ALPHA $VAULT_STRIKE $ROUND_TRANSITION_DURATION $AUCTION_DURATION $ROUND_DURATION && \ + ./deploy_and_fund_argent_wallet.sh $ARGENT_ADDRESS $ARGENT_SALT $ARGENT_CONSTRUCTOR_ARG1" diff --git a/docker-compose.yml b/docker-compose.yml index 42f1f6d5..2b992ce3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,15 +1,20 @@ -version: '3.8' +version: "3.8" services: pitchlake_starknet: + platform: linux/amd64 build: context: . - args: - - SIGNER_PRIVATE_KEY=${SIGNER_PRIVATE_KEY} - - DEVNET_RPC=${DEVNET_RPC} - - SIGNER_ADDRESS=${SIGNER_ADDRESS} - - FOSSIL_PROCESSOR_ADDRESS=${FOSSIL_PROCESSOR_ADDRESS} - - VAULT_ROUND_DURATION=${VAULT_ROUND_DURATION} - - ARGENT_ADDRESS=${ARGENT_WALLET_ADDRESS} - - ARGENT_SALT=${ARGENT_WALLET_SALT} - - ARGENT_CONSTRUCTOR_ARG1=${ARGENT_WALLET_CONSTRUCTOR_ARG1} + environment: + STARKNET_PRIVATE_KEY: ${PITCHLAKE_DEPLOYER_PRIVATE_KEY} + STARKNET_RPC: ${DEVNET_RPC} + SIGNER_ADDRESS: ${PITCHLAKE_DEPLOYER_ADDRESS} + FOSSIL_PROCESSOR_ADDRESS: ${FOSSIL_ADDRESS} + VAULT_ALPHA: ${VAULT_ALPHA} + VAULT_STRIKE: ${VAULT_STRIKE} + ROUND_TRANSITION_DURATION: ${ROUND_TRANSITION_DURATION} + AUCTION_DURATION: ${AUCTION_DURATION} + ROUND_DURATION: ${ROUND_DURATION} + ARGENT_ADDRESS: ${ARGENT_WALLET_ADDRESS} + ARGENT_SALT: ${ARGENT_WALLET_SALT} + ARGENT_CONSTRUCTOR_ARG1: ${ARGENT_WALLET_CONSTRUCTOR_ARG1} \ No newline at end of file diff --git a/katana/deploy_and_fund_argent_wallet.sh b/katana/deploy_and_fund_argent_wallet.sh index ec35081f..d4bf1791 100755 --- a/katana/deploy_and_fund_argent_wallet.sh +++ b/katana/deploy_and_fund_argent_wallet.sh @@ -1,21 +1,21 @@ # Declare Argent contract -echo +echo echo "============================" echo "Deploy Argent Account" echo "============================" -echo +echo # Check required environment variables if [ -z "$STARKNET_ACCOUNT" ] || [ -z "$STARKNET_RPC" ] || [ -z "$STARKNET_PRIVATE_KEY" ]; then - echo "Error: Required environment variables not set" - echo "Please ensure STARKNET_ACCOUNT, STARKNET_RPC and STARKNET_PRIVATE_KEY are set" - exit 1 + echo "Error: Required environment variables not set" + echo "Please ensure STARKNET_ACCOUNT, STARKNET_RPC and STARKNET_PRIVATE_KEY are set" + exit 1 fi echo "Environment variables:" echo "STARKNET_ACCOUNT: $STARKNET_ACCOUNT" -echo "STARKNET_RPC: $STARKNET_RPC" +echo "STARKNET_RPC: $STARKNET_RPC" echo "STARKNET_PRIVATE_KEY: $STARKNET_PRIVATE_KEY" echo @@ -26,13 +26,13 @@ ARG1=$3 # Check if all required arguments are provided if [ $# -ne 3 ]; then - echo "Error: Did not provide all arguments" - echo "Usage: $0 " - exit 1 + echo "Error: Did not provide all arguments" + echo "Usage: $0 " + exit 1 fi if [ ! -f "$STARKNET_ACCOUNT" ]; then - starkli account fetch $SIGNER_ADDRESS --output $STARKNET_ACCOUNT + starkli account fetch $SIGNER_ADDRESS --output $STARKNET_ACCOUNT fi # Deploy Argent wallet @@ -40,19 +40,21 @@ ARGENT_HASH=$(starkli declare --watch argent_ArgentAccount.contract_class.json - echo "[Argent Wallet] Class hash declared: $ARGENT_HASH" if starkli class-hash-at $ADDRESS; then - echo "Argent wallet already deployed at $ADDRESS" + echo "Argent wallet already deployed at $ADDRESS" else - DEPLOYED_ARGENT_ADDRESS=$(starkli deploy --watch $ARGENT_HASH 0 $ARG1 1 --salt $SALT --not-unique | grep -o '0x[a-fA-F0-9]\{64\}' | head -1) + DEPLOYED_ARGENT_ADDRESS=$(starkli deploy --watch $ARGENT_HASH 0 $ARG1 1 --salt $SALT --not-unique | grep -o '0x[a-fA-F0-9]\{64\}' | head -1) - echo "Expected wallet address: $ADDRESS" - echo "Deployed wallet address: $DEPLOYED_ARGENT_ADDRESS" + echo "Expected wallet address: $ADDRESS" + echo "Deployed wallet address: $DEPLOYED_ARGENT_ADDRESS" - # Verify addresses match - if [ "$ADDRESS" != "$DEPLOYED_ARGENT_ADDRESS" ]; then - echo "Error: Deployed address does not match expected address" - exit 1 - fi + # Verify addresses match (case-insensitive) + ADDRESS_LOWER=${ADDRESS,,} + DEPLOYED_ADDRESS_LOWER=${DEPLOYED_ARGENT_ADDRESS,,} + if [ "$ADDRESS_LOWER" != "$DEPLOYED_ADDRESS_LOWER" ]; then + echo "Error: Deployed address does not match expected address" + exit 1 + fi - OUTPUT=$(starkli invoke --watch 0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7 transfer $ADDRESS 10000 0) - echo "Funded wallet $OUTPUT" -fi \ No newline at end of file + OUTPUT=$(starkli invoke --watch 0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7 transfer $ADDRESS 10000 0) + echo "Funded wallet $OUTPUT" +fi diff --git a/katana/deploy_contracts.sh b/katana/deploy_contracts.sh index 85349aff..6443f760 100644 --- a/katana/deploy_contracts.sh +++ b/katana/deploy_contracts.sh @@ -28,7 +28,7 @@ echo "Class hash declared: $VAULT_HASH" # Deploy the third contract with additional parameters and salt echo "Deploying pitch_lake_Vault contract..." -VAULT_ADDRESS=$(starkli deploy $VAULT_HASH $FOSSILCLIENT_ADDRESS 0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7 $OPTIONROUND_HASH 5555 0 --salt 1 | grep -o '0x[a-fA-F0-9]\{64\}' | head -1) +VAULT_ADDRESS=$(starkli deploy $VAULT_HASH $FOSSILCLIENT_ADDRESS 0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7 $OPTIONROUND_HASH $VAULT_ALPHA $VAULT_STRIKE --salt 1 | grep -o '0x[a-fA-F0-9]\{64\}' | head -1) echo "Contract deployed at: $VAULT_ADDRESS" # Perform the first call to get the round address diff --git a/katana/deploy_contracts_devnet.sh b/katana/deploy_contracts_devnet.sh index 34566380..aabf33b9 100755 --- a/katana/deploy_contracts_devnet.sh +++ b/katana/deploy_contracts_devnet.sh @@ -3,11 +3,11 @@ # Ensure the script stops on the first error set -e -echo +echo echo "============================" echo "Deploy Pitchlake Contracts" echo "============================" -echo +echo # Set compiler version COMPILER_VERSION="2.8.2" @@ -20,35 +20,39 @@ echo "STARKNET_RPC: $STARKNET_RPC" # Check if environment variables exist if [ -z "$STARKNET_ACCOUNT" ] || [ -z "$STARKNET_PRIVATE_KEY" ] || [ -z "$STARKNET_RPC" ]; then - echo "Error: One or more required environment variables are missing." - exit 1 + echo "Error: One or more required environment variables are missing." + exit 1 fi # Check if all required arguments are provided -if [ $# -ne 3 ]; then - echo "Usage: $0 " - exit 1 +if [ $# -ne 7 ]; then + echo "Usage: $0 " + exit 1 fi # Assign command line arguments to variables SIGNER_ADDRESS=$1 FOSSIL_PROCESSOR_ADDRESS=$2 -VAULT_ROUND_DURATION=$3 +VAULT_ALPHA=$3 +VAULT_STRIKE=$4 +ROUND_TRANSITION_DURATION=$5 +AUCTION_DURATION=$6 +ROUND_DURATION=$7 # Check if deployment_addresses.env exists if [ -f "deployment_addresses.env" ]; then - echo "Contracts already deployed" - echo "Deployment addresses:" - cat deployment_addresses.env - echo "Exiting..." - exit 0 + echo "Contracts already deployed" + echo "Deployment addresses:" + cat deployment_addresses.env + echo "Exiting..." + exit 0 fi # Check if the account file already exists if [ ! -f "$STARKNET_ACCOUNT" ]; then - starkli account fetch $SIGNER_ADDRESS --output $STARKNET_ACCOUNT -else - echo "Acount config already exists at path $STARKNET_ACCOUNT" + starkli account fetch $SIGNER_ADDRESS --output $STARKNET_ACCOUNT +else + echo "Acount config already exists at path $STARKNET_ACCOUNT" fi # Declare and deploy the ETH contract @@ -64,33 +68,27 @@ ETH_ADDRESS="0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7" # Declare the first contract sleep 2 -FOSSILCLIENT_HASH=$(starkli declare ../target/dev/pitch_lake_FossilClient.contract_class.json --compiler-version $COMPILER_VERSION | grep -o '0x[a-fA-F0-9]\{64\}' | head -1) +FOSSILCLIENT_HASH=$(starkli declare ../target/dev/pitch_lake_FossilClient.contract_class.json --compiler-version $COMPILER_VERSION --watch | grep -o '0x[a-fA-F0-9]\{64\}' | head -1) echo "[Fossil Client] Class hash declared" # Deploy the first contract with salt and FOSSIL_PROCESSOR_ADDRESS -sleep 2 -FOSSILCLIENT_ADDRESS=$(starkli deploy $FOSSILCLIENT_HASH $FOSSIL_PROCESSOR_ADDRESS --salt 1 | grep -o '0x[a-fA-F0-9]\{64\}' | head -1) +FOSSILCLIENT_ADDRESS=$(starkli deploy $FOSSILCLIENT_HASH $FOSSIL_PROCESSOR_ADDRESS --salt 1 --watch| grep -o '0x[a-fA-F0-9]\{64\}' | head -1) echo "[Fossil Client] Contract deployed" # Declare the second contract -sleep 2 -OPTIONROUND_HASH=$(starkli declare ../target/dev/pitch_lake_OptionRound.contract_class.json --compiler-version $COMPILER_VERSION | grep -o '0x[a-fA-F0-9]\{64\}' | head -1) +OPTIONROUND_HASH=$(starkli declare ../target/dev/pitch_lake_OptionRound.contract_class.json --compiler-version $COMPILER_VERSION --watch | grep -o '0x[a-fA-F0-9]\{64\}' | head -1) echo "[Option Round] Class hash declared" # Declare the third contract -sleep 2 -VAULT_HASH=$(starkli declare ../target/dev/pitch_lake_Vault.contract_class.json --compiler-version $COMPILER_VERSION | grep -o '0x[a-fA-F0-9]\{64\}' | head -1) +VAULT_HASH=$(starkli declare ../target/dev/pitch_lake_Vault.contract_class.json --compiler-version $COMPILER_VERSION --watch | grep -o '0x[a-fA-F0-9]\{64\}' | head -1) echo "[Vault] Class hash declared" # Deploy the third contract with additional parameters and salt -sleep 2 -VAULT_ADDRESS=$(starkli deploy $VAULT_HASH $FOSSILCLIENT_ADDRESS $ETH_ADDRESS $OPTIONROUND_HASH $VAULT_ROUND_DURATION 0 --salt 1 | grep -o '0x[a-fA-F0-9]\{64\}' | head -1) +VAULT_ADDRESS=$(starkli deploy $VAULT_HASH $FOSSILCLIENT_ADDRESS $ETH_ADDRESS $OPTIONROUND_HASH $VAULT_ALPHA $VAULT_STRIKE $ROUND_TRANSITION_DURATION $AUCTION_DURATION $ROUND_DURATION --salt 1 --watch | grep -o '0x[a-fA-F0-9]\{64\}' | head -1) echo "[Vault] Contract deployed" - # Set pricing data for first round to start echo "Fulfilling 1st round job request..." -sleep 2 OUTPUT6=$(starkli call $VAULT_ADDRESS get_request_to_start_first_round) CALLDATA1=$(echo "$OUTPUT6" | tr -d '[]"' | tr ',' ' ' | tr -s '[:space:]' | sed 's/^ *//; s/ *$//') echo $CALLDATA1 @@ -99,10 +97,10 @@ starkli invoke --watch $FOSSILCLIENT_ADDRESS fossil_callback $CALLDATA1 0x6 0x02 echo "Finished" { - echo "ETH_ADDRESS=$ETH_ADDRESS" - echo "FOSSILCLIENT_ADDRESS=$FOSSILCLIENT_ADDRESS" - echo "VAULT_ADDRESS=$VAULT_ADDRESS" -} > deployment_addresses.env + echo "ETH_ADDRESS=$ETH_ADDRESS" + echo "FOSSILCLIENT_ADDRESS=$FOSSILCLIENT_ADDRESS" + echo "VAULT_ADDRESS=$VAULT_ADDRESS" +} >deployment_addresses.env echo "Deployment addresses" -cat deployment_addresses.env \ No newline at end of file +cat deployment_addresses.env diff --git a/scripts/abi/optionRound.ts b/scripts/abi/optionRound.ts index 4e87b382..df21311c 100644 --- a/scripts/abi/optionRound.ts +++ b/scripts/abi/optionRound.ts @@ -830,6 +830,18 @@ export const ABI = [ { "name": "pricing_data", "type": "pitch_lake::option_round::interface::PricingData" + }, + { + "name": "round_transition_duration", + "type": "core::integer::u64" + }, + { + "name": "auction_duration", + "type": "core::integer::u64" + }, + { + "name": "round_duration", + "type": "core::integer::u64" } ] }, diff --git a/scripts/abi/vault.ts b/scripts/abi/vault.ts index 7d064390..f53ba6b3 100644 --- a/scripts/abi/vault.ts +++ b/scripts/abi/vault.ts @@ -123,6 +123,39 @@ export const ABI = [ ], "state_mutability": "view" }, + { + "type": "function", + "name": "get_round_transition_duration", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u64" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "get_auction_duration", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u64" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "get_round_duration", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u64" + } + ], + "state_mutability": "view" + }, { "type": "function", "name": "get_current_round_id", @@ -445,6 +478,18 @@ export const ABI = [ { "name": "strike_level", "type": "core::integer::i128" + }, + { + "name": "round_transition_duration", + "type": "core::integer::u64" + }, + { + "name": "auction_duration", + "type": "core::integer::u64" + }, + { + "name": "round_duration", + "type": "core::integer::u64" } ] }, @@ -532,6 +577,11 @@ export const ABI = [ "type": "core::integer::u64", "kind": "data" }, + { + "name": "account_queued_liquidity_before", + "type": "core::integer::u256", + "kind": "data" + }, { "name": "account_queued_liquidity_now", "type": "core::integer::u256", diff --git a/sncast/script.sh b/sncast/script.sh index 942f5494..c8a520cf 100644 --- a/sncast/script.sh +++ b/sncast/script.sh @@ -1,78 +1,121 @@ #!/bin/bash -cd argent -FOSSIL_PROCESSOR=$(grep '^FOSSIL_PROCESSOR=' .env | cut -d '=' -f2 | tr -d '"') -echo "Fossil processor address: $FOSSIL_PROCESSOR" -cd ../ - # Declare Contracts echo "Declaring contracts..." -# sleep 2 -# OUTPUT1=$(sncast declare -c FossilClient --fee-token eth) -# FOSSIL_CLASS_HASH=$(echo "$OUTPUT1" | awk '/class_hash:/ {print $2}') -FOSSIL_CLASS_HASH=0x0711b785a4c9741c731b01a7487e3aaaf73acb2d9da9f68704a06a39baa4f1b6 -CONSTRUCTOR_CALLDATA=$(echo "$OUTPUT1" | awk '/constructor_calldata:/ {print $2}') -#echo "Fossil client clash hash: $FOSSIL_CLASS_HASH" - -# sleep 2 -# OUTPUT2=$(sncast declare -c OptionRound --fee-token eth) -# OPTION_ROUND_CLASS_HASH=$(echo "$OUTPUT2" | awk '/class_hash:/ {print $2}') -OPTION_ROUND_CLASS_HASH=0x06cbdcbc78b34d3a703410a26edb91afa0532b64876e831871d41fbc4174607b #0x0740110b337e39f3c1099a89faf4fcac867442b21a81c490b98897f682cc7ae4 - -# sleep 2 -# OUTPUT3=$(sncast declare -c Vault --fee-token eth) -# VAULT_CLASS_HASH=$(echo "$OUTPUT3" | awk '/class_hash:/ {print $2}') -VAULT_CLASS_HASH=0x0740110b337e39f3c1099a89faf4fcac867442b21a81c490b98897f682cc7ae4 + +OUTPUT1=$(sncast declare -c FossilClient --fee-token eth) +FOSSIL_CLASS_HASH=$(echo "$OUTPUT1" | awk '/class_hash:/ {print $2}') +### FOSSIL_CLASS_HASH=0x711b785a4c9741c731b01a7487e3aaaf73acb2d9da9f68704a06a39baa4f1b6 +echo "Fossil class hash: $FOSSIL_CLASS_HASH" + +OUTPUT2=$(sncast declare -c OptionRound --fee-token eth) +OPTION_ROUND_CLASS_HASH=$(echo "$OUTPUT2" | awk '/class_hash:/ {print $2}') +### OPTION_ROUND_CLASS_HASH=0x378211be15fa10df3a5d70e92bfd1bca0752a0196ea0bfcd5b3131491a1305 +echo "Option round class hash: $OPTION_ROUND_CLASS_HASH" + +OUTPUT3=$(sncast declare -c Vault --fee-token eth) +VAULT_CLASS_HASH=$(echo "$OUTPUT3" | awk '/class_hash:/ {print $2}') +### VAULT_CLASS_HASH=0x51653f39500cfb021b791c3bf9f2b2f1e294a862c8824be21f3b44a0ee40449 +echo "Vault class hash: $VAULT_CLASS_HASH" # Deploy contracts echo "Deploying contracts..." -sleep 2 + +ETH_ADDRESS=0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7 +echo "ETH address: $ETH_ADDRESS" + +FOSSIL_PROCESSOR=$(grep '^FOSSIL_PROCESSOR=' .env | cut -d '=' -f2 | tr -d '"') +echo "Fossil processor address: $FOSSIL_PROCESSOR" + OUTPUT4=$(sncast deploy --fee-token eth --class-hash $FOSSIL_CLASS_HASH --constructor-calldata $FOSSIL_PROCESSOR) FOSSIL_CONTRACT_ADDRESS=$(echo "$OUTPUT4" | awk '/contract_address:/ {print $2}') +### FOSSIL_CONTRACT_ADDRESS=0x0239664d7e16f82ad369eed526150fedfbb8c02d5ea374d826228d8f8ae3d91c +echo "Fossil Client address: $FOSSIL_CONTRACT_ADDRESS" -sleep 2 -OUTPUT5=$(sncast deploy --fee-token eth --class-hash $VAULT_CLASS_HASH --constructor-calldata $FOSSIL_CONTRACT_ADDRESS 0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7 $OPTION_ROUND_CLASS_HASH 5555 0) +# 12 minute vault +ROUND_TRANSITION_DURATION1=180 # 3 min +AUCTION_DURATION1=180 # 3 min +ROUND_DURATION1=720 # 12 min +sleep 60 +OUTPUT5=$(sncast deploy --fee-token eth --class-hash $VAULT_CLASS_HASH --constructor-calldata $FOSSIL_CONTRACT_ADDRESS $ETH_ADDRESS $OPTION_ROUND_CLASS_HASH 5000 0 $ROUND_TRANSITION_DURATION1 $AUCTION_DURATION1 $ROUND_DURATION1) VAULT_CONTRACT_ADDRESS=$(echo "$OUTPUT5" | awk '/contract_address:/ {print $2}') -echo "Vault address: $VAULT_CONTRACT_ADDRESS" +echo "(12 minute) Vault address: $VAULT_CONTRACT_ADDRESS" +# 3 hour vault +ROUND_TRANSITION_DURATION2=1800 # 30 min +AUCTION_DURATION2=1800 # 30 min +ROUND_DURATION2=10800 # 3 hour +sleep 60 +OUTPUT5_2=$(sncast deploy --fee-token eth --class-hash $VAULT_CLASS_HASH --constructor-calldata $FOSSIL_CONTRACT_ADDRESS $ETH_ADDRESS $OPTION_ROUND_CLASS_HASH 2500 0 $ROUND_TRANSITION_DURATION2 $AUCTION_DURATION2 $ROUND_DURATION2) +VAULT_CONTRACT_ADDRESS2=$(echo "$OUTPUT5_2" | awk '/contract_address:/ {print $2}') +echo "(15 minute) Vault address: $VAULT_CONTRACT_ADDRESS2" +# 1 month vault +sleep 60 +ROUND_TRANSITION_DURATION3=10800 # 3 hours +AUCTION_DURATION3=10800 # 3 hours +ROUND_DURATION3=2592000 # 1 month +OUTPUT5_3=$(sncast deploy --fee-token eth --class-hash $VAULT_CLASS_HASH --constructor-calldata $FOSSIL_CONTRACT_ADDRESS $ETH_ADDRESS $OPTION_ROUND_CLASS_HASH 1250 0 $ROUND_TRANSITION_DURATION3 $AUCTION_DURATION3 $ROUND_DURATION3) +VAULT_CONTRACT_ADDRESS3=$(echo "$OUTPUT5_3" | awk '/contract_address:/ {print $2}') +echo "(30 day) Vault address: $VAULT_CONTRACT_ADDRESS3" +echo "Vaults: [$VAULT_CONTRACT_ADDRESS,$VAULT_CONTRACT_ADDRESS2,$VAULT_CONTRACT_ADDRESS3]" # Set pricing data for first round to start -echo "Fulfilling 1st round job request..." -sleep 2 +echo "Fulfilling 1st job request..." +sleep 25 OUTPUT6=$(sncast call --contract-address $VAULT_CONTRACT_ADDRESS --function get_request_to_start_first_round) response_line=$(echo "$OUTPUT6" | grep 'response:') contents=$(echo "$response_line" | sed 's/.*\[\(.*\)\].*/\1/') contents=$(echo "$contents" | tr ',' ' ' | tr -s '[:space:]') contents=$(echo "$contents" | sed 's/^ *//; s/ *$//') CALLDATA1=$(echo "$contents" | sed 's/,\s*/ /g') -sleep 2 +sleep 25 sncast invoke --contract-address $FOSSIL_CONTRACT_ADDRESS --function fossil_callback --calldata $CALLDATA1 0x6 0x02540be400 0x00 0x0d05 0x77359400 0x00 0x00 --fee-token eth -echo "Finished" -### HERE IS WHERE WE CAN LOAD THE DEFAULT/FIRST VAULT INTO THE DB +echo "Fulfilling 2nd job request..." +sleep 25 +OUTPUT6_2=$(sncast call --contract-address $VAULT_CONTRACT_ADDRESS2 --function get_request_to_start_first_round) +response_line=$(echo "$OUTPUT6_2" | grep 'response:') +contents=$(echo "$response_line" | sed 's/.*\[\(.*\)\].*/\1/') +contents=$(echo "$contents" | tr ',' ' ' | tr -s '[:space:]') +contents=$(echo "$contents" | sed 's/^ *//; s/ *$//') +CALLDATA2=$(echo "$contents" | sed 's/,\s*/ /g') +sleep 25 +sncast invoke --contract-address $FOSSIL_CONTRACT_ADDRESS --function fossil_callback --calldata $CALLDATA2 0x6 0x02540be400 0x00 0x0d05 0x77359400 0x00 0x00 --fee-token eth -# ... +echo "Fulfilling 3rd job request..." +sleep 25 +OUTPUT6_3=$(sncast call --contract-address $VAULT_CONTRACT_ADDRESS3 --function get_request_to_start_first_round) +response_line=$(echo "$OUTPUT6_3" | grep 'response:') +contents=$(echo "$response_line" | sed 's/.*\[\(.*\)\].*/\1/') +contents=$(echo "$contents" | tr ',' ' ' | tr -s '[:space:]') +contents=$(echo "$contents" | sed 's/^ *//; s/ *$//') +CALLDATA3=$(echo "$contents" | sed 's/,\s*/ /g') +sleep 25 +sncast invoke --contract-address $FOSSIL_CONTRACT_ADDRESS --function fossil_callback --calldata $CALLDATA3 0x6 0x02540be400 0x00 0x0d05 0x77359400 0x00 0x00 --fee-token eth +echo "Finished" -### BELOW IS FOR USING ARGENT WALLETS ON DEVNET ### +### - HERE IS WHERE WE COULD LOAD THE VAULT ADDRESSES INTO THE DB -# Declare Argent contract +### - Below is for deploying your argent account to devnet -sleep 2 +# Declare Argent contract +sleep 1 echo "Declaring argent..." cd argent OUTPUTA=$(sncast declare -c ArgentAccount --fee-token eth) ARGENT_CLASS_HASH=$(echo "$OUTPUTA" | awk '/class_hash:/ {print $2}') echo "Argent clash hash: $ARGENT_CLASS_HASH" -# Deploy Argent contract +# Deploy Argent contract (your wallet) +sleep 1 ADDRESS=$(grep '^ARGENT_WALLET_ADDRESS=' .env | cut -d '=' -f2 | tr -d '"') SALT=$(grep '^ARGENT_WALLET_SALT=' .env | cut -d '=' -f2 | tr -d '"') ARG1=$(grep '^ARGENT_WALLET_CONSTRUCTOR_ARG1=' .env | cut -d '=' -f2 | tr -d '"') - OUTPUTA2=$(sncast deploy --fee-token eth --class-hash $ARGENT_CLASS_HASH -s $SALT --constructor-calldata 0 $ARG1 1 -v v1) DEPLOYED_WALLET_ADDRESS=$(echo "$OUTPUTA2" | awk '/contract_address:/ {print $2}') echo "Expected wallet address: $ADDRESS" echo "Deployed wallet address: $DEPLOYED_WALLET_ADDRESS" # Fund the wallet +sleep 1 OUTPUTA3=$(sncast invoke --contract-address 0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7 -f transfer -c $ADDRESS 1000000000000000000000 0 --fee-token eth) echo "Funded wallet $OUTPUTA3" diff --git a/snfoundry.toml b/snfoundry.toml index 6b558626..2486570e 100644 --- a/snfoundry.toml +++ b/snfoundry.toml @@ -5,17 +5,17 @@ # account = "user1" -# [sncast.default] -# url = "http://127.0.0.1:5050/rpc" -# network = "devnet" -# accounts-file = ".starknet_accounts/starknet_accounts.json" -# account = "user1" +# [sncast.default] +# url = "http://127.0.0.1:5050/rpc" +# network = "KATANA" +# accounts-file = ".starknet_accounts/starknet_accounts.json" +# account = "user1" [sncast.default] #url = "http://localhost:6060" -#url = "https://starknet-sepolia.public.blastapi.io/rpc/v0_7" -url = "http://localhost:6060/rpc" -network = "juno" +url = "https://starknet-sepolia.public.blastapi.io/rpc/v0_7" +#url = "http://localhost:6060/rpc" +#network = "juno" accounts-file = ".starknet_accounts/starknet_accounts.json" account = "user1" diff --git a/src/fossil_client/contract.cairo b/src/fossil_client/contract.cairo index eca6f142..93997765 100644 --- a/src/fossil_client/contract.cairo +++ b/src/fossil_client/contract.cairo @@ -82,10 +82,10 @@ mod FossilClient { // (timestamp & program id)/outputs (l1 data)/proof // @note Skipping for now for testnet testing - assert( - get_caller_address() == self.fossil_processor.read(), - Errors::CallerNotFossilProcessor - ); + assert( + get_caller_address() == self.fossil_processor.read(), + Errors::CallerNotFossilProcessor + ); // Relay L1 data to the vault IVaultDispatcher { contract_address: vault_address } diff --git a/src/library/constants.cairo b/src/library/constants.cairo index da976fcf..7d849f9a 100644 --- a/src/library/constants.cairo +++ b/src/library/constants.cairo @@ -1,27 +1,11 @@ const MINUTE: u64 = 60; const HOUR: u64 = 60 * MINUTE; const DAY: u64 = 24 * HOUR; - const BPS_u128: u128 = 10_000; const BPS_i128: i128 = 10_000; const BPS_u256: u256 = 10_000; const BPS_felt252: felt252 = 10_000; - -/// VAULT /// - -/// OPTION ROUND /// - -// Testing -const ROUND_TRANSITION_PERIOD: u64 = 1 * MINUTE; -const AUCTION_RUN_TIME: u64 = 1 * MINUTE; -const OPTION_RUN_TIME: u64 = 1 * MINUTE; - -// Realistic -// const ROUND_TRANSITION_PERIOD: u64 = 1 * HOUR; -// const AUCTION_RUN_TIME: u64 = 6 * HOUR; -// const OPTION_RUN_TIME: u64 = 30 * DAY; - /// FOSSIL CLIENT /// // The identifier of the program Fossil will run diff --git a/src/option_round/contract.cairo b/src/option_round/contract.cairo index 84e80881..f3c8c969 100644 --- a/src/option_round/contract.cairo +++ b/src/option_round/contract.cairo @@ -17,9 +17,6 @@ mod OptionRound { max_payout_per_option, calculate_total_options_available, calculate_payout_per_option, }; use pitch_lake::library::red_black_tree::{RBTreeComponent, RBTreeComponent::Node}; - use pitch_lake::library::constants::{ - ROUND_TRANSITION_PERIOD, AUCTION_RUN_TIME, OPTION_RUN_TIME - }; // ************************************************************************* // COMPONENTS @@ -108,7 +105,13 @@ mod OptionRound { #[constructor] fn constructor(ref self: ContractState, args: ConstructorArgs) { // @dev Get the constructor arguments - let ConstructorArgs { vault_address, round_id, pricing_data, } = args; + let ConstructorArgs { vault_address, + round_id, + pricing_data, + round_transition_duration, + auction_duration, + round_duration, } = + args; // @dev Set the name and symbol for the minted option (ERC-20) tokens let (name, symbol) = self.generate_erc20_name_and_symbol(round_id); @@ -116,8 +119,10 @@ mod OptionRound { // @dev Set round's dates let deployment_date = get_block_timestamp(); - let (auction_start_date, auction_end_date, settlement_date) = self - .calculate_dates(deployment_date); + let auction_start_date = deployment_date + round_transition_duration; + let auction_end_date = auction_start_date + auction_duration; + let settlement_date = auction_end_date + round_duration; + self.deployment_date.write(get_block_timestamp()); self.auction_start_date.write(auction_start_date); self.auction_end_date.write(auction_end_date); @@ -151,6 +156,8 @@ mod OptionRound { ERC20Event: ERC20Component::Event, } + // @dev Emitted when the pricing data is set + // @member pricing_data: The pricing data (strike price, cap level, reserve price) #[derive(Drop, starknet::Event, PartialEq)] struct PricingDataSet { pricing_data: PricingData, @@ -513,7 +520,6 @@ mod OptionRound { /// State transition - // @note todo: only if round 1 fn set_pricing_data(ref self: ContractState, pricing_data: PricingData) { // @dev Assert the caller is the vault self.assert_caller_is_vault(); @@ -803,14 +809,6 @@ mod OptionRound { #[generate_trait] impl InternalImpl of OptionRoundInternalTrait { - fn calculate_dates(self: @ContractState, deployment_date: u64) -> (u64, u64, u64) { - let auction_start_date = deployment_date + ROUND_TRANSITION_PERIOD; - let auction_end_date = auction_start_date + AUCTION_RUN_TIME; - let option_settlement_date = auction_end_date + OPTION_RUN_TIME; - - (auction_start_date, auction_end_date, option_settlement_date) - } - // @dev Transitions the round's state to `to_state` if the proper conditions are met fn transition_state_to(ref self: ContractState, to_state: OptionRoundState) { // @dev Assert the caller is the vault diff --git a/src/option_round/interface.cairo b/src/option_round/interface.cairo index 3fed5762..39d74fe8 100644 --- a/src/option_round/interface.cairo +++ b/src/option_round/interface.cairo @@ -23,7 +23,10 @@ struct PricingData { struct ConstructorArgs { vault_address: ContractAddress, round_id: u64, - pricing_data: PricingData + pricing_data: PricingData, + round_transition_duration: u64, + auction_duration: u64, + round_duration: u64, } // The interface for an option round contract @@ -61,7 +64,7 @@ trait IOptionRound { fn get_strike_price(self: @TContractState) -> u256; // @dev The percentage points (BPS) above the TWAP to cap the payout per option - // @note E.g. 3333 tranlates to a capped payout of 33.33% above the settlement price + // @note E.g. 3333 tranlates to a capped payout of 33.33% above the strike price fn get_cap_level(self: @TContractState) -> u128; // @dev The total ETH locked at the start of the auction diff --git a/src/tests/deployment/initializing_option_round_params_tests.cairo b/src/tests/deployment/initializing_option_round_params_tests.cairo index 763ee8ec..355c18de 100644 --- a/src/tests/deployment/initializing_option_round_params_tests.cairo +++ b/src/tests/deployment/initializing_option_round_params_tests.cairo @@ -123,7 +123,6 @@ fn test_vault_strike_levels_otm() { assert_eq!(otm_strike, (10_000 + 10_007) * s_price / 10000); } - //#[test] //#[available_gas(50000000)] //fn test_calculated_strike_ITM_high_vol() { diff --git a/src/tests/utils/facades/fossil_client_facade.cairo b/src/tests/utils/facades/fossil_client_facade.cairo index 65ded8b7..1dc77148 100644 --- a/src/tests/utils/facades/fossil_client_facade.cairo +++ b/src/tests/utils/facades/fossil_client_facade.cairo @@ -28,7 +28,7 @@ impl FossilClientFacadeImpl of FossilClientFacadeTrait { /// Entrypoints fn fossil_callback(self: FossilClientFacade, request: Span, result: Span) { - set_contract_address(FOSSIL_PROCESSOR()); + set_contract_address(FOSSIL_PROCESSOR()); self.dispatcher().fossil_callback(request, result); } diff --git a/src/tests/utils/facades/vault_facade.cairo b/src/tests/utils/facades/vault_facade.cairo index 7095bb2b..e11ca057 100644 --- a/src/tests/utils/facades/vault_facade.cairo +++ b/src/tests/utils/facades/vault_facade.cairo @@ -11,7 +11,6 @@ use pitch_lake::{ option_round::{ contract::OptionRound, interface::{IOptionRoundDispatcher, IOptionRoundDispatcherTrait,} }, - library::constants::{ROUND_TRANSITION_PERIOD, AUCTION_RUN_TIME, OPTION_RUN_TIME}, tests::{ utils::{ lib::{ @@ -255,8 +254,7 @@ impl VaultFacadeImpl of VaultFacadeTrait { } - fn get_unsold_liquidity(ref self: VaultFacade, - round_id: u64) -> u256 { + fn get_unsold_liquidity(ref self: VaultFacade, round_id: u64) -> u256 { let contract_address = self.get_option_round_address(round_id); let round = IOptionRoundDispatcher { contract_address }; @@ -478,20 +476,17 @@ impl VaultFacadeImpl of VaultFacadeTrait { fn get_auction_run_time(ref self: VaultFacade) -> u64 { - AUCTION_RUN_TIME - //self.vault_dispatcher.get_auction_run_time() + self.vault_dispatcher.get_auction_duration() } fn get_option_run_time(ref self: VaultFacade) -> u64 { - //self.vault_dispatcher.get_option_run_time() - OPTION_RUN_TIME + self.vault_dispatcher.get_round_duration() } // Gets the round transition period in seconds, 3 hours is a random number for testing // @note TODO impl this in contract later fn get_round_transition_period(ref self: VaultFacade) -> u64 { - //self.vault_dispatcher.get_round_transition_period() - ROUND_TRANSITION_PERIOD + self.vault_dispatcher.get_round_transition_duration() } } diff --git a/src/tests/utils/helpers/event_helpers.cairo b/src/tests/utils/helpers/event_helpers.cairo index 39f85237..f060e972 100644 --- a/src/tests/utils/helpers/event_helpers.cairo +++ b/src/tests/utils/helpers/event_helpers.cairo @@ -390,7 +390,12 @@ fn assert_event_withdrawal_queued( Option::Some(e) => { let expected = Vault::Event::WithdrawalQueued( Vault::WithdrawalQueued { - account, bps, round_id, account_queued_liquidity_before, account_queued_liquidity_now, vault_queued_liquidity_now + account, + bps, + round_id, + account_queued_liquidity_before, + account_queued_liquidity_now, + vault_queued_liquidity_now } ); diff --git a/src/tests/utils/helpers/setup.cairo b/src/tests/utils/helpers/setup.cairo index b4028578..a722ce79 100644 --- a/src/tests/utils/helpers/setup.cairo +++ b/src/tests/utils/helpers/setup.cairo @@ -12,7 +12,7 @@ use openzeppelin_token::erc20::{ use pitch_lake::fossil_client::interface::{JobRequest, FossilResult, L1Data}; use pitch_lake::fossil_client::contract::FossilClient; use pitch_lake::{ - library::eth::Eth, vault::contract::Vault, + library::eth::Eth, vault::contract::Vault, library::constants::{MINUTE}, vault::interface::{ConstructorArgs, VaultType, IVaultDispatcher, IVaultDispatcherTrait}, option_round::{ contract::OptionRound, @@ -93,6 +93,10 @@ fn deploy_fossil_client() -> FossilClientFacade { return FossilClientFacade { contract_address }; } +const ROUND_TRANSITION_DURATION: u64= 3 * MINUTE; +const AUCTION_DURATION: u64= 3 * MINUTE; +const ROUND_DURATION: u64= 3 * MINUTE; + // Deploy the vault and fossil client fn deploy_vault_with_events( @@ -106,6 +110,9 @@ fn deploy_vault_with_events( option_round_class_hash: OptionRound::TEST_CLASS_HASH.try_into().unwrap(), alpha, // risk factor for vault strike_level, // strike price for r1 is settlement price of r0 + round_transition_duration: ROUND_TRANSITION_DURATION, + auction_duration: AUCTION_DURATION, + round_duration: ROUND_DURATION }; args.serialize(ref calldata); diff --git a/src/tests/vault/liquidity_providers/withdrawal_queue_tests.cairo b/src/tests/vault/liquidity_providers/withdrawal_queue_tests.cairo index 0fb3880e..e172bfed 100644 --- a/src/tests/vault/liquidity_providers/withdrawal_queue_tests.cairo +++ b/src/tests/vault/liquidity_providers/withdrawal_queue_tests.cairo @@ -1074,7 +1074,13 @@ fn test_queueing_withdrawal_event() { let queued_amount2 = (deposit_amount * bps2.into()) / BPS_u256; assert_event_withdrawal_queued( - vault.contract_address(), liquidity_provider, bps2, 1, queued_amount, queued_amount2, queued_amount2 + vault.contract_address(), + liquidity_provider, + bps2, + 1, + queued_amount, + queued_amount2, + queued_amount2 ); } diff --git a/src/tests/vault/state_transition/option_settle_tests.cairo b/src/tests/vault/state_transition/option_settle_tests.cairo index 43b10189..77575efe 100644 --- a/src/tests/vault/state_transition/option_settle_tests.cairo +++ b/src/tests/vault/state_transition/option_settle_tests.cairo @@ -6,7 +6,7 @@ use starknet::{ use openzeppelin_utils::serde::SerializedAppend; use openzeppelin_token::erc20::interface::ERC20ABIDispatcherTrait; use pitch_lake::{ - library::{eth::Eth, constants::{ROUND_TRANSITION_PERIOD, AUCTION_RUN_TIME, OPTION_RUN_TIME}}, + library::{eth::Eth}, vault::{ contract::Vault, interface::{ @@ -33,7 +33,7 @@ use pitch_lake::{ }, setup::{ deploy_vault_with_events, setup_facade, setup_test_auctioning_providers, - setup_test_running + setup_test_running, AUCTION_DURATION, ROUND_TRANSITION_DURATION, ROUND_DURATION }, }, lib::{ @@ -126,9 +126,9 @@ fn test_first_round_deployed_event() { let mut current_round = vault.get_current_round(); let exp_deployment_date = get_block_timestamp(); - let exp_auction_start_date = exp_deployment_date + ROUND_TRANSITION_PERIOD; - let exp_auction_end_date = exp_auction_start_date + AUCTION_RUN_TIME; - let exp_option_settlement_date = exp_auction_end_date + OPTION_RUN_TIME; + let exp_auction_start_date = exp_deployment_date + ROUND_TRANSITION_DURATION; + let exp_auction_end_date = exp_auction_start_date + AUCTION_DURATION; + let exp_option_settlement_date = exp_auction_end_date + ROUND_DURATION; assert_event_option_round_deployed_single( vault.contract_address(), diff --git a/src/vault/contract.cairo b/src/vault/contract.cairo index e04d48c5..df848839 100644 --- a/src/vault/contract.cairo +++ b/src/vault/contract.cairo @@ -32,6 +32,9 @@ mod Vault { vault_type: VaultType, alpha: u128, strike_level: i128, + round_transition_duration: u64, + auction_duration: u64, + round_duration: u64, /// l1_data: Map, option_round_class_hash: ClassHash, @@ -71,13 +74,19 @@ mod Vault { eth_address, option_round_class_hash, strike_level, - alpha } = + alpha, + round_transition_duration, + auction_duration, + round_duration } = args; // @dev Set the Vault's parameters self.fossil_client_address.write(fossil_client_address); self.eth_address.write(eth_address); self.option_round_class_hash.write(option_round_class_hash); + self.round_transition_duration.write(round_transition_duration); + self.auction_duration.write(auction_duration); + self.round_duration.write(round_duration); // @dev Alpha is between 0.01% and 100.00% assert(alpha.is_non_zero() && alpha <= BPS_u128, Errors::AlphaOutOfRange); @@ -241,6 +250,20 @@ mod Vault { fn get_strike_level(self: @ContractState) -> i128 { self.strike_level.read() } + + fn get_round_transition_duration(self: @ContractState) -> u64 { + self.round_transition_duration.read() + } + + fn get_auction_duration(self: @ContractState) -> u64 { + self.auction_duration.read() + } + + fn get_round_duration(self: @ContractState) -> u64 { + self.round_duration.read() + } + + fn get_round_address(self: @ContractState, option_round_id: u64) -> ContractAddress { self.round_addresses.read(option_round_id) } @@ -527,7 +550,12 @@ mod Vault { .emit( Event::WithdrawalQueued( WithdrawalQueued { - account, bps, round_id: current_round_id, account_queued_liquidity_before, account_queued_liquidity_now, vault_queued_liquidity_now + account, + bps, + round_id: current_round_id, + account_queued_liquidity_before, + account_queued_liquidity_now, + vault_queued_liquidity_now } ) ); @@ -765,8 +793,18 @@ mod Vault { // @dev Create this round's constructor args let mut calldata: Array = array![]; let pricing_data = self.convert_l1_data_to_round_data(l1_data); + + let round_transition_duration = self.round_transition_duration.read(); + let auction_duration = self.auction_duration.read(); + let round_duration = self.round_duration.read(); + let constructor_args = OptionRoundConstructorArgs { - vault_address, round_id, pricing_data + vault_address, + round_id, + pricing_data, + round_transition_duration, + auction_duration, + round_duration }; calldata.append_serde(constructor_args); diff --git a/src/vault/interface.cairo b/src/vault/interface.cairo index 8a6b06e5..35bb3b7b 100644 --- a/src/vault/interface.cairo +++ b/src/vault/interface.cairo @@ -19,6 +19,9 @@ struct ConstructorArgs { option_round_class_hash: ClassHash, alpha: u128, strike_level: i128, + round_transition_duration: u64, + auction_duration: u64, + round_duration: u64, } // The interface for the vault contract @@ -41,10 +44,19 @@ trait IVault { // @dev The the Fossil Client's address fn get_fossil_client_address(self: @TContractState) -> ContractAddress; - // @return the current option round id + // @dev The number of seconds between a round deploying and its auction starting + fn get_round_transition_duration(self: @TContractState) -> u64; + + // @dev The number of seconds a round's auction runs for + fn get_auction_duration(self: @TContractState) -> u64; + + // @dev The number of seconds between a round's auction ending and the round settling + fn get_round_duration(self: @TContractState) -> u64; + + // @return The current option round id fn get_current_round_id(self: @TContractState) -> u64; - // @return the contract address of the option round + // @return The contract address of the option round fn get_round_address(self: @TContractState, option_round_id: u64) -> ContractAddress; /// Liquidity