From 3d917ce1eeca9d6b8cae584c06a802d7d6bdab0b Mon Sep 17 00:00:00 2001 From: lubkoll <11710767+lubkoll@users.noreply.github.com> Date: Mon, 26 Aug 2024 10:49:51 +0200 Subject: [PATCH] Rename CoinList::find_coin to CoinList::coin and use &str as argument (#812) --- .../osmosis/contracts/cl-vault/src/helpers/coinlist.rs | 4 ++-- .../osmosis/contracts/cl-vault/src/helpers/getters.rs | 7 ++----- smart-contracts/osmosis/contracts/cl-vault/src/query.rs | 4 ++-- .../osmosis/contracts/cl-vault/src/vault/withdraw.rs | 7 ++----- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/smart-contracts/osmosis/contracts/cl-vault/src/helpers/coinlist.rs b/smart-contracts/osmosis/contracts/cl-vault/src/helpers/coinlist.rs index d452503f6..e7ba57450 100644 --- a/smart-contracts/osmosis/contracts/cl-vault/src/helpers/coinlist.rs +++ b/smart-contracts/osmosis/contracts/cl-vault/src/helpers/coinlist.rs @@ -135,13 +135,13 @@ impl CoinList { CoinList(coins) } - pub fn find_coin(&self, denom: String) -> Coin { + pub fn find(&self, denom: &str) -> Coin { self.0 .iter() .find(|c| c.denom == denom) .cloned() .unwrap_or(Coin { - denom, + denom: denom.to_string(), amount: 0u128.into(), }) } diff --git a/smart-contracts/osmosis/contracts/cl-vault/src/helpers/getters.rs b/smart-contracts/osmosis/contracts/cl-vault/src/helpers/getters.rs index 8706f08ca..7627970ac 100644 --- a/smart-contracts/osmosis/contracts/cl-vault/src/helpers/getters.rs +++ b/smart-contracts/osmosis/contracts/cl-vault/src/helpers/getters.rs @@ -212,13 +212,10 @@ pub fn get_unused_pair_balances( env: &Env, pool_config: &PoolConfig, ) -> Result, ContractError> { - // Get unused balances from the contract. This is the amount of tokens that are not currently in a position. - // This amount already includes the withdrawn amounts from previous steps as in this reply those funds already compose the contract balance. let unused_balances = get_unused_balances(&deps.querier, env)?; - // Use the unused balances to get the token0 and token1 amounts that we can use to create a new position - let base = unused_balances.find_coin(pool_config.token0.clone()); - let quote = unused_balances.find_coin(pool_config.token1.clone()); + let base = unused_balances.find(&pool_config.token0); + let quote = unused_balances.find(&pool_config.token1); Ok(vec![base, quote]) } diff --git a/smart-contracts/osmosis/contracts/cl-vault/src/query.rs b/smart-contracts/osmosis/contracts/cl-vault/src/query.rs index f4dfde817..9da35e720 100644 --- a/smart-contracts/osmosis/contracts/cl-vault/src/query.rs +++ b/smart-contracts/osmosis/contracts/cl-vault/src/query.rs @@ -190,7 +190,7 @@ pub fn query_total_assets(deps: Deps, env: Env) -> Result Result