Skip to content

Commit

Permalink
feat: reduce yield if not enough rewards (#514)
Browse files Browse the repository at this point in the history
* go

* code is good

* Checkpoint

* test: add test

* better test

* test

* revert this file

* clippy

* go

* go

* undo changes to stability

* cleanup
  • Loading branch information
guibescos authored Sep 2, 2024
1 parent b0634e9 commit 5a0f694
Show file tree
Hide file tree
Showing 19 changed files with 497 additions and 288 deletions.
161 changes: 0 additions & 161 deletions staking/integration-tests/src/integrity_pool/delegate.rs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub fn initialize_pool_reward_custody(
svm: &mut litesvm::LiteSVM,
payer: &Keypair,
pyth_token_mint: &Keypair,
reward_amount_override: Option<u64>,
) {
let pool_config_pubkey = get_pool_config_address();

Expand All @@ -30,6 +31,6 @@ pub fn initialize_pool_reward_custody(
payer,
get_pool_reward_custody_address(pyth_token_mint.pubkey()),
pyth_token_mint,
1_000_000 * FRAC_64_MULTIPLIER,
reward_amount_override.unwrap_or(1_000_000 * FRAC_64_MULTIPLIER),
);
}
8 changes: 7 additions & 1 deletion staking/integration-tests/src/integrity_pool/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,19 @@ use {

pub fn advance(svm: &mut LiteSVM, payer: &Keypair, publisher_caps: Pubkey) -> TransactionResult {
let pool_config = get_pool_config_address();
let pool_data = fetch_account_data::<PoolConfig>(svm, &pool_config).pool_data;
let PoolConfig {
pool_data,
pyth_token_mint,
..
} = fetch_account_data::<PoolConfig>(svm, &pool_config);
let pool_reward_custody = get_pool_reward_custody_address(pyth_token_mint);

let accounts = integrity_pool::accounts::Advance {
signer: payer.pubkey(),
pool_config,
publisher_caps,
pool_data,
pool_reward_custody,
};

let instruction_data = integrity_pool::instruction::Advance {};
Expand Down
14 changes: 8 additions & 6 deletions staking/integration-tests/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ pub struct SetupResult {
}

pub struct SetupProps {
pub init_config: bool,
pub init_target: bool,
pub init_mint: bool,
pub init_pool_data: bool,
pub init_publishers: bool,
pub init_config: bool,
pub init_target: bool,
pub init_mint: bool,
pub init_pool_data: bool,
pub init_publishers: bool,
pub reward_amount_override: Option<u64>,
}

pub fn setup(props: SetupProps) -> SetupResult {
Expand All @@ -54,6 +55,7 @@ pub fn setup(props: SetupProps) -> SetupResult {
init_mint,
init_pool_data,
init_publishers,
reward_amount_override,
} = props;

let pyth_token_mint = Keypair::new();
Expand Down Expand Up @@ -106,7 +108,7 @@ pub fn setup(props: SetupProps) -> SetupResult {

advance_n_epochs(&mut svm, &payer, 1);
if init_publishers {
initialize_pool_reward_custody(&mut svm, &payer, &pyth_token_mint);
initialize_pool_reward_custody(&mut svm, &payer, &pyth_token_mint, reward_amount_override);
let publisher_caps =
post_dummy_publisher_caps(&mut svm, &payer, publisher_keypair.pubkey(), 100);
advance(&mut svm, &payer, publisher_caps).unwrap();
Expand Down
Loading

0 comments on commit 5a0f694

Please sign in to comment.