---
eip: 7527
label: ERC-7527
title: Token Bound Function Oracle AMM
status: Draft
type: Standards Track
category: ERC
created: 2023-09-03
requires: 165, 721
official: https://eips.ethereum.org/EIPS/eip-7527
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7527.md
canonical: https://eips.huatuo.xyz/eip-7527/
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]
---

# ERC-7527: Token Bound Function Oracle AMM

> Interfaces that wrap FT to NFT and unwrap NFT to FT based on an embedded Function Oracle AMM

**TL;DR:** 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.

## What problem does it solve?

NFTs 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.

ERC-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.

## How it works

Two contracts are bound to each other:

- **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:
  - `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.
  - `wrap(to, data)`: takes premium + fee, sends the fee to `feeRecipient`, keeps the premium, and has the App mint an NFT.
  - `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.
- **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.

Once 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.

The 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.

## Sample code

Reading 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.

```ts
import { Contract, AbiCoder } from "ethers";

const agency = new Contract(agencyAddr, [
  "function getWrapOracle(bytes) view returns (uint256 premium, uint256 fee)",
  "function wrap(address to, bytes data) payable returns (uint256)",
  "function unwrap(address to, uint256 tokenId, bytes data) payable",
], signer);

// `app` is a Contract for the bound ERC-721 App (exposes totalSupply())
const data = AbiCoder.defaultAbiCoder().encode(["uint256"], [await app.totalSupply()]);
const [premium, fee] = await agency.getWrapOracle(data);
const tx = await agency.wrap(await signer.getAddress(), data, { value: premium + fee });
await tx.wait();
```

Core shape of the Agency settings:

```solidity
struct Asset {
    address currency;        // 0 = ETH, otherwise an ERC-20
    uint256 basePremium;
    address feeRecipient;
    uint16  mintFeePercent;  // basis points in the reference implementation
    uint16  burnFeePercent;
}
```

## Things to know

- Status is **Draft**.
- 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/).
- Each Agency supports a single currency, either ETH or one [ERC-20](/eip-20/).
- 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).
- On-chain inputs to the pricing function are recommended over off-chain ones.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-7527
