{"eip":7527,"title":"Token Bound Function Oracle AMM","description":"Interfaces that wrap FT to NFT and unwrap NFT to FT based on an embedded Function Oracle AMM","authors":["Elaine Zhang (@lanyinzly) \u003clz8aj@virginia.edu\u003e","Jerry \u003cjerrymindflow@gmail.com\u003e","Amandafanny \u003camandafanny200@gmail.com\u003e","Shouhao Wong (@wangshouh) \u003cwongshouhao@outlook.com\u003e","0xPoet \u003c0xpoets@gmail.com\u003e"],"status":"Draft","type":"Standards Track","category":"ERC","created":"2023-09-03","requires":[165,721],"discussionsTo":"https://ethereum-magicians.org/t/eip-7527-token-bound-function-oracle-amm-contract/15950","repo":"ERCs","label":"ERC-7527","officialUrl":"https://eips.ethereum.org/EIPS/eip-7527","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7527.md","url":"https://eips.huatuo.xyz/eip-7527/","tldr":{"en":"Lets anyone mint an NFT by depositing ETH or an ERC-20 at a price set by an on-chain formula, and burn it later to get the formula's current price back, giving NFTs built-in liquidity without external liquidity providers.","ja":"ETH または ERC-20 を預けることで、オンチェーンの数式で決まる価格で誰でも NFT をミントでき、後でバーンして数式の現在価格を受け取れる。外部の流動性提供者なしで、NFT に組み込みの流動性を与える。","ko":"누구나 ETH나 ERC-20을 예치해 온체인 공식이 정한 가격으로 NFT를 민팅하고, 나중에 소각해 공식의 현재 가격을 돌려받을 수 있다. 외부 유동성 공급자 없이 NFT에 내장된 유동성을 부여한다.","zh":"任何人都可以存入 ETH 或 ERC-20，按链上公式设定的价格铸造 NFT，之后再销毁它，按公式的当前价格取回资金，使 NFT 无需外部流动性提供者就拥有内置流动性。"},"tags":["nft","amm","liquidity","pricing","erc721"],"explainers":{"en":{"lang":"en","tldr":"Lets anyone mint an NFT by depositing ETH or an ERC-20 at a price set by an on-chain formula, and burn it later to get the formula's current price back, giving NFTs built-in liquidity without external liquidity providers.","tags":["nft","amm","liquidity","pricing","erc721"],"related":[721,20,5679,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7527/","markdown":"## What problem does it solve?\n\nNFTs are hard to sell quickly: each one needs a matching buyer, and pools that rely on outside liquidity providers become volatile when those providers withdraw.\n\nERC-7527 defines a \"Function Oracle AMM\" (FOAMM). The NFT contract itself always quotes a price from a fixed mathematical function. You **wrap** fungible currency into a newly minted [ERC-721](/eip-721/), and you can **unwrap** (burn) any NFT back into currency at the function's current price. No counterparty or LP is needed: the deposits of everyone who wrapped are the liquidity.\n\n## How it works\n\nTwo contracts are bound to each other:\n\n- **Agency**: the single entry point and holder of funds. Its `Asset` settings fix the `currency` (address 0 means ETH), a `basePremium`, a `feeRecipient`, and mint/burn fee percentages. It exposes:\n  - `getWrapOracle(data)` / `getUnwrapOracle(data)`: the \"function oracle\", returning `(premium, fee)` from a predefined formula. Other contracts, such as lenders, can call these to value the NFT.\n  - `wrap(to, data)`: takes premium + fee, sends the fee to `feeRecipient`, keeps the premium, and has the App mint an NFT.\n  - `unwrap(to, tokenId, data)`: has the App burn the NFT and pays out premium minus fee. Only the owner or an approved address may unwrap.\n- **App**: the ERC-721 contract. Its `mint` and `burn` must be restricted with `onlyAgency()`, so tokens can only be created or destroyed through the Agency.\n\nOnce initialized, the two are each other's only owner and are not upgradable, and the pricing strategy should not change. Premiums locked in the Agency can leave only via `unwrap`. An optional **Factory** (`deployWrap`) deploys matched Agency/App clones, calling each one's `iconstructor()` to validate the configuration.\n\nThe reference implementation uses a simple linear curve: `premium = basePremium + sold * basePremium / 100`, with fees in basis points of the premium. The price rises as more NFTs are outstanding and falls as they are burned.\n\n## Sample code\n\nReading a quote and wrapping with ETH (ethers v6). The `data` encoding is implementation-specific; here it carries the App's current `totalSupply()`, the input the reference curve uses.\n\n```ts\nimport { Contract, AbiCoder } from \"ethers\";\n\nconst agency = new Contract(agencyAddr, [\n  \"function getWrapOracle(bytes) view returns (uint256 premium, uint256 fee)\",\n  \"function wrap(address to, bytes data) payable returns (uint256)\",\n  \"function unwrap(address to, uint256 tokenId, bytes data) payable\",\n], signer);\n\n// `app` is a Contract for the bound ERC-721 App (exposes totalSupply())\nconst data = AbiCoder.defaultAbiCoder().encode([\"uint256\"], [await app.totalSupply()]);\nconst [premium, fee] = await agency.getWrapOracle(data);\nconst tx = await agency.wrap(await signer.getAddress(), data, { value: premium + fee });\nawait tx.wait();\n```\n\nCore shape of the Agency settings:\n\n```solidity\nstruct Asset {\n    address currency;        // 0 = ETH, otherwise an ERC-20\n    uint256 basePremium;\n    address feeRecipient;\n    uint16  mintFeePercent;  // basis points in the reference implementation\n    uint16  burnFeePercent;\n}\n```\n\n## Things to know\n\n- Status is **Draft**.\n- The App uses plain `mint` instead of `safeMint`, and `burn` has no `from` argument. The rationale explains these as deliberate departures from [ERC-5679](/eip-5679/).\n- Each Agency supports a single currency, either ETH or one [ERC-20](/eip-20/).\n- Security checklist from the spec: make sure `onlyAgency`/`onlyApp` are applied correctly, review the pricing function, guard against re-entrancy, and confirm that every NFT can actually be unwrapped at the formula price (the Agency must stay solvent).\n- On-chain inputs to the pricing function are recommended over off-chain ones.\n"},"ja":{"lang":"ja","tldr":"ETH または ERC-20 を預けることで、オンチェーンの数式で決まる価格で誰でも NFT をミントでき、後でバーンして数式の現在価格を受け取れる。外部の流動性提供者なしで、NFT に組み込みの流動性を与える。","tags":["nft","amm","liquidity","pricing","erc721"],"related":[721,20,5679,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7527/","markdown":"## 何を解決するのか\n\nNFT はすばやく売るのが困難です。1 つひとつにマッチする買い手が必要で、外部の流動性提供者に頼るプールは、提供者が引き出すと変動が激しくなります。\n\nERC-7527 は「Function Oracle AMM」（FOAMM）を定義します。NFT コントラクト自体が、固定された数学的関数から常に価格を提示します。代替可能な通貨を **wrap** して新しくミントされた [ERC-721](/eip-721/) にでき、どの NFT も関数の現在価格で通貨に **unwrap**（バーン）できます。取引相手も LP も不要です。wrap した全員の預入が流動性になります。\n\n## 仕組み\n\n互いに結び付けられた 2 つのコントラクトがあります。\n\n- **Agency**: 唯一の入口で、資金の保管者です。その `Asset` 設定で、`currency`（アドレス 0 は ETH を意味します）、`basePremium`、`feeRecipient`、ミント／バーンの手数料率が固定されます。次を公開します。\n  - `getWrapOracle(data)` / `getUnwrapOracle(data)`: 「関数オラクル」で、あらかじめ定められた式から `(premium, fee)` を返します。貸付プロトコルなどの他のコントラクトが、これを呼んで NFT を評価できます。\n  - `wrap(to, data)`: premium + fee を受け取り、fee を `feeRecipient` に送り、premium は保持して、App に NFT をミントさせます。\n  - `unwrap(to, tokenId, data)`: App に NFT をバーンさせ、premium から fee を引いた額を支払います。unwrap できるのはオーナーまたは承認されたアドレスのみです。\n- **App**: ERC-721 コントラクト。その `mint` と `burn` は `onlyAgency()` で制限されなければならず、トークンの作成と破棄は Agency を通じてのみ行えます。\n\n初期化後、両者は互いにとって唯一のオーナーとなり、アップグレードできず、価格戦略も変更されるべきではありません。Agency にロックされた premium は、`unwrap` でのみ出ていけます。任意の **Factory**（`deployWrap`）は、対応する Agency/App のクローンをデプロイし、それぞれの `iconstructor()` を呼んで設定を検証します。\n\nリファレンス実装は単純な線形カーブを使います。`premium = basePremium + sold * basePremium / 100` で、手数料は premium に対するベーシスポイントです。未償還の NFT が増えるほど価格は上がり、バーンされるほど下がります。\n\n## サンプルコード\n\n見積もりを読み、ETH で wrap する（ethers v6）。`data` のエンコードは実装依存です。ここではリファレンスのカーブが使う入力である、App の現在の `totalSupply()` を渡しています。\n\n```ts\nimport { Contract, AbiCoder } from \"ethers\";\n\nconst agency = new Contract(agencyAddr, [\n  \"function getWrapOracle(bytes) view returns (uint256 premium, uint256 fee)\",\n  \"function wrap(address to, bytes data) payable returns (uint256)\",\n  \"function unwrap(address to, uint256 tokenId, bytes data) payable\",\n], signer);\n\n// `app` is a Contract for the bound ERC-721 App (exposes totalSupply())\nconst data = AbiCoder.defaultAbiCoder().encode([\"uint256\"], [await app.totalSupply()]);\nconst [premium, fee] = await agency.getWrapOracle(data);\nconst tx = await agency.wrap(await signer.getAddress(), data, { value: premium + fee });\nawait tx.wait();\n```\n\nAgency 設定のコア部分の形:\n\n```solidity\nstruct Asset {\n    address currency;        // 0 = ETH, otherwise an ERC-20\n    uint256 basePremium;\n    address feeRecipient;\n    uint16  mintFeePercent;  // basis points in the reference implementation\n    uint16  burnFeePercent;\n}\n```\n\n## 知っておくべきこと\n\n- ステータスは **Draft** です。\n- App は `safeMint` ではなく単純な `mint` を使い、`burn` には `from` 引数がありません。根拠の説明では、これらは [ERC-5679](/eip-5679/) からの意図的な逸脱とされています。\n- 各 Agency がサポートする通貨は 1 つだけで、ETH か 1 つの [ERC-20](/eip-20/) のどちらかです。\n- 仕様のセキュリティチェックリスト: `onlyAgency`/`onlyApp` が正しく適用されていることを確認する、価格関数をレビューする、リエントランシーを防ぐ、すべての NFT が実際に数式の価格で unwrap できる（Agency が支払い能力を保つ）ことを確認する。\n- 価格関数への入力は、オフチェーンのものよりオンチェーンのものが推奨されます。\n"},"ko":{"lang":"ko","tldr":"누구나 ETH나 ERC-20을 예치해 온체인 공식이 정한 가격으로 NFT를 민팅하고, 나중에 소각해 공식의 현재 가격을 돌려받을 수 있다. 외부 유동성 공급자 없이 NFT에 내장된 유동성을 부여한다.","tags":["nft","amm","liquidity","pricing","erc721"],"related":[721,20,5679,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7527/","markdown":"## 어떤 문제를 해결하나요?\n\nNFT는 빠르게 팔기 어렵습니다. 하나하나가 짝이 맞는 구매자를 필요로 하고, 외부 유동성 공급자에 의존하는 풀은 공급자가 빠져나가면 변동성이 커집니다.\n\nERC-7527은 \"Function Oracle AMM\"(FOAMM)을 정의합니다. NFT 컨트랙트 자체가 고정된 수학 함수로 항상 가격을 제시합니다. 대체 가능한 통화를 **wrap**해서 새로 민팅된 [ERC-721](/eip-721/)로 만들 수 있고, 어떤 NFT든 함수의 현재 가격으로 통화로 **unwrap**(소각)할 수 있습니다. 상대방이나 LP가 필요 없습니다. wrap한 모든 사람의 예치금이 곧 유동성입니다.\n\n## 어떻게 동작하나요?\n\n서로 묶인 두 컨트랙트가 있습니다.\n\n- **Agency**: 유일한 진입점이자 자금 보관자입니다. `Asset` 설정으로 `currency`(주소 0은 ETH), `basePremium`, `feeRecipient`, 민팅/소각 수수료율이 고정됩니다. 다음을 노출합니다.\n  - `getWrapOracle(data)` / `getUnwrapOracle(data)`: \"함수 오라클\"로, 미리 정의된 공식에서 `(premium, fee)`를 반환합니다. 대출 프로토콜 같은 다른 컨트랙트가 이를 호출해 NFT의 가치를 평가할 수 있습니다.\n  - `wrap(to, data)`: premium + fee를 받고, fee는 `feeRecipient`에게 보내고, premium은 보관하며, App이 NFT를 민팅하게 합니다.\n  - `unwrap(to, tokenId, data)`: App이 NFT를 소각하게 하고 premium에서 fee를 뺀 금액을 지급합니다. 소유자 또는 승인된 주소만 unwrap할 수 있습니다.\n- **App**: ERC-721 컨트랙트. `mint`와 `burn`은 `onlyAgency()`로 제한되어야 하므로, 토큰은 Agency를 통해서만 생성되거나 소멸될 수 있습니다.\n\n초기화된 후에는 두 컨트랙트가 서로의 유일한 소유자가 되고 업그레이드할 수 없으며, 가격 전략도 바뀌어서는 안 됩니다. Agency에 잠긴 premium은 `unwrap`을 통해서만 빠져나갈 수 있습니다. 선택 사항인 **Factory**(`deployWrap`)는 짝이 되는 Agency/App 클론을 배포하고 각각의 `iconstructor()`를 호출해 설정을 검증합니다.\n\n레퍼런스 구현은 단순한 선형 곡선을 사용합니다. `premium = basePremium + sold * basePremium / 100`이며, 수수료는 premium의 베이시스 포인트입니다. 발행된 NFT가 많아질수록 가격이 오르고 소각될수록 내립니다.\n\n## 샘플 코드\n\n견적을 읽고 ETH로 wrap하기(ethers v6). `data` 인코딩은 구현마다 다릅니다. 여기서는 레퍼런스 곡선이 입력으로 쓰는 App의 현재 `totalSupply()`를 담습니다.\n\n```ts\nimport { Contract, AbiCoder } from \"ethers\";\n\nconst agency = new Contract(agencyAddr, [\n  \"function getWrapOracle(bytes) view returns (uint256 premium, uint256 fee)\",\n  \"function wrap(address to, bytes data) payable returns (uint256)\",\n  \"function unwrap(address to, uint256 tokenId, bytes data) payable\",\n], signer);\n\n// `app` is a Contract for the bound ERC-721 App (exposes totalSupply())\nconst data = AbiCoder.defaultAbiCoder().encode([\"uint256\"], [await app.totalSupply()]);\nconst [premium, fee] = await agency.getWrapOracle(data);\nconst tx = await agency.wrap(await signer.getAddress(), data, { value: premium + fee });\nawait tx.wait();\n```\n\nAgency 설정의 핵심 구조:\n\n```solidity\nstruct Asset {\n    address currency;        // 0 = ETH, otherwise an ERC-20\n    uint256 basePremium;\n    address feeRecipient;\n    uint16  mintFeePercent;  // basis points in the reference implementation\n    uint16  burnFeePercent;\n}\n```\n\n## 알아둘 점\n\n- 상태는 **Draft**입니다.\n- App은 `safeMint` 대신 일반 `mint`를 쓰고, `burn`에는 `from` 인자가 없습니다. 설계 근거는 이를 [ERC-5679](/eip-5679/)에서의 의도적인 이탈로 설명합니다.\n- 각 Agency는 통화를 하나만 지원하며, ETH 또는 [ERC-20](/eip-20/) 하나입니다.\n- 명세의 보안 체크리스트: `onlyAgency`/`onlyApp`이 올바르게 적용되었는지 확인하고, 가격 함수를 검토하고, 재진입을 방어하고, 모든 NFT가 실제로 공식 가격에 unwrap될 수 있는지(Agency가 지급 능력을 유지해야 함) 확인합니다.\n- 가격 함수의 입력은 오프체인보다 온체인 값이 권장됩니다.\n"},"zh":{"lang":"zh","tldr":"任何人都可以存入 ETH 或 ERC-20，按链上公式设定的价格铸造 NFT，之后再销毁它，按公式的当前价格取回资金，使 NFT 无需外部流动性提供者就拥有内置流动性。","tags":["nft","amm","liquidity","pricing","erc721"],"related":[721,20,5679,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7527/","markdown":"## 它解决什么问题？\n\nNFT 很难快速卖出：每一个都需要一个匹配的买家，而依赖外部流动性提供者的池子在这些提供者撤出时会变得波动剧烈。\n\nERC-7527 定义了\"函数预言机 AMM\"（Function Oracle AMM，FOAMM）。NFT 合约本身始终根据一个固定的数学函数报价。你可以把同质化货币 **wrap**（封装）成一个新铸造的 [ERC-721](/eip-721/)，也可以按函数的当前价格把任何 NFT **unwrap**（销毁）换回货币。不需要对手方或 LP：所有 wrap 过的人的存款就是流动性。\n\n## 它如何运作\n\n两个相互绑定的合约：\n\n- **Agency**：唯一的入口和资金持有者。它的 `Asset` 设置固定了 `currency`（地址 0 表示 ETH）、`basePremium`、`feeRecipient` 以及铸造/销毁的费率。它公开：\n  - `getWrapOracle(data)` / `getUnwrapOracle(data)`：即\"函数预言机\"，根据预定义的公式返回 `(premium, fee)`。其他合约（例如借贷协议）可以调用它们来给 NFT 估值。\n  - `wrap(to, data)`：收取 premium + fee，把 fee 发给 `feeRecipient`，保留 premium，并让 App 铸造一个 NFT。\n  - `unwrap(to, tokenId, data)`：让 App 销毁该 NFT，并支付 premium 减去 fee 的金额。只有所有者或被授权的地址才能 unwrap。\n- **App**：ERC-721 合约。其 `mint` 和 `burn` 必须用 `onlyAgency()` 加以限制，因此代币只能通过 Agency 创建或销毁。\n\n初始化之后，两者互为对方唯一的所有者，不可升级，定价策略也不应更改。锁定在 Agency 中的 premium 只能通过 `unwrap` 流出。可选的 **Factory**（`deployWrap`）会部署配对的 Agency/App 克隆，并调用各自的 `iconstructor()` 来验证配置。\n\n参考实现使用一条简单的线性曲线：`premium = basePremium + sold * basePremium / 100`，费用按 premium 的基点计算。流通中的 NFT 越多价格越高，被销毁时价格下降。\n\n## 示例代码\n\n读取报价并用 ETH 进行 wrap（ethers v6）。`data` 的编码取决于具体实现；这里它携带的是 App 当前的 `totalSupply()`，即参考曲线所用的输入。\n\n```ts\nimport { Contract, AbiCoder } from \"ethers\";\n\nconst agency = new Contract(agencyAddr, [\n  \"function getWrapOracle(bytes) view returns (uint256 premium, uint256 fee)\",\n  \"function wrap(address to, bytes data) payable returns (uint256)\",\n  \"function unwrap(address to, uint256 tokenId, bytes data) payable\",\n], signer);\n\n// `app` is a Contract for the bound ERC-721 App (exposes totalSupply())\nconst data = AbiCoder.defaultAbiCoder().encode([\"uint256\"], [await app.totalSupply()]);\nconst [premium, fee] = await agency.getWrapOracle(data);\nconst tx = await agency.wrap(await signer.getAddress(), data, { value: premium + fee });\nawait tx.wait();\n```\n\nAgency 设置的核心结构：\n\n```solidity\nstruct Asset {\n    address currency;        // 0 = ETH, otherwise an ERC-20\n    uint256 basePremium;\n    address feeRecipient;\n    uint16  mintFeePercent;  // basis points in the reference implementation\n    uint16  burnFeePercent;\n}\n```\n\n## 需要注意\n\n- 状态为 **Draft**。\n- App 使用普通的 `mint` 而不是 `safeMint`，`burn` 也没有 `from` 参数。设计依据把这些解释为对 [ERC-5679](/eip-5679/) 的有意偏离。\n- 每个 Agency 只支持一种货币，即 ETH 或某一个 [ERC-20](/eip-20/)。\n- 规范中的安全检查清单：确保正确应用 `onlyAgency`/`onlyApp`，审查定价函数，防范重入，并确认每个 NFT 确实都能按公式价格 unwrap（Agency 必须保持有偿付能力）。\n- 定价函数的输入建议使用链上数据，而不是链下数据。\n"}}}
