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
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ This subgraph indexes events emitted by the "Skinny Optimistic Oracle" contracts

- Mainnet
- TheGraph: <https://thegraph.com/studio/subgraph/mainnet-skinny-oo>
- Goldsky:
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/mainnet-skinny-optimistic-oracle/1.1.0/gn>
- (testnet) Sepolia
- TheGraph: <https://thegraph.com/studio/subgraph/sepolia-skinny-oo>
- Goldsky:
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/sepolia-skinny-optimistic-oracle/1.1.0/gn>

## Optimistic Oracle Events

Expand Down Expand Up @@ -107,16 +107,16 @@ This subgraph indexes events and function calls by the "Optimistic Oracle V2" co

- Mainnet
- TheGraph: <https://thegraph.com/studio/subgraph/mainnet-optimistic-oracle-v2>
- Goldsky: <>
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/mainnet-optimistic-oracle-v2/latest/gn>
- Polygon
- TheGraph: <https://thegraph.com/studio/subgraph/polygon-optimistic-oracle-v2>
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/polygon-optimistic-oracle-v2/latest/gn>
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/polygon-optimistic-oracle-v2/1.1.0/gn>
- Arbitrum
- TheGraph: <https://thegraph.com/studio/subgraph/arbitrum-optimistic-oracle-v2>
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/arbitrum-optimistic-oracle-v2/latest/gn>
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/arbitrum-optimistic-oracle-v2/1.1.0/gn>
- Optimism
- TheGraph: <https://thegraph.com/studio/subgraph/optimism-optimistic-oracle-v2>
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/optimism-optimistic-oracle-v2/latest/gn>
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/optimism-optimistic-oracle-v2/1.1.0/gn>
- Boba
- TheGraph: <https://thegraph.com/studio/subgraph/boba-optimistic-oracle-v2>
- Goldsky:
Expand All @@ -126,30 +126,30 @@ This subgraph indexes events and function calls by the "Optimistic Oracle V2" co
- TheGraph: <https://thegraph.coredao.org/subgraphs/name/umaprotocol/core-optimistic-oracle-v2>
- (testnet) Sepolia
- TheGraph: <https://thegraph.com/studio/subgraph/sepolia-optimistic-oracle-v2/>
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/sepolia-optimistic-oracle-v2/1.0.0/gn>
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/sepolia-optimistic-oracle-v2/1.1.0/gn>
- Base
- TheGraph: <https://thegraph.com/studio/subgraph/base-optimistic-oracle-v2>
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/base-optimistic-oracle-v2/latest/gn>
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/base-optimistic-oracle-v2/1.1.0/gn>
- (staging) Base Sepolia
- TheGraph: <https://thegraph.com/studio/subgraph/base-sepolia-oo-v2>
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/base-optimistic-oracle-v2/latest/gn>
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/base-sepolia-optimistic-oracle-v2/1.1.0/gn>
- Blast
- TheGraph: <https://thegraph.com/studio/subgraph/blast-optimistic-oracle-v2>
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/blast-optimistic-oracle-v2/1.0.0/gn>
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/blast-optimistic-oracle-v2/1.1.0/gn>
- Story
- TheGraph:
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/story-optimistic-oracle-v2/0.0.1/gn>
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/story-optimistic-oracle-v2/1.1.0/gn>

## Managed Optimistic Oracle V2 Events and Calls

This subgraph indexes events and function calls by the "Managed Optimistic Oracle V2" contracts. We reuse the code from `packages/optimistic-oracle-v2` because the events emitted are the same.

- Amoy
- TheGraph:
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/amoy-managed-optimistic-oracle-v2/1.0.6/gn>
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/amoy-managed-optimistic-oracle-v2/1.1.0/gn>
- Polygon
- TheGraph:
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/polygon-managed-optimistic-oracle-v2/1.0.3/gn>
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/polygon-managed-optimistic-oracle-v2/1.0.4/gn>

## Financial Contract Events

Expand Down Expand Up @@ -179,7 +179,7 @@ This subgraph indexes events emitted by the core Oracle contracts. The code can

