Skip to content

Latest commit

 

History

History
102 lines (85 loc) · 2.4 KB

FACTORY.md

File metadata and controls

102 lines (85 loc) · 2.4 KB

The Super Token Factory Class

This class gives us all the functionality to work with the superToken Factory contract

To interact with the supertoken Factory contract on a particular chain, You first connect to the target chain

Importing the pachage

>>> from superfluid_finance.supertoken_factory import SupertokenFatory 
>>> from superfluid_finance import accounts_provider as a

instanciate an account object

>>> account = a.get_account("<ENV_VARIABLE_NAME>")

or

>>>account = a.load_account("<local account name>") 

Instantiate The factory contract on that chain

>>> factory = SupertokenFatory("kovan", "infura")

Now you have a factory object connected to a factory contract on the active chain

Interactig with the factory contract is as easy as calling methods of the factory object

Functions on the factory object

View Functions

There are only two view functions

Get Host

>>> factory.get_host()

It returns the host address

Get Super Token Logic

>>> factory.get_supertoken_logic()

Get the current super token logic used by the factory

Write functions

Write functions change the state of the blockchain hence, require you to sign the transaction with an acount

>>> factory.initialize(account)

@dev Initialize the contract

Wrapping Tokens

Wrap with decmals

>>> factory.create_ERC20Wraper_decimals(
        underlying_token,
        underlyingDecimals,
        upgradability,
        name,
        symbol,
        account
    )

Breakdown

  • Creates new super token wrapper for the underlying ERC20 token
  • @param underlyingToken Underlying ERC20 token
  • @param underlyingDecimals Underlying token decimals
  • @param upgradability Upgradability mode
  • @param name Super token name
  • @param symbol Super token symbol

Wrap without decimals

>>> factory.create_ERC20Wraper(
        underlying_token,
        upgradability,
        name,
        symbol,
        account
    )

Breakdown

  • Create new super token wrapper for the underlying ERC20 token with extra token info
  • underlyingToken Underlying ERC20 token
  • upgradability Upgradability mode
  • name Super token name
  • symbol Super token symbol
  • NOTE:
    • It assumes token provides the .decimals() function

Initialize custom Super Token

>>> factory.initialize_custom_supertoken(
        customSuperTokenProxy,
        account
    )