{"eip":8017,"title":"Payout Race","description":"Minimal ERC for a single-asset payout bucket that vends its entire balance for a fixed payment amount.","authors":["Kyle Thornton (@kyle) \u003ckyle@cowrie.io\u003e"],"status":"Draft","type":"Standards Track","category":"ERC","created":"2025-08-31","requires":[20],"discussionsTo":"https://ethereum-magicians.org/t/erc-8017-payout-race/25311","repo":"ERCs","label":"ERC-8017","officialUrl":"https://eips.ethereum.org/EIPS/eip-8017","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-8017.md","url":"https://eips.huatuo.xyz/eip-8017/","tldr":{"en":"A draft minimal interface for a 'payout race': a contract that accumulates one asset and hands its entire balance to the first caller who pays a fixed price in another asset, useful for revenue buybacks.","ja":"「ペイアウトレース」のための最小限インターフェースのドラフト。ある資産を蓄積し、別の資産で固定価格を支払った最初の呼び出し元に残高全体を渡すコントラクトで、収益によるバイバックなどに使える。","ko":"\"페이아웃 레이스\"를 위한 최소 인터페이스 초안. 한 자산을 쌓아 두었다가, 다른 자산으로 고정 가격을 지불한 첫 호출자에게 잔액 전부를 넘기는 컨트랙트로, 수익을 이용한 바이백 등에 쓸 수 있다.","zh":"“支付竞赛”最小接口的草案：合约累积一种资产，并把全部余额交给第一个用另一种资产支付固定价格的调用者，适用于收入回购等场景。"},"tags":["defi","auction","buyback","erc20","erc"],"explainers":{"en":{"lang":"en","tldr":"A draft minimal interface for a 'payout race': a contract that accumulates one asset and hands its entire balance to the first caller who pays a fixed price in another asset, useful for revenue buybacks.","tags":["defi","auction","buyback","erc20","erc"],"related":[20,2612,173],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-8017/","markdown":"## What problem does it solve?\n\nProtocols often need to keep converting a stream of income (fees, revenue) into another asset: buying back their own token, building a reserve, funding incentives. Routing that through an AMM exposes them to slippage, pool liquidity and fees; running continuous on-chain auctions is complex and gas-heavy.\n\nERC-8017 standardises a simpler primitive inspired by the Uniswap Foundation's Unistaker proposal. Value flows into a **bucket**. Anyone may pay a fixed **required payment** to take the **whole** bucket. As the bucket grows, it eventually becomes profitable to buy, so searchers compete to be first, which works somewhat like a Dutch auction.\n\n## How it works\n\nEach contract is configured with:\n\n- `payoutAsset`: what the bucket holds (ETH if `address(0)`, else one ERC-20);\n- `desiredAsset`: what buyers pay (ETH if `address(0)`, else one ERC-20);\n- `requiredPayment`: fixed price, adjustable by an admin;\n- `paymentSink`: where payments go (treasury, splitter, burn).\n\nRules:\n\n1. Payout and desired asset **cannot both be ETH**, and neither may change after initialization.\n2. `purchase(to)` reads the payout balance **at entry**, reverts if it is zero, collects exactly `requiredPayment` (as `msg.value` for ETH, or `transferFrom(msg.sender, paymentSink, requiredPayment)` for ERC-20), then sends the full captured balance to `to` and emits `Purchased`.\n3. Admin setters for `requiredPayment` and `paymentSink` must be access-controlled and emit `PaymentConfigUpdated`.\n\nOptional extras: `purchaseWithPermit` using [ERC-2612](/eip-2612/), and an admin `rescue` for assets other than the payout asset.\n\n## Sample code\n\nA searcher checking whether a race is worth winning, then buying (ethers v6):\n\n```ts\nimport { Contract, ZeroAddress } from \"ethers\";\n\nconst race = new Contract(RACE, [\n  \"function payoutAsset() view returns (address)\",\n  \"function desiredAsset() view returns (address)\",\n  \"function requiredPayment() view returns (uint256)\",\n  \"function purchase(address to) payable returns (uint256)\",\n], signer);\n\nconst [payout, desired, price] = await Promise.all([\n  race.payoutAsset(), race.desiredAsset(), race.requiredPayment(),\n]);\nconst bucket = payout === ZeroAddress\n  ? await provider.getBalance(RACE)\n  : await new Contract(payout, [\"function balanceOf(address) view returns (uint256)\"], provider)\n      .balanceOf(RACE);\n\nif (isProfitable(bucket, price)) {            // your own pricing logic\n  if (desired === ZeroAddress) {\n    await race.purchase(myAddress, { value: price });\n  } else {\n    // approve `price` of `desired` to RACE first (or use a permit helper)\n    await race.purchase(myAddress);\n  }\n}\n```\n\n## Things to know\n\n- **Status: Draft.**\n- Works best when value trickles in. A large single deposit can push the bucket well past the price and hand the surplus to whoever buys first. If the payout asset rises in value relative to the payment asset, purchases may stall.\n- Changing `requiredPayment` is risky: lowering it can give an instant bargain to searchers; raising it can strand bots. The spec suggests timelocks, announcement windows, cooldowns or TWAP-based adjustments.\n- Anything sent to the contract in the payout asset, including unsolicited transfers, goes out with the next payout.\n- Buyers race in the mempool, so expect MEV competition. The interface has no slippage parameter; a buyer cannot specify a minimum payout amount.\n- Access control is left open; [EIP-173](/eip-173/) ownership is used in the reference. The spec's reference contract has a small naming typo (`payoutToken` in `receive`) and should not be deployed as-is.\n"},"ja":{"lang":"ja","tldr":"「ペイアウトレース」のための最小限インターフェースのドラフト。ある資産を蓄積し、別の資産で固定価格を支払った最初の呼び出し元に残高全体を渡すコントラクトで、収益によるバイバックなどに使える。","tags":["defi","auction","buyback","erc20","erc"],"related":[20,2612,173],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-8017/","markdown":"## 何を解決するのか\n\nプロトコルは、収入（手数料や収益）の流れを別の資産に変換し続ける必要がしばしばあります。自社トークンのバイバック、準備金の積み立て、インセンティブの原資などです。これを AMM 経由で行うと、スリッページ、プールの流動性、手数料にさらされます。継続的なオンチェーンオークションを回すのは複雑で、ガスも重くなります。\n\nERC-8017 は、Uniswap Foundation の Unistaker 提案に着想を得た、よりシンプルなプリミティブを標準化します。価値は**バケット**に流れ込みます。誰でも固定の**必要支払額**を支払えば、バケットの**全額**を受け取れます。バケットが大きくなるにつれ、いずれ購入が採算に合うようになるため、サーチャーが先を争います。これはダッチオークションに少し似た動きをします。\n\n## 仕組み\n\n各コントラクトには次が設定されます。\n\n- `payoutAsset`: バケットが保持する資産（`address(0)` なら ETH、それ以外は 1 つの ERC-20）\n- `desiredAsset`: 購入者が支払う資産（`address(0)` なら ETH、それ以外は 1 つの ERC-20）\n- `requiredPayment`: 固定価格。管理者が調整可能\n- `paymentSink`: 支払いの送り先（トレジャリー、スプリッター、バーン）\n\nルール:\n\n1. ペイアウト資産と希望資産が**両方とも ETH であってはならず**、どちらも初期化後に変更できません。\n2. `purchase(to)` は**エントリ時点**のペイアウト残高を読み取り、ゼロならリバートし、ちょうど `requiredPayment` を回収し（ETH なら `msg.value`、ERC-20 なら `transferFrom(msg.sender, paymentSink, requiredPayment)`）、取得した残高全額を `to` に送り、`Purchased` を emit します。\n3. `requiredPayment` と `paymentSink` の管理者用セッターはアクセス制御が必須で、`PaymentConfigUpdated` を emit しなければなりません。\n\n任意の拡張として、[ERC-2612](/eip-2612/) を使う `purchaseWithPermit` と、ペイアウト資産以外の資産に対する管理者用の `rescue` があります。\n\n## サンプルコード\n\nサーチャーが、そのレースに勝つ価値があるかを確認してから購入する例（ethers v6）:\n\n```ts\nimport { Contract, ZeroAddress } from \"ethers\";\n\nconst race = new Contract(RACE, [\n  \"function payoutAsset() view returns (address)\",\n  \"function desiredAsset() view returns (address)\",\n  \"function requiredPayment() view returns (uint256)\",\n  \"function purchase(address to) payable returns (uint256)\",\n], signer);\n\nconst [payout, desired, price] = await Promise.all([\n  race.payoutAsset(), race.desiredAsset(), race.requiredPayment(),\n]);\nconst bucket = payout === ZeroAddress\n  ? await provider.getBalance(RACE)\n  : await new Contract(payout, [\"function balanceOf(address) view returns (uint256)\"], provider)\n      .balanceOf(RACE);\n\nif (isProfitable(bucket, price)) {            // your own pricing logic\n  if (desired === ZeroAddress) {\n    await race.purchase(myAddress, { value: price });\n  } else {\n    // approve `price` of `desired` to RACE first (or use a permit helper)\n    await race.purchase(myAddress);\n  }\n}\n```\n\n## 知っておくべきこと\n\n- **ステータス: Draft。**\n- 価値が少しずつ入ってくる場合に最もよく機能します。1 回の大きな入金でバケットが価格を大きく超えてしまうと、余剰分は最初に購入した人に渡ります。ペイアウト資産の価値が支払い資産に対して上がると、購入が滞ることがあります。\n- `requiredPayment` の変更にはリスクがあります。下げるとサーチャーに即座に割安な機会を与え、上げるとボットが取り残される可能性があります。仕様はタイムロック、告知期間、クールダウン、TWAP に基づく調整を提案しています。\n- ペイアウト資産でコントラクトに送られたものは、頼まれていない送金も含めて、次のペイアウトで出ていきます。\n- 購入者はメンプールで競うため、MEV の競争が起こります。インターフェースにスリッページのパラメータはなく、購入者は最低ペイアウト額を指定できません。\n- アクセス制御は未規定です。リファレンスでは [EIP-173](/eip-173/) のオーナーシップを使っています。仕様のリファレンスコントラクトには小さな命名のタイプミス（`receive` 内の `payoutToken`）があり、そのままデプロイすべきではありません。\n"},"ko":{"lang":"ko","tldr":"\"페이아웃 레이스\"를 위한 최소 인터페이스 초안. 한 자산을 쌓아 두었다가, 다른 자산으로 고정 가격을 지불한 첫 호출자에게 잔액 전부를 넘기는 컨트랙트로, 수익을 이용한 바이백 등에 쓸 수 있다.","tags":["defi","auction","buyback","erc20","erc"],"related":[20,2612,173],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-8017/","markdown":"## 어떤 문제를 해결하나요?\n\n프로토콜은 수입(수수료, 매출)의 흐름을 다른 자산으로 계속 바꿔야 할 때가 많습니다. 자체 토큰 바이백, 준비금 적립, 인센티브 재원 마련 등입니다. 이를 AMM으로 처리하면 슬리피지, 풀 유동성, 수수료에 노출됩니다. 지속적인 온체인 경매를 운영하는 것은 복잡하고 가스도 많이 듭니다.\n\nERC-8017은 Uniswap Foundation의 Unistaker 제안에서 영감을 받은 더 단순한 프리미티브를 표준화합니다. 가치는 **버킷(bucket)**으로 흘러 들어갑니다. 누구나 고정된 **필수 지불액**을 내고 버킷 **전체**를 가져갈 수 있습니다. 버킷이 커지면 결국 구매가 이득이 되는 시점이 오고, 서처들이 먼저 사려고 경쟁합니다. 이는 어느 정도 더치 옥션처럼 동작합니다.\n\n## 어떻게 동작하나요?\n\n각 컨트랙트에는 다음이 설정됩니다.\n\n- `payoutAsset`: 버킷에 담기는 자산(`address(0)`이면 ETH, 아니면 ERC-20 하나)\n- `desiredAsset`: 구매자가 지불하는 자산(`address(0)`이면 ETH, 아니면 ERC-20 하나)\n- `requiredPayment`: 고정 가격, 관리자가 조정 가능\n- `paymentSink`: 지불금이 가는 곳(트레저리, 스플리터, 소각)\n\n규칙:\n\n1. 지급 자산과 희망 자산이 **둘 다 ETH일 수 없으며**, 둘 다 초기화 이후에는 바뀔 수 없습니다.\n2. `purchase(to)`는 **진입 시점**의 지급 자산 잔액을 읽고, 0이면 리버트하며, 정확히 `requiredPayment`만큼을 받은 뒤(ETH는 `msg.value`, ERC-20은 `transferFrom(msg.sender, paymentSink, requiredPayment)`), 읽어 둔 잔액 전체를 `to`에게 보내고 `Purchased`를 emit합니다.\n3. `requiredPayment`와 `paymentSink`의 관리자 setter는 접근 제어가 있어야 하며 `PaymentConfigUpdated`를 emit해야 합니다.\n\n선택 확장으로 [ERC-2612](/eip-2612/)를 사용하는 `purchaseWithPermit`과, 지급 자산 이외의 자산에 대한 관리자용 `rescue`가 있습니다.\n\n## 샘플 코드\n\n서처가 레이스에서 이길 가치가 있는지 확인한 뒤 구매하는 예(ethers v6):\n\n```ts\nimport { Contract, ZeroAddress } from \"ethers\";\n\nconst race = new Contract(RACE, [\n  \"function payoutAsset() view returns (address)\",\n  \"function desiredAsset() view returns (address)\",\n  \"function requiredPayment() view returns (uint256)\",\n  \"function purchase(address to) payable returns (uint256)\",\n], signer);\n\nconst [payout, desired, price] = await Promise.all([\n  race.payoutAsset(), race.desiredAsset(), race.requiredPayment(),\n]);\nconst bucket = payout === ZeroAddress\n  ? await provider.getBalance(RACE)\n  : await new Contract(payout, [\"function balanceOf(address) view returns (uint256)\"], provider)\n      .balanceOf(RACE);\n\nif (isProfitable(bucket, price)) {            // your own pricing logic\n  if (desired === ZeroAddress) {\n    await race.purchase(myAddress, { value: price });\n  } else {\n    // approve `price` of `desired` to RACE first (or use a permit helper)\n    await race.purchase(myAddress);\n  }\n}\n```\n\n## 알아둘 점\n\n- **상태: Draft.**\n- 가치가 조금씩 들어올 때 가장 잘 동작합니다. 한 번에 큰 금액이 입금되면 버킷이 가격을 훌쩍 넘어서고, 그 초과분은 가장 먼저 구매한 사람에게 넘어갑니다. 지급 자산의 가치가 지불 자산 대비 오르면 구매가 정체될 수 있습니다.\n- `requiredPayment`를 바꾸는 것은 위험합니다. 낮추면 서처에게 즉각적인 횡재를 줄 수 있고, 올리면 봇이 갇힐 수 있습니다. 스펙은 타임락, 공지 기간, 쿨다운, TWAP 기반 조정을 제안합니다.\n- 지급 자산으로 컨트랙트에 보내진 것은 요청하지 않은 전송을 포함해 모두 다음 지급 때 함께 나갑니다.\n- 구매자들은 멤풀에서 경쟁하므로 MEV 경쟁을 예상해야 합니다. 인터페이스에는 슬리피지 파라미터가 없어, 구매자가 최소 지급 금액을 지정할 수 없습니다.\n- 접근 제어는 열어 두었으며, 레퍼런스에서는 [EIP-173](/eip-173/) 소유권을 사용합니다. 스펙의 레퍼런스 컨트랙트에는 작은 이름 오타(`receive`의 `payoutToken`)가 있어 그대로 배포해서는 안 됩니다.\n"},"zh":{"lang":"zh","tldr":"“支付竞赛”最小接口的草案：合约累积一种资产，并把全部余额交给第一个用另一种资产支付固定价格的调用者，适用于收入回购等场景。","tags":["defi","auction","buyback","erc20","erc"],"related":[20,2612,173],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-8017/","markdown":"## 它解决什么问题？\n\n协议常常需要把持续的收入（手续费、营收）不断兑换成另一种资产：回购自己的代币、建立储备、资助激励。通过 AMM 来做会面临滑点、池子流动性和手续费；运行连续的链上拍卖则复杂且耗费大量 gas。\n\nERC-8017 受 Uniswap Foundation 的 Unistaker 提案启发，标准化了一个更简单的原语。价值流入一个**桶（bucket）**。任何人都可以支付固定的**所需付款**来取走**整个**桶。随着桶越来越满，购买最终会变得有利可图，于是搜索者争相抢先，这在一定程度上类似荷兰式拍卖。\n\n## 它如何运作\n\n每个合约配置如下：\n\n- `payoutAsset`：桶里装的资产（`address(0)` 表示 ETH，否则为某个 ERC-20）；\n- `desiredAsset`：买家支付的资产（`address(0)` 表示 ETH，否则为某个 ERC-20）；\n- `requiredPayment`：固定价格，管理员可调整；\n- `paymentSink`：付款的去向（金库、分账合约、销毁）。\n\n规则：\n\n1. 支付资产和期望资产**不能同时是 ETH**，并且初始化之后两者都不能更改。\n2. `purchase(to)` 在**入口处**读取支付资产余额，余额为零则回滚，收取恰好 `requiredPayment` 的款项（ETH 为 `msg.value`，ERC-20 为 `transferFrom(msg.sender, paymentSink, requiredPayment)`），然后把所捕获的全部余额发送给 `to`，并触发 `Purchased`。\n3. `requiredPayment` 和 `paymentSink` 的管理员 setter 必须有访问控制，并触发 `PaymentConfigUpdated`。\n\n可选的扩展：使用 [ERC-2612](/eip-2612/) 的 `purchaseWithPermit`，以及针对支付资产之外其他资产的管理员 `rescue`。\n\n## 示例代码\n\n搜索者先检查某场竞赛是否值得赢下，然后购买（ethers v6）：\n\n```ts\nimport { Contract, ZeroAddress } from \"ethers\";\n\nconst race = new Contract(RACE, [\n  \"function payoutAsset() view returns (address)\",\n  \"function desiredAsset() view returns (address)\",\n  \"function requiredPayment() view returns (uint256)\",\n  \"function purchase(address to) payable returns (uint256)\",\n], signer);\n\nconst [payout, desired, price] = await Promise.all([\n  race.payoutAsset(), race.desiredAsset(), race.requiredPayment(),\n]);\nconst bucket = payout === ZeroAddress\n  ? await provider.getBalance(RACE)\n  : await new Contract(payout, [\"function balanceOf(address) view returns (uint256)\"], provider)\n      .balanceOf(RACE);\n\nif (isProfitable(bucket, price)) {            // your own pricing logic\n  if (desired === ZeroAddress) {\n    await race.purchase(myAddress, { value: price });\n  } else {\n    // approve `price` of `desired` to RACE first (or use a permit helper)\n    await race.purchase(myAddress);\n  }\n}\n```\n\n## 需要注意\n\n- **状态：Draft。**\n- 在价值细水长流地流入时效果最好。一次性的大额存入可能把桶推到远高于价格的水平，并把盈余交给第一个购买的人。如果支付资产相对于购买所用资产升值，购买可能会停滞。\n- 修改 `requiredPayment` 有风险：调低会让搜索者立刻捡到便宜，调高则可能让机器人被搁浅。规范建议使用时间锁、公告窗口、冷却期或基于 TWAP 的调整。\n- 以支付资产形式发送到合约的任何东西，包括未经请求的转账，都会随下一次支付一并发出。\n- 买家在 mempool 中竞争，因此会有 MEV 竞争。接口中没有滑点参数；买家无法指定最低支付金额。\n- 访问控制未做规定；参考实现使用了 [EIP-173](/eip-173/) 所有权。规范的参考合约有一处小的命名笔误（`receive` 中的 `payoutToken`），不应原样部署。\n"}}}
