The margin engine is responsible for managing user positions and collateral. Allows users to take positions in all registered vAMMs.
The instantiation message takes the addresses of the insurance and fee contracts. It also takes the eligible collateral to be used and the margin ratios and liquidation fees.
{
"insurance_fund": "juno...",
"fee_pool": "juno...",
"eligible_collateral": "juno...",
"initial_margin_ratio": "10000",
"maintenance_margin_ratio": "10000",
"liquidation_fee": "10000",
}
Enables owner to update key contract parameters.
{
"update_config" {
"owner": "juno...",
"insurance_fund": "juno...",
"fee_pool": "juno...",
"eligible_collateral": "juno...",
"initial_margin_ratio": "10000",
"maintenance_margin_ratio": "10000",
"partial_liquidation_ratio": "10000",
"liquidation_fee": "1000",
}
}
Enables a user to open a position for a specific vAMM with leverage. Also allows order to be placed with slippage limits.
{
"open_position" {
"vamm": "juno...",
"side": "buy",
"quote_asset_amount": "10",
"leverage": "1",
"base_asset_limit": "0",
}
}
Enables a user to close a position they have for a specific vAMM including slippage limits.
{
"close_position" {
"vamm": "juno...",
"quote_asset_limit": "0",
}
}
Allows third parties to liquidate users positions when they are no longer sufficiently collateralised.
{
"liquidate" {
"vamm": "juno...",
"trader": "juno...",
"quote_asset_limit": "0",
}
}
Allows third parties to trigger funding payments to be processed for a specific vAMM.
{
"pay_funding" {
"vamm": "juno...",
}
}
Users can deposit additional margin to their positions to prevent them from becoming under-collateralised.
{
"deposit_margin" {
"vamm": "juno...",
"amount": "250000",
}
}
Users can withdraw excess collateral from their positions if they are over-collateralised
{
"withdraw_margin" {
"vamm": "juno...",
"amount": "250000",
}
}
}
Enables owner to pause contracts in emergency situations
{
"set_pause" {
"pause": true,
}
}
Returns the contracts configuration.
{
"config" {}
}
Returns the state variables of the contract.
{
"state" {}
}
Returns a user's position for a specific vAMM.
{
"position" {
"vamm": "juno...",
"trader": "juno...",
}
}
Returns a user's positions for all vAMMs.
{
"all_positions" {
"trader": "juno...",
}
}
Returns the unrealized PnL (profit and loss) of a user for a specific vAMM using a specific calculation method.
{
"unrealized_pnl" {
"vamm": "juno...",
"trader": "juno...",
"calc_option": "spot",
}
}
Returns the cumulative premium fraction of a vAMM.
{
"cumulative_premium_fraction" {
"vamm": "juno...",
}
}
Returns the margin ratio of a user for a vAMM.
{
"margin_ratio" {
"vamm": "juno...",
"trader": "juno...",
}
}
Returns the excess collateral a user has for a vAMM.
{
"free_collateral" {
"vamm": "juno...",
"trader": "juno...",
}
}
Returns a user's margin balance across all vAMMs inclusive funding payments.
{
"balance_with_funding_payment" {
"trader": "juno...",
}
}
Returns a user's margin balance inclusive funding payments for a specific vAMM.
{
"position_with_funding_payment" {
"vamm": "juno...",
"trader": "juno...",
}
}