Skip to content

Commit

Permalink
fix: fees does not require additional funds (#1718)
Browse files Browse the repository at this point in the history
* remove unused param

* error rounding 1 cent

* fix more code

* add fee payment on close partially

* temp commit!

* last test upgrade

* Update changelog

* Update CHANGELOG.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* ci(codecov.yml): set fixed patch target

* ci: PR template too long

---------

Co-authored-by: Unique Divine <[email protected]>
Co-authored-by: Unique-Divine <[email protected]>
  • Loading branch information
3 people authored Dec 18, 2023
1 parent 8a3b7b8 commit 29e6900
Show file tree
Hide file tree
Showing 13 changed files with 372 additions and 432 deletions.
3 changes: 3 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ coverage:
threshold: 1% # Allow coverage to drop by X%, posting a success status.
# removed_code_behavior: Takes values [off, removals_only, adjust_base]
removed_code_behavior: adjust_base
patch:
default:
target: 70%

comment: # this is a top-level key
layout: " diff, flags, files"
Expand Down
11 changes: 6 additions & 5 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Description
# Purpose / Abstract

What does this PR do?

# Purpose
- Closes #AAA

Why is this PR important?
<!--
Why is this PR important?
What does this PR do?
-->
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#1632](https://github.com/NibiruChain/nibiru/pull/1632) - feat(perp): Add settle position transaction
* [#1573](https://github.com/NibiruChain/nibiru/pull/1573) - feat(perp): Close markets and compute settlement price
* [#1705](https://github.com/NibiruChain/nibiru/pull/1705) - feat(perp): Add oracle pair to market object
* [#1718](https://github.com/NibiruChain/nibiru/pull/1718) - fix: fees does not require additional funds

### Non-breaking/Compatible Improvements

Expand Down
94 changes: 48 additions & 46 deletions x/perp/v2/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,20 +244,20 @@ func (s *IntegrationTestSuite) TestMarketOrdersAndCloseCmd() {
ammMarketDuo, err = testutilcli.QueryMarketV2(val.ClientCtx, pair)
s.Require().NoError(err)
s.T().Logf("ammMarketDuo: %s", ammMarketDuo.String())
s.EqualValues(sdk.MustNewDecFromStr("9999666.677777407419752675"), ammMarketDuo.Amm.BaseReserve)
s.EqualValues(sdk.MustNewDecFromStr("10000333.333333333333333333"), ammMarketDuo.Amm.QuoteReserve)
s.EqualValues(sdk.MustNewDecFromStr("9999667.344399676304101617"), ammMarketDuo.Amm.BaseReserve)
s.EqualValues(sdk.MustNewDecFromStr("10000332.666666666666666667"), ammMarketDuo.Amm.QuoteReserve)

s.T().Log("B. check trader position")
queryResp, err := testutilcli.QueryPositionV2(val.ClientCtx, asset.Registry.Pair(denoms.BTC, denoms.NUSD), user)
s.NoError(err)
s.T().Logf("query response: %+v", queryResp)
s.EqualValues(user.String(), queryResp.Position.TraderAddress)
s.EqualValues(asset.Registry.Pair(denoms.BTC, denoms.NUSD), queryResp.Position.Pair)
s.EqualValues(sdk.MustNewDecFromStr("333.322222592580247325"), queryResp.Position.Size_)
s.EqualValues(sdk.NewDec(2*common.TO_MICRO), queryResp.Position.Margin)
s.EqualValues(sdk.NewDec(2*common.TO_MICRO), queryResp.Position.OpenNotional)
s.EqualValues(sdk.MustNewDecFromStr("1999999.999999999999998000"), queryResp.PositionNotional)
s.EqualValues(sdk.MustNewDecFromStr("-0.000000000000002000"), queryResp.UnrealizedPnl)
s.EqualValues(sdk.MustNewDecFromStr("332.655600323695898383"), queryResp.Position.Size_)
s.EqualValues(sdk.MustNewDecFromStr("1996000.000000000000000000"), queryResp.Position.Margin)
s.EqualValues(sdk.MustNewDecFromStr("1996000.000000000000000000"), queryResp.Position.OpenNotional)
s.EqualValues(sdk.MustNewDecFromStr("1996000.000000000000002000"), queryResp.PositionNotional)
s.EqualValues(sdk.MustNewDecFromStr("0.000000000000002000"), queryResp.UnrealizedPnl)
s.EqualValues(sdk.OneDec(), queryResp.MarginRatio)

s.T().Log("C. open position with 2x leverage and zero baseAmtLimit")
Expand All @@ -278,12 +278,12 @@ func (s *IntegrationTestSuite) TestMarketOrdersAndCloseCmd() {
s.T().Logf("query response: %+v", queryResp)
s.EqualValues(user.String(), queryResp.Position.TraderAddress)
s.EqualValues(asset.Registry.Pair(denoms.BTC, denoms.NUSD), queryResp.Position.Pair)
s.EqualValues(sdk.MustNewDecFromStr("999.900009999000099990"), queryResp.Position.Size_)
s.EqualValues(sdk.NewDec(4*common.TO_MICRO), queryResp.Position.Margin)
s.EqualValues(sdk.NewDec(6*common.TO_MICRO), queryResp.Position.OpenNotional)
s.EqualValues(sdk.MustNewDecFromStr("6000000.000000000000000000"), queryResp.PositionNotional)
s.EqualValues(sdk.MustNewDecFromStr("0.000000000000000000"), queryResp.UnrealizedPnl)
s.EqualValues(sdk.MustNewDecFromStr("0.666666666666666667"), queryResp.MarginRatio)
s.EqualValues(sdk.MustNewDecFromStr("996.567342121568550334"), queryResp.Position.Size_)
s.EqualValues(sdk.MustNewDecFromStr("3988000.000000000000000000"), queryResp.Position.Margin)
s.EqualValues(sdk.MustNewDecFromStr("5980000.0"), queryResp.Position.OpenNotional)
s.EqualValues(sdk.MustNewDecFromStr("5979999.999999999999996000"), queryResp.PositionNotional)
s.EqualValues(sdk.MustNewDecFromStr("-0.000000000000004000"), queryResp.UnrealizedPnl)
s.EqualValues(sdk.MustNewDecFromStr("0.666889632107023411"), queryResp.MarginRatio)

s.T().Log("D. Open a reverse position smaller than the existing position")
txResp, err = s.network.ExecTxCmd(cli.MarketOrderCmd(), user, []string{
Expand All @@ -302,21 +302,23 @@ func (s *IntegrationTestSuite) TestMarketOrdersAndCloseCmd() {
ammMarketDuo, err = testutilcli.QueryMarketV2(val.ClientCtx, pair)
s.Require().NoError(err)
s.T().Logf("ammMarketDuo: %s", ammMarketDuo.String())
s.EqualValues(sdk.MustNewDecFromStr("9999166.736105324556286976"), ammMarketDuo.Amm.BaseReserve)
s.EqualValues(sdk.MustNewDecFromStr("10000833.333333333333333333"), ammMarketDuo.Amm.QuoteReserve)
s.EqualValues(sdk.MustNewDecFromStr("9999169.735606286824650660"), ammMarketDuo.Amm.BaseReserve)
s.EqualValues(sdk.MustNewDecFromStr("10000830.333333333333333334"), ammMarketDuo.Amm.QuoteReserve)

s.T().Log("D. Check trader position")
queryResp, err = testutilcli.QueryPositionV2(val.ClientCtx, asset.Registry.Pair(denoms.BTC, denoms.NUSD), user)
s.NoError(err)
s.T().Logf("query response: %+v", queryResp)
s.EqualValues(user.String(), queryResp.Position.TraderAddress)
s.EqualValues(asset.Registry.Pair(denoms.BTC, denoms.NUSD), queryResp.Position.Pair)
s.EqualValues(sdk.MustNewDecFromStr("833.263894675443713024"), queryResp.Position.Size_)
s.EqualValues(sdk.NewDec(4*common.TO_MICRO), queryResp.Position.Margin)
s.EqualValues(sdk.NewDec(5_000_000), queryResp.Position.OpenNotional)
s.EqualValues(sdk.MustNewDecFromStr("4999999.999999999999998000"), queryResp.PositionNotional)
s.EqualValues(sdk.MustNewDecFromStr("-0.000000000000002000"), queryResp.UnrealizedPnl)
s.EqualValues(sdk.MustNewDecFromStr("0.800000000000000000"), queryResp.MarginRatio)
s.EqualValues(sdk.MustNewDecFromStr("830.264393713175349340"), queryResp.Position.Size_)
s.EqualValues(sdk.MustNewDecFromStr("3987999.999999999999999332"), queryResp.Position.Margin)
s.EqualValues(sdk.MustNewDecFromStr("3987999.999999999999999332"), queryResp.Position.Margin)

s.EqualValues(sdk.MustNewDecFromStr("4981999.999999999999999332"), queryResp.Position.OpenNotional)
s.EqualValues(sdk.MustNewDecFromStr("4981999.999999999999998000"), queryResp.PositionNotional)
s.EqualValues(sdk.MustNewDecFromStr("-0.000000000000001332"), queryResp.UnrealizedPnl)
s.EqualValues(sdk.MustNewDecFromStr("0.800481734243275793"), queryResp.MarginRatio)

s.T().Log("E. Open a reverse position larger than the existing position")
txResp, err = s.network.ExecTxCmd(cli.MarketOrderCmd(), user, []string{
Expand All @@ -336,11 +338,11 @@ func (s *IntegrationTestSuite) TestMarketOrdersAndCloseCmd() {
s.T().Logf("query response: %+v", queryResp)
s.EqualValues(user.String(), queryResp.Position.TraderAddress)
s.EqualValues(asset.Registry.Pair(denoms.BTC, denoms.NUSD), queryResp.Position.Pair)
s.EqualValues(sdk.MustNewDecFromStr("-500.025001250062503125"), queryResp.Position.Size_)
s.EqualValues(sdk.MustNewDecFromStr("3000000.000000000000002000"), queryResp.Position.OpenNotional)
s.EqualValues(sdk.MustNewDecFromStr("3000000.000000000000002000"), queryResp.Position.Margin)
s.EqualValues(sdk.MustNewDecFromStr("3000000.000000000000000000"), queryResp.PositionNotional)
s.EqualValues(sdk.MustNewDecFromStr("0.000000000000002000"), queryResp.UnrealizedPnl)
s.EqualValues(sdk.MustNewDecFromStr("-500.358367930342114784"), queryResp.Position.Size_)
s.EqualValues(sdk.MustNewDecFromStr("3002000.000000000000002000"), queryResp.Position.OpenNotional)
s.EqualValues(sdk.MustNewDecFromStr("3002000.000000000000002000"), queryResp.Position.Margin)
s.EqualValues(sdk.MustNewDecFromStr("3002000.000000000000004000"), queryResp.PositionNotional)
s.EqualValues(sdk.MustNewDecFromStr("-0.000000000000002000"), queryResp.UnrealizedPnl)
// there is a random delta due to twap margin ratio calculation and random block times in the in-process network
s.InDelta(1, queryResp.MarginRatio.MustFloat64(), 0.008)

Expand Down Expand Up @@ -382,19 +384,19 @@ func (s *IntegrationTestSuite) TestPartialCloseCmd() {
ammMarketDuo, err := testutilcli.QueryMarketV2(val.ClientCtx, pair)
s.Require().NoError(err)
s.T().Logf("ammMarketDuo: %s", ammMarketDuo.String())
s.EqualValues(sdk.MustNewDecFromStr("9998000.399920015996800640"), ammMarketDuo.Amm.BaseReserve)
s.EqualValues(sdk.MustNewDecFromStr("10002000.000000000000000000"), ammMarketDuo.Amm.QuoteReserve)
s.EqualValues(sdk.MustNewDecFromStr("9998004.398322094909855993"), ammMarketDuo.Amm.BaseReserve)
s.EqualValues(sdk.MustNewDecFromStr("10001996.000000000000000001"), ammMarketDuo.Amm.QuoteReserve)

s.T().Log("Check trader position")
queryResp, err := testutilcli.QueryPositionV2(val.ClientCtx, asset.Registry.Pair(denoms.BTC, denoms.NUSD), user)
s.NoError(err)
s.T().Logf("query response: %+v", queryResp)
s.EqualValues(user.String(), queryResp.Position.TraderAddress)
s.EqualValues(pair, queryResp.Position.Pair)
s.EqualValues(sdk.MustNewDecFromStr("1999.600079984003199360"), queryResp.Position.Size_)
s.EqualValues(sdk.NewDec(12e6), queryResp.Position.Margin)
s.EqualValues(sdk.NewDec(12e6), queryResp.Position.OpenNotional)
s.EqualValues(sdk.MustNewDecFromStr("12000000"), queryResp.PositionNotional)
s.EqualValues(sdk.MustNewDecFromStr("1995.601677905090144007"), queryResp.Position.Size_)
s.EqualValues(sdk.MustNewDecFromStr("11976000.000000000000000000"), queryResp.Position.Margin)
s.EqualValues(sdk.MustNewDecFromStr("11976000.000000000000000000"), queryResp.Position.OpenNotional)
s.EqualValues(sdk.MustNewDecFromStr("11976000.000000000000000000"), queryResp.PositionNotional)
s.EqualValues(sdk.ZeroDec(), queryResp.UnrealizedPnl)
s.EqualValues(sdk.OneDec(), queryResp.MarginRatio)

Expand Down Expand Up @@ -428,21 +430,21 @@ func (s *IntegrationTestSuite) TestPartialCloseCmd() {
ammMarketDuo, err = testutilcli.QueryMarketV2(val.ClientCtx, pair)
s.Require().NoError(err)
s.T().Logf("ammMarketDuo: %s", ammMarketDuo.String())
s.EqualValues(sdk.MustNewDecFromStr("9998500.399920015996800640"), ammMarketDuo.Amm.BaseReserve)
s.EqualValues(sdk.MustNewDecFromStr("10001499.824993752062459356"), ammMarketDuo.Amm.QuoteReserve)
s.EqualValues(sdk.MustNewDecFromStr("9998503.398288059264958855"), ammMarketDuo.Amm.BaseReserve)
s.EqualValues(sdk.MustNewDecFromStr("10001496.825727135305804567"), ammMarketDuo.Amm.QuoteReserve)

s.T().Log("Check trader position")
queryResp, err = testutilcli.QueryPositionV2(val.ClientCtx, asset.Registry.Pair(denoms.BTC, denoms.NUSD), user)
s.NoError(err)
s.T().Logf("query response: %+v", queryResp)
s.EqualValues(user.String(), queryResp.Position.TraderAddress)
s.EqualValues(asset.Registry.Pair(denoms.BTC, denoms.NUSD), queryResp.Position.Pair)
s.EqualValues(sdk.MustNewDecFromStr("1499.600079984003199360"), queryResp.Position.Size_)
s.EqualValues(sdk.NewDec(12e6), queryResp.Position.Margin)
s.EqualValues(sdk.MustNewDecFromStr("8998949.962512374756136000"), queryResp.Position.OpenNotional)
s.EqualValues(sdk.MustNewDecFromStr("8998949.962512374756136000"), queryResp.PositionNotional)
s.EqualValues(sdk.ZeroDec(), queryResp.UnrealizedPnl)
s.EqualValues(sdk.MustNewDecFromStr("1.333488912594172945"), queryResp.MarginRatio)
s.EqualValues(sdk.MustNewDecFromStr("1496.601711940735041145"), queryResp.Position.Size_)
s.EqualValues(sdk.MustNewDecFromStr("11976000.000000000000000000"), queryResp.Position.Margin)
s.EqualValues(sdk.MustNewDecFromStr("8980954.362811834827398000"), queryResp.Position.OpenNotional)
s.EqualValues(sdk.MustNewDecFromStr("8980954.362811834827396000"), queryResp.PositionNotional)
s.EqualValues(sdk.MustNewDecFromStr("-0.000000000000002000"), queryResp.UnrealizedPnl)
s.EqualValues(sdk.MustNewDecFromStr("1.333488571057658776"), queryResp.MarginRatio)
}

func (s *IntegrationTestSuite) TestPositionEmptyAndClose() {
Expand Down Expand Up @@ -519,7 +521,7 @@ func (s *IntegrationTestSuite) TestX_AddMargin() {
fmt.Sprintf("10000%s", denoms.USDT),
},
expectFail: false,
expectedMargin: sdk.NewDec(1_000_000),
expectedMargin: sdk.NewDec(980000),
expectedCode: 1,
},
{
Expand All @@ -529,7 +531,7 @@ func (s *IntegrationTestSuite) TestX_AddMargin() {
fmt.Sprintf("10000%s", types.TestingCollateralDenomNUSD),
},
expectedCode: types.ErrPositionNotFound.ABCICode(),
expectedMargin: sdk.NewDec(1_000_000),
expectedMargin: sdk.NewDec(980000),
expectFail: false,
},
{
Expand All @@ -539,7 +541,7 @@ func (s *IntegrationTestSuite) TestX_AddMargin() {
fmt.Sprintf("10000%s", types.TestingCollateralDenomNUSD),
},
expectedCode: 0,
expectedMargin: sdk.NewDec(1_010_000),
expectedMargin: sdk.NewDec(990_000),
expectFail: false,
},
{
Expand Down Expand Up @@ -623,7 +625,7 @@ func (s *IntegrationTestSuite) TestX_RemoveMargin() {
},
expectFail: false,
expectedCode: 1,
expectedMargin: sdk.NewDec(1_000_000),
expectedMargin: sdk.NewDec(980_000),
},
{
name: "fail: position not found",
Expand All @@ -632,7 +634,7 @@ func (s *IntegrationTestSuite) TestX_RemoveMargin() {
fmt.Sprintf("10000%s", types.TestingCollateralDenomNUSD),
},
expectedCode: types.ErrPositionNotFound.ABCICode(),
expectedMargin: sdk.NewDec(1_000_000),
expectedMargin: sdk.NewDec(980_000),
expectFail: false,
},
{
Expand All @@ -642,7 +644,7 @@ func (s *IntegrationTestSuite) TestX_RemoveMargin() {
fmt.Sprintf("10000%s", types.TestingCollateralDenomNUSD),
},
expectedCode: 0,
expectedMargin: sdk.NewDec(990_000),
expectedMargin: sdk.NewDec(970_000),
expectFail: false,
},
{
Expand Down
2 changes: 1 addition & 1 deletion x/perp/v2/keeper/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func TestCloseMarket(t *testing.T) {
),
).When(
CloseMarket(pairBtcUsdc),
AMMShouldBeEqual(pairBtcUsdc, AMM_SettlementPriceShoulBeEqual(sdk.MustNewDecFromStr("1.1"))),
AMMShouldBeEqual(pairBtcUsdc, AMM_SettlementPriceShoulBeEqual(sdk.MustNewDecFromStr("1.099800000000000000"))),
).Then(
PartialCloseFails(alice, pairBtcUsdc, sdk.NewDec(5_000), perptypes.ErrMarketNotEnabled),
),
Expand Down
50 changes: 35 additions & 15 deletions x/perp/v2/keeper/clearing_house.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ func (k Keeper) MarketOrder(
sameSideLong := position.Size_.IsPositive() && dir == types.Direction_LONG
sameSideShort := position.Size_.IsNegative() && dir == types.Direction_SHORT

openNotionalPreFees := leverage.MulInt(quoteAssetAmt)
transferredFee, err := k.transferFee(ctx, market.Pair, traderAddr, openNotionalPreFees,
market.ExchangeFeeRatio, market.EcosystemFundFeeRatio,
)
if err != nil {
return nil, err
}
quoteAssetAmtMinusFees := quoteAssetAmt.Sub(transferredFee)

var updatedAMM *types.AMM
openSideMatchesPosition := sameSideLong || sameSideShort
if isNewPosition || openSideMatchesPosition {
Expand All @@ -73,14 +82,14 @@ func (k Keeper) MarketOrder(
amm,
position,
dir,
/* openNotional */ leverage.MulInt(quoteAssetAmt),
/* openNotional */ leverage.MulInt(quoteAssetAmtMinusFees),
/* minPositionSize */ baseAmtLimit,
/* leverage */ leverage)
if err != nil {
return nil, err
}
} else {
quoteAssetAmtToDec := sdk.NewDecFromInt(quoteAssetAmt)
quoteAssetAmtToDec := sdk.NewDecFromInt(quoteAssetAmtMinusFees)
updatedAMM, positionResp, err = k.openReversePosition(
ctx,
market,
Expand Down Expand Up @@ -108,7 +117,7 @@ func (k Keeper) MarketOrder(
}

if err = k.afterPositionUpdate(
ctx, market, *updatedAMM, traderAddr, *positionResp, types.ChangeReason_MarketOrder, position,
ctx, market, traderAddr, *positionResp, types.ChangeReason_MarketOrder, transferredFee, position,
); err != nil {
return nil, err
}
Expand Down Expand Up @@ -531,10 +540,10 @@ func checkMarketOrderRequirements(market types.Market, quoteAssetAmt sdkmath.Int
func (k Keeper) afterPositionUpdate(
ctx sdk.Context,
market types.Market,
amm types.AMM,
traderAddr sdk.AccAddress,
positionResp types.PositionResp,
changeType types.ChangeReason,
transferredFee sdkmath.Int,
existingPosition types.Position,
) (err error) {
// transfer trader <=> vault
Expand All @@ -558,13 +567,6 @@ func (k Keeper) afterPositionUpdate(
}
}

transferredFee, err := k.transferFee(ctx, market.Pair, traderAddr, positionResp.ExchangedNotionalValue,
market.ExchangeFeeRatio, market.EcosystemFundFeeRatio,
)
if err != nil {
return err
}

if !positionResp.Position.Size_.IsZero() {
k.SavePosition(ctx, market.Pair, market.Version, traderAddr, positionResp.Position)
}
Expand All @@ -579,6 +581,17 @@ func (k Keeper) afterPositionUpdate(
positionNotional = positionResp.Position.OpenNotional.Sub(positionResp.UnrealizedPnlAfter)
}

// This means that the position has been closed entirely.
if transferredFee.IsZero() {
// If the position has margin to be transferred to the user, we get the fees from it.
if positionResp.MarginToVault.IsNegative() {
transferredFee, err = k.transferFee(ctx, market.Pair, traderAddr, positionResp.MarginToVault.Abs(), market.ExchangeFeeRatio, market.EcosystemFundFeeRatio)
if err != nil {
return err
}
}
}

_ = ctx.EventManager().EmitTypedEvents(
&types.PositionChangedEvent{
FinalPosition: positionResp.Position,
Expand Down Expand Up @@ -718,7 +731,7 @@ func (k Keeper) ClosePosition(ctx sdk.Context, pair asset.Pair, traderAddr sdk.A
return nil, err
}

updatedAMM, positionResp, err := k.closePositionEntirely(
_, positionResp, err := k.closePositionEntirely(
ctx,
market,
amm,
Expand All @@ -742,10 +755,10 @@ func (k Keeper) ClosePosition(ctx sdk.Context, pair asset.Pair, traderAddr sdk.A
if err = k.afterPositionUpdate(
ctx,
market,
*updatedAMM,
traderAddr,
*positionResp,
types.ChangeReason_ClosePosition,
sdk.ZeroInt(),
position,
); err != nil {
return nil, err
Expand Down Expand Up @@ -889,7 +902,14 @@ func (k Keeper) PartialClose(
}
reverseNotionalAmt = amm.QuoteReserveToAsset(reverseNotionalAmt)

updatedAMM, positionResp, err := k.decreasePosition(ctx, market, amm, position, reverseNotionalAmt, sdk.ZeroDec())
feesTransferred, err := k.transferFee(ctx, market.Pair, traderAddr, reverseNotionalAmt, market.ExchangeFeeRatio, market.EcosystemFundFeeRatio)
if err != nil {
return nil, err
}

reverseNotionalAmtWithoutFees := reverseNotionalAmt.Sub(feesTransferred.ToLegacyDec())

_, positionResp, err := k.decreasePosition(ctx, market, amm, position, reverseNotionalAmtWithoutFees, sdk.ZeroDec())
if err != nil {
return nil, err
}
Expand All @@ -907,10 +927,10 @@ func (k Keeper) PartialClose(
err = k.afterPositionUpdate(
ctx,
market,
*updatedAMM,
traderAddr,
*positionResp,
types.ChangeReason_PartialClose,
feesTransferred,
position,
)
if err != nil {
Expand Down
Loading

0 comments on commit 29e6900

Please sign in to comment.