- Mainnet
- TheGraph: <https://thegraph.com/studio/subgraph/mainnet-voting-v2>
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/mainnet-voting-v2/0.1.0/gn>
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/mainnet-voting-v2/0.1.1/gn>
- (testnet) Sepolia
- TheGraph: <https://thegraph.com/studio/subgraph/sepolia-voting-v2/>
- Goldsky: <https://api.goldsky.com/api/public/project_clus2fndawbcc01w31192938i/subgraphs/sepolia-voting-v2/1.0.0/gn>
Expand Down
79 changes: 36 additions & 43 deletions packages/managed-oracle-v2/src/mappings/optimisticOracleV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
SetEventBasedCall,
Settle,
} from "../../generated/ManagedOracleV2/ManagedOracleV2";
import { getManagedRequestId, getOrCreateOptimisticPriceRequest } from "../utils/helpers";
import { createOptimisticPriceRequestId, getManagedRequestId, getOrCreateOptimisticPriceRequest } from "../utils/helpers";
import { CustomBond, CustomLiveness } from "../../generated/schema";

import { Address, BigInt, Bytes, dataSource, log } from "@graphprotocol/graph-ts";
Expand Down Expand Up @@ -89,12 +89,11 @@ export function handleOptimisticRequestPrice(event: RequestPrice): void {
event.params.identifier.toString(),
event.params.ancillaryData.toHex(),
]);
let requestId = event.params.identifier
.toString()
.concat("-")
.concat(event.params.timestamp.toString())
.concat("-")
.concat(event.params.ancillaryData.toHex());
let requestId = createOptimisticPriceRequestId(
event.params.identifier,
event.params.timestamp,
event.params.ancillaryData
);

let request = getOrCreateOptimisticPriceRequest(requestId);

Expand Down Expand Up @@ -184,12 +183,11 @@ export function handleOptimisticProposePrice(event: ProposePrice): void {
event.params.identifier.toString(),
event.params.ancillaryData.toHex(),
]);
let requestId = event.params.identifier
.toString()
.concat("-")
.concat(event.params.timestamp.toString())
.concat("-")
.concat(event.params.ancillaryData.toHex());
let requestId = createOptimisticPriceRequestId(
event.params.identifier,
event.params.timestamp,
event.params.ancillaryData
);

let request = getOrCreateOptimisticPriceRequest(requestId);

Expand Down Expand Up @@ -260,12 +258,11 @@ export function handleOptimisticDisputePrice(event: DisputePrice): void {
event.params.identifier.toString(),
event.params.ancillaryData.toHex(),
]);
let requestId = event.params.identifier
.toString()
.concat("-")
.concat(event.params.timestamp.toString())
.concat("-")
.concat(event.params.ancillaryData.toHex());
let requestId = createOptimisticPriceRequestId(
event.params.identifier,
event.params.timestamp,
event.params.ancillaryData
);

let request = getOrCreateOptimisticPriceRequest(requestId);

Expand Down Expand Up @@ -306,12 +303,11 @@ export function handleOptimisticSettle(event: Settle): void {
event.params.identifier.toString(),
event.params.ancillaryData.toHex(),
]);
let requestId = event.params.identifier
.toString()
.concat("-")
.concat(event.params.timestamp.toString())
.concat("-")
.concat(event.params.ancillaryData.toHex());
let requestId = createOptimisticPriceRequestId(
event.params.identifier,
event.params.timestamp,
event.params.ancillaryData
);

let request = getOrCreateOptimisticPriceRequest(requestId);

Expand Down Expand Up @@ -347,12 +343,11 @@ export function handleSetCustomLiveness(call: SetCustomLivenessCall): void {
call.inputs.ancillaryData.toHex(),
call.inputs.customLiveness.toString(),
]);
let requestId = call.inputs.identifier
.toString()
.concat("-")
.concat(call.inputs.timestamp.toString())
.concat("-")
.concat(call.inputs.ancillaryData.toHex());
let requestId = createOptimisticPriceRequestId(
call.inputs.identifier,
call.inputs.timestamp,
call.inputs.ancillaryData
);

let request = getOrCreateOptimisticPriceRequest(requestId);
request.customLiveness = call.inputs.customLiveness;
Expand All @@ -367,12 +362,11 @@ export function handleSetBond(call: SetBondCall): void {
call.inputs.ancillaryData.toHex(),
call.inputs.bond.toString(),
]);
let requestId = call.inputs.identifier
.toString()
.concat("-")
.concat(call.inputs.timestamp.toString())
.concat("-")
.concat(call.inputs.ancillaryData.toHex());
let requestId = createOptimisticPriceRequestId(
call.inputs.identifier,
call.inputs.timestamp,
call.inputs.ancillaryData
);

