From a57514ce8c757dbec2593ec4043dc8cfad2fd0c5 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 10 Jan 2023 12:44:58 +0100 Subject: [PATCH] Scale receiver balance. --- src/types/safe.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/types/safe.rs b/src/types/safe.rs index a747973..bc3b720 100644 --- a/src/types/safe.rs +++ b/src/types/safe.rs @@ -29,8 +29,9 @@ impl Safe { let amount = (receiver.balance(&receiver.token_address) * U256::from(trust_percentage as u128)) / U256::from(100); - let scaled_receiver_balance = receiver_balance; // * U256::from((100 - trust_percentage) as u128) / U256::from(100); - if amount < scaled_receiver_balance { + let scaled_receiver_balance = + receiver_balance * U256::from((100 - trust_percentage) as u128) / U256::from(100); + if amount < receiver_balance { U256::from(0) } else { // TODO it should not be "min" - the second constraint