Skip to content

Implementations

The StableSwap-NG Factory makes use of blueprint contracts to deploy its contracts from the implementations.

Warning

Implementation contracts are upgradable. They can either be replaced, or additional implementation contracts can be added. Therefore, please always make sure to check the most recent ones.

It utilizes five different implementations:

  • pool_implementations, containing multiple blueprint contracts that are used to deploy plain pools.
  • metapool_implementations, containing multiple blueprint contracts that are used to deploy metapools.
  • math_implementation, containing math functions used in the AMM.
  • gauge_implementation, containing a blueprint contract that is used when deploying gauges for pools.
  • views_implementation, containing a view methods contract relevant for integrators and users looking to interact with the AMMs.

More on the Math Implementation and Views Implementation.

Query Implementations

pool_implementations

Factory.pool_implementations(arg0: uint256) -> address: view

Getter for the pool implementations. There might be multiple pool implementations base on various circumstances.

Returns: implementation (address).

Input Type Description
arg0 uint256 index value of the implementation
Source code
# index -> implementation address
pool_implementations: public(HashMap[uint256, address])
>>> Factory.pool_implementation(0)
'0x3E3B5F27bbf5CC967E074b70E9f4046e31663181'

metapool_implementations

Factory.metapool_implementations(arg0: uint256) -> address: view

Getter for the pool implementations. There might be multiple metapool implementations base on various circumstances.

Returns: implementation (address).

Input Type Description
arg0 uint256 index value of the implementation
Source code
# index -> implementation address
metapool_implementations: public(HashMap[uint256, address])
>>> Factory.metapool_implementation(0)
'0x19bd1AB34d6ABB584b9C1D5519093bfAA7f6c7d2'

math_implementations

Factory.math_implementations() -> address: view

Getter for the math implementations.

Returns: implementation (address).

Source code
# index -> implementation address
math_implementation: public(address)
>>> Factory.math_implementation()
'0x20D1c021525C85D9617Ccc64D8f547d5f730118A'

gauge_implementations

Factory.gauge_implementations() -> address: view

Getter for the gauge implementations.

Returns: implementation (address).

Source code
# index -> implementation address
gauge_implementation: public(address)
>>> Factory.gauge_implementation()
'0xF5617D4f7514bE35fce829a1C19AE7f6c9106979'

views_implementation

Factory.views_implementations() -> address: view

Getter for the views implementations.

Returns: implementation (address).

Source code
# index -> implementation address
views_implementation: public(address)
>>> Factory.views_implementation()
'0x87DD13Dd25a1DBde0E1EdcF5B8Fa6cfff7eABCaD' 

Set New Implementations

New implementations can be set via these admin-only functions:

set_pool_implementations

Factory.set_pool_implementations(_implementation_index: uint256, _implementation: address,):

Guarded Method

This function is only callable by the admin of the contract.

Function to set/add a new pool implementation.

Input Type Description
_implementation_index uint256 index value of implementation
_implementation address implementation contract address
Source code
# index -> implementation address
pool_implementations: public(HashMap[uint256, address])
metapool_implementations: public(HashMap[uint256, address])
math_implementation: public(address)
gauge_implementation: public(address)
views_implementation: public(address)

@external
def set_pool_implementations(
    _implementation_index: uint256,
    _implementation: address,
):
    """
    @notice Set implementation contracts for pools
    @dev Only callable by admin
    @param _implementation_index Implementation index where implementation is stored
    @param _implementation Implementation address to use when deploying plain pools
    """
    assert msg.sender == self.admin  # dev: admin-only function
    self.pool_implementations[_implementation_index] = _implementation
>>> Factory.set_pool_implementations('todo')

set_metapool_implementations

Factory.set_pool_implementations(_implementation_index: uint256, _implementation: address,):

Guarded Method

This function is only callable by the admin of the contract.

Function to set/add a new metapool implementation.

Input Type Description
_implementation_index uint256 index value of implementation
_implementation address implementation contract address
Source code
# index -> implementation address
pool_implementations: public(HashMap[uint256, address])
metapool_implementations: public(HashMap[uint256, address])
math_implementation: public(address)
gauge_implementation: public(address)
views_implementation: public(address)

@external
def set_metapool_implementations(
    _implementation_index: uint256,
    _implementation: address,
):
    """
    @notice Set implementation contracts for metapools
    @dev Only callable by admin
    @param _implementation_index Implementation index where implementation is stored
    @param _implementation Implementation address to use when deploying meta pools
    """
    assert msg.sender == self.admin  # dev: admin-only function
    self.metapool_implementations[_implementation_index] = _implementation
>>> Factory.set_metapool_implementations('todo')

set_math_implementation

Factory.set_math_implementation(_math_implementation: address):

Guarded Method

This function is only callable by the admin of the contract.

Function to set a new math implementation. There can only be one math implementation.

Input Type Description
_math_implementation address new math implementation contract
Source code
# index -> implementation address
pool_implementations: public(HashMap[uint256, address])
metapool_implementations: public(HashMap[uint256, address])
math_implementation: public(address)
gauge_implementation: public(address)
views_implementation: public(address)

@external
def set_math_implementation(_math_implementation: address):
    """
    @notice Set implementation contracts for StableSwap Math
    @dev Only callable by admin
    @param _math_implementation Address of the math implementation contract
    """
    assert msg.sender == self.admin  # dev: admin-only function
    self.math_implementation = _math_implementation
>>> Factory.set_math_implementations('todo')

set_gauge_implementations

Factory.set_gauge_implementation(_gauge_implementation: address):

Guarded Method

This function is only callable by the admin of the contract. There can only be one gauge implementation.

Function to set a new gauge implementation.

Input Type Description
_gauge_implementation address new gauge implementation contract
Source code
# index -> implementation address
pool_implementations: public(HashMap[uint256, address])
metapool_implementations: public(HashMap[uint256, address])
math_implementation: public(address)
gauge_implementation: public(address)
views_implementation: public(address)

@external
def set_gauge_implementation(_gauge_implementation: address):
    """
    @notice Set implementation contracts for liquidity gauge
    @dev Only callable by admin
    @param _gauge_implementation Address of the gauge blueprint implementation contract
    """
    assert msg.sender == self.admin  # dev: admin-only function
    self.gauge_implementation = _gauge_implementation
>>> Factory.set_gauge_implementations('todo')

set_views_implementation

Factory.set_views_implementation(_views_implementation: address):

Guarded Method

This function is only callable by the admin of the contract. There can only be one views implementation.

Function to set a new views implementation.

Input Type Description
_views_implementation address new views implementation contract
Source code
# index -> implementation address
pool_implementations: public(HashMap[uint256, address])
metapool_implementations: public(HashMap[uint256, address])
math_implementation: public(address)
gauge_implementation: public(address)
views_implementation: public(address)

@external
def set_views_implementation(_views_implementation: address):
    """
    @notice Set implementation contracts for Views methods
    @dev Only callable by admin
    @param _views_implementation Implementation address of views contract
    """
    assert msg.sender == self.admin  # dev: admin-only function
    self.views_implementation = _views_implementation
>>> Factory.set_views_implementations('todo')