Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[epic] feat: "tokenfactory" module #1584

Closed
6 tasks done
Unique-Divine opened this issue Sep 14, 2023 · 0 comments · Fixed by #1638
Closed
6 tasks done

[epic] feat: "tokenfactory" module #1584

Unique-Divine opened this issue Sep 14, 2023 · 0 comments · Fixed by #1638
Assignees
Labels
epic Project or large task that groups multiple tickets and PRs

Comments

@Unique-Divine
Copy link
Member

Unique-Divine commented Sep 14, 2023

Context

Implement a permissionless tokenfactory module based on the standard used by Osmosis, Juno, Injective, and other networks.

"This is important for cosmwasm applications on osmosis to thrive." - osmosis#1029

Rationale

  • Sending CW20 asssets that use the factory can be simple
    "/cosmos.bank.v1beta1.MsgSend" tx msgs. This makes it much easier to transfer tokens at the CLI without invoking multiple wasm contracts.
  • The x/bank module is well-tested and exists on every Cosmos-SDK chain, whereas CW20 only exists on chains with CosmWasm.
  • All smart contracts can access the bank module messages and queries by default, and this will continue to be the case even if we have ERC-20 assets with EVM support next year.
  • Way more efficient query via x/bank with built-in total supply tracking. No need to do paginated CW20 queries and then filter the pages.
  • Factory tokens can automatically be displayed in popular tools like explorers (Mintscan), Leap, Keplr, etc.
  • Saves us from needing to migrate to the bank standard in the future like Juno.

Completion Tracking

  • Impl tokenfactory/types
  • Impl the tokenfactory state with collections
  • Impl tokenfactory/keeper business logic (and wire module to app)
  • Impl CLI for tokenfactory
  • Impl wasm bindings for tokenfactory
  • test(cw-nibiru): Create an e2e test using the tokenfactory wasm bindings

Core Functionality

For smart contracts, the Public API for the transaction messages of this module could look something like this.

use cosmwasm_std::Int256;
type SdkInt = Int256; // alias for cosmos-sdk/types.Int

/// `TokenfactoryExecuteMsg` describes the different messages that the token
/// factory can accept.
enum TokenfactoryExecutMsg {
    /// CreateDenom creates a token factory denomination of the form: 
    /// "factory/{contract-address}/{subdenom}".
    /// Contracts can create denoms, namespaced under the contract's address.
    /// A contract may create any number of independent sub-denoms.
    CreateDenom {
        /// `subdenom` can be of length at most 44 characters, in [0-9a-zA-Z./]
        /// The `(creating contract address, subdenom)` pair must be unique.
        /// The created denom's admin is the creating contract address.
        subdenom: String,
    },
    /// Contracts can change the admin of a denom that they are the admin of.
    ChangeAdmin {
        denom: String,
        /// If the `new_admin_address` is empty, the denom has no admin.
        new_admin_address: String,
    },
    /// Contracts can mint native tokens for an existing factory denom
    /// that they are the admin of.
    MintTokens {
        denom: String,
        amount: SdkInt,
        mint_to_address: String,
    },
    /// Contracts can burn native tokens for an existing factory denom
    /// that they are the admin of.
    /// Currently, the `burn_from_address` must be set to `""`.
    BurnTokens {
        denom: String,
        amount: SdkInt,
        burn_from_address: String,
    },
}

For queries, let's include bindings similar to those of bindings.OsmosisQuery.

References

  1. Osmosis Token Factory Docs
  2. Juno Token Factory implementation #635
  3. Osmosis wasm bindings
  4. Juno Token Factory Contracts
  5. Governance proposals on param change of denom_creation_fee from @larry0x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic Project or large task that groups multiple tickets and PRs
Projects
Archived in project
1 participant