diff --git a/program/src/lib.rs b/program/src/lib.rs index 24c91fbf2..f2b9a5204 100644 --- a/program/src/lib.rs +++ b/program/src/lib.rs @@ -47,7 +47,7 @@ pub fn find_authority_program_address( Pubkey::find_program_address(&[&lido_address.to_bytes(), authority], program_id) } -/// The minimum amount to put in a stake account (1 SOL). +/// The minimum amount to put in a stake account (1 SOL + rent_exempt). /// /// For stake accounts, there is a minimum balance for the account to be /// rent-exempt, that depends on the size of the stake program's stake state @@ -58,7 +58,8 @@ pub fn find_authority_program_address( /// need to be able to merge stake accounts, we also need to make sure that they /// contain enough stake that they will earn at least one lamport per epoch. /// 1 SOL should be sufficient for that. -pub const MINIMUM_STAKE_ACCOUNT_BALANCE: token::Lamports = token::Lamports(1_000_000_000); +/// https://github.com/solana-labs/solana/issues/24357#issuecomment-1225776709 +pub const MINIMUM_STAKE_ACCOUNT_BALANCE: token::Lamports = token::Lamports(1_002_282_880); /// The maximum number of unstake accounts that a validator can have simultaneously. pub const MAXIMUM_UNSTAKE_ACCOUNTS: u64 = 3; diff --git a/program/tests/tests/stake_deposit.rs b/program/tests/tests/stake_deposit.rs index e4cce1805..d1e904021 100644 --- a/program/tests/tests/stake_deposit.rs +++ b/program/tests/tests/stake_deposit.rs @@ -8,6 +8,7 @@ use lido::error::LidoError; use lido::processor::StakeType; use lido::state::{ListEntry, StakeDeposit}; use lido::token::Lamports; +use lido::MINIMUM_STAKE_ACCOUNT_BALANCE; use solana_program_test::tokio; use solana_sdk::signer::Signer; @@ -228,7 +229,7 @@ async fn test_stake_deposit_fails_if_validator_with_less_stake_exists() { .stake_deposit( v1.vote_account, StakeDeposit::Append, - Lamports(1_000_000_000), + MINIMUM_STAKE_ACCOUNT_BALANCE, ) .await; @@ -238,7 +239,7 @@ async fn test_stake_deposit_fails_if_validator_with_less_stake_exists() { .try_stake_deposit( v1.vote_account, StakeDeposit::Append, - Lamports(1_000_000_000), + MINIMUM_STAKE_ACCOUNT_BALANCE, ) .await; assert_solido_error!(result, LidoError::ValidatorWithLessStakeExists); @@ -248,7 +249,7 @@ async fn test_stake_deposit_fails_if_validator_with_less_stake_exists() { .stake_deposit( v2.vote_account, StakeDeposit::Append, - Lamports(1_000_000_000), + MINIMUM_STAKE_ACCOUNT_BALANCE, ) .await; @@ -257,7 +258,7 @@ async fn test_stake_deposit_fails_if_validator_with_less_stake_exists() { .stake_deposit( v2.vote_account, StakeDeposit::Append, - Lamports(1_000_000_000), + MINIMUM_STAKE_ACCOUNT_BALANCE, ) .await; } diff --git a/program/tests/tests/update_stake_account_balance.rs b/program/tests/tests/update_stake_account_balance.rs index 15dc41432..9acf44695 100644 --- a/program/tests/tests/update_stake_account_balance.rs +++ b/program/tests/tests/update_stake_account_balance.rs @@ -4,6 +4,7 @@ use lido::error::LidoError; use lido::state::StakeDeposit; use lido::token::Lamports; +use lido::MINIMUM_STAKE_ACCOUNT_BALANCE; use solana_program_test::tokio; use testlib::assert_solido_error; use testlib::solido_context::Context; @@ -25,7 +26,7 @@ async fn test_update_stake_account_balance() { assert_eq!(solido_before, solido_after); // Deposit and stake the deposit with the validator. This creates one stake account. - let initial_amount = Lamports(1_000_000_000); + let initial_amount = MINIMUM_STAKE_ACCOUNT_BALANCE; context.deposit(initial_amount).await; let stake_account = context .stake_deposit(validator.vote_account, StakeDeposit::Append, initial_amount) diff --git a/scripts/migrate.sh b/scripts/migrate.sh index e31d300e1..cce5b50c2 100644 --- a/scripts/migrate.sh +++ b/scripts/migrate.sh @@ -5,7 +5,7 @@ cd solido_old # start local validator -rm -rf tests/.keys/ test-ledger/ tests/__pycache__/ && solana-test-validator --slots-per-epoch 300 +rm -rf tests/.keys/ test-ledger/ tests/__pycache__/ && solana-test-validator --slots-per-epoch 150 # withdraw SOLs from local validator vote account to start fresh solana withdraw-from-vote-account test-ledger/vote-account-keypair.json v9zvcQbyuCAuFw6rt7VLedE2qV4NAY8WLaLg37muBM2 999999.9 --authorized-withdrawer test-ledger/vote-account-keypair.json @@ -21,6 +21,10 @@ solana withdraw-from-vote-account test-ledger/vote-account-keypair.json v9zvcQby # EPOCH 1 +# receive some rewards + +# EPOCH 2 + # deactivate validators ../solido/scripts/update_solido_version.py --config ../solido_test.json deactivate-validators --keypair-path ./tests/.keys/maintainer.json > output ./target/debug/solido --config ../solido_test.json --keypair-path ./tests/.keys/maintainer.json multisig approve-batch --transaction-addresses-path output @@ -41,7 +45,7 @@ solana --url localhost transfer --allow-unfunded-recipient ../solido_old/tests/. # propose migration scripts/update_solido_version.py --config ../solido_test.json propose-migrate --keypair-path ../solido_old/tests/.keys/maintainer.json >> output -# EPOCH 2 +# EPOCH 3 # wait for maintainers to remove validators, approve program update and migration ./target/debug/solido --config ../solido_test.json --keypair-path ../solido_old/tests/.keys/maintainer.json multisig approve-batch --transaction-addresses-path output @@ -51,7 +55,11 @@ scripts/update_solido_version.py --config ../solido_test.json propose-migrate -- echo ADD_VALIDATOR_TRANSACTION > ../solido/output ./target/debug/solido --config ../solido_test.json --keypair-path ../solido_old/tests/.keys/maintainer.json multisig approve-batch --transaction-addresses-path output -# EPOCH 3 +# EPOCH 4 # try to withdraw ./target/debug/solido --config ~/Documents/solido_test.json withdraw --amount-st-sol 1.1 + +# withdraw developer some fee to self +spl-token transfer --from DEVELOPER_FEE_ADDRESS STSOL_MINT_ADDRESS 0.0001 $(solana-keygen pubkey) --owner ~/developer_fee_key.json +# spl-token account-info --address DEVELOPER_FEE_ADDRESS diff --git a/tests/test_solido.py b/tests/test_solido.py index 76e58c770..6caff3321 100755 --- a/tests/test_solido.py +++ b/tests/test_solido.py @@ -868,3 +868,30 @@ def set_max_validation_commission(fee: int) -> Any: ) number_validators = len(solido_instance['validators']['entries']) assert number_validators == 0 + + +# def test_rewards(): +# def balance(v1, v2, v3, reserve): +# return v1 + v2 + v3 + reserve + +# s1_before = balance(8.048978427, 9.054659727, 7.948410296, 2.4 + 0.00089088) +# s1 = balance(9.150682817, 9.054659727, 9.150682816, 0.09691397) +# assert s1_before == s1 +# s2 = balance(9.210892341, 9.126038084, 9.212256215, 0.10147973) +# rewards = s2 - s1 + +# def rewards_from_fees(t1, d1, a1, t2, d2, a2): +# dt = t2 - t1 +# print(f"dt {dt}, {0.04*rewards}, {dt-0.04*rewards}") +# dd = d2 - d1 +# print(f"dd {dd}, {0.01*rewards}, {dd-0.01*rewards}") +# da = a2 - a1 +# print(f"da {da}, {0.95*rewards}, {da-0.95*rewards}") +# return dt + dd + da + +# rewards_alt = rewards_from_fees( +# 0.008198959, 0.003279583, 0.147581266, 0.016108040, 0.005256852, 0.335421956 +# ) + +# diff = rewards - rewards_alt +# print(diff)