-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cryptoswap Third Gen #10
Comments
My rationale for not reintroducing rebase support is:
Very excited about the boost, a couple of questions:
|
Curve has been a long standing supporter of rebasing markets and it's a pedigree of ours to have rebasing token support in our AMMs. But: I don't disagree. I think rebasing tokens are a small market, and we could revisit them in the future if security around the composability of rebasing tokens improves.
Naming rights go to whoever writes the algorithm. We can discuss re-iterate internally.
I think we should parameterise them: so a parameter that decides how much of earned revenue from swaps goes into the 'rebalancing funds' which is then used to rebalance? |
Background
TricryptoNGWETH is the first optimised implementation of the old 3-coin cryptoswap AMM, allowing native token transfers. Its immediate upgrade (almost a year after its launch) removes some of the features and adds new ones.
The different implementations of Curve's CryptoSwap invariant AMM are noted in the following:
a. tricrypto2 (genesis)
b. twocrypto (genesis)
There are significant improvements from the genesis cryptoswap invariant AMM contract to the 1st gen (NG, or next-gen). Gas costs are reduced by half between the genesis and the first gen implementations. This was a labour of love, requiring development work in the compiler, dev tools (titanoboa was built to build tricryptong), coordination with etherscan, coordination with math researchers to optimise math in tricrypto, come up with better cube roots, auditors coming up with their optimisations etc. The optimisations are listed in the following:
The implementation of state prices allowed the creation of very good oracles that power today's curve stablecoin. State prices, as opposed to last traded prices (the widely prevalent industry standard), significantly reduce the impact of price manipulation.
Cryptoswap (like everything Curve has) is an ongoing process of improvement. The features added in the second iteration of NG are simply features that come out of a natural progression of improving contracts after user feedback, experiences with speaking to auditors, etc. No known vulnerabilities in the first NG implementation prompted the second iteration of cryptoswap NG contracts.
Some of the features removed from the first gen (in the second-gen) are (not an exhaustive list):
self.balances
can be updated with a read ofcoin.balanceOf(self)
).The second-gen adds several new features including:
a. claim sparingly
b. do not claim if virtual price goes below 1e18
self.balances[i] = coins[i].balanceOf(self)
in theself._claim_admin_fees()
method like the old contract doesWith that in mind, there are new features and more improvements that Cryptoswap contracts could accommodate.
Improvements Suggested
1. Rebasing token support
The second-gen cryptoswap NG contracts do not gulp rebases: if the amm contract holds rebasing tokens, the rebases are not absorbed by the pool contract and are simply available as:
rebase_balance[i] = coins[i].balanceOf(self) - self.balances[i]
. These could be recovered by the LPs somehow and added to their LP token share. This is something to consider: can we add support for pairs likestETH <> USDM
where both tokens in the pool are rebasing and are very tightly pegged to their underlying collateral's value (at least historically as of writing this feature)?2. Boost
Cryptoswap invariant AMMs take half the earned profits to rebalance liquidity closer to the exponential moving average prices. This means, if the pool had some form of capability to accept donations to inflate its profits, it could absorb these donated profits to rebalance and deepen liquidity significantly. This is even more effective in pools where the tokens do not have significant volatility but are not volatile pairs (e.g., USD <> EUR forex markets, which are generally very deep).
The ability to donate was discontinued in the second generation since the removal of the
gulp
.The idea would be to
a. Donate to the pool contract safely and not manipulate prices in any direction
b. call tweak_price
c. Donated profits should not go into user positions, and only be used for amm rebalancing.
This is quite tricky to achieve but increases flexibility and utility of these AMM contracts.
Additional considerations
Security considerations
Task List
Nice to have
The text was updated successfully, but these errors were encountered: