Some checks failed
CI/CD Pipeline / Solidity Contracts (push) Failing after 1m18s
CI/CD Pipeline / Security Scanning (push) Successful in 2m27s
CI/CD Pipeline / Lint and Format (push) Failing after 46s
CI/CD Pipeline / Terraform Validation (push) Failing after 28s
CI/CD Pipeline / Kubernetes Validation (push) Successful in 29s
Deploy ChainID 138 / Deploy ChainID 138 (push) Failing after 1m0s
HYBX OMNL TypeScript & anchor / token-aggregation build + reconcile artifact (push) Failing after 29s
Validation / validate-genesis (push) Successful in 30s
Validation / validate-terraform (push) Failing after 32s
Validation / validate-kubernetes (push) Failing after 10s
Validation / validate-smart-contracts (push) Failing after 13s
Validation / validate-security (push) Failing after 1m23s
Validation / validate-documentation (push) Failing after 22s
Verify Deployment / Verify Deployment (push) Failing after 11m53s
- CWTokenMarketRegistry + USD feeds for mainnet cW* market anchors - HYBX cross-chain treasury line registry expansion - PMM seed default → live DODOPMMIntegration (0x86ADA6Ef…) - mint-xau-chain138: troy-ounce mint helper with multisig path - relay: prefer CCIP_MAINNET_LINK138 relayer key on default profile Co-authored-by: Cursor <cursoragent@cursor.com>
78 lines
2.6 KiB
Solidity
78 lines
2.6 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.20;
|
|
|
|
import {Test} from "forge-std/Test.sol";
|
|
import {CWTokenMarketRegistry} from "../../contracts/mainnet-market/CWTokenMarketRegistry.sol";
|
|
import {CWTokenUsdFeed} from "../../contracts/mainnet-market/CWTokenUsdFeed.sol";
|
|
|
|
contract CWTokenMarketRegistryTest is Test {
|
|
CWTokenMarketRegistry registry;
|
|
MockErc20 token;
|
|
CWTokenUsdFeed feed;
|
|
|
|
function setUp() public {
|
|
registry = new CWTokenMarketRegistry(address(this));
|
|
token = new MockErc20(6, 15_452_106_931_334_998_000_000);
|
|
feed = new CWTokenUsdFeed(registry, address(token), "test cWUSD / USD");
|
|
registry.registerToken(address(token), 6, 100_000_000, address(0), true, address(feed));
|
|
}
|
|
|
|
function test_latestRoundData_faceBootstrap() public view {
|
|
(, int256 answer,,,) = feed.latestRoundData();
|
|
assertEq(answer, 100_000_000);
|
|
}
|
|
|
|
function test_onchainMarketCap() public view {
|
|
uint256 cap = registry.onchainMarketCapUsdE8(address(token));
|
|
assertEq(cap, 15_452_106_931_334_998_000_000 * 100_000_000 / 1e6);
|
|
}
|
|
|
|
function test_publishPrice_updatesFeed() public {
|
|
registry.publishPrice(address(token), 99_500_000, "univ3_twap");
|
|
(, int256 answer,,,) = feed.latestRoundData();
|
|
assertEq(answer, 99_500_000);
|
|
}
|
|
|
|
function test_publishPrice_revertsOutsidePegBand() public {
|
|
vm.expectRevert(bytes("peg band"));
|
|
registry.publishPrice(address(token), 50_000_000, "bad");
|
|
}
|
|
|
|
function test_registerToken_revertsFeedMismatch() public {
|
|
CWTokenUsdFeed badFeed = new CWTokenUsdFeed(registry, address(0xBEEF), "bad");
|
|
vm.expectRevert(bytes("feed mismatch"));
|
|
registry.registerToken(address(0xCAFE), 6, 100_000_000, address(0), true, address(badFeed));
|
|
}
|
|
|
|
function test_recordX402Settlement() public {
|
|
registry.recordX402Settlement(
|
|
address(token),
|
|
address(0x4A66),
|
|
address(0x6435),
|
|
10_000,
|
|
10_000,
|
|
8453,
|
|
bytes32(uint256(1)),
|
|
keccak256("resource")
|
|
);
|
|
(,,,,,,,, uint256 settlementCount) = registry.tokens(address(token));
|
|
assertEq(settlementCount, 1);
|
|
}
|
|
|
|
function test_pauseBlocksPublish() public {
|
|
registry.pause();
|
|
vm.expectRevert(bytes("paused"));
|
|
registry.publishPrice(address(token), 100_000_000, "x");
|
|
}
|
|
}
|
|
|
|
contract MockErc20 {
|
|
uint8 public decimals;
|
|
uint256 public totalSupply;
|
|
|
|
constructor(uint8 d, uint256 supply) {
|
|
decimals = d;
|
|
totalSupply = supply;
|
|
}
|
|
}
|