ERC-7649 · Draft · ERC · 2024-02-28
ERC-7649: Bonding curve-embedded liquidity for NFTs
A Draft standard for attaching a separate bonding-curve 'shares' contract to any ERC-721 NFT, so people can buy and sell shares at a formula-defined price while the NFT's owner earns a guaranteed fee on every trade.
What problem does it solve?
An NFT is a single, indivisible item, so it is often illiquid: there may be no buyer at any given moment, and there is no way to take a small position in it. Bonding curves, where a contract always quotes a price as a function of supply, provide continuous liquidity, but there was no standard way to attach one to an existing ERC-721 token.
ERC-7649 defines how to bolt a "Tradeable Shares" contract onto an NFT without modifying ERC-721. The authors' motivating examples are NFTs representing AI models or GPU and storage pools, where demand for shares signals how valuable the resource is.
How it works
- Separate contract. Each shares contract points to one subject NFT (
getSharesSubject()returns the ERC-721 address and token ID). The NFT contract itself is unchanged. - Bonding curve.
getPrice(supply, amount)defines the price ofamountshares given the currentsupply. Creators may customise parameters (slope, intercept) or even the curve shape. - Buying and selling.
buyShares(amount)/buySharesTo(amount, beneficiary)mint shares at the curve price plus fees;sellShares(amount)/sellSharesTo(...)burn them and pay out. The first share can only be bought by the current NFT owner, and the last share cannot be sold. - Price quotes.
getBuyPrice,getSellPriceand their...AfterFeevariants, either for the current supply or for any hypothetical supply. - Shares are not transferable. They can only be bought from and sold back to the contract.
getSharesBalanceandgetSharesSupplyplay the role ofbalanceOf/totalSupply. - Guaranteed creator fees. Every trade pays a fee to the issuer, which is whoever currently owns the NFT (
getSharesIssuer()).getFeePercent()uses 18 decimals (1e18= 100 %). Implementations may split fees between protocol, holders and subject. - Payment. Either native ETH or an ERC-20 token (or both).
- A
Tradeevent logs every buy and sell, andgetTradeVolume()only ever increases.
Sample code
Buying shares for ETH and checking the sell-back value (ethers v6):
import { Contract, Wallet, JsonRpcProvider, formatEther } from "ethers";
const abi = [
"function getSharesSubject() view returns (tuple(address tokenAddress, uint256 tokenId))",
"function getBuyPriceAfterFee(uint256 amount) view returns (uint256)",
"function getSellPriceAfterFee(uint256 amount) view returns (uint256)",
"function getSharesBalance(address holder) view returns (uint256)",
"function buyShares(uint256 amount) payable",
];
const provider = new JsonRpcProvider(process.env.RPC_URL);
const trader = new Wallet(process.env.TRADER_KEY!, provider);
const shares = new Contract(process.env.SHARES!, abi, trader);
const subject = await shares.getSharesSubject();
console.log("NFT:", subject.tokenAddress, subject.tokenId.toString());
const cost = await shares.getBuyPriceAfterFee(2n);
await (await shares.buyShares(2n, { value: cost })).wait();
const bal = await shares.getSharesBalance(trader.address);
console.log("could sell now for", formatEther(await shares.getSellPriceAfterFee(bal)), "ETH");
Things to know
- Status: Draft. Security considerations are generic, and the interface may change.
- Fees go to the current NFT owner, which can change at any moment (including by front-running). Clients must not rely on
getSharesIssuer()staying the same. - Bonding-curve shares reward early buyers; late buyers can lose most of their value if demand falls. Fees on both buy and sell mean a round trip always costs money.
- The spec points to the older Bonded Fungible Tokens idea (ERC-1671) as related prior work.