I'm simplifying this down but let's say I have a payable function called myFunction. After a transaction is made (via React) I want to update the number property of a struct within the contract called myStruct using basic math. Let's say I want to calculate it as 1 minus the new contract balance.
function myFunction() public payable {
myStruct.number = 1 - address(this).balance;
}
If I send a 0.01 ETH to this function on a new contract with a 0 balance, myStruct.number renders out as 15792089237316195423570985008687907853269984665640564039457574007913129639937
I can't for the life of me figure out why. If I do basic math without using address(this).balance or msg.value then it's fine and renders correctly. But every time I try to involve either of those, I get these wild results.
Help would be much appreciated!