From b01bbb2a76461446e69208b3eac5ed8e41207975 Mon Sep 17 00:00:00 2001 From: Sam MacPherson Date: Wed, 24 Apr 2024 14:03:01 +0700 Subject: [PATCH] add balancer rate provider oracle --- test/DSRBalancerRateProviderAdapter.t.sol | 49 +++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 test/DSRBalancerRateProviderAdapter.t.sol diff --git a/test/DSRBalancerRateProviderAdapter.t.sol b/test/DSRBalancerRateProviderAdapter.t.sol new file mode 100644 index 0000000..2da5881 --- /dev/null +++ b/test/DSRBalancerRateProviderAdapter.t.sol @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later +pragma solidity ^0.8.0; + +import "forge-std/Test.sol"; + +import { IDSROracle } from "../src/interfaces/IDSROracle.sol"; +import { DSRBalancerRateProviderAdapter } from "../src/adapters/DSRBalancerRateProviderAdapter.sol"; + +contract DSROracleMock { + + uint256 public conversionRate; + + constructor(uint256 _conversionRate) { + conversionRate = _conversionRate; + } + + function getConversionRateBinomialApprox() external view returns (uint256) { + return conversionRate; + } + + function setConversionRate(uint256 _conversionRate) external { + conversionRate = _conversionRate; + } + +} + +contract DSRBalancerRateProviderAdapterTest is Test { + + DSROracleMock oracle; + + DSRBalancerRateProviderAdapter adapter; + + function setUp() public { + oracle = new DSROracleMock(1e27); + adapter = new DSRBalancerRateProviderAdapter(IDSROracle(address(oracle))); + } + + function test_constructor() public { + adapter = new DSRBalancerRateProviderAdapter(IDSROracle(address(oracle))); + assertEq(address(adapter.dsrOracle()), address(oracle)); + } + + function test_getRate() public { + assertEq(adapter.getRate(), 1e18); + oracle.setConversionRate(1.2e27); + assertEq(adapter.getRate(), 1.2e18); + } + +}