mirror of
https://github.com/Instadapp/dsa-resolvers-deprecated.git
synced 2024-07-29 22:38:16 +00:00
ERC20 and Uniswap changes
This commit is contained in:
parent
075fc2b08a
commit
455cc14548
|
@ -7,7 +7,6 @@ interface TokenInterface {
|
||||||
function decimals() external view returns (uint);
|
function decimals() external view returns (uint);
|
||||||
function name() external view returns (string memory);
|
function name() external view returns (string memory);
|
||||||
function symbol() external view returns (string memory);
|
function symbol() external view returns (string memory);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
contract Resolver {
|
contract Resolver {
|
||||||
|
@ -30,21 +29,32 @@ contract Resolver {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
TokenInterface token = TokenInterface(tknAddress[i]);
|
TokenInterface token = TokenInterface(tknAddress[i]);
|
||||||
|
bool isToken = true;
|
||||||
|
|
||||||
|
try token.symbol() {
|
||||||
|
} catch {
|
||||||
|
isToken = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
try token.name() {
|
try token.name() {
|
||||||
|
} catch {
|
||||||
|
isToken = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try token.decimals() {
|
||||||
|
} catch {
|
||||||
|
isToken = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
tokenDatas[i] = TokenData(
|
tokenDatas[i] = TokenData(
|
||||||
true,
|
true,
|
||||||
token.name(),
|
token.name(),
|
||||||
token.symbol(),
|
token.symbol(),
|
||||||
token.decimals()
|
token.decimals()
|
||||||
);
|
);
|
||||||
} catch {
|
|
||||||
tokenDatas[i] = TokenData(
|
|
||||||
false,
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
0
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tokenDatas;
|
return tokenDatas;
|
||||||
|
@ -81,6 +91,6 @@ contract Resolver {
|
||||||
|
|
||||||
contract InstaERC20Resolver is Resolver {
|
contract InstaERC20Resolver is Resolver {
|
||||||
|
|
||||||
string public constant name = "ERC20-Resolver-v1";
|
string public constant name = "ERC20-Resolver-v1.1";
|
||||||
|
|
||||||
}
|
}
|
|
@ -541,6 +541,8 @@ contract Resolver is UniswapHelpers {
|
||||||
uint reserveB;
|
uint reserveB;
|
||||||
uint tokenAShareAmt;
|
uint tokenAShareAmt;
|
||||||
uint tokenBShareAmt;
|
uint tokenBShareAmt;
|
||||||
|
uint tokenABalance;
|
||||||
|
uint tokenBBalance;
|
||||||
uint lpAmount;
|
uint lpAmount;
|
||||||
uint totalSupply;
|
uint totalSupply;
|
||||||
}
|
}
|
||||||
|
@ -570,17 +572,23 @@ contract Resolver is UniswapHelpers {
|
||||||
uint amtA = wmul(reserveA, share);
|
uint amtA = wmul(reserveA, share);
|
||||||
uint amtB = wmul(reserveB, share);
|
uint amtB = wmul(reserveB, share);
|
||||||
poolData[i] = PoolData(
|
poolData[i] = PoolData(
|
||||||
tokenPairs[i].tokenA,
|
address(0),
|
||||||
tokenPairs[i].tokenB,
|
address(0),
|
||||||
address(lpToken),
|
address(lpToken),
|
||||||
reserveA,
|
reserveA,
|
||||||
reserveB,
|
reserveB,
|
||||||
amtA,
|
amtA,
|
||||||
amtB,
|
amtB,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
lpAmount,
|
lpAmount,
|
||||||
totalSupply
|
totalSupply
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
poolData[i].tokenA = tokenPairs[i].tokenA;
|
||||||
|
poolData[i].tokenB = tokenPairs[i].tokenB;
|
||||||
|
poolData[i].tokenABalance = tokenPairs[i].tokenA == getEthAddr() ? owner.balance : tokenA.balanceOf(owner);
|
||||||
|
poolData[i].tokenBBalance = tokenPairs[i].tokenB == getEthAddr() ? owner.balance : tokenB.balanceOf(owner);
|
||||||
}
|
}
|
||||||
return poolData;
|
return poolData;
|
||||||
}
|
}
|
||||||
|
@ -592,6 +600,8 @@ contract Resolver is UniswapHelpers {
|
||||||
{
|
{
|
||||||
uint _len = lpTokens.length;
|
uint _len = lpTokens.length;
|
||||||
PoolData[] memory poolData = new PoolData[](_len);
|
PoolData[] memory poolData = new PoolData[](_len);
|
||||||
|
address wethAddr = getAddressWETH();
|
||||||
|
address ethAddr = getEthAddr();
|
||||||
for (uint i = 0; i < _len; i++) {
|
for (uint i = 0; i < _len; i++) {
|
||||||
IUniswapV2Pair lpToken = IUniswapV2Pair(lpTokens[i]);
|
IUniswapV2Pair lpToken = IUniswapV2Pair(lpTokens[i]);
|
||||||
(uint256 reserveA, uint256 reserveB, ) = lpToken.getReserves();
|
(uint256 reserveA, uint256 reserveB, ) = lpToken.getReserves();
|
||||||
|
@ -603,13 +613,15 @@ contract Resolver is UniswapHelpers {
|
||||||
uint amtA = wmul(reserveA, share);
|
uint amtA = wmul(reserveA, share);
|
||||||
uint amtB = wmul(reserveB, share);
|
uint amtB = wmul(reserveB, share);
|
||||||
poolData[i] = PoolData(
|
poolData[i] = PoolData(
|
||||||
tokenA,
|
tokenA == wethAddr ? ethAddr : tokenA,
|
||||||
tokenB,
|
tokenB == wethAddr ? ethAddr : tokenB,
|
||||||
address(lpToken),
|
address(lpToken),
|
||||||
reserveA,
|
reserveA,
|
||||||
reserveB,
|
reserveB,
|
||||||
amtA,
|
amtA,
|
||||||
amtB,
|
amtB,
|
||||||
|
tokenA == wethAddr ? owner.balance : TokenInterface(tokenA).balanceOf(owner),
|
||||||
|
tokenB == wethAddr ? owner.balance : TokenInterface(tokenB).balanceOf(owner),
|
||||||
lpAmount,
|
lpAmount,
|
||||||
totalSupply
|
totalSupply
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user