1

After doing a simple calculation in rust ink! 4.0 smart contract, the result is incorrect and doesn't match the expected result.

Here is the simple formula:

let a0_balance_mul:U256 = U256::from(amount_in_with_lp_fees * self.get_a0_balance());

The variables for the above formula are:

  1. amount_in_with_lp_fees = 100,000,000,000,000,000,000
  2. self.get_a0_balance() = 10,000,000,000,000,000,000

The result that Im getting is : 319,435,266,158,123,073,073,250,785,136,463,577,088 Which should be : 1000000000000000000000000000000000000000

I've checked both numbers and they are both represented correctly using U256 int.

Thanks in advance.

1 Answer 1

2

I should've converted both amount_in_with_lp_fees and self.get_a0_balance() into U256 int, they were u128.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.