ArdanaLabs / audit

0 stars 0 forks source link

["pile"] scalar types: the arguments #15

Open quinn-dougherty opened 2 years ago

quinn-dougherty commented 2 years ago

Description

@morganthomas I want an audit section on the choice of Rational over Double. Please type some notes about your thinking here, let me worry about audit language.

Deliverable

A section of the audit that advances our belief that Rationals are better for defi, or whatever our belief is.

Notes

optional field

morganthomas commented 2 years ago

For the smart contract, we require calculations which are highly precise and can handle very large numbers and can be reproduced exactly across different hardware. Using FLOPs (floating point operations) is not compatible with these requirements. We are not able to determine exactly how big or how precise our numbers need to be, so we cannot say that FLOPs allow for enough size and precision. We can say, however, that FLOPs are implemented slightly differently on different hardware and results may not be reproducible across different hardware. Additionally, FLOPs are not allowed to be used in Plutus on-chain code. These are the constraints which do not allow us to use Double to represent numbers in the smart contract. @quinn-dougherty

quinn-dougherty commented 2 years ago

As of this writing Morgan's language is plagiarized into the audit's short section.

quinn-dougherty commented 2 years ago

@Benjmhart I wasn't able to get any insight into ardana-dollar's choices regarding this. Could you please write me some of your reasoning about selecting a scalar type, if there are different scalar types offchain than PlutusTx's scalar types, etc? in https://github.com/ArdanaLabs/audit/issues/14 you allude to a float of some kind.

Benjmhart commented 2 years ago

not a float in the data representation sense. A float is a slang for business funds in a petty cash situation being used to facilitate a transaction, the money in a register is called a float.

we use Rationals (and rationals with some enforcement of non-zero denominators/natural numbers) as our primary means of representing fractional values of any kind.

quinn-dougherty commented 2 years ago

thanks @Benjmhart to be clear, is that import PlutusTx.Ratio or vanilla haskell import Data.Ratio?

Benjmhart commented 2 years ago

PlutusTx.Ratio for now, in the future i think it will be Plutus.Extra.Numeric.NatRatio or something similar (these features are not yet merged in plutus-extra i don't think)