Skip to content

Commit

Permalink
chore: edit backstop take rate to 7 decimals to normalize all configu…
Browse files Browse the repository at this point in the history
…ration inputs to 7 decimals
  • Loading branch information
mootz12 committed Jan 5, 2024
1 parent 44d4405 commit 7488e81
Show file tree
Hide file tree
Showing 19 changed files with 119 additions and 119 deletions.
8 changes: 4 additions & 4 deletions mocks/mock-pool-factory/src/pool_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ pub trait MockPoolFactoryTrait {
/// * `admin` - The admin address for the pool
/// * `name` - The name of the pool
/// * `oracle` - The oracle address for the pool
/// * `backstop_take_rate` - The backstop take rate for the pool
/// * `backstop_take_rate` - The backstop take rate for the pool (7 decimals)
fn deploy(
e: Env,
admin: Address,
name: Symbol,
salt: BytesN<32>,
oracle: Address,
backstop_take_rate: u64,
backstop_take_rate: u32,
max_positions: u32,
) -> Address;

Expand Down Expand Up @@ -65,14 +65,14 @@ impl MockPoolFactoryTrait for MockPoolFactory {
name: Symbol,
_salt: BytesN<32>,
oracle: Address,
backstop_take_rate: u64,
backstop_take_rate: u32,
max_positions: u32,
) -> Address {
storage::extend_instance(&e);
let pool_init_meta = storage::get_pool_init_meta(&e);

// verify backstop take rate is within [0,1) with 9 decimals
if backstop_take_rate >= 1_000_000_000 {
if backstop_take_rate >= 1_0000000 {
panic_with_error!(&e, PoolFactoryError::InvalidPoolInitArgs);
}

Expand Down
12 changes: 6 additions & 6 deletions pool-factory/src/pool_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use soroban_sdk::{
Symbol, Val, Vec,
};

const SCALAR_9: u64 = 1_000_000_000;
const SCALAR_7: u32 = 1_0000000;

#[contract]
pub struct PoolFactoryContract;
Expand All @@ -26,15 +26,15 @@ pub trait PoolFactory {
/// * `admin` - The admin address for the pool
/// * `name` - The name of the pool
/// * `oracle` - The oracle address for the pool
/// * `backstop_take_rate` - The backstop take rate for the pool
/// * `backstop_take_rate` - The backstop take rate for the pool (7 decimals)
/// * `max_positions` - The maximum user positions supported by the pool
fn deploy(
e: Env,
admin: Address,
name: Symbol,
salt: BytesN<32>,
oracle: Address,
backstop_take_rate: u64,
backstop_take_rate: u32,
max_positions: u32,
) -> Address;

Expand Down Expand Up @@ -66,15 +66,15 @@ impl PoolFactory for PoolFactoryContract {
name: Symbol,
salt: BytesN<32>,
oracle: Address,
backstop_take_rate: u64,
backstop_take_rate: u32,
max_positions: u32,
) -> Address {
admin.require_auth();
storage::extend_instance(&e);
let pool_init_meta = storage::get_pool_init_meta(&e);

// verify backstop take rate is within [0,1) with 9 decimals
if backstop_take_rate >= SCALAR_9 {
// verify backstop take rate is within [0,1) with 7 decimals
if backstop_take_rate >= SCALAR_7 {
panic_with_error!(&e, PoolFactoryError::InvalidPoolInitArgs);
}

Expand Down
4 changes: 2 additions & 2 deletions pool-factory/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn test_pool_factory() {

let oracle = Address::generate(&e);
let backstop_id = Address::generate(&e);
let backstop_rate: u64 = 100000;
let backstop_rate: u32 = 0_1000000;
let max_positions: u32 = 6;
let blnd_id = Address::generate(&e);
let usdc_id = Address::generate(&e);
Expand Down Expand Up @@ -154,7 +154,7 @@ fn test_pool_factory_invalid_pool_init_args() {

let bombadil = Address::generate(&e);
let oracle = Address::generate(&e);
let backstop_rate: u64 = 1_000_000_000;
let backstop_rate: u32 = 1_0000000;
let max_positions: u32 = 6;

let name1 = Symbol::new(&e, "pool1");
Expand Down
16 changes: 8 additions & 8 deletions pool/src/auctions/auction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ mod tests {

let pool_config = PoolConfig {
oracle: oracle_id,
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down Expand Up @@ -493,7 +493,7 @@ mod tests {

let pool_config = PoolConfig {
oracle: oracle_id,
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down Expand Up @@ -598,7 +598,7 @@ mod tests {
};
let pool_config = PoolConfig {
oracle: oracle_address,
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down Expand Up @@ -741,7 +741,7 @@ mod tests {
};
let pool_config = PoolConfig {
oracle: oracle_address,
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down Expand Up @@ -849,7 +849,7 @@ mod tests {
};
let pool_config = PoolConfig {
oracle: oracle_address,
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down Expand Up @@ -970,7 +970,7 @@ mod tests {
};
let pool_config = PoolConfig {
oracle: oracle_address,
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down Expand Up @@ -1159,7 +1159,7 @@ mod tests {
};
let pool_config = PoolConfig {
oracle: oracle_address,
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down Expand Up @@ -1281,7 +1281,7 @@ mod tests {
};
let pool_config = PoolConfig {
oracle: oracle_address,
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down
10 changes: 5 additions & 5 deletions pool/src/auctions/backstop_interest_auction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ mod tests {

let pool_config = PoolConfig {
oracle: oracle_id,
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down Expand Up @@ -340,7 +340,7 @@ mod tests {

let pool_config = PoolConfig {
oracle: oracle_id,
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down Expand Up @@ -448,7 +448,7 @@ mod tests {

let pool_config = PoolConfig {
oracle: oracle_id,
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down Expand Up @@ -535,7 +535,7 @@ mod tests {

let pool_config = PoolConfig {
oracle: Address::generate(&e),
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down Expand Up @@ -637,7 +637,7 @@ mod tests {

let pool_config = PoolConfig {
oracle: Address::generate(&e),
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down
14 changes: 7 additions & 7 deletions pool/src/auctions/bad_debt_auction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ mod tests {

let pool_config = PoolConfig {
oracle: oracle_id,
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down Expand Up @@ -453,7 +453,7 @@ mod tests {

let pool_config = PoolConfig {
oracle: oracle_id,
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down Expand Up @@ -588,7 +588,7 @@ mod tests {

let pool_config = PoolConfig {
oracle: oracle_id,
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down Expand Up @@ -696,7 +696,7 @@ mod tests {
);
let pool_config = PoolConfig {
oracle: Address::generate(&e),
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down Expand Up @@ -840,7 +840,7 @@ mod tests {
);
let pool_config = PoolConfig {
oracle: Address::generate(&e),
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down Expand Up @@ -993,7 +993,7 @@ mod tests {
);
let pool_config = PoolConfig {
oracle: Address::generate(&e),
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down Expand Up @@ -1158,7 +1158,7 @@ mod tests {
);
let pool_config = PoolConfig {
oracle: Address::generate(&e),
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down
14 changes: 7 additions & 7 deletions pool/src/auctions/user_liquidation_auction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ mod tests {
};
let pool_config = PoolConfig {
oracle,
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down Expand Up @@ -288,7 +288,7 @@ mod tests {
};
let pool_config = PoolConfig {
oracle: oracle_address,
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down Expand Up @@ -394,7 +394,7 @@ mod tests {
let liq_pct = 100;
let pool_config = PoolConfig {
oracle: oracle_address,
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down Expand Up @@ -502,7 +502,7 @@ mod tests {
let liq_pct = 46;
let pool_config = PoolConfig {
oracle: oracle_address,
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down Expand Up @@ -611,7 +611,7 @@ mod tests {
let liq_pct = 25;
let pool_config = PoolConfig {
oracle: oracle_address,
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down Expand Up @@ -731,7 +731,7 @@ mod tests {
};
let pool_config = PoolConfig {
oracle: oracle_address,
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down Expand Up @@ -907,7 +907,7 @@ mod tests {
};
let pool_config = PoolConfig {
oracle: oracle_address,
bstop_rate: 0_100_000_000,
bstop_rate: 0_1000000,
status: 0,
max_positions: 4,
};
Expand Down
12 changes: 6 additions & 6 deletions pool/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub trait Pool {
/// * `admin` - The Address for the admin
/// * `name` - The name of the pool
/// * `oracle` - The contract address of the oracle
/// * `backstop_take_rate` - The take rate for the backstop in stroops
/// * `backstop_take_rate` - The take rate for the backstop (7 decimals)
/// * `max_positions` - The maximum number of positions a user is permitted to have
///
/// Pool Factory supplied:
Expand All @@ -34,7 +34,7 @@ pub trait Pool {
admin: Address,
name: Symbol,
oracle: Address,
bstop_rate: u64,
bstop_rate: u32,
max_positions: u32,
backstop_id: Address,
blnd_id: Address,
Expand All @@ -53,12 +53,12 @@ pub trait Pool {
/// (Admin only) Update the pool
///
/// ### Arguments
/// * `backstop_take_rate` - The new take rate for the backstop
/// * `backstop_take_rate` - The new take rate for the backstop (7 decimals)
/// * `max_positions` - The new maximum number of allowed positions for a single user's account
///
/// ### Panics
/// If the caller is not the admin
fn update_pool(e: Env, backstop_take_rate: u64, max_positions: u32);
fn update_pool(e: Env, backstop_take_rate: u32, max_positions: u32);

/// (Admin only) Queues setting data for a reserve in the pool
///
Expand Down Expand Up @@ -233,7 +233,7 @@ impl Pool for PoolContract {
admin: Address,
name: Symbol,
oracle: Address,
bstop_rate: u64,
bstop_rate: u32,
max_postions: u32,
backstop_id: Address,
blnd_id: Address,
Expand Down Expand Up @@ -266,7 +266,7 @@ impl Pool for PoolContract {
.publish((Symbol::new(&e, "set_admin"), admin), new_admin);
}

fn update_pool(e: Env, backstop_take_rate: u64, max_positions: u32) {
fn update_pool(e: Env, backstop_take_rate: u32, max_positions: u32) {
storage::extend_instance(&e);
let admin = storage::get_admin(&e);
admin.require_auth();
Expand Down
Loading

0 comments on commit 7488e81

Please sign in to comment.