Skip to content

Commit

Permalink
fix wrong total value bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Art3miX committed Apr 7, 2024
1 parent 2296541 commit 2cc2044
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 3 additions & 1 deletion contracts/services/rebalancer/src/rebalance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ pub fn do_rebalance(
.unwrap_or(&Uint128::zero());

if verify_account_balance(total_value.to_uint_floor(), min_value).is_err() {
event = event.add_attribute("pausing", true.to_string());

// We pause the account if the account balance doesn't meet the minimum requirements
return Ok(RebalanceResponse::new(config, None, event, true));
};
Expand Down Expand Up @@ -395,7 +397,7 @@ fn get_inputs(
} else {
prices
.iter()
.find(|(pair, _)| pair.1 == target.denom)
.find(|(pair, _)| pair.0 == config.base_denom && pair.1 == target.denom)
// we can safely unwrap here as we are 100% sure we have all prices for the whitelisted targets
.unwrap()
.1
Expand Down
4 changes: 2 additions & 2 deletions packages/valence-package/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ pub fn verify_services_manager(deps: Deps, info: &MessageInfo) -> Result<Addr, V
Ok(manager_addr)
}

/// Get the timestomt of the start of the day (00:00 midnight)
/// Get the timestamp of the start of the cycle (if cycle is a day - 00:00 midnight)
pub fn start_of_cycle(time: Timestamp, cycle: u64) -> Timestamp {
let leftover = time.seconds() % cycle; // How much leftover from the start of the day (mid night UTC)
let leftover = time.seconds() % cycle; // How much leftover from the start of the cycle (if cycle is a day - mid night UTC)
time.minus_seconds(leftover)
}

Expand Down
12 changes: 11 additions & 1 deletion scripts/general_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,14 @@ neutrond tx wasm execute neutron1qs6mzpmcw3dvg5l8nyywetcj326scszdj7v4pfk55xwshd4
neutrond tx wasm execute neutron1qs6mzpmcw3dvg5l8nyywetcj326scszdj7v4pfk55xwshd4prqnqfwc0z2 '{"admin":{"update_base_denom_whitelist": {"to_add": [{"denom": "ibc/B559A80D62249C8AA07A380E2A2BEA6E5CA9A6F079C912C3A9E9B494105E4F81", "min_balance_limit": "10000000"}], "to_remove":[]}}}' --from ntrn-main-tester --gas-prices 0.075untrn --gas auto --gas-adjustment 1.4 --output json -y

// update auction code id in auctions manager
neutrond tx wasm execute neutron13exc5wdc7y5qpqazc34djnu934lqvfw2dru30j52ahhjep6jzx8ssjxcyz '{"admin": {"update_auction_id":"869"}}' --from ntrn-main-tester --gas-prices 0.075untrn --gas auto --gas-adjustment 1.4 --output json -y
neutrond tx wasm execute neutron13exc5wdc7y5qpqazc34djnu934lqvfw2dru30j52ahhjep6jzx8ssjxcyz '{"admin": {"update_auction_id":"869"}}' --from ntrn-main-tester --gas-prices 0.075untrn --gas auto --gas-adjustment 1.4 --output json -y

// Send funds to the auction manually (outside of the rebalancer)
neutrond tx wasm execute neutron13jppm4n77u8ud5wma9xe0dqnaz85ne9jem3r0scc009uemvh49qqxuuggf '{"auction_funds": {}}' --amount 1500000untrn --from ntrn-main-tester --gas-prices 0.075untrn --gas auto --gas-adjustment 1.4 --output json -y

// Open auction manually (start_block doesn't needed because it takes current block by default)
neutrond tx wasm execute neutron13exc5wdc7y5qpqazc34djnu934lqvfw2dru30j52ahhjep6jzx8ssjxcyz '{"admin": {"open_auction": {"pair": ["untrn", "ibc/B559A80D62249C8AA07A380E2A2BEA6E5CA9A6F079C912C3A9E9B494105E4F81"], "params": {"end_block": 8796000}}}}' --from ntrn-main-tester --gas-prices 0.075untrn --gas auto --gas-adjustment 1.4 --output json -y

// Update price in the oracle for a pair
neutrond tx wasm execute neutron1s8uqyh0mmh8g66s2dectf56c08y6fvusp39undp8kf4v678ededsy6tstf '{"update_price": {"pair": ["ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9", "factory/neutron1p8d89wvxyjcnawmgw72klknr3lg9gwwl6ypxda/newt"]}}' --from ntrn-main-tester --gas-prices 0.075untrn --gas auto --gas-adjustment 1.4 --output json -y

0 comments on commit 2cc2044

Please sign in to comment.