DSS 2026 / Day 2 / Amber Hall
Every Division Picks a Winner
Dhairya Sethi · Tomer Ganor
Source: YouTube automatic caption track · Exported 2026-11-16. Timestamps link to the source video. Cue end times were not supplied.
Transcript
0:01Hi everyone.
0:02I'm Thomas Gano from Thomas Security
0:04First.
0:05>> I'm Darius Seti, smart contracts
0:07developer at Ave Labs. We are here as
0:09mentioned to talk about rounding,
0:11especially because it's such an
0:13important field. It's such an important
0:15aspect while thinking about DeFi, while
0:17thinking about arithmetic, while
0:18thinking about finance on chain. So
0:21we'll just give a quick primer because I
0:22think everyone is aware,
0:24but because we cannot because we use
0:25fixed point arithmetic,
0:27decimals have probabilistic problems
0:29inside.
0:31In any scenario, you have to work with
0:33rounding in any case. So very very
0:36simple example just to get us warmed up.
0:39If you have 10 assets with a share price
0:41of three because it's not perfectly
0:42divisible, there is a remainder that
0:45modulus that you have to decide who to
0:47allocate because you cannot vanish it
0:49into thin air. Either you gift it to the
0:51protocol, either you gift it to the
0:52user, or you gift it to an arbitrary
0:54entity. You can keep it aside, but there
0:56is something that you have to do with
0:57that. So whoever gets this
1:01leftover piece is the winner that we're
1:03talking about.
1:04So rounding whenever you have to make
1:06them, it forces you to pick a winner.
1:09Now who
1:11wins actually? Let's try to define these
1:14entities, let's call them.
1:16So the types of entities when we're
1:18dealing with rounding can be thought of
1:20as active or passive. Active entities
1:23are entities which initiate operations
1:25which are very proactive. They're the
1:27ones who determine when an action will
1:29take place. They determine
1:32the time and
1:34under what scenario, under what price,
1:36under what market conditions, under what
1:39integration and so on.
1:41The polar opposite is a passive entity.
1:43A passive entity is the entity on whom
1:46the action takes place or who is bearing
1:48the benefit, like who loses or who wins
1:50or whose account is being modified.
1:53These entities because they don't
1:54initiate, they
1:56only have their position updated.
1:58Hence they're usually not incentivized
2:00to for this. And for active entities to
2:03perform this action maybe during a
2:04callback, maybe during a certain event
2:06trigger, maybe during
2:08a certain liquidation. These entities
2:09are usually incentivized to perform the
2:11operation.
2:12So let's just formally define what these
2:15entities are. In case of lending
2:17protocols, more or less broadly you have
2:19four types of entities, protocol,
2:22the treasury which can come under
2:23protocol, but let's treat it separate.
2:26Users and external entities like
2:27liquidators, keepers, bots and so on.
2:31The protocol is always the most most
2:33passive because it is the entity on
2:36which the rounding gets taken place on.
2:39Treasury can be passive or active. It
2:42depends on the kind of structure that
2:44you have. If you want your treasury to
2:45be
2:47taking some action on each place, but
2:48usually it's passive.
2:50That's why it falls more on the passive
2:51side of the graph. The user
2:54can be both. That's the most interesting
2:56case because the user initiates most
2:57transactions to set up his position, to
2:59modify and so on. But whenever his
3:02position, let's say in a lending
3:03protocol falls below a certain
3:04threshold, he needs to get liquidated.
3:06We need another external entity to
3:08perform the callback because we cannot
3:09have on-chain timers. We have the
3:11liquidator. Liquidator is always the
3:13most most active entity. So when
3:16deciding when what direction to round up
3:19or down, who to gift this donation, we
3:22always round we always give the donation
3:25to the most active entity. So you should
3:26always round in favor of the protocol
3:28over anybody else. You should round in
3:30favor of the treasury over the user.
3:33That's where it falls on the graph.
3:35And any when thinking about
3:36liquidations, the most interesting
3:37cases, you should always round in favor
3:40of the non-liquidator over the
3:42liquidator.
3:46>> Okay, thank you, Dhara.
3:48So basically this is the role. We want
3:50to round in favor of the passive entity
3:52because when you are the passive entity,
3:54you cannot, as Dhara said, you cannot
3:55force the operation. You are basically
3:58forced the operation is forced upon you
4:00and that 's why you want to round
4:01against you when you're active.
4:07Okay. So let's go to the trivial cases.
4:10So the trivial cases in lending
4:11protocols are the four
4:14trivial functions, which is the supply,
4:15the withdraw, the borrow, and the repay.
4:17Let's go over them real quick and then
4:19we go to the more interesting cases.
4:21So when we supply to the protocol, then
4:24this is an active operation. We are the
4:25user, we supply to the protocol. It's
4:27very trivial that we need to get paid
4:29less. Otherwise, what we'll do, we just
4:31split our operation to many small
4:32operations and we're going to make
4:34profit each operation and then we're
4:36just going to get either the protocol is
4:38insolvent or we're going to steal money
4:39from someone else, which is of course
4:41not good.
4:43When we withdraw from the protocol, we
4:44want to round against the user again,
4:46which basically mean in this context
4:48we're going to round up the amount we
4:50decrease from the user. So if I want to
4:52withdraw 10 assets, then maybe my
4:55balance in the protocol will decrease by
4:5611. Maybe it decrease by 10, which is
4:58great and it's precise. But if we need
5:00to round, we need to round against the
5:01user, we might decrease it by 11.
5:03Again,
5:04with the borrow, we round up, which
5:06means that if I borrow 10, I might owe
5:0811 afterwards because again, otherwise,
5:11if we round down, let's say we been
5:12instead of owing 10, I would owe nine.
5:14So I just borrow 10, repay, borrow 10,
5:16repay, and I get paid more than what
5:18than what I repay, so I get free money
5:21stealing money from the protocol.
5:23And same [clears throat] with the repay,
5:24of course, the same context as borrow.
5:26We were going to round down the amount
5:28of debt whether we are decreasing from
5:30the borrower, which means that if I
5:32repay 10, we're going to decrease the
5:34debt by nine, maybe by eight in some
5:35cases depending on the rounding, but
5:37never by more.
5:39Because then the active entity is the
5:41user, so we want to round against them
5:43and in favor of the other users which
5:45are the protocol in this context. So
5:47those are the trivial cases.
5:49So
5:50now what we care about is the the fee.
5:54So the fee of the treasury or the fee
5:56the fee that we pay to the treasury
5:58doing the flow of the of the flow of the
6:01action, it always needs to be rounded
6:04correctly. So one of the fees or one of
6:06the ways that the fee rounding happens
6:09is when we actually realize the fee,
6:11which means that we take the asset that
6:13we have and then we supply them back to
6:15the protocol. So, when we do this
6:17operation, this part of the fee minting,
6:20it's treated as supply, which means that
6:21we want against the protocol against the
6:23treasury and and not against the
6:26protocol.
6:27That means that when we charge the fee,
6:29we need to round against the user
6:31because we charge the fee from them and
6:33the treasury is passive. But when the
6:35the treasury is credited this money,
6:37then we round against the treasury. So,
6:39this treasury, as before, it's not
6:41always passive, it's not always active.
6:43It's not completely trivial case, but
6:45this part, the the minting for the of
6:49the fee to the treasury when it reinvest
6:51the money in the protocol, we need to
6:52round against it exactly like we do in
6:54supply.
6:56In liquidation, which is the most scary
6:58operation, there is a couple of
7:00different roundings we need to take into
7:01account. So, we always want to round
7:03against the liquidator. So, in what
7:05context is this relevant? So, one of
7:07them is the amount of debt the
7:08liquidator repays because liquidation is
7:10basically I'm the liquidator, I pay the
7:12debt, I get repaid some collateral, and
7:14I need to pay some liquidation fee
7:16usually to the treasury
7:17and and
7:19maybe also to the users.
7:21Um but what happens in every single
7:23point, every single decision we can get,
7:25we always round against the liquidator.
7:27So, one time we round up the amount the
7:28liquidator pays, other time we round
7:30down the amount the liquidator gets, and
7:33again we round up the amount of fee we
7:34charge from the liquidator as the
7:36liquidation fee and what we repay and
7:39what we feed it we give to the treasury.
7:41So, here round up the amount the
7:43treasury gets, but when we mint later,
7:45we round down against the treasury.
7:48So, this is very there is a lot of
7:50roundings happening in this function
7:51specifically, not only one place. It's
7:53very important to notice that
7:55this is very this is like the mechanism,
7:58this is the engine of settling the the
8:01score in the lending protocol. So, it's
8:03very important to use right.
8:05And the last place is the index. So, in
8:09any protocols like Aave V3 for example,
8:11there is two places, there is indexes,
8:13two different indexes. One of them is
8:14the debt index. The debt index is the
8:16way to calculate what is the total
8:19total debt it is owed by the users, by
8:21all of the users together or by every
8:23single user
8:24alone. And they always round up the
8:26calculation based on the debt.
8:29For example, if we multiply the index by
8:31the amount of debt shares that the user
8:33has, we round up. That that's easy.
8:35Also, when we calculate the index
8:37itself, the debt index itself, we need
8:39to round up because it means that we
8:41otherwise we could just ping the
8:43protocol every single block if we round
8:45down and then effectively the index
8:47might stay the same because the
8:49calculation, the extra small amount
8:51would be not enough to get us to the
8:53next number. So, we stay the same index.
8:54So, effectively there is no interest
8:56charged from the users, which is of
8:57course very bad. We want to round up.
8:59That way no one has an incentive to ping
9:02the protocol every single block. They
9:04could do it if they want legitimately,
9:05but they don't have an incentive to do
9:07it every single block or if they
9:08actually want to do the operation.
9:11With supply index, it's the opposite.
9:13So, we round down the supply index. So,
9:14every calculation based on the supply
9:16index, which is the credit the user has
9:18in the protocol, the the collateral they
9:20have, all of the assets they own. So,
9:22they always round down against the user
9:24in favor of the protocol. In this in
9:26this way that we calculate the supply
9:28index, we just round down always every
9:31time when we multiply we round down,
9:32always round down. And that way
9:34everything is always over conservative
9:37and everything is safe.
9:40>> So, now we know who wins and what
9:43direction to take because it's very
9:45important. But one thing that's common
9:47not commonly talked about is when. It's
9:49also equally as important to think about
9:51your rounding directions or your
9:53donations when
9:55in terms of times, in terms of actions
9:57we don't actually commit to the
9:59rounding. So, we will take a simple and
10:02quick case study depending on the time.
10:03The idea would be that you take a
10:04lending protocol which
10:07has an invariant that its share price
10:09always goes up. So, case of shortfalls
10:11or deficits, it does not socialize the
10:13losses, but it keeps the counter
10:15separately such that maybe another
10:16entity at the later later point can
10:19claim that from an insurance fund. So
10:20remember the invariant of our protocol
10:22is that the share price is monotonic.
10:25Now the idea would be with the
10:27commitment that we always look at the
10:30rounding direction when you do a preview
10:32action and when you do
10:34an actual action which commits to the
10:36rounding.
10:37So let's take a simple example. Let's
10:38say that
10:40value is being
10:42started. Let's say we started a share
10:43price of one. The snapshot is one. We
10:45don't commit anything. Let's say over
10:47time the share price increases. Now we
10:50have accumulated 0.6 worth of a share
10:53price. So these are like incremental
10:55steps because this is not perfectly
10:57divisible. We have to take a decision on
10:59where to round. Now let's say that here
11:01we're talking about treasury fee. Like
11:03like Thomas said, in the non-trivial
11:05cases, fees should be treated as a
11:07supply. So you should always round down
11:09against
11:11the supplier. So in favor of the
11:13protocol. So here what you would do is
11:15that if let's say that this is the
11:17treasury accrual, you would treat this
11:19as a supply if treasury was supplying
11:210.6 rounded down to zero. It will round
11:24down to zero shares. So the treasury
11:26doesn't get anything and the 0.6 gets
11:27donated to the users essentially. It
11:29gets socialized to all the suppliers.
11:31So here we donate
11:340.6. Now imagine that another external
11:37lending protocol or any other DeFi
11:39protocol tries to interact with
11:42protocol and let's say it just snapshots
11:44the price. Let's say it previews the
11:45share price for an operation. Let's say
11:47just converting some shares, but it's
11:49not actually doing any action which
11:51commits to this. In this example here we
11:54are compounding the fees on each action,
11:56for example.
11:57Now
11:58let's say after some time
12:00the share price has grown to 2.3. At
12:03this point, remember that we did not
12:05commit here. Only
12:07external protocol previewed the share
12:08price. So they previewed zero shares to
12:10the treasury and 0.6 that was donated to
12:12all suppliers.
12:14Now at this point if
12:16anybody tries to preview or they commit
12:18to an action, we can take either case.
12:20But here if anybody tries to commit an
12:22action or preview,
12:23the the donation that was given out
12:25previously to the users is reclaimed
12:27back because we never committed to that
12:28rounding. And now we donate 0.3 above.
12:31So if you calculate the share prices
12:33before and after this case, here if you
12:35commit the share price, it comes out to
12:360.06 and after it comes down to 0.03
12:40because what you did was you reclaimed
12:42part of the donation that you had given
12:43to some other entity to to the fees to
12:45the fee receiver here. So here your
12:48invariance can break.
12:49The so this is why it's very important
12:51to think about when you're rounding
12:54in which context. So the way to the way
12:57RV V4 RV V3 solves this is that we do
13:00not have rounding on preview actions.
13:03Anytime you have fees that is
13:04accumulated, we keep it aside to
13:06simplify the interactions with the
13:08protocol and you only mint for the
13:10treasury on demand.
13:12Uh that's all from us folks. Uh thank
13:14you so much. Any questions?
Source and accuracy details
- Names, organizations, technical terms, code and numbers may be misrecognized.
- Source wording and disfluencies are preserved; no editorial corrections were applied.
- Export contains whole-second cue starts only; cue ends and subsecond timing are unavailable.
- A full caption-track export does not establish that every spoken word is represented.
- Automatic YouTube captions; not human-verified against the audio.
Source export SHA256: 6d70bbf936cee194f6d2389ac15be5fd7518d4a2c87b53e6eccdd9e3759cc279