xGov-31 Add arbitrary decimal precision exp, log, pow to the AVM

Author 1m1 (1m1-github)

Category AVM

Focus Defi, Science, Math

Open-Source Yes

ALGO Requested 200000

Abstract

This would expand the AVM capabilities (uniquely?) to enable much more complex kinds of dApps, needed for Financial, Scientific or Mathematical use cases.

This would allow Algorand to have balancer.fi style smart contracts, e.g. to represent a “FairTreasury”, which is missed by every project.

Even basic financial contracts need roots, e.g. to convert yearly to daily volatility.

Such functionality can be easily tested with 100% correctness.

Normally, opcodes are kept basic in assembly language due to hardware limitations. The AVM however is a virtual machine and hence not bound by such limitations.
Hence there is nothing stopping us from adding such super powers to the AVM. It would invite a lot more innovation.

The details and an MVP have been written up in the following PR, which has been shown to be popular in the community:

Btw, Consensys has shown interest to me privately to similarly arithmetize the EVM.

The AVM already allows for some decimal math; this change would complete it to add full decimal precision including negative numbers.
The current (e.g. b+) decimal math is based on (positive only) binary representations, which cannot even represent 0.1 exactly. The proposed is a decimal float type (not floating point), which represents any decimal value exactly, thus allowing for arbitrary precision math.

Link for details

1 Like

while having access to more complex mathematical functions as a dev i wonder why you need 200k ALGO for that? maybe i am over simplifying this since i know nothing about opcodes but from my perspective (a mathematician) it seems like if devs need square roots or stuff they can use standard numerical methods to implement them themselves.

especially since you are saying this and saying that balancer is a thing on ethereum already. so they were able to build it even tho they have the same problems algorand devs might have now too

How does this technical feature help Regular Users of the Apps or Devs?

What is the purpose of this feature?

why you need 200k ALGO for that?
it is for the time required to code everything and check everything

implement them themselves
the EVM supports int, i.e. negative values and also code import.
the AVM supports neither. to have such opcodes costs nothing but gives the user strong abilities (to do arbitrary precision high level math), which would be very long code written in TEAL e.g.

it allows users to run calculations like a^b (a to the power of b). this kind of feature is useful in all kinds of applications, financial, mathematical, scientific. its a very basic mathematical operation.

the 200k goes only to you? Assume price of algo is 0.1 that’s 20,000 USD. How many hours a day are you planning to put into this realistically?

3 month time frame, that’s approx 7000 dollars a month.

What is the price of checking/audit at the end? Who will be checking your code?

Is it possible to break down the entire codebase and outsource certain parts of the codebase to freelance devs across the globe? And then you can put it all together, double check, proof read, edit etc.

It will be cheaper this way and might be faster too.

And then once you have done the proof reading and then get it audited by a third party.

i would write the code myself, as i have multi decade experience in writing precise, efficient mathematical code.

the work will include statistical proofs of the correctness of the algorithm: given any probability p (e.g. 0.000001%), the test will show that the algorithm is correct with an error of at most p.
note that lots of cryptographic proofs are statistical in nature.

yes, the funds are for my time. actually, it is a significant discount on the value of my time and a very small cost compared to the value Algorand would gain.

1 Like