diff --git a/README.md b/README.md index 7373624..2e32538 100644 --- a/README.md +++ b/README.md @@ -95,12 +95,12 @@ with the private key of the delegator account. Make sure the account's balance c The output will look like this: ``` Running version: 2 - Current stake: 10000000000000000000000000 ZIL - Current rewards: 110314207650273223687 ZIL + Current stake: 10000000000000000000000000 wei + Current rewards: 110314207650273223687 wei LST address: 0x9e5c257D1c6dF74EaA54e58CdccaCb924669dc83 Owner balance: 10000000000000000000000000 LST - Staker balance before: 99899145245801454561224 ZIL 0 LST - Staker balance after: 99699145245801454561224 ZIL 199993793908430833324 LST + Staker balance before: 99899145245801454561224 wei 0 LST + Staker balance after: 99699145245801454561224 wei 199993793908430833324 LST ``` Note that the staker LST balance in the output will be different from the actual LST balance which you can query by running @@ -120,12 +120,12 @@ with the private key of an account that holds some LST. The output will look like this: ``` Running version: 2 - Current stake: 10000000000000000000000000 ZIL - Current rewards: 331912568306010928520 ZIL + Current stake: 10000000000000000000000000 wei + Current rewards: 331912568306010928520 wei LST address: 0x9e5c257D1c6dF74EaA54e58CdccaCb924669dc83 Owner balance: 10000000000000000000000000 LST - Staker balance before: 99698814298179759361224 ZIL 199993784619390291653 LST - Staker balance after: 99698814298179759361224 ZIL 99993784619390291653 LST + Staker balance before: 99698814298179759361224 wei 199993784619390291653 LST + Staker balance after: 99698814298179759361224 wei 99993784619390291653 LST ``` Last but not least, to claim the amount that is available after the unbonding period, run @@ -137,6 +137,6 @@ with the private key of an account that unstaked some LST. The output will look like this: ``` Running version: 2 - Staker balance before: 99698086421983460161224 ZIL - Staker balance after: 99798095485861371162343 ZIL + Staker balance before: 99698086421983460161224 wei + Staker balance after: 99798095485861371162343 wei ``` \ No newline at end of file diff --git a/claim.sh b/claim.sh index c44bada..d0f9021 100755 --- a/claim.sh +++ b/claim.sh @@ -1,16 +1,22 @@ #!/bin/bash -if [ $# -ne 1 ]; then - echo "Provide a staker private key as an arguments." +if [ $# -ne 2 ]; then + echo "Provide the delegation contract address and a staker private key as arguments." exit 1 fi -forge script script/claim_Delegation.s.sol --rpc-url http://localhost:4201 --broadcast --legacy --sig "run(address payable)" 0x7A0b7e6D24eDe78260c9ddBD98e828B0e11A8EA2 --private-key $1 -vvvv && \ -block=$(cast rpc eth_blockNumber --rpc-url http://localhost:4201 | tr -d '"' | cast to-dec --base-in 16) && \ -echo rewardsAfterClaiming = $(cast call 0x7A0b7e6D24eDe78260c9ddBD98e828B0e11A8EA2 "getRewards()(uint256)" --block $block --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ -echo taxedRewardsAfterClaiming = $(cast call 0x7A0b7e6D24eDe78260c9ddBD98e828B0e11A8EA2 "getTaxedRewards()(uint256)" --block $block --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ -echo $(date +"%T,%3N") $block && \ -block=$((block-1)) && \ -echo rewardsBeforeClaiming = $(cast call 0x7A0b7e6D24eDe78260c9ddBD98e828B0e11A8EA2 "getRewards()(uint256)" --block $block --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ -echo taxedRewardsBeforeClaiming = $(cast call 0x7A0b7e6D24eDe78260c9ddBD98e828B0e11A8EA2 "getTaxedRewards()(uint256)" --block $block --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ -echo $(date +"%T,%3N") $block +staker=$(cast wallet address $2) && \ +forge script script/claim_Delegation.s.sol --rpc-url http://localhost:4201 --broadcast --legacy --sig "run(address payable)" $1 --private-key $2 -vvvv && \ +block=$(cast rpc eth_blockNumber --rpc-url http://localhost:4201) && \ +block_num=$(echo $block | tr -d '"' | cast to-dec --base-in 16) && \ +echo rewardsAfterClaiming = $(cast call $1 "getRewards()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ +echo taxedRewardsAfterClaiming = $(cast call $1 "getTaxedRewards()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ +staker_wei_after=$(cast rpc eth_getBalance $staker $block --rpc-url http://localhost:4201 | tr -d '"' | cast to-dec --base-in 16) && \ +echo $(date +"%T,%3N") $block_num && \ +block_num=$((block_num-1)) && \ +block=$(echo $block_num | cast to-hex --base-in 10) && \ +echo rewardsBeforeClaiming = $(cast call $1 "getRewards()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ +echo taxedRewardsBeforeClaiming = $(cast call $1 "getTaxedRewards()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ +staker_wei_before=$(cast rpc eth_getBalance $staker $block --rpc-url http://localhost:4201 | tr -d '"' | cast to-dec --base-in 16) && \ +echo claimed amount - gas fee = $(bc -l <<< $staker_wei_after-$staker_wei_before) wei +echo $(date +"%T,%3N") $block_num diff --git a/script/claim_Delegation.s.sol b/script/claim_Delegation.s.sol index 78a75fc..eabb46c 100644 --- a/script/claim_Delegation.s.sol +++ b/script/claim_Delegation.s.sol @@ -18,7 +18,7 @@ contract Claim is Script { delegation.version() ); - console.log("Staker balance before: %s ZIL", + console.log("Staker balance before: %s wei", staker.balance ); @@ -26,7 +26,7 @@ contract Claim is Script { delegation.claim(); - console.log("Staker balance after: %s ZIL", + console.log("Staker balance after: %s wei", staker.balance ); } diff --git a/script/stake_Delegation.s.sol b/script/stake_Delegation.s.sol index 79f2385..82077d8 100644 --- a/script/stake_Delegation.s.sol +++ b/script/stake_Delegation.s.sol @@ -21,7 +21,7 @@ contract Stake is Script { delegation.version() ); - console.log("Current stake: %s ZIL \r\n Current rewards: %s ZIL", + console.log("Current stake: %s wei \r\n Current rewards: %s wei", delegation.getStake(), delegation.getRewards() ); @@ -35,7 +35,7 @@ contract Stake is Script { lst.balanceOf(owner) ); - console.log("Staker balance before: %s ZIL %s LST", + console.log("Staker balance before: %s wei %s LST", staker.balance, lst.balanceOf(staker) ); @@ -46,7 +46,7 @@ contract Stake is Script { value: amount }(); - console.log("Staker balance after: %s ZIL %s LST", + console.log("Staker balance after: %s wei %s LST", staker.balance, lst.balanceOf(staker) ); diff --git a/script/unstake_Delegation.s.sol b/script/unstake_Delegation.s.sol index f9fab0b..06e29a8 100644 --- a/script/unstake_Delegation.s.sol +++ b/script/unstake_Delegation.s.sol @@ -21,7 +21,7 @@ contract Unstake is Script { delegation.version() ); - console.log("Current stake: %s ZIL \r\n Current rewards: %s ZIL", + console.log("Current stake: %s wei \r\n Current rewards: %s wei", delegation.getStake(), delegation.getRewards() ); @@ -31,11 +31,11 @@ contract Unstake is Script { address(lst) ); - console.log("Owner LST balance: %s LST", + console.log("Owner balance: %s LST", lst.balanceOf(owner) ); - console.log("Staker balance before: %s ZIL %s LST", + console.log("Staker balance before: %s wei %s LST", staker.balance, lst.balanceOf(staker) ); @@ -50,7 +50,7 @@ contract Unstake is Script { amount ); - console.log("Staker balance after: %s ZIL %s LST", + console.log("Staker balance after: %s wei %s LST", staker.balance, lst.balanceOf(staker) ); diff --git a/stake.sh b/stake.sh index e528b81..1b0139f 100755 --- a/stake.sh +++ b/stake.sh @@ -1,16 +1,22 @@ #!/bin/bash -if [ $# -ne 2 ]; then - echo "Provide a staker private key and the amount in wei as arguments." +if [ $# -ne 3 ]; then + echo "Provide the delegation contract address, a staker private key and an amount in wei as arguments." exit 1 fi -forge script script/stake_Delegation.s.sol --rpc-url http://localhost:4201 --broadcast --legacy --sig "run(address payable, uint256)" 0x7A0b7e6D24eDe78260c9ddBD98e828B0e11A8EA2 $2 --private-key $1 && \ -block=$(cast rpc eth_blockNumber --rpc-url http://localhost:4201 | tr -d '"' | cast to-dec --base-in 16) && \ -echo rewardsAfterStaking = $(cast call 0x7A0b7e6D24eDe78260c9ddBD98e828B0e11A8EA2 "getRewards()(uint256)" --block $block --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ -echo taxedRewardsAfterStaking = $(cast call 0x7A0b7e6D24eDe78260c9ddBD98e828B0e11A8EA2 "getTaxedRewards()(uint256)" --block $block --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ -echo $(date +"%T,%3N") $block && \ -block=$((block-1)) && \ -echo rewardsBeforeStaking = $(cast call 0x7A0b7e6D24eDe78260c9ddBD98e828B0e11A8EA2 "getRewards()(uint256)" --block $block --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ -echo taxedRewardsBeforeStaking = $(cast call 0x7A0b7e6D24eDe78260c9ddBD98e828B0e11A8EA2 "getTaxedRewards()(uint256)" --block $block --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ -echo $(date +"%T,%3N") $block \ No newline at end of file +staker=$(cast wallet address $2) && \ +forge script script/stake_Delegation.s.sol --rpc-url http://localhost:4201 --broadcast --legacy --sig "run(address payable, uint256)" $1 $3 --private-key $2 && \ +block=$(cast rpc eth_blockNumber --rpc-url http://localhost:4201) && \ +block_num=$(echo $block | tr -d '"' | cast to-dec --base-in 16) && \ +echo rewardsAfterStaking = $(cast call $1 "getRewards()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ +echo taxedRewardsAfterStaking = $(cast call $1 "getTaxedRewards()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ +staker_wei_after=$(cast rpc eth_getBalance $staker $block --rpc-url http://localhost:4201 | tr -d '"' | cast to-dec --base-in 16) && \ +echo $(date +"%T,%3N") $block_num && \ +block_num=$((block_num-1)) && \ +block=$(echo $block_num | cast to-hex --base-in 10) && \ +echo rewardsBeforeStaking = $(cast call $1 "getRewards()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ +echo taxedRewardsBeforeStaking = $(cast call $1 "getTaxedRewards()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ +staker_wei_before=$(cast rpc eth_getBalance $staker $block --rpc-url http://localhost:4201 | tr -d '"' | cast to-dec --base-in 16) && \ +echo staked amount + gas fee = $(bc -l <<< $staker_wei_before-$staker_wei_after) wei +echo $(date +"%T,%3N") $block_num \ No newline at end of file diff --git a/state.sh b/state.sh index a2baad6..1eaf673 100755 --- a/state.sh +++ b/state.sh @@ -1,32 +1,34 @@ #!/bin/bash -if [ $# -ne 1 ]; then - echo "Provide a staker address as an argument." +if [ $# -ne 2 ]; then + echo "Provide the delegation contract address and a staker address as arguments." exit 1 fi block=$(cast rpc eth_blockNumber --rpc-url http://localhost:4201) && \ block_num=$(echo $block | tr -d '"' | cast to-dec --base-in 16) && \ echo $(date +"%T,%3N") $block_num && \ -echo rewardsBeforeUnstaking = $(cast rpc eth_getBalance 0x7A0b7e6D24eDe78260c9ddBD98e828B0e11A8EA2 $block --rpc-url http://localhost:4201 | tr -d '"' | cast to-dec --base-in 16) && \ -x=$(cast call 0x9e5c257D1c6dF74EaA54e58CdccaCb924669dc83 "balanceOf(address)(uint256)" 0x15fc323DFE5D5DCfbeEdc25CEcbf57f676634d77 --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ +owner=$(cast call $1 "owner()(address)" --block $block_num --rpc-url http://localhost:4201) && \ +lst=$(cast call $1 "getLST()(address)" --block $block_num --rpc-url http://localhost:4201) && \ +echo rewardsBeforeUnstaking = $(cast rpc eth_getBalance $1 $block --rpc-url http://localhost:4201 | tr -d '"' | cast to-dec --base-in 16) && \ +x=$(cast call $lst "balanceOf(address)(uint256)" $owner --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ owner_lst=$(cast to-unit $x ether) && \ -x=$(cast rpc eth_getBalance 0x15fc323DFE5D5DCfbeEdc25CEcbf57f676634d77 $block --rpc-url http://localhost:4201 | tr -d '"' | cast to-dec --base-in 16) && \ +x=$(cast rpc eth_getBalance $owner $block --rpc-url http://localhost:4201 | tr -d '"' | cast to-dec --base-in 16) && \ owner_zil=$(cast to-unit $x ether) && \ echo owner: $owner_lst LST && echo owner: $owner_zil ZIL && \ -x=$(cast call 0x9e5c257D1c6dF74EaA54e58CdccaCb924669dc83 "balanceOf(address)(uint256)" $1 --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ +x=$(cast call $lst "balanceOf(address)(uint256)" $2 --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ staker_lst=$(cast to-unit $x ether) && \ -x=$(cast rpc eth_getBalance $1 $block --rpc-url http://localhost:4201 | tr -d '"' | cast to-dec --base-in 16) && \ +x=$(cast rpc eth_getBalance $2 $block --rpc-url http://localhost:4201 | tr -d '"' | cast to-dec --base-in 16) && \ staker_zil=$(cast to-unit $x ether) && \ echo staker: $staker_lst LST && echo staker: $staker_zil ZIL && \ -x=$(cast call 0x9e5c257D1c6dF74EaA54e58CdccaCb924669dc83 "totalSupply()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ -y=$(cast call 0x7A0b7e6D24eDe78260c9ddBD98e828B0e11A8EA2 "getRewards()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ -z=$(cast call 0x7A0b7e6D24eDe78260c9ddBD98e828B0e11A8EA2 "getStake()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ +x=$(cast call $lst "totalSupply()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ +y=$(cast call $1 "getRewards()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ +z=$(cast call $1 "getStake()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ price=$(bc -l <<< \($y+$z\)/$x) && \ echo LST supply: $(cast to-unit $x ether) && \ echo LST price: $price && \ echo staker LST value: $(bc -l <<< $staker_lst*$price) ZIL && \ -echo getStake = $(cast call 0x7A0b7e6D24eDe78260c9ddBD98e828B0e11A8EA2 "getStake()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ -echo getRewards = $(cast call 0x7A0b7e6D24eDe78260c9ddBD98e828B0e11A8EA2 "getRewards()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ -echo getTaxedRewards = $(cast call 0x7A0b7e6D24eDe78260c9ddBD98e828B0e11A8EA2 "getTaxedRewards()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ -echo getTotalWithdrawals = $(cast call 0x7A0b7e6D24eDe78260c9ddBD98e828B0e11A8EA2 "getTotalWithdrawals()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') \ No newline at end of file +echo getStake = $z && \ +echo getRewards = $y && \ +echo getTaxedRewards = $(cast call $1 "getTaxedRewards()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ +echo getTotalWithdrawals = $(cast call $1 "getTotalWithdrawals()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') \ No newline at end of file diff --git a/test/Delegation.t.sol b/test/Delegation.t.sol index 7817d28..60c6c44 100644 --- a/test/Delegation.t.sol +++ b/test/Delegation.t.sol @@ -771,19 +771,19 @@ contract DelegationTest is Test { to stake, unstake and claim on the network your local node is connected to. Before and after running the STAKING, UNSTAKING and CLAIMING scripts presented below, - always execute the following bash script to capture the values needed in the Foundry test below. + always execute the STATE script to capture the values needed in the Foundry test below. STATE: - chmod +x state.sh && ./state.sh + chmod +x state.sh && ./state.sh STAKING: - chmod +x stake.sh && ./stake.sh 10000000000000000000000 + chmod +x stake.sh && ./stake.sh 10000000000000000000000 UNSTAKING: - chmod +x unstake.sh && ./unstake.sh + chmod +x unstake.sh && ./unstake.sh CLAIMING: - chmod +x claim.sh && ./claim.sh + chmod +x claim.sh && ./claim.sh Before running the test, replace the address on the first line with */ @@ -798,7 +798,7 @@ contract DelegationTest is Test { uint256 taxedRewardsAfterStaking = rewardsBeforeStaking - (rewardsBeforeStaking - taxedRewardsBeforeStaking) / uint256(10); Console.log("Expected taxed rewards after staking: %s.%s%s ZIL", taxedRewardsAfterStaking); - // Insert the following value output by the UNSTAKE script + // Insert the following value output by the UNSTAKING script uint256 rewardsBeforeUnstaking = 233367080700403454378; run( 10_000_000 ether, @@ -812,16 +812,16 @@ contract DelegationTest is Test { true // initialDeposit ); // Replace the values below in the same order with the values output by the STATE script - // run after the CLAIM script or logged by the CLAIM script itself + // run after the CLAIMING script or logged by the CLAIMING script itself // the staker's ZIL balance in wei according to the STATE script after claiming // the staker's ZIL balance in wei according to the STATE script before claiming - // the claiming transaction fee in wei output by the CLAIM script + // the claiming transaction fee in wei output by the CLAIMING script Console.log("Expected staker balance after claiming: %s.%s%s ZIL", 100_000 ether - delegatedAmount + 100013.464887553198739807 ether - 90013.819919979031083499 ether + 0.3897714316896 ether ); // Replace the values below in the same order with values output by the STATE script - // run before the STAKE and after the UNSTAKE scripts or logged by those script themselves + // run before the STAKING and after the UNSTAKE scripts or logged by those script themselves // the owner's ZIL balance in wei according to the STATE script after unstaking // the owner's ZIL balance in wei according to the STATE script before staking // the transaction fees in wei output by the STAKING and UNSTAKING scripts diff --git a/unstake.sh b/unstake.sh index 4d0d597..78740b9 100755 --- a/unstake.sh +++ b/unstake.sh @@ -1,22 +1,33 @@ #!/bin/bash -if [ $# -lt 1 ]; then - echo "Provide a staker private key and optionally the number of shares as arguments." +if [ $# -lt 2 ]; then + echo "Provide the delegation contract address, a staker private key and optionally the number of shares as arguments." exit 1 fi -if [ $# -eq 2 ]; then - amount="$2" +if [ $# -eq 3 ]; then + amount="$3" else amount=0 fi -forge script script/unstake_Delegation.s.sol --rpc-url http://localhost:4201 --broadcast --legacy --sig "run(address payable, uint256)" 0x7A0b7e6D24eDe78260c9ddBD98e828B0e11A8EA2 $amount --private-key $1 && \ -block=$(cast rpc eth_blockNumber --rpc-url http://localhost:4201 | tr -d '"' | cast to-dec --base-in 16) && \ -echo rewardsAfterUnstaking = $(cast call 0x7A0b7e6D24eDe78260c9ddBD98e828B0e11A8EA2 "getRewards()(uint256)" --block $block --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ -echo taxedRewardsAfterUnstaking = $(cast call 0x7A0b7e6D24eDe78260c9ddBD98e828B0e11A8EA2 "getTaxedRewards()(uint256)" --block $block --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ -echo $(date +"%T,%3N") $block && \ -block=$((block-1)) && \ -echo rewardsBeforeUnstaking = $(cast call 0x7A0b7e6D24eDe78260c9ddBD98e828B0e11A8EA2 "getRewards()(uint256)" --block $block --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ -echo taxedRewardsBeforeUnstaking = $(cast call 0x7A0b7e6D24eDe78260c9ddBD98e828B0e11A8EA2 "getTaxedRewards()(uint256)" --block $block --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ -echo $(date +"%T,%3N") $block \ No newline at end of file +staker=$(cast wallet address $2) && \ +forge script script/unstake_Delegation.s.sol --rpc-url http://localhost:4201 --broadcast --legacy --sig "run(address payable, uint256)" $1 $amount --private-key $2 && \ +block=$(cast rpc eth_blockNumber --rpc-url http://localhost:4201) && \ +block_num=$(echo $block | tr -d '"' | cast to-dec --base-in 16) && \ +echo rewardsAfterUnstaking = $(cast call $1 "getRewards()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ +echo taxedRewardsAfterUnstaking = $(cast call $1 "getTaxedRewards()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ +echo $(date +"%T,%3N") $block_num && \ +block_num=$((block_num-1)) && \ +block=$(echo $block_num | cast to-hex --base-in 10) && \ +echo rewardsBeforeUnstaking = $(cast call $1 "getRewards()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ +echo taxedRewardsBeforeUnstaking = $(cast call $1 "getTaxedRewards()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ +lst=$(cast call $1 "getLST()(address)" --block $block_num --rpc-url http://localhost:4201) && \ +if [[ "$amount" == "0" ]]; then amount=$(cast call $lst "balanceOf(address)(uint256)" $staker --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g'); fi && \ +x=$(cast call $lst "totalSupply()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ +y=$(cast call $1 "getRewards()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ +z=$(cast call $1 "getStake()(uint256)" --block $block_num --rpc-url http://localhost:4201 | sed 's/\[[^]]*\]//g') && \ +price=$(bc -l <<< \($y+$z\)/$x) && \ +echo LST price: $price && \ +echo unstaked LST value: $(bc -l <<< $amount*$price/10^18) ZIL && \ +echo $(date +"%T,%3N") $block_num \ No newline at end of file