mirror of
https://github.com/Instadapp/smart-contract.git
synced 2024-07-29 22:08:07 +00:00
setApproval gas efficiency
This commit is contained in:
parent
fc3c03d852
commit
3ff43069e1
|
@ -37,7 +37,8 @@ contract Helper {
|
||||||
* @dev get Uniswap Proxy address
|
* @dev get Uniswap Proxy address
|
||||||
*/
|
*/
|
||||||
function getAddressUniFactory() public pure returns (address factory) {
|
function getAddressUniFactory() public pure returns (address factory) {
|
||||||
factory = 0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95;
|
// factory = 0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95;
|
||||||
|
factory = 0xf5D915570BC477f9B8D6C0E980aA81757A3AaC36; // Rinkeby
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get Uniswap's Exchange address from Factory Contract
|
// Get Uniswap's Exchange address from Factory Contract
|
||||||
|
@ -75,9 +76,10 @@ contract Helper {
|
||||||
* @param token is the token address
|
* @param token is the token address
|
||||||
*/
|
*/
|
||||||
function setApproval(address token, uint srcAmt, address to) internal {
|
function setApproval(address token, uint srcAmt, address to) internal {
|
||||||
uint tokenAllowance = IERC20(token).allowance(address(this), to);
|
IERC20 erc20Contract = IERC20(token);
|
||||||
|
uint tokenAllowance = erc20Contract.allowance(address(this), to);
|
||||||
if (srcAmt > tokenAllowance) {
|
if (srcAmt > tokenAllowance) {
|
||||||
IERC20(token).approve(to, 2**255);
|
erc20Contract.approve(to, 2**255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user