Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -733,11 +733,11 @@ impl Env {
/// 5% bonus, 50% close factor, 10% reserve factor (protocol's cut of interest),
/// kink at 80% utilization, 2%/20%/150% APR curve.
/// Slots in a year, which is how a reserve turns an APR into a per-slot rate.
/// 78_840_000 is a 400ms slot: 2.5 slots/second * 60 * 60 * 24 * 365. It is a
/// 157_680_000 is a 200ms slot: 5 slots/second * 60 * 60 * 24 * 365. It is a
/// test fixture, not a law: a deployment reads the slot time off the cluster it
/// points at (two `getBlockTime` results a known number of slots apart) and
/// updates the reserve when the protocol changes it.
pub const SLOTS_PER_YEAR: u64 = 78_840_000;
pub const SLOTS_PER_YEAR: u64 = 157_680_000;

pub fn default_config() -> ReserveConfig {
ReserveConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fn protocol_fees_accrue_and_owner_can_collect() {
// No interest has accrued yet, so no fees.
assert_eq!(env.reserve(&borrow).accumulated_protocol_fees, 0);

env.warp_slots(7_884_000);
env.warp_slots(SLOTS_PER_YEAR / 10);
env.refresh_reserve_only(&borrower, &borrow);

// Fees accrued, and they are ~10% (the reserve factor) of total interest.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod common;

use common::{ata, default_config, dollars, Env};
use common::{ata, default_config, dollars, Env, SLOTS_PER_YEAR};
use solana_signer::Signer;

/// After interest makes the pool worth more than its share supply, a deposit so
Expand All @@ -26,7 +26,7 @@ fn deposit_that_would_mint_zero_shares_is_rejected() {
.unwrap();

// Accrue enough interest that total liquidity exceeds the share supply.
env.warp_slots(7_884_000);
env.warp_slots(SLOTS_PER_YEAR / 10);
env.refresh_reserve_only(&borrower, &borrow);
assert!(env.reserve(&borrow).borrow_accumulation_factor > lending::constants::FIXED_POINT_SCALE);

Expand Down
4 changes: 2 additions & 2 deletions finance/lending/anchor/programs/lending/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -798,11 +798,11 @@ impl Env {
/// 5% bonus, 50% close factor, 10% reserve factor (protocol's cut of interest),
/// kink at 80% utilization, 2%/20%/150% APR curve.
/// Slots in a year, which is how a reserve turns an APR into a per-slot rate.
/// 78_840_000 is a 400ms slot: 2.5 slots/second * 60 * 60 * 24 * 365. It is a
/// 157_680_000 is a 200ms slot: 5 slots/second * 60 * 60 * 24 * 365. It is a
/// test fixture, not a law: a deployment reads the slot time off the cluster it
/// points at (two `getBlockTime` results a known number of slots apart) and
/// updates the reserve when the protocol changes it.
pub const SLOTS_PER_YEAR: u64 = 78_840_000;
pub const SLOTS_PER_YEAR: u64 = 157_680_000;

pub fn default_config() -> ReserveConfig {
ReserveConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn protocol_fees_accrue_and_owner_can_collect() {
// No interest has accrued yet, so no fees.
assert_eq!(env.reserve(&borrow).accumulated_protocol_fees, 0);

env.warp_slots(7_884_000);
env.warp_slots(SLOTS_PER_YEAR / 10);
env.refresh_reserve_only(&borrower, &borrow);

// Fees accrued, and they are ~10% (the reserve factor) of total interest.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod common;
use anchor_v2_testing::Signer;
use lending::errors::LendingError;

use common::{ata, default_config, dollars, Env};
use common::{ata, default_config, dollars, Env, SLOTS_PER_YEAR};

/// After interest makes the pool worth more than its share supply, a deposit so
/// small it would mint zero shares is rejected rather than silently giving the
Expand Down Expand Up @@ -35,7 +35,7 @@ fn deposit_that_would_mint_zero_shares_is_rejected() {
.unwrap();

// Accrue enough interest that total liquidity exceeds the share supply.
env.warp_slots(7_884_000);
env.warp_slots(SLOTS_PER_YEAR / 10);
env.refresh_reserve_only(&borrower, &borrow);
assert!(
env.reserve(&borrow).borrow_accumulation_factor > lending::constants::FIXED_POINT_SCALE
Expand Down
10 changes: 5 additions & 5 deletions finance/lending/quasar/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ const DECIMALS: u8 = 6;
const UNIT: u64 = 1_000_000; // 1 token at 6 decimals

/// Slots in a year, which is how a reserve turns an APR into a per-slot rate.
/// 78_840_000 is a 400ms slot: 2.5 slots/second * 60 * 60 * 24 * 365. It is a
/// 157_680_000 is a 200ms slot: 5 slots/second * 60 * 60 * 24 * 365. It is a
/// fixture, not a law: a deployment reads the slot time off the cluster it
/// points at and calls `update_slots_per_year` when the protocol changes it.
const SLOTS_PER_YEAR: u64 = 78_840_000;
const SLOTS_PER_YEAR: u64 = 157_680_000;

// Deterministic addresses.
const OWNER: Pubkey = Pubkey::new_from_array([1; 32]);
Expand Down Expand Up @@ -766,7 +766,7 @@ mod slot_warp {
world.borrow(500 * UNIT).assert_success();

// ~0.1 year passes; re-publish prices so feeds stay fresh.
world.svm.sysvars.warp_to_slot(7_884_000);
world.svm.sysvars.warp_to_slot(super::SLOTS_PER_YEAR / 10);
world.set_price(COLLATERAL_MINT, world.collateral_price, dollars(1));
world.set_price(BORROW_MINT, world.borrow_price, dollars(1));

Expand Down Expand Up @@ -821,7 +821,7 @@ mod slot_warp {
world.borrow(500 * UNIT).assert_success();

// First window, at the figure the reserve was created with.
let window = 7_884_000;
let window = super::SLOTS_PER_YEAR / 10;
let start = world.svm.sysvars.clock.slot;
world.svm.sysvars.warp_to_slot(start + window);
let first = balance(&world.collect_borrow_fees(), OWNER_BORROW);
Expand Down Expand Up @@ -854,7 +854,7 @@ mod slot_warp {

// ~0.1 year passes; interest accrues, and the reserve factor (10%)
// sets some of it aside for the market owner.
world.svm.sysvars.warp_to_slot(7_884_000);
world.svm.sysvars.warp_to_slot(super::SLOTS_PER_YEAR / 10);

let result = world.collect_borrow_fees();
result.assert_success();
Expand Down
Loading