Skip to content

Commit

Permalink
Test failing with unsupported identifier error
Browse files Browse the repository at this point in the history
  • Loading branch information
ckoopmann committed Dec 18, 2023
1 parent a73d98b commit 05ec545
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 35 deletions.
11 changes: 10 additions & 1 deletion contracts/interfaces/OptimisticOracleV3Interface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ interface OptimisticOracleV3Interface {
uint256 finalFee; // Final fee of the currency.
}

/**
* @notice Disputes an assertion. Depending on how the assertion was configured, this may either escalate to the UMA
* DVM or the configured escalation manager for arbitration.
* @dev The caller must approve this contract to spend at least bond amount of currency for the associated assertion.
* @param assertionId unique identifier for the assertion to dispute.
* @param disputer receives bonds back at settlement.
*/
function disputeAssertion(bytes32 assertionId, address disputer) external;

/**
* @notice Returns the default identifier used by the Optimistic Oracle V3.
* @return The default identifier.
Expand Down Expand Up @@ -167,4 +176,4 @@ interface OptimisticOracleV3Interface {
);

event AdminPropertiesSet(IERC20 defaultCurrency, uint64 defaultLiveness, uint256 burnedBondPercentage);
}
}
6 changes: 5 additions & 1 deletion contracts/mocks/OptimisticOracleV3Mock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ contract OptimisticOracleV3Mock is OptimisticOracleV3Interface {
return (false);
}

function disputeAssertion(bytes32 assertionId, address disputer) external override {
revert("Not implemented");
}

// Mock implementation of getMinimumBond
function getMinimumBond(address ) public view override returns (uint256) {
return (uint256(0));
Expand All @@ -95,4 +99,4 @@ contract OptimisticOracleV3Mock is OptimisticOracleV3Interface {
callbackInterface(target).assertionResolvedCallback(assertionId, truthfully);
}

}
}
7 changes: 6 additions & 1 deletion test/integration/ethereum/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const PRODUCTION_ADDRESSES = {
debtIssuanceModuleV2: "0xa0a98EB7Af028BE00d04e46e1316808A62a8fd59",
notionalTradeModule: "0x600d9950c6ecAef98Cc42fa207E92397A6c43416",
integrationRegistry: "0xb9083dee5e8273E54B9DB4c31bA9d4aB7C6B28d3",
auctionModuleV1: "0x59D55D53a715b3B4581c52098BCb4075C2941DBa",
auctionModuleV1: "0x59D55D53a715b3B4581c52098BCb4075C2941DBa",
tradeModule: "0xFaAB3F8f3678f68AA0d307B66e71b636F82C28BF",
airdropModule: "0x09b9e7c7e2daf40fCb286fE6b863e517d5d5c40F",
aaveV3LeverageStrategyExtension: "0x7d3f7EDD04916F3Cb2bC6740224c636B9AE43200",
Expand All @@ -88,6 +88,11 @@ export const PRODUCTION_ADDRESSES = {
nUpgreadableBeacon: "0xFAaF0C5B81E802C231A5249221cfe0B6ae639118",
},
},
oracles: {
uma: {
optimisticOracleV3: "0xfb55F43fB9F48F63f9269DB7Dde3BbBe1ebDC0dE",
},
},
};

export const STAGING_ADDRESSES = structuredClone(PRODUCTION_ADDRESSES);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Address, Account } from "@utils/types";
import { ADDRESS_ZERO, ZERO } from "@utils/constants";
import {
OptimisticAuctionRebalanceExtension,
OptimisticOracleV3Mock,
} from "@utils/contracts/index";
import {
AuctionRebalanceModuleV1,
Expand All @@ -17,6 +16,10 @@ import {
BaseManagerV2__factory,
IntegrationRegistry,
IntegrationRegistry__factory,
IWETH,
IWETH__factory,
OptimisticOracleV3Interface,
OptimisticOracleV3Interface__factory,
} from "../../../typechain";
import DeployHelper from "@utils/deploys";
import { impersonateAccount } from "./utils";
Expand All @@ -31,6 +34,7 @@ import {
getRandomAccount,
} from "@utils/index";
import { BigNumber, ContractTransaction, utils, Signer } from "ethers";
import { ethers } from "hardhat";
import base58 from "bs58";

const expect = getWaffleExpect();
Expand Down Expand Up @@ -69,16 +73,16 @@ if (process.env.INTEGRATIONTEST) {
let integrationRegistry: IntegrationRegistry;

let priceAdapter: ConstantPriceAdapter;

let optimisticOracleV3Mock: OptimisticOracleV3Mock;

let optimisticOracleV3MockUpgraded: OptimisticOracleV3Mock;
let optimisticOracleV3: OptimisticOracleV3Interface;

let collateralAssetAddress: string;

let useAssetAllowlist: boolean;
let allowedAssets: Address[];

let weth: IWETH;
let minimumBond: BigNumber;

before(async () => {
[owner, methodologist] = await getAccounts();

Expand All @@ -88,9 +92,14 @@ if (process.env.INTEGRATIONTEST) {
contractAddresses.setFork.constantPriceAdapter,
owner.wallet,
);
optimisticOracleV3Mock = await deployer.mocks.deployOptimisticOracleV3Mock();
optimisticOracleV3MockUpgraded = await deployer.mocks.deployOptimisticOracleV3Mock();
collateralAssetAddress = contractAddresses.tokens.weth;
weth = IWETH__factory.connect(contractAddresses.tokens.weth, owner.wallet);
collateralAssetAddress = weth.address;

optimisticOracleV3 = OptimisticOracleV3Interface__factory.connect(
contractAddresses.oracles.uma.optimisticOracleV3,
owner.wallet,
);
minimumBond = await optimisticOracleV3.getMinimumBond(collateralAssetAddress);

integrationRegistry = IntegrationRegistry__factory.connect(
contractAddresses.setFork.integrationRegistry,
Expand Down Expand Up @@ -125,23 +134,26 @@ if (process.env.INTEGRATIONTEST) {
addSnapshotBeforeRestoreAfterEach();

context("when auction rebalance extension is added as extension", () => {

beforeEach(async () => {
await baseManager.addExtension(auctionRebalanceExtension.address);
});

context("when the product settings have been set", () => {
let productSettings: any;
beforeEach(async () => {
await auctionRebalanceExtension.connect(operator).setProductSettings(
{
collateral: collateralAssetAddress,
liveness: BigNumber.from(0),
bondAmount: BigNumber.from(0),
identifier: utils.formatBytes32String(""),
optimisticOracleV3: optimisticOracleV3Mock.address,
},
utils.arrayify(base58ToHexString("Qmc5gCcjYypU7y28oCALwfSvxCBskLuPKWpK4qpterKC7z")),
);
productSettings = {
collateral: collateralAssetAddress,
liveness: BigNumber.from(0),
bondAmount: BigNumber.from(0),
identifier: utils.formatBytes32String(""),
optimisticOracleV3: optimisticOracleV3.address,
};
await auctionRebalanceExtension
.connect(operator)
.setProductSettings(
productSettings,
utils.arrayify(base58ToHexString("Qmc5gCcjYypU7y28oCALwfSvxCBskLuPKWpK4qpterKC7z")),
);
});

context("when a rebalance has been proposed", () => {
Expand All @@ -155,6 +167,8 @@ if (process.env.INTEGRATIONTEST) {
let subjectPositionMultiplier: BigNumber;
let subjectCaller: Signer;
beforeEach(async () => {
const effectiveBond = productSettings.bondAmount.gt(minimumBond) ? productSettings.bondAmount : minimumBond;

subjectQuoteAsset = contractAddresses.tokens.weth;

subjectOldComponents = await dsEth.getComponents();
Expand All @@ -179,6 +193,16 @@ if (process.env.INTEGRATIONTEST) {
subjectRebalanceDuration = BigNumber.from(86400);
subjectPositionMultiplier = ether(0.999);
subjectCaller = operator;

const quantity = utils.parseEther("1000").add(effectiveBond).toHexString();
console.log("quantity", quantity);
// set operator balance to effective bond
await ethers.provider.send("hardhat_setBalance", [
await subjectCaller.getAddress(),
quantity,
]);
await weth.connect(subjectCaller).deposit({ value: effectiveBond });
await weth.connect(subjectCaller).approve(auctionRebalanceExtension.address, effectiveBond);
});
describe("#startRebalance", () => {
async function subject(): Promise<ContractTransaction> {
Expand Down Expand Up @@ -343,10 +367,7 @@ if (process.env.INTEGRATIONTEST) {
beforeEach(async () => {
const price = await priceAdapter.getEncodedData(ether(1));
const setComponents = await dsEth.getComponents();
subjectOldComponents = [
...setComponents,
contractAddresses.tokens.dai,
];
subjectOldComponents = [...setComponents, contractAddresses.tokens.dai];
subjectOldComponentsAuctionParams = subjectOldComponents.map(() => {
return {
targetUnit: ether(50),
Expand Down Expand Up @@ -389,7 +410,7 @@ if (process.env.INTEGRATIONTEST) {
});
describe("assertionDisputedCallback", () => {
it("should delete the proposal on a disputed callback", async () => {
await auctionRebalanceExtension
const tx = await auctionRebalanceExtension
.connect(subjectCaller)
.proposeRebalance(
subjectQuoteAsset,
Expand All @@ -401,18 +422,20 @@ if (process.env.INTEGRATIONTEST) {
subjectRebalanceDuration,
subjectPositionMultiplier,
);
const receipt = await tx.wait();
// Extract AssertedClaim event
console.log("Events:", receipt.events);
const proposalId = 0;

const proposal = await auctionRebalanceExtension
.connect(subjectCaller)
.proposedProduct(utils.formatBytes32String("win"));
expect(proposal.product).to.eq(dsEth.address);

await expect(
optimisticOracleV3Mock
optimisticOracleV3
.connect(subjectCaller)
.mockAssertionDisputedCallback(
auctionRebalanceExtension.address,
utils.formatBytes32String("win"),
),
.disputeAssertion(proposalId, owner.address),
).to.not.be.reverted;

const proposalAfter = await auctionRebalanceExtension
Expand All @@ -439,7 +462,7 @@ if (process.env.INTEGRATIONTEST) {
liveness: BigNumber.from(0),
bondAmount: BigNumber.from(0),
identifier: utils.formatBytes32String(""),
optimisticOracleV3: optimisticOracleV3MockUpgraded.address,
optimisticOracleV3: optimisticOracleV3.address,
},
utils.arrayify(base58ToHexString("Qmc5gCcjYypU7y28oCALwfSvxCBskLuPKWpK4qpterKC7z")),
);
Expand All @@ -448,7 +471,7 @@ if (process.env.INTEGRATIONTEST) {
.proposedProduct(utils.formatBytes32String("win"));
expect(proposal.product).to.eq(dsEth.address);
await expect(
optimisticOracleV3Mock
optimisticOracleV3
.connect(subjectCaller)
.mockAssertionDisputedCallback(
auctionRebalanceExtension.address,
Expand Down Expand Up @@ -476,7 +499,7 @@ if (process.env.INTEGRATIONTEST) {
subjectPositionMultiplier,
);
await expect(
optimisticOracleV3Mock
optimisticOracleV3
.connect(subjectCaller)
.mockAssertionResolvedCallback(
auctionRebalanceExtension.address,
Expand Down

0 comments on commit 05ec545

Please sign in to comment.