Six steps, and every one is on chain
Nothing here happens in a backend. Each step below names the contract that does it and the number it produced when measured against live BNB Chain state.
2% leaves the trade as token
Buy or sell, the token withholds 2%. At this point it is still token, not money, and it sits inside the token contract. Nothing has reached the vault yet.
Flap converts a batch to BNB
Accrued tax is liquidated when it crosses a threshold set at launch, not on every trade.
That batching is why the vault's receive() has to be almost free:
Flap forwards with a plain call, and if that call ever ran out of gas or reverted, tax
collection for the token would break permanently.
The vault wakes on a schedule
Flap's trigger service calls the vault every five minutes. Each wake buys the next slot before doing any work and runs the job inside a try, so a job that fails cannot break the chain that would have retried it. When there is nothing to do, the next slot is booked an hour out instead.
One flash loan, one swap, three passes
Venus checks collateral at the instant of the borrow, before the proceeds become collateral. So a loop can only take the sliver its current collateral supports, and those passes converge slowly — eighteen swaps to reach 3×. A flash loan reverses the order: supply first, borrow second.
| Path | Swaps | Cost | Why |
|---|---|---|---|
| Loop | 18 | 0.30% | Converges at cf/health = 0.667 per pass. Measured before the flash path replaced it. |
| Flash | 1 | 0.12–0.18% | Supply first, borrow second, repay from the position. Measured at 1, 5 and 20 BNB. |
The flash pool must be a
different fee tier from the swap pool. A V3 pool is locked for the duration of its own flash
callback, so borrowing and swapping in the same pool reverts LOK.
3× is the ceiling, not a choice
Venus lends against BNB at an 80% collateral factor. Health is
supply × CF / debt, and Venus
liquidates at 1.00. Run leverage against that and the product line writes itself.
At 5×, health is exactly 1.00. That is not
an aggressive position, it is one that liquidates on arrival. This vault does not offer
it: the target is a hard-coded constant at 3×, and the
build caps debt by the health floor rather than by what Venus would allow.
| Target | Health | Liquidates on |
|---|---|---|
| 2.00× | 1.600 | −37.5% |
| 3.00× | 1.200 | −16.7% |
| 4.00× | 1.067 | −6.3% |
| 5.00× | 1.000 | 0.0% |
A gain leaves, the principal stays
When the position has gained at least 0.02 BNB, a wake distributes it. The unwind takes only the gain — measured at three sizes, what it frees over what it gained is 1.00× — and health rises rather than falls, because the position gets smaller relative to its collateral.
Holders are paid through the
token's own dividend contract in WBNB. Flap's dividends are claimed, not pushed — call
withdrawDividends() when you want yours. They do not expire. A
holding below the dividend threshold earns no share; that rule is Flap's, not ours.