solana-labs / solana-program-library

A collection of Solana programs maintained by Solana Labs
https://solanalabs.com
Apache License 2.0
3.63k stars 2.11k forks source link

Why the offset curve is not a valid curve type in token swap program ? #2312

Closed andropixels closed 3 years ago

andropixels commented 3 years ago

https://github.com/solana-labs/solana-program-library/blob/master/token-swap/program/src/constraints.rs#L77 in above line the VALID_CURVE TYPE does not include the offset curve type? why is that ? is there any possible way to implement a offset without changing the existing smart contract ?

joncinque commented 3 years ago

The idea of the VALID_CURVE_TYPE, and the contraints system in general, is to allow different teams to reuse the same token-swap program, but impose certain restrictions as needed. For example, as the person managing the program, you can enforce that you must own all of the accounts, so that other people don't benefit from your work.

Constraints are only ever included if you use the optional production feature, so you can always redeploy a version of the program built without it! The version currently deployed at SwaPpA9LAaLfeLi3a68M4DjnLqgtticKg6CnyNwgAC8 is the Serum version, so they wanted some contraints on curves and fee account ownership.