let request = getOrCreateOptimisticPriceRequest(requestId);
request.bond = call.inputs.bond;
Expand All @@ -386,12 +380,11 @@ export function handleSetEventBased(call: SetEventBasedCall): void {
call.inputs.identifier.toString(),
call.inputs.ancillaryData.toHex(),
]);
let requestId = call.inputs.identifier
.toString()
.concat("-")
.concat(call.inputs.timestamp.toString())
.concat("-")
.concat(call.inputs.ancillaryData.toHex());
let requestId = createOptimisticPriceRequestId(
call.inputs.identifier,
call.inputs.timestamp,
call.inputs.ancillaryData
);

let request = getOrCreateOptimisticPriceRequest(requestId);
request.eventBased = true;
Expand Down
2 changes: 1 addition & 1 deletion packages/managed-oracle-v2/src/utils/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { getOrCreateOptimisticPriceRequest } from "./optimisticOracle";
export { getOrCreateOptimisticPriceRequest, createOptimisticPriceRequestId } from "./optimisticOracle";
export { getManagedRequestId } from "./managedOracleV2";
20 changes: 18 additions & 2 deletions packages/managed-oracle-v2/src/utils/helpers/optimisticOracle.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
import { Bytes } from "@graphprotocol/graph-ts";
import { BigInt, Bytes, crypto } from "@graphprotocol/graph-ts";
import { OptimisticPriceRequest } from "../../../generated/schema";
import { BIGINT_ZERO } from "../constants";


// Creates a unique ID for an OptimisticPriceRequest entity.
export function createOptimisticPriceRequestId(
identifier: Bytes,
timestamp: BigInt,
ancillaryData: Bytes
): string {
const ancillaryDataHash = crypto.keccak256(ancillaryData).toHexString();
return identifier
.toString()
.concat("-")
.concat(timestamp.toString())
.concat("-")
.concat(ancillaryDataHash);
}

export function getOrCreateOptimisticPriceRequest(
id: String,
id: string,
createIfNotFound: boolean = true
): OptimisticPriceRequest {
let request = OptimisticPriceRequest.load(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { describe, test, clearStore, assert, log, afterEach } from "matchstick-a
import { handleCustomLivenessSet, handleCustomBondSet } from "../../src/mappings/managedOracleV2";
import { handleOptimisticProposePrice, handleOptimisticRequestPrice } from "../../src/mappings/optimisticOracleV2";
import { createCustomBondIdFromEvent } from "../../src/utils/helpers/managedOracleV2";
import { createOptimisticPriceRequestId } from "../../src/utils/helpers/optimisticOracle";
import {
createCustomLivenessSetEvent,
createCustomBondSetEvent,
Expand Down Expand Up @@ -173,7 +174,11 @@ describe("Managed OOv2", () => {
);
handleOptimisticRequestPrice(requestPriceEvent);

const requestId = identifierString.concat("-").concat(timestamp.toString()).concat("-").concat(ancillaryData);
const requestId = createOptimisticPriceRequestId(
Bytes.fromHexString(identifierHex) as Bytes,
BigInt.fromI32(timestamp),
Bytes.fromHexString(ancillaryData) as Bytes
);

const priceRequestEntity = OptimisticPriceRequest.load(requestId);

Expand Down Expand Up @@ -294,7 +299,11 @@ describe("Managed OOv2", () => {
);
handleOptimisticProposePrice(proposePriceEvent);

const requestId = identifierString.concat("-").concat(timestamp.toString()).concat("-").concat(ancillaryData);
const requestId = createOptimisticPriceRequestId(
Bytes.fromHexString(identifierHex) as Bytes,
BigInt.fromI32(timestamp),
Bytes.fromHexString(ancillaryData) as Bytes
);

const priceRequestEntity = OptimisticPriceRequest.load(requestId);

Expand Down Expand Up @@ -389,7 +398,11 @@ describe("Managed OOv2", () => {
);
handleOptimisticRequestPrice(requestPriceEvent);

const requestId = identifierString.concat("-").concat(timestamp.toString()).concat("-").concat(ancillaryData);
const requestId = createOptimisticPriceRequestId(
Bytes.fromHexString(identifierHex) as Bytes,
BigInt.fromI32(timestamp),
Bytes.fromHexString(ancillaryData) as Bytes
);

const priceRequestEntity = OptimisticPriceRequest.load(requestId);

Expand Down
Loading