Skip to content

Commit

Permalink
refactor(controller): add max funding rate to CreateMarket (#65)
Browse files Browse the repository at this point in the history
* refactor(controller): add max funding rate to CreateMarket

* build: updated artifacts
  • Loading branch information
Unique-Divine authored Aug 13, 2023
1 parent fd8672e commit 5fa2fdb
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 20 deletions.
Binary file modified artifacts/bindings_perp.wasm
Binary file not shown.
14 changes: 7 additions & 7 deletions artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
b73b0a03fe8a4bbb547b1219c8d16db72978567261e17a8891995357b4c8de51 bindings_perp.wasm
3e00736bbe16cee88413f2a2bd64b61cafdfb2756ff77c4389b6a284609dd88e controller.wasm
1f56dbfc522b21f69bca15146c404533828646e2108b9616615a6b859de2edb8 incentives.wasm
e9834b1d66fbd389e1c1f77f6c5ae7e9151ce6adc2d56e5aa818d2171a637c83 lockup.wasm
87c8b35253b4593bd70769685a2f5a36ed25f6c73f17fbeea9be4736227a78fd pricefeed.wasm
66bcc1b1690a04ee611a634b55ddbbd3d204f0490d6656a03c92bfa4e88fb07c shifter.wasm
7482e5cfdf5e1d422f278e5f5af855f44c16634606480c0742434cbfb8e094e7 token_vesting.wasm
13b02a828f6e62b8a93cfd18e208a180394c91036a83ac36f2e891a8267471f4 bindings_perp.wasm
997f5a7e4d4074a5fe19bffaaae43e5206fe6f453081da1b554ca4938ee1202e controller.wasm
93bdd8cdc89ebbc8e29bc6a334483c45b507a6accfd2a4a0dc06a0bfcbc3ff05 incentives.wasm
c549f596f4faba0ef06eafb8fa56984ad0d6bd861e67e9a02ca612ada64904a5 lockup.wasm
c65ba2019c202f0e637201f6aa06ae9716145c9d0d2d7de0077ebfff59b2f130 pricefeed.wasm
a9328c1a53f52e279ea38f93d62102d92ace8234b7061e606df279a9cc9bc20c shifter.wasm
d76da8d1886f4f88655db753a4d91d29bf7cf0eed337e803ad28430e58b4642b token_vesting.wasm
14 changes: 7 additions & 7 deletions artifacts/checksums_intermediate.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
474dcc6557c56f85c5b6581e27fdd60468ac53573012d841ca7b65591a1d78ef target/wasm32-unknown-unknown/release/incentives.wasm
c3ebe629a7fb6cd41e88c6a77fb2076001c992d823240415f9cda2744023dda6 target/wasm32-unknown-unknown/release/lockup.wasm
f09ca83af90096f8773f48bbde73dcf8f509dc1da84a9243d1c7dba125c5c9f9 target/wasm32-unknown-unknown/release/pricefeed.wasm
e74d712db4d582678edf6d04d700d85c2444087ca9a03b0a90c49a78304ad039 target/wasm32-unknown-unknown/release/bindings_perp.wasm
06715ebbf2f1b1c8293d09144846bcc83a4590115c2acdf417645928af65639f target/wasm32-unknown-unknown/release/shifter.wasm
0fe6a359778d09b089221405aa194b8624803c34d39d4acc1b44d53aa755f7f6 target/wasm32-unknown-unknown/release/token_vesting.wasm
65224673b5fbea7b7eacd0fd7b4787151bae7fc2b51936315096e5c68a08a1d2 target/wasm32-unknown-unknown/release/controller.wasm
e160b4f3e3c7d065713ef3f03c241b3a0128ad5a7ee34ec7e49ee6b5dc4ea3d8 target/wasm32-unknown-unknown/release/bindings_perp.wasm
c8734717ed15d31870e1ef7b84c86ec1f3dbda4a559deb86a65c41e1654d59ed target/wasm32-unknown-unknown/release/controller.wasm
c90a93d49a68fc067f9e29e12fdbf49dcce92e96915c88b8f4d7c2a258ac85bb target/wasm32-unknown-unknown/release/incentives.wasm
48fab3b1295b9e274e7b31f5efe8c7fd91a16983ffcb1f403afdb6fd32958871 target/wasm32-unknown-unknown/release/lockup.wasm
d3e5b3b5c1e836d83d1106b839dc30ed6278f0f0a27c9181c94b8ae8b6554e5d target/wasm32-unknown-unknown/release/pricefeed.wasm
3b67e260906a1b510080c12028c1f2aee3ea87e30802e760307252f193c43c0b target/wasm32-unknown-unknown/release/shifter.wasm
a7c2a01a66685220cd51c2e9594b68d3ca06995edb2605284206637837ed30ee target/wasm32-unknown-unknown/release/token_vesting.wasm
Binary file modified artifacts/controller.wasm
Binary file not shown.
Binary file modified artifacts/incentives.wasm
Binary file not shown.
Binary file modified artifacts/lockup.wasm
Binary file not shown.
Binary file modified artifacts/pricefeed.wasm
Binary file not shown.
Binary file modified artifacts/shifter.wasm
Binary file not shown.
Binary file modified artifacts/token_vesting.wasm
Binary file not shown.
4 changes: 4 additions & 0 deletions contracts/controller/src/msgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ pub struct MarketParams {
pub maintenance_margin_ratio: Decimal,
/// the maximum leverage a user is able to be taken on this market
pub max_leverage: Decimal,
/// Maximum daily funding rate, where funding_payed = size * index_price *
/// (max_funding_rate / num_payments) In our case, payments occur every 30
/// minutes, so num_payments is 48.
pub max_funding_rate: Decimal,
// Latest cumulative premium fraction for a given pair.
// Calculated once per funding rate interval.
// A premium fraction is the difference between mark and index, divided by the
Expand Down
16 changes: 15 additions & 1 deletion packages/dummy/execute_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,21 @@
"pair": "ETH:USD",
"peg_mult": "420",
"sqrt_depth": "420",
"market_params": null
"market_params": {
"pair": "ETH:USD",
"enabled": true,
"price_fluctuation_limit_ratio": "420",
"maintenance_margin_ratio": "420",
"max_leverage": "420",
"max_funding_rate": "420",
"latest_cpf": "420",
"exchange_fee_ratio": "420",
"ecosystem_fund_fee_ratio": "420",
"liquidation_fee_ratio": "420",
"partial_liquidation_ratio": "420",
"funding_rate_epoch_id": "30 min",
"twap_lookback_window": "15"
}
}
}
}
8 changes: 4 additions & 4 deletions packages/dummy/query_resp.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@
"funding_rate_interval": "1h",
"twap_lookback_window": "3600",
"whitelisted_liquidators": [
"nibi1ah8gqrtjllhc5ld4rxgl4uglvwl93ag0sh6e6v",
"nibi1zaavvzxez0elundtn32qnk9lkm8kmcsz44g7xl"
"nibi1zaavvzxez0elundtn32qnk9lkm8kmcsz44g7xl",
"nibi1ah8gqrtjllhc5ld4rxgl4uglvwl93ag0sh6e6v"
]
}
},
Expand Down Expand Up @@ -114,7 +114,7 @@
}
},
"oracle_prices": {
"ETH:USD": "420",
"NIBI:USD": "69"
"NIBI:USD": "69",
"ETH:USD": "420"
}
}
16 changes: 15 additions & 1 deletion packages/dummy/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,21 @@ pub mod test {
pair: DUMMY_PAIR.to_string(),
peg_mult: dec_420(),
sqrt_depth: dec_420(),
market_params: None,
market_params: Some(controller::msgs::MarketParams {
pair: DUMMY_PAIR.to_string(),
enabled: true,
price_fluctuation_limit_ratio: dec_420(),
maintenance_margin_ratio: dec_420(),
max_leverage: dec_420(),
max_funding_rate: dec_420(),
latest_cpf: dec_420(),
exchange_fee_ratio: dec_420(),
ecosystem_fund_fee_ratio: dec_420(),
liquidation_fee_ratio: dec_420(),
partial_liquidation_ratio: dec_420(),
funding_rate_epoch_id: "30 min".to_string(),
twap_lookback_window: Uint256::from(15u128),
}),
}
}

Expand Down

0 comments on commit 5fa2fdb

Please sign in to comment.