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