-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Roundrip fee on proportional remove #1010
base: main
Are you sure you want to change the base?
Changes from all commits
998733b
b422a51
cefcefa
279ec36
6b631a9
6320f88
5d1b298
3c67514
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
302.1k | ||
302.0k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
333.0k | ||
332.8k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
259.2k | ||
259.1k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
196.9k | ||
197.1k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
181.5k | ||
181.7k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
195.5k | ||
195.4k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
180.2k | ||
180.4k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
172.5k | ||
172.8k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
215.0k | ||
215.2k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
168.2k | ||
168.3k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
218.6k | ||
218.8k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
203.2k | ||
203.4k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
198.4k | ||
198.3k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
235.6k | ||
235.8k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
194.3k | ||
194.5k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
231.4k | ||
231.6k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
223.4k | ||
223.5k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
178.9k | ||
179.1k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
297.0k | ||
296.9k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
319.5k | ||
319.4k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
190.6k | ||
190.8k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
168.2k | ||
168.4k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
180.2k | ||
180.4k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
159.3k | ||
159.5k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
213.5k | ||
213.7k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
168.2k | ||
168.4k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
169.2k | ||
169.1k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
152.1k | ||
152.0k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
212.5k | ||
212.7k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
190.0k | ||
190.2k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
218.5k | ||
218.4k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
184.3k | ||
184.2k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
235.6k | ||
235.8k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
181.0k | ||
181.3k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
230.3k | ||
230.5k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
223.4k | ||
223.6k |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
178.9k | ||
179.2k |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -500,6 +500,7 @@ contract Vault is IVaultMain, VaultCommon, Proxy { | |
// bptOut = supply * (ratio - 1), so lower ratio = less bptOut, favoring the pool. | ||
|
||
_ensureUnpaused(params.pool); | ||
_addLiquidityCalled().tSet(params.pool, true); | ||
|
||
// `_loadPoolDataUpdatingBalancesAndYieldFees` is non-reentrant, as it updates storage as well | ||
// as filling in poolData in memory. Since the add liquidity hooks are reentrant and could do anything, | ||
|
@@ -878,6 +879,15 @@ contract Vault is IVaultMain, VaultCommon, Proxy { | |
_totalSupply(params.pool), | ||
bptAmountIn | ||
); | ||
|
||
// Charge roundtrip fee. | ||
if (_addLiquidityCalled().tGet(params.pool)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: if we clear this flag here, it's easy to bypass. You add a huge amount, make a decoy proportional exit, and then a big exit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree that's probably not worth it for an edge case. Although... maybe aggregators might bundle lots of transactions and come across that, since it just checks the pool, not the pool + user, so this could also get triggered on bundled transactions with multiple unrelated users doing liquidity operations on a popular pool. Maybe worth investigating if that's possible? If one person added and another person removed, the second one would get unexpectedly taxed. Though even storing the user wouldn't be foolproof, as someone could craft a transaction where the add and remove steps were done from separate addresses controlled by the same account. |
||
uint256 swapFeePercentage = poolData.poolConfigBits.getStaticSwapFeePercentage(); | ||
for (uint256 i = 0; i < locals.numTokens; ++i) { | ||
swapFeeAmounts[i] = amountsOutScaled18[i].mulUp(swapFeePercentage); | ||
amountsOutScaled18[i] -= swapFeeAmounts[i]; | ||
} | ||
} | ||
} else if (params.kind == RemoveLiquidityKind.SINGLE_TOKEN_EXACT_IN) { | ||
poolData.poolConfigBits.requireUnbalancedLiquidityEnabled(); | ||
bptAmountIn = params.maxBptAmountIn; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also add a dev section here with more detail on why this is desirable / improves security, and documenting limitations.