Skip to content
Merged
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
30 changes: 22 additions & 8 deletions test/Adapters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,40 +26,34 @@ describe("Price Adapter", function () {
beforeEach(async function () {
[owner, automationRegistry] = await ethers.getSigners();

// Deploy Mock Underlying Asset
const MockUnderlyingAssetFactory = await ethers.getContractFactory("MockUnderlyingAsset");
const underlyingAssetDeployed = await MockUnderlyingAssetFactory.deploy(12);
await underlyingAssetDeployed.waitForDeployment();
underlyingAsset = underlyingAssetDeployed as unknown as MockUnderlyingAsset;

// Deploy Mock ERC20 Asset (different from underlying asset)
const MockERC20AssetFactory = await ethers.getContractFactory("MockUnderlyingAsset");
const mockAsset1Deployed = await MockERC20AssetFactory.deploy(10);
await mockAsset1Deployed.waitForDeployment();
mockAsset1 = mockAsset1Deployed as unknown as MockUnderlyingAsset;

// Deploy OrionConfig
const OrionConfigFactory = await ethers.getContractFactory("OrionConfig");
const orionConfigDeployed = await OrionConfigFactory.deploy(owner.address, await underlyingAsset.getAddress());
await orionConfigDeployed.waitForDeployment();
orionConfig = orionConfigDeployed as unknown as OrionConfig;

// Deploy Price Adapter
const OrionAssetERC4626PriceAdapterFactory = await ethers.getContractFactory("OrionAssetERC4626PriceAdapter");
priceAdapter = (await OrionAssetERC4626PriceAdapterFactory.deploy(
await orionConfig.getAddress(),
)) as unknown as OrionAssetERC4626PriceAdapter;
await priceAdapter.waitForDeployment();

// Deploy Price Adapter Registry
const PriceAdapterRegistryFactory = await ethers.getContractFactory("PriceAdapterRegistry");
priceAdapterRegistry = (await PriceAdapterRegistryFactory.deploy(
owner.address,
await orionConfig.getAddress(),
)) as unknown as PriceAdapterRegistry;
await priceAdapterRegistry.waitForDeployment();

// Deploy LiquidityOrchestrator
const LiquidityOrchestratorFactory = await ethers.getContractFactory("LiquidityOrchestrator");
const liquidityOrchestratorDeployed = await LiquidityOrchestratorFactory.deploy(
owner.address,
Expand All @@ -69,7 +63,6 @@ describe("Price Adapter", function () {
await liquidityOrchestratorDeployed.waitForDeployment();
liquidityOrchestrator = liquidityOrchestratorDeployed as unknown as LiquidityOrchestrator;

// Deploy InternalStatesOrchestrator
const InternalStatesOrchestratorFactory = await ethers.getContractFactory("InternalStatesOrchestrator");
const internalStatesOrchestratorDeployed = await InternalStatesOrchestratorFactory.deploy(
owner.address,
Expand All @@ -79,7 +72,6 @@ describe("Price Adapter", function () {
await internalStatesOrchestratorDeployed.waitForDeployment();
internalStatesOrchestrator = internalStatesOrchestratorDeployed as unknown as InternalStatesOrchestrator;

// Set up OrionConfig
await orionConfig.setLiquidityOrchestrator(await liquidityOrchestrator.getAddress());
await orionConfig.setInternalStatesOrchestrator(await internalStatesOrchestrator.getAddress());
await orionConfig.setPriceAdapterRegistry(await priceAdapterRegistry.getAddress());
Expand All @@ -99,5 +91,27 @@ describe("Price Adapter", function () {
),
).to.be.revertedWithCustomError(priceAdapter, "InvalidAdapter");
});

it("should revert with InvalidAdapter when trying to whitelist a regular ERC20 token with ERC4626 execution adapter", async function () {
const MockPriceAdapterFactory = await ethers.getContractFactory("MockPriceAdapter");
const mockPriceAdapter = await MockPriceAdapterFactory.deploy();
await mockPriceAdapter.waitForDeployment();

const OrionAssetERC4626ExecutionAdapterFactory = await ethers.getContractFactory(
"OrionAssetERC4626ExecutionAdapter",
);
const erc4626ExecutionAdapter = await OrionAssetERC4626ExecutionAdapterFactory.deploy(
await orionConfig.getAddress(),
);
await erc4626ExecutionAdapter.waitForDeployment();

await expect(
orionConfig.addWhitelistedAsset(
await mockAsset1.getAddress(),
await mockPriceAdapter.getAddress(),
await erc4626ExecutionAdapter.getAddress(),
),
).to.be.revertedWithCustomError(erc4626ExecutionAdapter, "InvalidAdapter");
});
});
});
Loading
Loading