-
Notifications
You must be signed in to change notification settings - Fork 200
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
feat(vpool): Add governance proposal to edit the swap invariant of one or more vpools #1082
feat(vpool): Add governance proposal to edit the swap invariant of one or more vpools #1082
Conversation
As I said to @Unique-Divine, i think making our changes in k public through votation opens a possibility of making money for the traders (at the expense of the protocol): take for example: Pool state t0:
Alice open a long position for ~2k -> mark price to 20k. If i close it now, slippage means i get nothing. New proposal, Change in k for the pool, new k is 100x bigger: Pool state t1:
close a position -> no slippage, i get 2k for free. If i time this just before the proposal passes, i can actually open long positions for every block before the change with multiple wallets and heavily modify the price between mark and index to collect free money with the slippage |
This is only for testnet, not live markets. Since there's no repegging or anything to go with this feature right now, it should just be thought of as a temporary utility function for changing We may be able to use the keeper function and type later when the dynamic updates have a finished spec. |
20*time.Second, | ||
2*time.Second, | ||
"proposal should pass after voting period") | ||
s.PassGovProposal() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
Purpose
Change 1 - EditSwapInvariantsProposal
This PR implements a proposal type that maps one or more trading pairs to corresponding multiplers on the swap invariant. The multiplier then changes the virtual reserves in-place without altering the mark price.
The "multiplier" is$c^2$ . Notice this implies that a multipying both the base and quote reserves by $c$ results in the new value for $k$ without changing price.
This logic is implemented in
vpool/keeper/pool_state.go
in theEditSwapInvariant
function. The function and its governance proposal have related unit tests, types tests, marshalling tests, and a CLI test.A nice perk of this is we won't need to keep updating the script to get a more accurate mark price.
Change 2 - Lower default reserves in localnet.sh
Case A - Online
If the CoinGecko query works via cURL, localnet.sh will instead grab the ETH and BTC price from this free endpoint and use that to initialize the reserves.
The initial value is chosen from an estimate of how large
y
should be given some number of traders and size of NUSD the faucet gives.The thinking here is to make the pool just big enough that everyone in our Discord (for example) could use the faucet and try to change the reserves of the pool but make it no bigger than that. At least this way, users will be able to see the price change a bit when they open positions.
Case B - Offline
The default reserves are set with
y=1e10
(unusd) as the starting point if the script is run offline.