snapshot-labs / boost

A protocol for token distribution
MIT License
13 stars 5 forks source link

update token fee computation #40

Closed pscott closed 6 months ago

pscott commented 6 months ago

Makes it easier for the depositor to compute the exact amount needed to deposit.

e.g for a prize of 100 and a tokenFee of 10, just send 110. Previously, you would've had to deposit 100 * 100 / 90 == 111.111

Orland0x commented 6 months ago

Looks good. I do agree this simplifies the reasoning for a fixed boost size.

Now the fee is computed as a % of the boost balance increase rather than the deposit amount. We should be explicit about this in the comments//docs. There is no longer a limit on the token fee of 10000.

https://github.com/snapshot-labs/boost/blob/9440238ca7e82fc76815c98b02c6dd3d4d647645/src/Boost.sol#L50

An interesting edge case of this is that its now impossible to have a 100% fee due to the asymptotic nature of the fee curve.

Screenshot 2024-02-28 at 11 32 59

It should be fine to just use uint256.max though and the loss of precision should handle it.

pscott commented 6 months ago

Good point about updating the doc, I will do that (I had removed the reverts but forgot to update the comment).

Regarding asymptote: indeed this had occurred to me: I managed to get a 100% fee by using this little trick: https://github.com/snapshot-labs/boost/blob/9440238ca7e82fc76815c98b02c6dd3d4d647645/test/ProtocolFees.t.sol#L223

🔥