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
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
math_implementations
¶
Factory.math_implementations() -> address: view
Getter for the math implementations.
Returns: implementation (address
).
gauge_implementations
¶
Factory.gauge_implementations() -> address: view
Getter for the gauge implementations.
Returns: implementation (address
).
views_implementation
¶
Factory.views_implementations() -> address: view
Getter for the views implementations.
Returns: implementation (address
).
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
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
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
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
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