@@ -4,24 +4,23 @@ pragma solidity ^0.6.0;
4
4
5
5
import "./IUnifiedStableFarming.sol " ;
6
6
7
- /**
8
- * @inheritdoc IUnifiedStableFarming
9
- */
10
7
contract UnifiedStableFarming is IUnifiedStableFarming {
11
8
address private constant UNISWAP_V2_ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D ;
12
9
13
10
uint256 [] private _percentage;
14
11
15
- constructor (uint256 [] memory percentage ) {
12
+ constructor (uint256 [] memory percentage ) public {
16
13
assert (percentage.length == 2 );
17
14
_percentage = percentage;
18
15
}
19
16
20
- function percentage () public override view returns (uint256 [] memory ) {
17
+ function percentage () public view returns (uint256 [] memory ) {
21
18
return _percentage;
22
19
}
23
20
24
- //Earn pumping uSD - Means swap a chosen stableCoin for uSD, then burn the difference of uSD to obtain a greater uSD value in Uniswap Pool tokens
21
+ /**
22
+ * @inheritdoc IUnifiedStableFarming
23
+ */
25
24
function earnByPump (
26
25
address stableCoinAddress ,
27
26
uint256 pairIndex ,
@@ -48,8 +47,8 @@ contract UnifiedStableFarming is IUnifiedStableFarming {
48
47
(uint256 returnA , uint256 returnB ) = IStableCoin (stableCoinAddress).burn (
49
48
pairIndex,
50
49
pairAmount,
51
- amountA ,
52
- amountB
50
+ amountAMin ,
51
+ amountBMin
53
52
);
54
53
(address tokenA , address tokenB , ) = _getPairData (stableCoinAddress, pairIndex);
55
54
// Check that the pump was successful
@@ -81,18 +80,13 @@ contract UnifiedStableFarming is IUnifiedStableFarming {
81
80
uint256 stableCoinAmount
82
81
) private view returns (bool ) {
83
82
IStableCoin stableCoin = IStableCoin (stableCoinAddress);
84
- uint256 cumulative = stableCoin.fromTokenToStable (
85
- tokenAddress,
86
- tokenValue
87
- );
83
+ uint256 cumulative = stableCoin.fromTokenToStable (tokenAddress, tokenValue);
88
84
cumulative += stableCoin.fromTokenToStable (token0, return0);
89
85
cumulative += stableCoin.fromTokenToStable (token1, return1);
90
86
uint256 percentage = (cumulative * _percentage[0 ]) / _percentage[1 ];
91
87
uint256 cumulativePlus = cumulative + percentage;
92
88
uint256 cumulativeMinus = cumulative - percentage;
93
- return
94
- stableCoinAmount >= cumulativeMinus &&
95
- stableCoinAmount <= cumulativePlus;
89
+ return stableCoinAmount >= cumulativeMinus && stableCoinAmount <= cumulativePlus;
96
90
}
97
91
98
92
/**
@@ -124,29 +118,29 @@ contract UnifiedStableFarming is IUnifiedStableFarming {
124
118
amountB
125
119
);
126
120
// Mint $uSD
127
- IStableCoin (stableCoinAddress).mint (pairIndex, amount0, amount1, amount0Min, amount1Min );
121
+ IStableCoin (stableCoinAddress).mint (pairIndex, amountA, amountB, amountAMin, amountBMin );
128
122
// For each of the chosen output pair swap $uSD to obtain the desired amount of stablecoin
129
123
for (uint256 i = 0 ; i < tokenIndices.length ; i++ ) {
130
124
_swap (
131
125
stableCoinAddress,
132
- tokenIndices[i] == 0 ? token0 : token1 ,
126
+ tokenIndices[i] == 0 ? tokenA : tokenB ,
133
127
stableCoinAmounts[i],
134
128
msg .sender
135
129
);
136
130
}
137
131
// Send the tokens back to their owner
138
- _flushToSender (token0, token1 , stableCoinAddress);
132
+ _flushToSender (tokenA, tokenB , stableCoinAddress);
139
133
}
140
134
141
135
function _transferTokens (
142
136
address stableCoinAddress ,
143
137
uint256 pairIndex ,
144
- uint256 amount0 ,
145
- uint256 amount1
138
+ uint256 amountA ,
139
+ uint256 amountB
146
140
) private {
147
- (address token0 , address token1 , ) = _getPairData (stableCoinAddress, pairIndex);
148
- IERC20 (token0 ).transferFrom (msg .sender , address (this ), amount0 );
149
- IERC20 (token1 ).transferFrom (msg .sender , address (this ), amount1 );
141
+ (address tokenA , address tokenB , ) = _getPairData (stableCoinAddress, pairIndex);
142
+ IERC20 (tokenA ).transferFrom (msg .sender , address (this ), amountA );
143
+ IERC20 (tokenB ).transferFrom (msg .sender , address (this ), amountB );
150
144
}
151
145
152
146
function _getPairData (address stableCoinAddress , uint256 pairIndex )
@@ -200,13 +194,13 @@ contract UnifiedStableFarming is IUnifiedStableFarming {
200
194
}
201
195
202
196
function _flushToSender (
203
- address token0 ,
204
- address token1 ,
205
- address token2
197
+ address tokenA ,
198
+ address tokenB ,
199
+ address tokenC
206
200
) private {
207
- _flushToSender (token0 );
208
- _flushToSender (token1 );
209
- _flushToSender (token2 );
201
+ _flushToSender (tokenA );
202
+ _flushToSender (tokenB );
203
+ _flushToSender (tokenC );
210
204
}
211
205
212
206
/**
0 commit comments