So, the cool thing is that because of the way Penumbra works, I think it’s possible to compose together a token factory and a bonding curve to have a completely fair launch token – with no frontrunning the initial price discovery!
Let’s look at how this could work.
Token Factory
In other parts of Penumbra, we’ve adopted a “stateful NFT” pattern for controlling public state from inside the shielded pool. For example, an auction is controlled by an auction NFT, and the NFT has a sequence number, so that each action on an auction can consume the previous state and produce an NFT with the next sequence number. A similar approach could work for a token factory, by adding the following transaction actions:
ActionBurn
This action specifies a Value
and burns it explicitly. Having an explicit burn action means that it’s not necessary to do some hacky mechanism and it’s easy to verify that tokens were in fact burned (e.g., it can emit an event).
Value Balance
The ActionBurn
consumes the specified value from the transaction’s value balance and produces nothing.
ActionTokenFactoryCreate
This action would specify a Metadata
for the token, a nonce, and an initial supply. The nonce would be a random 32-byte value that defines the token’s denom (e.g., factory/[32 hex bytes]
), and the chain would check that it’s unused, similar to the way auctions or LPs work. (The chain cannot assign the value, because it needs to be known on the client side at the point the transaction is created in order to record outputs).
Value Balance
The ActionTokenFactoryCreate
would contribute the following to the transaction’s value balance:
+SUPPLY
of the newly created factory/[ID]
token
+1
of a “token factory NFT”, factory_mint_0_[ID]
, which represents minting rights over the newly created token
ActionTokenFactoryMint
This action would mint additional tokens, using the token factory NFT. It would specify an amount of tokens to mint.
Value Balance
The ActionTokenFactoryMint
would contribute the following to the transaction’s value balance:
+SUPPLY
of the factory/[ID]
token
-1
of the factory_mint_[N]_[ID]
NFT with sequence number N
+1
of the factory_mint_[N+1]_[ID]
NFT with sequence number N+1
Using the Token Factory for Mintable Tokens
This mechanism allows two different use cases: tokens that are issued by a central party who retains minting rights, and tokens that are minted once and then have a fixed supply.
For an application like https://cigzone.org , where minting rights are a feature, the initial token factory creation would look like
Spend
(to pay fees)
ActionTokenFactoryCreate
(with initial supply, could be 0)
Output
(to store newly created supply, if any)
Output
(to store the mint authority token)
Output
(to store change from fee payment)
The issuer can then mint new tokens on demand as needed, by using the ActionTokenFactoryMint
. Currently, they can’t programmatically encumber minting, but this limitation of the protocol would be difficult to change without becoming Aztec (let’s put that off into the further future).
Using the Token Factory with Bonding Curves
Now let’s look at the case where a user wants to perform a fair launch using a bonding curve. Penumbra is actually incredibly well-suited to this, because all DEX operations are batched, meaning that all users access the bonding curve at the same “time”.
Penumbra LP positions have fixed prices, but they can be used to replicate the behavior of a bonding curve, by creating a sequence of positions with ascending prices. The Penumbra DEX will index these and route through each of them in turn.
A fair launch transaction on Penumbra would look like
Spend
(to pay fees)
ActionTokenFactoryCreate
(with fixed initial supply)
ActionBurn
(to burn the mint NFT)
- Repeated:
PositionOpen
(to define one part of the bonding curve, with 0% fee and fixed price)
ActionBurn
(to burn the LPNFT, making the liquidity immutable)
Output
(to store change from fee payment)
This is really cool, because now the entire supply of the token has been verifiably committed to the bonding curve, and any user can interact with it on an equal footing (no frontrunning). But we can do even better. Rather than having just one bonding curve, the fair launch transaction can define bonding curves to multiple assets. Because the Penumbra DEX can do multi-hop routing, this allows the assets that were previously used to buy the new token at lower prices to be used to provide liquidity on other routes, rather than just being locked away in an inaccessible part of the bonding curve!