Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/v2v3 helper support mock oracles #307

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions contracts/mocks/oracle/CLAggregators/MockAggregator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ pragma solidity 0.6.12;

contract MockAggregator {
int256 private _latestAnswer;
uint8 private _decimals;

event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 timestamp);

constructor(int256 _initialAnswer) public {
constructor(int256 _initialAnswer, uint8 _aggregatorDecimals) public {
_latestAnswer = _initialAnswer;
_decimals = _aggregatorDecimals;

emit AnswerUpdated(_initialAnswer, 0, now);
}

Expand All @@ -19,8 +22,11 @@ contract MockAggregator {
return 1;
}

// function getSubTokens() external view returns (address[] memory) {
// TODO: implement mock for when multiple subtokens. Maybe we need to create diff mock contract
// to call it from the migration for this case??
// }
/**
* @notice represents the number of decimals the aggregator responses represent.
* @dev Allows to support UiPoolDataProviderV2V3 that expects Chainlink Aggregators interface.
*/
function decimals() external view returns (uint8) {
return _decimals;
}
}
4 changes: 2 additions & 2 deletions helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const chainlinkAggregatorProxy = {
'arbitrum-rinkeby': '0x5f0423B1a6935dc5596e7A24d98532b67A0AeFd8',
arbitrum: '0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612',
rinkeby: '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e',
goerli: '0x9F54B624fb17d07816C5552f8AB133c21b0322cD',
goerli: '0x7f65Ad9264F6319A818c3cEfc473Cf17e561b5C7',
};

export const chainlinkEthUsdAggregatorProxy = {
Expand All @@ -100,5 +100,5 @@ export const chainlinkEthUsdAggregatorProxy = {
'arbitrum-rinkeby': '0x5f0423B1a6935dc5596e7A24d98532b67A0AeFd8',
arbitrum: '0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612',
rinkeby: '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e',
goerli: '0x9F54B624fb17d07816C5552f8AB133c21b0322cD',
goerli: '0x7f65Ad9264F6319A818c3cEfc473Cf17e561b5C7',
};
2 changes: 1 addition & 1 deletion helpers/contracts-deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export const deployLendingRateOracle = async (verify?: boolean) =>

export const deployMockAggregator = async (price: tStringTokenSmallUnits, verify?: boolean) =>
withSaveAndVerify(
await new MockAggregatorFactory(await getFirstSigner()).deploy(price),
await new MockAggregatorFactory(await getFirstSigner()).deploy(price, 18),
eContractid.MockAggregator,
[price],
verify
Expand Down