Skip to content

Instantly share code, notes, and snippets.

@zmanian
Last active March 15, 2023 17:54
Show Gist options
  • Save zmanian/da583432f3d99d6aaa853653cdddfa6b to your computer and use it in GitHub Desktop.
Save zmanian/da583432f3d99d6aaa853653cdddfa6b to your computer and use it in GitHub Desktop.

ICS: Cinderella Tokens: An Async/IBC friendly alternative to flash loans

Flashloans are a fascinating economic coordination mechanism that has emerged out the Ethereum architecture as a result of a synchronous, sequential, atomic transaction system. It allows anonymous coordination between capital providers and arbitrageurs because the capital providers can condition providing any capital on protocol enforced guarantee that the entire arbitrage is profitable denominated in the token being lent.

One of the effects of this process has been the it ensures an efficient and healthy liquidation market for the collateral in long term debt instruments. It also enables low cost scaling of economic exploits.

Why don’t flash loans exist in IBC world?

Flash loans are impossible in an IBC world because IBC semantics require finalizing a block on the origin chain rather than on the receiving chain. This makes atomicity for the lender difficult and moves us into the domain of over collateralized lending.

What are Cinderella tokens?

Cinderella tokens are a lending contract where a source chain locks an amount of tokens in a time limited escrow. If at the end of the time limit, the escrow is not previously released the tokens return back to the sender.

The expectation is the Cinderella token creator must lock up some small amount of collateral on the sending chain that either goes to the redeemer of the Cinderella tokens or the originator of the loan.

Cinderella tokens are inspired by the fairytale and just like it those tokens turn into pumpkins when the clock strikes.

As long as Cinderella tokens are returned to the source chain before the escrow expires. There is a guarantee that no intermediary was double spent.

Finally a Cinderella token implementation should enable the escrow to be extended for algorithmically generated additional capital.

Safely handling Cinderella tokens

While Cinderella tokens can be represented as ICS20 tokens where the double spend risk floats to the user level.

Chains may want to accept Cinderella tokens in automated processes like liquidations. Doing this safely requires native support for this ICS.

Recipient chains may want to set a minimum validity margin between any un-redeemd tokens and their escrow end and require automatic sale of any tokens.

Finally , implementations should be able handle escrow updates on any coins in their possession.

Example

There is a arb on chain B.

there are ATOMs on Chain A.

Alice is poor but knows how to exploit the arb. Bob is a whale.

Bob's smart contract/agent locks up ATOM on Chain A.

Alice gets Cinderella ATOM on chain A. Lets say the Cinderella token last for 100 blocks on Chain A.

Alice swaps the cinderella tokens for asset underpriced asset, swaps A for atoms, Atoms for cinderella Atoms, returns the cinderella atoms for A.

Any counter party that has to hold cinderella atoms knows that they can pay a small fee to extend the escrow on chain A so they should be willing to hold them at a relatively small discount to the price of ATOM. Eventually the arbs are exhausted on chain A and someone returns to the Chain A and collects a small fee.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment