diff --git a/src/abi/Oval.ts b/src/abi/Oval.ts deleted file mode 100644 index 502341c..0000000 --- a/src/abi/Oval.ts +++ /dev/null @@ -1,395 +0,0 @@ -// Todo: move to using typechain exports -export const ovalAbi = [ - { - inputs: [ - { internalType: "address", name: "chainlinkSource", type: "address" }, - { internalType: "address", name: "chronicleSource", type: "address" }, - { internalType: "address", name: "pythSource", type: "address" }, - { internalType: "bytes32", name: "pythPriceId", type: "bytes32" }, - { internalType: "uint8", name: "decimals", type: "uint8" }, - ], - stateMutability: "nonpayable", - type: "constructor", - }, - { - anonymous: false, - inputs: [{ indexed: true, internalType: "uint8", name: "decimals", type: "uint8" }], - name: "DecimalsSet", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "uint256", - name: "timestamp", - type: "uint256", - }, - ], - name: "LatestValueUnlocked", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "uint256", - name: "lockWindow", - type: "uint256", - }, - ], - name: "LockWindowSet", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "uint256", - name: "maxTraversal", - type: "uint256", - }, - ], - name: "MaxTraversalSet", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "previousOwner", - type: "address", - }, - { - indexed: true, - internalType: "address", - name: "newOwner", - type: "address", - }, - ], - name: "OwnershipTransferred", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "uint256", - name: "snapshotIndex", - type: "uint256", - }, - { - indexed: true, - internalType: "uint256", - name: "timestamp", - type: "uint256", - }, - { indexed: true, internalType: "int256", name: "answer", type: "int256" }, - ], - name: "SnapshotTaken", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "sourceOracle", - type: "address", - }, - { - indexed: true, - internalType: "bytes32", - name: "pythPriceId", - type: "bytes32", - }, - ], - name: "SourceSet", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "sourceOracle", - type: "address", - }, - ], - name: "SourceSet", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "sourceOracle", - type: "address", - }, - { - indexed: true, - internalType: "uint8", - name: "sourceDecimals", - type: "uint8", - }, - ], - name: "SourceSet", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "unlocker", - type: "address", - }, - { indexed: true, internalType: "bool", name: "allowed", type: "bool" }, - ], - name: "UnlockerSet", - type: "event", - }, - { - inputs: [], - name: "BOUNDING_TOLERANCE", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "CHAINLINK_SOURCE", - outputs: [ - { - internalType: "contract IAggregatorV3Source", - name: "", - type: "address", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "CHRONICLE_SOURCE", - outputs: [{ internalType: "contract IMedian", name: "", type: "address" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "PYTH_PRICE_ID", - outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "PYTH_SOURCE", - outputs: [{ internalType: "contract IPyth", name: "", type: "address" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "caller", type: "address" }, - { internalType: "uint256", name: "_lastUnlockTime", type: "uint256" }, - ], - name: "canUnlock", - outputs: [{ internalType: "bool", name: "", type: "bool" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "decimals", - outputs: [{ internalType: "uint8", name: "", type: "uint8" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "getLatestSourceData", - outputs: [ - { internalType: "int256", name: "answer", type: "int256" }, - { internalType: "uint256", name: "timestamp", type: "uint256" }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "internalLatestData", - outputs: [ - { internalType: "int256", name: "", type: "int256" }, - { internalType: "uint256", name: "", type: "uint256" }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "lastUnlockTime", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "latestAnswer", - outputs: [{ internalType: "int256", name: "", type: "int256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "latestRoundData", - outputs: [ - { internalType: "uint80", name: "", type: "uint80" }, - { internalType: "int256", name: "", type: "int256" }, - { internalType: "uint256", name: "", type: "uint256" }, - { internalType: "uint256", name: "", type: "uint256" }, - { internalType: "uint80", name: "", type: "uint80" }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "latestSnapshotData", - outputs: [ - { - components: [ - { internalType: "int256", name: "answer", type: "int256" }, - { internalType: "uint256", name: "timestamp", type: "uint256" }, - ], - internalType: "struct SnapshotSource.Snapshot", - name: "", - type: "tuple", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "latestTimestamp", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "lockWindow", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "maxTraversal", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "owner", - outputs: [{ internalType: "address", name: "", type: "address" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "renounceOwnership", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [{ internalType: "uint256", name: "newLockWindow", type: "uint256" }], - name: "setLockWindow", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [{ internalType: "uint256", name: "newMaxTraversal", type: "uint256" }], - name: "setMaxTraversal", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "unlocker", type: "address" }, - { internalType: "bool", name: "allowed", type: "bool" }, - ], - name: "setUnlocker", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [], - name: "snapshotData", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [{ internalType: "uint256", name: "", type: "uint256" }], - name: "snapshots", - outputs: [ - { internalType: "int256", name: "answer", type: "int256" }, - { internalType: "uint256", name: "timestamp", type: "uint256" }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [{ internalType: "address", name: "newOwner", type: "address" }], - name: "transferOwnership", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "uint256", name: "timestamp", type: "uint256" }, - { internalType: "uint256", name: "maxTraversal", type: "uint256" }, - ], - name: "tryLatestDataAt", - outputs: [ - { internalType: "int256", name: "", type: "int256" }, - { internalType: "uint256", name: "", type: "uint256" }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "unlockLatestValue", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [{ internalType: "address", name: "", type: "address" }], - name: "unlockers", - outputs: [{ internalType: "bool", name: "", type: "bool" }], - stateMutability: "view", - type: "function", - }, -]; diff --git a/src/abi/index.ts b/src/abi/index.ts deleted file mode 100644 index 1647d16..0000000 --- a/src/abi/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./Oval"; diff --git a/src/abi/oval.json b/src/abi/oval.json new file mode 100644 index 0000000..e8c4c06 --- /dev/null +++ b/src/abi/oval.json @@ -0,0 +1,623 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "chainlinkSource", + "type": "address" + }, + { + "internalType": "address", + "name": "chronicleSource", + "type": "address" + }, + { + "internalType": "address", + "name": "pythSource", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "pythPriceId", + "type": "bytes32" + }, + { + "internalType": "uint8", + "name": "decimals", + "type": "uint8" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint8", + "name": "decimals", + "type": "uint8" + } + ], + "name": "DecimalsSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "LatestValueUnlocked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "lockWindow", + "type": "uint256" + } + ], + "name": "LockWindowSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "maxTraversal", + "type": "uint256" + } + ], + "name": "MaxTraversalSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "snapshotIndex", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "int256", + "name": "answer", + "type": "int256" + } + ], + "name": "SnapshotTaken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sourceOracle", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "pythPriceId", + "type": "bytes32" + } + ], + "name": "SourceSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sourceOracle", + "type": "address" + } + ], + "name": "SourceSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sourceOracle", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint8", + "name": "sourceDecimals", + "type": "uint8" + } + ], + "name": "SourceSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "unlocker", + "type": "address" + }, + { + "indexed": true, + "internalType": "bool", + "name": "allowed", + "type": "bool" + } + ], + "name": "UnlockerSet", + "type": "event" + }, + { + "inputs": [], + "name": "BOUNDING_TOLERANCE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CHAINLINK_SOURCE", + "outputs": [ + { + "internalType": "contract IAggregatorV3Source", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CHRONICLE_SOURCE", + "outputs": [ + { + "internalType": "contract IMedian", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PYTH_PRICE_ID", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PYTH_SOURCE", + "outputs": [ + { + "internalType": "contract IPyth", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_lastUnlockTime", + "type": "uint256" + } + ], + "name": "canUnlock", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLatestSourceData", + "outputs": [ + { + "internalType": "int256", + "name": "answer", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "internalLatestData", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lastUnlockTime", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "latestAnswer", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "latestRoundData", + "outputs": [ + { + "internalType": "uint80", + "name": "", + "type": "uint80" + }, + { + "internalType": "int256", + "name": "", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint80", + "name": "", + "type": "uint80" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "latestSnapshotData", + "outputs": [ + { + "components": [ + { + "internalType": "int256", + "name": "answer", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "internalType": "struct SnapshotSource.Snapshot", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "latestTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lockWindow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxTraversal", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newLockWindow", + "type": "uint256" + } + ], + "name": "setLockWindow", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newMaxTraversal", + "type": "uint256" + } + ], + "name": "setMaxTraversal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "unlocker", + "type": "address" + }, + { + "internalType": "bool", + "name": "allowed", + "type": "bool" + } + ], + "name": "setUnlocker", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "snapshotData", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "snapshots", + "outputs": [ + { + "internalType": "int256", + "name": "answer", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxTraversal", + "type": "uint256" + } + ], + "name": "tryLatestDataAt", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "unlockLatestValue", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "unlockers", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/src/lib/bundleUtils.ts b/src/lib/bundleUtils.ts index ce5e76b..63dcb68 100644 --- a/src/lib/bundleUtils.ts +++ b/src/lib/bundleUtils.ts @@ -7,13 +7,12 @@ import { WalletManager } from "./walletManager"; import MevShareClient, { BundleParams } from "@flashbots/mev-share-client"; import { JSONRPCID, createJSONRPCSuccessResponse } from "json-rpc-2.0"; -import { ovalAbi } from "../abi"; import { env } from "./env"; import { Logger } from "./logging"; import { Refund } from "./types"; -import { PermissionProxy__factory } from "../contract-types"; +import { Oval__factory, PermissionProxy__factory } from "../contract-types"; -export const ovalInterface = Interface.from(ovalAbi); +export const ovalInterface = Oval__factory.createInterface(); export const createUnlockLatestValueTx = async ( wallet: Wallet,