Mean Finance
Search…
Creating a Position
Once you have a pair's address, you can now create your position. Take into account that:
  • Rate must be a positive number
  • Amount of swaps must be a positive number
  • Swap interval must be one of the supported swap intervals (defined by the Global Parameters contract)
1
pragma solidity 0.8.6;
2
3
import '@mean-finance/dca-v1/contracts/interfaces/IDCAPair.sol';
4
5
contract MyContract {
6
7
IDCAPair public immutable pair;
8
9
constructor(IDCAPair _pair) {
10
pair = _pair;
11
}
12
13
/// @notice Creates a new position
14
/// @param _tokenAddress The address of the token that will be deposited
15
/// @param _rate How many "from" tokens need to be traded in each swap
16
/// @param _amountOfSwaps How many swaps to execute for this position
17
/// @param _swapInterval How frequently the position's swaps should be executed
18
/// @return _dcaId The id of the created position
19
function deposit(
20
address _from,
21
uint160 _rate,
22
uint32 _amountOfSwaps,
23
uint32 _swapInterval
24
) external returns (uint256 _dcaId) {
25
_dcaId = pair.deposit(_from, _rate, _amountOfSwaps, _swapInterval);
26
}
27
}
Copied!
Last modified 3mo ago
Copy link