-
Notifications
You must be signed in to change notification settings - Fork 206
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): maintenance margin ratio should be modifiable by governance #1065
Comments
SuggestionWe should make this a parameter of the virtual pool rather than the module. It's common for different asset pairs to have different maintenance margin requirements and maximum leverage on larger exchanges. Different position change magnitudes can also factor into this. Benchmark - Binance
References:
Benchmark - dYdX
Reference: Maximum Leverage for Perpetuals. dYdX Benchmark - Huobi
Reference: Contract Leverage Introduction @NibiruChain/backend |
It's already a parameter for the vpool (#729) x/vpool/keeper/pool_state.go // CreatePool creates a pool for a specific pair.
func (k Keeper) CreatePool(
ctx sdk.Context,
pair common.AssetPair,
tradeLimitRatio sdk.Dec, // integer with 6 decimals, 1_000_000 means 1.0
quoteAssetReserve sdk.Dec,
baseAssetReserve sdk.Dec,
fluctuationLimitRatio sdk.Dec,
maxOracleSpreadRatio sdk.Dec,
maintenanceMarginRatio sdk.Dec,
maxLeverage sdk.Dec,
) {
k.Pools.Insert(ctx, pair, types.VPool{
Pair: pair,
BaseAssetReserve: baseAssetReserve,
QuoteAssetReserve: quoteAssetReserve,
TradeLimitRatio: tradeLimitRatio,
FluctuationLimitRatio: fluctuationLimitRatio,
MaxOracleSpreadRatio: maxOracleSpreadRatio,
MaintenanceMarginRatio: maintenanceMarginRatio,
MaxLeverage: maxLeverage,
})
k.ReserveSnapshots.Insert(
ctx,
collections.Join(pair, ctx.BlockTime()),
types.NewReserveSnapshot(
pair,
baseAssetReserve,
quoteAssetReserve,
ctx.BlockTime(),
),
)
} |
Ideally all parameters of a vpool (along with the k value) should be adjustable by governance. I'm wondering if we want to have k slowly adjusting from A->B on a timeframe? Curve does it for their amplification parameter on their stable pools, osmosis does it for their weight change in LBP. |
The objective of this ticket would be to move the vpool fields into the module params so that they are subject to governance proposals. Right now I don't believe there is a way to modify the vpool fields after the chain goes live. |
… ratio modifiable by governance (#1074) * refactor!(vpool): Remove ReserveSnapshot from genesis since snapshots are done in CreatePool * change log * chore(dependencies): re-run go mod tidy * refactor(vpool): Use VPool.ToSnapshot * revert go mod tidy changes since it breaks things * test: Use minimum UTC time rather than 0 for the lowest possible snapshot time * linter * docs: fix comment * refactor(vpool): Use VpoolConfig type for less type repetition | DRY improvement * refactor: finish VpoolConfig update. All tests green again * feat(vpool): proposal handler for EditVpoolConfig #wip * changelog * run golangci-lint * feat(testutil): util function for getting a blank context * fix: account for nil sdk.Dec values in Validate * test: unit tests for ToSnapshot * test(gov_test.go): Lots of tests for gov proposal types and marshaling * feat,test: EditPoolConfig keeper fn and corresponding tests * feat(vpool/client): CLI command and and handler for the EditPoolConfigProposal * refactor(vpool): run golangci-lint * test(vpool/client): Integration test for EditPoolConfigProposal * fix(dependencies): Revert any automatic go.mod changes to fix the x/oracle integration tests
Task Summary
Vpool
, it can be removed from the genesis.The text was updated successfully, but these errors were encountered: