diff --git a/Cargo.lock b/Cargo.lock index e186b01..9fbbf15 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2322,7 +2322,7 @@ dependencies = [ [[package]] name = "ref-exchange" -version = "1.7.1" +version = "1.7.2" dependencies = [ "mock-boost-farming", "near-contract-standards", diff --git a/ref-exchange/Cargo.toml b/ref-exchange/Cargo.toml index 28ec677..9a3cc0f 100644 --- a/ref-exchange/Cargo.toml +++ b/ref-exchange/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ref-exchange" -version = "1.7.1" +version = "1.7.2" authors = ["Illia Polosukhin "] edition = "2018" publish = false diff --git a/ref-exchange/release_notes.md b/ref-exchange/release_notes.md index 4ab9b0f..b2248a5 100644 --- a/ref-exchange/release_notes.md +++ b/ref-exchange/release_notes.md @@ -1,5 +1,11 @@ # Release Notes +### Version 1.7.2 +``` +9KuaBbp9FT1g17YCaCsaezGxWDuZkKrjPsXu1RCN8Ux7 +``` +1. add modify_total_fee; + ### Version 1.7.1 ``` 6ZU3rmDwEs988pvYWyDxg6DJm7fP1F3FnAwHGo698ATw diff --git a/ref-exchange/src/owner.rs b/ref-exchange/src/owner.rs index 408fd89..87aaa98 100644 --- a/ref-exchange/src/owner.rs +++ b/ref-exchange/src/owner.rs @@ -6,7 +6,6 @@ use near_contract_standards::fungible_token::core_impl::ext_fungible_token; use crate::*; use crate::rated_swap::rate::{global_register_rate, global_unregister_rate}; use crate::utils::{FEE_DIVISOR, MAX_ADMIN_FEE_BPS, GAS_FOR_BASIC_OP}; -use crate::legacy::ContractV1; #[near_bindgen] impl Contract { @@ -199,6 +198,19 @@ impl Contract { self.admin_fee_bps = admin_fee_bps; } + #[payable] + pub fn modify_total_fee(&mut self, pool_id: u64, total_fee: u32) { + assert_one_yocto(); + assert!(self.is_owner_or_guardians(), "{}", ERR100_NOT_ALLOWED); + assert!(total_fee < FEE_DIVISOR, "{}", ERR62_FEE_ILLEGAL); + let mut pool = self.pools.get(pool_id).expect(ERR85_NO_POOL); + env::log( + format!("Modify total_fee pool_id {} from {} to {}", pool_id, pool.get_fee(), total_fee).as_bytes() + ); + pool.modify_total_fee(total_fee); + self.pools.replace(pool_id, &pool); + } + /// Remove exchange fee liquidity to owner's inner account. /// Owner's inner account storage should be prepared in advance. #[payable] diff --git a/ref-exchange/src/pool.rs b/ref-exchange/src/pool.rs index d811124..4c7cc78 100644 --- a/ref-exchange/src/pool.rs +++ b/ref-exchange/src/pool.rs @@ -35,6 +35,14 @@ impl Pool { } } + pub fn modify_total_fee(&mut self, total_fee: u32) { + match self { + Pool::SimplePool(pool) => pool.modify_total_fee(total_fee), + Pool::StableSwapPool(pool) => pool.modify_total_fee(total_fee), + Pool::RatedSwapPool(pool) => pool.modify_total_fee(total_fee), + } + } + /// Adds liquidity into underlying pool. /// Updates amounts to amount kept in the pool. pub fn add_liquidity( diff --git a/ref-exchange/src/rated_swap/mod.rs b/ref-exchange/src/rated_swap/mod.rs index e40f4d1..5f5655e 100644 --- a/ref-exchange/src/rated_swap/mod.rs +++ b/ref-exchange/src/rated_swap/mod.rs @@ -86,6 +86,10 @@ impl RatedSwapPool { } } + pub fn modify_total_fee(&mut self, total_fee: u32) { + self.total_fee = total_fee; + } + pub fn get_rates(&self) -> Vec { self.token_account_ids .iter() diff --git a/ref-exchange/src/simple_pool.rs b/ref-exchange/src/simple_pool.rs index a0d2cdf..4c48bf2 100644 --- a/ref-exchange/src/simple_pool.rs +++ b/ref-exchange/src/simple_pool.rs @@ -64,6 +64,10 @@ impl SimplePool { } } + pub fn modify_total_fee(&mut self, total_fee: u32) { + self.total_fee = total_fee; + } + /// See if the given account has been registered as a LP pub fn share_has_registered(&self, account_id: &AccountId) -> bool { self.shares.contains_key(account_id) diff --git a/ref-exchange/src/stable_swap/mod.rs b/ref-exchange/src/stable_swap/mod.rs index a20e39a..593a7cf 100644 --- a/ref-exchange/src/stable_swap/mod.rs +++ b/ref-exchange/src/stable_swap/mod.rs @@ -77,6 +77,10 @@ impl StableSwapPool { } } + pub fn modify_total_fee(&mut self, total_fee: u32) { + self.total_fee = total_fee; + } + pub fn get_amounts(&self) ->Vec { let mut amounts = self.c_amounts.clone(); for (index, value) in self.token_decimals.iter().enumerate() { diff --git a/ref-exchange/tests/test_migrate.rs b/ref-exchange/tests/test_migrate.rs index cd3286a..a54b859 100644 --- a/ref-exchange/tests/test_migrate.rs +++ b/ref-exchange/tests/test_migrate.rs @@ -9,7 +9,7 @@ use crate::common::utils::*; pub mod common; near_sdk_sim::lazy_static_include::lazy_static_include_bytes! { - PREV_EXCHANGE_WASM_BYTES => "../releases/ref_exchange_release_v170.wasm", + PREV_EXCHANGE_WASM_BYTES => "../releases/ref_exchange_release_v171.wasm", EXCHANGE_WASM_BYTES => "../res/ref_exchange.wasm", } @@ -47,7 +47,7 @@ fn test_upgrade() { .assert_success(); let metadata = get_metadata(&pool); // println!("{:#?}", metadata); - assert_eq!(metadata.version, "1.7.1".to_string()); + assert_eq!(metadata.version, "1.7.2".to_string()); assert_eq!(metadata.admin_fee_bps, 5); assert_eq!(metadata.state, RunningState::Running); diff --git a/releases/ref_exchange_release.wasm b/releases/ref_exchange_release.wasm index f5f46d3..2924fae 100755 Binary files a/releases/ref_exchange_release.wasm and b/releases/ref_exchange_release.wasm differ diff --git a/releases/ref_exchange_release_v170.wasm b/releases/ref_exchange_release_v170.wasm deleted file mode 100755 index b481148..0000000 Binary files a/releases/ref_exchange_release_v170.wasm and /dev/null differ diff --git a/releases/ref_exchange_release_v171.wasm b/releases/ref_exchange_release_v171.wasm new file mode 100755 index 0000000..f5f46d3 Binary files /dev/null and b/releases/ref_exchange_release_v171.wasm differ