Mean Finance
Search…
Finding a Pair's Contract
When trying to interact with a Mean Finance pair, the first thing you'll need to do is find the contract's address. In order to do that, you should use the factory.
1
pragma solidity 0.8.6;
2
3
import '@mean-finance/dca-v1/contracts/interfaces/IDCAFactory.sol';
4
5
contract MyContract {
6
7
IDCAFactory public immutable factory;
8
9
constructor(IDCAFactory _factory) {
10
factory = _factory;
11
}
12
13
/// @notice Returns the pool address for a given pair of tokens, or address 0 if it does not exist
14
/// @dev _tokenA and _tokenB may be passed in either tokenA/tokenB or tokenB/tokenA order
15
/// @param _tokenA The contract address of either tokenA or tokenB
16
/// @param _tokenB The contract address of the other token
17
/// @return _pool The pool address
18
function findPair(address _tokenA, address _tokenB) external view returns (address _pool) {
19
_pool = factory.pairByTokens(_tokenA, _tokenB);
20
}
21
}
Copied!
Last modified 2mo ago
Copy link