Some checks failed
CI/CD Pipeline / Solidity Contracts (push) Failing after 1m11s
CI/CD Pipeline / Security Scanning (push) Has been cancelled
CI/CD Pipeline / Lint and Format (push) Has been cancelled
CI/CD Pipeline / Terraform Validation (push) Has been cancelled
CI/CD Pipeline / Kubernetes Validation (push) Has been cancelled
Validation / validate-genesis (push) Has been cancelled
Validation / validate-terraform (push) Has been cancelled
Validation / validate-kubernetes (push) Has been cancelled
Validation / validate-smart-contracts (push) Has been cancelled
Validation / validate-security (push) Has been cancelled
Validation / validate-documentation (push) Has been cancelled
Deploy ChainID 138 / Deploy ChainID 138 (push) Failing after 1m4s
HYBX OMNL TypeScript & anchor / token-aggregation build + reconcile artifact (push) Failing after 31s
OMNL reconcile anchor / Run omnl:reconcile and upload artifacts (push) Failing after 29s
Verify Deployment / Verify Deployment (push) Failing after 57s
Relay router, reserve system, oracle publisher, token-aggregation compliance middleware, and Monad deployment scripts. Co-authored-by: Cursor <cursoragent@cursor.com>
50 lines
1.8 KiB
Solidity
50 lines
1.8 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.20;
|
|
|
|
import {Test} from "forge-std/Test.sol";
|
|
import {ReserveSystem} from "../../contracts/reserve/ReserveSystem.sol";
|
|
import {ReserveConversionPriceAdapter} from "../../contracts/reserve/ReserveConversionPriceAdapter.sol";
|
|
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
|
|
|
contract MockERC20Adapter is ERC20 {
|
|
constructor(string memory name, string memory symbol) ERC20(name, symbol) {}
|
|
}
|
|
|
|
contract ReserveConversionPriceAdapterTest is Test {
|
|
ReserveSystem public reserveSystem;
|
|
ReserveConversionPriceAdapter public adapter;
|
|
MockERC20Adapter public weth;
|
|
MockERC20Adapter public usdc;
|
|
|
|
address public admin = address(0x1);
|
|
address public priceFeedOperator = address(0x3);
|
|
|
|
function setUp() public {
|
|
reserveSystem = new ReserveSystem(admin);
|
|
adapter = new ReserveConversionPriceAdapter(address(reserveSystem));
|
|
weth = new MockERC20Adapter("WETH", "WETH");
|
|
usdc = new MockERC20Adapter("USDC", "USDC");
|
|
|
|
vm.startPrank(admin);
|
|
reserveSystem.grantRole(reserveSystem.PRICE_FEED_ROLE(), priceFeedOperator);
|
|
reserveSystem.addSupportedAsset(address(weth), true);
|
|
reserveSystem.addSupportedAsset(address(usdc), true);
|
|
vm.stopPrank();
|
|
|
|
vm.startPrank(priceFeedOperator);
|
|
reserveSystem.updatePriceFeed(address(weth), 1732e18, block.timestamp);
|
|
reserveSystem.updatePriceFeed(address(usdc), 1e18, block.timestamp);
|
|
vm.stopPrank();
|
|
}
|
|
|
|
function test_adapter_getConversionPrice_quotePerBase() public view {
|
|
uint256 conv = adapter.getConversionPrice(address(weth), address(usdc));
|
|
assertEq(conv, 1732e18);
|
|
}
|
|
|
|
function test_adapter_getPrice_delegates() public view {
|
|
(uint256 price,) = adapter.getPrice(address(weth));
|
|
assertEq(price, 1732e18);
|
|
}
|
|
}
|