From 87e2077c6985a75311e528feb795eca4080288f2 Mon Sep 17 00:00:00 2001 From: Nick Poulden Date: Thu, 28 Sep 2023 10:41:16 -0600 Subject: [PATCH] Track YieldDistribution events --- abi/oeth-vault.json | 760 ++++++++++++++ ...39072092-Data.js => 1695855931552-Data.js} | 6 +- schema.graphql | 2 + src/abi/oeth-vault.abi.ts | 970 ++++++++++++++++++ src/abi/oeth-vault.ts | 298 ++++++ src/model/generated/rebase.model.ts | 6 + src/processors/oeth/oeth.ts | 137 ++- src/processors/oeth/utils.ts | 6 + 8 files changed, 2133 insertions(+), 52 deletions(-) create mode 100644 abi/oeth-vault.json rename db/migrations/{1695839072092-Data.js => 1695855931552-Data.js} (97%) create mode 100644 src/abi/oeth-vault.abi.ts create mode 100644 src/abi/oeth-vault.ts diff --git a/abi/oeth-vault.json b/abi/oeth-vault.json new file mode 100644 index 00000000..972cc9f8 --- /dev/null +++ b/abi/oeth-vault.json @@ -0,0 +1,760 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "_threshold", + "type": "uint256" + } + ], + "name": "AllocateThresholdUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "_strategy", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "AssetAllocated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "_strategy", + "type": "address" + } + ], + "name": "AssetDefaultStrategyUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_asset", + "type": "address" + } + ], + "name": "AssetSupported", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "CapitalPaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "CapitalUnpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousGovernor", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newGovernor", + "type": "address" + } + ], + "name": "GovernorshipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "maxSupplyDiff", + "type": "uint256" + } + ], + "name": "MaxSupplyDiffChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_addr", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_value", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "_threshold", + "type": "uint256" + } + ], + "name": "NetOusdMintForStrategyThresholdChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_ousdMetaStrategy", + "type": "address" + } + ], + "name": "OusdMetaStrategyUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousGovernor", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newGovernor", + "type": "address" + } + ], + "name": "PendingGovernorshipTransfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_priceProvider", + "type": "address" + } + ], + "name": "PriceProviderUpdated", + "type": "event" + }, + { "anonymous": false, "inputs": [], "name": "RebasePaused", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "_threshold", + "type": "uint256" + } + ], + "name": "RebaseThresholdUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "RebaseUnpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_addr", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_value", + "type": "uint256" + } + ], + "name": "Redeem", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "_redeemFeeBps", + "type": "uint256" + } + ], + "name": "RedeemFeeUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "StrategistUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_addr", + "type": "address" + } + ], + "name": "StrategyApproved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_addr", + "type": "address" + } + ], + "name": "StrategyRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "TrusteeAddressChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "_basis", + "type": "uint256" + } + ], + "name": "TrusteeFeeBpsChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "_vaultBuffer", + "type": "uint256" + } + ], + "name": "VaultBufferUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_yield", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_fee", + "type": "uint256" + } + ], + "name": "YieldDistribution", + "type": "event" + }, + { + "inputs": [ + { "internalType": "address", "name": "_addr", "type": "address" } + ], + "name": "approveStrategy", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "assetDefaultStrategies", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "autoAllocateThreshold", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_asset", "type": "address" } + ], + "name": "cacheDecimals", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "capitalPaused", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "claimGovernance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_strategyToAddress", + "type": "address" + }, + { "internalType": "address[]", "name": "_assets", "type": "address[]" }, + { "internalType": "uint256[]", "name": "_amounts", "type": "uint256[]" } + ], + "name": "depositToStrategy", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "governor", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_priceProvider", + "type": "address" + }, + { "internalType": "address", "name": "_ousd", "type": "address" } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "isGovernor", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxSupplyDiff", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "netOusdMintForStrategyThreshold", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "netOusdMintedForStrategy", + "outputs": [{ "internalType": "int256", "name": "", "type": "int256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ousdMetaStrategy", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pauseCapital", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "pauseRebase", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "priceProvider", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_strategyFromAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_strategyToAddress", + "type": "address" + }, + { "internalType": "address[]", "name": "_assets", "type": "address[]" }, + { "internalType": "uint256[]", "name": "_amounts", "type": "uint256[]" } + ], + "name": "reallocate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "rebasePaused", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rebaseThreshold", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "redeemFeeBps", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_addr", "type": "address" } + ], + "name": "removeStrategy", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "newImpl", "type": "address" } + ], + "name": "setAdminImpl", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_asset", "type": "address" }, + { "internalType": "address", "name": "_strategy", "type": "address" } + ], + "name": "setAssetDefaultStrategy", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_threshold", "type": "uint256" } + ], + "name": "setAutoAllocateThreshold", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_maxSupplyDiff", "type": "uint256" } + ], + "name": "setMaxSupplyDiff", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_threshold", "type": "uint256" } + ], + "name": "setNetOusdMintForStrategyThreshold", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_ousdMetaStrategy", + "type": "address" + } + ], + "name": "setOusdMetaStrategy", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_priceProvider", "type": "address" } + ], + "name": "setPriceProvider", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_threshold", "type": "uint256" } + ], + "name": "setRebaseThreshold", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_redeemFeeBps", "type": "uint256" } + ], + "name": "setRedeemFeeBps", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_address", "type": "address" } + ], + "name": "setStrategistAddr", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_address", "type": "address" } + ], + "name": "setTrusteeAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_basis", "type": "uint256" } + ], + "name": "setTrusteeFeeBps", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_vaultBuffer", "type": "uint256" } + ], + "name": "setVaultBuffer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "strategistAddr", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_asset", "type": "address" }, + { "internalType": "uint8", "name": "_unitConversion", "type": "uint8" } + ], + "name": "supportAsset", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_newGovernor", "type": "address" } + ], + "name": "transferGovernance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_asset", "type": "address" }, + { "internalType": "uint256", "name": "_amount", "type": "uint256" } + ], + "name": "transferToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "trusteeAddress", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "trusteeFeeBps", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "unpauseCapital", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unpauseRebase", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "vaultBuffer", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawAllFromStrategies", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_strategyAddr", "type": "address" } + ], + "name": "withdrawAllFromStrategy", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_strategyFromAddress", + "type": "address" + }, + { "internalType": "address[]", "name": "_assets", "type": "address[]" }, + { "internalType": "uint256[]", "name": "_amounts", "type": "uint256[]" } + ], + "name": "withdrawFromStrategy", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/db/migrations/1695839072092-Data.js b/db/migrations/1695855931552-Data.js similarity index 97% rename from db/migrations/1695839072092-Data.js rename to db/migrations/1695855931552-Data.js index daa92e53..f27d4e4f 100644 --- a/db/migrations/1695839072092-Data.js +++ b/db/migrations/1695855931552-Data.js @@ -1,5 +1,5 @@ -module.exports = class Data1695839072092 { - name = 'Data1695839072092' +module.exports = class Data1695855931552 { + name = 'Data1695855931552' async up(db) { await db.query(`CREATE TABLE "oeth" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "total_supply" numeric NOT NULL, CONSTRAINT "PK_de1d885501070dbd1ab6f8577ba" PRIMARY KEY ("id"))`) @@ -14,7 +14,7 @@ module.exports = class Data1695839072092 { await db.query(`CREATE INDEX "IDX_1f069a908b679be0b5fbc0b2e6" ON "apy" ("timestamp") `) await db.query(`CREATE INDEX "IDX_7fb752652a983d6629a722ae7a" ON "apy" ("block_number") `) await db.query(`CREATE INDEX "IDX_d1165411d71160d1230073d0fa" ON "apy" ("tx_hash") `) - await db.query(`CREATE TABLE "rebase" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "tx_hash" text NOT NULL, "total_supply" numeric NOT NULL, "rebasing_credits" numeric NOT NULL, "rebasing_credits_per_token" numeric NOT NULL, "apy_id" character varying, CONSTRAINT "PK_cadd381a400a7e41b538c788d13" PRIMARY KEY ("id"))`) + await db.query(`CREATE TABLE "rebase" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "tx_hash" text NOT NULL, "total_supply" numeric NOT NULL, "rebasing_credits" numeric NOT NULL, "rebasing_credits_per_token" numeric NOT NULL, "fee" numeric NOT NULL, "yield" numeric NOT NULL, "apy_id" character varying, CONSTRAINT "PK_cadd381a400a7e41b538c788d13" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_c308a9ecd3d05b0c45e7c60d10" ON "rebase" ("timestamp") `) await db.query(`CREATE INDEX "IDX_a5955dbd9ac031314697cbd54f" ON "rebase" ("block_number") `) await db.query(`CREATE INDEX "IDX_7cd793b6c4bc15b9082e0eb97a" ON "rebase" ("tx_hash") `) diff --git a/schema.graphql b/schema.graphql index 37e7ff79..d8dcea65 100644 --- a/schema.graphql +++ b/schema.graphql @@ -48,6 +48,8 @@ type Rebase @entity { rebasingCredits: BigInt! rebasingCreditsPerToken: BigInt! apy: APY! + fee: BigInt! + yield: BigInt! } type RebaseOption @entity { diff --git a/src/abi/oeth-vault.abi.ts b/src/abi/oeth-vault.abi.ts new file mode 100644 index 00000000..66a4baac --- /dev/null +++ b/src/abi/oeth-vault.abi.ts @@ -0,0 +1,970 @@ +export const ABI_JSON = [ + { + "type": "event", + "anonymous": false, + "name": "AllocateThresholdUpdated", + "inputs": [ + { + "type": "uint256", + "name": "_threshold", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "AssetAllocated", + "inputs": [ + { + "type": "address", + "name": "_asset", + "indexed": false + }, + { + "type": "address", + "name": "_strategy", + "indexed": false + }, + { + "type": "uint256", + "name": "_amount", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "AssetDefaultStrategyUpdated", + "inputs": [ + { + "type": "address", + "name": "_asset", + "indexed": false + }, + { + "type": "address", + "name": "_strategy", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "AssetSupported", + "inputs": [ + { + "type": "address", + "name": "_asset", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "CapitalPaused", + "inputs": [] + }, + { + "type": "event", + "anonymous": false, + "name": "CapitalUnpaused", + "inputs": [] + }, + { + "type": "event", + "anonymous": false, + "name": "GovernorshipTransferred", + "inputs": [ + { + "type": "address", + "name": "previousGovernor", + "indexed": true + }, + { + "type": "address", + "name": "newGovernor", + "indexed": true + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "MaxSupplyDiffChanged", + "inputs": [ + { + "type": "uint256", + "name": "maxSupplyDiff", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "Mint", + "inputs": [ + { + "type": "address", + "name": "_addr", + "indexed": false + }, + { + "type": "uint256", + "name": "_value", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "NetOusdMintForStrategyThresholdChanged", + "inputs": [ + { + "type": "uint256", + "name": "_threshold", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "OusdMetaStrategyUpdated", + "inputs": [ + { + "type": "address", + "name": "_ousdMetaStrategy", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "PendingGovernorshipTransfer", + "inputs": [ + { + "type": "address", + "name": "previousGovernor", + "indexed": true + }, + { + "type": "address", + "name": "newGovernor", + "indexed": true + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "PriceProviderUpdated", + "inputs": [ + { + "type": "address", + "name": "_priceProvider", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "RebasePaused", + "inputs": [] + }, + { + "type": "event", + "anonymous": false, + "name": "RebaseThresholdUpdated", + "inputs": [ + { + "type": "uint256", + "name": "_threshold", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "RebaseUnpaused", + "inputs": [] + }, + { + "type": "event", + "anonymous": false, + "name": "Redeem", + "inputs": [ + { + "type": "address", + "name": "_addr", + "indexed": false + }, + { + "type": "uint256", + "name": "_value", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "RedeemFeeUpdated", + "inputs": [ + { + "type": "uint256", + "name": "_redeemFeeBps", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "StrategistUpdated", + "inputs": [ + { + "type": "address", + "name": "_address", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "StrategyApproved", + "inputs": [ + { + "type": "address", + "name": "_addr", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "StrategyRemoved", + "inputs": [ + { + "type": "address", + "name": "_addr", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "TrusteeAddressChanged", + "inputs": [ + { + "type": "address", + "name": "_address", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "TrusteeFeeBpsChanged", + "inputs": [ + { + "type": "uint256", + "name": "_basis", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "VaultBufferUpdated", + "inputs": [ + { + "type": "uint256", + "name": "_vaultBuffer", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "YieldDistribution", + "inputs": [ + { + "type": "address", + "name": "_to", + "indexed": false + }, + { + "type": "uint256", + "name": "_yield", + "indexed": false + }, + { + "type": "uint256", + "name": "_fee", + "indexed": false + } + ] + }, + { + "type": "function", + "name": "approveStrategy", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_addr" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "assetDefaultStrategies", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "" + } + ], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "autoAllocateThreshold", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "cacheDecimals", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_asset" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "capitalPaused", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "claimGovernance", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "depositToStrategy", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_strategyToAddress" + }, + { + "type": "address[]", + "name": "_assets" + }, + { + "type": "uint256[]", + "name": "_amounts" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "governor", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "initialize", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_priceProvider" + }, + { + "type": "address", + "name": "_ousd" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "isGovernor", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "maxSupplyDiff", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "netOusdMintForStrategyThreshold", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "netOusdMintedForStrategy", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "int256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "ousdMetaStrategy", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "pauseCapital", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "pauseRebase", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "priceProvider", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "reallocate", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_strategyFromAddress" + }, + { + "type": "address", + "name": "_strategyToAddress" + }, + { + "type": "address[]", + "name": "_assets" + }, + { + "type": "uint256[]", + "name": "_amounts" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "rebasePaused", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "rebaseThreshold", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "redeemFeeBps", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "removeStrategy", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_addr" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setAdminImpl", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "newImpl" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setAssetDefaultStrategy", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_asset" + }, + { + "type": "address", + "name": "_strategy" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setAutoAllocateThreshold", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "_threshold" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setMaxSupplyDiff", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "_maxSupplyDiff" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setNetOusdMintForStrategyThreshold", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "_threshold" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setOusdMetaStrategy", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_ousdMetaStrategy" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setPriceProvider", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_priceProvider" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setRebaseThreshold", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "_threshold" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setRedeemFeeBps", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "_redeemFeeBps" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setStrategistAddr", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_address" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setTrusteeAddress", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_address" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setTrusteeFeeBps", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "_basis" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setVaultBuffer", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "_vaultBuffer" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "strategistAddr", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "supportAsset", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_asset" + }, + { + "type": "uint8", + "name": "_unitConversion" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "transferGovernance", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_newGovernor" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "transferToken", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_asset" + }, + { + "type": "uint256", + "name": "_amount" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "trusteeAddress", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "trusteeFeeBps", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "unpauseCapital", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "unpauseRebase", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "vaultBuffer", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "withdrawAllFromStrategies", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "withdrawAllFromStrategy", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_strategyAddr" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "withdrawFromStrategy", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_strategyFromAddress" + }, + { + "type": "address[]", + "name": "_assets" + }, + { + "type": "uint256[]", + "name": "_amounts" + } + ], + "outputs": [] + } +] diff --git a/src/abi/oeth-vault.ts b/src/abi/oeth-vault.ts new file mode 100644 index 00000000..abeca014 --- /dev/null +++ b/src/abi/oeth-vault.ts @@ -0,0 +1,298 @@ +import * as ethers from 'ethers' +import {LogEvent, Func, ContractBase} from './abi.support' +import {ABI_JSON} from './oeth-vault.abi' + +export const abi = new ethers.Interface(ABI_JSON); + +export const events = { + AllocateThresholdUpdated: new LogEvent<([_threshold: bigint] & {_threshold: bigint})>( + abi, '0x2ec5fb5a3d2703edc461252d92ccd2799c3c74f01d97212b20388207fa17ae45' + ), + AssetAllocated: new LogEvent<([_asset: string, _strategy: string, _amount: bigint] & {_asset: string, _strategy: string, _amount: bigint})>( + abi, '0x41b99659f6ba0803f444aff29e5bf6e26dd86a3219aff92119d69710a956ba8d' + ), + AssetDefaultStrategyUpdated: new LogEvent<([_asset: string, _strategy: string] & {_asset: string, _strategy: string})>( + abi, '0xba58ce12801c949fa65f41c46ed108671c219baf945fa48d21026cea99ff252a' + ), + AssetSupported: new LogEvent<([_asset: string] & {_asset: string})>( + abi, '0x4f1ac48525e50059cc1cc6e0e1940ece0dd653a4db4841538d6aef036be2fb7b' + ), + CapitalPaused: new LogEvent<[]>( + abi, '0x71f0e5b62f846a22e0b4d159e516e62fa9c2b8eb570be15f83e67d98a2ee51e0' + ), + CapitalUnpaused: new LogEvent<[]>( + abi, '0x891ebab18da80ebeeea06b1b1cede098329c4c008906a98370c2ac7a80b571cb' + ), + GovernorshipTransferred: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( + abi, '0xc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a' + ), + MaxSupplyDiffChanged: new LogEvent<([maxSupplyDiff: bigint] & {maxSupplyDiff: bigint})>( + abi, '0x95201f9c21f26877223b1ff4073936a6484c35495649e60e55730497aeb60d93' + ), + Mint: new LogEvent<([_addr: string, _value: bigint] & {_addr: string, _value: bigint})>( + abi, '0x0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885' + ), + NetOusdMintForStrategyThresholdChanged: new LogEvent<([_threshold: bigint] & {_threshold: bigint})>( + abi, '0xc29d6fedbc6bdf267a08166c2b976fbd72aca5d6a769528616f8b9224c8f197f' + ), + OusdMetaStrategyUpdated: new LogEvent<([_ousdMetaStrategy: string] & {_ousdMetaStrategy: string})>( + abi, '0xa12850fb726e0b2b7b3c9a9342031e1268a8148d0eb06b4bea8613204ffcd2b8' + ), + PendingGovernorshipTransfer: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( + abi, '0xa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d' + ), + PriceProviderUpdated: new LogEvent<([_priceProvider: string] & {_priceProvider: string})>( + abi, '0xb266add5f3044b17d27db796af992cecbe413921b4e8aaaee03c719e16b9806a' + ), + RebasePaused: new LogEvent<[]>( + abi, '0x8cff26a5985614b3d30629cc4ab83824bf115aec971b718d8f2f99562032e972' + ), + RebaseThresholdUpdated: new LogEvent<([_threshold: bigint] & {_threshold: bigint})>( + abi, '0x39367850377ac04920a9a670f2180e7a94d83b15ad302e59875ec58fd10bd37d' + ), + RebaseUnpaused: new LogEvent<[]>( + abi, '0xbc044409505c95b6b851433df96e1beae715c909d8e7c1d6d7ab783300d4e3b9' + ), + Redeem: new LogEvent<([_addr: string, _value: bigint] & {_addr: string, _value: bigint})>( + abi, '0x222838db2794d11532d940e8dec38ae307ed0b63cd97c233322e221f998767a6' + ), + RedeemFeeUpdated: new LogEvent<([_redeemFeeBps: bigint] & {_redeemFeeBps: bigint})>( + abi, '0xd6c7508d6658ccee36b7b7d7fd72e5cbaeefb40c64eff24e9ae7470e846304ee' + ), + StrategistUpdated: new LogEvent<([_address: string] & {_address: string})>( + abi, '0x869e0abd13cc3a975de7b93be3df1cb2255c802b1cead85963cc79d99f131bee' + ), + StrategyApproved: new LogEvent<([_addr: string] & {_addr: string})>( + abi, '0x960dd94cbb79169f09a4e445d58b895df2d9bffa5b31055d0932d801724a20d1' + ), + StrategyRemoved: new LogEvent<([_addr: string] & {_addr: string})>( + abi, '0x09a1db4b80c32706328728508c941a6b954f31eb5affd32f236c1fd405f8fea4' + ), + TrusteeAddressChanged: new LogEvent<([_address: string] & {_address: string})>( + abi, '0x1e4af5ac389e8cde1bdaa6830881b6c987c62a45cfb3b33d27d805cde3b57750' + ), + TrusteeFeeBpsChanged: new LogEvent<([_basis: bigint] & {_basis: bigint})>( + abi, '0x56287a45051933ea374811b3d5d165033047be5572cac676f7c28b8be4f746c7' + ), + VaultBufferUpdated: new LogEvent<([_vaultBuffer: bigint] & {_vaultBuffer: bigint})>( + abi, '0x41ecb23a0e7865b25f38c268b7c3012220d822929e9edff07326e89d5bb822b5' + ), + YieldDistribution: new LogEvent<([_to: string, _yield: bigint, _fee: bigint] & {_to: string, _yield: bigint, _fee: bigint})>( + abi, '0x09516ecf4a8a86e59780a9befc6dee948bc9e60a36e3be68d31ea817ee8d2c80' + ), +} + +export const functions = { + approveStrategy: new Func<[_addr: string], {_addr: string}, []>( + abi, '0x3b8ae397' + ), + assetDefaultStrategies: new Func<[_: string], {}, string>( + abi, '0xa403e4d5' + ), + autoAllocateThreshold: new Func<[], {}, bigint>( + abi, '0x9fa1826e' + ), + cacheDecimals: new Func<[_asset: string], {_asset: string}, []>( + abi, '0x36b6d944' + ), + capitalPaused: new Func<[], {}, boolean>( + abi, '0xe6cc5432' + ), + claimGovernance: new Func<[], {}, []>( + abi, '0x5d36b190' + ), + depositToStrategy: new Func<[_strategyToAddress: string, _assets: Array, _amounts: Array], {_strategyToAddress: string, _assets: Array, _amounts: Array}, []>( + abi, '0x840c4c7a' + ), + governor: new Func<[], {}, string>( + abi, '0x0c340a24' + ), + initialize: new Func<[_priceProvider: string, _ousd: string], {_priceProvider: string, _ousd: string}, []>( + abi, '0x485cc955' + ), + isGovernor: new Func<[], {}, boolean>( + abi, '0xc7af3352' + ), + maxSupplyDiff: new Func<[], {}, bigint>( + abi, '0x8e510b52' + ), + netOusdMintForStrategyThreshold: new Func<[], {}, bigint>( + abi, '0x7a2202f3' + ), + netOusdMintedForStrategy: new Func<[], {}, bigint>( + abi, '0xe45cc9f0' + ), + ousdMetaStrategy: new Func<[], {}, string>( + abi, '0x18ce56bd' + ), + pauseCapital: new Func<[], {}, []>( + abi, '0x3dbc911f' + ), + pauseRebase: new Func<[], {}, []>( + abi, '0xc5f00841' + ), + priceProvider: new Func<[], {}, string>( + abi, '0xb888879e' + ), + reallocate: new Func<[_strategyFromAddress: string, _strategyToAddress: string, _assets: Array, _amounts: Array], {_strategyFromAddress: string, _strategyToAddress: string, _assets: Array, _amounts: Array}, []>( + abi, '0x7fe2d393' + ), + rebasePaused: new Func<[], {}, boolean>( + abi, '0x53ca9f24' + ), + rebaseThreshold: new Func<[], {}, bigint>( + abi, '0x52d38e5d' + ), + redeemFeeBps: new Func<[], {}, bigint>( + abi, '0x09f6442c' + ), + removeStrategy: new Func<[_addr: string], {_addr: string}, []>( + abi, '0x175188e8' + ), + setAdminImpl: new Func<[newImpl: string], {newImpl: string}, []>( + abi, '0xfc0cfeee' + ), + setAssetDefaultStrategy: new Func<[_asset: string, _strategy: string], {_asset: string, _strategy: string}, []>( + abi, '0xbc90106b' + ), + setAutoAllocateThreshold: new Func<[_threshold: bigint], {_threshold: bigint}, []>( + abi, '0xb2c9336d' + ), + setMaxSupplyDiff: new Func<[_maxSupplyDiff: bigint], {_maxSupplyDiff: bigint}, []>( + abi, '0x663e64ce' + ), + setNetOusdMintForStrategyThreshold: new Func<[_threshold: bigint], {_threshold: bigint}, []>( + abi, '0x636e6c40' + ), + setOusdMetaStrategy: new Func<[_ousdMetaStrategy: string], {_ousdMetaStrategy: string}, []>( + abi, '0xd58e3b3a' + ), + setPriceProvider: new Func<[_priceProvider: string], {_priceProvider: string}, []>( + abi, '0x372aa224' + ), + setRebaseThreshold: new Func<[_threshold: bigint], {_threshold: bigint}, []>( + abi, '0xb890ebf6' + ), + setRedeemFeeBps: new Func<[_redeemFeeBps: bigint], {_redeemFeeBps: bigint}, []>( + abi, '0xeb03654b' + ), + setStrategistAddr: new Func<[_address: string], {_address: string}, []>( + abi, '0x773540b3' + ), + setTrusteeAddress: new Func<[_address: string], {_address: string}, []>( + abi, '0x2da845a8' + ), + setTrusteeFeeBps: new Func<[_basis: bigint], {_basis: bigint}, []>( + abi, '0x0acbda75' + ), + setVaultBuffer: new Func<[_vaultBuffer: bigint], {_vaultBuffer: bigint}, []>( + abi, '0x8ec489a2' + ), + strategistAddr: new Func<[], {}, string>( + abi, '0x570d8e1d' + ), + supportAsset: new Func<[_asset: string, _unitConversion: number], {_asset: string, _unitConversion: number}, []>( + abi, '0x6c7561e8' + ), + transferGovernance: new Func<[_newGovernor: string], {_newGovernor: string}, []>( + abi, '0xd38bfff4' + ), + transferToken: new Func<[_asset: string, _amount: bigint], {_asset: string, _amount: bigint}, []>( + abi, '0x1072cbea' + ), + trusteeAddress: new Func<[], {}, string>( + abi, '0x49c1d54d' + ), + trusteeFeeBps: new Func<[], {}, bigint>( + abi, '0x207134b0' + ), + unpauseCapital: new Func<[], {}, []>( + abi, '0x94828ffd' + ), + unpauseRebase: new Func<[], {}, []>( + abi, '0x09f49bf5' + ), + vaultBuffer: new Func<[], {}, bigint>( + abi, '0x1edfe3da' + ), + withdrawAllFromStrategies: new Func<[], {}, []>( + abi, '0xc9919112' + ), + withdrawAllFromStrategy: new Func<[_strategyAddr: string], {_strategyAddr: string}, []>( + abi, '0x597c8910' + ), + withdrawFromStrategy: new Func<[_strategyFromAddress: string, _assets: Array, _amounts: Array], {_strategyFromAddress: string, _assets: Array, _amounts: Array}, []>( + abi, '0xae69f3cb' + ), +} + +export class Contract extends ContractBase { + + assetDefaultStrategies(arg0: string): Promise { + return this.eth_call(functions.assetDefaultStrategies, [arg0]) + } + + autoAllocateThreshold(): Promise { + return this.eth_call(functions.autoAllocateThreshold, []) + } + + capitalPaused(): Promise { + return this.eth_call(functions.capitalPaused, []) + } + + governor(): Promise { + return this.eth_call(functions.governor, []) + } + + isGovernor(): Promise { + return this.eth_call(functions.isGovernor, []) + } + + maxSupplyDiff(): Promise { + return this.eth_call(functions.maxSupplyDiff, []) + } + + netOusdMintForStrategyThreshold(): Promise { + return this.eth_call(functions.netOusdMintForStrategyThreshold, []) + } + + netOusdMintedForStrategy(): Promise { + return this.eth_call(functions.netOusdMintedForStrategy, []) + } + + ousdMetaStrategy(): Promise { + return this.eth_call(functions.ousdMetaStrategy, []) + } + + priceProvider(): Promise { + return this.eth_call(functions.priceProvider, []) + } + + rebasePaused(): Promise { + return this.eth_call(functions.rebasePaused, []) + } + + rebaseThreshold(): Promise { + return this.eth_call(functions.rebaseThreshold, []) + } + + redeemFeeBps(): Promise { + return this.eth_call(functions.redeemFeeBps, []) + } + + strategistAddr(): Promise { + return this.eth_call(functions.strategistAddr, []) + } + + trusteeAddress(): Promise { + return this.eth_call(functions.trusteeAddress, []) + } + + trusteeFeeBps(): Promise { + return this.eth_call(functions.trusteeFeeBps, []) + } + + vaultBuffer(): Promise { + return this.eth_call(functions.vaultBuffer, []) + } +} diff --git a/src/model/generated/rebase.model.ts b/src/model/generated/rebase.model.ts index d39be3f5..60f41b15 100644 --- a/src/model/generated/rebase.model.ts +++ b/src/model/generated/rebase.model.ts @@ -35,4 +35,10 @@ export class Rebase { @Index_() @ManyToOne_(() => APY, {nullable: true}) apy!: APY + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + fee!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + yield!: bigint } diff --git a/src/processors/oeth/oeth.ts b/src/processors/oeth/oeth.ts index eed1b429..a7bc663d 100644 --- a/src/processors/oeth/oeth.ts +++ b/src/processors/oeth/oeth.ts @@ -2,6 +2,7 @@ import { EvmBatchProcessor } from '@subsquid/evm-processor' import { v4 as uuidv4 } from 'uuid' import * as oeth from '../../abi/oeth' +import * as oethVault from '../../abi/oeth-vault' import { APY, Address, @@ -13,7 +14,11 @@ import { RebasingOption, } from '../../model' import { Context } from '../../processor' -import { ADDRESS_ZERO, OETH_ADDRESS } from '../../utils/addresses' +import { + ADDRESS_ZERO, + OETH_ADDRESS, + OETH_VAULT_ADDRESS, +} from '../../utils/addresses' import { DECIMALS_18 } from '../../utils/constants' import { getLatestEntity } from '../utils' import { createAddress, createRebaseAPY } from './utils' @@ -37,6 +42,10 @@ export const setup = (processor: EvmBatchProcessor) => { ], transaction: true, }) + processor.addLog({ + address: [OETH_VAULT_ADDRESS], + topic0: [oethVault.events.YieldDistribution.topic], + }) } interface ProcessResult { @@ -48,6 +57,10 @@ interface ProcessResult { rebaseOptions: RebaseOption[] apies: APY[] owners: Map + lastYieldDistributionEvent?: { + fee: bigint + yield: bigint + } } export const process = async (ctx: Context) => { @@ -77,6 +90,7 @@ export const process = async (ctx: Context) => { } for (const log of block.logs) { await processTransfer(ctx, result, block, log) + await processYieldDistribution(ctx, result, block, log) await processTotalSupplyUpdatedHighres(ctx, result, block, log) } } @@ -157,61 +171,86 @@ const processTotalSupplyUpdatedHighres = async ( log: Context['blocks']['0']['logs']['0'], ) => { if (log.address !== OETH_ADDRESS) return - if (log.topics[0] === oeth.events.TotalSupplyUpdatedHighres.topic) { - await result.initialize() - const data = oeth.events.TotalSupplyUpdatedHighres.decode(log) + if (log.topics[0] !== oeth.events.TotalSupplyUpdatedHighres.topic) return - // OETH Object - const timestampId = new Date(block.header.timestamp).toISOString() - const { latest, current } = await getLatestEntity( - ctx, - OETH, - result.oeths, - timestampId, - ) + await result.initialize() + const data = oeth.events.TotalSupplyUpdatedHighres.decode(log) - let oethObject = current - if (!oethObject) { - oethObject = new OETH({ - id: timestampId, - timestamp: new Date(block.header.timestamp), - blockNumber: block.header.height, - totalSupply: latest?.totalSupply ?? 0n, - }) - result.oeths.push(oethObject) - } - oethObject.totalSupply = data.totalSupply + // OETH Object + const timestampId = new Date(block.header.timestamp).toISOString() + const { latest, current } = await getLatestEntity( + ctx, + OETH, + result.oeths, + timestampId, + ) - // Rebase events - let rebase = createRebaseAPY(ctx, result.apies, block, log, data) - for (const address of result.owners.values()) { - if (address.rebasingOption === RebasingOption.OptOut) { - continue - } - const newBalance = - (address.credits * DECIMALS_18) / data.rebasingCreditsPerToken - const earned = newBalance - address.balance + let oethObject = current + if (!oethObject) { + oethObject = new OETH({ + id: timestampId, + timestamp: new Date(block.header.timestamp), + blockNumber: block.header.height, + totalSupply: latest?.totalSupply ?? 0n, + }) + result.oeths.push(oethObject) + } + oethObject.totalSupply = data.totalSupply - result.history.push( - new History({ - id: uuidv4(), - // we can't use {t.id} because it's not unique - address: address, - value: earned, - balance: newBalance, - timestamp: new Date(block.header.timestamp), - blockNumber: block.header.height, - txHash: log.transactionHash, - type: HistoryType.Yield, - }), - ) + if (!result.lastYieldDistributionEvent) { + throw new Error('lastYieldDistributionEvent is not set') + } - address.balance = newBalance - address.earned += earned + // Rebase events + let rebase = createRebaseAPY( + ctx, + result.apies, + block, + log, + data, + result.lastYieldDistributionEvent, + ) + for (const address of result.owners.values()) { + if (address.rebasingOption === RebasingOption.OptOut) { + continue } - const entity = await rebase - result.rebases.push(entity) + const newBalance = + (address.credits * DECIMALS_18) / data.rebasingCreditsPerToken + const earned = newBalance - address.balance + + result.history.push( + new History({ + id: uuidv4(), + // we can't use {t.id} because it's not unique + address: address, + value: earned, + balance: newBalance, + timestamp: new Date(block.header.timestamp), + blockNumber: block.header.height, + txHash: log.transactionHash, + type: HistoryType.Yield, + }), + ) + + address.balance = newBalance + address.earned += earned } + const entity = await rebase + result.rebases.push(entity) +} + +const processYieldDistribution = async ( + ctx: Context, + result: ProcessResult, + block: Context['blocks']['0'], + log: Context['blocks']['0']['logs']['0'], +) => { + if (log.address !== OETH_VAULT_ADDRESS) return + if (log.topics[0] !== oethVault.events.YieldDistribution.topic) return + + await result.initialize() + const { _yield, _fee } = oethVault.events.YieldDistribution.decode(log) + result.lastYieldDistributionEvent = { yield: _yield, fee: _fee } } const processRebaseOpt = async ( diff --git a/src/processors/oeth/utils.ts b/src/processors/oeth/utils.ts index d431c46a..b526796c 100644 --- a/src/processors/oeth/utils.ts +++ b/src/processors/oeth/utils.ts @@ -40,6 +40,10 @@ export async function createRebaseAPY( block: Context['blocks']['0'], log: Context['blocks']['0']['logs']['0'], rebaseEvent: ReturnType, + lastYieldDistributionEvent: { + fee: bigint + yield: bigint + }, ): Promise { const rebase = new Rebase({ id: log.id, @@ -49,6 +53,8 @@ export async function createRebaseAPY( rebasingCredits: rebaseEvent.rebasingCredits, rebasingCreditsPerToken: rebaseEvent.rebasingCreditsPerToken, totalSupply: rebaseEvent.totalSupply, + fee: lastYieldDistributionEvent.fee, + yield: lastYieldDistributionEvent.yield, }) // use date as id for APY