From e018c0a536b9b9e7692aff56a98cac02dadf7628 Mon Sep 17 00:00:00 2001 From: Cosmic Vagabond <121588426+cosmic-vagabond@users.noreply.github.com> Date: Thu, 3 Oct 2024 04:45:13 +0200 Subject: [PATCH] Feat/perp close estimation (#828) * feat: close estimation query init files * feat: add additional logic + tests * test(perpetual): fix tests --- docs/static/openapi.yml | 1431 ++++++++++------- proto/elys/perpetual/query.proto | 32 +- testutil/keeper/perpetual.go | 4 +- x/amm/types/calc_in_amt_given_out.go | 4 +- x/amm/types/calc_out_amt_given_in.go | 6 +- x/perpetual/client/cli/query.go | 2 + .../client/cli/query_close_estimation.go | 52 + x/perpetual/genesis_test.go | 2 +- x/perpetual/keeper/borrow_rate_test.go | 2 +- x/perpetual/keeper/calc_return_amount.go | 75 + x/perpetual/keeper/estimate_and_repay.go | 18 +- x/perpetual/keeper/keeper.go | 10 + .../msg_server_update_take_profit_price.go | 2 +- x/perpetual/keeper/msg_servers_test.go | 2 +- x/perpetual/keeper/params_test.go | 2 +- x/perpetual/keeper/pool_test.go | 6 +- x/perpetual/keeper/query_close_estimation.go | 93 ++ .../keeper/query_close_estimation_test.go | 149 ++ x/perpetual/keeper/query_params_test.go | 2 +- x/perpetual/keeper/repay.go | 136 +- x/perpetual/types/expected_keepers.go | 15 + .../types/message_update_take_profit_price.go | 10 +- .../types/mocks/close_estimation_checker.go | 501 ++++++ x/perpetual/types/query.pb.go | 892 ++++++++-- x/perpetual/types/query.pb.gw.go | 119 ++ 25 files changed, 2717 insertions(+), 850 deletions(-) create mode 100644 x/perpetual/client/cli/query_close_estimation.go create mode 100644 x/perpetual/keeper/calc_return_amount.go create mode 100644 x/perpetual/keeper/query_close_estimation.go create mode 100644 x/perpetual/keeper/query_close_estimation_test.go create mode 100644 x/perpetual/types/mocks/close_estimation_checker.go diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 808e70dc3..285488bf9 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -43509,6 +43509,93 @@ paths: additionalProperties: {} tags: - Query + /elys-network/elys/perpetual/close_estimation/{positionId}: + get: + summary: Queries a list of CloseEstimation items. + operationId: ElysPerpetualCloseEstimation + responses: + '200': + description: A successful response. + schema: + type: object + properties: + position: + type: string + positionSize: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + liabilities: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + priceImpact: + type: string + swapFee: + type: string + repayAmount: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: positionId + in: path + required: true + type: string + format: uint64 + tags: + - Query /elys-network/elys/perpetual/get_all_to_pay: get: summary: Queries a list of GetAllToPay items. @@ -43605,83 +43692,88 @@ paths: mtp: type: object properties: - address: - type: string - collateral_asset: - type: string - trading_asset: - type: string - liabilities_asset: - type: string - custody_asset: - type: string - collateral: - type: string - liabilities: - type: string - borrow_interest_paid_collateral: - type: string - borrow_interest_paid_custody: - type: string - borrow_interest_unpaid_collateral: - type: string - custody: - type: string - take_profit_liabilities: - type: string - take_profit_custody: - type: string - leverage: - type: string - mtp_health: - type: string - position: - type: string - enum: - - UNSPECIFIED - - LONG - - SHORT - default: UNSPECIFIED - id: - type: string - format: uint64 - amm_pool_id: - type: string - format: uint64 - consolidate_leverage: - type: string - sum_collateral: - type: string - take_profit_price: - type: string - take_profit_borrow_rate: - type: string - funding_fee_paid_collateral: - type: string - title: funding fee paid - funding_fee_paid_custody: - type: string - funding_fee_received_collateral: - type: string - title: funding fee received - funding_fee_received_custody: - type: string - open_price: - type: string - stop_loss_price: - type: string - last_interest_calc_time: - type: string - format: uint64 - last_interest_calc_block: - type: string - format: uint64 - last_funding_calc_time: - type: string - format: uint64 - last_funding_calc_block: + mtp: + type: object + properties: + address: + type: string + collateral_asset: + type: string + trading_asset: + type: string + liabilities_asset: + type: string + custody_asset: + type: string + collateral: + type: string + liabilities: + type: string + borrow_interest_paid_collateral: + type: string + borrow_interest_paid_custody: + type: string + borrow_interest_unpaid_collateral: + type: string + custody: + type: string + take_profit_liabilities: + type: string + take_profit_custody: + type: string + leverage: + type: string + mtp_health: + type: string + position: + type: string + enum: + - UNSPECIFIED + - LONG + - SHORT + default: UNSPECIFIED + id: + type: string + format: uint64 + amm_pool_id: + type: string + format: uint64 + consolidate_leverage: + type: string + sum_collateral: + type: string + take_profit_price: + type: string + take_profit_borrow_rate: + type: string + funding_fee_paid_collateral: + type: string + title: funding fee paid + funding_fee_paid_custody: + type: string + funding_fee_received_collateral: + type: string + title: funding fee received + funding_fee_received_custody: + type: string + open_price: + type: string + stop_loss_price: + type: string + last_interest_calc_time: + type: string + format: uint64 + last_interest_calc_block: + type: string + format: uint64 + last_funding_calc_time: + type: string + format: uint64 + last_funding_calc_block: + type: string + format: uint64 + trading_asset_price: type: string - format: uint64 default: description: An unexpected error response. schema: @@ -43727,83 +43819,88 @@ paths: items: type: object properties: - address: - type: string - collateral_asset: - type: string - trading_asset: - type: string - liabilities_asset: - type: string - custody_asset: - type: string - collateral: - type: string - liabilities: - type: string - borrow_interest_paid_collateral: - type: string - borrow_interest_paid_custody: - type: string - borrow_interest_unpaid_collateral: - type: string - custody: - type: string - take_profit_liabilities: - type: string - take_profit_custody: - type: string - leverage: - type: string - mtp_health: - type: string - position: - type: string - enum: - - UNSPECIFIED - - LONG - - SHORT - default: UNSPECIFIED - id: - type: string - format: uint64 - amm_pool_id: - type: string - format: uint64 - consolidate_leverage: - type: string - sum_collateral: - type: string - take_profit_price: - type: string - take_profit_borrow_rate: - type: string - funding_fee_paid_collateral: - type: string - title: funding fee paid - funding_fee_paid_custody: - type: string - funding_fee_received_collateral: - type: string - title: funding fee received - funding_fee_received_custody: - type: string - open_price: - type: string - stop_loss_price: - type: string - last_interest_calc_time: - type: string - format: uint64 - last_interest_calc_block: - type: string - format: uint64 - last_funding_calc_time: - type: string - format: uint64 - last_funding_calc_block: + mtp: + type: object + properties: + address: + type: string + collateral_asset: + type: string + trading_asset: + type: string + liabilities_asset: + type: string + custody_asset: + type: string + collateral: + type: string + liabilities: + type: string + borrow_interest_paid_collateral: + type: string + borrow_interest_paid_custody: + type: string + borrow_interest_unpaid_collateral: + type: string + custody: + type: string + take_profit_liabilities: + type: string + take_profit_custody: + type: string + leverage: + type: string + mtp_health: + type: string + position: + type: string + enum: + - UNSPECIFIED + - LONG + - SHORT + default: UNSPECIFIED + id: + type: string + format: uint64 + amm_pool_id: + type: string + format: uint64 + consolidate_leverage: + type: string + sum_collateral: + type: string + take_profit_price: + type: string + take_profit_borrow_rate: + type: string + funding_fee_paid_collateral: + type: string + title: funding fee paid + funding_fee_paid_custody: + type: string + funding_fee_received_collateral: + type: string + title: funding fee received + funding_fee_received_custody: + type: string + open_price: + type: string + stop_loss_price: + type: string + last_interest_calc_time: + type: string + format: uint64 + last_interest_calc_block: + type: string + format: uint64 + last_funding_calc_time: + type: string + format: uint64 + last_funding_calc_block: + type: string + format: uint64 + trading_asset_price: type: string - format: uint64 pagination: type: object properties: @@ -43929,83 +44026,88 @@ paths: items: type: object properties: - address: - type: string - collateral_asset: - type: string - trading_asset: - type: string - liabilities_asset: - type: string - custody_asset: - type: string - collateral: - type: string - liabilities: - type: string - borrow_interest_paid_collateral: - type: string - borrow_interest_paid_custody: - type: string - borrow_interest_unpaid_collateral: - type: string - custody: - type: string - take_profit_liabilities: - type: string - take_profit_custody: - type: string - leverage: - type: string - mtp_health: - type: string - position: - type: string - enum: - - UNSPECIFIED - - LONG - - SHORT - default: UNSPECIFIED - id: - type: string - format: uint64 - amm_pool_id: - type: string - format: uint64 - consolidate_leverage: - type: string - sum_collateral: - type: string - take_profit_price: - type: string - take_profit_borrow_rate: - type: string - funding_fee_paid_collateral: - type: string - title: funding fee paid - funding_fee_paid_custody: - type: string - funding_fee_received_collateral: - type: string - title: funding fee received - funding_fee_received_custody: - type: string - open_price: - type: string - stop_loss_price: - type: string - last_interest_calc_time: - type: string - format: uint64 - last_interest_calc_block: - type: string - format: uint64 - last_funding_calc_time: - type: string - format: uint64 - last_funding_calc_block: + mtp: + type: object + properties: + address: + type: string + collateral_asset: + type: string + trading_asset: + type: string + liabilities_asset: + type: string + custody_asset: + type: string + collateral: + type: string + liabilities: + type: string + borrow_interest_paid_collateral: + type: string + borrow_interest_paid_custody: + type: string + borrow_interest_unpaid_collateral: + type: string + custody: + type: string + take_profit_liabilities: + type: string + take_profit_custody: + type: string + leverage: + type: string + mtp_health: + type: string + position: + type: string + enum: + - UNSPECIFIED + - LONG + - SHORT + default: UNSPECIFIED + id: + type: string + format: uint64 + amm_pool_id: + type: string + format: uint64 + consolidate_leverage: + type: string + sum_collateral: + type: string + take_profit_price: + type: string + take_profit_borrow_rate: + type: string + funding_fee_paid_collateral: + type: string + title: funding fee paid + funding_fee_paid_custody: + type: string + funding_fee_received_collateral: + type: string + title: funding fee received + funding_fee_received_custody: + type: string + open_price: + type: string + stop_loss_price: + type: string + last_interest_calc_time: + type: string + format: uint64 + last_interest_calc_block: + type: string + format: uint64 + last_funding_calc_time: + type: string + format: uint64 + last_funding_calc_block: + type: string + format: uint64 + trading_asset_price: type: string - format: uint64 pagination: type: object properties: @@ -44432,6 +44534,8 @@ paths: title: >- funding rate, if positive longs pay shorts, if negative shorts pay longs + net_open_interest: + type: string default: description: An unexpected error response. schema: @@ -44530,6 +44634,8 @@ paths: title: >- funding rate, if positive longs pay shorts, if negative shorts pay longs + net_open_interest: + type: string pagination: type: object properties: @@ -44650,83 +44756,88 @@ paths: items: type: object properties: - address: - type: string - collateral_asset: - type: string - trading_asset: - type: string - liabilities_asset: - type: string - custody_asset: - type: string - collateral: - type: string - liabilities: - type: string - borrow_interest_paid_collateral: - type: string - borrow_interest_paid_custody: - type: string - borrow_interest_unpaid_collateral: - type: string - custody: - type: string - take_profit_liabilities: - type: string - take_profit_custody: - type: string - leverage: - type: string - mtp_health: - type: string - position: - type: string - enum: - - UNSPECIFIED - - LONG - - SHORT - default: UNSPECIFIED - id: - type: string - format: uint64 - amm_pool_id: - type: string - format: uint64 - consolidate_leverage: - type: string - sum_collateral: - type: string - take_profit_price: - type: string - take_profit_borrow_rate: - type: string - funding_fee_paid_collateral: - type: string - title: funding fee paid - funding_fee_paid_custody: - type: string - funding_fee_received_collateral: - type: string - title: funding fee received - funding_fee_received_custody: - type: string - open_price: - type: string - stop_loss_price: - type: string - last_interest_calc_time: - type: string - format: uint64 - last_interest_calc_block: - type: string - format: uint64 - last_funding_calc_time: - type: string - format: uint64 - last_funding_calc_block: + mtp: + type: object + properties: + address: + type: string + collateral_asset: + type: string + trading_asset: + type: string + liabilities_asset: + type: string + custody_asset: + type: string + collateral: + type: string + liabilities: + type: string + borrow_interest_paid_collateral: + type: string + borrow_interest_paid_custody: + type: string + borrow_interest_unpaid_collateral: + type: string + custody: + type: string + take_profit_liabilities: + type: string + take_profit_custody: + type: string + leverage: + type: string + mtp_health: + type: string + position: + type: string + enum: + - UNSPECIFIED + - LONG + - SHORT + default: UNSPECIFIED + id: + type: string + format: uint64 + amm_pool_id: + type: string + format: uint64 + consolidate_leverage: + type: string + sum_collateral: + type: string + take_profit_price: + type: string + take_profit_borrow_rate: + type: string + funding_fee_paid_collateral: + type: string + title: funding fee paid + funding_fee_paid_custody: + type: string + funding_fee_received_collateral: + type: string + title: funding fee received + funding_fee_received_custody: + type: string + open_price: + type: string + stop_loss_price: + type: string + last_interest_calc_time: + type: string + format: uint64 + last_interest_calc_block: + type: string + format: uint64 + last_funding_calc_time: + type: string + format: uint64 + last_funding_calc_block: + type: string + format: uint64 + trading_asset_price: type: string - format: uint64 pagination: type: object properties: @@ -46266,6 +46377,8 @@ paths: - EXECUTED - CANCLED default: PENDING + stop_loss_price: + type: string pagination: type: object properties: @@ -46446,6 +46559,8 @@ paths: - EXECUTED - CANCLED default: PENDING + stop_loss_price: + type: string default: description: An unexpected error response. schema: @@ -89935,6 +90050,122 @@ definitions: type: string format: uint64 elys.perpetual.MTPResponse: + type: object + properties: + mtp: + type: object + properties: + mtp: + type: object + properties: + address: + type: string + collateral_asset: + type: string + trading_asset: + type: string + liabilities_asset: + type: string + custody_asset: + type: string + collateral: + type: string + liabilities: + type: string + borrow_interest_paid_collateral: + type: string + borrow_interest_paid_custody: + type: string + borrow_interest_unpaid_collateral: + type: string + custody: + type: string + take_profit_liabilities: + type: string + take_profit_custody: + type: string + leverage: + type: string + mtp_health: + type: string + position: + type: string + enum: + - UNSPECIFIED + - LONG + - SHORT + default: UNSPECIFIED + id: + type: string + format: uint64 + amm_pool_id: + type: string + format: uint64 + consolidate_leverage: + type: string + sum_collateral: + type: string + take_profit_price: + type: string + take_profit_borrow_rate: + type: string + funding_fee_paid_collateral: + type: string + title: funding fee paid + funding_fee_paid_custody: + type: string + funding_fee_received_collateral: + type: string + title: funding fee received + funding_fee_received_custody: + type: string + open_price: + type: string + stop_loss_price: + type: string + last_interest_calc_time: + type: string + format: uint64 + last_interest_calc_block: + type: string + format: uint64 + last_funding_calc_time: + type: string + format: uint64 + last_funding_calc_block: + type: string + format: uint64 + trading_asset_price: + type: string + elys.perpetual.MsgAddCollateralResponse: + type: object + elys.perpetual.MsgClosePositionsResponse: + type: object + elys.perpetual.MsgCloseResponse: + type: object + properties: + id: + type: string + format: uint64 + amount: + type: string + elys.perpetual.MsgDewhitelistResponse: + type: object + elys.perpetual.MsgOpenResponse: + type: object + properties: + id: + type: string + format: uint64 + elys.perpetual.MsgUpdateParamsResponse: + type: object + elys.perpetual.MsgUpdateStopLossResponse: + type: object + elys.perpetual.MsgUpdateTakeProfitPriceResponse: + type: object + elys.perpetual.MsgWhitelistResponse: + type: object + elys.perpetual.MtpAndPrice: type: object properties: mtp: @@ -90017,32 +90248,8 @@ definitions: last_funding_calc_block: type: string format: uint64 - elys.perpetual.MsgAddCollateralResponse: - type: object - elys.perpetual.MsgClosePositionsResponse: - type: object - elys.perpetual.MsgCloseResponse: - type: object - properties: - id: - type: string - format: uint64 - amount: - type: string - elys.perpetual.MsgDewhitelistResponse: - type: object - elys.perpetual.MsgOpenResponse: - type: object - properties: - id: + trading_asset_price: type: string - format: uint64 - elys.perpetual.MsgUpdateParamsResponse: - type: object - elys.perpetual.MsgUpdateStopLossResponse: - type: object - elys.perpetual.MsgWhitelistResponse: - type: object elys.perpetual.Params: type: object properties: @@ -90151,7 +90358,24 @@ definitions: swap_fee: type: string description: ParamsResponse is response type for the Query/Params RPC method. - elys.perpetual.Pool: + elys.perpetual.PoolAsset: + type: object + properties: + liabilities: + type: string + custody: + type: string + take_profit_liabilities: + type: string + take_profit_custody: + type: string + asset_balance: + type: string + block_borrow_interest: + type: string + asset_denom: + type: string + elys.perpetual.PoolResponse: type: object properties: amm_pool_id: @@ -90211,22 +90435,7 @@ definitions: title: >- funding rate, if positive longs pay shorts, if negative shorts pay longs - elys.perpetual.PoolAsset: - type: object - properties: - liabilities: - type: string - custody: - type: string - take_profit_liabilities: - type: string - take_profit_custody: - type: string - asset_balance: - type: string - block_borrow_interest: - type: string - asset_denom: + net_open_interest: type: string elys.perpetual.Position: type: string @@ -90251,83 +90460,88 @@ definitions: items: type: object properties: - address: - type: string - collateral_asset: - type: string - trading_asset: - type: string - liabilities_asset: - type: string - custody_asset: - type: string - collateral: - type: string - liabilities: - type: string - borrow_interest_paid_collateral: - type: string - borrow_interest_paid_custody: - type: string - borrow_interest_unpaid_collateral: - type: string - custody: - type: string - take_profit_liabilities: - type: string - take_profit_custody: - type: string - leverage: - type: string - mtp_health: - type: string - position: - type: string - enum: - - UNSPECIFIED - - LONG - - SHORT - default: UNSPECIFIED - id: - type: string - format: uint64 - amm_pool_id: - type: string - format: uint64 - consolidate_leverage: - type: string - sum_collateral: - type: string - take_profit_price: - type: string - take_profit_borrow_rate: - type: string - funding_fee_paid_collateral: - type: string - title: funding fee paid - funding_fee_paid_custody: - type: string - funding_fee_received_collateral: - type: string - title: funding fee received - funding_fee_received_custody: - type: string - open_price: - type: string - stop_loss_price: - type: string - last_interest_calc_time: - type: string - format: uint64 - last_interest_calc_block: - type: string - format: uint64 - last_funding_calc_time: - type: string - format: uint64 - last_funding_calc_block: + mtp: + type: object + properties: + address: + type: string + collateral_asset: + type: string + trading_asset: + type: string + liabilities_asset: + type: string + custody_asset: + type: string + collateral: + type: string + liabilities: + type: string + borrow_interest_paid_collateral: + type: string + borrow_interest_paid_custody: + type: string + borrow_interest_unpaid_collateral: + type: string + custody: + type: string + take_profit_liabilities: + type: string + take_profit_custody: + type: string + leverage: + type: string + mtp_health: + type: string + position: + type: string + enum: + - UNSPECIFIED + - LONG + - SHORT + default: UNSPECIFIED + id: + type: string + format: uint64 + amm_pool_id: + type: string + format: uint64 + consolidate_leverage: + type: string + sum_collateral: + type: string + take_profit_price: + type: string + take_profit_borrow_rate: + type: string + funding_fee_paid_collateral: + type: string + title: funding fee paid + funding_fee_paid_custody: + type: string + funding_fee_received_collateral: + type: string + title: funding fee received + funding_fee_received_custody: + type: string + open_price: + type: string + stop_loss_price: + type: string + last_interest_calc_time: + type: string + format: uint64 + last_interest_calc_block: + type: string + format: uint64 + last_funding_calc_time: + type: string + format: uint64 + last_funding_calc_block: + type: string + format: uint64 + trading_asset_price: type: string - format: uint64 pagination: type: object properties: @@ -90362,83 +90576,88 @@ definitions: items: type: object properties: - address: - type: string - collateral_asset: - type: string - trading_asset: - type: string - liabilities_asset: - type: string - custody_asset: - type: string - collateral: - type: string - liabilities: - type: string - borrow_interest_paid_collateral: - type: string - borrow_interest_paid_custody: - type: string - borrow_interest_unpaid_collateral: - type: string - custody: - type: string - take_profit_liabilities: - type: string - take_profit_custody: - type: string - leverage: - type: string - mtp_health: - type: string - position: - type: string - enum: - - UNSPECIFIED - - LONG - - SHORT - default: UNSPECIFIED - id: - type: string - format: uint64 - amm_pool_id: - type: string - format: uint64 - consolidate_leverage: - type: string - sum_collateral: - type: string - take_profit_price: - type: string - take_profit_borrow_rate: - type: string - funding_fee_paid_collateral: - type: string - title: funding fee paid - funding_fee_paid_custody: - type: string - funding_fee_received_collateral: - type: string - title: funding fee received - funding_fee_received_custody: - type: string - open_price: - type: string - stop_loss_price: - type: string - last_interest_calc_time: - type: string - format: uint64 - last_interest_calc_block: - type: string - format: uint64 - last_funding_calc_time: - type: string - format: uint64 - last_funding_calc_block: + mtp: + type: object + properties: + address: + type: string + collateral_asset: + type: string + trading_asset: + type: string + liabilities_asset: + type: string + custody_asset: + type: string + collateral: + type: string + liabilities: + type: string + borrow_interest_paid_collateral: + type: string + borrow_interest_paid_custody: + type: string + borrow_interest_unpaid_collateral: + type: string + custody: + type: string + take_profit_liabilities: + type: string + take_profit_custody: + type: string + leverage: + type: string + mtp_health: + type: string + position: + type: string + enum: + - UNSPECIFIED + - LONG + - SHORT + default: UNSPECIFIED + id: + type: string + format: uint64 + amm_pool_id: + type: string + format: uint64 + consolidate_leverage: + type: string + sum_collateral: + type: string + take_profit_price: + type: string + take_profit_borrow_rate: + type: string + funding_fee_paid_collateral: + type: string + title: funding fee paid + funding_fee_paid_custody: + type: string + funding_fee_received_collateral: + type: string + title: funding fee received + funding_fee_received_custody: + type: string + open_price: + type: string + stop_loss_price: + type: string + last_interest_calc_time: + type: string + format: uint64 + last_interest_calc_block: + type: string + format: uint64 + last_funding_calc_time: + type: string + format: uint64 + last_funding_calc_block: + type: string + format: uint64 + trading_asset_price: type: string - format: uint64 pagination: type: object properties: @@ -90473,83 +90692,88 @@ definitions: items: type: object properties: - address: - type: string - collateral_asset: - type: string - trading_asset: - type: string - liabilities_asset: - type: string - custody_asset: - type: string - collateral: - type: string - liabilities: - type: string - borrow_interest_paid_collateral: - type: string - borrow_interest_paid_custody: - type: string - borrow_interest_unpaid_collateral: - type: string - custody: - type: string - take_profit_liabilities: - type: string - take_profit_custody: - type: string - leverage: - type: string - mtp_health: - type: string - position: - type: string - enum: - - UNSPECIFIED - - LONG - - SHORT - default: UNSPECIFIED - id: - type: string - format: uint64 - amm_pool_id: - type: string - format: uint64 - consolidate_leverage: - type: string - sum_collateral: - type: string - take_profit_price: - type: string - take_profit_borrow_rate: - type: string - funding_fee_paid_collateral: - type: string - title: funding fee paid - funding_fee_paid_custody: - type: string - funding_fee_received_collateral: - type: string - title: funding fee received - funding_fee_received_custody: - type: string - open_price: - type: string - stop_loss_price: - type: string - last_interest_calc_time: - type: string - format: uint64 - last_interest_calc_block: - type: string - format: uint64 - last_funding_calc_time: - type: string - format: uint64 - last_funding_calc_block: + mtp: + type: object + properties: + address: + type: string + collateral_asset: + type: string + trading_asset: + type: string + liabilities_asset: + type: string + custody_asset: + type: string + collateral: + type: string + liabilities: + type: string + borrow_interest_paid_collateral: + type: string + borrow_interest_paid_custody: + type: string + borrow_interest_unpaid_collateral: + type: string + custody: + type: string + take_profit_liabilities: + type: string + take_profit_custody: + type: string + leverage: + type: string + mtp_health: + type: string + position: + type: string + enum: + - UNSPECIFIED + - LONG + - SHORT + default: UNSPECIFIED + id: + type: string + format: uint64 + amm_pool_id: + type: string + format: uint64 + consolidate_leverage: + type: string + sum_collateral: + type: string + take_profit_price: + type: string + take_profit_borrow_rate: + type: string + funding_fee_paid_collateral: + type: string + title: funding fee paid + funding_fee_paid_custody: + type: string + funding_fee_received_collateral: + type: string + title: funding fee received + funding_fee_received_custody: + type: string + open_price: + type: string + stop_loss_price: + type: string + last_interest_calc_time: + type: string + format: uint64 + last_interest_calc_block: + type: string + format: uint64 + last_funding_calc_time: + type: string + format: uint64 + last_funding_calc_block: + type: string + format: uint64 + trading_asset_price: type: string - format: uint64 pagination: type: object properties: @@ -90641,6 +90865,8 @@ definitions: title: >- funding rate, if positive longs pay shorts, if negative shorts pay longs + net_open_interest: + type: string pagination: type: object properties: @@ -90667,6 +90893,51 @@ definitions: repeated Bar results = 1; PageResponse page = 2; } + elys.perpetual.QueryCloseEstimationResponse: + type: object + properties: + position: + type: string + positionSize: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + liabilities: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + priceImpact: + type: string + swapFee: + type: string + repayAmount: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. elys.perpetual.QueryGetAllToPayResponse: type: object properties: @@ -90747,6 +91018,8 @@ definitions: title: >- funding rate, if positive longs pay shorts, if negative shorts pay longs + net_open_interest: + type: string elys.perpetual.QueryOpenEstimationResponse: type: object properties: @@ -91407,13 +91680,13 @@ definitions: elys.tradeshield.MsgCreatePendingPerpetualOrderResponse: type: object properties: - id: + order_id: type: string format: uint64 elys.tradeshield.MsgCreatePendingSpotOrderResponse: type: object properties: - id: + order_id: type: string format: uint64 elys.tradeshield.MsgDeletePendingPerpetualOrderResponse: @@ -91527,6 +91800,8 @@ definitions: - EXECUTED - CANCLED default: PENDING + stop_loss_price: + type: string elys.tradeshield.PerpetualOrderType: type: string enum: @@ -91614,6 +91889,8 @@ definitions: - EXECUTED - CANCLED default: PENDING + stop_loss_price: + type: string pagination: type: object properties: @@ -91798,6 +92075,8 @@ definitions: - EXECUTED - CANCLED default: PENDING + stop_loss_price: + type: string elys.tradeshield.QueryGetPendingSpotOrderResponse: type: object properties: diff --git a/proto/elys/perpetual/query.proto b/proto/elys/perpetual/query.proto index 24ed446ee..a8ace419d 100644 --- a/proto/elys/perpetual/query.proto +++ b/proto/elys/perpetual/query.proto @@ -86,10 +86,15 @@ service Query { option (google.api.http).get = "/elys-network/elys/perpetual/get_all_to_pay"; } + + // Queries a list of CloseEstimation items. + rpc CloseEstimation (QueryCloseEstimationRequest) returns (QueryCloseEstimationResponse) { + option (google.api.http).get = "/elys-network/elys/perpetual/close-estimation/{position_id}"; + + } } - message MtpAndPrice { - MTP mtp =1; + MTP mtp = 1; string trading_asset_price = 2 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false @@ -99,6 +104,7 @@ message MtpAndPrice { (gogoproto.nullable) = false ]; } + // ParamsRequest is request type for the Query/Params RPC method. message ParamsRequest {} @@ -114,7 +120,7 @@ message PositionsRequest { } message PositionsResponse { - repeated MtpAndPrice mtps = 1; + repeated MtpAndPrice mtps = 1; cosmos.base.query.v1beta1.PageResponse pagination = 2; } @@ -124,7 +130,7 @@ message PositionsByPoolRequest { } message PositionsByPoolResponse { - repeated MtpAndPrice mtps = 1; + repeated MtpAndPrice mtps = 1; cosmos.base.query.v1beta1.PageResponse pagination = 2; } @@ -141,7 +147,7 @@ message PositionsForAddressRequest { } message PositionsForAddressResponse { - repeated MtpAndPrice mtps = 1; + repeated MtpAndPrice mtps = 1; cosmos.base.query.v1beta1.PageResponse pagination = 2; } @@ -176,8 +182,8 @@ message QueryAllPoolRequest { } message QueryAllPoolResponse { - repeated PoolResponse pool = 1 [(gogoproto.nullable) = false]; - cosmos.base.query.v1beta1.PageResponse pagination = 2; + repeated PoolResponse pool = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; } message MTPRequest { @@ -252,6 +258,18 @@ message PoolResponse { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; +} +message QueryCloseEstimationRequest { + string address = 1; + uint64 position_id = 2; } +message QueryCloseEstimationResponse { + Position position = 1; + cosmos.base.v1beta1.Coin position_size = 2 [(gogoproto.nullable) = false]; + cosmos.base.v1beta1.Coin liabilities = 3 [(gogoproto.nullable) = false]; + string price_impact = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + string swap_fee = 5 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + cosmos.base.v1beta1.Coin return_amount = 6 [(gogoproto.nullable) = false]; +} \ No newline at end of file diff --git a/testutil/keeper/perpetual.go b/testutil/keeper/perpetual.go index 3a69ac276..6df383295 100644 --- a/testutil/keeper/perpetual.go +++ b/testutil/keeper/perpetual.go @@ -18,7 +18,7 @@ import ( "github.com/stretchr/testify/require" ) -func PerpetualKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { +func PerpetualKeeper(t testing.TB) (*keeper.Keeper, sdk.Context, *mocks.AssetProfileKeeper) { storeKey := sdk.NewKVStoreKey(types.StoreKey) memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) @@ -52,5 +52,5 @@ func PerpetualKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { params := types.DefaultParams() k.SetParams(ctx, ¶ms) - return k, ctx + return k, ctx, assetProfileKeeper } diff --git a/x/amm/types/calc_in_amt_given_out.go b/x/amm/types/calc_in_amt_given_out.go index aaee8e42c..fbc005a95 100644 --- a/x/amm/types/calc_in_amt_given_out.go +++ b/x/amm/types/calc_in_amt_given_out.go @@ -68,9 +68,9 @@ func (p Pool) CalcInAmtGivenOut( } amountInWithoutSlippage := sdk.NewDecFromInt(tokenOut.Amount).Quo(rate) - if tokenAmountIn.IsZero(){ + if tokenAmountIn.IsZero() { return sdk.Coin{}, sdk.ZeroDec(), ErrAmountTooLow - } + } slippage = sdk.OneDec().Sub(amountInWithoutSlippage.Quo(tokenAmountIn)) // Ensure (1 - swapfee) is not zero to avoid division by zero diff --git a/x/amm/types/calc_out_amt_given_in.go b/x/amm/types/calc_out_amt_given_in.go index c8155201b..963b2bf60 100644 --- a/x/amm/types/calc_out_amt_given_in.go +++ b/x/amm/types/calc_out_amt_given_in.go @@ -65,9 +65,9 @@ func (p Pool) CalcOutAmtGivenIn( if err != nil { return sdk.Coin{}, sdk.ZeroDec(), err } - if tokenAmountOut.IsZero(){ + if tokenAmountOut.IsZero() { return sdk.Coin{}, sdk.ZeroDec(), ErrAmountTooLow - } + } rate, err := p.GetTokenARate(ctx, oracle, snapshot, tokenIn.Denom, tokenOutDenom, accountedPool) if err != nil { @@ -80,7 +80,7 @@ func (p Pool) CalcOutAmtGivenIn( if amountOutWithoutSlippage.IsZero() { return sdk.Coin{}, sdk.ZeroDec(), errorsmod.Wrapf(ErrInvalidMathApprox, "amount out without slippage must be positive") } - + slippage := sdk.OneDec().Sub(tokenAmountOut.Quo(amountOutWithoutSlippage)) // We ignore the decimal component, as we round down the token amount out. diff --git a/x/perpetual/client/cli/query.go b/x/perpetual/client/cli/query.go index 713999dc3..19a03b87c 100644 --- a/x/perpetual/client/cli/query.go +++ b/x/perpetual/client/cli/query.go @@ -38,6 +38,8 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdGetAllToPay()) + cmd.AddCommand(CmdCloseEstimation()) + // this line is used by starport scaffolding # 1 return cmd diff --git a/x/perpetual/client/cli/query_close_estimation.go b/x/perpetual/client/cli/query_close_estimation.go new file mode 100644 index 000000000..8df4000fe --- /dev/null +++ b/x/perpetual/client/cli/query_close_estimation.go @@ -0,0 +1,52 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/elys-network/elys/x/perpetual/types" + "github.com/spf13/cast" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdCloseEstimation() *cobra.Command { + cmd := &cobra.Command{ + Use: "close-estimation [address] [position-id]", + Short: "Query close-estimation", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqAddress := args[0] + + reqPositionId, err := cast.ToUint64E(args[1]) + if err != nil { + return err + } + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryCloseEstimationRequest{ + Address: reqAddress, + PositionId: reqPositionId, + } + + res, err := queryClient.CloseEstimation(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/perpetual/genesis_test.go b/x/perpetual/genesis_test.go index 6754a20ea..81d04af74 100644 --- a/x/perpetual/genesis_test.go +++ b/x/perpetual/genesis_test.go @@ -25,7 +25,7 @@ func TestGenesis(t *testing.T) { // this line is used by starport scaffolding # genesis/test/state } - k, ctx := keepertest.PerpetualKeeper(t) + k, ctx, _ := keepertest.PerpetualKeeper(t) perpetual.InitGenesis(ctx, *k, genesisState) got := perpetual.ExportGenesis(ctx, *k) require.NotNil(t, got) diff --git a/x/perpetual/keeper/borrow_rate_test.go b/x/perpetual/keeper/borrow_rate_test.go index f7562e59d..ee046e2bb 100644 --- a/x/perpetual/keeper/borrow_rate_test.go +++ b/x/perpetual/keeper/borrow_rate_test.go @@ -26,7 +26,7 @@ func createNBorrowRate(keeper *keeper.Keeper, ctx sdk.Context, n int) ([]types.I } func TestBorrowRateGet(t *testing.T) { - keeper, ctx := keepertest.PerpetualKeeper(t) + keeper, ctx, _ := keepertest.PerpetualKeeper(t) _, lastBlock := createNBorrowRate(keeper, ctx, 10) ctx = ctx.WithBlockHeight(lastBlock) diff --git a/x/perpetual/keeper/calc_return_amount.go b/x/perpetual/keeper/calc_return_amount.go new file mode 100644 index 000000000..f4bb0095e --- /dev/null +++ b/x/perpetual/keeper/calc_return_amount.go @@ -0,0 +1,75 @@ +package keeper + +import ( + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + ammtypes "github.com/elys-network/elys/x/amm/types" + "github.com/elys-network/elys/x/perpetual/types" +) + +func (k Keeper) CalcReturnAmount(ctx sdk.Context, mtp types.MTP, pool types.Pool, ammPool ammtypes.Pool, repayAmount math.Int, amount math.Int, baseCurrency string) (returnAmount math.Int, err error) { + Liabilities := mtp.Liabilities + BorrowInterestUnpaid := mtp.BorrowInterestUnpaidCollateral + + if mtp.BorrowInterestUnpaidCollateral.IsPositive() { + if mtp.Position == types.Position_SHORT { + // swap to trading asset + unpaidCollateralIn := sdk.NewCoin(mtp.CollateralAsset, mtp.BorrowInterestUnpaidCollateral) + C, err := k.CloseEstimationChecker.EstimateSwapGivenOut(ctx, unpaidCollateralIn, mtp.TradingAsset, ammPool) + if err != nil { + return sdk.ZeroInt(), err + } + + BorrowInterestUnpaid = C + } else if mtp.CollateralAsset != baseCurrency { + // swap to base currency + unpaidCollateralIn := sdk.NewCoin(mtp.CollateralAsset, mtp.BorrowInterestUnpaidCollateral) + C, err := k.CloseEstimationChecker.EstimateSwapGivenOut(ctx, unpaidCollateralIn, baseCurrency, ammPool) + if err != nil { + return sdk.ZeroInt(), err + } + + BorrowInterestUnpaid = C + } + } + + // Reminder: + // if long both repay amount and liablities are collateral asset + // if short both repay amount and liablities are trading asset + + have := repayAmount + owe := Liabilities.Add(BorrowInterestUnpaid).Mul(amount.Quo(mtp.Custody)) + + if have.LT(owe) { + // v principle liability; x excess liability + returnAmount = sdk.ZeroInt() + } else { + // can afford both + returnAmount = have.Sub(owe) + } + + // returnAmount is so far in base currency if long or trading asset if short, now should convert it to collateralAsset in order to return + if returnAmount.IsPositive() { + if mtp.Position == types.Position_SHORT { + // swap to collateral asset + amtTokenIn := sdk.NewCoin(mtp.TradingAsset, returnAmount) + C, err := k.CloseEstimationChecker.EstimateSwapGivenOut(ctx, amtTokenIn, mtp.CollateralAsset, ammPool) + if err != nil { + return sdk.ZeroInt(), err + } + + returnAmount = C + } else if mtp.CollateralAsset != baseCurrency { + // swap to collateral asset + amtTokenIn := sdk.NewCoin(baseCurrency, returnAmount) + C, err := k.CloseEstimationChecker.EstimateSwapGivenOut(ctx, amtTokenIn, mtp.CollateralAsset, ammPool) + if err != nil { + return sdk.ZeroInt(), err + } + + returnAmount = C + } + } + + return returnAmount, nil +} diff --git a/x/perpetual/keeper/estimate_and_repay.go b/x/perpetual/keeper/estimate_and_repay.go index ef7592349..6ba78c80c 100644 --- a/x/perpetual/keeper/estimate_and_repay.go +++ b/x/perpetual/keeper/estimate_and_repay.go @@ -30,8 +30,24 @@ func (k Keeper) EstimateAndRepay(ctx sdk.Context, mtp types.MTP, pool types.Pool return sdk.ZeroInt(), types.ErrInvalidPosition } + returnAmount, err := k.CalcReturnAmount(ctx, mtp, pool, ammPool, repayAmount, amount, baseCurrency) + if err != nil { + return sdk.ZeroInt(), err + } + + // update mtp health + mtp.MtpHealth, err = k.GetMTPHealth(ctx, mtp, ammPool, baseCurrency) + if err != nil { + return sdk.ZeroInt(), err + } + + // if return amount positive then update liabilities + if returnAmount.IsPositive() { + mtp.Liabilities = mtp.Liabilities.Sub(mtp.Liabilities.Mul(amount).Quo(mtp.Custody)) + } + // Note: Long settlement is done in trading asset. And short settlement in usdc in Repay function - if err := k.Repay(ctx, &mtp, &pool, ammPool, repayAmount, false, amount, baseCurrency); err != nil { + if err := k.Repay(ctx, &mtp, &pool, ammPool, returnAmount, amount); err != nil { return sdk.ZeroInt(), err } diff --git a/x/perpetual/keeper/keeper.go b/x/perpetual/keeper/keeper.go index becaa8842..5b6089732 100644 --- a/x/perpetual/keeper/keeper.go +++ b/x/perpetual/keeper/keeper.go @@ -25,6 +25,7 @@ type ( types.OpenShortChecker types.CloseLongChecker types.CloseShortChecker + types.CloseEstimationChecker cdc codec.BinaryCodec storeKey storetypes.StoreKey @@ -76,6 +77,7 @@ func NewKeeper( keeper.OpenShortChecker = keeper keeper.CloseLongChecker = keeper keeper.CloseShortChecker = keeper + keeper.CloseEstimationChecker = keeper return keeper } @@ -457,6 +459,14 @@ func (k Keeper) TakeFundPayment(ctx sdk.Context, returnAmount math.Int, returnAs return takeAmount, nil } +// CalcTakeFundPayment calculates the take fund payment +func (k Keeper) CalcTakeFundPayment(ctx sdk.Context, returnAmount math.Int, returnAsset string, takePercentage sdk.Dec) math.Int { + returnAmountDec := sdk.NewDecFromBigInt(returnAmount.BigInt()) + takeAmount := sdk.NewIntFromBigInt(takePercentage.Mul(returnAmountDec).TruncateInt().BigInt()) + + return takeAmount +} + // Set the perpetual hooks. func (k *Keeper) SetHooks(gh types.PerpetualHooks) *Keeper { if k.hooks != nil { diff --git a/x/perpetual/keeper/msg_server_update_take_profit_price.go b/x/perpetual/keeper/msg_server_update_take_profit_price.go index 29a5642ca..9788d5be1 100644 --- a/x/perpetual/keeper/msg_server_update_take_profit_price.go +++ b/x/perpetual/keeper/msg_server_update_take_profit_price.go @@ -7,9 +7,9 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/perpetual/types" assetprofiletypes "github.com/elys-network/elys/x/assetprofile/types" ptypes "github.com/elys-network/elys/x/parameter/types" + "github.com/elys-network/elys/x/perpetual/types" ) func (k msgServer) UpdateTakeProfitPrice(goCtx context.Context, msg *types.MsgUpdateTakeProfitPrice) (*types.MsgUpdateTakeProfitPriceResponse, error) { diff --git a/x/perpetual/keeper/msg_servers_test.go b/x/perpetual/keeper/msg_servers_test.go index f9cc36bc6..a2b6f2bd2 100644 --- a/x/perpetual/keeper/msg_servers_test.go +++ b/x/perpetual/keeper/msg_servers_test.go @@ -11,6 +11,6 @@ import ( ) func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { - k, ctx := keepertest.PerpetualKeeper(t) + k, ctx, _ := keepertest.PerpetualKeeper(t) return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) } diff --git a/x/perpetual/keeper/params_test.go b/x/perpetual/keeper/params_test.go index 7beb1990b..68539f697 100644 --- a/x/perpetual/keeper/params_test.go +++ b/x/perpetual/keeper/params_test.go @@ -9,7 +9,7 @@ import ( ) func TestGetParams(t *testing.T) { - k, ctx := testkeeper.PerpetualKeeper(t) + k, ctx, _ := testkeeper.PerpetualKeeper(t) params := types.DefaultParams() k.SetParams(ctx, ¶ms) diff --git a/x/perpetual/keeper/pool_test.go b/x/perpetual/keeper/pool_test.go index 706ed227e..7b4809ff9 100644 --- a/x/perpetual/keeper/pool_test.go +++ b/x/perpetual/keeper/pool_test.go @@ -43,7 +43,7 @@ func createNPoolResponse(keeper *keeper.Keeper, ctx sdk.Context, n int) []types. } func TestPoolGet(t *testing.T) { - keeper, ctx := keepertest.PerpetualKeeper(t) + keeper, ctx, _ := keepertest.PerpetualKeeper(t) items := createNPool(keeper, ctx, 10) for _, item := range items { rst, found := keeper.GetPool(ctx, @@ -58,7 +58,7 @@ func TestPoolGet(t *testing.T) { } func TestPoolRemove(t *testing.T) { - keeper, ctx := keepertest.PerpetualKeeper(t) + keeper, ctx, _ := keepertest.PerpetualKeeper(t) items := createNPool(keeper, ctx, 10) for _, item := range items { keeper.RemovePool(ctx, @@ -72,7 +72,7 @@ func TestPoolRemove(t *testing.T) { } func TestPoolGetAll(t *testing.T) { - keeper, ctx := keepertest.PerpetualKeeper(t) + keeper, ctx, _ := keepertest.PerpetualKeeper(t) items := createNPool(keeper, ctx, 10) require.ElementsMatch(t, nullify.Fill(items), diff --git a/x/perpetual/keeper/query_close_estimation.go b/x/perpetual/keeper/query_close_estimation.go new file mode 100644 index 000000000..d5142d128 --- /dev/null +++ b/x/perpetual/keeper/query_close_estimation.go @@ -0,0 +1,93 @@ +package keeper + +import ( + "context" + + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + assetprofiletypes "github.com/elys-network/elys/x/assetprofile/types" + ptypes "github.com/elys-network/elys/x/parameter/types" + "github.com/elys-network/elys/x/perpetual/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) CloseEstimation(goCtx context.Context, req *types.QueryCloseEstimationRequest) (res *types.QueryCloseEstimationResponse, err error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + address, err := sdk.AccAddressFromBech32(req.Address) + if err != nil { + return &types.QueryCloseEstimationResponse{}, err + } + mtp, err := k.CloseEstimationChecker.GetMTP(ctx, address, req.PositionId) + if err != nil { + return &types.QueryCloseEstimationResponse{}, err + } + + // Retrieve Pool + pool, found := k.CloseEstimationChecker.GetPool(ctx, mtp.AmmPoolId) + if !found { + return &types.QueryCloseEstimationResponse{}, errorsmod.Wrap(types.ErrInvalidBorrowingAsset, "invalid pool id") + } + + _ = pool + + // Retrieve AmmPool + ammPool, err := k.CloseEstimationChecker.GetAmmPool(ctx, mtp.AmmPoolId, mtp.CustodyAsset) + if err != nil { + return &types.QueryCloseEstimationResponse{}, err + } + + _ = ammPool + + // get base currency entry + entry, found := k.assetProfileKeeper.GetEntry(ctx, ptypes.BaseCurrency) + if !found { + return &types.QueryCloseEstimationResponse{}, errorsmod.Wrapf(assetprofiletypes.ErrAssetProfileNotFound, "asset %s not found", ptypes.BaseCurrency) + } + baseCurrency := entry.Denom + + // init repay amount + var repayAmount math.Int + + // if position is long, repay in collateral asset + if mtp.Position == types.Position_LONG { + custodyAmtTokenIn := sdk.NewCoin(mtp.CustodyAsset, mtp.Custody) + repayAmount, err = k.CloseEstimationChecker.EstimateSwap(ctx, custodyAmtTokenIn, mtp.CollateralAsset, ammPool) + if err != nil { + return &types.QueryCloseEstimationResponse{}, err + } + } else if mtp.Position == types.Position_SHORT { + // if position is short, repay in trading asset + custodyAmtTokenIn := sdk.NewCoin(mtp.CustodyAsset, mtp.Custody) + repayAmount, err = k.CloseEstimationChecker.EstimateSwap(ctx, custodyAmtTokenIn, mtp.TradingAsset, ammPool) + if err != nil { + return &types.QueryCloseEstimationResponse{}, err + } + } else { + return &types.QueryCloseEstimationResponse{}, types.ErrInvalidPosition + } + + returnAmount, err := k.CalcReturnAmount(ctx, mtp, pool, ammPool, repayAmount, mtp.Custody, baseCurrency) + if err != nil { + return &types.QueryCloseEstimationResponse{}, err + } + + // get swap fee param + swapFee := k.GetSwapFee(ctx) + + return &types.QueryCloseEstimationResponse{ + Position: mtp.Position, + PositionSize: sdk.NewCoin(mtp.CustodyAsset, mtp.Custody), + Liabilities: sdk.NewCoin(mtp.LiabilitiesAsset, mtp.Liabilities), + // TODO: price impact calculation + PriceImpact: sdk.ZeroDec(), + SwapFee: swapFee, + ReturnAmount: sdk.NewCoin(mtp.CollateralAsset, returnAmount), + }, nil +} diff --git a/x/perpetual/keeper/query_close_estimation_test.go b/x/perpetual/keeper/query_close_estimation_test.go new file mode 100644 index 000000000..7be139abc --- /dev/null +++ b/x/perpetual/keeper/query_close_estimation_test.go @@ -0,0 +1,149 @@ +package keeper_test + +import ( + "testing" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + keepertest "github.com/elys-network/elys/testutil/keeper" + ammtypes "github.com/elys-network/elys/x/amm/types" + atypes "github.com/elys-network/elys/x/assetprofile/types" + ptypes "github.com/elys-network/elys/x/parameter/types" + "github.com/elys-network/elys/x/perpetual/keeper" + "github.com/elys-network/elys/x/perpetual/types" + "github.com/elys-network/elys/x/perpetual/types/mocks" + "github.com/stretchr/testify/assert" +) + +func TestCloseEstimation_InvalidRequest(t *testing.T) { + // Setup the mock checker + mockChecker := new(mocks.CloseEstimationChecker) + + // Create an instance of Keeper with the mock checker + k := keeper.Keeper{ + CloseEstimationChecker: mockChecker, + } + + // Mock behavior + // No mock behavior + + _, err := k.CloseEstimation(sdk.Context{}, nil) + assert.Error(t, err) +} + +func TestCloseEstimation_InvalidAddress(t *testing.T) { + // Setup the mock checker + mockChecker := new(mocks.CloseEstimationChecker) + + // Create an instance of Keeper with the mock checker + k := keeper.Keeper{ + CloseEstimationChecker: mockChecker, + } + + var ( + ctx = sdk.Context{} // Mock or setup a context + query = &types.QueryCloseEstimationRequest{ + Address: "invalid_address", + PositionId: 1, + } + ) + + // Mock behavior + // No mock behavior + + _, err := k.CloseEstimation(ctx, query) + assert.Error(t, err) +} + +func TestCloseEstimation_MTPNotFound(t *testing.T) { + // Setup the mock checker + mockChecker := new(mocks.CloseEstimationChecker) + + // Create an instance of Keeper with the mock checker + k := keeper.Keeper{ + CloseEstimationChecker: mockChecker, + } + + address := sdk.AccAddress([]byte("address")) + + var ( + ctx = sdk.Context{} // Mock or setup a context + query = &types.QueryCloseEstimationRequest{ + Address: address.String(), + PositionId: 1, + } + ) + + // Mock behavior + mockChecker.On("GetMTP", ctx, sdk.MustAccAddressFromBech32(query.Address), query.PositionId).Return(types.MTP{}, types.ErrMTPDoesNotExist) + + _, err := k.CloseEstimation(ctx, query) + assert.Error(t, err) + + mockChecker.AssertExpectations(t) +} + +func TestCloseEstimation_ExistingMTP(t *testing.T) { + // Setup the perpetual keeper + k, ctx, assetProfileKeeper := keepertest.PerpetualKeeper(t) + + // Setup the mock checker + mockChecker := new(mocks.CloseEstimationChecker) + + // assign the mock checker to the keeper + k.CloseEstimationChecker = mockChecker + + address := sdk.AccAddress([]byte("address")) + + // get swap fee param + swapFee := k.GetSwapFee(ctx) + + var ( + query = &types.QueryCloseEstimationRequest{ + Address: address.String(), + PositionId: 1, + } + mtp = types.MTP{ + AmmPoolId: 2, + CollateralAsset: ptypes.BaseCurrency, + Collateral: sdk.NewInt(100), + CustodyAsset: "uatom", + Custody: sdk.NewInt(50), + LiabilitiesAsset: ptypes.BaseCurrency, + Liabilities: sdk.NewInt(400), + TradingAsset: "uatom", + Position: types.Position_LONG, + BorrowInterestUnpaidCollateral: sdk.NewInt(10), + } + pool = types.Pool{ + BorrowInterestRate: math.LegacyNewDec(2), + } + ammPool = ammtypes.Pool{} + baseCurrency = "usdc" + ) + + // Mock behavior + mockChecker.On("GetMTP", ctx, sdk.MustAccAddressFromBech32(query.Address), query.PositionId).Return(mtp, nil).Once() + mockChecker.On("GetPool", ctx, mtp.AmmPoolId).Return(pool, true).Once() + mockChecker.On("GetAmmPool", ctx, mtp.AmmPoolId, mtp.CustodyAsset).Return(ammPool, nil).Once() + mockChecker.On("EstimateSwap", ctx, sdk.NewCoin(mtp.CustodyAsset, mtp.Custody), mtp.CollateralAsset, ammPool).Return(math.NewInt(10000), nil).Once() + mockChecker.On("EstimateSwapGivenOut", ctx, sdk.NewCoin(mtp.CollateralAsset, mtp.BorrowInterestUnpaidCollateral), baseCurrency, ammPool).Return(math.NewInt(200), nil).Once() + mockChecker.On("EstimateSwapGivenOut", ctx, sdk.NewCoin(baseCurrency, sdk.NewInt(9400)), mtp.CollateralAsset, ammPool).Return(math.NewInt(9400), nil).Once() + + assetProfileKeeper.On("GetEntry", ctx, ptypes.BaseCurrency).Return(atypes.Entry{ + Denom: baseCurrency, + }, true) + + res, err := k.CloseEstimation(ctx, query) + assert.NoError(t, err) + + mockChecker.AssertExpectations(t) + assetProfileKeeper.AssertExpectations(t) + + assert.Equal(t, mtp.Position, res.Position) + assert.Equal(t, mtp.Custody, res.PositionSize.Amount) + assert.Equal(t, mtp.Liabilities, res.Liabilities.Amount) + assert.Equal(t, sdk.ZeroDec(), res.PriceImpact) + assert.Equal(t, swapFee, res.SwapFee) + assert.Equal(t, sdk.NewCoin(mtp.CollateralAsset, sdk.NewInt(9400)), res.ReturnAmount) +} diff --git a/x/perpetual/keeper/query_params_test.go b/x/perpetual/keeper/query_params_test.go index 980ecc6ba..4670d063e 100644 --- a/x/perpetual/keeper/query_params_test.go +++ b/x/perpetual/keeper/query_params_test.go @@ -10,7 +10,7 @@ import ( ) func TestParamsQuery(t *testing.T) { - keeper, ctx := testkeeper.PerpetualKeeper(t) + keeper, ctx, _ := testkeeper.PerpetualKeeper(t) wctx := sdk.WrapSDKContext(ctx) params := types.DefaultParams() keeper.SetParams(ctx, ¶ms) diff --git a/x/perpetual/keeper/repay.go b/x/perpetual/keeper/repay.go index 1422bdcc1..9ece19ade 100644 --- a/x/perpetual/keeper/repay.go +++ b/x/perpetual/keeper/repay.go @@ -1,150 +1,30 @@ package keeper import ( - "fmt" - "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" ammtypes "github.com/elys-network/elys/x/amm/types" "github.com/elys-network/elys/x/perpetual/types" ) -func (k Keeper) Repay(ctx sdk.Context, mtp *types.MTP, pool *types.Pool, ammPool ammtypes.Pool, repayAmount math.Int, takeFundPayment bool, amount math.Int, baseCurrency string) error { - // nolint:staticcheck,ineffassign - returnAmount := sdk.ZeroInt() - Liabilities := mtp.Liabilities - BorrowInterestUnpaid := mtp.BorrowInterestUnpaidCollateral - - if mtp.BorrowInterestUnpaidCollateral.IsPositive() { - if mtp.Position == types.Position_SHORT { - // swap to trading asset - unpaidCollateralIn := sdk.NewCoin(mtp.CollateralAsset, mtp.BorrowInterestUnpaidCollateral) - C, err := k.EstimateSwapGivenOut(ctx, unpaidCollateralIn, mtp.TradingAsset, ammPool) - if err != nil { - return err - } - - BorrowInterestUnpaid = C - } else if mtp.CollateralAsset != baseCurrency { - // swap to base currency - unpaidCollateralIn := sdk.NewCoin(mtp.CollateralAsset, mtp.BorrowInterestUnpaidCollateral) - C, err := k.EstimateSwapGivenOut(ctx, unpaidCollateralIn, baseCurrency, ammPool) - if err != nil { - return err - } - - BorrowInterestUnpaid = C - } - } - - var err error - mtp.MtpHealth, err = k.GetMTPHealth(ctx, *mtp, ammPool, baseCurrency) - if err != nil { - return err - } - - // Reminder: - // if long both repay amount and liablities are collateral asset - // if short both repay amount and liablities are trading asset - - have := repayAmount - owe := Liabilities.Add(BorrowInterestUnpaid).Mul(amount.Quo(mtp.Custody)) - - if have.LT(owe) { - // v principle liability; x excess liability - returnAmount = sdk.ZeroInt() - } else { - // can afford both - returnAmount = have.Sub(owe) - mtp.Liabilities = mtp.Liabilities.Sub(Liabilities.Mul(amount).Quo(mtp.Custody)) - } - +func (k Keeper) Repay(ctx sdk.Context, mtp *types.MTP, pool *types.Pool, ammPool ammtypes.Pool, returnAmount math.Int, amount math.Int) (err error) { if returnAmount.IsPositive() { - actualReturnAmount := returnAmount - if takeFundPayment { - takePercentage := k.GetForceCloseFundPercentage(ctx) - - fundAddr := k.GetForceCloseFundAddress(ctx) - takeAmount := sdk.ZeroInt() - if mtp.Position == types.Position_LONG { - takeAmount, err = k.TakeFundPayment(ctx, returnAmount, baseCurrency, takePercentage, fundAddr, &ammPool) - if err != nil { - return err - } - } else if mtp.Position == types.Position_SHORT { - takeAmount, err = k.TakeFundPayment(ctx, returnAmount, mtp.TradingAsset, takePercentage, fundAddr, &ammPool) - if err != nil { - return err - } - } - actualReturnAmount = returnAmount.Sub(takeAmount) - if !takeAmount.IsZero() { - k.EmitFundPayment(ctx, mtp, takeAmount, baseCurrency, types.EventRepayFund) - } - } - - // actualReturnAmount is so far in base currency if long or trading asset if short, now should convert it to collateralAsset in order to return - if actualReturnAmount.IsPositive() { - if mtp.Position == types.Position_SHORT { - // swap to collateral asset - amtTokenIn := sdk.NewCoin(mtp.TradingAsset, actualReturnAmount) - C, err := k.EstimateSwapGivenOut(ctx, amtTokenIn, mtp.CollateralAsset, ammPool) - if err != nil { - return err - } - - actualReturnAmount = C - } else if mtp.CollateralAsset != baseCurrency { - // swap to collateral asset - amtTokenIn := sdk.NewCoin(baseCurrency, actualReturnAmount) - C, err := k.EstimateSwapGivenOut(ctx, amtTokenIn, mtp.CollateralAsset, ammPool) - if err != nil { - return err - } - - actualReturnAmount = C - } - - returnCoin := sdk.NewCoin(mtp.CollateralAsset, sdk.NewIntFromBigInt(actualReturnAmount.BigInt())) - returnCoins := sdk.NewCoins(returnCoin) - addr, err := sdk.AccAddressFromBech32(mtp.Address) - if err != nil { - return err - } - - ammPoolAddr, err := sdk.AccAddressFromBech32(ammPool.Address) - if err != nil { - return err - } - - err = k.bankKeeper.SendCoins(ctx, ammPoolAddr, addr, returnCoins) - if err != nil { - return err - } + returnCoin := sdk.NewCoin(mtp.CollateralAsset, sdk.NewIntFromBigInt(returnAmount.BigInt())) + returnCoins := sdk.NewCoins(returnCoin) + addr, err := sdk.AccAddressFromBech32(mtp.Address) + if err != nil { + return err } - } - // before updating collateral asset balance, we should convert returnAmount to collateralAsset - // because so far returnAmount is in base currency. - if mtp.Position == types.Position_SHORT { - // swap to collateral asset - fmt.Print("returnAmount: ", returnAmount, "\n") - amtTokenIn := sdk.NewCoin(mtp.TradingAsset, returnAmount) - C, err := k.EstimateSwapGivenOut(ctx, amtTokenIn, mtp.CollateralAsset, ammPool) + ammPoolAddr, err := sdk.AccAddressFromBech32(ammPool.Address) if err != nil { return err } - returnAmount = C - } else if mtp.CollateralAsset != baseCurrency { - // swap to collateral asset - amtTokenIn := sdk.NewCoin(baseCurrency, returnAmount) - C, err := k.EstimateSwapGivenOut(ctx, amtTokenIn, mtp.CollateralAsset, ammPool) + err = k.bankKeeper.SendCoins(ctx, ammPoolAddr, addr, returnCoins) if err != nil { return err } - - returnAmount = C } err = pool.UpdateBalance(ctx, mtp.CollateralAsset, returnAmount, false, mtp.Position) diff --git a/x/perpetual/types/expected_keepers.go b/x/perpetual/types/expected_keepers.go index 63b08b0ea..b4496e88e 100644 --- a/x/perpetual/types/expected_keepers.go +++ b/x/perpetual/types/expected_keepers.go @@ -109,6 +109,21 @@ type CloseShortChecker interface { EstimateAndRepay(ctx sdk.Context, mtp MTP, pool Pool, ammPool ammtypes.Pool, amount math.Int, baseCurrency string) (math.Int, error) } +//go:generate mockery --srcpkg . --name CloseEstimationChecker --structname CloseEstimationChecker --filename close_estimation_checker.go --with-expecter +type CloseEstimationChecker interface { + GetMTP(ctx sdk.Context, mtpAddress sdk.AccAddress, id uint64) (MTP, error) + GetPool( + ctx sdk.Context, + poolId uint64, + ) (val Pool, found bool) + GetAmmPool(ctx sdk.Context, poolId uint64, tradingAsset string) (ammtypes.Pool, error) + SettleBorrowInterest(ctx sdk.Context, mtp *MTP, pool *Pool, ammPool ammtypes.Pool) (math.Int, error) + TakeOutCustody(ctx sdk.Context, mtp MTP, pool *Pool, amount math.Int) error + EstimateAndRepay(ctx sdk.Context, mtp MTP, pool Pool, ammPool ammtypes.Pool, amount math.Int, baseCurrency string) (math.Int, error) + EstimateSwap(ctx sdk.Context, leveragedAmtTokenIn sdk.Coin, borrowAsset string, ammPool ammtypes.Pool) (math.Int, error) + EstimateSwapGivenOut(ctx sdk.Context, tokenOutAmount sdk.Coin, tokenInDenom string, ammPool ammtypes.Pool) (math.Int, error) +} + // AccountKeeper defines the expected account keeper used for simulations (noalias) // //go:generate mockery --srcpkg . --name AccountKeeper --structname AccountKeeper --filename account_keeper.go --with-expecter diff --git a/x/perpetual/types/message_update_take_profit_price.go b/x/perpetual/types/message_update_take_profit_price.go index c7673dfb5..6cf033a23 100644 --- a/x/perpetual/types/message_update_take_profit_price.go +++ b/x/perpetual/types/message_update_take_profit_price.go @@ -7,15 +7,15 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -const TypeMsgUpdateTakeProfitPrice= "update_take_profit_price" +const TypeMsgUpdateTakeProfitPrice = "update_take_profit_price" var _ sdk.Msg = &MsgUpdateTakeProfitPrice{} func NewMsgUpdateTakeProfitPrice(creator string, id uint64, price sdk.Dec) *MsgUpdateTakeProfitPrice { return &MsgUpdateTakeProfitPrice{ - Creator: creator, - Id: id, - Price: price, + Creator: creator, + Id: id, + Price: price, } } @@ -50,4 +50,4 @@ func (msg *MsgUpdateTakeProfitPrice) ValidateBasic() error { return fmt.Errorf("take profit price cannot be negative") } return nil -} \ No newline at end of file +} diff --git a/x/perpetual/types/mocks/close_estimation_checker.go b/x/perpetual/types/mocks/close_estimation_checker.go new file mode 100644 index 000000000..f724c121d --- /dev/null +++ b/x/perpetual/types/mocks/close_estimation_checker.go @@ -0,0 +1,501 @@ +// Code generated by mockery v2.46.1. DO NOT EDIT. + +package mocks + +import ( + math "cosmossdk.io/math" + ammtypes "github.com/elys-network/elys/x/amm/types" + + mock "github.com/stretchr/testify/mock" + + perpetualtypes "github.com/elys-network/elys/x/perpetual/types" + + types "github.com/cosmos/cosmos-sdk/types" +) + +// CloseEstimationChecker is an autogenerated mock type for the CloseEstimationChecker type +type CloseEstimationChecker struct { + mock.Mock +} + +type CloseEstimationChecker_Expecter struct { + mock *mock.Mock +} + +func (_m *CloseEstimationChecker) EXPECT() *CloseEstimationChecker_Expecter { + return &CloseEstimationChecker_Expecter{mock: &_m.Mock} +} + +// EstimateAndRepay provides a mock function with given fields: ctx, mtp, pool, ammPool, amount, baseCurrency +func (_m *CloseEstimationChecker) EstimateAndRepay(ctx types.Context, mtp perpetualtypes.MTP, pool perpetualtypes.Pool, ammPool ammtypes.Pool, amount math.Int, baseCurrency string) (math.Int, error) { + ret := _m.Called(ctx, mtp, pool, ammPool, amount, baseCurrency) + + if len(ret) == 0 { + panic("no return value specified for EstimateAndRepay") + } + + var r0 math.Int + var r1 error + if rf, ok := ret.Get(0).(func(types.Context, perpetualtypes.MTP, perpetualtypes.Pool, ammtypes.Pool, math.Int, string) (math.Int, error)); ok { + return rf(ctx, mtp, pool, ammPool, amount, baseCurrency) + } + if rf, ok := ret.Get(0).(func(types.Context, perpetualtypes.MTP, perpetualtypes.Pool, ammtypes.Pool, math.Int, string) math.Int); ok { + r0 = rf(ctx, mtp, pool, ammPool, amount, baseCurrency) + } else { + r0 = ret.Get(0).(math.Int) + } + + if rf, ok := ret.Get(1).(func(types.Context, perpetualtypes.MTP, perpetualtypes.Pool, ammtypes.Pool, math.Int, string) error); ok { + r1 = rf(ctx, mtp, pool, ammPool, amount, baseCurrency) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CloseEstimationChecker_EstimateAndRepay_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EstimateAndRepay' +type CloseEstimationChecker_EstimateAndRepay_Call struct { + *mock.Call +} + +// EstimateAndRepay is a helper method to define mock.On call +// - ctx types.Context +// - mtp perpetualtypes.MTP +// - pool perpetualtypes.Pool +// - ammPool ammtypes.Pool +// - amount math.Int +// - baseCurrency string +func (_e *CloseEstimationChecker_Expecter) EstimateAndRepay(ctx interface{}, mtp interface{}, pool interface{}, ammPool interface{}, amount interface{}, baseCurrency interface{}) *CloseEstimationChecker_EstimateAndRepay_Call { + return &CloseEstimationChecker_EstimateAndRepay_Call{Call: _e.mock.On("EstimateAndRepay", ctx, mtp, pool, ammPool, amount, baseCurrency)} +} + +func (_c *CloseEstimationChecker_EstimateAndRepay_Call) Run(run func(ctx types.Context, mtp perpetualtypes.MTP, pool perpetualtypes.Pool, ammPool ammtypes.Pool, amount math.Int, baseCurrency string)) *CloseEstimationChecker_EstimateAndRepay_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(types.Context), args[1].(perpetualtypes.MTP), args[2].(perpetualtypes.Pool), args[3].(ammtypes.Pool), args[4].(math.Int), args[5].(string)) + }) + return _c +} + +func (_c *CloseEstimationChecker_EstimateAndRepay_Call) Return(_a0 math.Int, _a1 error) *CloseEstimationChecker_EstimateAndRepay_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CloseEstimationChecker_EstimateAndRepay_Call) RunAndReturn(run func(types.Context, perpetualtypes.MTP, perpetualtypes.Pool, ammtypes.Pool, math.Int, string) (math.Int, error)) *CloseEstimationChecker_EstimateAndRepay_Call { + _c.Call.Return(run) + return _c +} + +// EstimateSwap provides a mock function with given fields: ctx, leveragedAmtTokenIn, borrowAsset, ammPool +func (_m *CloseEstimationChecker) EstimateSwap(ctx types.Context, leveragedAmtTokenIn types.Coin, borrowAsset string, ammPool ammtypes.Pool) (math.Int, error) { + ret := _m.Called(ctx, leveragedAmtTokenIn, borrowAsset, ammPool) + + if len(ret) == 0 { + panic("no return value specified for EstimateSwap") + } + + var r0 math.Int + var r1 error + if rf, ok := ret.Get(0).(func(types.Context, types.Coin, string, ammtypes.Pool) (math.Int, error)); ok { + return rf(ctx, leveragedAmtTokenIn, borrowAsset, ammPool) + } + if rf, ok := ret.Get(0).(func(types.Context, types.Coin, string, ammtypes.Pool) math.Int); ok { + r0 = rf(ctx, leveragedAmtTokenIn, borrowAsset, ammPool) + } else { + r0 = ret.Get(0).(math.Int) + } + + if rf, ok := ret.Get(1).(func(types.Context, types.Coin, string, ammtypes.Pool) error); ok { + r1 = rf(ctx, leveragedAmtTokenIn, borrowAsset, ammPool) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CloseEstimationChecker_EstimateSwap_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EstimateSwap' +type CloseEstimationChecker_EstimateSwap_Call struct { + *mock.Call +} + +// EstimateSwap is a helper method to define mock.On call +// - ctx types.Context +// - leveragedAmtTokenIn types.Coin +// - borrowAsset string +// - ammPool ammtypes.Pool +func (_e *CloseEstimationChecker_Expecter) EstimateSwap(ctx interface{}, leveragedAmtTokenIn interface{}, borrowAsset interface{}, ammPool interface{}) *CloseEstimationChecker_EstimateSwap_Call { + return &CloseEstimationChecker_EstimateSwap_Call{Call: _e.mock.On("EstimateSwap", ctx, leveragedAmtTokenIn, borrowAsset, ammPool)} +} + +func (_c *CloseEstimationChecker_EstimateSwap_Call) Run(run func(ctx types.Context, leveragedAmtTokenIn types.Coin, borrowAsset string, ammPool ammtypes.Pool)) *CloseEstimationChecker_EstimateSwap_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(types.Context), args[1].(types.Coin), args[2].(string), args[3].(ammtypes.Pool)) + }) + return _c +} + +func (_c *CloseEstimationChecker_EstimateSwap_Call) Return(_a0 math.Int, _a1 error) *CloseEstimationChecker_EstimateSwap_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CloseEstimationChecker_EstimateSwap_Call) RunAndReturn(run func(types.Context, types.Coin, string, ammtypes.Pool) (math.Int, error)) *CloseEstimationChecker_EstimateSwap_Call { + _c.Call.Return(run) + return _c +} + +// EstimateSwapGivenOut provides a mock function with given fields: ctx, tokenOutAmount, tokenInDenom, ammPool +func (_m *CloseEstimationChecker) EstimateSwapGivenOut(ctx types.Context, tokenOutAmount types.Coin, tokenInDenom string, ammPool ammtypes.Pool) (math.Int, error) { + ret := _m.Called(ctx, tokenOutAmount, tokenInDenom, ammPool) + + if len(ret) == 0 { + panic("no return value specified for EstimateSwapGivenOut") + } + + var r0 math.Int + var r1 error + if rf, ok := ret.Get(0).(func(types.Context, types.Coin, string, ammtypes.Pool) (math.Int, error)); ok { + return rf(ctx, tokenOutAmount, tokenInDenom, ammPool) + } + if rf, ok := ret.Get(0).(func(types.Context, types.Coin, string, ammtypes.Pool) math.Int); ok { + r0 = rf(ctx, tokenOutAmount, tokenInDenom, ammPool) + } else { + r0 = ret.Get(0).(math.Int) + } + + if rf, ok := ret.Get(1).(func(types.Context, types.Coin, string, ammtypes.Pool) error); ok { + r1 = rf(ctx, tokenOutAmount, tokenInDenom, ammPool) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CloseEstimationChecker_EstimateSwapGivenOut_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EstimateSwapGivenOut' +type CloseEstimationChecker_EstimateSwapGivenOut_Call struct { + *mock.Call +} + +// EstimateSwapGivenOut is a helper method to define mock.On call +// - ctx types.Context +// - tokenOutAmount types.Coin +// - tokenInDenom string +// - ammPool ammtypes.Pool +func (_e *CloseEstimationChecker_Expecter) EstimateSwapGivenOut(ctx interface{}, tokenOutAmount interface{}, tokenInDenom interface{}, ammPool interface{}) *CloseEstimationChecker_EstimateSwapGivenOut_Call { + return &CloseEstimationChecker_EstimateSwapGivenOut_Call{Call: _e.mock.On("EstimateSwapGivenOut", ctx, tokenOutAmount, tokenInDenom, ammPool)} +} + +func (_c *CloseEstimationChecker_EstimateSwapGivenOut_Call) Run(run func(ctx types.Context, tokenOutAmount types.Coin, tokenInDenom string, ammPool ammtypes.Pool)) *CloseEstimationChecker_EstimateSwapGivenOut_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(types.Context), args[1].(types.Coin), args[2].(string), args[3].(ammtypes.Pool)) + }) + return _c +} + +func (_c *CloseEstimationChecker_EstimateSwapGivenOut_Call) Return(_a0 math.Int, _a1 error) *CloseEstimationChecker_EstimateSwapGivenOut_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CloseEstimationChecker_EstimateSwapGivenOut_Call) RunAndReturn(run func(types.Context, types.Coin, string, ammtypes.Pool) (math.Int, error)) *CloseEstimationChecker_EstimateSwapGivenOut_Call { + _c.Call.Return(run) + return _c +} + +// GetAmmPool provides a mock function with given fields: ctx, poolId, tradingAsset +func (_m *CloseEstimationChecker) GetAmmPool(ctx types.Context, poolId uint64, tradingAsset string) (ammtypes.Pool, error) { + ret := _m.Called(ctx, poolId, tradingAsset) + + if len(ret) == 0 { + panic("no return value specified for GetAmmPool") + } + + var r0 ammtypes.Pool + var r1 error + if rf, ok := ret.Get(0).(func(types.Context, uint64, string) (ammtypes.Pool, error)); ok { + return rf(ctx, poolId, tradingAsset) + } + if rf, ok := ret.Get(0).(func(types.Context, uint64, string) ammtypes.Pool); ok { + r0 = rf(ctx, poolId, tradingAsset) + } else { + r0 = ret.Get(0).(ammtypes.Pool) + } + + if rf, ok := ret.Get(1).(func(types.Context, uint64, string) error); ok { + r1 = rf(ctx, poolId, tradingAsset) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CloseEstimationChecker_GetAmmPool_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetAmmPool' +type CloseEstimationChecker_GetAmmPool_Call struct { + *mock.Call +} + +// GetAmmPool is a helper method to define mock.On call +// - ctx types.Context +// - poolId uint64 +// - tradingAsset string +func (_e *CloseEstimationChecker_Expecter) GetAmmPool(ctx interface{}, poolId interface{}, tradingAsset interface{}) *CloseEstimationChecker_GetAmmPool_Call { + return &CloseEstimationChecker_GetAmmPool_Call{Call: _e.mock.On("GetAmmPool", ctx, poolId, tradingAsset)} +} + +func (_c *CloseEstimationChecker_GetAmmPool_Call) Run(run func(ctx types.Context, poolId uint64, tradingAsset string)) *CloseEstimationChecker_GetAmmPool_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(types.Context), args[1].(uint64), args[2].(string)) + }) + return _c +} + +func (_c *CloseEstimationChecker_GetAmmPool_Call) Return(_a0 ammtypes.Pool, _a1 error) *CloseEstimationChecker_GetAmmPool_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CloseEstimationChecker_GetAmmPool_Call) RunAndReturn(run func(types.Context, uint64, string) (ammtypes.Pool, error)) *CloseEstimationChecker_GetAmmPool_Call { + _c.Call.Return(run) + return _c +} + +// GetMTP provides a mock function with given fields: ctx, mtpAddress, id +func (_m *CloseEstimationChecker) GetMTP(ctx types.Context, mtpAddress types.AccAddress, id uint64) (perpetualtypes.MTP, error) { + ret := _m.Called(ctx, mtpAddress, id) + + if len(ret) == 0 { + panic("no return value specified for GetMTP") + } + + var r0 perpetualtypes.MTP + var r1 error + if rf, ok := ret.Get(0).(func(types.Context, types.AccAddress, uint64) (perpetualtypes.MTP, error)); ok { + return rf(ctx, mtpAddress, id) + } + if rf, ok := ret.Get(0).(func(types.Context, types.AccAddress, uint64) perpetualtypes.MTP); ok { + r0 = rf(ctx, mtpAddress, id) + } else { + r0 = ret.Get(0).(perpetualtypes.MTP) + } + + if rf, ok := ret.Get(1).(func(types.Context, types.AccAddress, uint64) error); ok { + r1 = rf(ctx, mtpAddress, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CloseEstimationChecker_GetMTP_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetMTP' +type CloseEstimationChecker_GetMTP_Call struct { + *mock.Call +} + +// GetMTP is a helper method to define mock.On call +// - ctx types.Context +// - mtpAddress types.AccAddress +// - id uint64 +func (_e *CloseEstimationChecker_Expecter) GetMTP(ctx interface{}, mtpAddress interface{}, id interface{}) *CloseEstimationChecker_GetMTP_Call { + return &CloseEstimationChecker_GetMTP_Call{Call: _e.mock.On("GetMTP", ctx, mtpAddress, id)} +} + +func (_c *CloseEstimationChecker_GetMTP_Call) Run(run func(ctx types.Context, mtpAddress types.AccAddress, id uint64)) *CloseEstimationChecker_GetMTP_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(types.Context), args[1].(types.AccAddress), args[2].(uint64)) + }) + return _c +} + +func (_c *CloseEstimationChecker_GetMTP_Call) Return(_a0 perpetualtypes.MTP, _a1 error) *CloseEstimationChecker_GetMTP_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CloseEstimationChecker_GetMTP_Call) RunAndReturn(run func(types.Context, types.AccAddress, uint64) (perpetualtypes.MTP, error)) *CloseEstimationChecker_GetMTP_Call { + _c.Call.Return(run) + return _c +} + +// GetPool provides a mock function with given fields: ctx, poolId +func (_m *CloseEstimationChecker) GetPool(ctx types.Context, poolId uint64) (perpetualtypes.Pool, bool) { + ret := _m.Called(ctx, poolId) + + if len(ret) == 0 { + panic("no return value specified for GetPool") + } + + var r0 perpetualtypes.Pool + var r1 bool + if rf, ok := ret.Get(0).(func(types.Context, uint64) (perpetualtypes.Pool, bool)); ok { + return rf(ctx, poolId) + } + if rf, ok := ret.Get(0).(func(types.Context, uint64) perpetualtypes.Pool); ok { + r0 = rf(ctx, poolId) + } else { + r0 = ret.Get(0).(perpetualtypes.Pool) + } + + if rf, ok := ret.Get(1).(func(types.Context, uint64) bool); ok { + r1 = rf(ctx, poolId) + } else { + r1 = ret.Get(1).(bool) + } + + return r0, r1 +} + +// CloseEstimationChecker_GetPool_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPool' +type CloseEstimationChecker_GetPool_Call struct { + *mock.Call +} + +// GetPool is a helper method to define mock.On call +// - ctx types.Context +// - poolId uint64 +func (_e *CloseEstimationChecker_Expecter) GetPool(ctx interface{}, poolId interface{}) *CloseEstimationChecker_GetPool_Call { + return &CloseEstimationChecker_GetPool_Call{Call: _e.mock.On("GetPool", ctx, poolId)} +} + +func (_c *CloseEstimationChecker_GetPool_Call) Run(run func(ctx types.Context, poolId uint64)) *CloseEstimationChecker_GetPool_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(types.Context), args[1].(uint64)) + }) + return _c +} + +func (_c *CloseEstimationChecker_GetPool_Call) Return(val perpetualtypes.Pool, found bool) *CloseEstimationChecker_GetPool_Call { + _c.Call.Return(val, found) + return _c +} + +func (_c *CloseEstimationChecker_GetPool_Call) RunAndReturn(run func(types.Context, uint64) (perpetualtypes.Pool, bool)) *CloseEstimationChecker_GetPool_Call { + _c.Call.Return(run) + return _c +} + +// SettleBorrowInterest provides a mock function with given fields: ctx, mtp, pool, ammPool +func (_m *CloseEstimationChecker) SettleBorrowInterest(ctx types.Context, mtp *perpetualtypes.MTP, pool *perpetualtypes.Pool, ammPool ammtypes.Pool) (math.Int, error) { + ret := _m.Called(ctx, mtp, pool, ammPool) + + if len(ret) == 0 { + panic("no return value specified for SettleBorrowInterest") + } + + var r0 math.Int + var r1 error + if rf, ok := ret.Get(0).(func(types.Context, *perpetualtypes.MTP, *perpetualtypes.Pool, ammtypes.Pool) (math.Int, error)); ok { + return rf(ctx, mtp, pool, ammPool) + } + if rf, ok := ret.Get(0).(func(types.Context, *perpetualtypes.MTP, *perpetualtypes.Pool, ammtypes.Pool) math.Int); ok { + r0 = rf(ctx, mtp, pool, ammPool) + } else { + r0 = ret.Get(0).(math.Int) + } + + if rf, ok := ret.Get(1).(func(types.Context, *perpetualtypes.MTP, *perpetualtypes.Pool, ammtypes.Pool) error); ok { + r1 = rf(ctx, mtp, pool, ammPool) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CloseEstimationChecker_SettleBorrowInterest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SettleBorrowInterest' +type CloseEstimationChecker_SettleBorrowInterest_Call struct { + *mock.Call +} + +// SettleBorrowInterest is a helper method to define mock.On call +// - ctx types.Context +// - mtp *perpetualtypes.MTP +// - pool *perpetualtypes.Pool +// - ammPool ammtypes.Pool +func (_e *CloseEstimationChecker_Expecter) SettleBorrowInterest(ctx interface{}, mtp interface{}, pool interface{}, ammPool interface{}) *CloseEstimationChecker_SettleBorrowInterest_Call { + return &CloseEstimationChecker_SettleBorrowInterest_Call{Call: _e.mock.On("SettleBorrowInterest", ctx, mtp, pool, ammPool)} +} + +func (_c *CloseEstimationChecker_SettleBorrowInterest_Call) Run(run func(ctx types.Context, mtp *perpetualtypes.MTP, pool *perpetualtypes.Pool, ammPool ammtypes.Pool)) *CloseEstimationChecker_SettleBorrowInterest_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(types.Context), args[1].(*perpetualtypes.MTP), args[2].(*perpetualtypes.Pool), args[3].(ammtypes.Pool)) + }) + return _c +} + +func (_c *CloseEstimationChecker_SettleBorrowInterest_Call) Return(_a0 math.Int, _a1 error) *CloseEstimationChecker_SettleBorrowInterest_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CloseEstimationChecker_SettleBorrowInterest_Call) RunAndReturn(run func(types.Context, *perpetualtypes.MTP, *perpetualtypes.Pool, ammtypes.Pool) (math.Int, error)) *CloseEstimationChecker_SettleBorrowInterest_Call { + _c.Call.Return(run) + return _c +} + +// TakeOutCustody provides a mock function with given fields: ctx, mtp, pool, amount +func (_m *CloseEstimationChecker) TakeOutCustody(ctx types.Context, mtp perpetualtypes.MTP, pool *perpetualtypes.Pool, amount math.Int) error { + ret := _m.Called(ctx, mtp, pool, amount) + + if len(ret) == 0 { + panic("no return value specified for TakeOutCustody") + } + + var r0 error + if rf, ok := ret.Get(0).(func(types.Context, perpetualtypes.MTP, *perpetualtypes.Pool, math.Int) error); ok { + r0 = rf(ctx, mtp, pool, amount) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// CloseEstimationChecker_TakeOutCustody_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TakeOutCustody' +type CloseEstimationChecker_TakeOutCustody_Call struct { + *mock.Call +} + +// TakeOutCustody is a helper method to define mock.On call +// - ctx types.Context +// - mtp perpetualtypes.MTP +// - pool *perpetualtypes.Pool +// - amount math.Int +func (_e *CloseEstimationChecker_Expecter) TakeOutCustody(ctx interface{}, mtp interface{}, pool interface{}, amount interface{}) *CloseEstimationChecker_TakeOutCustody_Call { + return &CloseEstimationChecker_TakeOutCustody_Call{Call: _e.mock.On("TakeOutCustody", ctx, mtp, pool, amount)} +} + +func (_c *CloseEstimationChecker_TakeOutCustody_Call) Run(run func(ctx types.Context, mtp perpetualtypes.MTP, pool *perpetualtypes.Pool, amount math.Int)) *CloseEstimationChecker_TakeOutCustody_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(types.Context), args[1].(perpetualtypes.MTP), args[2].(*perpetualtypes.Pool), args[3].(math.Int)) + }) + return _c +} + +func (_c *CloseEstimationChecker_TakeOutCustody_Call) Return(_a0 error) *CloseEstimationChecker_TakeOutCustody_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CloseEstimationChecker_TakeOutCustody_Call) RunAndReturn(run func(types.Context, perpetualtypes.MTP, *perpetualtypes.Pool, math.Int) error) *CloseEstimationChecker_TakeOutCustody_Call { + _c.Call.Return(run) + return _c +} + +// NewCloseEstimationChecker creates a new instance of CloseEstimationChecker. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewCloseEstimationChecker(t interface { + mock.TestingT + Cleanup(func()) +}) *CloseEstimationChecker { + mock := &CloseEstimationChecker{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/x/perpetual/types/query.pb.go b/x/perpetual/types/query.pb.go index 2e2744886..eff696685 100644 --- a/x/perpetual/types/query.pb.go +++ b/x/perpetual/types/query.pb.go @@ -1370,6 +1370,128 @@ func (m *PoolResponse) GetLastHeightBorrowInterestRateComputed() int64 { return 0 } +type QueryCloseEstimationRequest struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + PositionId uint64 `protobuf:"varint,2,opt,name=position_id,json=positionId,proto3" json:"position_id,omitempty"` +} + +func (m *QueryCloseEstimationRequest) Reset() { *m = QueryCloseEstimationRequest{} } +func (m *QueryCloseEstimationRequest) String() string { return proto.CompactTextString(m) } +func (*QueryCloseEstimationRequest) ProtoMessage() {} +func (*QueryCloseEstimationRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_9a2c961615c1b7fe, []int{26} +} +func (m *QueryCloseEstimationRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCloseEstimationRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCloseEstimationRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryCloseEstimationRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCloseEstimationRequest.Merge(m, src) +} +func (m *QueryCloseEstimationRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryCloseEstimationRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCloseEstimationRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCloseEstimationRequest proto.InternalMessageInfo + +func (m *QueryCloseEstimationRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *QueryCloseEstimationRequest) GetPositionId() uint64 { + if m != nil { + return m.PositionId + } + return 0 +} + +type QueryCloseEstimationResponse struct { + Position Position `protobuf:"varint,1,opt,name=position,proto3,enum=elys.perpetual.Position" json:"position,omitempty"` + PositionSize types.Coin `protobuf:"bytes,2,opt,name=position_size,json=positionSize,proto3" json:"position_size"` + Liabilities types.Coin `protobuf:"bytes,3,opt,name=liabilities,proto3" json:"liabilities"` + PriceImpact github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=price_impact,json=priceImpact,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"price_impact"` + SwapFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=swap_fee,json=swapFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_fee"` + ReturnAmount types.Coin `protobuf:"bytes,6,opt,name=return_amount,json=returnAmount,proto3" json:"return_amount"` +} + +func (m *QueryCloseEstimationResponse) Reset() { *m = QueryCloseEstimationResponse{} } +func (m *QueryCloseEstimationResponse) String() string { return proto.CompactTextString(m) } +func (*QueryCloseEstimationResponse) ProtoMessage() {} +func (*QueryCloseEstimationResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9a2c961615c1b7fe, []int{27} +} +func (m *QueryCloseEstimationResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCloseEstimationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCloseEstimationResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryCloseEstimationResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCloseEstimationResponse.Merge(m, src) +} +func (m *QueryCloseEstimationResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryCloseEstimationResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCloseEstimationResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCloseEstimationResponse proto.InternalMessageInfo + +func (m *QueryCloseEstimationResponse) GetPosition() Position { + if m != nil { + return m.Position + } + return Position_UNSPECIFIED +} + +func (m *QueryCloseEstimationResponse) GetPositionSize() types.Coin { + if m != nil { + return m.PositionSize + } + return types.Coin{} +} + +func (m *QueryCloseEstimationResponse) GetLiabilities() types.Coin { + if m != nil { + return m.Liabilities + } + return types.Coin{} +} + +func (m *QueryCloseEstimationResponse) GetReturnAmount() types.Coin { + if m != nil { + return m.ReturnAmount + } + return types.Coin{} +} + func init() { proto.RegisterType((*MtpAndPrice)(nil), "elys.perpetual.MtpAndPrice") proto.RegisterType((*ParamsRequest)(nil), "elys.perpetual.ParamsRequest") @@ -1397,128 +1519,138 @@ func init() { proto.RegisterType((*QueryGetAllToPayRequest)(nil), "elys.perpetual.QueryGetAllToPayRequest") proto.RegisterType((*QueryGetAllToPayResponse)(nil), "elys.perpetual.QueryGetAllToPayResponse") proto.RegisterType((*PoolResponse)(nil), "elys.perpetual.PoolResponse") + proto.RegisterType((*QueryCloseEstimationRequest)(nil), "elys.perpetual.QueryCloseEstimationRequest") + proto.RegisterType((*QueryCloseEstimationResponse)(nil), "elys.perpetual.QueryCloseEstimationResponse") } func init() { proto.RegisterFile("elys/perpetual/query.proto", fileDescriptor_9a2c961615c1b7fe) } var fileDescriptor_9a2c961615c1b7fe = []byte{ - // 1850 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x59, 0xdd, 0x6f, 0x1c, 0x57, - 0x15, 0xcf, 0xf8, 0x2b, 0xde, 0xe3, 0xf5, 0xda, 0x7b, 0xed, 0xa4, 0x9b, 0x75, 0xd8, 0x86, 0xc9, - 0x67, 0xeb, 0xec, 0x2e, 0x71, 0xa3, 0x56, 0x20, 0x44, 0x6b, 0x27, 0x38, 0x71, 0xa9, 0x61, 0x3b, - 0x89, 0x14, 0x64, 0x04, 0xc3, 0xf5, 0xce, 0xf5, 0xfa, 0x2a, 0x33, 0x73, 0x27, 0x33, 0x77, 0xe3, - 0x6e, 0x22, 0x23, 0x04, 0xbc, 0x82, 0x40, 0x05, 0xf5, 0x91, 0x77, 0xc4, 0x3b, 0x7f, 0x00, 0x2f, - 0x7d, 0xac, 0x40, 0x42, 0x88, 0x87, 0x0a, 0x25, 0xfc, 0x21, 0xe8, 0x7e, 0xcc, 0x7a, 0x76, 0x67, - 0xbf, 0x32, 0xb5, 0x94, 0x87, 0x3e, 0xd9, 0x33, 0xf7, 0x9c, 0xdf, 0xf9, 0xdd, 0xf3, 0x71, 0xef, - 0x99, 0xb3, 0x50, 0x26, 0x6e, 0x27, 0xaa, 0x07, 0x24, 0x0c, 0x08, 0x6f, 0x63, 0xb7, 0xfe, 0xa4, - 0x4d, 0xc2, 0x4e, 0x2d, 0x08, 0x19, 0x67, 0xa8, 0x20, 0xd6, 0x6a, 0xdd, 0xb5, 0xf2, 0x6a, 0x8b, - 0xb5, 0x98, 0x5c, 0xaa, 0x8b, 0xff, 0x94, 0x54, 0xf9, 0x62, 0x8b, 0xb1, 0x96, 0x4b, 0xea, 0x38, - 0xa0, 0x75, 0xec, 0xfb, 0x8c, 0x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, - 0xe5, 0xcc, 0x17, 0x2f, 0x2b, 0x67, 0xfe, 0xfd, 0xb2, 0x72, 0x66, 0xaf, 0x96, 0xb8, 0x58, 0xd3, - 0x80, 0x9f, 0xf4, 0xff, 0x7c, 0xb5, 0x3f, 0x27, 0x7f, 0x84, 0x7a, 0xe7, 0xff, 0x01, 0x00, 0x00, - 0xff, 0xff, 0x0e, 0x7c, 0xfe, 0x94, 0x86, 0x1b, 0x00, 0x00, + // 1976 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x59, 0xcd, 0x6f, 0x1b, 0xc7, + 0x15, 0xf7, 0xea, 0xcb, 0xe2, 0xa3, 0x44, 0x8a, 0x23, 0xd9, 0xa1, 0x29, 0x97, 0x76, 0xd7, 0x9f, + 0x89, 0x4c, 0xb2, 0x56, 0x8c, 0x04, 0xfd, 0x4c, 0x24, 0xb9, 0xb2, 0x95, 0x46, 0x2d, 0xb3, 0x36, + 0xe0, 0x40, 0x45, 0xbb, 0x1d, 0x72, 0x47, 0xd4, 0xc0, 0xcb, 0x9d, 0xf5, 0xee, 0xd0, 0x0a, 0x6d, + 0xa8, 0x28, 0x8a, 0x5e, 0x5b, 0xb4, 0x48, 0x8b, 0x1c, 0x7b, 0x2f, 0x7a, 0xe9, 0x29, 0xe7, 0xa2, + 0x97, 0x1c, 0x83, 0x16, 0x28, 0x8a, 0x1e, 0x82, 0xc2, 0xee, 0x1f, 0x52, 0xcc, 0xec, 0xec, 0x6a, + 0xc9, 0xe5, 0x97, 0x57, 0x02, 0x7c, 0xe8, 0x49, 0xe2, 0xcc, 0x7b, 0xbf, 0xf7, 0x9b, 0xf7, 0x31, + 0xf3, 0xf8, 0x08, 0x25, 0x62, 0x77, 0xfd, 0x9a, 0x4b, 0x3c, 0x97, 0xf0, 0x0e, 0xb6, 0x6b, 0x4f, + 0x3a, 0xc4, 0xeb, 0x56, 0x5d, 0x8f, 0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3, + 0xf5, 0xd8, 0x3e, 0x0d, 0x3b, 0xa6, 0xb9, 0x54, 0xa0, 0x79, 0x01, 0x54, 0x97, 0x38, 0x32, 0x66, + 0xfa, 0xdf, 0x17, 0x60, 0x75, 0x60, 0xb8, 0xa2, 0x56, 0xe7, 0xff, 0x23, 0x5e, 0x8f, 0x20, 0x4f, + 0x1d, 0x4e, 0x3c, 0xe2, 0x73, 0x13, 0xb7, 0x53, 0x86, 0x6d, 0xc7, 0xe1, 0x46, 0x2e, 0x84, 0xd9, + 0x90, 0x28, 0xe8, 0x2e, 0x2c, 0x86, 0x6e, 0x31, 0x7d, 0xfa, 0x2c, 0x08, 0xdc, 0x04, 0xe4, 0x16, + 0x42, 0xad, 0x07, 0xf4, 0x19, 0x41, 0x3b, 0x30, 0xef, 0x1f, 0x62, 0xd7, 0xdc, 0x27, 0xa4, 0x78, + 0x36, 0x95, 0x43, 0xcf, 0x0a, 0xfd, 0x6d, 0x42, 0x7a, 0x32, 0x73, 0xfe, 0x84, 0x99, 0xb9, 0x0b, + 0x20, 0x5b, 0x95, 0x20, 0x25, 0x33, 0xa9, 0xd0, 0x32, 0x02, 0x21, 0x68, 0xde, 0x07, 0x26, 0x3a, + 0x9c, 0x4a, 0xa2, 0xa3, 0x1f, 0x43, 0xc1, 0xa6, 0x4f, 0x3a, 0xd4, 0x92, 0xf9, 0xad, 0xb0, 0xb3, + 0xa9, 0xb0, 0x97, 0x62, 0x40, 0x01, 0xf8, 0x03, 0x58, 0x24, 0x41, 0xed, 0x10, 0xcb, 0x14, 0xdf, + 0x3f, 0x16, 0x52, 0xe5, 0xce, 0x42, 0x04, 0x52, 0x77, 0x6c, 0x54, 0x85, 0xe5, 0x1e, 0x50, 0xd3, + 0x22, 0x0e, 0x6b, 0x17, 0x17, 0x65, 0xfa, 0x17, 0xe2, 0xa2, 0x77, 0xc5, 0x06, 0xaa, 0xc3, 0x32, + 0x7e, 0x8a, 0xa9, 0x8d, 0x1b, 0x36, 0x31, 0x03, 0x8a, 0x94, 0x77, 0x8b, 0xb9, 0xc9, 0xf2, 0x0d, + 0x45, 0xba, 0x1f, 0x86, 0xaa, 0x22, 0x55, 0x7c, 0x9b, 0xba, 0xae, 0x28, 0xe3, 0x7c, 0xba, 0x54, + 0x09, 0xf5, 0xd1, 0xcf, 0x60, 0xe5, 0x90, 0xd0, 0xd6, 0x01, 0x37, 0x1b, 0xd8, 0xc6, 0x4e, 0x93, + 0x98, 0x9e, 0x70, 0x60, 0x71, 0x29, 0x15, 0x2e, 0x0a, 0xb0, 0x36, 0x03, 0x28, 0x43, 0x20, 0x09, + 0x0b, 0x0d, 0xe6, 0x79, 0xec, 0xd0, 0x8c, 0x2a, 0xd9, 0xc3, 0x9c, 0x14, 0x0b, 0xe9, 0x2c, 0x04, + 0x58, 0x3b, 0x0a, 0xca, 0xc0, 0x9c, 0xa0, 0x8f, 0x60, 0x61, 0xbf, 0xe3, 0xc8, 0xab, 0x48, 0x22, + 0xa3, 0x54, 0xc8, 0x59, 0x85, 0x11, 0x42, 0xca, 0x54, 0x34, 0x69, 0xdb, 0xc5, 0x4d, 0x5e, 0x5c, + 0x4e, 0x07, 0x29, 0x31, 0x76, 0x24, 0x04, 0xfa, 0x1e, 0x80, 0xf2, 0x83, 0xb8, 0x2d, 0x56, 0x26, + 0x0b, 0x7f, 0x26, 0x50, 0x11, 0x17, 0xc4, 0xfb, 0x10, 0x32, 0x94, 0x00, 0xe7, 0x26, 0xbc, 0x4c, + 0x95, 0xce, 0x36, 0x21, 0xfa, 0x05, 0x78, 0x23, 0x6c, 0xe1, 0x36, 0x6c, 0xfb, 0x21, 0xab, 0xe3, + 0x6e, 0xf8, 0x75, 0xe7, 0x3e, 0x14, 0x93, 0x5b, 0xea, 0xad, 0xb9, 0x05, 0x73, 0x9c, 0x99, 0x2e, + 0xee, 0xaa, 0x9e, 0xe9, 0x5c, 0xff, 0x4b, 0x13, 0x88, 0xcf, 0x72, 0xf1, 0x47, 0xff, 0xd3, 0x2c, + 0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x88, 0xba, 0x74, 0x08, 0x97, 0x76, 0x2c, 0xfd, 0xaf, 0xd3, 0x70, + 0x71, 0x30, 0xf4, 0x89, 0x3a, 0xb8, 0x44, 0xdb, 0x32, 0x95, 0xa6, 0x6d, 0xd9, 0x80, 0xac, 0x4d, + 0x71, 0x83, 0xda, 0x94, 0x53, 0xe2, 0xcb, 0x72, 0x99, 0x00, 0x23, 0xae, 0x93, 0xb8, 0x20, 0x67, + 0x4e, 0x7e, 0x41, 0xc6, 0x9b, 0xa9, 0xd9, 0x93, 0x35, 0x53, 0x77, 0x61, 0xd1, 0x23, 0xbc, 0xe3, + 0x39, 0x61, 0xd3, 0x38, 0x69, 0x77, 0x17, 0x68, 0x05, 0x3d, 0xe2, 0xfa, 0xe7, 0x79, 0x98, 0x95, + 0x31, 0x44, 0x1c, 0xe6, 0x82, 0xd9, 0x21, 0xfa, 0xda, 0xe0, 0x99, 0xa2, 0xca, 0x98, 0x52, 0x79, + 0xd8, 0x76, 0x10, 0x75, 0x7d, 0xed, 0x97, 0xff, 0xf8, 0xef, 0xa7, 0x53, 0xd7, 0xd0, 0x95, 0x9a, + 0x90, 0xab, 0x38, 0x84, 0x1f, 0x32, 0xef, 0x71, 0x6d, 0xe0, 0xa0, 0x18, 0xfd, 0x5e, 0x83, 0x05, + 0xf9, 0x75, 0x5b, 0x0d, 0x68, 0xd0, 0xe5, 0x61, 0x19, 0x12, 0xd9, 0xff, 0xfa, 0x08, 0x09, 0x45, + 0xe1, 0x3d, 0x49, 0xe1, 0x9b, 0xe8, 0xdd, 0xd1, 0x14, 0x42, 0xbd, 0xda, 0xf3, 0xd8, 0x5c, 0xfb, + 0x31, 0xe9, 0x1e, 0xa1, 0xcf, 0x35, 0x40, 0x71, 0x5a, 0xc1, 0x10, 0x0f, 0x5d, 0x1f, 0x6a, 0xba, + 0x67, 0xd0, 0x58, 0xba, 0x31, 0x56, 0x4e, 0x11, 0xad, 0x4b, 0xa2, 0x1f, 0xa0, 0xfb, 0x23, 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 0xfe, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xb3, 0xb0, 0x41, 0x82, 0x58, 0x1e, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1557,6 +1689,8 @@ type QueryClient interface { OpenEstimation(ctx context.Context, in *QueryOpenEstimationRequest, opts ...grpc.CallOption) (*QueryOpenEstimationResponse, error) // Queries a list of GetAllToPay items. GetAllToPay(ctx context.Context, in *QueryGetAllToPayRequest, opts ...grpc.CallOption) (*QueryGetAllToPayResponse, error) + // Queries a list of CloseEstimation items. + CloseEstimation(ctx context.Context, in *QueryCloseEstimationRequest, opts ...grpc.CallOption) (*QueryCloseEstimationResponse, error) } type queryClient struct { @@ -1675,6 +1809,15 @@ func (c *queryClient) GetAllToPay(ctx context.Context, in *QueryGetAllToPayReque return out, nil } +func (c *queryClient) CloseEstimation(ctx context.Context, in *QueryCloseEstimationRequest, opts ...grpc.CallOption) (*QueryCloseEstimationResponse, error) { + out := new(QueryCloseEstimationResponse) + err := c.cc.Invoke(ctx, "/elys.perpetual.Query/CloseEstimation", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. @@ -1701,6 +1844,8 @@ type QueryServer interface { OpenEstimation(context.Context, *QueryOpenEstimationRequest) (*QueryOpenEstimationResponse, error) // Queries a list of GetAllToPay items. GetAllToPay(context.Context, *QueryGetAllToPayRequest) (*QueryGetAllToPayResponse, error) + // Queries a list of CloseEstimation items. + CloseEstimation(context.Context, *QueryCloseEstimationRequest) (*QueryCloseEstimationResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -1743,6 +1888,9 @@ func (*UnimplementedQueryServer) OpenEstimation(ctx context.Context, req *QueryO func (*UnimplementedQueryServer) GetAllToPay(ctx context.Context, req *QueryGetAllToPayRequest) (*QueryGetAllToPayResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetAllToPay not implemented") } +func (*UnimplementedQueryServer) CloseEstimation(ctx context.Context, req *QueryCloseEstimationRequest) (*QueryCloseEstimationResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CloseEstimation not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -1964,6 +2112,24 @@ func _Query_GetAllToPay_Handler(srv interface{}, ctx context.Context, dec func(i return interceptor(ctx, in, info, handler) } +func _Query_CloseEstimation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryCloseEstimationRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).CloseEstimation(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.perpetual.Query/CloseEstimation", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).CloseEstimation(ctx, req.(*QueryCloseEstimationRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "elys.perpetual.Query", HandlerType: (*QueryServer)(nil), @@ -2016,6 +2182,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "GetAllToPay", Handler: _Query_GetAllToPay_Handler, }, + { + MethodName: "CloseEstimation", + Handler: _Query_CloseEstimation_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "elys/perpetual/query.proto", @@ -3306,6 +3476,119 @@ func (m *PoolResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryCloseEstimationRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryCloseEstimationRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCloseEstimationRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PositionId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PositionId)) + i-- + dAtA[i] = 0x10 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryCloseEstimationResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryCloseEstimationResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCloseEstimationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.ReturnAmount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + { + size := m.SwapFee.Size() + i -= size + if _, err := m.SwapFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size := m.PriceImpact.Size() + i -= size + if _, err := m.PriceImpact.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size, err := m.Liabilities.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size, err := m.PositionSize.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.Position != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Position)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -3771,6 +4054,44 @@ func (m *PoolResponse) Size() (n int) { return n } +func (m *QueryCloseEstimationRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.PositionId != 0 { + n += 1 + sovQuery(uint64(m.PositionId)) + } + return n +} + +func (m *QueryCloseEstimationResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Position != 0 { + n += 1 + sovQuery(uint64(m.Position)) + } + l = m.PositionSize.Size() + n += 1 + l + sovQuery(uint64(l)) + l = m.Liabilities.Size() + n += 1 + l + sovQuery(uint64(l)) + l = m.PriceImpact.Size() + n += 1 + l + sovQuery(uint64(l)) + l = m.SwapFee.Size() + n += 1 + l + sovQuery(uint64(l)) + l = m.ReturnAmount.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -7246,6 +7567,343 @@ func (m *PoolResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryCloseEstimationRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryCloseEstimationRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCloseEstimationRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PositionId", wireType) + } + m.PositionId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PositionId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryCloseEstimationResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryCloseEstimationResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCloseEstimationResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Position", wireType) + } + m.Position = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Position |= Position(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PositionSize", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PositionSize.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Liabilities", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Liabilities.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PriceImpact", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PriceImpact.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SwapFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SwapFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ReturnAmount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ReturnAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/perpetual/types/query.pb.gw.go b/x/perpetual/types/query.pb.gw.go index b379fb690..34203e902 100644 --- a/x/perpetual/types/query.pb.gw.go +++ b/x/perpetual/types/query.pb.gw.go @@ -693,6 +693,78 @@ func local_request_Query_GetAllToPay_0(ctx context.Context, marshaler runtime.Ma } +var ( + filter_Query_CloseEstimation_0 = &utilities.DoubleArray{Encoding: map[string]int{"position_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_CloseEstimation_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCloseEstimationRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["position_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "position_id") + } + + protoReq.PositionId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "position_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_CloseEstimation_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CloseEstimation(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_CloseEstimation_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCloseEstimationRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["position_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "position_id") + } + + protoReq.PositionId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "position_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_CloseEstimation_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.CloseEstimation(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -975,6 +1047,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_CloseEstimation_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_CloseEstimation_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_CloseEstimation_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1256,6 +1351,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_CloseEstimation_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_CloseEstimation_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_CloseEstimation_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1283,6 +1398,8 @@ var ( pattern_Query_OpenEstimation_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"elys-network", "elys", "perpetual", "open-estimation"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_GetAllToPay_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"elys-network", "elys", "perpetual", "get_all_to_pay"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_CloseEstimation_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"elys-network", "elys", "perpetual", "close-estimation", "position_id"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -1309,4 +1426,6 @@ var ( forward_Query_OpenEstimation_0 = runtime.ForwardResponseMessage forward_Query_GetAllToPay_0 = runtime.ForwardResponseMessage + + forward_Query_CloseEstimation_0 = runtime.ForwardResponseMessage )