Skip to content
Jean-Baptiste Dusseaut edited this page Mar 3, 2021 · 9 revisions

Minter contract

Contract logic

  • The contract maintains several special roles : minter, admin, governance, oracle

  • The contract maintains a map of managed assets, identified by their ethereum contract address.

  • FT are stored in separated FA2 contracts. Each contract can manage several tokens. Its defined at origination time, and cannot be changed afterwhile.

  • Each NFT is stored in a separated FA2 (one FA2 contract per NFT). Token ids are the same between ethereum and tezos.

  • The contract collects fees on behalf on the signers, the dev pool and the staking contract, according to the current fees distribution.

  • The contract can manage to some extent the underlying FA2s: migrating to a new minter contract, pause tokens.

Signer entrypoints

These entrypoints are permissionned : only the quorum contract can call them.

mint_erc20

(pair %mint_erc20
    (bytes %erc_20)
    (pair (pair %event_id (bytes %block_hash) (nat %log_index))
          (pair (address %owner) (nat %amount)))

The targeted token is identified by its ERC20 contract address. Each minting operation is identified by the block hash and the log index inside the block, that way, it is truly unique.

Part of the amount is given the user, another goes to the fees reserve, according to the current fees levels.

mint_erc721

(pair %mint_erc721
    (bytes %erc_721)
    (pair (pair %event_id (bytes %block_hash) (nat %log_index))
        (pair (address %owner) (nat %token_id))))

The minting unique identifer is the same as mint_erc20. Fees are collected in xtz, so a payment is expected here.

add_erc20

(pair %add_erc20 (bytes %eth_contract) (pair %token_address address nat))

A token address is defined as a pair of address nat. The nat here is the token_id, identifying in a multi asset fa2 which asset we should target. As always, a token is identified by its eth contract address.

The contract will try to ensure that the token_address address in an actual fa2, containing in addition the entrypoints associated with wrap protocol (mint, burn, etc).

add_erc721

(pair %add_erc721 (bytes %eth_contract) (address %token_contract))

Very much the same logic than in add_erc20, but we don’t need a token id. Indeed, the token_id cannot be knonw in advance, because it’s a information comming from the ethereum network, at wrapping time. As a consequence, minter contract cannot rely on a multi NFT token contract.

Unwrap entrypoints

unwrap_erc20

unwrap_erc721

Fees entrypoints

Fees are collected in several steps:

  1. For each minting or unwrap operation, fees are accumulated in the fees ledger, under the contract address.

  2. A call of the different disribute entrypoints (from the quorum contract) will update the ledger, dispatching the accumulated fees to the proper recipients

  3. Recipients must call one of the withdrawal entrypoints, and one ore several transfers will be issued.

withdraw_all_tokens

withdraw_all_xtz

withdraw_token

withdraw_xtz

Goverance entrypoints

set_erc20_unwrapping_fees

set_erc20_wrapping_fees

set_erc721_unwrapping_fees

set_erc721_wrapping_fees

set_fees_share

set_governance

Assets admin entrypoints

change_tokens_administrator

confirm_tokens_administrator

pause_tokens

Admin entrypoints

pause_contract

set_administrator

set_oracle

set_signer

Signer ops entrypoints

default (set payment address)

Clone this wiki locally