Skip to content

MSc

MeltyFi

NFT-backed lending that replaces price-based liquidation with a lottery: the borrower is funded by ticket sales, and a default hands the NFT to a ticket holder rather than to a liquidator.

Nov 2022Most Innovative Project, Sui HackathonWeb3

MeltyFi lends against an NFT without ever needing to know what the NFT is worth. The collateral is split into lottery tickets that lenders buy; if the loan is repaid the lenders are refunded and the NFT returns to its owner, and if it is not, one ticket holder receives the NFT itself.

Origin
MSc, Blockchain and Distributed Ledger Technologies, Sapienza, 2022/23
Implementations
EVM, Sui, and the XRPL EVM sidechain
Award
Most Innovative Project, Sui Hackathon
Team
MSc version with Andrea Princic and Benigno Ansanelli
Repository
Princic-1837592/MeltyFi.NFT
Princic-1837592/MeltyFi.NFTLending and borrowing platform with NFT collateral based on lottery-ticket fundraising.Solidity

The problem

NFT-backed lending normally works the way any collateralised loan does: the lender watches a price, and when the collateral falls below a threshold it is seized and sold. That mechanism needs a price, which for an NFT means a floor price: a number derived from whatever happens to be listed on a marketplace at that moment, which can be manipulated by a single sale and does not exist at all for a thin collection.

So the liquidation machinery is built on the least reliable input in the system, and the borrower’s collateral can be taken because of an oracle rather than because of anything they did.

What I built

The protocol removes the price from the design entirely. An owner deposits an NFT and opens a lottery over it; lenders buy tickets – WonkaBars – and the proceeds go to the owner immediately, which is the loan. At resolution one ticket is drawn. If the owner repays, the lottery closes and the NFT is returned; if they do not, the drawn ticket holder takes the NFT. Everyone who participated is minted ChocoChip, a fungible reward token, either way.

There is no threshold, no oracle, and no forced sale. What replaces the floor price as the pricing mechanism is the lenders themselves: the amount raised is the market’s valuation, set by people willing to put money behind it.

On the EVM version the pieces are a core contract holding the logic, an ERC-1155 for the tickets, an ERC-20 for the rewards, a governance contract, and Chainlink VRF for the draw. The Sui rewrite models the same protocol in Move as three on-chain assets: the tickets, the reward coin, and a shared Lottery object that escrows both the NFT and the raised SUI and carries the state machine (active, concluded, cancelled, expired), with a fixed 5% protocol fee.

Hard parts

The draw has to be unriggable, and the way to get randomness is not portable. A lottery whose outcome the borrower can influence is not a loan, it is a coin flip they control. On the EVM implementation that means Chainlink VRF: an external oracle, a callback, and a dependency the protocol otherwise does not want. The Sui rewrite uses sui::random, randomness native to the chain. Same requirement, completely different shape: the one part of the design that had to be rewritten rather than translated when the protocol moved. None of the implementations has received a security audit, and the incentive design has not been analysed formally. The work establishes the mechanism, not that it is safe to resolve a lottery over real assets.

Tickets have to be ownable and countable at the same time. A ticket is a transferable asset, but the draw needs to map a single winning number onto a holder. The Sui implementation records, per holding, the lottery it belongs to and the contiguous range of ticket numbers it covers, so a draw resolves to an owner without iterating over every participant.

Four implementations of one protocol. It exists on EVM, on Sui in Move, and on the XRPL EVM sidechain, with a current consolidation on Solidity 0.8.30 and Foundry. What is portable is the mechanism; what is not is everything touching the chain’s own primitives: randomness, object ownership, and how an escrow is represented.