UniswapX:做市商報價後不成交,誰負責?
Life of a Fill: How Market Makers Work on UniswapX
- Alan Wu Uniswap
影片
影片與逐字稿來源:ETHTaipei
場次摘要
Uniswap 工程師 Alan Wu 拆解 UniswapX 的換幣流程:使用者在鏈下簽下交易條件,由做市商報價並負責送上鏈,因此使用者不必自行支付 gas。報價分為簽名前的初步報價與執行前的最終報價。為避免做市商報價後不成交,系統會暫停反覆棄單者接收新訂單。
值得記下的 5 件事
- UniswapX 使用者在鏈下簽署最低收款量與截止時間,做市商決定交易路徑並負責鏈上結算,使用者不必自行支付 gas。
- 做市商須在 500 毫秒內回覆報價或明確表示不報價,讓系統辨別正常參與與逾時。
- UniswapX 先給軟報價,使用者簽名後再給硬報價,避免簽名延遲讓做市商被迫接受舊價格。
- 大額交易不一定拿到較差報價:若這筆交易讓做市商庫存更接近中性,做市商可能願意提供更好的價格。
- 做市商報價後反覆不成交,RFQ 系統會暫停向它發送新訂單,以未來訂單流的損失抑制棄單。
逐字稿
開場:跟一筆 UniswapX 成交走一遍
大家好。Vitalik 後面接著講很難,請大家包涵。我是 Alan,Uniswap 的協議工程師,很高興再回到這裡。我以前講過 UniswapX、拍賣設計,也講過協議本身。今天想講比較少被放到台面上的東西:UniswapX 的 RFQ,以及在這個協議裡當做市商是什麼感覺。我們會跟著一筆交易走完整個系統,看做市商怎麼在 UniswapX 裡運作,又怎麼幫兌換者成交。Hey everyone. Vitalik's a pretty tough act to follow, so bear with me. But yeah, I'm Alan. I'm a protocol engineer at Uniswap, and it's great to be back here. I've given previous talks in the past about UniswapX, auction design, and the protocol itself. But today I wanted to talk about something that isn't shown as much, and it's the UniswapX RFQ, and specifically what it's like to be a market maker in that protocol. So today we're going to be following a trade through the system and seeing how market makers work in UniswapX and how they fill trades for swappers.
第一件事:UniswapX 用的是意圖。一般 AMM 兌換會先有路由演算法,找出一串池子讓你走,再由兌換者自己帶 calldata 上鏈執行。UniswapX 則是兌換者在鏈下簽名一則訊息,描述自己想做的交易,例如最低數量與截止時間。這就叫意圖。他們其實不在乎走哪條路徑。成交方,也就是我們說的做市商,要自己想辦法滿足這筆交易,再把交易送到鏈上結算。因為送交易的人是成交方,UniswapX 對兌換者來說等於免 gas。First thing is UniswapX uses intents. So with a typical AMM swap, you're going to have some kind of routing algorithm that finds a path of pools for you to trade through. Then the swappers themselves are going to use the calldata and then execute it on-chain. With UniswapX instead, the swapper would sign a message off-chain describing the trade that they want. So it looks something like a minimum amount and a deadline on the trade. That's called an intent. So they ultimately don't care what path it takes. The filler, which is the person that we're calling the market maker, is going to figure out how to satisfy that trade and send the transaction on-chain to settle it. Because the filler is the one who's sending the transaction, UniswapX swaps are effectively gasless for swappers.
意圖交易是一種通用模式:它只說使用者要什麼結果、必須滿足什麼條件,不一定規定價格怎麼發現。後面可以接不同機制,包括 RFQ、荷蘭式拍賣,或 MEV 稅,去年那場就是講 MEV 稅。今天聚焦 RFQ,更精確地說,是做市商怎麼跟這套協議互動。它跟其他拍賣不太一樣,因為有很大一塊在鏈下,等等會講。先看 RFQ 能做什麼。AMM 流動性是跟區塊更新的,區塊與區塊之間,池子狀態停在原地,市場價格其實還在動。Intent-based trading is a general pattern, but it says what outcome the user wants and what conditions must be met, but it doesn't necessarily specify anything about price discovery. So we can put different mechanisms behind it, which includes an RFQ, a Dutch auction, or a MEV tax, which is what my talk last year was about. Today we're going to be focusing on the RFQ, and more specifically, what it's like to be a market maker that interacts with that protocol. This one's a little bit special because it's pretty distinct from the other auction mechanisms because it has a significant off-chain component that we'll be discussing today. So let's start with what an RFQ allows us to do. So AMM liquidity gets updated in blocks, and during the time between the blocks, the state of the pools is staying the same, even though the market price is actually changing.
你拿來報價的同一條 AMM 路徑,會經過同一份狀態,給出同一套過期價格,市場卻還在走,只因為出塊時間。這在主網特別明顯,因為出塊比較慢。我們可以在鏈下連續跑 RFQ,不必等下一個區塊,價格發現可以更細。交易最後還是在鏈上結算,只是定價不必在鏈上做。可以把市價想成連續過程,AMM 路由只是在看離散快照。有了 RFQ,就不必把價格發現鎖在那些瞬間。The same AMM route that you might be quoting through is going to go through the same state and give you the same stale price while the market is still moving, just because of the block time. And this is particularly pronounced on mainnet because of the long block times. What we can do is run RFQs off-chain, which we can do continuously instead of needing to wait for a block. And this is going to give us finer-grained price discovery. So we ultimately are still going to settle the trade on-chain, but we just don't need to do the pricing part on-chain. So think of a market price like a continuous process, and AMM routing is just looking at discrete snapshots of that. With an RFQ, we won't need to restrict ourselves to price discovery in those moments.
RFQ:鏈下發現價格,鏈上執行
這就是 RFQ 模式。價格在鏈下發現,談好的交易在鏈上執行。做市商可以在區塊之間回傳新鮮報價。交易準備好之後,RFQ 贏家負責把交易送到鏈上,在下一個區塊執行。這樣既能在鏈下拿到新價格,又能用智能合約在鏈上強制執行。講具體一點,來看這個系統裡一筆 RFQ 報價長什麼樣子。假設兌換者要賣 1 顆 ETH 換 USDC,畫面上看到的 RFQ 報價是 2,990。我說的報價就是這個意思。So that's the RFQ pattern. Basically, we discover the price off-chain and then execute the agreed trade on-chain. And this is going to allow market makers to return fresh offers between blocks. And once the trade is ready, the winner of the RFQ is responsible for sending the transaction on-chain to execute it in the next block. This way, we get fresh off-chain price discovery while also using smart contracts on-chain to enforce the trades. To make this more concrete, let's look at what an RFQ quote actually looks like in this system. So let's say a swapper wants to sell one ETH for USDC. The RFQ quote they see is 2,990. And that's what I mean by a quote here.
也就是做市商願意用多少 USDC,跟兌換者換 1 顆 ETH。這個階段還不是交易,還在鏈下,只是他們報出來的價格。價格從哪來?兌換者的請求會進到 UniswapX 的鏈下 RFQ 系統,再送到一組做市商。做市商一報 2,980;做市商二,也就是今天的例子,報 2,990;假設第三家選擇不報。最好的報價勝出,所以最後是 2,990。這是盲式第一價格拍賣。其他做市商看不到別人報多少,集合裡最高的那筆會被選成報價。It's the amount of USDC a market maker is willing to offer the swapper for one ETH. And that's not a transaction yet at this stage. This is still off-chain. This is still off-chain. This is just the price that they're naming. So where did that price come from? It starts like this. The swapper's request is going to reach the UniswapX off-chain RFQ system. And then it's sent to a set of market makers. So market maker one quotes 2,980. Market maker two, which is going to serve as the example today, offers 2,990. And then let's say a third market maker chooses not to quote. And the best quote wins in this, which is why 2,990 is ultimately the quote. So this is a blind first-price auction. So the other market makers can't see what the other people are quoting, and the highest price of that set is going to be selected as the quote.
放大看一家做市商自己那邊。每家都會收到一筆交易請求,這裡是主網上 1 顆 ETH 換 USDC。他們必須在 500 毫秒內回報價,或回一種叫 no-quote 的回應。這很重要,因為要分得出成交方還活著、有在參與,還是逾時、可能壞掉了。有回報的人裡面,最好的那筆會回到兌換者面前。兌換者覺得可以,就簽一則訊息表示要吃這筆,用的是 Permit2。Let's zoom in to one of the market makers to see what it looks like from their end. So each market maker is going to receive a request for a trade. Here it's one ETH to USDC on mainnet. And within 500 milliseconds, they have to respond to the system with a quote or respond with something called a no-quote. And this is important because this is distinguishing the case of the filler being alive and participating versus, like, timing out and potentially being broken. Then the best quote among all the makers who do this is going to go back to the swapper as a quote. If the swapper likes what they see, then they can sign a message saying that they want to take that trade, and that uses Permit2.
到這個階段,做市商就要負責在下一個區塊把這筆交易執行上鏈。簡單流程是:先有報價,兌換者喜歡就簽名,成交方在下一個區塊幫他上鏈執行。問題是兌換者可能停一下,可能要接硬體錢包,或就是慢。他們錢包裡正在簽的,可能是稍早看到的舊價格。不能因為訊息晚送到,就強迫做市商認舊價。所以簽名之後還要再報一次,執行前拿到新價格。我們把前面那次叫軟報價,後面這次叫硬報價。And now at this stage, the market maker is going to be responsible for executing this trade on-chain in the next block. So that's the simple flow. You have a quote, the swapper likes it, they'll sign it, and then the filler is going to execute it on-chain for them in the next block. But the issue is the swapper might pause, or they might need to connect a hardware wallet, or they just might be slow. So a price that they saw before that they're signing in their wallet might be old. And then they shouldn't be able to force the market maker to honor some old price just because they sent the message later. So we need to add a second quote after the signature to get a fresh price right before execution. And so we call this the soft quote and the hard quote.
硬報價定最終價格,沒成交就進荷蘭式拍賣
最終交易參數就是以這次為準,再疊上使用者 Permit2 訊息裡簽好的限制。串起來是:兌換、軟報價、使用者簽名、硬報價,這些都在鏈下。硬報價給出最終價格與成交方,也就是 RFQ 贏家,這個人應該在下一個區塊把交易成交上鏈。如果沒做,訂單會掉進開放的荷蘭式後備,也就是鏈上跑一場無需許可的荷蘭式拍賣。後果稍後再講。先從做市商視角把這個例子走完。And this is what the final trade parameters are based on, with the user's signed constraints in their Permit2 message. So putting that together, we have the swap, soft quote, the user signing, and then a hard quote, and then all these actions happen off-chain. Once the hard quote gives us the final trade with the final price and the filler, who is the RFQ winner, that person is supposed to fill the trade on-chain in the next block. If they don't do it, then the order will go into an open Dutch fallback, which is just running a permissionless Dutch auction on-chain. We'll talk about the consequences of that later, but we can continue this example from the market maker's perspective.
假設我們是做市商二,在這輪新鮮硬報價以 2,990 USDC 贏了,現在是被選中的成交方。我們要在下一個區塊送一筆交易,把 USDC 交給兌換者,換他的 ETH。先不講 2,990 怎麼算出來,先看執行交易要做什麼。我們看到兩大家族。一種用鏈上流動性:同一筆交易裡收下兌換者的 1 顆 ETH,拿去走一串池子,設法換到比要付給對方更多的錢。他們想從這顆 ETH 拿到超過 2,990,把 2,990 給兌換者,剩下當毛利。So imagine we're market maker two, and then we win this fresh hard quote round with 2,990 USDC. Now we're the selected filler. We need to send a transaction in the next block that delivers the USDC to the swapper in exchange for their ETH. Before we go into how they came up with 2,990, let's actually just look at what they need to do to execute the transaction. So there's two broad families of market makers that we see. One is using on-chain liquidity. This is like they would take the one ETH from the swapper in a transaction, they'll route it through a bunch of pools, and then try to get more than what they need to pay. They want to get more than 2,990 from the ETH, and then 2,990 goes to the swapper, and then they can keep the rest of the money as their gross profit.
第二種是用庫存:做市商用自己的餘額付款,再自己處理曝險。無論是抱著曝險、再平衡還是對沖,這比較接近一般做市。今天走的就是這個例子。走庫存策略,做市商需要鏈上元件,我們叫它執行合約。這份合約在鏈上持有做市商庫存,用來服務兌換者的交易。如果我們是做市商,會送一筆交易到自己的執行合約。The second approach is using inventory, and this is where the market maker is going to pay from their own balances and handle that exposure. So whether it's like carrying the exposure, rebalancing, and hedging, this follows general market making more closely. So this is the example we're going to go through today. For this inventory strategy, our market maker needs to have an on-chain component, which is a smart contract that we're going to call an executor contract. This is a contract that's going to hold the market maker's inventory on-chain so that they can service the trades of the swappers. So if we're the market maker, we're going to send a transaction to our executor contract.
執行合約會呼叫 UniswapX 合約,再 callback 回我們自己的合約,才能跑任意策略與安全檢查。例如交易進行到一半,用放在某些借貸協議裡的存款來履行,立刻提出來成交,再把所得放回借貸,沒在交易時也還能賺收益。UniswapX 智能合約就是鏈下報價與鏈上資產易手之間的橋。再來看這筆報價後面的整本庫存帳。重點是:持有庫存的智能合約,不是做市商資金唯一住的地方。Which is going to call the UniswapX contract, and then there's going to be a callback back into our own contract where we can have our own arbitrary strategies run and safety checks. Like one example could be if, in the middle of a transaction, we're going to fulfill the trade with deposits that we had in some lending protocols, so we can take that out immediately. Fulfill the trade and then put the proceeds back in lending, so we're earning yield even when we're not actually trading. So this UniswapX smart contract is the bridge between the off-chain quotes and the assets actually changing hands on-chain. So let's look at the rest of the inventory book behind that quote. The point is that the smart contract that holds the inventory isn't the only place our capital lives as a market maker.
報價要算整本書:幣安、鏈上與 Hyperliquid
我們在幣安也可能有現貨庫存,或在 Hyperliquid 上用抵押品撐著永續對沖。最終要為整本書定價,包括資金能用在哪裡,也要算到資金可能拆在幣安、鏈上,還有 Hyperliquid 的抵押。這很重要,因為場地之間轉帳要時間、要手續費,還有搬運的工夫。Hyperliquid 上的抵押也有機會成本,錢放在那裡,還要算資金費率,可能幫你也可能害你。報價時這些都要算進去。We might also have spot inventory on Binance, or we might have collateral supporting some kind of perp hedge on Hyperliquid. So ultimately, we need to price the whole book, including where we can use that capital. And accounting for the fact that our capital might be split up on Binance and on-chain and having collateral on Hyperliquid. And this is important because transfers between these venues are going to take time, they're going to take fees, and then we also have to do the work of it. The collateral on Hyperliquid also has an opportunity cost, right? If it's sitting there, and also needing to account for the funding rates on those, which could help us or hurt us. So we need to account for all of these things when we quote.
報價前要先想接下這筆的成本與曝險,也要想報價能拿到什麼優勢,也就是這筆交易的期望價值。經濟帳要算得過來。最後顯然也要有鏈上資金,才能把錢交到兌換者手上。把它變成真正的報價。兌換者要賣 1 顆 ETH,我們向他買。該出多少 USDC?好起點是有一個參考價,某種模型或餵價,告訴我們公允價值大概在哪。這只是起點,不是該報出去的價格。So before we quote, we need to think about the cost and the risk of exposure from taking on the trade. We also need to think about what edge we get from quoting, which is the value we expect from the trade. And these economics need to work out for us. And we also ultimately obviously need to have the capital on-chain to deliver the funds to the swapper. Let's turn this into an actual quote. So the swapper wants to sell one ETH. We're going to buy it from them. How much USDC should we offer? A good starting point is like having some kind of reference price, which is some kind of model or feed that gives us an idea of fair value. This is just a starting point, and it's not what we should quote.
該想的是價差:願意買的價、願意賣的價。需要多寬?先看價差寬度。執行很貴或不確定性很高,價差可能要拉大;執行更好或對沖更便宜,就可以報得更緊。價差基本上要撐得住贏下這筆的成本與風險,也會影響你跟其他做市商怎麼比。這只是簡單的對稱例子,真實政策可能更複雜。第二件是價差要放在哪裡。要考慮資金在不同場地之間移動,因為幣安上的 1 顆 ETH,跟主網上的 1 顆 ETH,或 Hyperliquid 上多 1 顆 ETH 的曝險,價值並不完全一樣。How we should think about it is in terms of a spread, which is a price we're willing to buy at and a price we're willing to sell at. So how much spread do we need? First, we want to think about the width of our spread. If the execution is expensive or there's a lot of uncertainty, we may need a larger spread. If we have better execution or cheaper hedging, then we can quote more tightly. The spread basically has to support the costs and the risks of winning the trade. It also affects how our offer is going to compare to the other market makers. And this is just a simple symmetric example, but the actual, like, real-life policy may be more complex. The second thing to think about is the centering of the spread. We need to think about the movement of capital between our different venues, and this is because one ETH on Binance is not worth exactly the same as one ETH on mainnet or plus one ETH of exposure on Hyperliquid.
所以要算進抱著這份曝險、以及在場地之間搬倉的成本,這是結構性基差那一塊。另外,我們可能想累積或減少曝險,把庫存調平衡,才能兩邊單都能接。結構性基差之上,庫存管理策略也會讓報價偏一邊。舉例:移動價差。假設帳上已經偏多 ETH。這個例子裡可以把價差下移,使用者賣 ETH 給我們時,我們買得比較不積極,因為已經偏多,更不想再更偏多。So we need to account for the cost of carrying that exposure and moving positions between these different venues, and that's the structural basis part of the problem. Separately, we might want to accumulate or reduce exposure to balance the inventory so that we can service both sides of a trade. So, on top of the structural basis, the inventory management strategy also can bias our quotes. Here's an example of that. One example is shifting the spread. So imagine that our book is long ETH. In this example, we can shift our spread down so that when a user sells ETH to us, we bid less because we're less competitive about going even more long if we're already long.
用未來單流再平衡,對沖不是免費的
如果使用者要向我們買 ETH,我們可以賣便宜一點,因為更想把曝險往中性收。想法是:未來的單流可以幫我們再平衡,不必每次都對沖、每次都付成本。但這顯然是統計上的,沒有保證。要考慮未來會進來什麼單流,以及非中性部位我們願意抱多久。外部對沖是另一個工具,但不是沒成本,也要做事。可以立刻在幣安賣掉現貨,但那會穿越價差、付手續費。And if a user wants to buy ETH from us, we can offer it for less because we're more keen and competitive about reducing our exposure to be a little bit more neutral. So, the idea is that future order flow can help us rebalance instead of needing to hedge every single time and incur the costs of that. But this is obviously statistical. It's not guaranteed. We need to account for, like, what order flow is going to come in the future and how long we're comfortable holding risk in a non-neutral position. External hedging is the other tool, but as I'm alluding to, it's not costless and it requires work. We can sell existing spot on Binance right away, but that's going to have us cross the spread and pay fees.
或者掛限價單,但限價單不保證成交。也可以只對沖一部分,慢慢分批對沖。即使做了現貨對沖、帳面已經 delta 中性,結果可能是鏈上只剩 ETH、幣安只剩 USDC,還是得再平衡。還是要把資金在場地之間搬,要算提現、手續費與延遲,因為那會影響你能報什麼。永續則改成管理抵押與資金費率。做這些時全部都要算進去,庫存與對沖沒有單一標準答案。Or we might leave a limit order, but a limit order isn't guaranteed to fill. Or we can just hedge part of the exposure. We can, like, hedge it over time gradually, and ultimately, even if we have a spot hedge and our book is now delta-neutral, it might result in us only having ETH on-chain and only having USDC on Binance and then needing to rebalance that. So we still have to move capital between the venues, and we have to account for withdrawals, fees, and delays, because that can affect what we're able to quote. And for perps, we're going to have to manage the collateral and the funding rates instead. So when we do this, we have to account for all of these things, and there is no single answer for how you should be managing inventory and hedging.
我們不知道每家做市商在做什麼。每家有自己的策略。我講的都只是可能與想法,不是人人在跟的藍圖。用一個簡單例子串起來:我們會圍繞目標庫存做持倉與報價偏移,偏離之後開始對沖,到某個點就不再往那個方向加曝險,那些方向也不再報價。參數會依量測或門檻來定。再做一個練習。假設請求不再是 1 顆 ETH,而是 100 顆。第一反應可能是價格一定更差,因為曝險更大、更難對沖。We don't know what every market maker is doing. Everyone has their own strategies. Everything I've discussed is just possibilities and ideas, not a blueprint that everybody's following. A simple example to tie it together is we're going to do a carry and a quote skew around some kind of target inventory, and then as we deviate from that, we're going to start hedging, and then maybe at a certain point, we'll just stop gaining more exposure in a certain direction and not quote trades in those directions anymore. And all the parameters for that would just be based on measurements or certain thresholds. Now let's do another exercise. Imagine the request wasn't one ETH anymore, but it's now 100 ETH. At first, this might sound like we're going to give a strictly worse price because it's more exposure and it's going to be harder to hedge.
這條曲線會呈現那個直覺。但它只是孤立地看這一筆。要更整本地看這筆交易對當前帳本意味什麼,才能下「更大就一定更差」的結論。我的意思是:假設帳上已經多 20 顆 ETH,成交後會變成多 120。另一個世界裡我們空 90 顆 ETH,吃下這筆會變成多 10 顆。贏下這筆會讓帳本更接近中性。我們更有理由想要這張單,也比較願意把一部分價值回饋成更好的價格。And the curve here is going to show that; it's capturing that intuition. But that only looks at this order in isolation. We need to take a more holistic view on what this trade means in the context of our current book before concluding that bigger just necessarily means worse. So here's what I mean by that. Imagine we had our book with plus 20 ETH of exposure. After the trade, it's going to be even greater at plus 120. And then imagine another world where we're 90 ETH short, and then taking this trade is going to bring us to plus 10 ETH of exposure. So winning this trade would bring the book closer to neutral for us. So we have more of a reason to want this order and then pass some of that value back as a better price.
同一張單,不同做市商報價可以差很多
所以右邊這本特定的帳,這筆 100 ETH 同時幫我們解了曝險問題。同一筆請求,不同做市商的回應可以差很多。合起來看,我們其實是在做某種定價曲面,用來決定一筆交易該報多少。這只是示意,不是人人在用的公式。基本上被問到價格時,就是要給出一個價格。模型會有規則、統計與各種調整。回到例子,現在比較清楚報價要做多少工,以及數字從哪來。So for this specific book on the right, this trade of 100 ETH will simultaneously solve an exposure problem for us. And that's why the same request might get really different responses from different market makers. So bringing it all together, we're effectively just creating some kind of pricing surface that helps us decide how much to quote for a trade. And this is just an illustration. This is not a formula everyone is using. But basically, we just need to come up with a price when we're asked to give one. And we'll have a model with rules, statistics, and whatever optimizations. So going back to the example, now we understand the work of what it takes to quote and the number behind what we're quoting.
假設硬報價贏了,要問這到底好不好。贏了也許是因為我們真的有優勢,但要想為什麼贏過其他做市商。為什麼做市商一報得比我們低?這就碰到贏家詛咒與逆選擇。稍早看過,同一筆交易對某家做市商可以真的比較值錢,但還是要問:別人為什麼給更差的價格?他們知道什麼嗎?兌換者是否知道我們不知道的事?這就是逆選擇。判斷錯了,反而可能讓你贏到,而贏並不總是好兆頭。Assuming that our hard quote won, we want to ask the question of if that's good. We won maybe because we actually have an advantage, but we have to think about why we beat the other market makers. Why did market maker one quote less than we did? And that gets into the idea of winner's curse and adverse selection. So we saw earlier how the same trade can be genuinely worth more to one market maker than another, but we have to think about why the other market makers gave worse prices. Do they know something? Does the swapper know something that we don't? This is just adverse selection, and being wrong could make us actually win, which could actually have consequences, because winning isn't always a good sign.
報價怎麼做、贏代表什麼,都想過了。現在還是要把交易執行並對沖。要把成交交易送上鏈並成功執行。我們會讀訂單,組一筆從執行智能合約出發的交易,那份合約再呼叫 UniswapX 合約;callback 回到我們合約時,可以做需要的鏈上策略與安全檢查,再由 UniswapX 合約完成結算。因為送交易的人是做市商,gas 也要自己算。So we thought through how we quote and what winning is telling us. At this point, we still need to execute the trade and hedge, so let's see what that looks like. Now we need to get the fill transaction on-chain and successfully executed. So what we're going to do is we're going to read the order, and then we're going to build our transaction that starts in our executor smart contract, and then that contract is going to call into the UniswapX contract, and then when the callback reaches our contract, we can do whatever on-chain strategies and safety checks that we need to do, and the UniswapX contract will finish the settlement of the trade. Because we're the person sending the transaction as a market maker, we have to account for gas.
所以 gas 成本也要反映在定價裡。還要處理討厭的事,例如重組,尤其在對沖時。講到對沖:假設成交時買進了那 1 顆 ETH,現在要對沖。是不是只要在別的地方做反向就好?比這難一點。鏈上交易是原子的,鏈下對沖跟它並不是原子綁在一起。報價用的對沖估計,是報價前看到的狀態,等到贏了,估計可能已經過期。下一題是:要不要在交易前對沖?交易失敗的話,對沖部位還是抱在手上。若交易後才對沖,走到那一步時成本可能已經變了。And so the cost of gas also needs to be reflected in our pricing. We also need to account for annoying things like reorgs, especially if we're hedging. So speaking of hedging, say we bought the one ETH on the fill. Now we need to hedge that. Is it as simple as just taking the opposite side of the trade somewhere else? It's a little harder than that because even though the on-chain transaction is atomic, our hedging off-chain is not atomic with that because our quote used a hedge estimate that was based on whatever we saw before we quoted, and by the time we win, that estimate might already be stale. And the next thing we think about is, should we hedge before the trade, where, like, if we fail the trade, we're still stuck with the exposure on the hedge, or if we decide to hedge after the trade, the cost of that hedging might have changed by the time we get there.
成交方有 last look,fade 太多會被斷路
這些風險都要進報價。對沖本身是很大的領域,這些只是做市商在 UniswapX 上可能會想的例子。接著有一個重要問題。做市商、成交方,最終是送交易上鏈的人。在把交易送上鏈之前的第二段空檔,他們可以繼續看盤。市場對自己不利時,如果直接食言、不送上鏈,有誰能阻止?沒有後果的話,這對他們是免費選擇權。So these are risks that need to be accounted for in our quotes. And obviously, hedging is a very, very big space, and these are just some example thoughts of what a market maker might be thinking about when they're doing it for UniswapX. Moving on, there's, like, an important question that pops up when we think about this interaction. So the market maker, the filler, is ultimately the person sending the transaction on-chain. So there's something else in this second interval where, before submitting the transaction on-chain, they can keep watching the market. And if the market moves against them, what if they just break their promise and then they don't send the transaction on-chain? What stops them from doing that? Because without consequences, this is a free option for them.
以接下來 10 秒、下一個區塊之前為例:市場對他們有利就成交;對他們不利就可以食言、不成交。誰有 last look,誰就有這個選擇權。UniswapX 裡有 last look 的是成交方、做市商,所以這個風險存在。還有另一種失敗模式:成交方報得非常好,兌換者每次都接受,做市商卻從不在鏈上交割。所以即使 RFQ 裡已經承諾,退出成交也必須有成本。我們把未能結算一筆交易叫做 fade。In the 10-second example before the next block, if the market moves favorably for them, they can fill it. And then if it moves adversely to them, they can just, like, break their promise and not fill it. So this is generally an option for whoever has last look. And in UniswapX, the filler or the market maker is the one with last look, and that's why this risk exists. There can be another failure mode where it's, like, the filler is just quoting really good quotes, and the swapper always accepts it, but then the market maker never actually delivers it on-chain. So this is why backing out of filling, even though you made a promise and commitment in the RFQ, needs some kind of cost to it. When we see a failure to settle a trade, we call that a fade.
fade 太多,鏈下 RFQ 系統裡有斷路器:偵測到某家做市商 fade 太多次,就暫停把訂單流送給他。這是一種指數退避,用來抑制這種行為。暫停期間他們看不到新單流,也就沒機會成交那些單。所以真要決定 fade,要想的是:現在避開這筆省下多少錢或價值,對上暫停期間無法再吃未來單流的價值。從設計上看,我們希望這些報價對兌換者是承諾,使用體驗才好,所以做市商走人應該要付出某種成本。And if you fade too much, there is a circuit breaker mechanism in the off-chain RFQ system that basically will pause order flow to a market maker if it detects that it's fading too many trades. And this is a kind of exponential backoff to discourage this type of behavior. And then during this timeout, they're not going to be able to see new order flow and thus won't have the opportunity to fill those trades. So what they really need to think about if they want to decide to fade is, what is the amount of money or value they're saving by avoiding this trade right now, versus the value of being able to continue to capture future order flow in whatever timeout period it would cause them? So from a design perspective, we want to make sure these quotes are commitments to the swapper for good UX, and that's why walking away from them as a market maker should come with some form of cost.
用來做這些報價的東西,都假設了執行、庫存、單流、對沖,以及報價到真正結算之間的風險。這些假設不是靜態的,因為市場在變、兌換者在變。做市商競爭對手也愈來愈強,你也得變強。分析不是只看單一筆做得怎樣,而是持續學習。怎麼知道自己做得好不好?可以比對模型裡的優勢、成交後的 markout,以及對沖實際執行得怎樣。簡單例子:模型用 3,000 當參考價,我們報 2,990。So everything we use to make these quotes had some kind of assumptions about execution, inventory, order flow, hedging, and the risks between quoting and actual settlement time. So these assumptions aren't static because the markets are evolving, your swappers are evolving. The competition of your market makers, they're getting better, so you need to get better as well. So analytics isn't just about analyzing how you did on a single trade; it's about a more continuous learning process. So how do we know if we're doing well? Well, we can compare the edge we modeled, the markout after the trade, and then look at how our hedges executed. For the simple example, our model used a 3,000 reference price and we quoted 2,990.
模型優勢 10 塊、五秒 markout,八月成交約 8 億美元
這代表模型裡的優勢是 10。另一個常用指標是 markout:拿成交價跟一段時間後的市場參考價比。如果我們在 2,990 買進 1 顆 ETH,五秒後變成 2,980,五秒 markout 就是負 10。最後還要看實際對沖回報。假設成交後一秒,我們在對沖端以 3,000 賣掉那顆 ETH,要檢查成交價、時點與成本,是否跟報價時算的對得上。這會告訴我們對沖實現得如何。做市商需要某種分析,才能更新並改善。This implies that our modeled edge was 10. And then another commonly used metric is markout. So a markout compares our fill price with a market reference a certain amount of time later. So if we bought one ETH at 2,990, and then five seconds later it's at 2,980, the five-second markout is minus 10. And the last thing we should look at is the actual hedge receipt. So assuming that we sold that ETH at 3,000 on the hedge one second after the fill, we basically want to check if the price it executed at and the timing and costs actually aligned with what we expected and calculated when we made the quote. And this is going to tell us how well we realized our hedge. So a market maker needs some kind of analytics to update on and improve.
拉遠來看,這就是用庫存在 UniswapX 成交時,做市商可能要做的整張地圖。今天都有帶到,沒有挖到很深,只想給這片地貌一個概觀。平常講 RFQ 聽起來很單純、很直觀,水面下其實很多。最後把這套系統放回脈絡。你用 Uniswap 介面或 API 時,會同時踢出兩種報價。一是你熟悉的經典 AMM 路由,二是 RFQ 流程。系統會比較這兩筆,較好的那筆才提供給兌換者。And zooming out, this is the big picture of the things that a market maker might need to do when they're filling with inventory on UniswapX. So today we covered everything on here, not in super deep detail, but I just wanted to give a broad overview of this landscape. Because when we typically talk about an RFQ, it sounds like a simple concept and it feels straightforward, but clearly there's just so much beneath the surface. I want to end on putting this system in context. So when you use the Uniswap interface or API, it's going to kick off two different quotes. One is the classic AMM routing that you're familiar with, and then two, it's going to be the RFQ process. And then it's going to compare these two quotes, and then whichever is the better one, that's the one that's going to be offered to the swapper.
執行之前這些都在鏈下。放幾個數字:八月 UniswapX 處理了大約 8 億美元成交量,這個月均量大約 4,500 萬美元。想點出的是,我們看到 RFQ 在藍籌、甚至迷因幣上都有貢獻,最近代幣化資產、RWA 起來之後也是。今天講了很多,謝謝聆聽。現在可以提問。謝謝。So all of that prior to execution is happening off-chain. And just to put some numbers on this, in August, UniswapX handled about $800 million of volume, and then this month we've been averaging about $45 million of volume. So something cool I want to point out is that we've seen the RFQ provide value across blue chips and even meme coins, and lately, tokenized assets with the rise of RWAs. I know we went through a lot of things today, but thank you for listening. I'm happy to take any questions now. Thank you.