Skip to content

Commit de84eb7

Browse files
authored
Perps fee case (#1361)
case
1 parent 3042ee4 commit de84eb7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

x/perpetual/keeper/keeper.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,13 @@ func (k Keeper) Borrow(ctx sdk.Context, collateralAmount math.Int, custodyAmount
151151
}
152152

153153
// send fees to masterchef and taker collection address
154-
_, err = k.SendFeesToMasterchefAndTakerCollection(ctx, senderAddress, mtp.Address, liabilitiesInCollateral, mtp.CollateralAsset, ammPool, &totalPerpFees)
154+
var totalAmount math.Int
155+
if mtp.Position == types.Position_LONG && mtp.CollateralAsset == baseCurrency {
156+
totalAmount = proxyLeverage.MulInt(collateralAmount).TruncateInt()
157+
} else {
158+
totalAmount = liabilitiesInCollateral
159+
}
160+
_, err = k.SendFeesToMasterchefAndTakerCollection(ctx, senderAddress, mtp.Address, totalAmount, mtp.CollateralAsset, ammPool, &totalPerpFees)
155161
if err != nil {
156162
return types.PerpetualFees{}, err
157163
}

0 commit comments

Comments
 (0)