TransformCurve is a contract that implements the ability to define any curve on chain with the usage of circular transforms. Inputs are specified as circles with a radius, frequency and phase. The transform function takes in a circle and returns a new circle.
The transform function is applied to the input circle and the result is used as the input for the next transform. The output of the last transform is the output of the curve.
This implementation relies heavily on Solidity Trigonemtry that enables the use of trigonometric functions in Solidity.
Traditionally, the implementation of an on-chain curve has been limited to the algebraic functions hard-coded into a contract. While not all curves make sense to be used in all cases, they can exist with this model -- Goodbye opinion and hello design space!
In action, this means that one can enjoy a world like:
Due to the surrounding complexity of this idea, you can find a more detailed explanation of the implementation in the Transform Curve (coming soon) document.
Functionally, this is as simple as discrete math implementation of a contiuous function.
The margin of error is extremely small and can be improved with the use of
A low number of
This enables the ability to construct curves using (a far more detailed process than illustrated below) such as:
If you would like a more detailed explanation of the implementation, join cosanostra on Discord.
There are a few things going on here.
- My first rough work of this implementation in Python which can be found in /model.
- The solidity implementation of it in /contracts accompanied with tests.
- Need to install hardhat and run
npx hardhat test
- Need to install hardhat and run
- A supporting front-end to visualize created curves in /frontend.
- Need to run npm install and then
npm run dev
- Need to run npm install and then