Add core math packages (using wasm)
Add two new packages to the monorepo
- rust-sdk/core
- ts-sdk/core which is the wasm version of rust-sdk/core
This approach is great because this allows us to have a single source of truth for math functions that are used throughout other libs (and potentially even the program). Writing it once means that the implementations will always be identical regardless of which platform you are on. Also means we only have to write tests for them once
The wasm lib currently only builds with std enabled because of something in tsify. This inflates the wasm bundle by quite a bit. I opened a ticket: https://github.com/madonoharu/tsify/issues/56. This only affects the ts-sdk/core and is a bundle size thing so not the end of the world. All code behaves identically as if it was built with/without std
This PR only contains basic test cases and does not test for any of the more tricky / edge cases for swap quoting. My brain is fried from looking at tick array traversal and bit math the past couple of days so I'd like to continue with other parts of the SDK and revisit this later.
note: Since this is not added to publish workflow yet this will not be deployed yet on tag
@yugure-orca I think this now contains all the core math and quoting logic for whirlpools 🥳. I am however not 100% confident yet that all the logic is implemented correctly 😬. Especially some of the round ups and downs when doing when doing muldiv and bitshifts
As stated this same logic is exported through wasm (still with std lib but we can fix that later) so rust sdk and ts sdk will share the exact same logic 🎊
(If in the future we ever want to make sure that the core logic is shared between the SDKs and the program that should theoretically be possible with the way I set up the core package)