There is an interface called IiZiSwapFactory
(source), which declares a method named swapX2YModule()
(source).
IiZiSwapFactory.sol
interface IiZiSwapFactory {
/// @notice emit when successfuly create a new pool (calling iZiSwapFactory#newPool)
/// @param tokenX address of erc-20 tokenX
/// @param tokenY address of erc-20 tokenY
/// @param fee fee amount of swap (3000 means 0.3%)
/// @param pointDelta minimum number of distance between initialized or limitorder points
/// @param pool address of swap pool
event NewPool(
address indexed tokenX,
address indexed tokenY,
uint24 indexed fee,
uint24 pointDelta,
address pool
);
/// @notice module to support swap from tokenX to tokenY
/// @return swapX2YModule address
function swapX2YModule() external returns (address);
... omitted ...
There is a concrete contract called iZiSwapPool
(source) and within its constructor, the interface IiZiSwapFactory
is instantiated (source.
iZiSwapFactory.sol
contract iZiSwapPool is IiZiSwapPool {
using Liquidity for mapping(bytes32 =>Liquidity.Data);
... omitted ...
constructor() {
swapModuleX2Y = IiZiSwapFactory(msg.sender).swapX2YModule();
... omitted ...
Questions
How does it work in general?
Who is
msg.sender
? Is it another contract or an Account?How is it possible that an interface is being instantiated?
swapModuleX2Y = IiZiSwapFactory(msg.sender).swapX2YModule();
does this line mean the following?A.
msg.sender
is a contract.B.
msg.sender
fulfilsIiZiSwapFactory
interfaceC. Contract
iZiSwapPool is IiZiSwapPool
meansiZiSwapPool
fulfilsIiZiSwapFactory
interfaceD. Could it be that
msg.sender
is alsoiZiSwapPool
?