Closed ilmoi closed 3 years ago
You've got this exactly right, the work was just never done to add this to the JS bindings. Please feel free to add a PR to integrate the curve params! You can tag me in the PR to review whenever youget it done and use this issue to track the work if you like
With current js bindings it's not possible to instantiate a Token Swap with curves that require parameters during initilization.
An example is the fixed price curve, which requires a single parameter:
The layout is correctly planned out to include 32 bytes for curve parameters, but the actual
commandDataLayout.encode()
call stops just 1 argument short and doesn't includecurveParamters
. As a result the program always reads them as 0s, which leads to the following error:Which makes sense since the exchange rate is basically set to 0.
The solution would be to simply add a buffered uint 8 array along the lines of:
And to then also add a new argument for the constructor / init method that asks the user what, if any, curve params they want to pass. I've done a rough test locally and it works.
I'm happy to work on this and submit a PR. I'm just new to solana community / open source and wasn't sure whether it's ok to directly do that or whether I need open an issue first. If someone from the team could comment that'd be great.