Why are we multiplying with 1e10? #6372
-
In Lesson 4 - Sorry if this question seems dumb, but I would be thankful if someone could answer. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This is my understanding from going up to Lesson 4. Maybe I'll understand it differently after going through the hardhat section. |
Beta Was this translation helpful? Give feedback.
This is my understanding from going up to Lesson 4. Maybe I'll understand it differently after going through the hardhat section.
ChainLink will return something like 3000 * 1e8 (8 is from
AggregatorV3Interface(ADDRESS).decimals
). We multiply by 1e10 so we can pad up to 3000 * 1e18. And we'd like to pad up to 1e18 for a similar reason why we have 1 eth = 1e18 wei; Solidity can't support decimals so all our calculations must be in whole numbers. By padding up to 1e18, we can guarantee we will always work with whole numbers, even if we say we only want to fund 1 wei.