Skip to content

Commit 1462ab9

Browse files
coreycaplan3dong77
authored andcommitted
[Protocol2] Update ParticipationHelper.sol (#261)
Dolomite needs to give away the margin, always, in order to synchronize the way our matching engine matches trades and Loopring settles them.
1 parent 91ee641 commit 1462ab9

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/loopring_v2/contracts/helper/ParticipationHelper.sol

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,19 @@ library ParticipationHelper {
109109
}
110110

111111
if ((p.fillAmountS - p.feeAmountS) >= prevP.fillAmountB) {
112-
// The miner (or in a P2P case, the taker) gets the margin
113-
p.splitS = (p.fillAmountS - p.feeAmountS) - prevP.fillAmountB;
114-
p.fillAmountS = prevP.fillAmountB + p.feeAmountS;
112+
// The taker gets the margin
113+
// This is the old way of calculating the margin split. GET RID OF IT so the user wins, always :-)
114+
// p.splitS = (p.fillAmountS - p.feeAmountS) - prevP.fillAmountB;
115+
116+
// Margin is given to the user
117+
uint marginSplitS = (p.fillAmountS - p.feeAmountS) - prevP.fillAmountB;
118+
p.fillAmountS = prevP.fillAmountB + p.feeAmountS + marginSplitS;
119+
p.splitS = 0;
115120
return true;
116121
} else {
117122
return false;
118123
}
124+
119125
}
120126

121127
function checkFills(

0 commit comments

Comments
 (0)