@gearbox-protocol/sdk 2.1.1 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/contracts/PriceFeedDataLive.sol +17 -17
- package/contracts/TokensData.sol +25 -14
- package/package.json +1 -1
|
@@ -54,23 +54,23 @@ struct RedStonePriceFeedData {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
contract PriceFeedDataLive {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
mapping(
|
|
60
|
-
mapping(
|
|
61
|
-
mapping(
|
|
62
|
-
mapping(
|
|
63
|
-
mapping(
|
|
64
|
-
mapping(
|
|
65
|
-
mapping(
|
|
66
|
-
mapping(
|
|
67
|
-
mapping(
|
|
68
|
-
mapping(
|
|
69
|
-
mapping(
|
|
70
|
-
mapping(
|
|
71
|
-
mapping(
|
|
72
|
-
|
|
73
|
-
constructor(
|
|
57
|
+
uint256 networkId;
|
|
58
|
+
|
|
59
|
+
mapping(uint256 => ChainlinkPriceFeedData[]) chainlinkPriceFeedsByNetwork;
|
|
60
|
+
mapping(uint256 => SingeTokenPriceFeedData[]) zeroPriceFeedsByNetwork;
|
|
61
|
+
mapping(uint256 => CurvePriceFeedData[]) curvePriceFeedsByNetwork;
|
|
62
|
+
mapping(uint256 => CurvePriceFeedData[]) curveCryptoPriceFeedsByNetwork;
|
|
63
|
+
mapping(uint256 => TheSamePriceFeedData[]) theSamePriceFeedsByNetwork;
|
|
64
|
+
mapping(uint256 => SingeTokenPriceFeedData[]) yearnPriceFeedsByNetwork;
|
|
65
|
+
mapping(uint256 => BoundedPriceFeedData[]) boundedPriceFeedsByNetwork;
|
|
66
|
+
mapping(uint256 => CompositePriceFeedData[]) compositePriceFeedsByNetwork;
|
|
67
|
+
mapping(uint256 => SingeTokenPriceFeedData) wstethPriceFeedByNetwork;
|
|
68
|
+
mapping(uint256 => GenericLPPriceFeedData[]) wrappedAaveV2PriceFeedsByNetwork;
|
|
69
|
+
mapping(uint256 => GenericLPPriceFeedData[]) compoundV2PriceFeedsByNetwork;
|
|
70
|
+
mapping(uint256 => GenericLPPriceFeedData[]) erc4626PriceFeedsByNetwork;
|
|
71
|
+
mapping(uint256 => RedStonePriceFeedData[]) redStonePriceFeedsByNetwork;
|
|
72
|
+
|
|
73
|
+
constructor(uint256 _networkId) {
|
|
74
74
|
networkId = _networkId;
|
|
75
75
|
// ------------------------ 1INCH ------------------------
|
|
76
76
|
chainlinkPriceFeedsByNetwork[1].push(
|
package/contracts/TokensData.sol
CHANGED
|
@@ -17,9 +17,8 @@ struct TokenData {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
contract TokensDataLive {
|
|
20
|
-
|
|
21
|
-
mapping(
|
|
22
|
-
mapping(uint16 => address) usdcByNetwork;
|
|
20
|
+
mapping(uint256 => TokenData[]) tokenDataByNetwork;
|
|
21
|
+
mapping(uint256 => address) usdcByNetwork;
|
|
23
22
|
|
|
24
23
|
uint16[] public connectedNetworks;
|
|
25
24
|
|
|
@@ -1015,30 +1014,42 @@ contract TokensDataLive {
|
|
|
1015
1014
|
tokenType: TokenType.AAVE_V2_A_TOKEN
|
|
1016
1015
|
})
|
|
1017
1016
|
);
|
|
1018
|
-
|
|
1019
|
-
networkId = getNetworkId();
|
|
1020
1017
|
}
|
|
1021
1018
|
|
|
1022
1019
|
function getTokenData() external view returns (TokenData[] memory) {
|
|
1023
|
-
return tokenDataByNetwork[
|
|
1020
|
+
return tokenDataByNetwork[block.chainid];
|
|
1024
1021
|
}
|
|
1025
1022
|
|
|
1026
|
-
function getNetworkId() internal view returns (
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1023
|
+
function getNetworkId() internal view returns (uint256) {
|
|
1024
|
+
if (block.chainid == 1337 || block.chainid == 31337) {
|
|
1025
|
+
uint256 len = connectedNetworks.length;
|
|
1026
|
+
for (uint256 i = 0; i < len; i++) {
|
|
1027
|
+
if (checkNetworkId(connectedNetworks[i])) {
|
|
1028
|
+
return connectedNetworks[i];
|
|
1029
|
+
}
|
|
1031
1030
|
}
|
|
1032
1031
|
}
|
|
1033
|
-
|
|
1034
|
-
revert("No network found");
|
|
1032
|
+
return block.chainid;
|
|
1035
1033
|
}
|
|
1036
1034
|
|
|
1037
1035
|
function checkNetworkId(uint16 _networkId) internal view returns (bool) {
|
|
1038
|
-
|
|
1036
|
+
address tokenToCheck = usdcByNetwork[_networkId];
|
|
1037
|
+
|
|
1038
|
+
if (!isContract(tokenToCheck)) {
|
|
1039
|
+
return false;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
try IERC20Check(tokenToCheck).totalSupply() returns (uint256) {
|
|
1039
1043
|
return true;
|
|
1040
1044
|
} catch {
|
|
1041
1045
|
return false;
|
|
1042
1046
|
}
|
|
1043
1047
|
}
|
|
1048
|
+
|
|
1049
|
+
// This method relies on extcodesize/address.code.length, which returns 0
|
|
1050
|
+
// for contracts in construction, since the code is only stored at the end
|
|
1051
|
+
// of the constructor execution.
|
|
1052
|
+
function isContract(address account) internal view returns (bool) {
|
|
1053
|
+
return account.code.length > 0;
|
|
1054
|
+
}
|
|
1044
1055
|
}
|