From 38d832a0801018d54b7a42e41a80f54722bf9189 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Thu, 16 May 2024 14:37:41 -0700 Subject: [PATCH 01/13] add x-ogn abi, regen types, fix issues made from typegen after `sqd bump` --- abi/x-ogn.json | 1030 +++++++++++++++++ src/abi/aave-lending-pool.ts | 337 +++--- src/abi/aave-token.ts | 347 +++--- src/abi/balancer-composable-stable-pool.ts | 601 +++++----- src/abi/balancer-meta-pool-strategy.ts | 424 +++---- src/abi/balancer-meta-stable-pool.ts | 505 ++++---- src/abi/balancer-rate-provider.ts | 32 +- src/abi/balancer-vault.ts | 302 ++--- src/abi/balancer-weighted-pool-2-token.ts | 421 ++++--- src/abi/base-reward-pool-4626.ts | 621 +++++----- src/abi/base-reward-pool.ts | 376 +++--- src/abi/ccip-evm2evmofframp.ts | 313 ++--- src/abi/ccip-evm2evmonramp.ts | 327 +++--- src/abi/ccip-router.ts | 212 ++-- src/abi/chainlink-feed-registry.ts | 347 +++--- src/abi/curve-lp-token.ts | 577 ++++----- src/abi/curve-registry-exchange.ts | 249 ++-- src/abi/dripper.ts | 119 +- src/abi/eac-aggregator-proxy.ts | 265 +++-- src/abi/erc20.ts | 109 +- src/abi/frx-eth-frax-oracle.ts | 262 +++-- src/abi/governance.ts | 528 +++++---- src/abi/initializable-abstract-strategy.ts | 265 +++-- src/abi/lido.ts | 794 +++++++------ src/abi/maverick-pool.ts | 279 ++--- src/abi/multicall.ts | 346 +++--- src/abi/oeth-oracle-router.ts | 28 +- src/abi/oeth-zapper.ts | 86 +- src/abi/oeth.ts | 348 +++--- src/abi/origin-lens.ts | 239 ++-- src/abi/otoken-vault.ts | 535 ++++----- src/abi/otoken.ts | 365 +++--- src/abi/sfrx-eth.ts | 382 +++--- src/abi/veogv.ts | 391 ++++--- src/abi/woeth.ts | 353 +++--- src/abi/x-ogn.ts | 284 +++++ src/abi/zero-x-exchange.ts | 81 +- src/oeth/processors/ccip.ts | 2 +- .../strategies/convex-meta-strategy.ts | 2 +- src/processor.ts | 2 +- src/templates/balancer/balancer.ts | 2 +- src/templates/erc20/erc20.ts | 2 +- src/templates/otoken/otoken.ts | 26 +- src/templates/strategy/strategy-balancer.ts | 3 +- src/utils/multicall.ts | 14 +- 45 files changed, 7620 insertions(+), 5513 deletions(-) create mode 100644 abi/x-ogn.json create mode 100644 src/abi/x-ogn.ts diff --git a/abi/x-ogn.json b/abi/x-ogn.json new file mode 100644 index 00000000..1d2af208 --- /dev/null +++ b/abi/x-ogn.json @@ -0,0 +1,1030 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "asset_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "epoch_", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minStakeDuration_", + "type": "uint256" + }, + { + "internalType": "address", + "name": "rewardsSource_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "x", + "type": "uint256" + } + ], + "name": "PRBMathUD60x18__Exp2InputTooBig", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "x", + "type": "uint256" + } + ], + "name": "PRBMathUD60x18__LogInputTooSmall", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "prod1", + "type": "uint256" + } + ], + "name": "PRBMath__MulDivFixedPointOverflow", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "fromDelegate", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "toDelegate", + "type": "address" + } + ], + "name": "DelegateChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegate", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "previousBalance", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newBalance", + "type": "uint256" + } + ], + "name": "DelegateVotesChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Penalty", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Reward", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lockupId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "end", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "points", + "type": "uint256" + } + ], + "name": "Stake", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lockupId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "end", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "points", + "type": "uint256" + } + ], + "name": "Unstake", + "type": "event" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "accRewardPerShare", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "asset", + "outputs": [ + { + "internalType": "contract ERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint32", + "name": "pos", + "type": "uint32" + } + ], + "name": "checkpoints", + "outputs": [ + { + "components": [ + { + "internalType": "uint32", + "name": "fromBlock", + "type": "uint32" + }, + { + "internalType": "uint224", + "name": "votes", + "type": "uint224" + } + ], + "internalType": "struct ERC20Votes.Checkpoint", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "collectRewards", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "delegatee", + "type": "address" + } + ], + "name": "delegate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "delegatee", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expiry", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "delegateBySig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "delegates", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "epoch", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + } + ], + "name": "getPastTotalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + } + ], + "name": "getPastVotes", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getVotes", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "lockups", + "outputs": [ + { + "internalType": "uint128", + "name": "amount", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "end", + "type": "uint128" + }, + { + "internalType": "uint256", + "name": "points", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "lockupsCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxStakeDuration", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "minStakeDuration", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "nonces", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "numCheckpoints", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "duration", + "type": "uint256" + } + ], + "name": "previewPoints", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "previewRewards", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "end", + "type": "uint256" + } + ], + "name": "previewWithdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "rewardDebtPerShare", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rewardsSource", + "outputs": [ + { + "internalType": "contract RewardsSource", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "duration", + "type": "uint256" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "bool", + "name": "stakeRewards", + "type": "bool" + }, + { + "internalType": "int256", + "name": "lockupId", + "type": "int256" + } + ], + "name": "stake", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "lockupId", + "type": "uint256" + } + ], + "name": "unstake", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/src/abi/aave-lending-pool.ts b/src/abi/aave-lending-pool.ts index 061cd3ff..b99befd0 100644 --- a/src/abi/aave-lending-pool.ts +++ b/src/abi/aave-lending-pool.ts @@ -1,195 +1,212 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './aave-lending-pool.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - Borrow: new LogEvent<([reserve: string, user: string, onBehalfOf: string, amount: bigint, borrowRateMode: bigint, borrowRate: bigint, referral: number] & {reserve: string, user: string, onBehalfOf: string, amount: bigint, borrowRateMode: bigint, borrowRate: bigint, referral: number})>( - abi, '0xc6a898309e823ee50bac64e45ca8adba6690e99e7841c45d754e2a38e9019d9b' - ), - Deposit: new LogEvent<([reserve: string, user: string, onBehalfOf: string, amount: bigint, referral: number] & {reserve: string, user: string, onBehalfOf: string, amount: bigint, referral: number})>( - abi, '0xde6857219544bb5b7746f48ed30be6386fefc61b2f864cacf559893bf50fd951' - ), - FlashLoan: new LogEvent<([target: string, initiator: string, asset: string, amount: bigint, premium: bigint, referralCode: number] & {target: string, initiator: string, asset: string, amount: bigint, premium: bigint, referralCode: number})>( - abi, '0x631042c832b07452973831137f2d73e395028b44b250dedc5abb0ee766e168ac' - ), - LiquidationCall: new LogEvent<([collateralAsset: string, debtAsset: string, user: string, debtToCover: bigint, liquidatedCollateralAmount: bigint, liquidator: string, receiveAToken: boolean] & {collateralAsset: string, debtAsset: string, user: string, debtToCover: bigint, liquidatedCollateralAmount: bigint, liquidator: string, receiveAToken: boolean})>( - abi, '0xe413a321e8681d831f4dbccbca790d2952b56f977908e45be37335533e005286' - ), - Paused: new LogEvent<[]>( - abi, '0x9e87fac88ff661f02d44f95383c817fece4bce600a3dab7a54406878b965e752' - ), - RebalanceStableBorrowRate: new LogEvent<([reserve: string, user: string] & {reserve: string, user: string})>( - abi, '0x9f439ae0c81e41a04d3fdfe07aed54e6a179fb0db15be7702eb66fa8ef6f5300' - ), - Repay: new LogEvent<([reserve: string, user: string, repayer: string, amount: bigint] & {reserve: string, user: string, repayer: string, amount: bigint})>( - abi, '0x4cdde6e09bb755c9a5589ebaec640bbfedff1362d4b255ebf8339782b9942faa' - ), - ReserveDataUpdated: new LogEvent<([reserve: string, liquidityRate: bigint, stableBorrowRate: bigint, variableBorrowRate: bigint, liquidityIndex: bigint, variableBorrowIndex: bigint] & {reserve: string, liquidityRate: bigint, stableBorrowRate: bigint, variableBorrowRate: bigint, liquidityIndex: bigint, variableBorrowIndex: bigint})>( - abi, '0x804c9b842b2748a22bb64b345453a3de7ca54a6ca45ce00d415894979e22897a' - ), - ReserveUsedAsCollateralDisabled: new LogEvent<([reserve: string, user: string] & {reserve: string, user: string})>( - abi, '0x44c58d81365b66dd4b1a7f36c25aa97b8c71c361ee4937adc1a00000227db5dd' - ), - ReserveUsedAsCollateralEnabled: new LogEvent<([reserve: string, user: string] & {reserve: string, user: string})>( - abi, '0x00058a56ea94653cdf4f152d227ace22d4c00ad99e2a43f58cb7d9e3feb295f2' - ), - Swap: new LogEvent<([reserve: string, user: string, rateMode: bigint] & {reserve: string, user: string, rateMode: bigint})>( - abi, '0xea368a40e9570069bb8e6511d668293ad2e1f03b0d982431fd223de9f3b70ca6' - ), - TokensRescued: new LogEvent<([tokenRescued: string, receiver: string, amountRescued: bigint] & {tokenRescued: string, receiver: string, amountRescued: bigint})>( - abi, '0x77023e19c7343ad491fd706c36335ca0e738340a91f29b1fd81e2673d44896c4' - ), - Unpaused: new LogEvent<[]>( - abi, '0xa45f47fdea8a1efdd9029a5691c7f759c32b7c698632b563573e155625d16933' - ), - Withdraw: new LogEvent<([reserve: string, user: string, to: string, amount: bigint] & {reserve: string, user: string, to: string, amount: bigint})>( - abi, '0x3115d1449a7b732c986cba18244e897a450f61e1bb8d589cd2e69e6c8924f9f7' - ), + Borrow: event("0xc6a898309e823ee50bac64e45ca8adba6690e99e7841c45d754e2a38e9019d9b", {"reserve": indexed(p.address), "user": p.address, "onBehalfOf": indexed(p.address), "amount": p.uint256, "borrowRateMode": p.uint256, "borrowRate": p.uint256, "referral": indexed(p.uint16)}), + Deposit: event("0xde6857219544bb5b7746f48ed30be6386fefc61b2f864cacf559893bf50fd951", {"reserve": indexed(p.address), "user": p.address, "onBehalfOf": indexed(p.address), "amount": p.uint256, "referral": indexed(p.uint16)}), + FlashLoan: event("0x631042c832b07452973831137f2d73e395028b44b250dedc5abb0ee766e168ac", {"target": indexed(p.address), "initiator": indexed(p.address), "asset": indexed(p.address), "amount": p.uint256, "premium": p.uint256, "referralCode": p.uint16}), + LiquidationCall: event("0xe413a321e8681d831f4dbccbca790d2952b56f977908e45be37335533e005286", {"collateralAsset": indexed(p.address), "debtAsset": indexed(p.address), "user": indexed(p.address), "debtToCover": p.uint256, "liquidatedCollateralAmount": p.uint256, "liquidator": p.address, "receiveAToken": p.bool}), + Paused: event("0x9e87fac88ff661f02d44f95383c817fece4bce600a3dab7a54406878b965e752", {}), + RebalanceStableBorrowRate: event("0x9f439ae0c81e41a04d3fdfe07aed54e6a179fb0db15be7702eb66fa8ef6f5300", {"reserve": indexed(p.address), "user": indexed(p.address)}), + Repay: event("0x4cdde6e09bb755c9a5589ebaec640bbfedff1362d4b255ebf8339782b9942faa", {"reserve": indexed(p.address), "user": indexed(p.address), "repayer": indexed(p.address), "amount": p.uint256}), + ReserveDataUpdated: event("0x804c9b842b2748a22bb64b345453a3de7ca54a6ca45ce00d415894979e22897a", {"reserve": indexed(p.address), "liquidityRate": p.uint256, "stableBorrowRate": p.uint256, "variableBorrowRate": p.uint256, "liquidityIndex": p.uint256, "variableBorrowIndex": p.uint256}), + ReserveUsedAsCollateralDisabled: event("0x44c58d81365b66dd4b1a7f36c25aa97b8c71c361ee4937adc1a00000227db5dd", {"reserve": indexed(p.address), "user": indexed(p.address)}), + ReserveUsedAsCollateralEnabled: event("0x00058a56ea94653cdf4f152d227ace22d4c00ad99e2a43f58cb7d9e3feb295f2", {"reserve": indexed(p.address), "user": indexed(p.address)}), + Swap: event("0xea368a40e9570069bb8e6511d668293ad2e1f03b0d982431fd223de9f3b70ca6", {"reserve": indexed(p.address), "user": indexed(p.address), "rateMode": p.uint256}), + TokensRescued: event("0x77023e19c7343ad491fd706c36335ca0e738340a91f29b1fd81e2673d44896c4", {"tokenRescued": indexed(p.address), "receiver": indexed(p.address), "amountRescued": p.uint256}), + Unpaused: event("0xa45f47fdea8a1efdd9029a5691c7f759c32b7c698632b563573e155625d16933", {}), + Withdraw: event("0x3115d1449a7b732c986cba18244e897a450f61e1bb8d589cd2e69e6c8924f9f7", {"reserve": indexed(p.address), "user": indexed(p.address), "to": indexed(p.address), "amount": p.uint256}), } export const functions = { - FLASHLOAN_PREMIUM_TOTAL: new Func<[], {}, bigint>( - abi, '0x074b2e43' - ), - LENDINGPOOL_REVISION: new Func<[], {}, bigint>( - abi, '0x8afaff02' - ), - MAX_NUMBER_RESERVES: new Func<[], {}, bigint>( - abi, '0xf8119d51' - ), - MAX_STABLE_RATE_BORROW_SIZE_PERCENT: new Func<[], {}, bigint>( - abi, '0xe82fec2f' - ), - borrow: new Func<[asset: string, amount: bigint, interestRateMode: bigint, referralCode: number, onBehalfOf: string], {asset: string, amount: bigint, interestRateMode: bigint, referralCode: number, onBehalfOf: string}, []>( - abi, '0xa415bcad' - ), - deposit: new Func<[asset: string, amount: bigint, onBehalfOf: string, referralCode: number], {asset: string, amount: bigint, onBehalfOf: string, referralCode: number}, []>( - abi, '0xe8eda9df' - ), - finalizeTransfer: new Func<[asset: string, from: string, to: string, amount: bigint, balanceFromBefore: bigint, balanceToBefore: bigint], {asset: string, from: string, to: string, amount: bigint, balanceFromBefore: bigint, balanceToBefore: bigint}, []>( - abi, '0xd5ed3933' - ), - flashLoan: new Func<[receiverAddress: string, assets: Array, amounts: Array, modes: Array, onBehalfOf: string, params: string, referralCode: number], {receiverAddress: string, assets: Array, amounts: Array, modes: Array, onBehalfOf: string, params: string, referralCode: number}, []>( - abi, '0xab9c4b5d' - ), - getAddressesProvider: new Func<[], {}, string>( - abi, '0xfe65acfe' - ), - getConfiguration: new Func<[asset: string], {asset: string}, ([data: bigint] & {data: bigint})>( - abi, '0xc44b11f7' - ), - getReserveData: new Func<[asset: string], {asset: string}, ([configuration: ([data: bigint] & {data: bigint}), liquidityIndex: bigint, variableBorrowIndex: bigint, currentLiquidityRate: bigint, currentVariableBorrowRate: bigint, currentStableBorrowRate: bigint, lastUpdateTimestamp: number, aTokenAddress: string, stableDebtTokenAddress: string, variableDebtTokenAddress: string, interestRateStrategyAddress: string, id: number] & {configuration: ([data: bigint] & {data: bigint}), liquidityIndex: bigint, variableBorrowIndex: bigint, currentLiquidityRate: bigint, currentVariableBorrowRate: bigint, currentStableBorrowRate: bigint, lastUpdateTimestamp: number, aTokenAddress: string, stableDebtTokenAddress: string, variableDebtTokenAddress: string, interestRateStrategyAddress: string, id: number})>( - abi, '0x35ea6a75' - ), - getReserveNormalizedIncome: new Func<[asset: string], {asset: string}, bigint>( - abi, '0xd15e0053' - ), - getReserveNormalizedVariableDebt: new Func<[asset: string], {asset: string}, bigint>( - abi, '0x386497fd' - ), - getReservesList: new Func<[], {}, Array>( - abi, '0xd1946dbc' - ), - getUserAccountData: new Func<[user: string], {user: string}, ([totalCollateralETH: bigint, totalDebtETH: bigint, availableBorrowsETH: bigint, currentLiquidationThreshold: bigint, ltv: bigint, healthFactor: bigint] & {totalCollateralETH: bigint, totalDebtETH: bigint, availableBorrowsETH: bigint, currentLiquidationThreshold: bigint, ltv: bigint, healthFactor: bigint})>( - abi, '0xbf92857c' - ), - getUserConfiguration: new Func<[user: string], {user: string}, ([data: bigint] & {data: bigint})>( - abi, '0x4417a583' - ), - initReserve: new Func<[asset: string, aTokenAddress: string, stableDebtAddress: string, variableDebtAddress: string, interestRateStrategyAddress: string], {asset: string, aTokenAddress: string, stableDebtAddress: string, variableDebtAddress: string, interestRateStrategyAddress: string}, []>( - abi, '0x7a708e92' - ), - initialize: new Func<[provider: string], {provider: string}, []>( - abi, '0xc4d66de8' - ), - liquidationCall: new Func<[collateralAsset: string, debtAsset: string, user: string, debtToCover: bigint, receiveAToken: boolean], {collateralAsset: string, debtAsset: string, user: string, debtToCover: bigint, receiveAToken: boolean}, []>( - abi, '0x00a718a9' - ), - paused: new Func<[], {}, boolean>( - abi, '0x5c975abb' - ), - rebalanceStableBorrowRate: new Func<[asset: string, user: string], {asset: string, user: string}, []>( - abi, '0xcd112382' - ), - repay: new Func<[asset: string, amount: bigint, rateMode: bigint, onBehalfOf: string], {asset: string, amount: bigint, rateMode: bigint, onBehalfOf: string}, bigint>( - abi, '0x573ade81' - ), - rescueTokens: new Func<[token: string, to: string, amount: bigint], {token: string, to: string, amount: bigint}, []>( - abi, '0xcea9d26f' - ), - setConfiguration: new Func<[asset: string, configuration: bigint], {asset: string, configuration: bigint}, []>( - abi, '0xb8d29276' - ), - setPause: new Func<[val: boolean], {val: boolean}, []>( - abi, '0xbedb86fb' - ), - setReserveInterestRateStrategyAddress: new Func<[asset: string, rateStrategyAddress: string], {asset: string, rateStrategyAddress: string}, []>( - abi, '0x1d2118f9' - ), - setUserUseReserveAsCollateral: new Func<[asset: string, useAsCollateral: boolean], {asset: string, useAsCollateral: boolean}, []>( - abi, '0x5a3b74b9' - ), - swapBorrowRateMode: new Func<[asset: string, rateMode: bigint], {asset: string, rateMode: bigint}, []>( - abi, '0x94ba89a2' - ), - withdraw: new Func<[asset: string, amount: bigint, to: string], {asset: string, amount: bigint, to: string}, bigint>( - abi, '0x69328dec' - ), + FLASHLOAN_PREMIUM_TOTAL: fun("0x074b2e43", {}, p.uint256), + LENDINGPOOL_REVISION: fun("0x8afaff02", {}, p.uint256), + MAX_NUMBER_RESERVES: fun("0xf8119d51", {}, p.uint256), + MAX_STABLE_RATE_BORROW_SIZE_PERCENT: fun("0xe82fec2f", {}, p.uint256), + borrow: fun("0xa415bcad", {"asset": p.address, "amount": p.uint256, "interestRateMode": p.uint256, "referralCode": p.uint16, "onBehalfOf": p.address}, ), + deposit: fun("0xe8eda9df", {"asset": p.address, "amount": p.uint256, "onBehalfOf": p.address, "referralCode": p.uint16}, ), + finalizeTransfer: fun("0xd5ed3933", {"asset": p.address, "from": p.address, "to": p.address, "amount": p.uint256, "balanceFromBefore": p.uint256, "balanceToBefore": p.uint256}, ), + flashLoan: fun("0xab9c4b5d", {"receiverAddress": p.address, "assets": p.array(p.address), "amounts": p.array(p.uint256), "modes": p.array(p.uint256), "onBehalfOf": p.address, "params": p.bytes, "referralCode": p.uint16}, ), + getAddressesProvider: fun("0xfe65acfe", {}, p.address), + getConfiguration: fun("0xc44b11f7", {"asset": p.address}, p.struct({"data": p.uint256})), + getReserveData: fun("0x35ea6a75", {"asset": p.address}, p.struct({"configuration": p.struct({"data": p.uint256}), "liquidityIndex": p.uint128, "variableBorrowIndex": p.uint128, "currentLiquidityRate": p.uint128, "currentVariableBorrowRate": p.uint128, "currentStableBorrowRate": p.uint128, "lastUpdateTimestamp": p.uint40, "aTokenAddress": p.address, "stableDebtTokenAddress": p.address, "variableDebtTokenAddress": p.address, "interestRateStrategyAddress": p.address, "id": p.uint8})), + getReserveNormalizedIncome: fun("0xd15e0053", {"asset": p.address}, p.uint256), + getReserveNormalizedVariableDebt: fun("0x386497fd", {"asset": p.address}, p.uint256), + getReservesList: fun("0xd1946dbc", {}, p.array(p.address)), + getUserAccountData: fun("0xbf92857c", {"user": p.address}, {"totalCollateralETH": p.uint256, "totalDebtETH": p.uint256, "availableBorrowsETH": p.uint256, "currentLiquidationThreshold": p.uint256, "ltv": p.uint256, "healthFactor": p.uint256}), + getUserConfiguration: fun("0x4417a583", {"user": p.address}, p.struct({"data": p.uint256})), + initReserve: fun("0x7a708e92", {"asset": p.address, "aTokenAddress": p.address, "stableDebtAddress": p.address, "variableDebtAddress": p.address, "interestRateStrategyAddress": p.address}, ), + initialize: fun("0xc4d66de8", {"provider": p.address}, ), + liquidationCall: fun("0x00a718a9", {"collateralAsset": p.address, "debtAsset": p.address, "user": p.address, "debtToCover": p.uint256, "receiveAToken": p.bool}, ), + paused: fun("0x5c975abb", {}, p.bool), + rebalanceStableBorrowRate: fun("0xcd112382", {"asset": p.address, "user": p.address}, ), + repay: fun("0x573ade81", {"asset": p.address, "amount": p.uint256, "rateMode": p.uint256, "onBehalfOf": p.address}, p.uint256), + rescueTokens: fun("0xcea9d26f", {"token": p.address, "to": p.address, "amount": p.uint256}, ), + setConfiguration: fun("0xb8d29276", {"asset": p.address, "configuration": p.uint256}, ), + setPause: fun("0xbedb86fb", {"val": p.bool}, ), + setReserveInterestRateStrategyAddress: fun("0x1d2118f9", {"asset": p.address, "rateStrategyAddress": p.address}, ), + setUserUseReserveAsCollateral: fun("0x5a3b74b9", {"asset": p.address, "useAsCollateral": p.bool}, ), + swapBorrowRateMode: fun("0x94ba89a2", {"asset": p.address, "rateMode": p.uint256}, ), + withdraw: fun("0x69328dec", {"asset": p.address, "amount": p.uint256, "to": p.address}, p.uint256), } export class Contract extends ContractBase { - FLASHLOAN_PREMIUM_TOTAL(): Promise { - return this.eth_call(functions.FLASHLOAN_PREMIUM_TOTAL, []) + FLASHLOAN_PREMIUM_TOTAL() { + return this.eth_call(functions.FLASHLOAN_PREMIUM_TOTAL, {}) } - LENDINGPOOL_REVISION(): Promise { - return this.eth_call(functions.LENDINGPOOL_REVISION, []) + LENDINGPOOL_REVISION() { + return this.eth_call(functions.LENDINGPOOL_REVISION, {}) } - MAX_NUMBER_RESERVES(): Promise { - return this.eth_call(functions.MAX_NUMBER_RESERVES, []) + MAX_NUMBER_RESERVES() { + return this.eth_call(functions.MAX_NUMBER_RESERVES, {}) } - MAX_STABLE_RATE_BORROW_SIZE_PERCENT(): Promise { - return this.eth_call(functions.MAX_STABLE_RATE_BORROW_SIZE_PERCENT, []) + MAX_STABLE_RATE_BORROW_SIZE_PERCENT() { + return this.eth_call(functions.MAX_STABLE_RATE_BORROW_SIZE_PERCENT, {}) } - getAddressesProvider(): Promise { - return this.eth_call(functions.getAddressesProvider, []) + getAddressesProvider() { + return this.eth_call(functions.getAddressesProvider, {}) } - getConfiguration(asset: string): Promise<([data: bigint] & {data: bigint})> { - return this.eth_call(functions.getConfiguration, [asset]) + getConfiguration(asset: GetConfigurationParams["asset"]) { + return this.eth_call(functions.getConfiguration, {asset}) } - getReserveData(asset: string): Promise<([configuration: ([data: bigint] & {data: bigint}), liquidityIndex: bigint, variableBorrowIndex: bigint, currentLiquidityRate: bigint, currentVariableBorrowRate: bigint, currentStableBorrowRate: bigint, lastUpdateTimestamp: number, aTokenAddress: string, stableDebtTokenAddress: string, variableDebtTokenAddress: string, interestRateStrategyAddress: string, id: number] & {configuration: ([data: bigint] & {data: bigint}), liquidityIndex: bigint, variableBorrowIndex: bigint, currentLiquidityRate: bigint, currentVariableBorrowRate: bigint, currentStableBorrowRate: bigint, lastUpdateTimestamp: number, aTokenAddress: string, stableDebtTokenAddress: string, variableDebtTokenAddress: string, interestRateStrategyAddress: string, id: number})> { - return this.eth_call(functions.getReserveData, [asset]) + getReserveData(asset: GetReserveDataParams["asset"]) { + return this.eth_call(functions.getReserveData, {asset}) } - getReserveNormalizedIncome(asset: string): Promise { - return this.eth_call(functions.getReserveNormalizedIncome, [asset]) + getReserveNormalizedIncome(asset: GetReserveNormalizedIncomeParams["asset"]) { + return this.eth_call(functions.getReserveNormalizedIncome, {asset}) } - getReserveNormalizedVariableDebt(asset: string): Promise { - return this.eth_call(functions.getReserveNormalizedVariableDebt, [asset]) + getReserveNormalizedVariableDebt(asset: GetReserveNormalizedVariableDebtParams["asset"]) { + return this.eth_call(functions.getReserveNormalizedVariableDebt, {asset}) } - getReservesList(): Promise> { - return this.eth_call(functions.getReservesList, []) + getReservesList() { + return this.eth_call(functions.getReservesList, {}) } - getUserAccountData(user: string): Promise<([totalCollateralETH: bigint, totalDebtETH: bigint, availableBorrowsETH: bigint, currentLiquidationThreshold: bigint, ltv: bigint, healthFactor: bigint] & {totalCollateralETH: bigint, totalDebtETH: bigint, availableBorrowsETH: bigint, currentLiquidationThreshold: bigint, ltv: bigint, healthFactor: bigint})> { - return this.eth_call(functions.getUserAccountData, [user]) + getUserAccountData(user: GetUserAccountDataParams["user"]) { + return this.eth_call(functions.getUserAccountData, {user}) } - getUserConfiguration(user: string): Promise<([data: bigint] & {data: bigint})> { - return this.eth_call(functions.getUserConfiguration, [user]) + getUserConfiguration(user: GetUserConfigurationParams["user"]) { + return this.eth_call(functions.getUserConfiguration, {user}) } - paused(): Promise { - return this.eth_call(functions.paused, []) + paused() { + return this.eth_call(functions.paused, {}) } } + +/// Event types +export type BorrowEventArgs = EParams +export type DepositEventArgs = EParams +export type FlashLoanEventArgs = EParams +export type LiquidationCallEventArgs = EParams +export type PausedEventArgs = EParams +export type RebalanceStableBorrowRateEventArgs = EParams +export type RepayEventArgs = EParams +export type ReserveDataUpdatedEventArgs = EParams +export type ReserveUsedAsCollateralDisabledEventArgs = EParams +export type ReserveUsedAsCollateralEnabledEventArgs = EParams +export type SwapEventArgs = EParams +export type TokensRescuedEventArgs = EParams +export type UnpausedEventArgs = EParams +export type WithdrawEventArgs = EParams + +/// Function types +export type FLASHLOAN_PREMIUM_TOTALParams = FunctionArguments +export type FLASHLOAN_PREMIUM_TOTALReturn = FunctionReturn + +export type LENDINGPOOL_REVISIONParams = FunctionArguments +export type LENDINGPOOL_REVISIONReturn = FunctionReturn + +export type MAX_NUMBER_RESERVESParams = FunctionArguments +export type MAX_NUMBER_RESERVESReturn = FunctionReturn + +export type MAX_STABLE_RATE_BORROW_SIZE_PERCENTParams = FunctionArguments +export type MAX_STABLE_RATE_BORROW_SIZE_PERCENTReturn = FunctionReturn + +export type BorrowParams = FunctionArguments +export type BorrowReturn = FunctionReturn + +export type DepositParams = FunctionArguments +export type DepositReturn = FunctionReturn + +export type FinalizeTransferParams = FunctionArguments +export type FinalizeTransferReturn = FunctionReturn + +export type FlashLoanParams = FunctionArguments +export type FlashLoanReturn = FunctionReturn + +export type GetAddressesProviderParams = FunctionArguments +export type GetAddressesProviderReturn = FunctionReturn + +export type GetConfigurationParams = FunctionArguments +export type GetConfigurationReturn = FunctionReturn + +export type GetReserveDataParams = FunctionArguments +export type GetReserveDataReturn = FunctionReturn + +export type GetReserveNormalizedIncomeParams = FunctionArguments +export type GetReserveNormalizedIncomeReturn = FunctionReturn + +export type GetReserveNormalizedVariableDebtParams = FunctionArguments +export type GetReserveNormalizedVariableDebtReturn = FunctionReturn + +export type GetReservesListParams = FunctionArguments +export type GetReservesListReturn = FunctionReturn + +export type GetUserAccountDataParams = FunctionArguments +export type GetUserAccountDataReturn = FunctionReturn + +export type GetUserConfigurationParams = FunctionArguments +export type GetUserConfigurationReturn = FunctionReturn + +export type InitReserveParams = FunctionArguments +export type InitReserveReturn = FunctionReturn + +export type InitializeParams = FunctionArguments +export type InitializeReturn = FunctionReturn + +export type LiquidationCallParams = FunctionArguments +export type LiquidationCallReturn = FunctionReturn + +export type PausedParams = FunctionArguments +export type PausedReturn = FunctionReturn + +export type RebalanceStableBorrowRateParams = FunctionArguments +export type RebalanceStableBorrowRateReturn = FunctionReturn + +export type RepayParams = FunctionArguments +export type RepayReturn = FunctionReturn + +export type RescueTokensParams = FunctionArguments +export type RescueTokensReturn = FunctionReturn + +export type SetConfigurationParams = FunctionArguments +export type SetConfigurationReturn = FunctionReturn + +export type SetPauseParams = FunctionArguments +export type SetPauseReturn = FunctionReturn + +export type SetReserveInterestRateStrategyAddressParams = FunctionArguments +export type SetReserveInterestRateStrategyAddressReturn = FunctionReturn + +export type SetUserUseReserveAsCollateralParams = FunctionArguments +export type SetUserUseReserveAsCollateralReturn = FunctionReturn + +export type SwapBorrowRateModeParams = FunctionArguments +export type SwapBorrowRateModeReturn = FunctionReturn + +export type WithdrawParams = FunctionArguments +export type WithdrawReturn = FunctionReturn + diff --git a/src/abi/aave-token.ts b/src/abi/aave-token.ts index ef8c5d94..9320ac15 100644 --- a/src/abi/aave-token.ts +++ b/src/abi/aave-token.ts @@ -1,207 +1,234 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './aave-token.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - Approval: new LogEvent<([owner: string, spender: string, value: bigint] & {owner: string, spender: string, value: bigint})>( - abi, '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925' - ), - BalanceTransfer: new LogEvent<([from: string, to: string, value: bigint, index: bigint] & {from: string, to: string, value: bigint, index: bigint})>( - abi, '0x4beccb90f994c31aced7a23b5611020728a23d8ec5cddd1a3e9d97b96fda8666' - ), - Burn: new LogEvent<([from: string, target: string, value: bigint, index: bigint] & {from: string, target: string, value: bigint, index: bigint})>( - abi, '0x5d624aa9c148153ab3446c1b154f660ee7701e549fe9b62dab7171b1c80e6fa2' - ), - Initialized: new LogEvent<([underlyingAsset: string, pool: string, treasury: string, incentivesController: string, aTokenDecimals: number, aTokenName: string, aTokenSymbol: string, params: string] & {underlyingAsset: string, pool: string, treasury: string, incentivesController: string, aTokenDecimals: number, aTokenName: string, aTokenSymbol: string, params: string})>( - abi, '0xb19e051f8af41150ccccb3fc2c2d8d15f4a4cf434f32a559ba75fe73d6eea20b' - ), - Mint: new LogEvent<([from: string, value: bigint, index: bigint] & {from: string, value: bigint, index: bigint})>( - abi, '0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f' - ), - TokensRescued: new LogEvent<([tokenRescued: string, receiver: string, amountRescued: bigint] & {tokenRescued: string, receiver: string, amountRescued: bigint})>( - abi, '0x77023e19c7343ad491fd706c36335ca0e738340a91f29b1fd81e2673d44896c4' - ), - Transfer: new LogEvent<([from: string, to: string, value: bigint] & {from: string, to: string, value: bigint})>( - abi, '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' - ), + Approval: event("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", {"owner": indexed(p.address), "spender": indexed(p.address), "value": p.uint256}), + BalanceTransfer: event("0x4beccb90f994c31aced7a23b5611020728a23d8ec5cddd1a3e9d97b96fda8666", {"from": indexed(p.address), "to": indexed(p.address), "value": p.uint256, "index": p.uint256}), + Burn: event("0x5d624aa9c148153ab3446c1b154f660ee7701e549fe9b62dab7171b1c80e6fa2", {"from": indexed(p.address), "target": indexed(p.address), "value": p.uint256, "index": p.uint256}), + Initialized: event("0xb19e051f8af41150ccccb3fc2c2d8d15f4a4cf434f32a559ba75fe73d6eea20b", {"underlyingAsset": indexed(p.address), "pool": indexed(p.address), "treasury": p.address, "incentivesController": p.address, "aTokenDecimals": p.uint8, "aTokenName": p.string, "aTokenSymbol": p.string, "params": p.bytes}), + Mint: event("0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f", {"from": indexed(p.address), "value": p.uint256, "index": p.uint256}), + TokensRescued: event("0x77023e19c7343ad491fd706c36335ca0e738340a91f29b1fd81e2673d44896c4", {"tokenRescued": indexed(p.address), "receiver": indexed(p.address), "amountRescued": p.uint256}), + Transfer: event("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", {"from": indexed(p.address), "to": indexed(p.address), "value": p.uint256}), } export const functions = { - ATOKEN_REVISION: new Func<[], {}, bigint>( - abi, '0x0bd7ad3b' - ), - DOMAIN_SEPARATOR: new Func<[], {}, string>( - abi, '0x3644e515' - ), - EIP712_REVISION: new Func<[], {}, string>( - abi, '0x78160376' - ), - PERMIT_TYPEHASH: new Func<[], {}, string>( - abi, '0x30adf81f' - ), - POOL: new Func<[], {}, string>( - abi, '0x7535d246' - ), - RESERVE_TREASURY_ADDRESS: new Func<[], {}, string>( - abi, '0xae167335' - ), - UINT_MAX_VALUE: new Func<[], {}, bigint>( - abi, '0xd0fc81d2' - ), - UNDERLYING_ASSET_ADDRESS: new Func<[], {}, string>( - abi, '0xb16a19de' - ), - _nonces: new Func<[_: string], {}, bigint>( - abi, '0xb9844d8d' - ), - allowance: new Func<[owner: string, spender: string], {owner: string, spender: string}, bigint>( - abi, '0xdd62ed3e' - ), - approve: new Func<[spender: string, amount: bigint], {spender: string, amount: bigint}, boolean>( - abi, '0x095ea7b3' - ), - balanceOf: new Func<[user: string], {user: string}, bigint>( - abi, '0x70a08231' - ), - burn: new Func<[user: string, receiverOfUnderlying: string, amount: bigint, index: bigint], {user: string, receiverOfUnderlying: string, amount: bigint, index: bigint}, []>( - abi, '0xd7020d0a' - ), - decimals: new Func<[], {}, number>( - abi, '0x313ce567' - ), - decreaseAllowance: new Func<[spender: string, subtractedValue: bigint], {spender: string, subtractedValue: bigint}, boolean>( - abi, '0xa457c2d7' - ), - getIncentivesController: new Func<[], {}, string>( - abi, '0x75d26413' - ), - getScaledUserBalanceAndSupply: new Func<[user: string], {user: string}, [_: bigint, _: bigint]>( - abi, '0x0afbcdc9' - ), - increaseAllowance: new Func<[spender: string, addedValue: bigint], {spender: string, addedValue: bigint}, boolean>( - abi, '0x39509351' - ), - initialize: new Func<[underlyingAssetDecimals: number, tokenName: string, tokenSymbol: string], {underlyingAssetDecimals: number, tokenName: string, tokenSymbol: string}, []>( - abi, '0x3118724e' - ), - mint: new Func<[user: string, amount: bigint, index: bigint], {user: string, amount: bigint, index: bigint}, boolean>( - abi, '0x156e29f6' - ), - mintToTreasury: new Func<[amount: bigint, index: bigint], {amount: bigint, index: bigint}, []>( - abi, '0x7df5bd3b' - ), - name: new Func<[], {}, string>( - abi, '0x06fdde03' - ), - permit: new Func<[owner: string, spender: string, value: bigint, deadline: bigint, v: number, r: string, s: string], {owner: string, spender: string, value: bigint, deadline: bigint, v: number, r: string, s: string}, []>( - abi, '0xd505accf' - ), - rescueTokens: new Func<[token: string, to: string, amount: bigint], {token: string, to: string, amount: bigint}, []>( - abi, '0xcea9d26f' - ), - scaledBalanceOf: new Func<[user: string], {user: string}, bigint>( - abi, '0x1da24f3e' - ), - scaledTotalSupply: new Func<[], {}, bigint>( - abi, '0xb1bf962d' - ), - symbol: new Func<[], {}, string>( - abi, '0x95d89b41' - ), - totalSupply: new Func<[], {}, bigint>( - abi, '0x18160ddd' - ), - transfer: new Func<[recipient: string, amount: bigint], {recipient: string, amount: bigint}, boolean>( - abi, '0xa9059cbb' - ), - transferFrom: new Func<[sender: string, recipient: string, amount: bigint], {sender: string, recipient: string, amount: bigint}, boolean>( - abi, '0x23b872dd' - ), - transferOnLiquidation: new Func<[from: string, to: string, value: bigint], {from: string, to: string, value: bigint}, []>( - abi, '0xf866c319' - ), - transferUnderlyingTo: new Func<[target: string, amount: bigint], {target: string, amount: bigint}, bigint>( - abi, '0x4efecaa5' - ), + ATOKEN_REVISION: fun("0x0bd7ad3b", {}, p.uint256), + DOMAIN_SEPARATOR: fun("0x3644e515", {}, p.bytes32), + EIP712_REVISION: fun("0x78160376", {}, p.bytes), + PERMIT_TYPEHASH: fun("0x30adf81f", {}, p.bytes32), + POOL: fun("0x7535d246", {}, p.address), + RESERVE_TREASURY_ADDRESS: fun("0xae167335", {}, p.address), + UINT_MAX_VALUE: fun("0xd0fc81d2", {}, p.uint256), + UNDERLYING_ASSET_ADDRESS: fun("0xb16a19de", {}, p.address), + _nonces: fun("0xb9844d8d", {"_0": p.address}, p.uint256), + allowance: fun("0xdd62ed3e", {"owner": p.address, "spender": p.address}, p.uint256), + approve: fun("0x095ea7b3", {"spender": p.address, "amount": p.uint256}, p.bool), + balanceOf: fun("0x70a08231", {"user": p.address}, p.uint256), + burn: fun("0xd7020d0a", {"user": p.address, "receiverOfUnderlying": p.address, "amount": p.uint256, "index": p.uint256}, ), + decimals: fun("0x313ce567", {}, p.uint8), + decreaseAllowance: fun("0xa457c2d7", {"spender": p.address, "subtractedValue": p.uint256}, p.bool), + getIncentivesController: fun("0x75d26413", {}, p.address), + getScaledUserBalanceAndSupply: fun("0x0afbcdc9", {"user": p.address}, {"_0": p.uint256, "_1": p.uint256}), + increaseAllowance: fun("0x39509351", {"spender": p.address, "addedValue": p.uint256}, p.bool), + initialize: fun("0x3118724e", {"underlyingAssetDecimals": p.uint8, "tokenName": p.string, "tokenSymbol": p.string}, ), + mint: fun("0x156e29f6", {"user": p.address, "amount": p.uint256, "index": p.uint256}, p.bool), + mintToTreasury: fun("0x7df5bd3b", {"amount": p.uint256, "index": p.uint256}, ), + name: fun("0x06fdde03", {}, p.string), + permit: fun("0xd505accf", {"owner": p.address, "spender": p.address, "value": p.uint256, "deadline": p.uint256, "v": p.uint8, "r": p.bytes32, "s": p.bytes32}, ), + rescueTokens: fun("0xcea9d26f", {"token": p.address, "to": p.address, "amount": p.uint256}, ), + scaledBalanceOf: fun("0x1da24f3e", {"user": p.address}, p.uint256), + scaledTotalSupply: fun("0xb1bf962d", {}, p.uint256), + symbol: fun("0x95d89b41", {}, p.string), + totalSupply: fun("0x18160ddd", {}, p.uint256), + transfer: fun("0xa9059cbb", {"recipient": p.address, "amount": p.uint256}, p.bool), + transferFrom: fun("0x23b872dd", {"sender": p.address, "recipient": p.address, "amount": p.uint256}, p.bool), + transferOnLiquidation: fun("0xf866c319", {"from": p.address, "to": p.address, "value": p.uint256}, ), + transferUnderlyingTo: fun("0x4efecaa5", {"target": p.address, "amount": p.uint256}, p.uint256), } export class Contract extends ContractBase { - ATOKEN_REVISION(): Promise { - return this.eth_call(functions.ATOKEN_REVISION, []) + ATOKEN_REVISION() { + return this.eth_call(functions.ATOKEN_REVISION, {}) } - DOMAIN_SEPARATOR(): Promise { - return this.eth_call(functions.DOMAIN_SEPARATOR, []) + DOMAIN_SEPARATOR() { + return this.eth_call(functions.DOMAIN_SEPARATOR, {}) } - EIP712_REVISION(): Promise { - return this.eth_call(functions.EIP712_REVISION, []) + EIP712_REVISION() { + return this.eth_call(functions.EIP712_REVISION, {}) } - PERMIT_TYPEHASH(): Promise { - return this.eth_call(functions.PERMIT_TYPEHASH, []) + PERMIT_TYPEHASH() { + return this.eth_call(functions.PERMIT_TYPEHASH, {}) } - POOL(): Promise { - return this.eth_call(functions.POOL, []) + POOL() { + return this.eth_call(functions.POOL, {}) } - RESERVE_TREASURY_ADDRESS(): Promise { - return this.eth_call(functions.RESERVE_TREASURY_ADDRESS, []) + RESERVE_TREASURY_ADDRESS() { + return this.eth_call(functions.RESERVE_TREASURY_ADDRESS, {}) } - UINT_MAX_VALUE(): Promise { - return this.eth_call(functions.UINT_MAX_VALUE, []) + UINT_MAX_VALUE() { + return this.eth_call(functions.UINT_MAX_VALUE, {}) } - UNDERLYING_ASSET_ADDRESS(): Promise { - return this.eth_call(functions.UNDERLYING_ASSET_ADDRESS, []) + UNDERLYING_ASSET_ADDRESS() { + return this.eth_call(functions.UNDERLYING_ASSET_ADDRESS, {}) } - _nonces(arg0: string): Promise { - return this.eth_call(functions._nonces, [arg0]) + _nonces(_0: _noncesParams["_0"]) { + return this.eth_call(functions._nonces, {_0}) } - allowance(owner: string, spender: string): Promise { - return this.eth_call(functions.allowance, [owner, spender]) + allowance(owner: AllowanceParams["owner"], spender: AllowanceParams["spender"]) { + return this.eth_call(functions.allowance, {owner, spender}) } - balanceOf(user: string): Promise { - return this.eth_call(functions.balanceOf, [user]) + balanceOf(user: BalanceOfParams["user"]) { + return this.eth_call(functions.balanceOf, {user}) } - decimals(): Promise { - return this.eth_call(functions.decimals, []) + decimals() { + return this.eth_call(functions.decimals, {}) } - getIncentivesController(): Promise { - return this.eth_call(functions.getIncentivesController, []) + getIncentivesController() { + return this.eth_call(functions.getIncentivesController, {}) } - getScaledUserBalanceAndSupply(user: string): Promise<[_: bigint, _: bigint]> { - return this.eth_call(functions.getScaledUserBalanceAndSupply, [user]) + getScaledUserBalanceAndSupply(user: GetScaledUserBalanceAndSupplyParams["user"]) { + return this.eth_call(functions.getScaledUserBalanceAndSupply, {user}) } - name(): Promise { - return this.eth_call(functions.name, []) + name() { + return this.eth_call(functions.name, {}) } - scaledBalanceOf(user: string): Promise { - return this.eth_call(functions.scaledBalanceOf, [user]) + scaledBalanceOf(user: ScaledBalanceOfParams["user"]) { + return this.eth_call(functions.scaledBalanceOf, {user}) } - scaledTotalSupply(): Promise { - return this.eth_call(functions.scaledTotalSupply, []) + scaledTotalSupply() { + return this.eth_call(functions.scaledTotalSupply, {}) } - symbol(): Promise { - return this.eth_call(functions.symbol, []) + symbol() { + return this.eth_call(functions.symbol, {}) } - totalSupply(): Promise { - return this.eth_call(functions.totalSupply, []) + totalSupply() { + return this.eth_call(functions.totalSupply, {}) } } + +/// Event types +export type ApprovalEventArgs = EParams +export type BalanceTransferEventArgs = EParams +export type BurnEventArgs = EParams +export type InitializedEventArgs = EParams +export type MintEventArgs = EParams +export type TokensRescuedEventArgs = EParams +export type TransferEventArgs = EParams + +/// Function types +export type ATOKEN_REVISIONParams = FunctionArguments +export type ATOKEN_REVISIONReturn = FunctionReturn + +export type DOMAIN_SEPARATORParams = FunctionArguments +export type DOMAIN_SEPARATORReturn = FunctionReturn + +export type EIP712_REVISIONParams = FunctionArguments +export type EIP712_REVISIONReturn = FunctionReturn + +export type PERMIT_TYPEHASHParams = FunctionArguments +export type PERMIT_TYPEHASHReturn = FunctionReturn + +export type POOLParams = FunctionArguments +export type POOLReturn = FunctionReturn + +export type RESERVE_TREASURY_ADDRESSParams = FunctionArguments +export type RESERVE_TREASURY_ADDRESSReturn = FunctionReturn + +export type UINT_MAX_VALUEParams = FunctionArguments +export type UINT_MAX_VALUEReturn = FunctionReturn + +export type UNDERLYING_ASSET_ADDRESSParams = FunctionArguments +export type UNDERLYING_ASSET_ADDRESSReturn = FunctionReturn + +export type _noncesParams = FunctionArguments +export type _noncesReturn = FunctionReturn + +export type AllowanceParams = FunctionArguments +export type AllowanceReturn = FunctionReturn + +export type ApproveParams = FunctionArguments +export type ApproveReturn = FunctionReturn + +export type BalanceOfParams = FunctionArguments +export type BalanceOfReturn = FunctionReturn + +export type BurnParams = FunctionArguments +export type BurnReturn = FunctionReturn + +export type DecimalsParams = FunctionArguments +export type DecimalsReturn = FunctionReturn + +export type DecreaseAllowanceParams = FunctionArguments +export type DecreaseAllowanceReturn = FunctionReturn + +export type GetIncentivesControllerParams = FunctionArguments +export type GetIncentivesControllerReturn = FunctionReturn + +export type GetScaledUserBalanceAndSupplyParams = FunctionArguments +export type GetScaledUserBalanceAndSupplyReturn = FunctionReturn + +export type IncreaseAllowanceParams = FunctionArguments +export type IncreaseAllowanceReturn = FunctionReturn + +export type InitializeParams = FunctionArguments +export type InitializeReturn = FunctionReturn + +export type MintParams = FunctionArguments +export type MintReturn = FunctionReturn + +export type MintToTreasuryParams = FunctionArguments +export type MintToTreasuryReturn = FunctionReturn + +export type NameParams = FunctionArguments +export type NameReturn = FunctionReturn + +export type PermitParams = FunctionArguments +export type PermitReturn = FunctionReturn + +export type RescueTokensParams = FunctionArguments +export type RescueTokensReturn = FunctionReturn + +export type ScaledBalanceOfParams = FunctionArguments +export type ScaledBalanceOfReturn = FunctionReturn + +export type ScaledTotalSupplyParams = FunctionArguments +export type ScaledTotalSupplyReturn = FunctionReturn + +export type SymbolParams = FunctionArguments +export type SymbolReturn = FunctionReturn + +export type TotalSupplyParams = FunctionArguments +export type TotalSupplyReturn = FunctionReturn + +export type TransferParams = FunctionArguments +export type TransferReturn = FunctionReturn + +export type TransferFromParams = FunctionArguments +export type TransferFromReturn = FunctionReturn + +export type TransferOnLiquidationParams = FunctionArguments +export type TransferOnLiquidationReturn = FunctionReturn + +export type TransferUnderlyingToParams = FunctionArguments +export type TransferUnderlyingToReturn = FunctionReturn + diff --git a/src/abi/balancer-composable-stable-pool.ts b/src/abi/balancer-composable-stable-pool.ts index f25b7d2f..07da3d69 100644 --- a/src/abi/balancer-composable-stable-pool.ts +++ b/src/abi/balancer-composable-stable-pool.ts @@ -1,355 +1,404 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './balancer-composable-stable-pool.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - AmpUpdateStarted: new LogEvent<([startValue: bigint, endValue: bigint, startTime: bigint, endTime: bigint] & {startValue: bigint, endValue: bigint, startTime: bigint, endTime: bigint})>( - abi, '0x1835882ee7a34ac194f717a35e09bb1d24c82a3b9d854ab6c9749525b714cdf2' - ), - AmpUpdateStopped: new LogEvent<([currentValue: bigint] & {currentValue: bigint})>( - abi, '0xa0d01593e47e69d07e0ccd87bece09411e07dd1ed40ca8f2e7af2976542a0233' - ), - Approval: new LogEvent<([owner: string, spender: string, value: bigint] & {owner: string, spender: string, value: bigint})>( - abi, '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925' - ), - PausedStateChanged: new LogEvent<([paused: boolean] & {paused: boolean})>( - abi, '0x9e3a5e37224532dea67b89face185703738a228a6e8a23dee546960180d3be64' - ), - ProtocolFeePercentageCacheUpdated: new LogEvent<([feeType: bigint, protocolFeePercentage: bigint] & {feeType: bigint, protocolFeePercentage: bigint})>( - abi, '0x6bfb689528fa96ec1ad670ad6d6064be1ae96bfd5d2ee35c837fd0fe0c11959a' - ), - RecoveryModeStateChanged: new LogEvent<([enabled: boolean] & {enabled: boolean})>( - abi, '0xeff3d4d215b42bf0960be9c6d5e05c22cba4df6627a3a523e2acee733b5854c8' - ), - SwapFeePercentageChanged: new LogEvent<([swapFeePercentage: bigint] & {swapFeePercentage: bigint})>( - abi, '0xa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc' - ), - TokenRateCacheUpdated: new LogEvent<([tokenIndex: bigint, rate: bigint] & {tokenIndex: bigint, rate: bigint})>( - abi, '0xb77a83204ca282e08dc3a65b0a1ca32ea4e6875c38ef0bf5bf75e52a67354fac' - ), - TokenRateProviderSet: new LogEvent<([tokenIndex: bigint, provider: string, cacheDuration: bigint] & {tokenIndex: bigint, provider: string, cacheDuration: bigint})>( - abi, '0xdd6d1c9badb346de6925b358a472c937b41698d2632696759e43fd6527feeec4' - ), - Transfer: new LogEvent<([from: string, to: string, value: bigint] & {from: string, to: string, value: bigint})>( - abi, '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' - ), + AmpUpdateStarted: event("0x1835882ee7a34ac194f717a35e09bb1d24c82a3b9d854ab6c9749525b714cdf2", {"startValue": p.uint256, "endValue": p.uint256, "startTime": p.uint256, "endTime": p.uint256}), + AmpUpdateStopped: event("0xa0d01593e47e69d07e0ccd87bece09411e07dd1ed40ca8f2e7af2976542a0233", {"currentValue": p.uint256}), + Approval: event("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", {"owner": indexed(p.address), "spender": indexed(p.address), "value": p.uint256}), + PausedStateChanged: event("0x9e3a5e37224532dea67b89face185703738a228a6e8a23dee546960180d3be64", {"paused": p.bool}), + ProtocolFeePercentageCacheUpdated: event("0x6bfb689528fa96ec1ad670ad6d6064be1ae96bfd5d2ee35c837fd0fe0c11959a", {"feeType": indexed(p.uint256), "protocolFeePercentage": p.uint256}), + RecoveryModeStateChanged: event("0xeff3d4d215b42bf0960be9c6d5e05c22cba4df6627a3a523e2acee733b5854c8", {"enabled": p.bool}), + SwapFeePercentageChanged: event("0xa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc", {"swapFeePercentage": p.uint256}), + TokenRateCacheUpdated: event("0xb77a83204ca282e08dc3a65b0a1ca32ea4e6875c38ef0bf5bf75e52a67354fac", {"tokenIndex": indexed(p.uint256), "rate": p.uint256}), + TokenRateProviderSet: event("0xdd6d1c9badb346de6925b358a472c937b41698d2632696759e43fd6527feeec4", {"tokenIndex": indexed(p.uint256), "provider": indexed(p.address), "cacheDuration": p.uint256}), + Transfer: event("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", {"from": indexed(p.address), "to": indexed(p.address), "value": p.uint256}), } export const functions = { - DELEGATE_PROTOCOL_SWAP_FEES_SENTINEL: new Func<[], {}, bigint>( - abi, '0xddf4627b' - ), - DOMAIN_SEPARATOR: new Func<[], {}, string>( - abi, '0x3644e515' - ), - allowance: new Func<[owner: string, spender: string], {owner: string, spender: string}, bigint>( - abi, '0xdd62ed3e' - ), - approve: new Func<[spender: string, amount: bigint], {spender: string, amount: bigint}, boolean>( - abi, '0x095ea7b3' - ), - balanceOf: new Func<[account: string], {account: string}, bigint>( - abi, '0x70a08231' - ), - decimals: new Func<[], {}, number>( - abi, '0x313ce567' - ), - decreaseAllowance: new Func<[spender: string, amount: bigint], {spender: string, amount: bigint}, boolean>( - abi, '0xa457c2d7' - ), - disableRecoveryMode: new Func<[], {}, []>( - abi, '0xb7b814fc' - ), - enableRecoveryMode: new Func<[], {}, []>( - abi, '0x54a844ba' - ), - getActionId: new Func<[selector: string], {selector: string}, string>( - abi, '0x851c1bb3' - ), - getActualSupply: new Func<[], {}, bigint>( - abi, '0x876f303b' - ), - getAmplificationParameter: new Func<[], {}, ([value: bigint, isUpdating: boolean, precision: bigint] & {value: bigint, isUpdating: boolean, precision: bigint})>( - abi, '0x6daccffa' - ), - getAuthorizer: new Func<[], {}, string>( - abi, '0xaaabadc5' - ), - getBptIndex: new Func<[], {}, bigint>( - abi, '0x82687a56' - ), - getDomainSeparator: new Func<[], {}, string>( - abi, '0xed24911d' - ), - getLastJoinExitData: new Func<[], {}, ([lastJoinExitAmplification: bigint, lastPostJoinExitInvariant: bigint] & {lastJoinExitAmplification: bigint, lastPostJoinExitInvariant: bigint})>( - abi, '0x3c975d51' - ), - getMinimumBpt: new Func<[], {}, bigint>( - abi, '0x04842d4c' - ), - getNextNonce: new Func<[account: string], {account: string}, bigint>( - abi, '0x90193b7c' - ), - getOwner: new Func<[], {}, string>( - abi, '0x893d20e8' - ), - getPausedState: new Func<[], {}, ([paused: boolean, pauseWindowEndTime: bigint, bufferPeriodEndTime: bigint] & {paused: boolean, pauseWindowEndTime: bigint, bufferPeriodEndTime: bigint})>( - abi, '0x1c0de051' - ), - getPoolId: new Func<[], {}, string>( - abi, '0x38fff2d0' - ), - getProtocolFeePercentageCache: new Func<[feeType: bigint], {feeType: bigint}, bigint>( - abi, '0x70464016' - ), - getProtocolFeesCollector: new Func<[], {}, string>( - abi, '0xd2946c2b' - ), - getProtocolSwapFeeDelegation: new Func<[], {}, boolean>( - abi, '0x15b0015b' - ), - getRate: new Func<[], {}, bigint>( - abi, '0x679aefce' - ), - getRateProviders: new Func<[], {}, Array>( - abi, '0x238a2d59' - ), - getScalingFactors: new Func<[], {}, Array>( - abi, '0x1dd746ea' - ), - getSwapFeePercentage: new Func<[], {}, bigint>( - abi, '0x55c67628' - ), - getTokenRate: new Func<[token: string], {token: string}, bigint>( - abi, '0x54dea00a' - ), - getTokenRateCache: new Func<[token: string], {token: string}, ([rate: bigint, oldRate: bigint, duration: bigint, expires: bigint] & {rate: bigint, oldRate: bigint, duration: bigint, expires: bigint})>( - abi, '0x7f1260d1' - ), - getVault: new Func<[], {}, string>( - abi, '0x8d928af8' - ), - inRecoveryMode: new Func<[], {}, boolean>( - abi, '0xb35056b8' - ), - increaseAllowance: new Func<[spender: string, addedValue: bigint], {spender: string, addedValue: bigint}, boolean>( - abi, '0x39509351' - ), - isExemptFromYieldProtocolFee: new Func<[], {}, boolean>( - abi, '0x77151bee' - ), - isTokenExemptFromYieldProtocolFee: new Func<[token: string], {token: string}, boolean>( - abi, '0xab7759f1' - ), - name: new Func<[], {}, string>( - abi, '0x06fdde03' - ), - nonces: new Func<[owner: string], {owner: string}, bigint>( - abi, '0x7ecebe00' - ), - onExitPool: new Func<[poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string], {poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string}, [_: Array, _: Array]>( - abi, '0x74f3b009' - ), - onJoinPool: new Func<[poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string], {poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string}, [_: Array, _: Array]>( - abi, '0xd5c096c4' - ), - onSwap: new Func<[swapRequest: ([kind: number, tokenIn: string, tokenOut: string, amount: bigint, poolId: string, lastChangeBlock: bigint, from: string, to: string, userData: string] & {kind: number, tokenIn: string, tokenOut: string, amount: bigint, poolId: string, lastChangeBlock: bigint, from: string, to: string, userData: string}), balances: Array, indexIn: bigint, indexOut: bigint], {swapRequest: ([kind: number, tokenIn: string, tokenOut: string, amount: bigint, poolId: string, lastChangeBlock: bigint, from: string, to: string, userData: string] & {kind: number, tokenIn: string, tokenOut: string, amount: bigint, poolId: string, lastChangeBlock: bigint, from: string, to: string, userData: string}), balances: Array, indexIn: bigint, indexOut: bigint}, bigint>( - abi, '0x01ec954a' - ), - pause: new Func<[], {}, []>( - abi, '0x8456cb59' - ), - permit: new Func<[owner: string, spender: string, value: bigint, deadline: bigint, v: number, r: string, s: string], {owner: string, spender: string, value: bigint, deadline: bigint, v: number, r: string, s: string}, []>( - abi, '0xd505accf' - ), - queryExit: new Func<[poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string], {poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string}, ([bptIn: bigint, amountsOut: Array] & {bptIn: bigint, amountsOut: Array})>( - abi, '0x6028bfd4' - ), - queryJoin: new Func<[poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string], {poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string}, ([bptOut: bigint, amountsIn: Array] & {bptOut: bigint, amountsIn: Array})>( - abi, '0x87ec6817' - ), - setAssetManagerPoolConfig: new Func<[token: string, poolConfig: string], {token: string, poolConfig: string}, []>( - abi, '0x50dd6ed9' - ), - setSwapFeePercentage: new Func<[swapFeePercentage: bigint], {swapFeePercentage: bigint}, []>( - abi, '0x38e9922e' - ), - setTokenRateCacheDuration: new Func<[token: string, duration: bigint], {token: string, duration: bigint}, []>( - abi, '0xf4b7964d' - ), - startAmplificationParameterUpdate: new Func<[rawEndValue: bigint, endTime: bigint], {rawEndValue: bigint, endTime: bigint}, []>( - abi, '0x2f1a0bc9' - ), - stopAmplificationParameterUpdate: new Func<[], {}, []>( - abi, '0xeb0f24d6' - ), - symbol: new Func<[], {}, string>( - abi, '0x95d89b41' - ), - totalSupply: new Func<[], {}, bigint>( - abi, '0x18160ddd' - ), - transfer: new Func<[recipient: string, amount: bigint], {recipient: string, amount: bigint}, boolean>( - abi, '0xa9059cbb' - ), - transferFrom: new Func<[sender: string, recipient: string, amount: bigint], {sender: string, recipient: string, amount: bigint}, boolean>( - abi, '0x23b872dd' - ), - unpause: new Func<[], {}, []>( - abi, '0x3f4ba83a' - ), - updateProtocolFeePercentageCache: new Func<[], {}, []>( - abi, '0x0da0669c' - ), - updateTokenRateCache: new Func<[token: string], {token: string}, []>( - abi, '0x2df2c7c0' - ), - version: new Func<[], {}, string>( - abi, '0x54fd4d50' - ), + DELEGATE_PROTOCOL_SWAP_FEES_SENTINEL: fun("0xddf4627b", {}, p.uint256), + DOMAIN_SEPARATOR: fun("0x3644e515", {}, p.bytes32), + allowance: fun("0xdd62ed3e", {"owner": p.address, "spender": p.address}, p.uint256), + approve: fun("0x095ea7b3", {"spender": p.address, "amount": p.uint256}, p.bool), + balanceOf: fun("0x70a08231", {"account": p.address}, p.uint256), + decimals: fun("0x313ce567", {}, p.uint8), + decreaseAllowance: fun("0xa457c2d7", {"spender": p.address, "amount": p.uint256}, p.bool), + disableRecoveryMode: fun("0xb7b814fc", {}, ), + enableRecoveryMode: fun("0x54a844ba", {}, ), + getActionId: fun("0x851c1bb3", {"selector": p.bytes4}, p.bytes32), + getActualSupply: fun("0x876f303b", {}, p.uint256), + getAmplificationParameter: fun("0x6daccffa", {}, {"value": p.uint256, "isUpdating": p.bool, "precision": p.uint256}), + getAuthorizer: fun("0xaaabadc5", {}, p.address), + getBptIndex: fun("0x82687a56", {}, p.uint256), + getDomainSeparator: fun("0xed24911d", {}, p.bytes32), + getLastJoinExitData: fun("0x3c975d51", {}, {"lastJoinExitAmplification": p.uint256, "lastPostJoinExitInvariant": p.uint256}), + getMinimumBpt: fun("0x04842d4c", {}, p.uint256), + getNextNonce: fun("0x90193b7c", {"account": p.address}, p.uint256), + getOwner: fun("0x893d20e8", {}, p.address), + getPausedState: fun("0x1c0de051", {}, {"paused": p.bool, "pauseWindowEndTime": p.uint256, "bufferPeriodEndTime": p.uint256}), + getPoolId: fun("0x38fff2d0", {}, p.bytes32), + getProtocolFeePercentageCache: fun("0x70464016", {"feeType": p.uint256}, p.uint256), + getProtocolFeesCollector: fun("0xd2946c2b", {}, p.address), + getProtocolSwapFeeDelegation: fun("0x15b0015b", {}, p.bool), + getRate: fun("0x679aefce", {}, p.uint256), + getRateProviders: fun("0x238a2d59", {}, p.array(p.address)), + getScalingFactors: fun("0x1dd746ea", {}, p.array(p.uint256)), + getSwapFeePercentage: fun("0x55c67628", {}, p.uint256), + getTokenRate: fun("0x54dea00a", {"token": p.address}, p.uint256), + getTokenRateCache: fun("0x7f1260d1", {"token": p.address}, {"rate": p.uint256, "oldRate": p.uint256, "duration": p.uint256, "expires": p.uint256}), + getVault: fun("0x8d928af8", {}, p.address), + inRecoveryMode: fun("0xb35056b8", {}, p.bool), + increaseAllowance: fun("0x39509351", {"spender": p.address, "addedValue": p.uint256}, p.bool), + isExemptFromYieldProtocolFee: fun("0x77151bee", {}, p.bool), + isTokenExemptFromYieldProtocolFee: fun("0xab7759f1", {"token": p.address}, p.bool), + name: fun("0x06fdde03", {}, p.string), + nonces: fun("0x7ecebe00", {"owner": p.address}, p.uint256), + onExitPool: fun("0x74f3b009", {"poolId": p.bytes32, "sender": p.address, "recipient": p.address, "balances": p.array(p.uint256), "lastChangeBlock": p.uint256, "protocolSwapFeePercentage": p.uint256, "userData": p.bytes}, {"_0": p.array(p.uint256), "_1": p.array(p.uint256)}), + onJoinPool: fun("0xd5c096c4", {"poolId": p.bytes32, "sender": p.address, "recipient": p.address, "balances": p.array(p.uint256), "lastChangeBlock": p.uint256, "protocolSwapFeePercentage": p.uint256, "userData": p.bytes}, {"_0": p.array(p.uint256), "_1": p.array(p.uint256)}), + onSwap: fun("0x01ec954a", {"swapRequest": p.struct({"kind": p.uint8, "tokenIn": p.address, "tokenOut": p.address, "amount": p.uint256, "poolId": p.bytes32, "lastChangeBlock": p.uint256, "from": p.address, "to": p.address, "userData": p.bytes}), "balances": p.array(p.uint256), "indexIn": p.uint256, "indexOut": p.uint256}, p.uint256), + pause: fun("0x8456cb59", {}, ), + permit: fun("0xd505accf", {"owner": p.address, "spender": p.address, "value": p.uint256, "deadline": p.uint256, "v": p.uint8, "r": p.bytes32, "s": p.bytes32}, ), + queryExit: fun("0x6028bfd4", {"poolId": p.bytes32, "sender": p.address, "recipient": p.address, "balances": p.array(p.uint256), "lastChangeBlock": p.uint256, "protocolSwapFeePercentage": p.uint256, "userData": p.bytes}, {"bptIn": p.uint256, "amountsOut": p.array(p.uint256)}), + queryJoin: fun("0x87ec6817", {"poolId": p.bytes32, "sender": p.address, "recipient": p.address, "balances": p.array(p.uint256), "lastChangeBlock": p.uint256, "protocolSwapFeePercentage": p.uint256, "userData": p.bytes}, {"bptOut": p.uint256, "amountsIn": p.array(p.uint256)}), + setAssetManagerPoolConfig: fun("0x50dd6ed9", {"token": p.address, "poolConfig": p.bytes}, ), + setSwapFeePercentage: fun("0x38e9922e", {"swapFeePercentage": p.uint256}, ), + setTokenRateCacheDuration: fun("0xf4b7964d", {"token": p.address, "duration": p.uint256}, ), + startAmplificationParameterUpdate: fun("0x2f1a0bc9", {"rawEndValue": p.uint256, "endTime": p.uint256}, ), + stopAmplificationParameterUpdate: fun("0xeb0f24d6", {}, ), + symbol: fun("0x95d89b41", {}, p.string), + totalSupply: fun("0x18160ddd", {}, p.uint256), + transfer: fun("0xa9059cbb", {"recipient": p.address, "amount": p.uint256}, p.bool), + transferFrom: fun("0x23b872dd", {"sender": p.address, "recipient": p.address, "amount": p.uint256}, p.bool), + unpause: fun("0x3f4ba83a", {}, ), + updateProtocolFeePercentageCache: fun("0x0da0669c", {}, ), + updateTokenRateCache: fun("0x2df2c7c0", {"token": p.address}, ), + version: fun("0x54fd4d50", {}, p.string), } export class Contract extends ContractBase { - DELEGATE_PROTOCOL_SWAP_FEES_SENTINEL(): Promise { - return this.eth_call(functions.DELEGATE_PROTOCOL_SWAP_FEES_SENTINEL, []) + DELEGATE_PROTOCOL_SWAP_FEES_SENTINEL() { + return this.eth_call(functions.DELEGATE_PROTOCOL_SWAP_FEES_SENTINEL, {}) } - DOMAIN_SEPARATOR(): Promise { - return this.eth_call(functions.DOMAIN_SEPARATOR, []) + DOMAIN_SEPARATOR() { + return this.eth_call(functions.DOMAIN_SEPARATOR, {}) } - allowance(owner: string, spender: string): Promise { - return this.eth_call(functions.allowance, [owner, spender]) + allowance(owner: AllowanceParams["owner"], spender: AllowanceParams["spender"]) { + return this.eth_call(functions.allowance, {owner, spender}) } - balanceOf(account: string): Promise { - return this.eth_call(functions.balanceOf, [account]) + balanceOf(account: BalanceOfParams["account"]) { + return this.eth_call(functions.balanceOf, {account}) } - decimals(): Promise { - return this.eth_call(functions.decimals, []) + decimals() { + return this.eth_call(functions.decimals, {}) } - getActionId(selector: string): Promise { - return this.eth_call(functions.getActionId, [selector]) + getActionId(selector: GetActionIdParams["selector"]) { + return this.eth_call(functions.getActionId, {selector}) } - getActualSupply(): Promise { - return this.eth_call(functions.getActualSupply, []) + getActualSupply() { + return this.eth_call(functions.getActualSupply, {}) } - getAmplificationParameter(): Promise<([value: bigint, isUpdating: boolean, precision: bigint] & {value: bigint, isUpdating: boolean, precision: bigint})> { - return this.eth_call(functions.getAmplificationParameter, []) + getAmplificationParameter() { + return this.eth_call(functions.getAmplificationParameter, {}) } - getAuthorizer(): Promise { - return this.eth_call(functions.getAuthorizer, []) + getAuthorizer() { + return this.eth_call(functions.getAuthorizer, {}) } - getBptIndex(): Promise { - return this.eth_call(functions.getBptIndex, []) + getBptIndex() { + return this.eth_call(functions.getBptIndex, {}) } - getDomainSeparator(): Promise { - return this.eth_call(functions.getDomainSeparator, []) + getDomainSeparator() { + return this.eth_call(functions.getDomainSeparator, {}) } - getLastJoinExitData(): Promise<([lastJoinExitAmplification: bigint, lastPostJoinExitInvariant: bigint] & {lastJoinExitAmplification: bigint, lastPostJoinExitInvariant: bigint})> { - return this.eth_call(functions.getLastJoinExitData, []) + getLastJoinExitData() { + return this.eth_call(functions.getLastJoinExitData, {}) } - getMinimumBpt(): Promise { - return this.eth_call(functions.getMinimumBpt, []) + getMinimumBpt() { + return this.eth_call(functions.getMinimumBpt, {}) } - getNextNonce(account: string): Promise { - return this.eth_call(functions.getNextNonce, [account]) + getNextNonce(account: GetNextNonceParams["account"]) { + return this.eth_call(functions.getNextNonce, {account}) } - getOwner(): Promise { - return this.eth_call(functions.getOwner, []) + getOwner() { + return this.eth_call(functions.getOwner, {}) } - getPausedState(): Promise<([paused: boolean, pauseWindowEndTime: bigint, bufferPeriodEndTime: bigint] & {paused: boolean, pauseWindowEndTime: bigint, bufferPeriodEndTime: bigint})> { - return this.eth_call(functions.getPausedState, []) + getPausedState() { + return this.eth_call(functions.getPausedState, {}) } - getPoolId(): Promise { - return this.eth_call(functions.getPoolId, []) + getPoolId() { + return this.eth_call(functions.getPoolId, {}) } - getProtocolFeePercentageCache(feeType: bigint): Promise { - return this.eth_call(functions.getProtocolFeePercentageCache, [feeType]) + getProtocolFeePercentageCache(feeType: GetProtocolFeePercentageCacheParams["feeType"]) { + return this.eth_call(functions.getProtocolFeePercentageCache, {feeType}) } - getProtocolFeesCollector(): Promise { - return this.eth_call(functions.getProtocolFeesCollector, []) + getProtocolFeesCollector() { + return this.eth_call(functions.getProtocolFeesCollector, {}) } - getProtocolSwapFeeDelegation(): Promise { - return this.eth_call(functions.getProtocolSwapFeeDelegation, []) + getProtocolSwapFeeDelegation() { + return this.eth_call(functions.getProtocolSwapFeeDelegation, {}) } - getRate(): Promise { - return this.eth_call(functions.getRate, []) + getRate() { + return this.eth_call(functions.getRate, {}) } - getRateProviders(): Promise> { - return this.eth_call(functions.getRateProviders, []) + getRateProviders() { + return this.eth_call(functions.getRateProviders, {}) } - getScalingFactors(): Promise> { - return this.eth_call(functions.getScalingFactors, []) + getScalingFactors() { + return this.eth_call(functions.getScalingFactors, {}) } - getSwapFeePercentage(): Promise { - return this.eth_call(functions.getSwapFeePercentage, []) + getSwapFeePercentage() { + return this.eth_call(functions.getSwapFeePercentage, {}) } - getTokenRate(token: string): Promise { - return this.eth_call(functions.getTokenRate, [token]) + getTokenRate(token: GetTokenRateParams["token"]) { + return this.eth_call(functions.getTokenRate, {token}) } - getTokenRateCache(token: string): Promise<([rate: bigint, oldRate: bigint, duration: bigint, expires: bigint] & {rate: bigint, oldRate: bigint, duration: bigint, expires: bigint})> { - return this.eth_call(functions.getTokenRateCache, [token]) + getTokenRateCache(token: GetTokenRateCacheParams["token"]) { + return this.eth_call(functions.getTokenRateCache, {token}) } - getVault(): Promise { - return this.eth_call(functions.getVault, []) + getVault() { + return this.eth_call(functions.getVault, {}) } - inRecoveryMode(): Promise { - return this.eth_call(functions.inRecoveryMode, []) + inRecoveryMode() { + return this.eth_call(functions.inRecoveryMode, {}) } - isExemptFromYieldProtocolFee(): Promise { - return this.eth_call(functions.isExemptFromYieldProtocolFee, []) + isExemptFromYieldProtocolFee() { + return this.eth_call(functions.isExemptFromYieldProtocolFee, {}) } - isTokenExemptFromYieldProtocolFee(token: string): Promise { - return this.eth_call(functions.isTokenExemptFromYieldProtocolFee, [token]) + isTokenExemptFromYieldProtocolFee(token: IsTokenExemptFromYieldProtocolFeeParams["token"]) { + return this.eth_call(functions.isTokenExemptFromYieldProtocolFee, {token}) } - name(): Promise { - return this.eth_call(functions.name, []) + name() { + return this.eth_call(functions.name, {}) } - nonces(owner: string): Promise { - return this.eth_call(functions.nonces, [owner]) + nonces(owner: NoncesParams["owner"]) { + return this.eth_call(functions.nonces, {owner}) } - symbol(): Promise { - return this.eth_call(functions.symbol, []) + symbol() { + return this.eth_call(functions.symbol, {}) } - totalSupply(): Promise { - return this.eth_call(functions.totalSupply, []) + totalSupply() { + return this.eth_call(functions.totalSupply, {}) } - version(): Promise { - return this.eth_call(functions.version, []) + version() { + return this.eth_call(functions.version, {}) } } + +/// Event types +export type AmpUpdateStartedEventArgs = EParams +export type AmpUpdateStoppedEventArgs = EParams +export type ApprovalEventArgs = EParams +export type PausedStateChangedEventArgs = EParams +export type ProtocolFeePercentageCacheUpdatedEventArgs = EParams +export type RecoveryModeStateChangedEventArgs = EParams +export type SwapFeePercentageChangedEventArgs = EParams +export type TokenRateCacheUpdatedEventArgs = EParams +export type TokenRateProviderSetEventArgs = EParams +export type TransferEventArgs = EParams + +/// Function types +export type DELEGATE_PROTOCOL_SWAP_FEES_SENTINELParams = FunctionArguments +export type DELEGATE_PROTOCOL_SWAP_FEES_SENTINELReturn = FunctionReturn + +export type DOMAIN_SEPARATORParams = FunctionArguments +export type DOMAIN_SEPARATORReturn = FunctionReturn + +export type AllowanceParams = FunctionArguments +export type AllowanceReturn = FunctionReturn + +export type ApproveParams = FunctionArguments +export type ApproveReturn = FunctionReturn + +export type BalanceOfParams = FunctionArguments +export type BalanceOfReturn = FunctionReturn + +export type DecimalsParams = FunctionArguments +export type DecimalsReturn = FunctionReturn + +export type DecreaseAllowanceParams = FunctionArguments +export type DecreaseAllowanceReturn = FunctionReturn + +export type DisableRecoveryModeParams = FunctionArguments +export type DisableRecoveryModeReturn = FunctionReturn + +export type EnableRecoveryModeParams = FunctionArguments +export type EnableRecoveryModeReturn = FunctionReturn + +export type GetActionIdParams = FunctionArguments +export type GetActionIdReturn = FunctionReturn + +export type GetActualSupplyParams = FunctionArguments +export type GetActualSupplyReturn = FunctionReturn + +export type GetAmplificationParameterParams = FunctionArguments +export type GetAmplificationParameterReturn = FunctionReturn + +export type GetAuthorizerParams = FunctionArguments +export type GetAuthorizerReturn = FunctionReturn + +export type GetBptIndexParams = FunctionArguments +export type GetBptIndexReturn = FunctionReturn + +export type GetDomainSeparatorParams = FunctionArguments +export type GetDomainSeparatorReturn = FunctionReturn + +export type GetLastJoinExitDataParams = FunctionArguments +export type GetLastJoinExitDataReturn = FunctionReturn + +export type GetMinimumBptParams = FunctionArguments +export type GetMinimumBptReturn = FunctionReturn + +export type GetNextNonceParams = FunctionArguments +export type GetNextNonceReturn = FunctionReturn + +export type GetOwnerParams = FunctionArguments +export type GetOwnerReturn = FunctionReturn + +export type GetPausedStateParams = FunctionArguments +export type GetPausedStateReturn = FunctionReturn + +export type GetPoolIdParams = FunctionArguments +export type GetPoolIdReturn = FunctionReturn + +export type GetProtocolFeePercentageCacheParams = FunctionArguments +export type GetProtocolFeePercentageCacheReturn = FunctionReturn + +export type GetProtocolFeesCollectorParams = FunctionArguments +export type GetProtocolFeesCollectorReturn = FunctionReturn + +export type GetProtocolSwapFeeDelegationParams = FunctionArguments +export type GetProtocolSwapFeeDelegationReturn = FunctionReturn + +export type GetRateParams = FunctionArguments +export type GetRateReturn = FunctionReturn + +export type GetRateProvidersParams = FunctionArguments +export type GetRateProvidersReturn = FunctionReturn + +export type GetScalingFactorsParams = FunctionArguments +export type GetScalingFactorsReturn = FunctionReturn + +export type GetSwapFeePercentageParams = FunctionArguments +export type GetSwapFeePercentageReturn = FunctionReturn + +export type GetTokenRateParams = FunctionArguments +export type GetTokenRateReturn = FunctionReturn + +export type GetTokenRateCacheParams = FunctionArguments +export type GetTokenRateCacheReturn = FunctionReturn + +export type GetVaultParams = FunctionArguments +export type GetVaultReturn = FunctionReturn + +export type InRecoveryModeParams = FunctionArguments +export type InRecoveryModeReturn = FunctionReturn + +export type IncreaseAllowanceParams = FunctionArguments +export type IncreaseAllowanceReturn = FunctionReturn + +export type IsExemptFromYieldProtocolFeeParams = FunctionArguments +export type IsExemptFromYieldProtocolFeeReturn = FunctionReturn + +export type IsTokenExemptFromYieldProtocolFeeParams = FunctionArguments +export type IsTokenExemptFromYieldProtocolFeeReturn = FunctionReturn + +export type NameParams = FunctionArguments +export type NameReturn = FunctionReturn + +export type NoncesParams = FunctionArguments +export type NoncesReturn = FunctionReturn + +export type OnExitPoolParams = FunctionArguments +export type OnExitPoolReturn = FunctionReturn + +export type OnJoinPoolParams = FunctionArguments +export type OnJoinPoolReturn = FunctionReturn + +export type OnSwapParams = FunctionArguments +export type OnSwapReturn = FunctionReturn + +export type PauseParams = FunctionArguments +export type PauseReturn = FunctionReturn + +export type PermitParams = FunctionArguments +export type PermitReturn = FunctionReturn + +export type QueryExitParams = FunctionArguments +export type QueryExitReturn = FunctionReturn + +export type QueryJoinParams = FunctionArguments +export type QueryJoinReturn = FunctionReturn + +export type SetAssetManagerPoolConfigParams = FunctionArguments +export type SetAssetManagerPoolConfigReturn = FunctionReturn + +export type SetSwapFeePercentageParams = FunctionArguments +export type SetSwapFeePercentageReturn = FunctionReturn + +export type SetTokenRateCacheDurationParams = FunctionArguments +export type SetTokenRateCacheDurationReturn = FunctionReturn + +export type StartAmplificationParameterUpdateParams = FunctionArguments +export type StartAmplificationParameterUpdateReturn = FunctionReturn + +export type StopAmplificationParameterUpdateParams = FunctionArguments +export type StopAmplificationParameterUpdateReturn = FunctionReturn + +export type SymbolParams = FunctionArguments +export type SymbolReturn = FunctionReturn + +export type TotalSupplyParams = FunctionArguments +export type TotalSupplyReturn = FunctionReturn + +export type TransferParams = FunctionArguments +export type TransferReturn = FunctionReturn + +export type TransferFromParams = FunctionArguments +export type TransferFromReturn = FunctionReturn + +export type UnpauseParams = FunctionArguments +export type UnpauseReturn = FunctionReturn + +export type UpdateProtocolFeePercentageCacheParams = FunctionArguments +export type UpdateProtocolFeePercentageCacheReturn = FunctionReturn + +export type UpdateTokenRateCacheParams = FunctionArguments +export type UpdateTokenRateCacheReturn = FunctionReturn + +export type VersionParams = FunctionArguments +export type VersionReturn = FunctionReturn + diff --git a/src/abi/balancer-meta-pool-strategy.ts b/src/abi/balancer-meta-pool-strategy.ts index 05449970..e665769f 100644 --- a/src/abi/balancer-meta-pool-strategy.ts +++ b/src/abi/balancer-meta-pool-strategy.ts @@ -1,248 +1,278 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './balancer-meta-pool-strategy.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - Deposit: new LogEvent<([_asset: string, _pToken: string, _amount: bigint] & {_asset: string, _pToken: string, _amount: bigint})>( - abi, '0x5548c837ab068cf56a2c2479df0882a4922fd203edb7517321831d95078c5f62' - ), - GovernorshipTransferred: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( - abi, '0xc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a' - ), - HarvesterAddressesUpdated: new LogEvent<([_oldHarvesterAddress: string, _newHarvesterAddress: string] & {_oldHarvesterAddress: string, _newHarvesterAddress: string})>( - abi, '0xe48386b84419f4d36e0f96c10cc3510b6fb1a33795620c5098b22472bbe90796' - ), - MaxDepositDeviationUpdated: new LogEvent<([_prevMaxDeviationPercentage: bigint, _newMaxDeviationPercentage: bigint] & {_prevMaxDeviationPercentage: bigint, _newMaxDeviationPercentage: bigint})>( - abi, '0x42ef8699937e03e56ce59a64b430e1a18719693244c594c7884f9cb7c1c98e5c' - ), - MaxWithdrawalDeviationUpdated: new LogEvent<([_prevMaxDeviationPercentage: bigint, _newMaxDeviationPercentage: bigint] & {_prevMaxDeviationPercentage: bigint, _newMaxDeviationPercentage: bigint})>( - abi, '0xdea5bd7251b6797372e2785ac437c2b046149b71216727e0d33ab3140b11d6f7' - ), - PTokenAdded: new LogEvent<([_asset: string, _pToken: string] & {_asset: string, _pToken: string})>( - abi, '0xef6485b84315f9b1483beffa32aae9a0596890395e3d7521f1c5fbb51790e765' - ), - PTokenRemoved: new LogEvent<([_asset: string, _pToken: string] & {_asset: string, _pToken: string})>( - abi, '0x16b7600acff27e39a8a96056b3d533045298de927507f5c1d97e4accde60488c' - ), - PendingGovernorshipTransfer: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( - abi, '0xa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d' - ), - RewardTokenAddressesUpdated: new LogEvent<([_oldAddresses: Array, _newAddresses: Array] & {_oldAddresses: Array, _newAddresses: Array})>( - abi, '0x04c0b9649497d316554306e53678d5f5f5dbc3a06f97dec13ff4cfe98b986bbc' - ), - RewardTokenCollected: new LogEvent<([recipient: string, rewardToken: string, amount: bigint] & {recipient: string, rewardToken: string, amount: bigint})>( - abi, '0xf6c07a063ed4e63808eb8da7112d46dbcd38de2b40a73dbcc9353c5a94c72353' - ), - Withdrawal: new LogEvent<([_asset: string, _pToken: string, _amount: bigint] & {_asset: string, _pToken: string, _amount: bigint})>( - abi, '0x2717ead6b9200dd235aad468c9809ea400fe33ac69b5bfaa6d3e90fc922b6398' - ), + Deposit: event("0x5548c837ab068cf56a2c2479df0882a4922fd203edb7517321831d95078c5f62", {"_asset": indexed(p.address), "_pToken": p.address, "_amount": p.uint256}), + GovernorshipTransferred: event("0xc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a", {"previousGovernor": indexed(p.address), "newGovernor": indexed(p.address)}), + HarvesterAddressesUpdated: event("0xe48386b84419f4d36e0f96c10cc3510b6fb1a33795620c5098b22472bbe90796", {"_oldHarvesterAddress": p.address, "_newHarvesterAddress": p.address}), + MaxDepositDeviationUpdated: event("0x42ef8699937e03e56ce59a64b430e1a18719693244c594c7884f9cb7c1c98e5c", {"_prevMaxDeviationPercentage": p.uint256, "_newMaxDeviationPercentage": p.uint256}), + MaxWithdrawalDeviationUpdated: event("0xdea5bd7251b6797372e2785ac437c2b046149b71216727e0d33ab3140b11d6f7", {"_prevMaxDeviationPercentage": p.uint256, "_newMaxDeviationPercentage": p.uint256}), + PTokenAdded: event("0xef6485b84315f9b1483beffa32aae9a0596890395e3d7521f1c5fbb51790e765", {"_asset": indexed(p.address), "_pToken": p.address}), + PTokenRemoved: event("0x16b7600acff27e39a8a96056b3d533045298de927507f5c1d97e4accde60488c", {"_asset": indexed(p.address), "_pToken": p.address}), + PendingGovernorshipTransfer: event("0xa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d", {"previousGovernor": indexed(p.address), "newGovernor": indexed(p.address)}), + RewardTokenAddressesUpdated: event("0x04c0b9649497d316554306e53678d5f5f5dbc3a06f97dec13ff4cfe98b986bbc", {"_oldAddresses": p.array(p.address), "_newAddresses": p.array(p.address)}), + RewardTokenCollected: event("0xf6c07a063ed4e63808eb8da7112d46dbcd38de2b40a73dbcc9353c5a94c72353", {"recipient": p.address, "rewardToken": p.address, "amount": p.uint256}), + Withdrawal: event("0x2717ead6b9200dd235aad468c9809ea400fe33ac69b5bfaa6d3e90fc922b6398", {"_asset": indexed(p.address), "_pToken": p.address, "_amount": p.uint256}), } export const functions = { - assetToPToken: new Func<[_: string], {}, string>( - abi, '0x0fc3b4c4' - ), - auraRewardPoolAddress: new Func<[], {}, string>( - abi, '0x3132a21d' - ), - balancerPoolId: new Func<[], {}, string>( - abi, '0xdbbb64b9' - ), - balancerVault: new Func<[], {}, string>( - abi, '0x158274a5' - ), - 'checkBalance(address)': new Func<[_asset: string], {_asset: string}, bigint>( - abi, '0x5f515226' - ), - 'checkBalance()': new Func<[], {}, bigint>( - abi, '0xc71daccb' - ), - claimGovernance: new Func<[], {}, []>( - abi, '0x5d36b190' - ), - collectRewardTokens: new Func<[], {}, []>( - abi, '0x5a063f63' - ), - 'deposit(address,uint256)': new Func<[_: string, _: bigint], {}, []>( - abi, '0x47e7ef24' - ), - 'deposit(address[],uint256[])': new Func<[_: Array, _: Array], {}, []>( - abi, '0xefc908a1' - ), - depositAll: new Func<[], {}, []>( - abi, '0xde5f6268' - ), - frxETH: new Func<[], {}, string>( - abi, '0x565d3e6e' - ), - getRewardTokenAddresses: new Func<[], {}, Array>( - abi, '0xf6ca71b0' - ), - governor: new Func<[], {}, string>( - abi, '0x0c340a24' - ), - harvesterAddress: new Func<[], {}, string>( - abi, '0x67c7066c' - ), - initialize: new Func<[_rewardTokenAddresses: Array, _assets: Array, _pTokens: Array], {_rewardTokenAddresses: Array, _assets: Array, _pTokens: Array}, []>( - abi, '0x435356d1' - ), - isGovernor: new Func<[], {}, boolean>( - abi, '0xc7af3352' - ), - maxDepositDeviation: new Func<[], {}, bigint>( - abi, '0x3f6f7a14' - ), - maxWithdrawalDeviation: new Func<[], {}, bigint>( - abi, '0x14f0747e' - ), - platformAddress: new Func<[], {}, string>( - abi, '0xdbe55e56' - ), - rETH: new Func<[], {}, string>( - abi, '0xca8aa0e4' - ), - removePToken: new Func<[_assetIndex: bigint], {_assetIndex: bigint}, []>( - abi, '0x9136616a' - ), - rewardTokenAddresses: new Func<[_: bigint], {}, string>( - abi, '0x7b2d9b2c' - ), - safeApproveAllTokens: new Func<[], {}, []>( - abi, '0xad1728cb' - ), - setHarvesterAddress: new Func<[_harvesterAddress: string], {_harvesterAddress: string}, []>( - abi, '0xc2e1e3f4' - ), - setMaxDepositDeviation: new Func<[_maxDepositDeviation: bigint], {_maxDepositDeviation: bigint}, []>( - abi, '0x683c1ef9' - ), - setMaxWithdrawalDeviation: new Func<[_maxWithdrawalDeviation: bigint], {_maxWithdrawalDeviation: bigint}, []>( - abi, '0x79e66fcc' - ), - setPTokenAddress: new Func<[_asset: string, _pToken: string], {_asset: string, _pToken: string}, []>( - abi, '0x0ed57b3a' - ), - setRewardTokenAddresses: new Func<[_rewardTokenAddresses: Array], {_rewardTokenAddresses: Array}, []>( - abi, '0x96d538bb' - ), - sfrxETH: new Func<[], {}, string>( - abi, '0xc9ac8c8e' - ), - stETH: new Func<[], {}, string>( - abi, '0xc1fe3e48' - ), - supportsAsset: new Func<[_asset: string], {_asset: string}, boolean>( - abi, '0xaa388af6' - ), - transferGovernance: new Func<[_newGovernor: string], {_newGovernor: string}, []>( - abi, '0xd38bfff4' - ), - transferToken: new Func<[_asset: string, _amount: bigint], {_asset: string, _amount: bigint}, []>( - abi, '0x1072cbea' - ), - vaultAddress: new Func<[], {}, string>( - abi, '0x430bf08a' - ), - 'withdraw(address,address,uint256)': new Func<[_recipient: string, _strategyAsset: string, _strategyAmount: bigint], {_recipient: string, _strategyAsset: string, _strategyAmount: bigint}, []>( - abi, '0xd9caed12' - ), - 'withdraw(address,address[],uint256[])': new Func<[_recipient: string, _strategyAssets: Array, _strategyAmounts: Array], {_recipient: string, _strategyAssets: Array, _strategyAmounts: Array}, []>( - abi, '0xedbd7668' - ), - withdrawAll: new Func<[], {}, []>( - abi, '0x853828b6' - ), - wstETH: new Func<[], {}, string>( - abi, '0x4aa07e64' - ), + assetToPToken: fun("0x0fc3b4c4", {"_0": p.address}, p.address), + auraRewardPoolAddress: fun("0x3132a21d", {}, p.address), + balancerPoolId: fun("0xdbbb64b9", {}, p.bytes32), + balancerVault: fun("0x158274a5", {}, p.address), + "checkBalance(address)": fun("0x5f515226", {"_asset": p.address}, p.uint256), + "checkBalance()": fun("0xc71daccb", {}, p.uint256), + claimGovernance: fun("0x5d36b190", {}, ), + collectRewardTokens: fun("0x5a063f63", {}, ), + "deposit(address,uint256)": fun("0x47e7ef24", {"_0": p.address, "_1": p.uint256}, ), + "deposit(address[],uint256[])": fun("0xefc908a1", {"_0": p.array(p.address), "_1": p.array(p.uint256)}, ), + depositAll: fun("0xde5f6268", {}, ), + frxETH: fun("0x565d3e6e", {}, p.address), + getRewardTokenAddresses: fun("0xf6ca71b0", {}, p.array(p.address)), + governor: fun("0x0c340a24", {}, p.address), + harvesterAddress: fun("0x67c7066c", {}, p.address), + initialize: fun("0x435356d1", {"_rewardTokenAddresses": p.array(p.address), "_assets": p.array(p.address), "_pTokens": p.array(p.address)}, ), + isGovernor: fun("0xc7af3352", {}, p.bool), + maxDepositDeviation: fun("0x3f6f7a14", {}, p.uint256), + maxWithdrawalDeviation: fun("0x14f0747e", {}, p.uint256), + platformAddress: fun("0xdbe55e56", {}, p.address), + rETH: fun("0xca8aa0e4", {}, p.address), + removePToken: fun("0x9136616a", {"_assetIndex": p.uint256}, ), + rewardTokenAddresses: fun("0x7b2d9b2c", {"_0": p.uint256}, p.address), + safeApproveAllTokens: fun("0xad1728cb", {}, ), + setHarvesterAddress: fun("0xc2e1e3f4", {"_harvesterAddress": p.address}, ), + setMaxDepositDeviation: fun("0x683c1ef9", {"_maxDepositDeviation": p.uint256}, ), + setMaxWithdrawalDeviation: fun("0x79e66fcc", {"_maxWithdrawalDeviation": p.uint256}, ), + setPTokenAddress: fun("0x0ed57b3a", {"_asset": p.address, "_pToken": p.address}, ), + setRewardTokenAddresses: fun("0x96d538bb", {"_rewardTokenAddresses": p.array(p.address)}, ), + sfrxETH: fun("0xc9ac8c8e", {}, p.address), + stETH: fun("0xc1fe3e48", {}, p.address), + supportsAsset: fun("0xaa388af6", {"_asset": p.address}, p.bool), + transferGovernance: fun("0xd38bfff4", {"_newGovernor": p.address}, ), + transferToken: fun("0x1072cbea", {"_asset": p.address, "_amount": p.uint256}, ), + vaultAddress: fun("0x430bf08a", {}, p.address), + "withdraw(address,address,uint256)": fun("0xd9caed12", {"_recipient": p.address, "_strategyAsset": p.address, "_strategyAmount": p.uint256}, ), + "withdraw(address,address[],uint256[])": fun("0xedbd7668", {"_recipient": p.address, "_strategyAssets": p.array(p.address), "_strategyAmounts": p.array(p.uint256)}, ), + withdrawAll: fun("0x853828b6", {}, ), + wstETH: fun("0x4aa07e64", {}, p.address), } export class Contract extends ContractBase { - assetToPToken(arg0: string): Promise { - return this.eth_call(functions.assetToPToken, [arg0]) + assetToPToken(_0: AssetToPTokenParams["_0"]) { + return this.eth_call(functions.assetToPToken, {_0}) } - auraRewardPoolAddress(): Promise { - return this.eth_call(functions.auraRewardPoolAddress, []) + auraRewardPoolAddress() { + return this.eth_call(functions.auraRewardPoolAddress, {}) } - balancerPoolId(): Promise { - return this.eth_call(functions.balancerPoolId, []) + balancerPoolId() { + return this.eth_call(functions.balancerPoolId, {}) } - balancerVault(): Promise { - return this.eth_call(functions.balancerVault, []) + balancerVault() { + return this.eth_call(functions.balancerVault, {}) } - 'checkBalance(address)'(_asset: string): Promise { - return this.eth_call(functions['checkBalance(address)'], [_asset]) + "checkBalance(address)"(_asset: CheckBalanceParams_0["_asset"]) { + return this.eth_call(functions["checkBalance(address)"], {_asset}) } - 'checkBalance()'(): Promise { - return this.eth_call(functions['checkBalance()'], []) + "checkBalance()"() { + return this.eth_call(functions["checkBalance()"], {}) } - frxETH(): Promise { - return this.eth_call(functions.frxETH, []) + frxETH() { + return this.eth_call(functions.frxETH, {}) } - getRewardTokenAddresses(): Promise> { - return this.eth_call(functions.getRewardTokenAddresses, []) + getRewardTokenAddresses() { + return this.eth_call(functions.getRewardTokenAddresses, {}) } - governor(): Promise { - return this.eth_call(functions.governor, []) + governor() { + return this.eth_call(functions.governor, {}) } - harvesterAddress(): Promise { - return this.eth_call(functions.harvesterAddress, []) + harvesterAddress() { + return this.eth_call(functions.harvesterAddress, {}) } - isGovernor(): Promise { - return this.eth_call(functions.isGovernor, []) + isGovernor() { + return this.eth_call(functions.isGovernor, {}) } - maxDepositDeviation(): Promise { - return this.eth_call(functions.maxDepositDeviation, []) + maxDepositDeviation() { + return this.eth_call(functions.maxDepositDeviation, {}) } - maxWithdrawalDeviation(): Promise { - return this.eth_call(functions.maxWithdrawalDeviation, []) + maxWithdrawalDeviation() { + return this.eth_call(functions.maxWithdrawalDeviation, {}) } - platformAddress(): Promise { - return this.eth_call(functions.platformAddress, []) + platformAddress() { + return this.eth_call(functions.platformAddress, {}) } - rETH(): Promise { - return this.eth_call(functions.rETH, []) + rETH() { + return this.eth_call(functions.rETH, {}) } - rewardTokenAddresses(arg0: bigint): Promise { - return this.eth_call(functions.rewardTokenAddresses, [arg0]) + rewardTokenAddresses(_0: RewardTokenAddressesParams["_0"]) { + return this.eth_call(functions.rewardTokenAddresses, {_0}) } - sfrxETH(): Promise { - return this.eth_call(functions.sfrxETH, []) + sfrxETH() { + return this.eth_call(functions.sfrxETH, {}) } - stETH(): Promise { - return this.eth_call(functions.stETH, []) + stETH() { + return this.eth_call(functions.stETH, {}) } - supportsAsset(_asset: string): Promise { - return this.eth_call(functions.supportsAsset, [_asset]) + supportsAsset(_asset: SupportsAssetParams["_asset"]) { + return this.eth_call(functions.supportsAsset, {_asset}) } - vaultAddress(): Promise { - return this.eth_call(functions.vaultAddress, []) + vaultAddress() { + return this.eth_call(functions.vaultAddress, {}) } - wstETH(): Promise { - return this.eth_call(functions.wstETH, []) + wstETH() { + return this.eth_call(functions.wstETH, {}) } } + +/// Event types +export type DepositEventArgs = EParams +export type GovernorshipTransferredEventArgs = EParams +export type HarvesterAddressesUpdatedEventArgs = EParams +export type MaxDepositDeviationUpdatedEventArgs = EParams +export type MaxWithdrawalDeviationUpdatedEventArgs = EParams +export type PTokenAddedEventArgs = EParams +export type PTokenRemovedEventArgs = EParams +export type PendingGovernorshipTransferEventArgs = EParams +export type RewardTokenAddressesUpdatedEventArgs = EParams +export type RewardTokenCollectedEventArgs = EParams +export type WithdrawalEventArgs = EParams + +/// Function types +export type AssetToPTokenParams = FunctionArguments +export type AssetToPTokenReturn = FunctionReturn + +export type AuraRewardPoolAddressParams = FunctionArguments +export type AuraRewardPoolAddressReturn = FunctionReturn + +export type BalancerPoolIdParams = FunctionArguments +export type BalancerPoolIdReturn = FunctionReturn + +export type BalancerVaultParams = FunctionArguments +export type BalancerVaultReturn = FunctionReturn + +export type CheckBalanceParams_0 = FunctionArguments +export type CheckBalanceReturn_0 = FunctionReturn + +export type CheckBalanceParams_1 = FunctionArguments +export type CheckBalanceReturn_1 = FunctionReturn + +export type ClaimGovernanceParams = FunctionArguments +export type ClaimGovernanceReturn = FunctionReturn + +export type CollectRewardTokensParams = FunctionArguments +export type CollectRewardTokensReturn = FunctionReturn + +export type DepositParams_0 = FunctionArguments +export type DepositReturn_0 = FunctionReturn + +export type DepositParams_1 = FunctionArguments +export type DepositReturn_1 = FunctionReturn + +export type DepositAllParams = FunctionArguments +export type DepositAllReturn = FunctionReturn + +export type FrxETHParams = FunctionArguments +export type FrxETHReturn = FunctionReturn + +export type GetRewardTokenAddressesParams = FunctionArguments +export type GetRewardTokenAddressesReturn = FunctionReturn + +export type GovernorParams = FunctionArguments +export type GovernorReturn = FunctionReturn + +export type HarvesterAddressParams = FunctionArguments +export type HarvesterAddressReturn = FunctionReturn + +export type InitializeParams = FunctionArguments +export type InitializeReturn = FunctionReturn + +export type IsGovernorParams = FunctionArguments +export type IsGovernorReturn = FunctionReturn + +export type MaxDepositDeviationParams = FunctionArguments +export type MaxDepositDeviationReturn = FunctionReturn + +export type MaxWithdrawalDeviationParams = FunctionArguments +export type MaxWithdrawalDeviationReturn = FunctionReturn + +export type PlatformAddressParams = FunctionArguments +export type PlatformAddressReturn = FunctionReturn + +export type RETHParams = FunctionArguments +export type RETHReturn = FunctionReturn + +export type RemovePTokenParams = FunctionArguments +export type RemovePTokenReturn = FunctionReturn + +export type RewardTokenAddressesParams = FunctionArguments +export type RewardTokenAddressesReturn = FunctionReturn + +export type SafeApproveAllTokensParams = FunctionArguments +export type SafeApproveAllTokensReturn = FunctionReturn + +export type SetHarvesterAddressParams = FunctionArguments +export type SetHarvesterAddressReturn = FunctionReturn + +export type SetMaxDepositDeviationParams = FunctionArguments +export type SetMaxDepositDeviationReturn = FunctionReturn + +export type SetMaxWithdrawalDeviationParams = FunctionArguments +export type SetMaxWithdrawalDeviationReturn = FunctionReturn + +export type SetPTokenAddressParams = FunctionArguments +export type SetPTokenAddressReturn = FunctionReturn + +export type SetRewardTokenAddressesParams = FunctionArguments +export type SetRewardTokenAddressesReturn = FunctionReturn + +export type SfrxETHParams = FunctionArguments +export type SfrxETHReturn = FunctionReturn + +export type StETHParams = FunctionArguments +export type StETHReturn = FunctionReturn + +export type SupportsAssetParams = FunctionArguments +export type SupportsAssetReturn = FunctionReturn + +export type TransferGovernanceParams = FunctionArguments +export type TransferGovernanceReturn = FunctionReturn + +export type TransferTokenParams = FunctionArguments +export type TransferTokenReturn = FunctionReturn + +export type VaultAddressParams = FunctionArguments +export type VaultAddressReturn = FunctionReturn + +export type WithdrawParams_0 = FunctionArguments +export type WithdrawReturn_0 = FunctionReturn + +export type WithdrawParams_1 = FunctionArguments +export type WithdrawReturn_1 = FunctionReturn + +export type WithdrawAllParams = FunctionArguments +export type WithdrawAllReturn = FunctionReturn + +export type WstETHParams = FunctionArguments +export type WstETHReturn = FunctionReturn + diff --git a/src/abi/balancer-meta-stable-pool.ts b/src/abi/balancer-meta-stable-pool.ts index c0790eed..20e7b245 100644 --- a/src/abi/balancer-meta-stable-pool.ts +++ b/src/abi/balancer-meta-stable-pool.ts @@ -1,297 +1,338 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './balancer-meta-stable-pool.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - AmpUpdateStarted: new LogEvent<([startValue: bigint, endValue: bigint, startTime: bigint, endTime: bigint] & {startValue: bigint, endValue: bigint, startTime: bigint, endTime: bigint})>( - abi, '0x1835882ee7a34ac194f717a35e09bb1d24c82a3b9d854ab6c9749525b714cdf2' - ), - AmpUpdateStopped: new LogEvent<([currentValue: bigint] & {currentValue: bigint})>( - abi, '0xa0d01593e47e69d07e0ccd87bece09411e07dd1ed40ca8f2e7af2976542a0233' - ), - Approval: new LogEvent<([owner: string, spender: string, value: bigint] & {owner: string, spender: string, value: bigint})>( - abi, '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925' - ), - OracleEnabledChanged: new LogEvent<([enabled: boolean] & {enabled: boolean})>( - abi, '0x3e350b41e86a8e10f804ade6d35340d620be35569cc75ac943e8bb14ab80ead1' - ), - PausedStateChanged: new LogEvent<([paused: boolean] & {paused: boolean})>( - abi, '0x9e3a5e37224532dea67b89face185703738a228a6e8a23dee546960180d3be64' - ), - PriceRateCacheUpdated: new LogEvent<([token: string, rate: bigint] & {token: string, rate: bigint})>( - abi, '0xc1a224b14823b63c7711127f125fbf592434682f38881ebb61408747a303affc' - ), - PriceRateProviderSet: new LogEvent<([token: string, provider: string, cacheDuration: bigint] & {token: string, provider: string, cacheDuration: bigint})>( - abi, '0xca6c2c5b6b44b5f3f0c08f0e28e5b6deda1cb38c3fe1113e8031d926c1e8c6d0' - ), - SwapFeePercentageChanged: new LogEvent<([swapFeePercentage: bigint] & {swapFeePercentage: bigint})>( - abi, '0xa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc' - ), - Transfer: new LogEvent<([from: string, to: string, value: bigint] & {from: string, to: string, value: bigint})>( - abi, '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' - ), + AmpUpdateStarted: event("0x1835882ee7a34ac194f717a35e09bb1d24c82a3b9d854ab6c9749525b714cdf2", {"startValue": p.uint256, "endValue": p.uint256, "startTime": p.uint256, "endTime": p.uint256}), + AmpUpdateStopped: event("0xa0d01593e47e69d07e0ccd87bece09411e07dd1ed40ca8f2e7af2976542a0233", {"currentValue": p.uint256}), + Approval: event("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", {"owner": indexed(p.address), "spender": indexed(p.address), "value": p.uint256}), + OracleEnabledChanged: event("0x3e350b41e86a8e10f804ade6d35340d620be35569cc75ac943e8bb14ab80ead1", {"enabled": p.bool}), + PausedStateChanged: event("0x9e3a5e37224532dea67b89face185703738a228a6e8a23dee546960180d3be64", {"paused": p.bool}), + PriceRateCacheUpdated: event("0xc1a224b14823b63c7711127f125fbf592434682f38881ebb61408747a303affc", {"token": indexed(p.address), "rate": p.uint256}), + PriceRateProviderSet: event("0xca6c2c5b6b44b5f3f0c08f0e28e5b6deda1cb38c3fe1113e8031d926c1e8c6d0", {"token": indexed(p.address), "provider": indexed(p.address), "cacheDuration": p.uint256}), + SwapFeePercentageChanged: event("0xa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc", {"swapFeePercentage": p.uint256}), + Transfer: event("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", {"from": indexed(p.address), "to": indexed(p.address), "value": p.uint256}), } export const functions = { - DOMAIN_SEPARATOR: new Func<[], {}, string>( - abi, '0x3644e515' - ), - allowance: new Func<[owner: string, spender: string], {owner: string, spender: string}, bigint>( - abi, '0xdd62ed3e' - ), - approve: new Func<[spender: string, amount: bigint], {spender: string, amount: bigint}, boolean>( - abi, '0x095ea7b3' - ), - balanceOf: new Func<[account: string], {account: string}, bigint>( - abi, '0x70a08231' - ), - decimals: new Func<[], {}, number>( - abi, '0x313ce567' - ), - decreaseAllowance: new Func<[spender: string, amount: bigint], {spender: string, amount: bigint}, boolean>( - abi, '0xa457c2d7' - ), - enableOracle: new Func<[], {}, []>( - abi, '0x292c914a' - ), - getActionId: new Func<[selector: string], {selector: string}, string>( - abi, '0x851c1bb3' - ), - getAmplificationParameter: new Func<[], {}, ([value: bigint, isUpdating: boolean, precision: bigint] & {value: bigint, isUpdating: boolean, precision: bigint})>( - abi, '0x6daccffa' - ), - getAuthorizer: new Func<[], {}, string>( - abi, '0xaaabadc5' - ), - getLargestSafeQueryWindow: new Func<[], {}, bigint>( - abi, '0xffd088eb' - ), - getLastInvariant: new Func<[], {}, ([lastInvariant: bigint, lastInvariantAmp: bigint] & {lastInvariant: bigint, lastInvariantAmp: bigint})>( - abi, '0x9b02cdde' - ), - getLatest: new Func<[variable: number], {variable: number}, bigint>( - abi, '0xb10be739' - ), - getOracleMiscData: new Func<[], {}, ([logInvariant: bigint, logTotalSupply: bigint, oracleSampleCreationTimestamp: bigint, oracleIndex: bigint, oracleEnabled: boolean] & {logInvariant: bigint, logTotalSupply: bigint, oracleSampleCreationTimestamp: bigint, oracleIndex: bigint, oracleEnabled: boolean})>( - abi, '0x1ed4eddc' - ), - getOwner: new Func<[], {}, string>( - abi, '0x893d20e8' - ), - getPastAccumulators: new Func<[queries: Array<([variable: number, ago: bigint] & {variable: number, ago: bigint})>], {queries: Array<([variable: number, ago: bigint] & {variable: number, ago: bigint})>}, Array>( - abi, '0x6b843239' - ), - getPausedState: new Func<[], {}, ([paused: boolean, pauseWindowEndTime: bigint, bufferPeriodEndTime: bigint] & {paused: boolean, pauseWindowEndTime: bigint, bufferPeriodEndTime: bigint})>( - abi, '0x1c0de051' - ), - getPoolId: new Func<[], {}, string>( - abi, '0x38fff2d0' - ), - getPriceRateCache: new Func<[token: string], {token: string}, ([rate: bigint, duration: bigint, expires: bigint] & {rate: bigint, duration: bigint, expires: bigint})>( - abi, '0xb867ee5a' - ), - getRate: new Func<[], {}, bigint>( - abi, '0x679aefce' - ), - getRateProviders: new Func<[], {}, Array>( - abi, '0x238a2d59' - ), - getSample: new Func<[index: bigint], {index: bigint}, ([logPairPrice: bigint, accLogPairPrice: bigint, logBptPrice: bigint, accLogBptPrice: bigint, logInvariant: bigint, accLogInvariant: bigint, timestamp: bigint] & {logPairPrice: bigint, accLogPairPrice: bigint, logBptPrice: bigint, accLogBptPrice: bigint, logInvariant: bigint, accLogInvariant: bigint, timestamp: bigint})>( - abi, '0x60d1507c' - ), - getScalingFactors: new Func<[], {}, Array>( - abi, '0x1dd746ea' - ), - getSwapFeePercentage: new Func<[], {}, bigint>( - abi, '0x55c67628' - ), - getTimeWeightedAverage: new Func<[queries: Array<([variable: number, secs: bigint, ago: bigint] & {variable: number, secs: bigint, ago: bigint})>], {queries: Array<([variable: number, secs: bigint, ago: bigint] & {variable: number, secs: bigint, ago: bigint})>}, Array>( - abi, '0x1dccd830' - ), - getTotalSamples: new Func<[], {}, bigint>( - abi, '0xb48b5b40' - ), - getVault: new Func<[], {}, string>( - abi, '0x8d928af8' - ), - increaseAllowance: new Func<[spender: string, addedValue: bigint], {spender: string, addedValue: bigint}, boolean>( - abi, '0x39509351' - ), - name: new Func<[], {}, string>( - abi, '0x06fdde03' - ), - nonces: new Func<[owner: string], {owner: string}, bigint>( - abi, '0x7ecebe00' - ), - onExitPool: new Func<[poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string], {poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string}, ([amountsOut: Array, dueProtocolFeeAmounts: Array] & {amountsOut: Array, dueProtocolFeeAmounts: Array})>( - abi, '0x74f3b009' - ), - onJoinPool: new Func<[poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string], {poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string}, ([amountsIn: Array, dueProtocolFeeAmounts: Array] & {amountsIn: Array, dueProtocolFeeAmounts: Array})>( - abi, '0xd5c096c4' - ), - 'onSwap((uint8,address,address,uint256,bytes32,uint256,address,address,bytes),uint256[],uint256,uint256)': new Func<[request: ([kind: number, tokenIn: string, tokenOut: string, amount: bigint, poolId: string, lastChangeBlock: bigint, from: string, to: string, userData: string] & {kind: number, tokenIn: string, tokenOut: string, amount: bigint, poolId: string, lastChangeBlock: bigint, from: string, to: string, userData: string}), balances: Array, indexIn: bigint, indexOut: bigint], {request: ([kind: number, tokenIn: string, tokenOut: string, amount: bigint, poolId: string, lastChangeBlock: bigint, from: string, to: string, userData: string] & {kind: number, tokenIn: string, tokenOut: string, amount: bigint, poolId: string, lastChangeBlock: bigint, from: string, to: string, userData: string}), balances: Array, indexIn: bigint, indexOut: bigint}, bigint>( - abi, '0x01ec954a' - ), - 'onSwap((uint8,address,address,uint256,bytes32,uint256,address,address,bytes),uint256,uint256)': new Func<[request: ([kind: number, tokenIn: string, tokenOut: string, amount: bigint, poolId: string, lastChangeBlock: bigint, from: string, to: string, userData: string] & {kind: number, tokenIn: string, tokenOut: string, amount: bigint, poolId: string, lastChangeBlock: bigint, from: string, to: string, userData: string}), balanceTokenIn: bigint, balanceTokenOut: bigint], {request: ([kind: number, tokenIn: string, tokenOut: string, amount: bigint, poolId: string, lastChangeBlock: bigint, from: string, to: string, userData: string] & {kind: number, tokenIn: string, tokenOut: string, amount: bigint, poolId: string, lastChangeBlock: bigint, from: string, to: string, userData: string}), balanceTokenIn: bigint, balanceTokenOut: bigint}, bigint>( - abi, '0x9d2c110c' - ), - permit: new Func<[owner: string, spender: string, value: bigint, deadline: bigint, v: number, r: string, s: string], {owner: string, spender: string, value: bigint, deadline: bigint, v: number, r: string, s: string}, []>( - abi, '0xd505accf' - ), - queryExit: new Func<[poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string], {poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string}, ([bptIn: bigint, amountsOut: Array] & {bptIn: bigint, amountsOut: Array})>( - abi, '0x6028bfd4' - ), - queryJoin: new Func<[poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string], {poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string}, ([bptOut: bigint, amountsIn: Array] & {bptOut: bigint, amountsIn: Array})>( - abi, '0x87ec6817' - ), - setAssetManagerPoolConfig: new Func<[token: string, poolConfig: string], {token: string, poolConfig: string}, []>( - abi, '0x50dd6ed9' - ), - setPaused: new Func<[paused: boolean], {paused: boolean}, []>( - abi, '0x16c38b3c' - ), - setPriceRateCacheDuration: new Func<[token: string, duration: bigint], {token: string, duration: bigint}, []>( - abi, '0xb7710251' - ), - setSwapFeePercentage: new Func<[swapFeePercentage: bigint], {swapFeePercentage: bigint}, []>( - abi, '0x38e9922e' - ), - startAmplificationParameterUpdate: new Func<[rawEndValue: bigint, endTime: bigint], {rawEndValue: bigint, endTime: bigint}, []>( - abi, '0x2f1a0bc9' - ), - stopAmplificationParameterUpdate: new Func<[], {}, []>( - abi, '0xeb0f24d6' - ), - symbol: new Func<[], {}, string>( - abi, '0x95d89b41' - ), - totalSupply: new Func<[], {}, bigint>( - abi, '0x18160ddd' - ), - transfer: new Func<[recipient: string, amount: bigint], {recipient: string, amount: bigint}, boolean>( - abi, '0xa9059cbb' - ), - transferFrom: new Func<[sender: string, recipient: string, amount: bigint], {sender: string, recipient: string, amount: bigint}, boolean>( - abi, '0x23b872dd' - ), - updatePriceRateCache: new Func<[token: string], {token: string}, []>( - abi, '0xa0daaed0' - ), + DOMAIN_SEPARATOR: fun("0x3644e515", {}, p.bytes32), + allowance: fun("0xdd62ed3e", {"owner": p.address, "spender": p.address}, p.uint256), + approve: fun("0x095ea7b3", {"spender": p.address, "amount": p.uint256}, p.bool), + balanceOf: fun("0x70a08231", {"account": p.address}, p.uint256), + decimals: fun("0x313ce567", {}, p.uint8), + decreaseAllowance: fun("0xa457c2d7", {"spender": p.address, "amount": p.uint256}, p.bool), + enableOracle: fun("0x292c914a", {}, ), + getActionId: fun("0x851c1bb3", {"selector": p.bytes4}, p.bytes32), + getAmplificationParameter: fun("0x6daccffa", {}, {"value": p.uint256, "isUpdating": p.bool, "precision": p.uint256}), + getAuthorizer: fun("0xaaabadc5", {}, p.address), + getLargestSafeQueryWindow: fun("0xffd088eb", {}, p.uint256), + getLastInvariant: fun("0x9b02cdde", {}, {"lastInvariant": p.uint256, "lastInvariantAmp": p.uint256}), + getLatest: fun("0xb10be739", {"variable": p.uint8}, p.uint256), + getOracleMiscData: fun("0x1ed4eddc", {}, {"logInvariant": p.int256, "logTotalSupply": p.int256, "oracleSampleCreationTimestamp": p.uint256, "oracleIndex": p.uint256, "oracleEnabled": p.bool}), + getOwner: fun("0x893d20e8", {}, p.address), + getPastAccumulators: fun("0x6b843239", {"queries": p.array(p.struct({"variable": p.uint8, "ago": p.uint256}))}, p.array(p.int256)), + getPausedState: fun("0x1c0de051", {}, {"paused": p.bool, "pauseWindowEndTime": p.uint256, "bufferPeriodEndTime": p.uint256}), + getPoolId: fun("0x38fff2d0", {}, p.bytes32), + getPriceRateCache: fun("0xb867ee5a", {"token": p.address}, {"rate": p.uint256, "duration": p.uint256, "expires": p.uint256}), + getRate: fun("0x679aefce", {}, p.uint256), + getRateProviders: fun("0x238a2d59", {}, p.array(p.address)), + getSample: fun("0x60d1507c", {"index": p.uint256}, {"logPairPrice": p.int256, "accLogPairPrice": p.int256, "logBptPrice": p.int256, "accLogBptPrice": p.int256, "logInvariant": p.int256, "accLogInvariant": p.int256, "timestamp": p.uint256}), + getScalingFactors: fun("0x1dd746ea", {}, p.array(p.uint256)), + getSwapFeePercentage: fun("0x55c67628", {}, p.uint256), + getTimeWeightedAverage: fun("0x1dccd830", {"queries": p.array(p.struct({"variable": p.uint8, "secs": p.uint256, "ago": p.uint256}))}, p.array(p.uint256)), + getTotalSamples: fun("0xb48b5b40", {}, p.uint256), + getVault: fun("0x8d928af8", {}, p.address), + increaseAllowance: fun("0x39509351", {"spender": p.address, "addedValue": p.uint256}, p.bool), + name: fun("0x06fdde03", {}, p.string), + nonces: fun("0x7ecebe00", {"owner": p.address}, p.uint256), + onExitPool: fun("0x74f3b009", {"poolId": p.bytes32, "sender": p.address, "recipient": p.address, "balances": p.array(p.uint256), "lastChangeBlock": p.uint256, "protocolSwapFeePercentage": p.uint256, "userData": p.bytes}, {"amountsOut": p.array(p.uint256), "dueProtocolFeeAmounts": p.array(p.uint256)}), + onJoinPool: fun("0xd5c096c4", {"poolId": p.bytes32, "sender": p.address, "recipient": p.address, "balances": p.array(p.uint256), "lastChangeBlock": p.uint256, "protocolSwapFeePercentage": p.uint256, "userData": p.bytes}, {"amountsIn": p.array(p.uint256), "dueProtocolFeeAmounts": p.array(p.uint256)}), + "onSwap((uint8,address,address,uint256,bytes32,uint256,address,address,bytes),uint256[],uint256,uint256)": fun("0x01ec954a", {"request": p.struct({"kind": p.uint8, "tokenIn": p.address, "tokenOut": p.address, "amount": p.uint256, "poolId": p.bytes32, "lastChangeBlock": p.uint256, "from": p.address, "to": p.address, "userData": p.bytes}), "balances": p.array(p.uint256), "indexIn": p.uint256, "indexOut": p.uint256}, p.uint256), + "onSwap((uint8,address,address,uint256,bytes32,uint256,address,address,bytes),uint256,uint256)": fun("0x9d2c110c", {"request": p.struct({"kind": p.uint8, "tokenIn": p.address, "tokenOut": p.address, "amount": p.uint256, "poolId": p.bytes32, "lastChangeBlock": p.uint256, "from": p.address, "to": p.address, "userData": p.bytes}), "balanceTokenIn": p.uint256, "balanceTokenOut": p.uint256}, p.uint256), + permit: fun("0xd505accf", {"owner": p.address, "spender": p.address, "value": p.uint256, "deadline": p.uint256, "v": p.uint8, "r": p.bytes32, "s": p.bytes32}, ), + queryExit: fun("0x6028bfd4", {"poolId": p.bytes32, "sender": p.address, "recipient": p.address, "balances": p.array(p.uint256), "lastChangeBlock": p.uint256, "protocolSwapFeePercentage": p.uint256, "userData": p.bytes}, {"bptIn": p.uint256, "amountsOut": p.array(p.uint256)}), + queryJoin: fun("0x87ec6817", {"poolId": p.bytes32, "sender": p.address, "recipient": p.address, "balances": p.array(p.uint256), "lastChangeBlock": p.uint256, "protocolSwapFeePercentage": p.uint256, "userData": p.bytes}, {"bptOut": p.uint256, "amountsIn": p.array(p.uint256)}), + setAssetManagerPoolConfig: fun("0x50dd6ed9", {"token": p.address, "poolConfig": p.bytes}, ), + setPaused: fun("0x16c38b3c", {"paused": p.bool}, ), + setPriceRateCacheDuration: fun("0xb7710251", {"token": p.address, "duration": p.uint256}, ), + setSwapFeePercentage: fun("0x38e9922e", {"swapFeePercentage": p.uint256}, ), + startAmplificationParameterUpdate: fun("0x2f1a0bc9", {"rawEndValue": p.uint256, "endTime": p.uint256}, ), + stopAmplificationParameterUpdate: fun("0xeb0f24d6", {}, ), + symbol: fun("0x95d89b41", {}, p.string), + totalSupply: fun("0x18160ddd", {}, p.uint256), + transfer: fun("0xa9059cbb", {"recipient": p.address, "amount": p.uint256}, p.bool), + transferFrom: fun("0x23b872dd", {"sender": p.address, "recipient": p.address, "amount": p.uint256}, p.bool), + updatePriceRateCache: fun("0xa0daaed0", {"token": p.address}, ), } export class Contract extends ContractBase { - DOMAIN_SEPARATOR(): Promise { - return this.eth_call(functions.DOMAIN_SEPARATOR, []) + DOMAIN_SEPARATOR() { + return this.eth_call(functions.DOMAIN_SEPARATOR, {}) } - allowance(owner: string, spender: string): Promise { - return this.eth_call(functions.allowance, [owner, spender]) + allowance(owner: AllowanceParams["owner"], spender: AllowanceParams["spender"]) { + return this.eth_call(functions.allowance, {owner, spender}) } - balanceOf(account: string): Promise { - return this.eth_call(functions.balanceOf, [account]) + balanceOf(account: BalanceOfParams["account"]) { + return this.eth_call(functions.balanceOf, {account}) } - decimals(): Promise { - return this.eth_call(functions.decimals, []) + decimals() { + return this.eth_call(functions.decimals, {}) } - getActionId(selector: string): Promise { - return this.eth_call(functions.getActionId, [selector]) + getActionId(selector: GetActionIdParams["selector"]) { + return this.eth_call(functions.getActionId, {selector}) } - getAmplificationParameter(): Promise<([value: bigint, isUpdating: boolean, precision: bigint] & {value: bigint, isUpdating: boolean, precision: bigint})> { - return this.eth_call(functions.getAmplificationParameter, []) + getAmplificationParameter() { + return this.eth_call(functions.getAmplificationParameter, {}) } - getAuthorizer(): Promise { - return this.eth_call(functions.getAuthorizer, []) + getAuthorizer() { + return this.eth_call(functions.getAuthorizer, {}) } - getLargestSafeQueryWindow(): Promise { - return this.eth_call(functions.getLargestSafeQueryWindow, []) + getLargestSafeQueryWindow() { + return this.eth_call(functions.getLargestSafeQueryWindow, {}) } - getLastInvariant(): Promise<([lastInvariant: bigint, lastInvariantAmp: bigint] & {lastInvariant: bigint, lastInvariantAmp: bigint})> { - return this.eth_call(functions.getLastInvariant, []) + getLastInvariant() { + return this.eth_call(functions.getLastInvariant, {}) } - getLatest(variable: number): Promise { - return this.eth_call(functions.getLatest, [variable]) + getLatest(variable: GetLatestParams["variable"]) { + return this.eth_call(functions.getLatest, {variable}) } - getOracleMiscData(): Promise<([logInvariant: bigint, logTotalSupply: bigint, oracleSampleCreationTimestamp: bigint, oracleIndex: bigint, oracleEnabled: boolean] & {logInvariant: bigint, logTotalSupply: bigint, oracleSampleCreationTimestamp: bigint, oracleIndex: bigint, oracleEnabled: boolean})> { - return this.eth_call(functions.getOracleMiscData, []) + getOracleMiscData() { + return this.eth_call(functions.getOracleMiscData, {}) } - getOwner(): Promise { - return this.eth_call(functions.getOwner, []) + getOwner() { + return this.eth_call(functions.getOwner, {}) } - getPastAccumulators(queries: Array<([variable: number, ago: bigint] & {variable: number, ago: bigint})>): Promise> { - return this.eth_call(functions.getPastAccumulators, [queries]) + getPastAccumulators(queries: GetPastAccumulatorsParams["queries"]) { + return this.eth_call(functions.getPastAccumulators, {queries}) } - getPausedState(): Promise<([paused: boolean, pauseWindowEndTime: bigint, bufferPeriodEndTime: bigint] & {paused: boolean, pauseWindowEndTime: bigint, bufferPeriodEndTime: bigint})> { - return this.eth_call(functions.getPausedState, []) + getPausedState() { + return this.eth_call(functions.getPausedState, {}) } - getPoolId(): Promise { - return this.eth_call(functions.getPoolId, []) + getPoolId() { + return this.eth_call(functions.getPoolId, {}) } - getPriceRateCache(token: string): Promise<([rate: bigint, duration: bigint, expires: bigint] & {rate: bigint, duration: bigint, expires: bigint})> { - return this.eth_call(functions.getPriceRateCache, [token]) + getPriceRateCache(token: GetPriceRateCacheParams["token"]) { + return this.eth_call(functions.getPriceRateCache, {token}) } - getRate(): Promise { - return this.eth_call(functions.getRate, []) + getRate() { + return this.eth_call(functions.getRate, {}) } - getRateProviders(): Promise> { - return this.eth_call(functions.getRateProviders, []) + getRateProviders() { + return this.eth_call(functions.getRateProviders, {}) } - getSample(index: bigint): Promise<([logPairPrice: bigint, accLogPairPrice: bigint, logBptPrice: bigint, accLogBptPrice: bigint, logInvariant: bigint, accLogInvariant: bigint, timestamp: bigint] & {logPairPrice: bigint, accLogPairPrice: bigint, logBptPrice: bigint, accLogBptPrice: bigint, logInvariant: bigint, accLogInvariant: bigint, timestamp: bigint})> { - return this.eth_call(functions.getSample, [index]) + getSample(index: GetSampleParams["index"]) { + return this.eth_call(functions.getSample, {index}) } - getScalingFactors(): Promise> { - return this.eth_call(functions.getScalingFactors, []) + getScalingFactors() { + return this.eth_call(functions.getScalingFactors, {}) } - getSwapFeePercentage(): Promise { - return this.eth_call(functions.getSwapFeePercentage, []) + getSwapFeePercentage() { + return this.eth_call(functions.getSwapFeePercentage, {}) } - getTimeWeightedAverage(queries: Array<([variable: number, secs: bigint, ago: bigint] & {variable: number, secs: bigint, ago: bigint})>): Promise> { - return this.eth_call(functions.getTimeWeightedAverage, [queries]) + getTimeWeightedAverage(queries: GetTimeWeightedAverageParams["queries"]) { + return this.eth_call(functions.getTimeWeightedAverage, {queries}) } - getTotalSamples(): Promise { - return this.eth_call(functions.getTotalSamples, []) + getTotalSamples() { + return this.eth_call(functions.getTotalSamples, {}) } - getVault(): Promise { - return this.eth_call(functions.getVault, []) + getVault() { + return this.eth_call(functions.getVault, {}) } - name(): Promise { - return this.eth_call(functions.name, []) + name() { + return this.eth_call(functions.name, {}) } - nonces(owner: string): Promise { - return this.eth_call(functions.nonces, [owner]) + nonces(owner: NoncesParams["owner"]) { + return this.eth_call(functions.nonces, {owner}) } - symbol(): Promise { - return this.eth_call(functions.symbol, []) + symbol() { + return this.eth_call(functions.symbol, {}) } - totalSupply(): Promise { - return this.eth_call(functions.totalSupply, []) + totalSupply() { + return this.eth_call(functions.totalSupply, {}) } } + +/// Event types +export type AmpUpdateStartedEventArgs = EParams +export type AmpUpdateStoppedEventArgs = EParams +export type ApprovalEventArgs = EParams +export type OracleEnabledChangedEventArgs = EParams +export type PausedStateChangedEventArgs = EParams +export type PriceRateCacheUpdatedEventArgs = EParams +export type PriceRateProviderSetEventArgs = EParams +export type SwapFeePercentageChangedEventArgs = EParams +export type TransferEventArgs = EParams + +/// Function types +export type DOMAIN_SEPARATORParams = FunctionArguments +export type DOMAIN_SEPARATORReturn = FunctionReturn + +export type AllowanceParams = FunctionArguments +export type AllowanceReturn = FunctionReturn + +export type ApproveParams = FunctionArguments +export type ApproveReturn = FunctionReturn + +export type BalanceOfParams = FunctionArguments +export type BalanceOfReturn = FunctionReturn + +export type DecimalsParams = FunctionArguments +export type DecimalsReturn = FunctionReturn + +export type DecreaseAllowanceParams = FunctionArguments +export type DecreaseAllowanceReturn = FunctionReturn + +export type EnableOracleParams = FunctionArguments +export type EnableOracleReturn = FunctionReturn + +export type GetActionIdParams = FunctionArguments +export type GetActionIdReturn = FunctionReturn + +export type GetAmplificationParameterParams = FunctionArguments +export type GetAmplificationParameterReturn = FunctionReturn + +export type GetAuthorizerParams = FunctionArguments +export type GetAuthorizerReturn = FunctionReturn + +export type GetLargestSafeQueryWindowParams = FunctionArguments +export type GetLargestSafeQueryWindowReturn = FunctionReturn + +export type GetLastInvariantParams = FunctionArguments +export type GetLastInvariantReturn = FunctionReturn + +export type GetLatestParams = FunctionArguments +export type GetLatestReturn = FunctionReturn + +export type GetOracleMiscDataParams = FunctionArguments +export type GetOracleMiscDataReturn = FunctionReturn + +export type GetOwnerParams = FunctionArguments +export type GetOwnerReturn = FunctionReturn + +export type GetPastAccumulatorsParams = FunctionArguments +export type GetPastAccumulatorsReturn = FunctionReturn + +export type GetPausedStateParams = FunctionArguments +export type GetPausedStateReturn = FunctionReturn + +export type GetPoolIdParams = FunctionArguments +export type GetPoolIdReturn = FunctionReturn + +export type GetPriceRateCacheParams = FunctionArguments +export type GetPriceRateCacheReturn = FunctionReturn + +export type GetRateParams = FunctionArguments +export type GetRateReturn = FunctionReturn + +export type GetRateProvidersParams = FunctionArguments +export type GetRateProvidersReturn = FunctionReturn + +export type GetSampleParams = FunctionArguments +export type GetSampleReturn = FunctionReturn + +export type GetScalingFactorsParams = FunctionArguments +export type GetScalingFactorsReturn = FunctionReturn + +export type GetSwapFeePercentageParams = FunctionArguments +export type GetSwapFeePercentageReturn = FunctionReturn + +export type GetTimeWeightedAverageParams = FunctionArguments +export type GetTimeWeightedAverageReturn = FunctionReturn + +export type GetTotalSamplesParams = FunctionArguments +export type GetTotalSamplesReturn = FunctionReturn + +export type GetVaultParams = FunctionArguments +export type GetVaultReturn = FunctionReturn + +export type IncreaseAllowanceParams = FunctionArguments +export type IncreaseAllowanceReturn = FunctionReturn + +export type NameParams = FunctionArguments +export type NameReturn = FunctionReturn + +export type NoncesParams = FunctionArguments +export type NoncesReturn = FunctionReturn + +export type OnExitPoolParams = FunctionArguments +export type OnExitPoolReturn = FunctionReturn + +export type OnJoinPoolParams = FunctionArguments +export type OnJoinPoolReturn = FunctionReturn + +export type OnSwapParams_0 = FunctionArguments +export type OnSwapReturn_0 = FunctionReturn + +export type OnSwapParams_1 = FunctionArguments +export type OnSwapReturn_1 = FunctionReturn + +export type PermitParams = FunctionArguments +export type PermitReturn = FunctionReturn + +export type QueryExitParams = FunctionArguments +export type QueryExitReturn = FunctionReturn + +export type QueryJoinParams = FunctionArguments +export type QueryJoinReturn = FunctionReturn + +export type SetAssetManagerPoolConfigParams = FunctionArguments +export type SetAssetManagerPoolConfigReturn = FunctionReturn + +export type SetPausedParams = FunctionArguments +export type SetPausedReturn = FunctionReturn + +export type SetPriceRateCacheDurationParams = FunctionArguments +export type SetPriceRateCacheDurationReturn = FunctionReturn + +export type SetSwapFeePercentageParams = FunctionArguments +export type SetSwapFeePercentageReturn = FunctionReturn + +export type StartAmplificationParameterUpdateParams = FunctionArguments +export type StartAmplificationParameterUpdateReturn = FunctionReturn + +export type StopAmplificationParameterUpdateParams = FunctionArguments +export type StopAmplificationParameterUpdateReturn = FunctionReturn + +export type SymbolParams = FunctionArguments +export type SymbolReturn = FunctionReturn + +export type TotalSupplyParams = FunctionArguments +export type TotalSupplyReturn = FunctionReturn + +export type TransferParams = FunctionArguments +export type TransferReturn = FunctionReturn + +export type TransferFromParams = FunctionArguments +export type TransferFromReturn = FunctionReturn + +export type UpdatePriceRateCacheParams = FunctionArguments +export type UpdatePriceRateCacheReturn = FunctionReturn + diff --git a/src/abi/balancer-rate-provider.ts b/src/abi/balancer-rate-provider.ts index 7b8ba9c4..8d377254 100644 --- a/src/abi/balancer-rate-provider.ts +++ b/src/abi/balancer-rate-provider.ts @@ -1,25 +1,27 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './balancer-rate-provider.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const functions = { - getRate: new Func<[], {}, bigint>( - abi, '0x679aefce' - ), - rocketTokenRETH: new Func<[], {}, string>( - abi, '0xdb5dacc9' - ), + getRate: fun("0x679aefce", {}, p.uint256), + rocketTokenRETH: fun("0xdb5dacc9", {}, p.address), } export class Contract extends ContractBase { - getRate(): Promise { - return this.eth_call(functions.getRate, []) + getRate() { + return this.eth_call(functions.getRate, {}) } - rocketTokenRETH(): Promise { - return this.eth_call(functions.rocketTokenRETH, []) + rocketTokenRETH() { + return this.eth_call(functions.rocketTokenRETH, {}) } } + +/// Function types +export type GetRateParams = FunctionArguments +export type GetRateReturn = FunctionReturn + +export type RocketTokenRETHParams = FunctionArguments +export type RocketTokenRETHReturn = FunctionReturn + diff --git a/src/abi/balancer-vault.ts b/src/abi/balancer-vault.ts index ca69514f..00984497 100644 --- a/src/abi/balancer-vault.ts +++ b/src/abi/balancer-vault.ts @@ -1,176 +1,192 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './balancer-vault.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - AuthorizerChanged: new LogEvent<([newAuthorizer: string] & {newAuthorizer: string})>( - abi, '0x94b979b6831a51293e2641426f97747feed46f17779fed9cd18d1ecefcfe92ef' - ), - ExternalBalanceTransfer: new LogEvent<([token: string, sender: string, recipient: string, amount: bigint] & {token: string, sender: string, recipient: string, amount: bigint})>( - abi, '0x540a1a3f28340caec336c81d8d7b3df139ee5cdc1839a4f283d7ebb7eaae2d5c' - ), - FlashLoan: new LogEvent<([recipient: string, token: string, amount: bigint, feeAmount: bigint] & {recipient: string, token: string, amount: bigint, feeAmount: bigint})>( - abi, '0x0d7d75e01ab95780d3cd1c8ec0dd6c2ce19e3a20427eec8bf53283b6fb8e95f0' - ), - InternalBalanceChanged: new LogEvent<([user: string, token: string, delta: bigint] & {user: string, token: string, delta: bigint})>( - abi, '0x18e1ea4139e68413d7d08aa752e71568e36b2c5bf940893314c2c5b01eaa0c42' - ), - PausedStateChanged: new LogEvent<([paused: boolean] & {paused: boolean})>( - abi, '0x9e3a5e37224532dea67b89face185703738a228a6e8a23dee546960180d3be64' - ), - PoolBalanceChanged: new LogEvent<([poolId: string, liquidityProvider: string, tokens: Array, deltas: Array, protocolFeeAmounts: Array] & {poolId: string, liquidityProvider: string, tokens: Array, deltas: Array, protocolFeeAmounts: Array})>( - abi, '0xe5ce249087ce04f05a957192435400fd97868dba0e6a4b4c049abf8af80dae78' - ), - PoolBalanceManaged: new LogEvent<([poolId: string, assetManager: string, token: string, cashDelta: bigint, managedDelta: bigint] & {poolId: string, assetManager: string, token: string, cashDelta: bigint, managedDelta: bigint})>( - abi, '0x6edcaf6241105b4c94c2efdbf3a6b12458eb3d07be3a0e81d24b13c44045fe7a' - ), - PoolRegistered: new LogEvent<([poolId: string, poolAddress: string, specialization: number] & {poolId: string, poolAddress: string, specialization: number})>( - abi, '0x3c13bc30b8e878c53fd2a36b679409c073afd75950be43d8858768e956fbc20e' - ), - RelayerApprovalChanged: new LogEvent<([relayer: string, sender: string, approved: boolean] & {relayer: string, sender: string, approved: boolean})>( - abi, '0x46961fdb4502b646d5095fba7600486a8ac05041d55cdf0f16ed677180b5cad8' - ), - Swap: new LogEvent<([poolId: string, tokenIn: string, tokenOut: string, amountIn: bigint, amountOut: bigint] & {poolId: string, tokenIn: string, tokenOut: string, amountIn: bigint, amountOut: bigint})>( - abi, '0x2170c741c41531aec20e7c107c24eecfdd15e69c9bb0a8dd37b1840b9e0b207b' - ), - TokensDeregistered: new LogEvent<([poolId: string, tokens: Array] & {poolId: string, tokens: Array})>( - abi, '0x7dcdc6d02ef40c7c1a7046a011b058bd7f988fa14e20a66344f9d4e60657d610' - ), - TokensRegistered: new LogEvent<([poolId: string, tokens: Array, assetManagers: Array] & {poolId: string, tokens: Array, assetManagers: Array})>( - abi, '0xf5847d3f2197b16cdcd2098ec95d0905cd1abdaf415f07bb7cef2bba8ac5dec4' - ), + AuthorizerChanged: event("0x94b979b6831a51293e2641426f97747feed46f17779fed9cd18d1ecefcfe92ef", {"newAuthorizer": indexed(p.address)}), + ExternalBalanceTransfer: event("0x540a1a3f28340caec336c81d8d7b3df139ee5cdc1839a4f283d7ebb7eaae2d5c", {"token": indexed(p.address), "sender": indexed(p.address), "recipient": p.address, "amount": p.uint256}), + FlashLoan: event("0x0d7d75e01ab95780d3cd1c8ec0dd6c2ce19e3a20427eec8bf53283b6fb8e95f0", {"recipient": indexed(p.address), "token": indexed(p.address), "amount": p.uint256, "feeAmount": p.uint256}), + InternalBalanceChanged: event("0x18e1ea4139e68413d7d08aa752e71568e36b2c5bf940893314c2c5b01eaa0c42", {"user": indexed(p.address), "token": indexed(p.address), "delta": p.int256}), + PausedStateChanged: event("0x9e3a5e37224532dea67b89face185703738a228a6e8a23dee546960180d3be64", {"paused": p.bool}), + PoolBalanceChanged: event("0xe5ce249087ce04f05a957192435400fd97868dba0e6a4b4c049abf8af80dae78", {"poolId": indexed(p.bytes32), "liquidityProvider": indexed(p.address), "tokens": p.array(p.address), "deltas": p.array(p.int256), "protocolFeeAmounts": p.array(p.uint256)}), + PoolBalanceManaged: event("0x6edcaf6241105b4c94c2efdbf3a6b12458eb3d07be3a0e81d24b13c44045fe7a", {"poolId": indexed(p.bytes32), "assetManager": indexed(p.address), "token": indexed(p.address), "cashDelta": p.int256, "managedDelta": p.int256}), + PoolRegistered: event("0x3c13bc30b8e878c53fd2a36b679409c073afd75950be43d8858768e956fbc20e", {"poolId": indexed(p.bytes32), "poolAddress": indexed(p.address), "specialization": p.uint8}), + RelayerApprovalChanged: event("0x46961fdb4502b646d5095fba7600486a8ac05041d55cdf0f16ed677180b5cad8", {"relayer": indexed(p.address), "sender": indexed(p.address), "approved": p.bool}), + Swap: event("0x2170c741c41531aec20e7c107c24eecfdd15e69c9bb0a8dd37b1840b9e0b207b", {"poolId": indexed(p.bytes32), "tokenIn": indexed(p.address), "tokenOut": indexed(p.address), "amountIn": p.uint256, "amountOut": p.uint256}), + TokensDeregistered: event("0x7dcdc6d02ef40c7c1a7046a011b058bd7f988fa14e20a66344f9d4e60657d610", {"poolId": indexed(p.bytes32), "tokens": p.array(p.address)}), + TokensRegistered: event("0xf5847d3f2197b16cdcd2098ec95d0905cd1abdaf415f07bb7cef2bba8ac5dec4", {"poolId": indexed(p.bytes32), "tokens": p.array(p.address), "assetManagers": p.array(p.address)}), } export const functions = { - WETH: new Func<[], {}, string>( - abi, '0xad5c4648' - ), - batchSwap: new Func<[kind: number, swaps: Array<([poolId: string, assetInIndex: bigint, assetOutIndex: bigint, amount: bigint, userData: string] & {poolId: string, assetInIndex: bigint, assetOutIndex: bigint, amount: bigint, userData: string})>, assets: Array, funds: ([sender: string, fromInternalBalance: boolean, recipient: string, toInternalBalance: boolean] & {sender: string, fromInternalBalance: boolean, recipient: string, toInternalBalance: boolean}), limits: Array, deadline: bigint], {kind: number, swaps: Array<([poolId: string, assetInIndex: bigint, assetOutIndex: bigint, amount: bigint, userData: string] & {poolId: string, assetInIndex: bigint, assetOutIndex: bigint, amount: bigint, userData: string})>, assets: Array, funds: ([sender: string, fromInternalBalance: boolean, recipient: string, toInternalBalance: boolean] & {sender: string, fromInternalBalance: boolean, recipient: string, toInternalBalance: boolean}), limits: Array, deadline: bigint}, Array>( - abi, '0x945bcec9' - ), - deregisterTokens: new Func<[poolId: string, tokens: Array], {poolId: string, tokens: Array}, []>( - abi, '0x7d3aeb96' - ), - exitPool: new Func<[poolId: string, sender: string, recipient: string, request: ([assets: Array, minAmountsOut: Array, userData: string, toInternalBalance: boolean] & {assets: Array, minAmountsOut: Array, userData: string, toInternalBalance: boolean})], {poolId: string, sender: string, recipient: string, request: ([assets: Array, minAmountsOut: Array, userData: string, toInternalBalance: boolean] & {assets: Array, minAmountsOut: Array, userData: string, toInternalBalance: boolean})}, []>( - abi, '0x8bdb3913' - ), - flashLoan: new Func<[recipient: string, tokens: Array, amounts: Array, userData: string], {recipient: string, tokens: Array, amounts: Array, userData: string}, []>( - abi, '0x5c38449e' - ), - getActionId: new Func<[selector: string], {selector: string}, string>( - abi, '0x851c1bb3' - ), - getAuthorizer: new Func<[], {}, string>( - abi, '0xaaabadc5' - ), - getDomainSeparator: new Func<[], {}, string>( - abi, '0xed24911d' - ), - getInternalBalance: new Func<[user: string, tokens: Array], {user: string, tokens: Array}, Array>( - abi, '0x0f5a6efa' - ), - getNextNonce: new Func<[user: string], {user: string}, bigint>( - abi, '0x90193b7c' - ), - getPausedState: new Func<[], {}, ([paused: boolean, pauseWindowEndTime: bigint, bufferPeriodEndTime: bigint] & {paused: boolean, pauseWindowEndTime: bigint, bufferPeriodEndTime: bigint})>( - abi, '0x1c0de051' - ), - getPool: new Func<[poolId: string], {poolId: string}, [_: string, _: number]>( - abi, '0xf6c00927' - ), - getPoolTokenInfo: new Func<[poolId: string, token: string], {poolId: string, token: string}, ([cash: bigint, managed: bigint, lastChangeBlock: bigint, assetManager: string] & {cash: bigint, managed: bigint, lastChangeBlock: bigint, assetManager: string})>( - abi, '0xb05f8e48' - ), - getPoolTokens: new Func<[poolId: string], {poolId: string}, ([tokens: Array, balances: Array, lastChangeBlock: bigint] & {tokens: Array, balances: Array, lastChangeBlock: bigint})>( - abi, '0xf94d4668' - ), - getProtocolFeesCollector: new Func<[], {}, string>( - abi, '0xd2946c2b' - ), - hasApprovedRelayer: new Func<[user: string, relayer: string], {user: string, relayer: string}, boolean>( - abi, '0xfec90d72' - ), - joinPool: new Func<[poolId: string, sender: string, recipient: string, request: ([assets: Array, maxAmountsIn: Array, userData: string, fromInternalBalance: boolean] & {assets: Array, maxAmountsIn: Array, userData: string, fromInternalBalance: boolean})], {poolId: string, sender: string, recipient: string, request: ([assets: Array, maxAmountsIn: Array, userData: string, fromInternalBalance: boolean] & {assets: Array, maxAmountsIn: Array, userData: string, fromInternalBalance: boolean})}, []>( - abi, '0xb95cac28' - ), - managePoolBalance: new Func<[ops: Array<([kind: number, poolId: string, token: string, amount: bigint] & {kind: number, poolId: string, token: string, amount: bigint})>], {ops: Array<([kind: number, poolId: string, token: string, amount: bigint] & {kind: number, poolId: string, token: string, amount: bigint})>}, []>( - abi, '0xe6c46092' - ), - manageUserBalance: new Func<[ops: Array<([kind: number, asset: string, amount: bigint, sender: string, recipient: string] & {kind: number, asset: string, amount: bigint, sender: string, recipient: string})>], {ops: Array<([kind: number, asset: string, amount: bigint, sender: string, recipient: string] & {kind: number, asset: string, amount: bigint, sender: string, recipient: string})>}, []>( - abi, '0x0e8e3e84' - ), - queryBatchSwap: new Func<[kind: number, swaps: Array<([poolId: string, assetInIndex: bigint, assetOutIndex: bigint, amount: bigint, userData: string] & {poolId: string, assetInIndex: bigint, assetOutIndex: bigint, amount: bigint, userData: string})>, assets: Array, funds: ([sender: string, fromInternalBalance: boolean, recipient: string, toInternalBalance: boolean] & {sender: string, fromInternalBalance: boolean, recipient: string, toInternalBalance: boolean})], {kind: number, swaps: Array<([poolId: string, assetInIndex: bigint, assetOutIndex: bigint, amount: bigint, userData: string] & {poolId: string, assetInIndex: bigint, assetOutIndex: bigint, amount: bigint, userData: string})>, assets: Array, funds: ([sender: string, fromInternalBalance: boolean, recipient: string, toInternalBalance: boolean] & {sender: string, fromInternalBalance: boolean, recipient: string, toInternalBalance: boolean})}, Array>( - abi, '0xf84d066e' - ), - registerPool: new Func<[specialization: number], {specialization: number}, string>( - abi, '0x09b2760f' - ), - registerTokens: new Func<[poolId: string, tokens: Array, assetManagers: Array], {poolId: string, tokens: Array, assetManagers: Array}, []>( - abi, '0x66a9c7d2' - ), - setAuthorizer: new Func<[newAuthorizer: string], {newAuthorizer: string}, []>( - abi, '0x058a628f' - ), - setPaused: new Func<[paused: boolean], {paused: boolean}, []>( - abi, '0x16c38b3c' - ), - setRelayerApproval: new Func<[sender: string, relayer: string, approved: boolean], {sender: string, relayer: string, approved: boolean}, []>( - abi, '0xfa6e671d' - ), - swap: new Func<[singleSwap: ([poolId: string, kind: number, assetIn: string, assetOut: string, amount: bigint, userData: string] & {poolId: string, kind: number, assetIn: string, assetOut: string, amount: bigint, userData: string}), funds: ([sender: string, fromInternalBalance: boolean, recipient: string, toInternalBalance: boolean] & {sender: string, fromInternalBalance: boolean, recipient: string, toInternalBalance: boolean}), limit: bigint, deadline: bigint], {singleSwap: ([poolId: string, kind: number, assetIn: string, assetOut: string, amount: bigint, userData: string] & {poolId: string, kind: number, assetIn: string, assetOut: string, amount: bigint, userData: string}), funds: ([sender: string, fromInternalBalance: boolean, recipient: string, toInternalBalance: boolean] & {sender: string, fromInternalBalance: boolean, recipient: string, toInternalBalance: boolean}), limit: bigint, deadline: bigint}, bigint>( - abi, '0x52bbbe29' - ), + WETH: fun("0xad5c4648", {}, p.address), + batchSwap: fun("0x945bcec9", {"kind": p.uint8, "swaps": p.array(p.struct({"poolId": p.bytes32, "assetInIndex": p.uint256, "assetOutIndex": p.uint256, "amount": p.uint256, "userData": p.bytes})), "assets": p.array(p.address), "funds": p.struct({"sender": p.address, "fromInternalBalance": p.bool, "recipient": p.address, "toInternalBalance": p.bool}), "limits": p.array(p.int256), "deadline": p.uint256}, p.array(p.int256)), + deregisterTokens: fun("0x7d3aeb96", {"poolId": p.bytes32, "tokens": p.array(p.address)}, ), + exitPool: fun("0x8bdb3913", {"poolId": p.bytes32, "sender": p.address, "recipient": p.address, "request": p.struct({"assets": p.array(p.address), "minAmountsOut": p.array(p.uint256), "userData": p.bytes, "toInternalBalance": p.bool})}, ), + flashLoan: fun("0x5c38449e", {"recipient": p.address, "tokens": p.array(p.address), "amounts": p.array(p.uint256), "userData": p.bytes}, ), + getActionId: fun("0x851c1bb3", {"selector": p.bytes4}, p.bytes32), + getAuthorizer: fun("0xaaabadc5", {}, p.address), + getDomainSeparator: fun("0xed24911d", {}, p.bytes32), + getInternalBalance: fun("0x0f5a6efa", {"user": p.address, "tokens": p.array(p.address)}, p.array(p.uint256)), + getNextNonce: fun("0x90193b7c", {"user": p.address}, p.uint256), + getPausedState: fun("0x1c0de051", {}, {"paused": p.bool, "pauseWindowEndTime": p.uint256, "bufferPeriodEndTime": p.uint256}), + getPool: fun("0xf6c00927", {"poolId": p.bytes32}, {"_0": p.address, "_1": p.uint8}), + getPoolTokenInfo: fun("0xb05f8e48", {"poolId": p.bytes32, "token": p.address}, {"cash": p.uint256, "managed": p.uint256, "lastChangeBlock": p.uint256, "assetManager": p.address}), + getPoolTokens: fun("0xf94d4668", {"poolId": p.bytes32}, {"tokens": p.array(p.address), "balances": p.array(p.uint256), "lastChangeBlock": p.uint256}), + getProtocolFeesCollector: fun("0xd2946c2b", {}, p.address), + hasApprovedRelayer: fun("0xfec90d72", {"user": p.address, "relayer": p.address}, p.bool), + joinPool: fun("0xb95cac28", {"poolId": p.bytes32, "sender": p.address, "recipient": p.address, "request": p.struct({"assets": p.array(p.address), "maxAmountsIn": p.array(p.uint256), "userData": p.bytes, "fromInternalBalance": p.bool})}, ), + managePoolBalance: fun("0xe6c46092", {"ops": p.array(p.struct({"kind": p.uint8, "poolId": p.bytes32, "token": p.address, "amount": p.uint256}))}, ), + manageUserBalance: fun("0x0e8e3e84", {"ops": p.array(p.struct({"kind": p.uint8, "asset": p.address, "amount": p.uint256, "sender": p.address, "recipient": p.address}))}, ), + queryBatchSwap: fun("0xf84d066e", {"kind": p.uint8, "swaps": p.array(p.struct({"poolId": p.bytes32, "assetInIndex": p.uint256, "assetOutIndex": p.uint256, "amount": p.uint256, "userData": p.bytes})), "assets": p.array(p.address), "funds": p.struct({"sender": p.address, "fromInternalBalance": p.bool, "recipient": p.address, "toInternalBalance": p.bool})}, p.array(p.int256)), + registerPool: fun("0x09b2760f", {"specialization": p.uint8}, p.bytes32), + registerTokens: fun("0x66a9c7d2", {"poolId": p.bytes32, "tokens": p.array(p.address), "assetManagers": p.array(p.address)}, ), + setAuthorizer: fun("0x058a628f", {"newAuthorizer": p.address}, ), + setPaused: fun("0x16c38b3c", {"paused": p.bool}, ), + setRelayerApproval: fun("0xfa6e671d", {"sender": p.address, "relayer": p.address, "approved": p.bool}, ), + swap: fun("0x52bbbe29", {"singleSwap": p.struct({"poolId": p.bytes32, "kind": p.uint8, "assetIn": p.address, "assetOut": p.address, "amount": p.uint256, "userData": p.bytes}), "funds": p.struct({"sender": p.address, "fromInternalBalance": p.bool, "recipient": p.address, "toInternalBalance": p.bool}), "limit": p.uint256, "deadline": p.uint256}, p.uint256), } export class Contract extends ContractBase { - WETH(): Promise { - return this.eth_call(functions.WETH, []) + WETH() { + return this.eth_call(functions.WETH, {}) } - getActionId(selector: string): Promise { - return this.eth_call(functions.getActionId, [selector]) + getActionId(selector: GetActionIdParams["selector"]) { + return this.eth_call(functions.getActionId, {selector}) } - getAuthorizer(): Promise { - return this.eth_call(functions.getAuthorizer, []) + getAuthorizer() { + return this.eth_call(functions.getAuthorizer, {}) } - getDomainSeparator(): Promise { - return this.eth_call(functions.getDomainSeparator, []) + getDomainSeparator() { + return this.eth_call(functions.getDomainSeparator, {}) } - getInternalBalance(user: string, tokens: Array): Promise> { - return this.eth_call(functions.getInternalBalance, [user, tokens]) + getInternalBalance(user: GetInternalBalanceParams["user"], tokens: GetInternalBalanceParams["tokens"]) { + return this.eth_call(functions.getInternalBalance, {user, tokens}) } - getNextNonce(user: string): Promise { - return this.eth_call(functions.getNextNonce, [user]) + getNextNonce(user: GetNextNonceParams["user"]) { + return this.eth_call(functions.getNextNonce, {user}) } - getPausedState(): Promise<([paused: boolean, pauseWindowEndTime: bigint, bufferPeriodEndTime: bigint] & {paused: boolean, pauseWindowEndTime: bigint, bufferPeriodEndTime: bigint})> { - return this.eth_call(functions.getPausedState, []) + getPausedState() { + return this.eth_call(functions.getPausedState, {}) } - getPool(poolId: string): Promise<[_: string, _: number]> { - return this.eth_call(functions.getPool, [poolId]) + getPool(poolId: GetPoolParams["poolId"]) { + return this.eth_call(functions.getPool, {poolId}) } - getPoolTokenInfo(poolId: string, token: string): Promise<([cash: bigint, managed: bigint, lastChangeBlock: bigint, assetManager: string] & {cash: bigint, managed: bigint, lastChangeBlock: bigint, assetManager: string})> { - return this.eth_call(functions.getPoolTokenInfo, [poolId, token]) + getPoolTokenInfo(poolId: GetPoolTokenInfoParams["poolId"], token: GetPoolTokenInfoParams["token"]) { + return this.eth_call(functions.getPoolTokenInfo, {poolId, token}) } - getPoolTokens(poolId: string): Promise<([tokens: Array, balances: Array, lastChangeBlock: bigint] & {tokens: Array, balances: Array, lastChangeBlock: bigint})> { - return this.eth_call(functions.getPoolTokens, [poolId]) + getPoolTokens(poolId: GetPoolTokensParams["poolId"]) { + return this.eth_call(functions.getPoolTokens, {poolId}) } - getProtocolFeesCollector(): Promise { - return this.eth_call(functions.getProtocolFeesCollector, []) + getProtocolFeesCollector() { + return this.eth_call(functions.getProtocolFeesCollector, {}) } - hasApprovedRelayer(user: string, relayer: string): Promise { - return this.eth_call(functions.hasApprovedRelayer, [user, relayer]) + hasApprovedRelayer(user: HasApprovedRelayerParams["user"], relayer: HasApprovedRelayerParams["relayer"]) { + return this.eth_call(functions.hasApprovedRelayer, {user, relayer}) } } + +/// Event types +export type AuthorizerChangedEventArgs = EParams +export type ExternalBalanceTransferEventArgs = EParams +export type FlashLoanEventArgs = EParams +export type InternalBalanceChangedEventArgs = EParams +export type PausedStateChangedEventArgs = EParams +export type PoolBalanceChangedEventArgs = EParams +export type PoolBalanceManagedEventArgs = EParams +export type PoolRegisteredEventArgs = EParams +export type RelayerApprovalChangedEventArgs = EParams +export type SwapEventArgs = EParams +export type TokensDeregisteredEventArgs = EParams +export type TokensRegisteredEventArgs = EParams + +/// Function types +export type WETHParams = FunctionArguments +export type WETHReturn = FunctionReturn + +export type BatchSwapParams = FunctionArguments +export type BatchSwapReturn = FunctionReturn + +export type DeregisterTokensParams = FunctionArguments +export type DeregisterTokensReturn = FunctionReturn + +export type ExitPoolParams = FunctionArguments +export type ExitPoolReturn = FunctionReturn + +export type FlashLoanParams = FunctionArguments +export type FlashLoanReturn = FunctionReturn + +export type GetActionIdParams = FunctionArguments +export type GetActionIdReturn = FunctionReturn + +export type GetAuthorizerParams = FunctionArguments +export type GetAuthorizerReturn = FunctionReturn + +export type GetDomainSeparatorParams = FunctionArguments +export type GetDomainSeparatorReturn = FunctionReturn + +export type GetInternalBalanceParams = FunctionArguments +export type GetInternalBalanceReturn = FunctionReturn + +export type GetNextNonceParams = FunctionArguments +export type GetNextNonceReturn = FunctionReturn + +export type GetPausedStateParams = FunctionArguments +export type GetPausedStateReturn = FunctionReturn + +export type GetPoolParams = FunctionArguments +export type GetPoolReturn = FunctionReturn + +export type GetPoolTokenInfoParams = FunctionArguments +export type GetPoolTokenInfoReturn = FunctionReturn + +export type GetPoolTokensParams = FunctionArguments +export type GetPoolTokensReturn = FunctionReturn + +export type GetProtocolFeesCollectorParams = FunctionArguments +export type GetProtocolFeesCollectorReturn = FunctionReturn + +export type HasApprovedRelayerParams = FunctionArguments +export type HasApprovedRelayerReturn = FunctionReturn + +export type JoinPoolParams = FunctionArguments +export type JoinPoolReturn = FunctionReturn + +export type ManagePoolBalanceParams = FunctionArguments +export type ManagePoolBalanceReturn = FunctionReturn + +export type ManageUserBalanceParams = FunctionArguments +export type ManageUserBalanceReturn = FunctionReturn + +export type QueryBatchSwapParams = FunctionArguments +export type QueryBatchSwapReturn = FunctionReturn + +export type RegisterPoolParams = FunctionArguments +export type RegisterPoolReturn = FunctionReturn + +export type RegisterTokensParams = FunctionArguments +export type RegisterTokensReturn = FunctionReturn + +export type SetAuthorizerParams = FunctionArguments +export type SetAuthorizerReturn = FunctionReturn + +export type SetPausedParams = FunctionArguments +export type SetPausedReturn = FunctionReturn + +export type SetRelayerApprovalParams = FunctionArguments +export type SetRelayerApprovalReturn = FunctionReturn + +export type SwapParams = FunctionArguments +export type SwapReturn = FunctionReturn + diff --git a/src/abi/balancer-weighted-pool-2-token.ts b/src/abi/balancer-weighted-pool-2-token.ts index e0756e7d..6b07a78c 100644 --- a/src/abi/balancer-weighted-pool-2-token.ts +++ b/src/abi/balancer-weighted-pool-2-token.ts @@ -1,253 +1,290 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './balancer-weighted-pool-2-token.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - Approval: new LogEvent<([owner: string, spender: string, value: bigint] & {owner: string, spender: string, value: bigint})>( - abi, '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925' - ), - OracleEnabledChanged: new LogEvent<([enabled: boolean] & {enabled: boolean})>( - abi, '0x3e350b41e86a8e10f804ade6d35340d620be35569cc75ac943e8bb14ab80ead1' - ), - PausedStateChanged: new LogEvent<([paused: boolean] & {paused: boolean})>( - abi, '0x9e3a5e37224532dea67b89face185703738a228a6e8a23dee546960180d3be64' - ), - SwapFeePercentageChanged: new LogEvent<([swapFeePercentage: bigint] & {swapFeePercentage: bigint})>( - abi, '0xa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc' - ), - Transfer: new LogEvent<([from: string, to: string, value: bigint] & {from: string, to: string, value: bigint})>( - abi, '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' - ), + Approval: event("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", {"owner": indexed(p.address), "spender": indexed(p.address), "value": p.uint256}), + OracleEnabledChanged: event("0x3e350b41e86a8e10f804ade6d35340d620be35569cc75ac943e8bb14ab80ead1", {"enabled": p.bool}), + PausedStateChanged: event("0x9e3a5e37224532dea67b89face185703738a228a6e8a23dee546960180d3be64", {"paused": p.bool}), + SwapFeePercentageChanged: event("0xa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc", {"swapFeePercentage": p.uint256}), + Transfer: event("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", {"from": indexed(p.address), "to": indexed(p.address), "value": p.uint256}), } export const functions = { - DOMAIN_SEPARATOR: new Func<[], {}, string>( - abi, '0x3644e515' - ), - allowance: new Func<[owner: string, spender: string], {owner: string, spender: string}, bigint>( - abi, '0xdd62ed3e' - ), - approve: new Func<[spender: string, amount: bigint], {spender: string, amount: bigint}, boolean>( - abi, '0x095ea7b3' - ), - balanceOf: new Func<[account: string], {account: string}, bigint>( - abi, '0x70a08231' - ), - decimals: new Func<[], {}, number>( - abi, '0x313ce567' - ), - decreaseApproval: new Func<[spender: string, amount: bigint], {spender: string, amount: bigint}, boolean>( - abi, '0x66188463' - ), - enableOracle: new Func<[], {}, []>( - abi, '0x292c914a' - ), - getActionId: new Func<[selector: string], {selector: string}, string>( - abi, '0x851c1bb3' - ), - getAuthorizer: new Func<[], {}, string>( - abi, '0xaaabadc5' - ), - getInvariant: new Func<[], {}, bigint>( - abi, '0xc0ff1a15' - ), - getLargestSafeQueryWindow: new Func<[], {}, bigint>( - abi, '0xffd088eb' - ), - getLastInvariant: new Func<[], {}, bigint>( - abi, '0x9b02cdde' - ), - getLatest: new Func<[variable: number], {variable: number}, bigint>( - abi, '0xb10be739' - ), - getMiscData: new Func<[], {}, ([logInvariant: bigint, logTotalSupply: bigint, oracleSampleCreationTimestamp: bigint, oracleIndex: bigint, oracleEnabled: boolean, swapFeePercentage: bigint] & {logInvariant: bigint, logTotalSupply: bigint, oracleSampleCreationTimestamp: bigint, oracleIndex: bigint, oracleEnabled: boolean, swapFeePercentage: bigint})>( - abi, '0x4a6b0b15' - ), - getNormalizedWeights: new Func<[], {}, Array>( - abi, '0xf89f27ed' - ), - getOwner: new Func<[], {}, string>( - abi, '0x893d20e8' - ), - getPastAccumulators: new Func<[queries: Array<([variable: number, ago: bigint] & {variable: number, ago: bigint})>], {queries: Array<([variable: number, ago: bigint] & {variable: number, ago: bigint})>}, Array>( - abi, '0x6b843239' - ), - getPausedState: new Func<[], {}, ([paused: boolean, pauseWindowEndTime: bigint, bufferPeriodEndTime: bigint] & {paused: boolean, pauseWindowEndTime: bigint, bufferPeriodEndTime: bigint})>( - abi, '0x1c0de051' - ), - getPoolId: new Func<[], {}, string>( - abi, '0x38fff2d0' - ), - getRate: new Func<[], {}, bigint>( - abi, '0x679aefce' - ), - getSample: new Func<[index: bigint], {index: bigint}, ([logPairPrice: bigint, accLogPairPrice: bigint, logBptPrice: bigint, accLogBptPrice: bigint, logInvariant: bigint, accLogInvariant: bigint, timestamp: bigint] & {logPairPrice: bigint, accLogPairPrice: bigint, logBptPrice: bigint, accLogBptPrice: bigint, logInvariant: bigint, accLogInvariant: bigint, timestamp: bigint})>( - abi, '0x60d1507c' - ), - getSwapFeePercentage: new Func<[], {}, bigint>( - abi, '0x55c67628' - ), - getTimeWeightedAverage: new Func<[queries: Array<([variable: number, secs: bigint, ago: bigint] & {variable: number, secs: bigint, ago: bigint})>], {queries: Array<([variable: number, secs: bigint, ago: bigint] & {variable: number, secs: bigint, ago: bigint})>}, Array>( - abi, '0x1dccd830' - ), - getTotalSamples: new Func<[], {}, bigint>( - abi, '0xb48b5b40' - ), - getVault: new Func<[], {}, string>( - abi, '0x8d928af8' - ), - increaseApproval: new Func<[spender: string, amount: bigint], {spender: string, amount: bigint}, boolean>( - abi, '0xd73dd623' - ), - name: new Func<[], {}, string>( - abi, '0x06fdde03' - ), - nonces: new Func<[owner: string], {owner: string}, bigint>( - abi, '0x7ecebe00' - ), - onExitPool: new Func<[poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string], {poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string}, [_: Array, _: Array]>( - abi, '0x74f3b009' - ), - onJoinPool: new Func<[poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string], {poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string}, ([amountsIn: Array, dueProtocolFeeAmounts: Array] & {amountsIn: Array, dueProtocolFeeAmounts: Array})>( - abi, '0xd5c096c4' - ), - onSwap: new Func<[request: ([kind: number, tokenIn: string, tokenOut: string, amount: bigint, poolId: string, lastChangeBlock: bigint, from: string, to: string, userData: string] & {kind: number, tokenIn: string, tokenOut: string, amount: bigint, poolId: string, lastChangeBlock: bigint, from: string, to: string, userData: string}), balanceTokenIn: bigint, balanceTokenOut: bigint], {request: ([kind: number, tokenIn: string, tokenOut: string, amount: bigint, poolId: string, lastChangeBlock: bigint, from: string, to: string, userData: string] & {kind: number, tokenIn: string, tokenOut: string, amount: bigint, poolId: string, lastChangeBlock: bigint, from: string, to: string, userData: string}), balanceTokenIn: bigint, balanceTokenOut: bigint}, bigint>( - abi, '0x9d2c110c' - ), - permit: new Func<[owner: string, spender: string, value: bigint, deadline: bigint, v: number, r: string, s: string], {owner: string, spender: string, value: bigint, deadline: bigint, v: number, r: string, s: string}, []>( - abi, '0xd505accf' - ), - queryExit: new Func<[poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string], {poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string}, ([bptIn: bigint, amountsOut: Array] & {bptIn: bigint, amountsOut: Array})>( - abi, '0x6028bfd4' - ), - queryJoin: new Func<[poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string], {poolId: string, sender: string, recipient: string, balances: Array, lastChangeBlock: bigint, protocolSwapFeePercentage: bigint, userData: string}, ([bptOut: bigint, amountsIn: Array] & {bptOut: bigint, amountsIn: Array})>( - abi, '0x87ec6817' - ), - setPaused: new Func<[paused: boolean], {paused: boolean}, []>( - abi, '0x16c38b3c' - ), - setSwapFeePercentage: new Func<[swapFeePercentage: bigint], {swapFeePercentage: bigint}, []>( - abi, '0x38e9922e' - ), - symbol: new Func<[], {}, string>( - abi, '0x95d89b41' - ), - totalSupply: new Func<[], {}, bigint>( - abi, '0x18160ddd' - ), - transfer: new Func<[recipient: string, amount: bigint], {recipient: string, amount: bigint}, boolean>( - abi, '0xa9059cbb' - ), - transferFrom: new Func<[sender: string, recipient: string, amount: bigint], {sender: string, recipient: string, amount: bigint}, boolean>( - abi, '0x23b872dd' - ), + DOMAIN_SEPARATOR: fun("0x3644e515", {}, p.bytes32), + allowance: fun("0xdd62ed3e", {"owner": p.address, "spender": p.address}, p.uint256), + approve: fun("0x095ea7b3", {"spender": p.address, "amount": p.uint256}, p.bool), + balanceOf: fun("0x70a08231", {"account": p.address}, p.uint256), + decimals: fun("0x313ce567", {}, p.uint8), + decreaseApproval: fun("0x66188463", {"spender": p.address, "amount": p.uint256}, p.bool), + enableOracle: fun("0x292c914a", {}, ), + getActionId: fun("0x851c1bb3", {"selector": p.bytes4}, p.bytes32), + getAuthorizer: fun("0xaaabadc5", {}, p.address), + getInvariant: fun("0xc0ff1a15", {}, p.uint256), + getLargestSafeQueryWindow: fun("0xffd088eb", {}, p.uint256), + getLastInvariant: fun("0x9b02cdde", {}, p.uint256), + getLatest: fun("0xb10be739", {"variable": p.uint8}, p.uint256), + getMiscData: fun("0x4a6b0b15", {}, {"logInvariant": p.int256, "logTotalSupply": p.int256, "oracleSampleCreationTimestamp": p.uint256, "oracleIndex": p.uint256, "oracleEnabled": p.bool, "swapFeePercentage": p.uint256}), + getNormalizedWeights: fun("0xf89f27ed", {}, p.array(p.uint256)), + getOwner: fun("0x893d20e8", {}, p.address), + getPastAccumulators: fun("0x6b843239", {"queries": p.array(p.struct({"variable": p.uint8, "ago": p.uint256}))}, p.array(p.int256)), + getPausedState: fun("0x1c0de051", {}, {"paused": p.bool, "pauseWindowEndTime": p.uint256, "bufferPeriodEndTime": p.uint256}), + getPoolId: fun("0x38fff2d0", {}, p.bytes32), + getRate: fun("0x679aefce", {}, p.uint256), + getSample: fun("0x60d1507c", {"index": p.uint256}, {"logPairPrice": p.int256, "accLogPairPrice": p.int256, "logBptPrice": p.int256, "accLogBptPrice": p.int256, "logInvariant": p.int256, "accLogInvariant": p.int256, "timestamp": p.uint256}), + getSwapFeePercentage: fun("0x55c67628", {}, p.uint256), + getTimeWeightedAverage: fun("0x1dccd830", {"queries": p.array(p.struct({"variable": p.uint8, "secs": p.uint256, "ago": p.uint256}))}, p.array(p.uint256)), + getTotalSamples: fun("0xb48b5b40", {}, p.uint256), + getVault: fun("0x8d928af8", {}, p.address), + increaseApproval: fun("0xd73dd623", {"spender": p.address, "amount": p.uint256}, p.bool), + name: fun("0x06fdde03", {}, p.string), + nonces: fun("0x7ecebe00", {"owner": p.address}, p.uint256), + onExitPool: fun("0x74f3b009", {"poolId": p.bytes32, "sender": p.address, "recipient": p.address, "balances": p.array(p.uint256), "lastChangeBlock": p.uint256, "protocolSwapFeePercentage": p.uint256, "userData": p.bytes}, {"_0": p.array(p.uint256), "_1": p.array(p.uint256)}), + onJoinPool: fun("0xd5c096c4", {"poolId": p.bytes32, "sender": p.address, "recipient": p.address, "balances": p.array(p.uint256), "lastChangeBlock": p.uint256, "protocolSwapFeePercentage": p.uint256, "userData": p.bytes}, {"amountsIn": p.array(p.uint256), "dueProtocolFeeAmounts": p.array(p.uint256)}), + onSwap: fun("0x9d2c110c", {"request": p.struct({"kind": p.uint8, "tokenIn": p.address, "tokenOut": p.address, "amount": p.uint256, "poolId": p.bytes32, "lastChangeBlock": p.uint256, "from": p.address, "to": p.address, "userData": p.bytes}), "balanceTokenIn": p.uint256, "balanceTokenOut": p.uint256}, p.uint256), + permit: fun("0xd505accf", {"owner": p.address, "spender": p.address, "value": p.uint256, "deadline": p.uint256, "v": p.uint8, "r": p.bytes32, "s": p.bytes32}, ), + queryExit: fun("0x6028bfd4", {"poolId": p.bytes32, "sender": p.address, "recipient": p.address, "balances": p.array(p.uint256), "lastChangeBlock": p.uint256, "protocolSwapFeePercentage": p.uint256, "userData": p.bytes}, {"bptIn": p.uint256, "amountsOut": p.array(p.uint256)}), + queryJoin: fun("0x87ec6817", {"poolId": p.bytes32, "sender": p.address, "recipient": p.address, "balances": p.array(p.uint256), "lastChangeBlock": p.uint256, "protocolSwapFeePercentage": p.uint256, "userData": p.bytes}, {"bptOut": p.uint256, "amountsIn": p.array(p.uint256)}), + setPaused: fun("0x16c38b3c", {"paused": p.bool}, ), + setSwapFeePercentage: fun("0x38e9922e", {"swapFeePercentage": p.uint256}, ), + symbol: fun("0x95d89b41", {}, p.string), + totalSupply: fun("0x18160ddd", {}, p.uint256), + transfer: fun("0xa9059cbb", {"recipient": p.address, "amount": p.uint256}, p.bool), + transferFrom: fun("0x23b872dd", {"sender": p.address, "recipient": p.address, "amount": p.uint256}, p.bool), } export class Contract extends ContractBase { - DOMAIN_SEPARATOR(): Promise { - return this.eth_call(functions.DOMAIN_SEPARATOR, []) + DOMAIN_SEPARATOR() { + return this.eth_call(functions.DOMAIN_SEPARATOR, {}) } - allowance(owner: string, spender: string): Promise { - return this.eth_call(functions.allowance, [owner, spender]) + allowance(owner: AllowanceParams["owner"], spender: AllowanceParams["spender"]) { + return this.eth_call(functions.allowance, {owner, spender}) } - balanceOf(account: string): Promise { - return this.eth_call(functions.balanceOf, [account]) + balanceOf(account: BalanceOfParams["account"]) { + return this.eth_call(functions.balanceOf, {account}) } - decimals(): Promise { - return this.eth_call(functions.decimals, []) + decimals() { + return this.eth_call(functions.decimals, {}) } - getActionId(selector: string): Promise { - return this.eth_call(functions.getActionId, [selector]) + getActionId(selector: GetActionIdParams["selector"]) { + return this.eth_call(functions.getActionId, {selector}) } - getAuthorizer(): Promise { - return this.eth_call(functions.getAuthorizer, []) + getAuthorizer() { + return this.eth_call(functions.getAuthorizer, {}) } - getInvariant(): Promise { - return this.eth_call(functions.getInvariant, []) + getInvariant() { + return this.eth_call(functions.getInvariant, {}) } - getLargestSafeQueryWindow(): Promise { - return this.eth_call(functions.getLargestSafeQueryWindow, []) + getLargestSafeQueryWindow() { + return this.eth_call(functions.getLargestSafeQueryWindow, {}) } - getLastInvariant(): Promise { - return this.eth_call(functions.getLastInvariant, []) + getLastInvariant() { + return this.eth_call(functions.getLastInvariant, {}) } - getLatest(variable: number): Promise { - return this.eth_call(functions.getLatest, [variable]) + getLatest(variable: GetLatestParams["variable"]) { + return this.eth_call(functions.getLatest, {variable}) } - getMiscData(): Promise<([logInvariant: bigint, logTotalSupply: bigint, oracleSampleCreationTimestamp: bigint, oracleIndex: bigint, oracleEnabled: boolean, swapFeePercentage: bigint] & {logInvariant: bigint, logTotalSupply: bigint, oracleSampleCreationTimestamp: bigint, oracleIndex: bigint, oracleEnabled: boolean, swapFeePercentage: bigint})> { - return this.eth_call(functions.getMiscData, []) + getMiscData() { + return this.eth_call(functions.getMiscData, {}) } - getNormalizedWeights(): Promise> { - return this.eth_call(functions.getNormalizedWeights, []) + getNormalizedWeights() { + return this.eth_call(functions.getNormalizedWeights, {}) } - getOwner(): Promise { - return this.eth_call(functions.getOwner, []) + getOwner() { + return this.eth_call(functions.getOwner, {}) } - getPastAccumulators(queries: Array<([variable: number, ago: bigint] & {variable: number, ago: bigint})>): Promise> { - return this.eth_call(functions.getPastAccumulators, [queries]) + getPastAccumulators(queries: GetPastAccumulatorsParams["queries"]) { + return this.eth_call(functions.getPastAccumulators, {queries}) } - getPausedState(): Promise<([paused: boolean, pauseWindowEndTime: bigint, bufferPeriodEndTime: bigint] & {paused: boolean, pauseWindowEndTime: bigint, bufferPeriodEndTime: bigint})> { - return this.eth_call(functions.getPausedState, []) + getPausedState() { + return this.eth_call(functions.getPausedState, {}) } - getPoolId(): Promise { - return this.eth_call(functions.getPoolId, []) + getPoolId() { + return this.eth_call(functions.getPoolId, {}) } - getRate(): Promise { - return this.eth_call(functions.getRate, []) + getRate() { + return this.eth_call(functions.getRate, {}) } - getSample(index: bigint): Promise<([logPairPrice: bigint, accLogPairPrice: bigint, logBptPrice: bigint, accLogBptPrice: bigint, logInvariant: bigint, accLogInvariant: bigint, timestamp: bigint] & {logPairPrice: bigint, accLogPairPrice: bigint, logBptPrice: bigint, accLogBptPrice: bigint, logInvariant: bigint, accLogInvariant: bigint, timestamp: bigint})> { - return this.eth_call(functions.getSample, [index]) + getSample(index: GetSampleParams["index"]) { + return this.eth_call(functions.getSample, {index}) } - getSwapFeePercentage(): Promise { - return this.eth_call(functions.getSwapFeePercentage, []) + getSwapFeePercentage() { + return this.eth_call(functions.getSwapFeePercentage, {}) } - getTimeWeightedAverage(queries: Array<([variable: number, secs: bigint, ago: bigint] & {variable: number, secs: bigint, ago: bigint})>): Promise> { - return this.eth_call(functions.getTimeWeightedAverage, [queries]) + getTimeWeightedAverage(queries: GetTimeWeightedAverageParams["queries"]) { + return this.eth_call(functions.getTimeWeightedAverage, {queries}) } - getTotalSamples(): Promise { - return this.eth_call(functions.getTotalSamples, []) + getTotalSamples() { + return this.eth_call(functions.getTotalSamples, {}) } - getVault(): Promise { - return this.eth_call(functions.getVault, []) + getVault() { + return this.eth_call(functions.getVault, {}) } - name(): Promise { - return this.eth_call(functions.name, []) + name() { + return this.eth_call(functions.name, {}) } - nonces(owner: string): Promise { - return this.eth_call(functions.nonces, [owner]) + nonces(owner: NoncesParams["owner"]) { + return this.eth_call(functions.nonces, {owner}) } - symbol(): Promise { - return this.eth_call(functions.symbol, []) + symbol() { + return this.eth_call(functions.symbol, {}) } - totalSupply(): Promise { - return this.eth_call(functions.totalSupply, []) + totalSupply() { + return this.eth_call(functions.totalSupply, {}) } } + +/// Event types +export type ApprovalEventArgs = EParams +export type OracleEnabledChangedEventArgs = EParams +export type PausedStateChangedEventArgs = EParams +export type SwapFeePercentageChangedEventArgs = EParams +export type TransferEventArgs = EParams + +/// Function types +export type DOMAIN_SEPARATORParams = FunctionArguments +export type DOMAIN_SEPARATORReturn = FunctionReturn + +export type AllowanceParams = FunctionArguments +export type AllowanceReturn = FunctionReturn + +export type ApproveParams = FunctionArguments +export type ApproveReturn = FunctionReturn + +export type BalanceOfParams = FunctionArguments +export type BalanceOfReturn = FunctionReturn + +export type DecimalsParams = FunctionArguments +export type DecimalsReturn = FunctionReturn + +export type DecreaseApprovalParams = FunctionArguments +export type DecreaseApprovalReturn = FunctionReturn + +export type EnableOracleParams = FunctionArguments +export type EnableOracleReturn = FunctionReturn + +export type GetActionIdParams = FunctionArguments +export type GetActionIdReturn = FunctionReturn + +export type GetAuthorizerParams = FunctionArguments +export type GetAuthorizerReturn = FunctionReturn + +export type GetInvariantParams = FunctionArguments +export type GetInvariantReturn = FunctionReturn + +export type GetLargestSafeQueryWindowParams = FunctionArguments +export type GetLargestSafeQueryWindowReturn = FunctionReturn + +export type GetLastInvariantParams = FunctionArguments +export type GetLastInvariantReturn = FunctionReturn + +export type GetLatestParams = FunctionArguments +export type GetLatestReturn = FunctionReturn + +export type GetMiscDataParams = FunctionArguments +export type GetMiscDataReturn = FunctionReturn + +export type GetNormalizedWeightsParams = FunctionArguments +export type GetNormalizedWeightsReturn = FunctionReturn + +export type GetOwnerParams = FunctionArguments +export type GetOwnerReturn = FunctionReturn + +export type GetPastAccumulatorsParams = FunctionArguments +export type GetPastAccumulatorsReturn = FunctionReturn + +export type GetPausedStateParams = FunctionArguments +export type GetPausedStateReturn = FunctionReturn + +export type GetPoolIdParams = FunctionArguments +export type GetPoolIdReturn = FunctionReturn + +export type GetRateParams = FunctionArguments +export type GetRateReturn = FunctionReturn + +export type GetSampleParams = FunctionArguments +export type GetSampleReturn = FunctionReturn + +export type GetSwapFeePercentageParams = FunctionArguments +export type GetSwapFeePercentageReturn = FunctionReturn + +export type GetTimeWeightedAverageParams = FunctionArguments +export type GetTimeWeightedAverageReturn = FunctionReturn + +export type GetTotalSamplesParams = FunctionArguments +export type GetTotalSamplesReturn = FunctionReturn + +export type GetVaultParams = FunctionArguments +export type GetVaultReturn = FunctionReturn + +export type IncreaseApprovalParams = FunctionArguments +export type IncreaseApprovalReturn = FunctionReturn + +export type NameParams = FunctionArguments +export type NameReturn = FunctionReturn + +export type NoncesParams = FunctionArguments +export type NoncesReturn = FunctionReturn + +export type OnExitPoolParams = FunctionArguments +export type OnExitPoolReturn = FunctionReturn + +export type OnJoinPoolParams = FunctionArguments +export type OnJoinPoolReturn = FunctionReturn + +export type OnSwapParams = FunctionArguments +export type OnSwapReturn = FunctionReturn + +export type PermitParams = FunctionArguments +export type PermitReturn = FunctionReturn + +export type QueryExitParams = FunctionArguments +export type QueryExitReturn = FunctionReturn + +export type QueryJoinParams = FunctionArguments +export type QueryJoinReturn = FunctionReturn + +export type SetPausedParams = FunctionArguments +export type SetPausedReturn = FunctionReturn + +export type SetSwapFeePercentageParams = FunctionArguments +export type SetSwapFeePercentageReturn = FunctionReturn + +export type SymbolParams = FunctionArguments +export type SymbolReturn = FunctionReturn + +export type TotalSupplyParams = FunctionArguments +export type TotalSupplyReturn = FunctionReturn + +export type TransferParams = FunctionArguments +export type TransferReturn = FunctionReturn + +export type TransferFromParams = FunctionArguments +export type TransferFromReturn = FunctionReturn + diff --git a/src/abi/base-reward-pool-4626.ts b/src/abi/base-reward-pool-4626.ts index 7b8e5821..e6efa7c3 100644 --- a/src/abi/base-reward-pool-4626.ts +++ b/src/abi/base-reward-pool-4626.ts @@ -1,371 +1,424 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './base-reward-pool-4626.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - Approval: new LogEvent<([owner: string, spender: string, value: bigint] & {owner: string, spender: string, value: bigint})>( - abi, '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925' - ), - Deposit: new LogEvent<([caller: string, owner: string, assets: bigint, shares: bigint] & {caller: string, owner: string, assets: bigint, shares: bigint})>( - abi, '0xdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7' - ), - RewardAdded: new LogEvent<([reward: bigint] & {reward: bigint})>( - abi, '0xde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d' - ), - RewardPaid: new LogEvent<([user: string, reward: bigint] & {user: string, reward: bigint})>( - abi, '0xe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486' - ), - Staked: new LogEvent<([user: string, amount: bigint] & {user: string, amount: bigint})>( - abi, '0x9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d' - ), - Transfer: new LogEvent<([from: string, to: string, value: bigint] & {from: string, to: string, value: bigint})>( - abi, '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' - ), - Withdraw: new LogEvent<([caller: string, receiver: string, owner: string, assets: bigint, shares: bigint] & {caller: string, receiver: string, owner: string, assets: bigint, shares: bigint})>( - abi, '0xfbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db' - ), - Withdrawn: new LogEvent<([user: string, amount: bigint] & {user: string, amount: bigint})>( - abi, '0x7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5' - ), + Approval: event("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", {"owner": indexed(p.address), "spender": indexed(p.address), "value": p.uint256}), + Deposit: event("0xdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7", {"caller": indexed(p.address), "owner": indexed(p.address), "assets": p.uint256, "shares": p.uint256}), + RewardAdded: event("0xde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d", {"reward": p.uint256}), + RewardPaid: event("0xe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486", {"user": indexed(p.address), "reward": p.uint256}), + Staked: event("0x9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d", {"user": indexed(p.address), "amount": p.uint256}), + Transfer: event("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", {"from": indexed(p.address), "to": indexed(p.address), "value": p.uint256}), + Withdraw: event("0xfbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db", {"caller": indexed(p.address), "receiver": indexed(p.address), "owner": indexed(p.address), "assets": p.uint256, "shares": p.uint256}), + Withdrawn: event("0x7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5", {"user": indexed(p.address), "amount": p.uint256}), } export const functions = { - addExtraReward: new Func<[_reward: string], {_reward: string}, boolean>( - abi, '0x5e43c47b' - ), - allowance: new Func<[owner: string, spender: string], {owner: string, spender: string}, bigint>( - abi, '0xdd62ed3e' - ), - approve: new Func<[spender: string, amount: bigint], {spender: string, amount: bigint}, boolean>( - abi, '0x095ea7b3' - ), - asset: new Func<[], {}, string>( - abi, '0x38d52e0f' - ), - balanceOf: new Func<[account: string], {account: string}, bigint>( - abi, '0x70a08231' - ), - clearExtraRewards: new Func<[], {}, []>( - abi, '0x0569d388' - ), - convertToAssets: new Func<[shares: bigint], {shares: bigint}, bigint>( - abi, '0x07a2d13a' - ), - convertToShares: new Func<[assets: bigint], {assets: bigint}, bigint>( - abi, '0xc6e6f592' - ), - currentRewards: new Func<[], {}, bigint>( - abi, '0x901a7d53' - ), - decimals: new Func<[], {}, number>( - abi, '0x313ce567' - ), - deposit: new Func<[assets: bigint, receiver: string], {assets: bigint, receiver: string}, bigint>( - abi, '0x6e553f65' - ), - duration: new Func<[], {}, bigint>( - abi, '0x0fb5a6b4' - ), - earned: new Func<[account: string], {account: string}, bigint>( - abi, '0x008cc262' - ), - extraRewards: new Func<[_: bigint], {}, string>( - abi, '0x40c35446' - ), - extraRewardsLength: new Func<[], {}, bigint>( - abi, '0xd55a23f4' - ), - 'getReward()': new Func<[], {}, boolean>( - abi, '0x3d18b912' - ), - 'getReward(address,bool)': new Func<[_account: string, _claimExtras: boolean], {_account: string, _claimExtras: boolean}, boolean>( - abi, '0x7050ccd9' - ), - historicalRewards: new Func<[], {}, bigint>( - abi, '0x262d3d6d' - ), - lastTimeRewardApplicable: new Func<[], {}, bigint>( - abi, '0x80faa57d' - ), - lastUpdateTime: new Func<[], {}, bigint>( - abi, '0xc8f33c91' - ), - maxDeposit: new Func<[_: string], {}, bigint>( - abi, '0x402d267d' - ), - maxMint: new Func<[owner: string], {owner: string}, bigint>( - abi, '0xc63d75b6' - ), - maxRedeem: new Func<[owner: string], {owner: string}, bigint>( - abi, '0xd905777e' - ), - maxWithdraw: new Func<[owner: string], {owner: string}, bigint>( - abi, '0xce96cb77' - ), - mint: new Func<[shares: bigint, receiver: string], {shares: bigint, receiver: string}, bigint>( - abi, '0x94bf804d' - ), - name: new Func<[], {}, string>( - abi, '0x06fdde03' - ), - newRewardRatio: new Func<[], {}, bigint>( - abi, '0x6c8bcee8' - ), - operator: new Func<[], {}, string>( - abi, '0x570ca735' - ), - periodFinish: new Func<[], {}, bigint>( - abi, '0xebe2b12b' - ), - pid: new Func<[], {}, bigint>( - abi, '0xf1068454' - ), - previewDeposit: new Func<[assets: bigint], {assets: bigint}, bigint>( - abi, '0xef8b30f7' - ), - previewMint: new Func<[shares: bigint], {shares: bigint}, bigint>( - abi, '0xb3d7f6b9' - ), - previewRedeem: new Func<[shares: bigint], {shares: bigint}, bigint>( - abi, '0x4cdad506' - ), - previewWithdraw: new Func<[assets: bigint], {assets: bigint}, bigint>( - abi, '0x0a28a477' - ), - processIdleRewards: new Func<[], {}, []>( - abi, '0x3e8b83e3' - ), - queueNewRewards: new Func<[_rewards: bigint], {_rewards: bigint}, boolean>( - abi, '0x590a41f5' - ), - queuedRewards: new Func<[], {}, bigint>( - abi, '0x63d38c3b' - ), - redeem: new Func<[shares: bigint, receiver: string, owner: string], {shares: bigint, receiver: string, owner: string}, bigint>( - abi, '0xba087652' - ), - rewardManager: new Func<[], {}, string>( - abi, '0x0f4ef8a6' - ), - rewardPerToken: new Func<[], {}, bigint>( - abi, '0xcd3daf9d' - ), - rewardPerTokenStored: new Func<[], {}, bigint>( - abi, '0xdf136d65' - ), - rewardRate: new Func<[], {}, bigint>( - abi, '0x7b0a47ee' - ), - rewardToken: new Func<[], {}, string>( - abi, '0xf7c618c1' - ), - rewards: new Func<[_: string], {}, bigint>( - abi, '0x0700037d' - ), - stake: new Func<[_amount: bigint], {_amount: bigint}, boolean>( - abi, '0xa694fc3a' - ), - stakeAll: new Func<[], {}, boolean>( - abi, '0x8dcb4061' - ), - stakeFor: new Func<[_for: string, _amount: bigint], {_for: string, _amount: bigint}, boolean>( - abi, '0x2ee40908' - ), - stakingToken: new Func<[], {}, string>( - abi, '0x72f702f3' - ), - symbol: new Func<[], {}, string>( - abi, '0x95d89b41' - ), - totalAssets: new Func<[], {}, bigint>( - abi, '0x01e1d114' - ), - totalSupply: new Func<[], {}, bigint>( - abi, '0x18160ddd' - ), - transfer: new Func<[_: string, _: bigint], {}, boolean>( - abi, '0xa9059cbb' - ), - transferFrom: new Func<[_: string, _: string, _: bigint], {}, boolean>( - abi, '0x23b872dd' - ), - userRewardPerTokenPaid: new Func<[_: string], {}, bigint>( - abi, '0x8b876347' - ), - 'withdraw(uint256,bool)': new Func<[amount: bigint, claim: boolean], {amount: bigint, claim: boolean}, boolean>( - abi, '0x38d07436' - ), - 'withdraw(uint256,address,address)': new Func<[assets: bigint, receiver: string, owner: string], {assets: bigint, receiver: string, owner: string}, bigint>( - abi, '0xb460af94' - ), - withdrawAll: new Func<[claim: boolean], {claim: boolean}, []>( - abi, '0x1c1c6fe5' - ), - withdrawAllAndUnwrap: new Func<[claim: boolean], {claim: boolean}, []>( - abi, '0x49f039a2' - ), - withdrawAndUnwrap: new Func<[amount: bigint, claim: boolean], {amount: bigint, claim: boolean}, boolean>( - abi, '0xc32e7202' - ), + addExtraReward: fun("0x5e43c47b", {"_reward": p.address}, p.bool), + allowance: fun("0xdd62ed3e", {"owner": p.address, "spender": p.address}, p.uint256), + approve: fun("0x095ea7b3", {"spender": p.address, "amount": p.uint256}, p.bool), + asset: fun("0x38d52e0f", {}, p.address), + balanceOf: fun("0x70a08231", {"account": p.address}, p.uint256), + clearExtraRewards: fun("0x0569d388", {}, ), + convertToAssets: fun("0x07a2d13a", {"shares": p.uint256}, p.uint256), + convertToShares: fun("0xc6e6f592", {"assets": p.uint256}, p.uint256), + currentRewards: fun("0x901a7d53", {}, p.uint256), + decimals: fun("0x313ce567", {}, p.uint8), + deposit: fun("0x6e553f65", {"assets": p.uint256, "receiver": p.address}, p.uint256), + duration: fun("0x0fb5a6b4", {}, p.uint256), + earned: fun("0x008cc262", {"account": p.address}, p.uint256), + extraRewards: fun("0x40c35446", {"_0": p.uint256}, p.address), + extraRewardsLength: fun("0xd55a23f4", {}, p.uint256), + "getReward()": fun("0x3d18b912", {}, p.bool), + "getReward(address,bool)": fun("0x7050ccd9", {"_account": p.address, "_claimExtras": p.bool}, p.bool), + historicalRewards: fun("0x262d3d6d", {}, p.uint256), + lastTimeRewardApplicable: fun("0x80faa57d", {}, p.uint256), + lastUpdateTime: fun("0xc8f33c91", {}, p.uint256), + maxDeposit: fun("0x402d267d", {"_0": p.address}, p.uint256), + maxMint: fun("0xc63d75b6", {"owner": p.address}, p.uint256), + maxRedeem: fun("0xd905777e", {"owner": p.address}, p.uint256), + maxWithdraw: fun("0xce96cb77", {"owner": p.address}, p.uint256), + mint: fun("0x94bf804d", {"shares": p.uint256, "receiver": p.address}, p.uint256), + name: fun("0x06fdde03", {}, p.string), + newRewardRatio: fun("0x6c8bcee8", {}, p.uint256), + operator: fun("0x570ca735", {}, p.address), + periodFinish: fun("0xebe2b12b", {}, p.uint256), + pid: fun("0xf1068454", {}, p.uint256), + previewDeposit: fun("0xef8b30f7", {"assets": p.uint256}, p.uint256), + previewMint: fun("0xb3d7f6b9", {"shares": p.uint256}, p.uint256), + previewRedeem: fun("0x4cdad506", {"shares": p.uint256}, p.uint256), + previewWithdraw: fun("0x0a28a477", {"assets": p.uint256}, p.uint256), + processIdleRewards: fun("0x3e8b83e3", {}, ), + queueNewRewards: fun("0x590a41f5", {"_rewards": p.uint256}, p.bool), + queuedRewards: fun("0x63d38c3b", {}, p.uint256), + redeem: fun("0xba087652", {"shares": p.uint256, "receiver": p.address, "owner": p.address}, p.uint256), + rewardManager: fun("0x0f4ef8a6", {}, p.address), + rewardPerToken: fun("0xcd3daf9d", {}, p.uint256), + rewardPerTokenStored: fun("0xdf136d65", {}, p.uint256), + rewardRate: fun("0x7b0a47ee", {}, p.uint256), + rewardToken: fun("0xf7c618c1", {}, p.address), + rewards: fun("0x0700037d", {"_0": p.address}, p.uint256), + stake: fun("0xa694fc3a", {"_amount": p.uint256}, p.bool), + stakeAll: fun("0x8dcb4061", {}, p.bool), + stakeFor: fun("0x2ee40908", {"_for": p.address, "_amount": p.uint256}, p.bool), + stakingToken: fun("0x72f702f3", {}, p.address), + symbol: fun("0x95d89b41", {}, p.string), + totalAssets: fun("0x01e1d114", {}, p.uint256), + totalSupply: fun("0x18160ddd", {}, p.uint256), + transfer: fun("0xa9059cbb", {"_0": p.address, "_1": p.uint256}, p.bool), + transferFrom: fun("0x23b872dd", {"_0": p.address, "_1": p.address, "_2": p.uint256}, p.bool), + userRewardPerTokenPaid: fun("0x8b876347", {"_0": p.address}, p.uint256), + "withdraw(uint256,bool)": fun("0x38d07436", {"amount": p.uint256, "claim": p.bool}, p.bool), + "withdraw(uint256,address,address)": fun("0xb460af94", {"assets": p.uint256, "receiver": p.address, "owner": p.address}, p.uint256), + withdrawAll: fun("0x1c1c6fe5", {"claim": p.bool}, ), + withdrawAllAndUnwrap: fun("0x49f039a2", {"claim": p.bool}, ), + withdrawAndUnwrap: fun("0xc32e7202", {"amount": p.uint256, "claim": p.bool}, p.bool), } export class Contract extends ContractBase { - allowance(owner: string, spender: string): Promise { - return this.eth_call(functions.allowance, [owner, spender]) + allowance(owner: AllowanceParams["owner"], spender: AllowanceParams["spender"]) { + return this.eth_call(functions.allowance, {owner, spender}) } - asset(): Promise { - return this.eth_call(functions.asset, []) + asset() { + return this.eth_call(functions.asset, {}) } - balanceOf(account: string): Promise { - return this.eth_call(functions.balanceOf, [account]) + balanceOf(account: BalanceOfParams["account"]) { + return this.eth_call(functions.balanceOf, {account}) } - convertToAssets(shares: bigint): Promise { - return this.eth_call(functions.convertToAssets, [shares]) + convertToAssets(shares: ConvertToAssetsParams["shares"]) { + return this.eth_call(functions.convertToAssets, {shares}) } - convertToShares(assets: bigint): Promise { - return this.eth_call(functions.convertToShares, [assets]) + convertToShares(assets: ConvertToSharesParams["assets"]) { + return this.eth_call(functions.convertToShares, {assets}) } - currentRewards(): Promise { - return this.eth_call(functions.currentRewards, []) + currentRewards() { + return this.eth_call(functions.currentRewards, {}) } - decimals(): Promise { - return this.eth_call(functions.decimals, []) + decimals() { + return this.eth_call(functions.decimals, {}) } - duration(): Promise { - return this.eth_call(functions.duration, []) + duration() { + return this.eth_call(functions.duration, {}) } - earned(account: string): Promise { - return this.eth_call(functions.earned, [account]) + earned(account: EarnedParams["account"]) { + return this.eth_call(functions.earned, {account}) } - extraRewards(arg0: bigint): Promise { - return this.eth_call(functions.extraRewards, [arg0]) + extraRewards(_0: ExtraRewardsParams["_0"]) { + return this.eth_call(functions.extraRewards, {_0}) } - extraRewardsLength(): Promise { - return this.eth_call(functions.extraRewardsLength, []) + extraRewardsLength() { + return this.eth_call(functions.extraRewardsLength, {}) } - historicalRewards(): Promise { - return this.eth_call(functions.historicalRewards, []) + historicalRewards() { + return this.eth_call(functions.historicalRewards, {}) } - lastTimeRewardApplicable(): Promise { - return this.eth_call(functions.lastTimeRewardApplicable, []) + lastTimeRewardApplicable() { + return this.eth_call(functions.lastTimeRewardApplicable, {}) } - lastUpdateTime(): Promise { - return this.eth_call(functions.lastUpdateTime, []) + lastUpdateTime() { + return this.eth_call(functions.lastUpdateTime, {}) } - maxDeposit(arg0: string): Promise { - return this.eth_call(functions.maxDeposit, [arg0]) + maxDeposit(_0: MaxDepositParams["_0"]) { + return this.eth_call(functions.maxDeposit, {_0}) } - maxMint(owner: string): Promise { - return this.eth_call(functions.maxMint, [owner]) + maxMint(owner: MaxMintParams["owner"]) { + return this.eth_call(functions.maxMint, {owner}) } - maxRedeem(owner: string): Promise { - return this.eth_call(functions.maxRedeem, [owner]) + maxRedeem(owner: MaxRedeemParams["owner"]) { + return this.eth_call(functions.maxRedeem, {owner}) } - maxWithdraw(owner: string): Promise { - return this.eth_call(functions.maxWithdraw, [owner]) + maxWithdraw(owner: MaxWithdrawParams["owner"]) { + return this.eth_call(functions.maxWithdraw, {owner}) } - name(): Promise { - return this.eth_call(functions.name, []) + name() { + return this.eth_call(functions.name, {}) } - newRewardRatio(): Promise { - return this.eth_call(functions.newRewardRatio, []) + newRewardRatio() { + return this.eth_call(functions.newRewardRatio, {}) } - operator(): Promise { - return this.eth_call(functions.operator, []) + operator() { + return this.eth_call(functions.operator, {}) } - periodFinish(): Promise { - return this.eth_call(functions.periodFinish, []) + periodFinish() { + return this.eth_call(functions.periodFinish, {}) } - pid(): Promise { - return this.eth_call(functions.pid, []) + pid() { + return this.eth_call(functions.pid, {}) } - previewDeposit(assets: bigint): Promise { - return this.eth_call(functions.previewDeposit, [assets]) + previewDeposit(assets: PreviewDepositParams["assets"]) { + return this.eth_call(functions.previewDeposit, {assets}) } - previewMint(shares: bigint): Promise { - return this.eth_call(functions.previewMint, [shares]) + previewMint(shares: PreviewMintParams["shares"]) { + return this.eth_call(functions.previewMint, {shares}) } - previewRedeem(shares: bigint): Promise { - return this.eth_call(functions.previewRedeem, [shares]) + previewRedeem(shares: PreviewRedeemParams["shares"]) { + return this.eth_call(functions.previewRedeem, {shares}) } - previewWithdraw(assets: bigint): Promise { - return this.eth_call(functions.previewWithdraw, [assets]) + previewWithdraw(assets: PreviewWithdrawParams["assets"]) { + return this.eth_call(functions.previewWithdraw, {assets}) } - queuedRewards(): Promise { - return this.eth_call(functions.queuedRewards, []) + queuedRewards() { + return this.eth_call(functions.queuedRewards, {}) } - rewardManager(): Promise { - return this.eth_call(functions.rewardManager, []) + rewardManager() { + return this.eth_call(functions.rewardManager, {}) } - rewardPerToken(): Promise { - return this.eth_call(functions.rewardPerToken, []) + rewardPerToken() { + return this.eth_call(functions.rewardPerToken, {}) } - rewardPerTokenStored(): Promise { - return this.eth_call(functions.rewardPerTokenStored, []) + rewardPerTokenStored() { + return this.eth_call(functions.rewardPerTokenStored, {}) } - rewardRate(): Promise { - return this.eth_call(functions.rewardRate, []) + rewardRate() { + return this.eth_call(functions.rewardRate, {}) } - rewardToken(): Promise { - return this.eth_call(functions.rewardToken, []) + rewardToken() { + return this.eth_call(functions.rewardToken, {}) } - rewards(arg0: string): Promise { - return this.eth_call(functions.rewards, [arg0]) + rewards(_0: RewardsParams["_0"]) { + return this.eth_call(functions.rewards, {_0}) } - stakingToken(): Promise { - return this.eth_call(functions.stakingToken, []) + stakingToken() { + return this.eth_call(functions.stakingToken, {}) } - symbol(): Promise { - return this.eth_call(functions.symbol, []) + symbol() { + return this.eth_call(functions.symbol, {}) } - totalAssets(): Promise { - return this.eth_call(functions.totalAssets, []) + totalAssets() { + return this.eth_call(functions.totalAssets, {}) } - totalSupply(): Promise { - return this.eth_call(functions.totalSupply, []) + totalSupply() { + return this.eth_call(functions.totalSupply, {}) } - userRewardPerTokenPaid(arg0: string): Promise { - return this.eth_call(functions.userRewardPerTokenPaid, [arg0]) + userRewardPerTokenPaid(_0: UserRewardPerTokenPaidParams["_0"]) { + return this.eth_call(functions.userRewardPerTokenPaid, {_0}) } } + +/// Event types +export type ApprovalEventArgs = EParams +export type DepositEventArgs = EParams +export type RewardAddedEventArgs = EParams +export type RewardPaidEventArgs = EParams +export type StakedEventArgs = EParams +export type TransferEventArgs = EParams +export type WithdrawEventArgs = EParams +export type WithdrawnEventArgs = EParams + +/// Function types +export type AddExtraRewardParams = FunctionArguments +export type AddExtraRewardReturn = FunctionReturn + +export type AllowanceParams = FunctionArguments +export type AllowanceReturn = FunctionReturn + +export type ApproveParams = FunctionArguments +export type ApproveReturn = FunctionReturn + +export type AssetParams = FunctionArguments +export type AssetReturn = FunctionReturn + +export type BalanceOfParams = FunctionArguments +export type BalanceOfReturn = FunctionReturn + +export type ClearExtraRewardsParams = FunctionArguments +export type ClearExtraRewardsReturn = FunctionReturn + +export type ConvertToAssetsParams = FunctionArguments +export type ConvertToAssetsReturn = FunctionReturn + +export type ConvertToSharesParams = FunctionArguments +export type ConvertToSharesReturn = FunctionReturn + +export type CurrentRewardsParams = FunctionArguments +export type CurrentRewardsReturn = FunctionReturn + +export type DecimalsParams = FunctionArguments +export type DecimalsReturn = FunctionReturn + +export type DepositParams = FunctionArguments +export type DepositReturn = FunctionReturn + +export type DurationParams = FunctionArguments +export type DurationReturn = FunctionReturn + +export type EarnedParams = FunctionArguments +export type EarnedReturn = FunctionReturn + +export type ExtraRewardsParams = FunctionArguments +export type ExtraRewardsReturn = FunctionReturn + +export type ExtraRewardsLengthParams = FunctionArguments +export type ExtraRewardsLengthReturn = FunctionReturn + +export type GetRewardParams_0 = FunctionArguments +export type GetRewardReturn_0 = FunctionReturn + +export type GetRewardParams_1 = FunctionArguments +export type GetRewardReturn_1 = FunctionReturn + +export type HistoricalRewardsParams = FunctionArguments +export type HistoricalRewardsReturn = FunctionReturn + +export type LastTimeRewardApplicableParams = FunctionArguments +export type LastTimeRewardApplicableReturn = FunctionReturn + +export type LastUpdateTimeParams = FunctionArguments +export type LastUpdateTimeReturn = FunctionReturn + +export type MaxDepositParams = FunctionArguments +export type MaxDepositReturn = FunctionReturn + +export type MaxMintParams = FunctionArguments +export type MaxMintReturn = FunctionReturn + +export type MaxRedeemParams = FunctionArguments +export type MaxRedeemReturn = FunctionReturn + +export type MaxWithdrawParams = FunctionArguments +export type MaxWithdrawReturn = FunctionReturn + +export type MintParams = FunctionArguments +export type MintReturn = FunctionReturn + +export type NameParams = FunctionArguments +export type NameReturn = FunctionReturn + +export type NewRewardRatioParams = FunctionArguments +export type NewRewardRatioReturn = FunctionReturn + +export type OperatorParams = FunctionArguments +export type OperatorReturn = FunctionReturn + +export type PeriodFinishParams = FunctionArguments +export type PeriodFinishReturn = FunctionReturn + +export type PidParams = FunctionArguments +export type PidReturn = FunctionReturn + +export type PreviewDepositParams = FunctionArguments +export type PreviewDepositReturn = FunctionReturn + +export type PreviewMintParams = FunctionArguments +export type PreviewMintReturn = FunctionReturn + +export type PreviewRedeemParams = FunctionArguments +export type PreviewRedeemReturn = FunctionReturn + +export type PreviewWithdrawParams = FunctionArguments +export type PreviewWithdrawReturn = FunctionReturn + +export type ProcessIdleRewardsParams = FunctionArguments +export type ProcessIdleRewardsReturn = FunctionReturn + +export type QueueNewRewardsParams = FunctionArguments +export type QueueNewRewardsReturn = FunctionReturn + +export type QueuedRewardsParams = FunctionArguments +export type QueuedRewardsReturn = FunctionReturn + +export type RedeemParams = FunctionArguments +export type RedeemReturn = FunctionReturn + +export type RewardManagerParams = FunctionArguments +export type RewardManagerReturn = FunctionReturn + +export type RewardPerTokenParams = FunctionArguments +export type RewardPerTokenReturn = FunctionReturn + +export type RewardPerTokenStoredParams = FunctionArguments +export type RewardPerTokenStoredReturn = FunctionReturn + +export type RewardRateParams = FunctionArguments +export type RewardRateReturn = FunctionReturn + +export type RewardTokenParams = FunctionArguments +export type RewardTokenReturn = FunctionReturn + +export type RewardsParams = FunctionArguments +export type RewardsReturn = FunctionReturn + +export type StakeParams = FunctionArguments +export type StakeReturn = FunctionReturn + +export type StakeAllParams = FunctionArguments +export type StakeAllReturn = FunctionReturn + +export type StakeForParams = FunctionArguments +export type StakeForReturn = FunctionReturn + +export type StakingTokenParams = FunctionArguments +export type StakingTokenReturn = FunctionReturn + +export type SymbolParams = FunctionArguments +export type SymbolReturn = FunctionReturn + +export type TotalAssetsParams = FunctionArguments +export type TotalAssetsReturn = FunctionReturn + +export type TotalSupplyParams = FunctionArguments +export type TotalSupplyReturn = FunctionReturn + +export type TransferParams = FunctionArguments +export type TransferReturn = FunctionReturn + +export type TransferFromParams = FunctionArguments +export type TransferFromReturn = FunctionReturn + +export type UserRewardPerTokenPaidParams = FunctionArguments +export type UserRewardPerTokenPaidReturn = FunctionReturn + +export type WithdrawParams_0 = FunctionArguments +export type WithdrawReturn_0 = FunctionReturn + +export type WithdrawParams_1 = FunctionArguments +export type WithdrawReturn_1 = FunctionReturn + +export type WithdrawAllParams = FunctionArguments +export type WithdrawAllReturn = FunctionReturn + +export type WithdrawAllAndUnwrapParams = FunctionArguments +export type WithdrawAllAndUnwrapReturn = FunctionReturn + +export type WithdrawAndUnwrapParams = FunctionArguments +export type WithdrawAndUnwrapReturn = FunctionReturn + diff --git a/src/abi/base-reward-pool.ts b/src/abi/base-reward-pool.ts index ded5dd46..73c07f44 100644 --- a/src/abi/base-reward-pool.ts +++ b/src/abi/base-reward-pool.ts @@ -1,226 +1,260 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './base-reward-pool.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - RewardAdded: new LogEvent<([reward: bigint] & {reward: bigint})>( - abi, '0xde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d' - ), - RewardPaid: new LogEvent<([user: string, reward: bigint] & {user: string, reward: bigint})>( - abi, '0xe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486' - ), - Staked: new LogEvent<([user: string, amount: bigint] & {user: string, amount: bigint})>( - abi, '0x9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d' - ), - Withdrawn: new LogEvent<([user: string, amount: bigint] & {user: string, amount: bigint})>( - abi, '0x7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5' - ), + RewardAdded: event("0xde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d", {"reward": p.uint256}), + RewardPaid: event("0xe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486", {"user": indexed(p.address), "reward": p.uint256}), + Staked: event("0x9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d", {"user": indexed(p.address), "amount": p.uint256}), + Withdrawn: event("0x7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5", {"user": indexed(p.address), "amount": p.uint256}), } export const functions = { - addExtraReward: new Func<[_reward: string], {_reward: string}, boolean>( - abi, '0x5e43c47b' - ), - balanceOf: new Func<[account: string], {account: string}, bigint>( - abi, '0x70a08231' - ), - clearExtraRewards: new Func<[], {}, []>( - abi, '0x0569d388' - ), - currentRewards: new Func<[], {}, bigint>( - abi, '0x901a7d53' - ), - donate: new Func<[_amount: bigint], {_amount: bigint}, boolean>( - abi, '0xf14faf6f' - ), - duration: new Func<[], {}, bigint>( - abi, '0x0fb5a6b4' - ), - earned: new Func<[account: string], {account: string}, bigint>( - abi, '0x008cc262' - ), - extraRewards: new Func<[_: bigint], {}, string>( - abi, '0x40c35446' - ), - extraRewardsLength: new Func<[], {}, bigint>( - abi, '0xd55a23f4' - ), - 'getReward()': new Func<[], {}, boolean>( - abi, '0x3d18b912' - ), - 'getReward(address,bool)': new Func<[_account: string, _claimExtras: boolean], {_account: string, _claimExtras: boolean}, boolean>( - abi, '0x7050ccd9' - ), - historicalRewards: new Func<[], {}, bigint>( - abi, '0x262d3d6d' - ), - lastTimeRewardApplicable: new Func<[], {}, bigint>( - abi, '0x80faa57d' - ), - lastUpdateTime: new Func<[], {}, bigint>( - abi, '0xc8f33c91' - ), - newRewardRatio: new Func<[], {}, bigint>( - abi, '0x6c8bcee8' - ), - operator: new Func<[], {}, string>( - abi, '0x570ca735' - ), - periodFinish: new Func<[], {}, bigint>( - abi, '0xebe2b12b' - ), - pid: new Func<[], {}, bigint>( - abi, '0xf1068454' - ), - queueNewRewards: new Func<[_rewards: bigint], {_rewards: bigint}, boolean>( - abi, '0x590a41f5' - ), - queuedRewards: new Func<[], {}, bigint>( - abi, '0x63d38c3b' - ), - rewardManager: new Func<[], {}, string>( - abi, '0x0f4ef8a6' - ), - rewardPerToken: new Func<[], {}, bigint>( - abi, '0xcd3daf9d' - ), - rewardPerTokenStored: new Func<[], {}, bigint>( - abi, '0xdf136d65' - ), - rewardRate: new Func<[], {}, bigint>( - abi, '0x7b0a47ee' - ), - rewardToken: new Func<[], {}, string>( - abi, '0xf7c618c1' - ), - rewards: new Func<[_: string], {}, bigint>( - abi, '0x0700037d' - ), - stake: new Func<[_amount: bigint], {_amount: bigint}, boolean>( - abi, '0xa694fc3a' - ), - stakeAll: new Func<[], {}, boolean>( - abi, '0x8dcb4061' - ), - stakeFor: new Func<[_for: string, _amount: bigint], {_for: string, _amount: bigint}, boolean>( - abi, '0x2ee40908' - ), - stakingToken: new Func<[], {}, string>( - abi, '0x72f702f3' - ), - totalSupply: new Func<[], {}, bigint>( - abi, '0x18160ddd' - ), - userRewardPerTokenPaid: new Func<[_: string], {}, bigint>( - abi, '0x8b876347' - ), - withdraw: new Func<[amount: bigint, claim: boolean], {amount: bigint, claim: boolean}, boolean>( - abi, '0x38d07436' - ), - withdrawAll: new Func<[claim: boolean], {claim: boolean}, []>( - abi, '0x1c1c6fe5' - ), - withdrawAllAndUnwrap: new Func<[claim: boolean], {claim: boolean}, []>( - abi, '0x49f039a2' - ), - withdrawAndUnwrap: new Func<[amount: bigint, claim: boolean], {amount: bigint, claim: boolean}, boolean>( - abi, '0xc32e7202' - ), + addExtraReward: fun("0x5e43c47b", {"_reward": p.address}, p.bool), + balanceOf: fun("0x70a08231", {"account": p.address}, p.uint256), + clearExtraRewards: fun("0x0569d388", {}, ), + currentRewards: fun("0x901a7d53", {}, p.uint256), + donate: fun("0xf14faf6f", {"_amount": p.uint256}, p.bool), + duration: fun("0x0fb5a6b4", {}, p.uint256), + earned: fun("0x008cc262", {"account": p.address}, p.uint256), + extraRewards: fun("0x40c35446", {"_0": p.uint256}, p.address), + extraRewardsLength: fun("0xd55a23f4", {}, p.uint256), + "getReward()": fun("0x3d18b912", {}, p.bool), + "getReward(address,bool)": fun("0x7050ccd9", {"_account": p.address, "_claimExtras": p.bool}, p.bool), + historicalRewards: fun("0x262d3d6d", {}, p.uint256), + lastTimeRewardApplicable: fun("0x80faa57d", {}, p.uint256), + lastUpdateTime: fun("0xc8f33c91", {}, p.uint256), + newRewardRatio: fun("0x6c8bcee8", {}, p.uint256), + operator: fun("0x570ca735", {}, p.address), + periodFinish: fun("0xebe2b12b", {}, p.uint256), + pid: fun("0xf1068454", {}, p.uint256), + queueNewRewards: fun("0x590a41f5", {"_rewards": p.uint256}, p.bool), + queuedRewards: fun("0x63d38c3b", {}, p.uint256), + rewardManager: fun("0x0f4ef8a6", {}, p.address), + rewardPerToken: fun("0xcd3daf9d", {}, p.uint256), + rewardPerTokenStored: fun("0xdf136d65", {}, p.uint256), + rewardRate: fun("0x7b0a47ee", {}, p.uint256), + rewardToken: fun("0xf7c618c1", {}, p.address), + rewards: fun("0x0700037d", {"_0": p.address}, p.uint256), + stake: fun("0xa694fc3a", {"_amount": p.uint256}, p.bool), + stakeAll: fun("0x8dcb4061", {}, p.bool), + stakeFor: fun("0x2ee40908", {"_for": p.address, "_amount": p.uint256}, p.bool), + stakingToken: fun("0x72f702f3", {}, p.address), + totalSupply: fun("0x18160ddd", {}, p.uint256), + userRewardPerTokenPaid: fun("0x8b876347", {"_0": p.address}, p.uint256), + withdraw: fun("0x38d07436", {"amount": p.uint256, "claim": p.bool}, p.bool), + withdrawAll: fun("0x1c1c6fe5", {"claim": p.bool}, ), + withdrawAllAndUnwrap: fun("0x49f039a2", {"claim": p.bool}, ), + withdrawAndUnwrap: fun("0xc32e7202", {"amount": p.uint256, "claim": p.bool}, p.bool), } export class Contract extends ContractBase { - balanceOf(account: string): Promise { - return this.eth_call(functions.balanceOf, [account]) + balanceOf(account: BalanceOfParams["account"]) { + return this.eth_call(functions.balanceOf, {account}) } - currentRewards(): Promise { - return this.eth_call(functions.currentRewards, []) + currentRewards() { + return this.eth_call(functions.currentRewards, {}) } - duration(): Promise { - return this.eth_call(functions.duration, []) + duration() { + return this.eth_call(functions.duration, {}) } - earned(account: string): Promise { - return this.eth_call(functions.earned, [account]) + earned(account: EarnedParams["account"]) { + return this.eth_call(functions.earned, {account}) } - extraRewards(arg0: bigint): Promise { - return this.eth_call(functions.extraRewards, [arg0]) + extraRewards(_0: ExtraRewardsParams["_0"]) { + return this.eth_call(functions.extraRewards, {_0}) } - extraRewardsLength(): Promise { - return this.eth_call(functions.extraRewardsLength, []) + extraRewardsLength() { + return this.eth_call(functions.extraRewardsLength, {}) } - historicalRewards(): Promise { - return this.eth_call(functions.historicalRewards, []) + historicalRewards() { + return this.eth_call(functions.historicalRewards, {}) } - lastTimeRewardApplicable(): Promise { - return this.eth_call(functions.lastTimeRewardApplicable, []) + lastTimeRewardApplicable() { + return this.eth_call(functions.lastTimeRewardApplicable, {}) } - lastUpdateTime(): Promise { - return this.eth_call(functions.lastUpdateTime, []) + lastUpdateTime() { + return this.eth_call(functions.lastUpdateTime, {}) } - newRewardRatio(): Promise { - return this.eth_call(functions.newRewardRatio, []) + newRewardRatio() { + return this.eth_call(functions.newRewardRatio, {}) } - operator(): Promise { - return this.eth_call(functions.operator, []) + operator() { + return this.eth_call(functions.operator, {}) } - periodFinish(): Promise { - return this.eth_call(functions.periodFinish, []) + periodFinish() { + return this.eth_call(functions.periodFinish, {}) } - pid(): Promise { - return this.eth_call(functions.pid, []) + pid() { + return this.eth_call(functions.pid, {}) } - queuedRewards(): Promise { - return this.eth_call(functions.queuedRewards, []) + queuedRewards() { + return this.eth_call(functions.queuedRewards, {}) } - rewardManager(): Promise { - return this.eth_call(functions.rewardManager, []) + rewardManager() { + return this.eth_call(functions.rewardManager, {}) } - rewardPerToken(): Promise { - return this.eth_call(functions.rewardPerToken, []) + rewardPerToken() { + return this.eth_call(functions.rewardPerToken, {}) } - rewardPerTokenStored(): Promise { - return this.eth_call(functions.rewardPerTokenStored, []) + rewardPerTokenStored() { + return this.eth_call(functions.rewardPerTokenStored, {}) } - rewardRate(): Promise { - return this.eth_call(functions.rewardRate, []) + rewardRate() { + return this.eth_call(functions.rewardRate, {}) } - rewardToken(): Promise { - return this.eth_call(functions.rewardToken, []) + rewardToken() { + return this.eth_call(functions.rewardToken, {}) } - rewards(arg0: string): Promise { - return this.eth_call(functions.rewards, [arg0]) + rewards(_0: RewardsParams["_0"]) { + return this.eth_call(functions.rewards, {_0}) } - stakingToken(): Promise { - return this.eth_call(functions.stakingToken, []) + stakingToken() { + return this.eth_call(functions.stakingToken, {}) } - totalSupply(): Promise { - return this.eth_call(functions.totalSupply, []) + totalSupply() { + return this.eth_call(functions.totalSupply, {}) } - userRewardPerTokenPaid(arg0: string): Promise { - return this.eth_call(functions.userRewardPerTokenPaid, [arg0]) + userRewardPerTokenPaid(_0: UserRewardPerTokenPaidParams["_0"]) { + return this.eth_call(functions.userRewardPerTokenPaid, {_0}) } } + +/// Event types +export type RewardAddedEventArgs = EParams +export type RewardPaidEventArgs = EParams +export type StakedEventArgs = EParams +export type WithdrawnEventArgs = EParams + +/// Function types +export type AddExtraRewardParams = FunctionArguments +export type AddExtraRewardReturn = FunctionReturn + +export type BalanceOfParams = FunctionArguments +export type BalanceOfReturn = FunctionReturn + +export type ClearExtraRewardsParams = FunctionArguments +export type ClearExtraRewardsReturn = FunctionReturn + +export type CurrentRewardsParams = FunctionArguments +export type CurrentRewardsReturn = FunctionReturn + +export type DonateParams = FunctionArguments +export type DonateReturn = FunctionReturn + +export type DurationParams = FunctionArguments +export type DurationReturn = FunctionReturn + +export type EarnedParams = FunctionArguments +export type EarnedReturn = FunctionReturn + +export type ExtraRewardsParams = FunctionArguments +export type ExtraRewardsReturn = FunctionReturn + +export type ExtraRewardsLengthParams = FunctionArguments +export type ExtraRewardsLengthReturn = FunctionReturn + +export type GetRewardParams_0 = FunctionArguments +export type GetRewardReturn_0 = FunctionReturn + +export type GetRewardParams_1 = FunctionArguments +export type GetRewardReturn_1 = FunctionReturn + +export type HistoricalRewardsParams = FunctionArguments +export type HistoricalRewardsReturn = FunctionReturn + +export type LastTimeRewardApplicableParams = FunctionArguments +export type LastTimeRewardApplicableReturn = FunctionReturn + +export type LastUpdateTimeParams = FunctionArguments +export type LastUpdateTimeReturn = FunctionReturn + +export type NewRewardRatioParams = FunctionArguments +export type NewRewardRatioReturn = FunctionReturn + +export type OperatorParams = FunctionArguments +export type OperatorReturn = FunctionReturn + +export type PeriodFinishParams = FunctionArguments +export type PeriodFinishReturn = FunctionReturn + +export type PidParams = FunctionArguments +export type PidReturn = FunctionReturn + +export type QueueNewRewardsParams = FunctionArguments +export type QueueNewRewardsReturn = FunctionReturn + +export type QueuedRewardsParams = FunctionArguments +export type QueuedRewardsReturn = FunctionReturn + +export type RewardManagerParams = FunctionArguments +export type RewardManagerReturn = FunctionReturn + +export type RewardPerTokenParams = FunctionArguments +export type RewardPerTokenReturn = FunctionReturn + +export type RewardPerTokenStoredParams = FunctionArguments +export type RewardPerTokenStoredReturn = FunctionReturn + +export type RewardRateParams = FunctionArguments +export type RewardRateReturn = FunctionReturn + +export type RewardTokenParams = FunctionArguments +export type RewardTokenReturn = FunctionReturn + +export type RewardsParams = FunctionArguments +export type RewardsReturn = FunctionReturn + +export type StakeParams = FunctionArguments +export type StakeReturn = FunctionReturn + +export type StakeAllParams = FunctionArguments +export type StakeAllReturn = FunctionReturn + +export type StakeForParams = FunctionArguments +export type StakeForReturn = FunctionReturn + +export type StakingTokenParams = FunctionArguments +export type StakingTokenReturn = FunctionReturn + +export type TotalSupplyParams = FunctionArguments +export type TotalSupplyReturn = FunctionReturn + +export type UserRewardPerTokenPaidParams = FunctionArguments +export type UserRewardPerTokenPaidReturn = FunctionReturn + +export type WithdrawParams = FunctionArguments +export type WithdrawReturn = FunctionReturn + +export type WithdrawAllParams = FunctionArguments +export type WithdrawAllReturn = FunctionReturn + +export type WithdrawAllAndUnwrapParams = FunctionArguments +export type WithdrawAllAndUnwrapReturn = FunctionReturn + +export type WithdrawAndUnwrapParams = FunctionArguments +export type WithdrawAndUnwrapReturn = FunctionReturn + diff --git a/src/abi/ccip-evm2evmofframp.ts b/src/abi/ccip-evm2evmofframp.ts index 5ec06788..4500cc4f 100644 --- a/src/abi/ccip-evm2evmofframp.ts +++ b/src/abi/ccip-evm2evmofframp.ts @@ -1,189 +1,206 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './ccip-evm2evmofframp.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - AdminSet: new LogEvent<([newAdmin: string] & {newAdmin: string})>( - abi, '0x8fe72c3e0020beb3234e76ae6676fa576fbfcae600af1c4fea44784cf0db329c' - ), - 'ConfigSet((address,uint64,uint64,address,address,address),(uint32,address,address,uint16,uint32,uint32))': new LogEvent<([staticConfig: ([commitStore: string, chainSelector: bigint, sourceChainSelector: bigint, onRamp: string, prevOffRamp: string, armProxy: string] & {commitStore: string, chainSelector: bigint, sourceChainSelector: bigint, onRamp: string, prevOffRamp: string, armProxy: string}), dynamicConfig: ([permissionLessExecutionThresholdSeconds: number, router: string, priceRegistry: string, maxNumberOfTokensPerMsg: number, maxDataBytes: number, maxPoolReleaseOrMintGas: number] & {permissionLessExecutionThresholdSeconds: number, router: string, priceRegistry: string, maxNumberOfTokensPerMsg: number, maxDataBytes: number, maxPoolReleaseOrMintGas: number})] & {staticConfig: ([commitStore: string, chainSelector: bigint, sourceChainSelector: bigint, onRamp: string, prevOffRamp: string, armProxy: string] & {commitStore: string, chainSelector: bigint, sourceChainSelector: bigint, onRamp: string, prevOffRamp: string, armProxy: string}), dynamicConfig: ([permissionLessExecutionThresholdSeconds: number, router: string, priceRegistry: string, maxNumberOfTokensPerMsg: number, maxDataBytes: number, maxPoolReleaseOrMintGas: number] & {permissionLessExecutionThresholdSeconds: number, router: string, priceRegistry: string, maxNumberOfTokensPerMsg: number, maxDataBytes: number, maxPoolReleaseOrMintGas: number})})>( - abi, '0xe668e1a4644c1a030b909bbfd837f5cfa914994ed5e0bb2e9c34a5c37753128a' - ), - 'ConfigSet(uint32,bytes32,uint64,address[],address[],uint8,bytes,uint64,bytes)': new LogEvent<([previousConfigBlockNumber: number, configDigest: string, configCount: bigint, signers: Array, transmitters: Array, f: number, onchainConfig: string, offchainConfigVersion: bigint, offchainConfig: string] & {previousConfigBlockNumber: number, configDigest: string, configCount: bigint, signers: Array, transmitters: Array, f: number, onchainConfig: string, offchainConfigVersion: bigint, offchainConfig: string})>( - abi, '0x1591690b8638f5fb2dbec82ac741805ac5da8b45dc5263f4875b0496fdce4e05' - ), - ExecutionStateChanged: new LogEvent<([sequenceNumber: bigint, messageId: string, state: number, returnData: string] & {sequenceNumber: bigint, messageId: string, state: number, returnData: string})>( - abi, '0xd4f851956a5d67c3997d1c9205045fef79bae2947fdee7e9e2641abc7391ef65' - ), - OwnershipTransferRequested: new LogEvent<([from: string, to: string] & {from: string, to: string})>( - abi, '0xed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae1278' - ), - OwnershipTransferred: new LogEvent<([from: string, to: string] & {from: string, to: string})>( - abi, '0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0' - ), - PoolAdded: new LogEvent<([token: string, pool: string] & {token: string, pool: string})>( - abi, '0x95f865c2808f8b2a85eea2611db7843150ee7835ef1403f9755918a97d76933c' - ), - PoolRemoved: new LogEvent<([token: string, pool: string] & {token: string, pool: string})>( - abi, '0x987eb3c2f78454541205f72f34839b434c306c9eaf4922efd7c0c3060fdb2e4c' - ), - SkippedIncorrectNonce: new LogEvent<([nonce: bigint, sender: string] & {nonce: bigint, sender: string})>( - abi, '0xd32ddb11d71e3d63411d37b09f9a8b28664f1cb1338bfd1413c173b0ebf41237' - ), - SkippedSenderWithPreviousRampMessageInflight: new LogEvent<([nonce: bigint, sender: string] & {nonce: bigint, sender: string})>( - abi, '0xe44a20935573a783dd0d5991c92d7b6a0eb3173566530364db3ec10e9a990b5d' - ), - Transmitted: new LogEvent<([configDigest: string, epoch: number] & {configDigest: string, epoch: number})>( - abi, '0xb04e63db38c49950639fa09d29872f21f5d49d614f3a969d8adf3d4b52e41a62' - ), + AdminSet: event("0x8fe72c3e0020beb3234e76ae6676fa576fbfcae600af1c4fea44784cf0db329c", {"newAdmin": p.address}), + "ConfigSet((address,uint64,uint64,address,address,address),(uint32,address,address,uint16,uint32,uint32))": event("0xe668e1a4644c1a030b909bbfd837f5cfa914994ed5e0bb2e9c34a5c37753128a", {"staticConfig": p.struct({"commitStore": p.address, "chainSelector": p.uint64, "sourceChainSelector": p.uint64, "onRamp": p.address, "prevOffRamp": p.address, "armProxy": p.address}), "dynamicConfig": p.struct({"permissionLessExecutionThresholdSeconds": p.uint32, "router": p.address, "priceRegistry": p.address, "maxNumberOfTokensPerMsg": p.uint16, "maxDataBytes": p.uint32, "maxPoolReleaseOrMintGas": p.uint32})}), + "ConfigSet(uint32,bytes32,uint64,address[],address[],uint8,bytes,uint64,bytes)": event("0x1591690b8638f5fb2dbec82ac741805ac5da8b45dc5263f4875b0496fdce4e05", {"previousConfigBlockNumber": p.uint32, "configDigest": p.bytes32, "configCount": p.uint64, "signers": p.array(p.address), "transmitters": p.array(p.address), "f": p.uint8, "onchainConfig": p.bytes, "offchainConfigVersion": p.uint64, "offchainConfig": p.bytes}), + ExecutionStateChanged: event("0xd4f851956a5d67c3997d1c9205045fef79bae2947fdee7e9e2641abc7391ef65", {"sequenceNumber": indexed(p.uint64), "messageId": indexed(p.bytes32), "state": p.uint8, "returnData": p.bytes}), + OwnershipTransferRequested: event("0xed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae1278", {"from": indexed(p.address), "to": indexed(p.address)}), + OwnershipTransferred: event("0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", {"from": indexed(p.address), "to": indexed(p.address)}), + PoolAdded: event("0x95f865c2808f8b2a85eea2611db7843150ee7835ef1403f9755918a97d76933c", {"token": p.address, "pool": p.address}), + PoolRemoved: event("0x987eb3c2f78454541205f72f34839b434c306c9eaf4922efd7c0c3060fdb2e4c", {"token": p.address, "pool": p.address}), + SkippedIncorrectNonce: event("0xd32ddb11d71e3d63411d37b09f9a8b28664f1cb1338bfd1413c173b0ebf41237", {"nonce": indexed(p.uint64), "sender": indexed(p.address)}), + SkippedSenderWithPreviousRampMessageInflight: event("0xe44a20935573a783dd0d5991c92d7b6a0eb3173566530364db3ec10e9a990b5d", {"nonce": indexed(p.uint64), "sender": indexed(p.address)}), + Transmitted: event("0xb04e63db38c49950639fa09d29872f21f5d49d614f3a969d8adf3d4b52e41a62", {"configDigest": p.bytes32, "epoch": p.uint32}), } export const functions = { - acceptOwnership: new Func<[], {}, []>( - abi, '0x79ba5097' - ), - applyPoolUpdates: new Func<[removes: Array<([token: string, pool: string] & {token: string, pool: string})>, adds: Array<([token: string, pool: string] & {token: string, pool: string})>], {removes: Array<([token: string, pool: string] & {token: string, pool: string})>, adds: Array<([token: string, pool: string] & {token: string, pool: string})>}, []>( - abi, '0x3a87ac53' - ), - ccipReceive: new Func<[_: ([messageId: string, sourceChainSelector: bigint, sender: string, data: string, destTokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>] & {messageId: string, sourceChainSelector: bigint, sender: string, data: string, destTokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>})], {}, []>( - abi, '0x85572ffb' - ), - currentRateLimiterState: new Func<[], {}, ([tokens: bigint, lastUpdated: number, isEnabled: boolean, capacity: bigint, rate: bigint] & {tokens: bigint, lastUpdated: number, isEnabled: boolean, capacity: bigint, rate: bigint})>( - abi, '0x546719cd' - ), - executeSingleMessage: new Func<[message: ([sourceChainSelector: bigint, sender: string, receiver: string, sequenceNumber: bigint, gasLimit: bigint, strict: boolean, nonce: bigint, feeToken: string, feeTokenAmount: bigint, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, sourceTokenData: Array, messageId: string] & {sourceChainSelector: bigint, sender: string, receiver: string, sequenceNumber: bigint, gasLimit: bigint, strict: boolean, nonce: bigint, feeToken: string, feeTokenAmount: bigint, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, sourceTokenData: Array, messageId: string}), offchainTokenData: Array], {message: ([sourceChainSelector: bigint, sender: string, receiver: string, sequenceNumber: bigint, gasLimit: bigint, strict: boolean, nonce: bigint, feeToken: string, feeTokenAmount: bigint, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, sourceTokenData: Array, messageId: string] & {sourceChainSelector: bigint, sender: string, receiver: string, sequenceNumber: bigint, gasLimit: bigint, strict: boolean, nonce: bigint, feeToken: string, feeTokenAmount: bigint, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, sourceTokenData: Array, messageId: string}), offchainTokenData: Array}, []>( - abi, '0xf52121a5' - ), - getDestinationToken: new Func<[sourceToken: string], {sourceToken: string}, string>( - abi, '0xb4069b31' - ), - getDestinationTokens: new Func<[], {}, Array>( - abi, '0x681fba16' - ), - getDynamicConfig: new Func<[], {}, ([permissionLessExecutionThresholdSeconds: number, router: string, priceRegistry: string, maxNumberOfTokensPerMsg: number, maxDataBytes: number, maxPoolReleaseOrMintGas: number] & {permissionLessExecutionThresholdSeconds: number, router: string, priceRegistry: string, maxNumberOfTokensPerMsg: number, maxDataBytes: number, maxPoolReleaseOrMintGas: number})>( - abi, '0x7437ff9f' - ), - getExecutionState: new Func<[sequenceNumber: bigint], {sequenceNumber: bigint}, number>( - abi, '0x142a98fc' - ), - getPoolByDestToken: new Func<[destToken: string], {destToken: string}, string>( - abi, '0xd7e2bb50' - ), - getPoolBySourceToken: new Func<[sourceToken: string], {sourceToken: string}, string>( - abi, '0x5d86f141' - ), - getSenderNonce: new Func<[sender: string], {sender: string}, bigint>( - abi, '0x856c8247' - ), - getStaticConfig: new Func<[], {}, ([commitStore: string, chainSelector: bigint, sourceChainSelector: bigint, onRamp: string, prevOffRamp: string, armProxy: string] & {commitStore: string, chainSelector: bigint, sourceChainSelector: bigint, onRamp: string, prevOffRamp: string, armProxy: string})>( - abi, '0x06285c69' - ), - getSupportedTokens: new Func<[], {}, Array>( - abi, '0xd3c7c2c7' - ), - getTokenLimitAdmin: new Func<[], {}, string>( - abi, '0x599f6431' - ), - getTransmitters: new Func<[], {}, Array>( - abi, '0x666cab8d' - ), - latestConfigDetails: new Func<[], {}, ([configCount: number, blockNumber: number, configDigest: string] & {configCount: number, blockNumber: number, configDigest: string})>( - abi, '0x81ff7048' - ), - latestConfigDigestAndEpoch: new Func<[], {}, ([scanLogs: boolean, configDigest: string, epoch: number] & {scanLogs: boolean, configDigest: string, epoch: number})>( - abi, '0xafcb95d7' - ), - manuallyExecute: new Func<[report: ([messages: Array<([sourceChainSelector: bigint, sender: string, receiver: string, sequenceNumber: bigint, gasLimit: bigint, strict: boolean, nonce: bigint, feeToken: string, feeTokenAmount: bigint, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, sourceTokenData: Array, messageId: string] & {sourceChainSelector: bigint, sender: string, receiver: string, sequenceNumber: bigint, gasLimit: bigint, strict: boolean, nonce: bigint, feeToken: string, feeTokenAmount: bigint, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, sourceTokenData: Array, messageId: string})>, offchainTokenData: Array>, proofs: Array, proofFlagBits: bigint] & {messages: Array<([sourceChainSelector: bigint, sender: string, receiver: string, sequenceNumber: bigint, gasLimit: bigint, strict: boolean, nonce: bigint, feeToken: string, feeTokenAmount: bigint, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, sourceTokenData: Array, messageId: string] & {sourceChainSelector: bigint, sender: string, receiver: string, sequenceNumber: bigint, gasLimit: bigint, strict: boolean, nonce: bigint, feeToken: string, feeTokenAmount: bigint, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, sourceTokenData: Array, messageId: string})>, offchainTokenData: Array>, proofs: Array, proofFlagBits: bigint}), gasLimitOverrides: Array], {report: ([messages: Array<([sourceChainSelector: bigint, sender: string, receiver: string, sequenceNumber: bigint, gasLimit: bigint, strict: boolean, nonce: bigint, feeToken: string, feeTokenAmount: bigint, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, sourceTokenData: Array, messageId: string] & {sourceChainSelector: bigint, sender: string, receiver: string, sequenceNumber: bigint, gasLimit: bigint, strict: boolean, nonce: bigint, feeToken: string, feeTokenAmount: bigint, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, sourceTokenData: Array, messageId: string})>, offchainTokenData: Array>, proofs: Array, proofFlagBits: bigint] & {messages: Array<([sourceChainSelector: bigint, sender: string, receiver: string, sequenceNumber: bigint, gasLimit: bigint, strict: boolean, nonce: bigint, feeToken: string, feeTokenAmount: bigint, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, sourceTokenData: Array, messageId: string] & {sourceChainSelector: bigint, sender: string, receiver: string, sequenceNumber: bigint, gasLimit: bigint, strict: boolean, nonce: bigint, feeToken: string, feeTokenAmount: bigint, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, sourceTokenData: Array, messageId: string})>, offchainTokenData: Array>, proofs: Array, proofFlagBits: bigint}), gasLimitOverrides: Array}, []>( - abi, '0x740f4150' - ), - owner: new Func<[], {}, string>( - abi, '0x8da5cb5b' - ), - setAdmin: new Func<[newAdmin: string], {newAdmin: string}, []>( - abi, '0x704b6c02' - ), - setOCR2Config: new Func<[signers: Array, transmitters: Array, f: number, onchainConfig: string, offchainConfigVersion: bigint, offchainConfig: string], {signers: Array, transmitters: Array, f: number, onchainConfig: string, offchainConfigVersion: bigint, offchainConfig: string}, []>( - abi, '0x1ef38174' - ), - setRateLimiterConfig: new Func<[config: ([isEnabled: boolean, capacity: bigint, rate: bigint] & {isEnabled: boolean, capacity: bigint, rate: bigint})], {config: ([isEnabled: boolean, capacity: bigint, rate: bigint] & {isEnabled: boolean, capacity: bigint, rate: bigint})}, []>( - abi, '0xc92b2832' - ), - transferOwnership: new Func<[to: string], {to: string}, []>( - abi, '0xf2fde38b' - ), - transmit: new Func<[reportContext: Array, report: string, rs: Array, ss: Array, _: string], {reportContext: Array, report: string, rs: Array, ss: Array}, []>( - abi, '0xb1dc65a4' - ), - typeAndVersion: new Func<[], {}, string>( - abi, '0x181f5a77' - ), + acceptOwnership: fun("0x79ba5097", {}, ), + applyPoolUpdates: fun("0x3a87ac53", {"removes": p.array(p.struct({"token": p.address, "pool": p.address})), "adds": p.array(p.struct({"token": p.address, "pool": p.address}))}, ), + ccipReceive: fun("0x85572ffb", {"_0": p.struct({"messageId": p.bytes32, "sourceChainSelector": p.uint64, "sender": p.bytes, "data": p.bytes, "destTokenAmounts": p.array(p.struct({"token": p.address, "amount": p.uint256}))})}, ), + currentRateLimiterState: fun("0x546719cd", {}, p.struct({"tokens": p.uint128, "lastUpdated": p.uint32, "isEnabled": p.bool, "capacity": p.uint128, "rate": p.uint128})), + executeSingleMessage: fun("0xf52121a5", {"message": p.struct({"sourceChainSelector": p.uint64, "sender": p.address, "receiver": p.address, "sequenceNumber": p.uint64, "gasLimit": p.uint256, "strict": p.bool, "nonce": p.uint64, "feeToken": p.address, "feeTokenAmount": p.uint256, "data": p.bytes, "tokenAmounts": p.array(p.struct({"token": p.address, "amount": p.uint256})), "sourceTokenData": p.array(p.bytes), "messageId": p.bytes32}), "offchainTokenData": p.array(p.bytes)}, ), + getDestinationToken: fun("0xb4069b31", {"sourceToken": p.address}, p.address), + getDestinationTokens: fun("0x681fba16", {}, p.array(p.address)), + getDynamicConfig: fun("0x7437ff9f", {}, p.struct({"permissionLessExecutionThresholdSeconds": p.uint32, "router": p.address, "priceRegistry": p.address, "maxNumberOfTokensPerMsg": p.uint16, "maxDataBytes": p.uint32, "maxPoolReleaseOrMintGas": p.uint32})), + getExecutionState: fun("0x142a98fc", {"sequenceNumber": p.uint64}, p.uint8), + getPoolByDestToken: fun("0xd7e2bb50", {"destToken": p.address}, p.address), + getPoolBySourceToken: fun("0x5d86f141", {"sourceToken": p.address}, p.address), + getSenderNonce: fun("0x856c8247", {"sender": p.address}, p.uint64), + getStaticConfig: fun("0x06285c69", {}, p.struct({"commitStore": p.address, "chainSelector": p.uint64, "sourceChainSelector": p.uint64, "onRamp": p.address, "prevOffRamp": p.address, "armProxy": p.address})), + getSupportedTokens: fun("0xd3c7c2c7", {}, p.array(p.address)), + getTokenLimitAdmin: fun("0x599f6431", {}, p.address), + getTransmitters: fun("0x666cab8d", {}, p.array(p.address)), + latestConfigDetails: fun("0x81ff7048", {}, {"configCount": p.uint32, "blockNumber": p.uint32, "configDigest": p.bytes32}), + latestConfigDigestAndEpoch: fun("0xafcb95d7", {}, {"scanLogs": p.bool, "configDigest": p.bytes32, "epoch": p.uint32}), + manuallyExecute: fun("0x740f4150", {"report": p.struct({"messages": p.array(p.struct({"sourceChainSelector": p.uint64, "sender": p.address, "receiver": p.address, "sequenceNumber": p.uint64, "gasLimit": p.uint256, "strict": p.bool, "nonce": p.uint64, "feeToken": p.address, "feeTokenAmount": p.uint256, "data": p.bytes, "tokenAmounts": p.array(p.struct({"token": p.address, "amount": p.uint256})), "sourceTokenData": p.array(p.bytes), "messageId": p.bytes32})), "offchainTokenData": p.array(p.array(p.bytes)), "proofs": p.array(p.bytes32), "proofFlagBits": p.uint256}), "gasLimitOverrides": p.array(p.uint256)}, ), + owner: fun("0x8da5cb5b", {}, p.address), + setAdmin: fun("0x704b6c02", {"newAdmin": p.address}, ), + setOCR2Config: fun("0x1ef38174", {"signers": p.array(p.address), "transmitters": p.array(p.address), "f": p.uint8, "onchainConfig": p.bytes, "offchainConfigVersion": p.uint64, "offchainConfig": p.bytes}, ), + setRateLimiterConfig: fun("0xc92b2832", {"config": p.struct({"isEnabled": p.bool, "capacity": p.uint128, "rate": p.uint128})}, ), + transferOwnership: fun("0xf2fde38b", {"to": p.address}, ), + transmit: fun("0xb1dc65a4", {"reportContext": p.fixedSizeArray(p.bytes32, 3), "report": p.bytes, "rs": p.array(p.bytes32), "ss": p.array(p.bytes32), "_4": p.bytes32}, ), + typeAndVersion: fun("0x181f5a77", {}, p.string), } export class Contract extends ContractBase { - currentRateLimiterState(): Promise<([tokens: bigint, lastUpdated: number, isEnabled: boolean, capacity: bigint, rate: bigint] & {tokens: bigint, lastUpdated: number, isEnabled: boolean, capacity: bigint, rate: bigint})> { - return this.eth_call(functions.currentRateLimiterState, []) + currentRateLimiterState() { + return this.eth_call(functions.currentRateLimiterState, {}) } - getDestinationToken(sourceToken: string): Promise { - return this.eth_call(functions.getDestinationToken, [sourceToken]) + getDestinationToken(sourceToken: GetDestinationTokenParams["sourceToken"]) { + return this.eth_call(functions.getDestinationToken, {sourceToken}) } - getDestinationTokens(): Promise> { - return this.eth_call(functions.getDestinationTokens, []) + getDestinationTokens() { + return this.eth_call(functions.getDestinationTokens, {}) } - getDynamicConfig(): Promise<([permissionLessExecutionThresholdSeconds: number, router: string, priceRegistry: string, maxNumberOfTokensPerMsg: number, maxDataBytes: number, maxPoolReleaseOrMintGas: number] & {permissionLessExecutionThresholdSeconds: number, router: string, priceRegistry: string, maxNumberOfTokensPerMsg: number, maxDataBytes: number, maxPoolReleaseOrMintGas: number})> { - return this.eth_call(functions.getDynamicConfig, []) + getDynamicConfig() { + return this.eth_call(functions.getDynamicConfig, {}) } - getExecutionState(sequenceNumber: bigint): Promise { - return this.eth_call(functions.getExecutionState, [sequenceNumber]) + getExecutionState(sequenceNumber: GetExecutionStateParams["sequenceNumber"]) { + return this.eth_call(functions.getExecutionState, {sequenceNumber}) } - getPoolByDestToken(destToken: string): Promise { - return this.eth_call(functions.getPoolByDestToken, [destToken]) + getPoolByDestToken(destToken: GetPoolByDestTokenParams["destToken"]) { + return this.eth_call(functions.getPoolByDestToken, {destToken}) } - getPoolBySourceToken(sourceToken: string): Promise { - return this.eth_call(functions.getPoolBySourceToken, [sourceToken]) + getPoolBySourceToken(sourceToken: GetPoolBySourceTokenParams["sourceToken"]) { + return this.eth_call(functions.getPoolBySourceToken, {sourceToken}) } - getSenderNonce(sender: string): Promise { - return this.eth_call(functions.getSenderNonce, [sender]) + getSenderNonce(sender: GetSenderNonceParams["sender"]) { + return this.eth_call(functions.getSenderNonce, {sender}) } - getStaticConfig(): Promise<([commitStore: string, chainSelector: bigint, sourceChainSelector: bigint, onRamp: string, prevOffRamp: string, armProxy: string] & {commitStore: string, chainSelector: bigint, sourceChainSelector: bigint, onRamp: string, prevOffRamp: string, armProxy: string})> { - return this.eth_call(functions.getStaticConfig, []) + getStaticConfig() { + return this.eth_call(functions.getStaticConfig, {}) } - getSupportedTokens(): Promise> { - return this.eth_call(functions.getSupportedTokens, []) + getSupportedTokens() { + return this.eth_call(functions.getSupportedTokens, {}) } - getTokenLimitAdmin(): Promise { - return this.eth_call(functions.getTokenLimitAdmin, []) + getTokenLimitAdmin() { + return this.eth_call(functions.getTokenLimitAdmin, {}) } - getTransmitters(): Promise> { - return this.eth_call(functions.getTransmitters, []) + getTransmitters() { + return this.eth_call(functions.getTransmitters, {}) } - latestConfigDetails(): Promise<([configCount: number, blockNumber: number, configDigest: string] & {configCount: number, blockNumber: number, configDigest: string})> { - return this.eth_call(functions.latestConfigDetails, []) + latestConfigDetails() { + return this.eth_call(functions.latestConfigDetails, {}) } - latestConfigDigestAndEpoch(): Promise<([scanLogs: boolean, configDigest: string, epoch: number] & {scanLogs: boolean, configDigest: string, epoch: number})> { - return this.eth_call(functions.latestConfigDigestAndEpoch, []) + latestConfigDigestAndEpoch() { + return this.eth_call(functions.latestConfigDigestAndEpoch, {}) } - owner(): Promise { - return this.eth_call(functions.owner, []) + owner() { + return this.eth_call(functions.owner, {}) } - typeAndVersion(): Promise { - return this.eth_call(functions.typeAndVersion, []) + typeAndVersion() { + return this.eth_call(functions.typeAndVersion, {}) } } + +/// Event types +export type AdminSetEventArgs = EParams +export type ConfigSetEventArgs_0 = EParams +export type ConfigSetEventArgs_1 = EParams +export type ExecutionStateChangedEventArgs = EParams +export type OwnershipTransferRequestedEventArgs = EParams +export type OwnershipTransferredEventArgs = EParams +export type PoolAddedEventArgs = EParams +export type PoolRemovedEventArgs = EParams +export type SkippedIncorrectNonceEventArgs = EParams +export type SkippedSenderWithPreviousRampMessageInflightEventArgs = EParams +export type TransmittedEventArgs = EParams + +/// Function types +export type AcceptOwnershipParams = FunctionArguments +export type AcceptOwnershipReturn = FunctionReturn + +export type ApplyPoolUpdatesParams = FunctionArguments +export type ApplyPoolUpdatesReturn = FunctionReturn + +export type CcipReceiveParams = FunctionArguments +export type CcipReceiveReturn = FunctionReturn + +export type CurrentRateLimiterStateParams = FunctionArguments +export type CurrentRateLimiterStateReturn = FunctionReturn + +export type ExecuteSingleMessageParams = FunctionArguments +export type ExecuteSingleMessageReturn = FunctionReturn + +export type GetDestinationTokenParams = FunctionArguments +export type GetDestinationTokenReturn = FunctionReturn + +export type GetDestinationTokensParams = FunctionArguments +export type GetDestinationTokensReturn = FunctionReturn + +export type GetDynamicConfigParams = FunctionArguments +export type GetDynamicConfigReturn = FunctionReturn + +export type GetExecutionStateParams = FunctionArguments +export type GetExecutionStateReturn = FunctionReturn + +export type GetPoolByDestTokenParams = FunctionArguments +export type GetPoolByDestTokenReturn = FunctionReturn + +export type GetPoolBySourceTokenParams = FunctionArguments +export type GetPoolBySourceTokenReturn = FunctionReturn + +export type GetSenderNonceParams = FunctionArguments +export type GetSenderNonceReturn = FunctionReturn + +export type GetStaticConfigParams = FunctionArguments +export type GetStaticConfigReturn = FunctionReturn + +export type GetSupportedTokensParams = FunctionArguments +export type GetSupportedTokensReturn = FunctionReturn + +export type GetTokenLimitAdminParams = FunctionArguments +export type GetTokenLimitAdminReturn = FunctionReturn + +export type GetTransmittersParams = FunctionArguments +export type GetTransmittersReturn = FunctionReturn + +export type LatestConfigDetailsParams = FunctionArguments +export type LatestConfigDetailsReturn = FunctionReturn + +export type LatestConfigDigestAndEpochParams = FunctionArguments +export type LatestConfigDigestAndEpochReturn = FunctionReturn + +export type ManuallyExecuteParams = FunctionArguments +export type ManuallyExecuteReturn = FunctionReturn + +export type OwnerParams = FunctionArguments +export type OwnerReturn = FunctionReturn + +export type SetAdminParams = FunctionArguments +export type SetAdminReturn = FunctionReturn + +export type SetOCR2ConfigParams = FunctionArguments +export type SetOCR2ConfigReturn = FunctionReturn + +export type SetRateLimiterConfigParams = FunctionArguments +export type SetRateLimiterConfigReturn = FunctionReturn + +export type TransferOwnershipParams = FunctionArguments +export type TransferOwnershipReturn = FunctionReturn + +export type TransmitParams = FunctionArguments +export type TransmitReturn = FunctionReturn + +export type TypeAndVersionParams = FunctionArguments +export type TypeAndVersionReturn = FunctionReturn + diff --git a/src/abi/ccip-evm2evmonramp.ts b/src/abi/ccip-evm2evmonramp.ts index ff0f9932..4e92831f 100644 --- a/src/abi/ccip-evm2evmonramp.ts +++ b/src/abi/ccip-evm2evmonramp.ts @@ -1,195 +1,214 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './ccip-evm2evmonramp.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - AdminSet: new LogEvent<([newAdmin: string] & {newAdmin: string})>( - abi, '0x8fe72c3e0020beb3234e76ae6676fa576fbfcae600af1c4fea44784cf0db329c' - ), - CCIPSendRequested: new LogEvent<([message: ([sourceChainSelector: bigint, sender: string, receiver: string, sequenceNumber: bigint, gasLimit: bigint, strict: boolean, nonce: bigint, feeToken: string, feeTokenAmount: bigint, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, sourceTokenData: Array, messageId: string] & {sourceChainSelector: bigint, sender: string, receiver: string, sequenceNumber: bigint, gasLimit: bigint, strict: boolean, nonce: bigint, feeToken: string, feeTokenAmount: bigint, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, sourceTokenData: Array, messageId: string})] & {message: ([sourceChainSelector: bigint, sender: string, receiver: string, sequenceNumber: bigint, gasLimit: bigint, strict: boolean, nonce: bigint, feeToken: string, feeTokenAmount: bigint, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, sourceTokenData: Array, messageId: string] & {sourceChainSelector: bigint, sender: string, receiver: string, sequenceNumber: bigint, gasLimit: bigint, strict: boolean, nonce: bigint, feeToken: string, feeTokenAmount: bigint, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, sourceTokenData: Array, messageId: string})})>( - abi, '0xd0c3c799bf9e2639de44391e7f524d229b2b55f5b1ea94b2bf7da42f7243dddd' - ), - ConfigSet: new LogEvent<([staticConfig: ([linkToken: string, chainSelector: bigint, destChainSelector: bigint, defaultTxGasLimit: bigint, maxNopFeesJuels: bigint, prevOnRamp: string, armProxy: string] & {linkToken: string, chainSelector: bigint, destChainSelector: bigint, defaultTxGasLimit: bigint, maxNopFeesJuels: bigint, prevOnRamp: string, armProxy: string}), dynamicConfig: ([router: string, maxNumberOfTokensPerMsg: number, destGasOverhead: number, destGasPerPayloadByte: number, destDataAvailabilityOverheadGas: number, destGasPerDataAvailabilityByte: number, destDataAvailabilityMultiplierBps: number, priceRegistry: string, maxDataBytes: number, maxPerMsgGasLimit: number] & {router: string, maxNumberOfTokensPerMsg: number, destGasOverhead: number, destGasPerPayloadByte: number, destDataAvailabilityOverheadGas: number, destGasPerDataAvailabilityByte: number, destDataAvailabilityMultiplierBps: number, priceRegistry: string, maxDataBytes: number, maxPerMsgGasLimit: number})] & {staticConfig: ([linkToken: string, chainSelector: bigint, destChainSelector: bigint, defaultTxGasLimit: bigint, maxNopFeesJuels: bigint, prevOnRamp: string, armProxy: string] & {linkToken: string, chainSelector: bigint, destChainSelector: bigint, defaultTxGasLimit: bigint, maxNopFeesJuels: bigint, prevOnRamp: string, armProxy: string}), dynamicConfig: ([router: string, maxNumberOfTokensPerMsg: number, destGasOverhead: number, destGasPerPayloadByte: number, destDataAvailabilityOverheadGas: number, destGasPerDataAvailabilityByte: number, destDataAvailabilityMultiplierBps: number, priceRegistry: string, maxDataBytes: number, maxPerMsgGasLimit: number] & {router: string, maxNumberOfTokensPerMsg: number, destGasOverhead: number, destGasPerPayloadByte: number, destDataAvailabilityOverheadGas: number, destGasPerDataAvailabilityByte: number, destDataAvailabilityMultiplierBps: number, priceRegistry: string, maxDataBytes: number, maxPerMsgGasLimit: number})})>( - abi, '0x2a57f7c2027cf032c78b77d4d8d2fbd20ad22e5d5e5b5fb23ac7d7820d44adc6' - ), - FeeConfigSet: new LogEvent<([feeConfig: Array<([token: string, networkFeeUSDCents: number, gasMultiplierWeiPerEth: bigint, premiumMultiplierWeiPerEth: bigint, enabled: boolean] & {token: string, networkFeeUSDCents: number, gasMultiplierWeiPerEth: bigint, premiumMultiplierWeiPerEth: bigint, enabled: boolean})>] & {feeConfig: Array<([token: string, networkFeeUSDCents: number, gasMultiplierWeiPerEth: bigint, premiumMultiplierWeiPerEth: bigint, enabled: boolean] & {token: string, networkFeeUSDCents: number, gasMultiplierWeiPerEth: bigint, premiumMultiplierWeiPerEth: bigint, enabled: boolean})>})>( - abi, '0x067924bf9277d905a9a4631a06d959bc032ace86b3caa835ae7e403d4f39010e' - ), - NopPaid: new LogEvent<([nop: string, amount: bigint] & {nop: string, amount: bigint})>( - abi, '0x55fdec2aab60a41fa5abb106670eb1006f5aeaee1ba7afea2bc89b5b3ec7678f' - ), - NopsSet: new LogEvent<([nopWeightsTotal: bigint, nopsAndWeights: Array<([nop: string, weight: number] & {nop: string, weight: number})>] & {nopWeightsTotal: bigint, nopsAndWeights: Array<([nop: string, weight: number] & {nop: string, weight: number})>})>( - abi, '0x8c337bff38141c507abd25c547606bdde78fe8c12e941ab613f3a565fea6cd24' - ), - OwnershipTransferRequested: new LogEvent<([from: string, to: string] & {from: string, to: string})>( - abi, '0xed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae1278' - ), - OwnershipTransferred: new LogEvent<([from: string, to: string] & {from: string, to: string})>( - abi, '0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0' - ), - PoolAdded: new LogEvent<([token: string, pool: string] & {token: string, pool: string})>( - abi, '0x95f865c2808f8b2a85eea2611db7843150ee7835ef1403f9755918a97d76933c' - ), - PoolRemoved: new LogEvent<([token: string, pool: string] & {token: string, pool: string})>( - abi, '0x987eb3c2f78454541205f72f34839b434c306c9eaf4922efd7c0c3060fdb2e4c' - ), - TokenTransferFeeConfigSet: new LogEvent<([transferFeeConfig: Array<([token: string, minFeeUSDCents: number, maxFeeUSDCents: number, deciBps: number, destGasOverhead: number, destBytesOverhead: number] & {token: string, minFeeUSDCents: number, maxFeeUSDCents: number, deciBps: number, destGasOverhead: number, destBytesOverhead: number})>] & {transferFeeConfig: Array<([token: string, minFeeUSDCents: number, maxFeeUSDCents: number, deciBps: number, destGasOverhead: number, destBytesOverhead: number] & {token: string, minFeeUSDCents: number, maxFeeUSDCents: number, deciBps: number, destGasOverhead: number, destBytesOverhead: number})>})>( - abi, '0x555c74101f7a15746d31c6731170310e667bcc607996b2fc0b981a7b26a416e9' - ), + AdminSet: event("0x8fe72c3e0020beb3234e76ae6676fa576fbfcae600af1c4fea44784cf0db329c", {"newAdmin": p.address}), + CCIPSendRequested: event("0xd0c3c799bf9e2639de44391e7f524d229b2b55f5b1ea94b2bf7da42f7243dddd", {"message": p.struct({"sourceChainSelector": p.uint64, "sender": p.address, "receiver": p.address, "sequenceNumber": p.uint64, "gasLimit": p.uint256, "strict": p.bool, "nonce": p.uint64, "feeToken": p.address, "feeTokenAmount": p.uint256, "data": p.bytes, "tokenAmounts": p.array(p.struct({"token": p.address, "amount": p.uint256})), "sourceTokenData": p.array(p.bytes), "messageId": p.bytes32})}), + ConfigSet: event("0x2a57f7c2027cf032c78b77d4d8d2fbd20ad22e5d5e5b5fb23ac7d7820d44adc6", {"staticConfig": p.struct({"linkToken": p.address, "chainSelector": p.uint64, "destChainSelector": p.uint64, "defaultTxGasLimit": p.uint64, "maxNopFeesJuels": p.uint96, "prevOnRamp": p.address, "armProxy": p.address}), "dynamicConfig": p.struct({"router": p.address, "maxNumberOfTokensPerMsg": p.uint16, "destGasOverhead": p.uint32, "destGasPerPayloadByte": p.uint16, "destDataAvailabilityOverheadGas": p.uint32, "destGasPerDataAvailabilityByte": p.uint16, "destDataAvailabilityMultiplierBps": p.uint16, "priceRegistry": p.address, "maxDataBytes": p.uint32, "maxPerMsgGasLimit": p.uint32})}), + FeeConfigSet: event("0x067924bf9277d905a9a4631a06d959bc032ace86b3caa835ae7e403d4f39010e", {"feeConfig": p.array(p.struct({"token": p.address, "networkFeeUSDCents": p.uint32, "gasMultiplierWeiPerEth": p.uint64, "premiumMultiplierWeiPerEth": p.uint64, "enabled": p.bool}))}), + NopPaid: event("0x55fdec2aab60a41fa5abb106670eb1006f5aeaee1ba7afea2bc89b5b3ec7678f", {"nop": indexed(p.address), "amount": p.uint256}), + NopsSet: event("0x8c337bff38141c507abd25c547606bdde78fe8c12e941ab613f3a565fea6cd24", {"nopWeightsTotal": p.uint256, "nopsAndWeights": p.array(p.struct({"nop": p.address, "weight": p.uint16}))}), + OwnershipTransferRequested: event("0xed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae1278", {"from": indexed(p.address), "to": indexed(p.address)}), + OwnershipTransferred: event("0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", {"from": indexed(p.address), "to": indexed(p.address)}), + PoolAdded: event("0x95f865c2808f8b2a85eea2611db7843150ee7835ef1403f9755918a97d76933c", {"token": p.address, "pool": p.address}), + PoolRemoved: event("0x987eb3c2f78454541205f72f34839b434c306c9eaf4922efd7c0c3060fdb2e4c", {"token": p.address, "pool": p.address}), + TokenTransferFeeConfigSet: event("0x555c74101f7a15746d31c6731170310e667bcc607996b2fc0b981a7b26a416e9", {"transferFeeConfig": p.array(p.struct({"token": p.address, "minFeeUSDCents": p.uint32, "maxFeeUSDCents": p.uint32, "deciBps": p.uint16, "destGasOverhead": p.uint32, "destBytesOverhead": p.uint32}))}), } export const functions = { - acceptOwnership: new Func<[], {}, []>( - abi, '0x79ba5097' - ), - applyPoolUpdates: new Func<[removes: Array<([token: string, pool: string] & {token: string, pool: string})>, adds: Array<([token: string, pool: string] & {token: string, pool: string})>], {removes: Array<([token: string, pool: string] & {token: string, pool: string})>, adds: Array<([token: string, pool: string] & {token: string, pool: string})>}, []>( - abi, '0x3a87ac53' - ), - currentRateLimiterState: new Func<[], {}, ([tokens: bigint, lastUpdated: number, isEnabled: boolean, capacity: bigint, rate: bigint] & {tokens: bigint, lastUpdated: number, isEnabled: boolean, capacity: bigint, rate: bigint})>( - abi, '0x546719cd' - ), - forwardFromRouter: new Func<[destChainSelector: bigint, message: ([receiver: string, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, feeToken: string, extraArgs: string] & {receiver: string, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, feeToken: string, extraArgs: string}), feeTokenAmount: bigint, originalSender: string], {destChainSelector: bigint, message: ([receiver: string, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, feeToken: string, extraArgs: string] & {receiver: string, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, feeToken: string, extraArgs: string}), feeTokenAmount: bigint, originalSender: string}, string>( - abi, '0xdf0aa9e9' - ), - getDynamicConfig: new Func<[], {}, ([router: string, maxNumberOfTokensPerMsg: number, destGasOverhead: number, destGasPerPayloadByte: number, destDataAvailabilityOverheadGas: number, destGasPerDataAvailabilityByte: number, destDataAvailabilityMultiplierBps: number, priceRegistry: string, maxDataBytes: number, maxPerMsgGasLimit: number] & {router: string, maxNumberOfTokensPerMsg: number, destGasOverhead: number, destGasPerPayloadByte: number, destDataAvailabilityOverheadGas: number, destGasPerDataAvailabilityByte: number, destDataAvailabilityMultiplierBps: number, priceRegistry: string, maxDataBytes: number, maxPerMsgGasLimit: number})>( - abi, '0x7437ff9f' - ), - getExpectedNextSequenceNumber: new Func<[], {}, bigint>( - abi, '0x4120fccd' - ), - getFee: new Func<[destChainSelector: bigint, message: ([receiver: string, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, feeToken: string, extraArgs: string] & {receiver: string, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, feeToken: string, extraArgs: string})], {destChainSelector: bigint, message: ([receiver: string, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, feeToken: string, extraArgs: string] & {receiver: string, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, feeToken: string, extraArgs: string})}, bigint>( - abi, '0x20487ded' - ), - getFeeTokenConfig: new Func<[token: string], {token: string}, ([networkFeeUSDCents: number, gasMultiplierWeiPerEth: bigint, premiumMultiplierWeiPerEth: bigint, enabled: boolean] & {networkFeeUSDCents: number, gasMultiplierWeiPerEth: bigint, premiumMultiplierWeiPerEth: bigint, enabled: boolean})>( - abi, '0x9a113c36' - ), - getNopFeesJuels: new Func<[], {}, bigint>( - abi, '0x54b71468' - ), - getNops: new Func<[], {}, ([nopsAndWeights: Array<([nop: string, weight: number] & {nop: string, weight: number})>, weightsTotal: bigint] & {nopsAndWeights: Array<([nop: string, weight: number] & {nop: string, weight: number})>, weightsTotal: bigint})>( - abi, '0xb06d41bc' - ), - getPoolBySourceToken: new Func<[_: bigint, sourceToken: string], {sourceToken: string}, string>( - abi, '0x48a98aa4' - ), - getSenderNonce: new Func<[sender: string], {sender: string}, bigint>( - abi, '0x856c8247' - ), - getStaticConfig: new Func<[], {}, ([linkToken: string, chainSelector: bigint, destChainSelector: bigint, defaultTxGasLimit: bigint, maxNopFeesJuels: bigint, prevOnRamp: string, armProxy: string] & {linkToken: string, chainSelector: bigint, destChainSelector: bigint, defaultTxGasLimit: bigint, maxNopFeesJuels: bigint, prevOnRamp: string, armProxy: string})>( - abi, '0x06285c69' - ), - getSupportedTokens: new Func<[_: bigint], {}, Array>( - abi, '0xfbca3b74' - ), - getTokenLimitAdmin: new Func<[], {}, string>( - abi, '0x599f6431' - ), - getTokenTransferFeeConfig: new Func<[token: string], {token: string}, ([minFeeUSDCents: number, maxFeeUSDCents: number, deciBps: number, destGasOverhead: number, destBytesOverhead: number] & {minFeeUSDCents: number, maxFeeUSDCents: number, deciBps: number, destGasOverhead: number, destBytesOverhead: number})>( - abi, '0x1772047e' - ), - linkAvailableForPayment: new Func<[], {}, bigint>( - abi, '0xd09dc339' - ), - owner: new Func<[], {}, string>( - abi, '0x8da5cb5b' - ), - payNops: new Func<[], {}, []>( - abi, '0xeff7cc48' - ), - setAdmin: new Func<[newAdmin: string], {newAdmin: string}, []>( - abi, '0x704b6c02' - ), - setDynamicConfig: new Func<[dynamicConfig: ([router: string, maxNumberOfTokensPerMsg: number, destGasOverhead: number, destGasPerPayloadByte: number, destDataAvailabilityOverheadGas: number, destGasPerDataAvailabilityByte: number, destDataAvailabilityMultiplierBps: number, priceRegistry: string, maxDataBytes: number, maxPerMsgGasLimit: number] & {router: string, maxNumberOfTokensPerMsg: number, destGasOverhead: number, destGasPerPayloadByte: number, destDataAvailabilityOverheadGas: number, destGasPerDataAvailabilityByte: number, destDataAvailabilityMultiplierBps: number, priceRegistry: string, maxDataBytes: number, maxPerMsgGasLimit: number})], {dynamicConfig: ([router: string, maxNumberOfTokensPerMsg: number, destGasOverhead: number, destGasPerPayloadByte: number, destDataAvailabilityOverheadGas: number, destGasPerDataAvailabilityByte: number, destDataAvailabilityMultiplierBps: number, priceRegistry: string, maxDataBytes: number, maxPerMsgGasLimit: number] & {router: string, maxNumberOfTokensPerMsg: number, destGasOverhead: number, destGasPerPayloadByte: number, destDataAvailabilityOverheadGas: number, destGasPerDataAvailabilityByte: number, destDataAvailabilityMultiplierBps: number, priceRegistry: string, maxDataBytes: number, maxPerMsgGasLimit: number})}, []>( - abi, '0xe687b40a' - ), - setFeeTokenConfig: new Func<[feeTokenConfigArgs: Array<([token: string, networkFeeUSDCents: number, gasMultiplierWeiPerEth: bigint, premiumMultiplierWeiPerEth: bigint, enabled: boolean] & {token: string, networkFeeUSDCents: number, gasMultiplierWeiPerEth: bigint, premiumMultiplierWeiPerEth: bigint, enabled: boolean})>], {feeTokenConfigArgs: Array<([token: string, networkFeeUSDCents: number, gasMultiplierWeiPerEth: bigint, premiumMultiplierWeiPerEth: bigint, enabled: boolean] & {token: string, networkFeeUSDCents: number, gasMultiplierWeiPerEth: bigint, premiumMultiplierWeiPerEth: bigint, enabled: boolean})>}, []>( - abi, '0xf25561fd' - ), - setNops: new Func<[nopsAndWeights: Array<([nop: string, weight: number] & {nop: string, weight: number})>], {nopsAndWeights: Array<([nop: string, weight: number] & {nop: string, weight: number})>}, []>( - abi, '0x76f6ae76' - ), - setRateLimiterConfig: new Func<[config: ([isEnabled: boolean, capacity: bigint, rate: bigint] & {isEnabled: boolean, capacity: bigint, rate: bigint})], {config: ([isEnabled: boolean, capacity: bigint, rate: bigint] & {isEnabled: boolean, capacity: bigint, rate: bigint})}, []>( - abi, '0xc92b2832' - ), - setTokenTransferFeeConfig: new Func<[tokenTransferFeeConfigArgs: Array<([token: string, minFeeUSDCents: number, maxFeeUSDCents: number, deciBps: number, destGasOverhead: number, destBytesOverhead: number] & {token: string, minFeeUSDCents: number, maxFeeUSDCents: number, deciBps: number, destGasOverhead: number, destBytesOverhead: number})>], {tokenTransferFeeConfigArgs: Array<([token: string, minFeeUSDCents: number, maxFeeUSDCents: number, deciBps: number, destGasOverhead: number, destBytesOverhead: number] & {token: string, minFeeUSDCents: number, maxFeeUSDCents: number, deciBps: number, destGasOverhead: number, destBytesOverhead: number})>}, []>( - abi, '0x7ec75751' - ), - transferOwnership: new Func<[to: string], {to: string}, []>( - abi, '0xf2fde38b' - ), - typeAndVersion: new Func<[], {}, string>( - abi, '0x181f5a77' - ), - withdrawNonLinkFees: new Func<[feeToken: string, to: string], {feeToken: string, to: string}, []>( - abi, '0x549e946f' - ), + acceptOwnership: fun("0x79ba5097", {}, ), + applyPoolUpdates: fun("0x3a87ac53", {"removes": p.array(p.struct({"token": p.address, "pool": p.address})), "adds": p.array(p.struct({"token": p.address, "pool": p.address}))}, ), + currentRateLimiterState: fun("0x546719cd", {}, p.struct({"tokens": p.uint128, "lastUpdated": p.uint32, "isEnabled": p.bool, "capacity": p.uint128, "rate": p.uint128})), + forwardFromRouter: fun("0xdf0aa9e9", {"destChainSelector": p.uint64, "message": p.struct({"receiver": p.bytes, "data": p.bytes, "tokenAmounts": p.array(p.struct({"token": p.address, "amount": p.uint256})), "feeToken": p.address, "extraArgs": p.bytes}), "feeTokenAmount": p.uint256, "originalSender": p.address}, p.bytes32), + getDynamicConfig: fun("0x7437ff9f", {}, p.struct({"router": p.address, "maxNumberOfTokensPerMsg": p.uint16, "destGasOverhead": p.uint32, "destGasPerPayloadByte": p.uint16, "destDataAvailabilityOverheadGas": p.uint32, "destGasPerDataAvailabilityByte": p.uint16, "destDataAvailabilityMultiplierBps": p.uint16, "priceRegistry": p.address, "maxDataBytes": p.uint32, "maxPerMsgGasLimit": p.uint32})), + getExpectedNextSequenceNumber: fun("0x4120fccd", {}, p.uint64), + getFee: fun("0x20487ded", {"destChainSelector": p.uint64, "message": p.struct({"receiver": p.bytes, "data": p.bytes, "tokenAmounts": p.array(p.struct({"token": p.address, "amount": p.uint256})), "feeToken": p.address, "extraArgs": p.bytes})}, p.uint256), + getFeeTokenConfig: fun("0x9a113c36", {"token": p.address}, p.struct({"networkFeeUSDCents": p.uint32, "gasMultiplierWeiPerEth": p.uint64, "premiumMultiplierWeiPerEth": p.uint64, "enabled": p.bool})), + getNopFeesJuels: fun("0x54b71468", {}, p.uint96), + getNops: fun("0xb06d41bc", {}, {"nopsAndWeights": p.array(p.struct({"nop": p.address, "weight": p.uint16})), "weightsTotal": p.uint256}), + getPoolBySourceToken: fun("0x48a98aa4", {"_0": p.uint64, "sourceToken": p.address}, p.address), + getSenderNonce: fun("0x856c8247", {"sender": p.address}, p.uint64), + getStaticConfig: fun("0x06285c69", {}, p.struct({"linkToken": p.address, "chainSelector": p.uint64, "destChainSelector": p.uint64, "defaultTxGasLimit": p.uint64, "maxNopFeesJuels": p.uint96, "prevOnRamp": p.address, "armProxy": p.address})), + getSupportedTokens: fun("0xfbca3b74", {"_0": p.uint64}, p.array(p.address)), + getTokenLimitAdmin: fun("0x599f6431", {}, p.address), + getTokenTransferFeeConfig: fun("0x1772047e", {"token": p.address}, p.struct({"minFeeUSDCents": p.uint32, "maxFeeUSDCents": p.uint32, "deciBps": p.uint16, "destGasOverhead": p.uint32, "destBytesOverhead": p.uint32})), + linkAvailableForPayment: fun("0xd09dc339", {}, p.int256), + owner: fun("0x8da5cb5b", {}, p.address), + payNops: fun("0xeff7cc48", {}, ), + setAdmin: fun("0x704b6c02", {"newAdmin": p.address}, ), + setDynamicConfig: fun("0xe687b40a", {"dynamicConfig": p.struct({"router": p.address, "maxNumberOfTokensPerMsg": p.uint16, "destGasOverhead": p.uint32, "destGasPerPayloadByte": p.uint16, "destDataAvailabilityOverheadGas": p.uint32, "destGasPerDataAvailabilityByte": p.uint16, "destDataAvailabilityMultiplierBps": p.uint16, "priceRegistry": p.address, "maxDataBytes": p.uint32, "maxPerMsgGasLimit": p.uint32})}, ), + setFeeTokenConfig: fun("0xf25561fd", {"feeTokenConfigArgs": p.array(p.struct({"token": p.address, "networkFeeUSDCents": p.uint32, "gasMultiplierWeiPerEth": p.uint64, "premiumMultiplierWeiPerEth": p.uint64, "enabled": p.bool}))}, ), + setNops: fun("0x76f6ae76", {"nopsAndWeights": p.array(p.struct({"nop": p.address, "weight": p.uint16}))}, ), + setRateLimiterConfig: fun("0xc92b2832", {"config": p.struct({"isEnabled": p.bool, "capacity": p.uint128, "rate": p.uint128})}, ), + setTokenTransferFeeConfig: fun("0x7ec75751", {"tokenTransferFeeConfigArgs": p.array(p.struct({"token": p.address, "minFeeUSDCents": p.uint32, "maxFeeUSDCents": p.uint32, "deciBps": p.uint16, "destGasOverhead": p.uint32, "destBytesOverhead": p.uint32}))}, ), + transferOwnership: fun("0xf2fde38b", {"to": p.address}, ), + typeAndVersion: fun("0x181f5a77", {}, p.string), + withdrawNonLinkFees: fun("0x549e946f", {"feeToken": p.address, "to": p.address}, ), } export class Contract extends ContractBase { - currentRateLimiterState(): Promise<([tokens: bigint, lastUpdated: number, isEnabled: boolean, capacity: bigint, rate: bigint] & {tokens: bigint, lastUpdated: number, isEnabled: boolean, capacity: bigint, rate: bigint})> { - return this.eth_call(functions.currentRateLimiterState, []) + currentRateLimiterState() { + return this.eth_call(functions.currentRateLimiterState, {}) } - getDynamicConfig(): Promise<([router: string, maxNumberOfTokensPerMsg: number, destGasOverhead: number, destGasPerPayloadByte: number, destDataAvailabilityOverheadGas: number, destGasPerDataAvailabilityByte: number, destDataAvailabilityMultiplierBps: number, priceRegistry: string, maxDataBytes: number, maxPerMsgGasLimit: number] & {router: string, maxNumberOfTokensPerMsg: number, destGasOverhead: number, destGasPerPayloadByte: number, destDataAvailabilityOverheadGas: number, destGasPerDataAvailabilityByte: number, destDataAvailabilityMultiplierBps: number, priceRegistry: string, maxDataBytes: number, maxPerMsgGasLimit: number})> { - return this.eth_call(functions.getDynamicConfig, []) + getDynamicConfig() { + return this.eth_call(functions.getDynamicConfig, {}) } - getExpectedNextSequenceNumber(): Promise { - return this.eth_call(functions.getExpectedNextSequenceNumber, []) + getExpectedNextSequenceNumber() { + return this.eth_call(functions.getExpectedNextSequenceNumber, {}) } - getFee(destChainSelector: bigint, message: ([receiver: string, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, feeToken: string, extraArgs: string] & {receiver: string, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, feeToken: string, extraArgs: string})): Promise { - return this.eth_call(functions.getFee, [destChainSelector, message]) + getFee(destChainSelector: GetFeeParams["destChainSelector"], message: GetFeeParams["message"]) { + return this.eth_call(functions.getFee, {destChainSelector, message}) } - getFeeTokenConfig(token: string): Promise<([networkFeeUSDCents: number, gasMultiplierWeiPerEth: bigint, premiumMultiplierWeiPerEth: bigint, enabled: boolean] & {networkFeeUSDCents: number, gasMultiplierWeiPerEth: bigint, premiumMultiplierWeiPerEth: bigint, enabled: boolean})> { - return this.eth_call(functions.getFeeTokenConfig, [token]) + getFeeTokenConfig(token: GetFeeTokenConfigParams["token"]) { + return this.eth_call(functions.getFeeTokenConfig, {token}) } - getNopFeesJuels(): Promise { - return this.eth_call(functions.getNopFeesJuels, []) + getNopFeesJuels() { + return this.eth_call(functions.getNopFeesJuels, {}) } - getNops(): Promise<([nopsAndWeights: Array<([nop: string, weight: number] & {nop: string, weight: number})>, weightsTotal: bigint] & {nopsAndWeights: Array<([nop: string, weight: number] & {nop: string, weight: number})>, weightsTotal: bigint})> { - return this.eth_call(functions.getNops, []) + getNops() { + return this.eth_call(functions.getNops, {}) } - getPoolBySourceToken(arg0: bigint, sourceToken: string): Promise { - return this.eth_call(functions.getPoolBySourceToken, [arg0, sourceToken]) + getPoolBySourceToken(_0: GetPoolBySourceTokenParams["_0"], sourceToken: GetPoolBySourceTokenParams["sourceToken"]) { + return this.eth_call(functions.getPoolBySourceToken, {_0, sourceToken}) } - getSenderNonce(sender: string): Promise { - return this.eth_call(functions.getSenderNonce, [sender]) + getSenderNonce(sender: GetSenderNonceParams["sender"]) { + return this.eth_call(functions.getSenderNonce, {sender}) } - getStaticConfig(): Promise<([linkToken: string, chainSelector: bigint, destChainSelector: bigint, defaultTxGasLimit: bigint, maxNopFeesJuels: bigint, prevOnRamp: string, armProxy: string] & {linkToken: string, chainSelector: bigint, destChainSelector: bigint, defaultTxGasLimit: bigint, maxNopFeesJuels: bigint, prevOnRamp: string, armProxy: string})> { - return this.eth_call(functions.getStaticConfig, []) + getStaticConfig() { + return this.eth_call(functions.getStaticConfig, {}) } - getSupportedTokens(arg0: bigint): Promise> { - return this.eth_call(functions.getSupportedTokens, [arg0]) + getSupportedTokens(_0: GetSupportedTokensParams["_0"]) { + return this.eth_call(functions.getSupportedTokens, {_0}) } - getTokenLimitAdmin(): Promise { - return this.eth_call(functions.getTokenLimitAdmin, []) + getTokenLimitAdmin() { + return this.eth_call(functions.getTokenLimitAdmin, {}) } - getTokenTransferFeeConfig(token: string): Promise<([minFeeUSDCents: number, maxFeeUSDCents: number, deciBps: number, destGasOverhead: number, destBytesOverhead: number] & {minFeeUSDCents: number, maxFeeUSDCents: number, deciBps: number, destGasOverhead: number, destBytesOverhead: number})> { - return this.eth_call(functions.getTokenTransferFeeConfig, [token]) + getTokenTransferFeeConfig(token: GetTokenTransferFeeConfigParams["token"]) { + return this.eth_call(functions.getTokenTransferFeeConfig, {token}) } - linkAvailableForPayment(): Promise { - return this.eth_call(functions.linkAvailableForPayment, []) + linkAvailableForPayment() { + return this.eth_call(functions.linkAvailableForPayment, {}) } - owner(): Promise { - return this.eth_call(functions.owner, []) + owner() { + return this.eth_call(functions.owner, {}) } - typeAndVersion(): Promise { - return this.eth_call(functions.typeAndVersion, []) + typeAndVersion() { + return this.eth_call(functions.typeAndVersion, {}) } } + +/// Event types +export type AdminSetEventArgs = EParams +export type CCIPSendRequestedEventArgs = EParams +export type ConfigSetEventArgs = EParams +export type FeeConfigSetEventArgs = EParams +export type NopPaidEventArgs = EParams +export type NopsSetEventArgs = EParams +export type OwnershipTransferRequestedEventArgs = EParams +export type OwnershipTransferredEventArgs = EParams +export type PoolAddedEventArgs = EParams +export type PoolRemovedEventArgs = EParams +export type TokenTransferFeeConfigSetEventArgs = EParams + +/// Function types +export type AcceptOwnershipParams = FunctionArguments +export type AcceptOwnershipReturn = FunctionReturn + +export type ApplyPoolUpdatesParams = FunctionArguments +export type ApplyPoolUpdatesReturn = FunctionReturn + +export type CurrentRateLimiterStateParams = FunctionArguments +export type CurrentRateLimiterStateReturn = FunctionReturn + +export type ForwardFromRouterParams = FunctionArguments +export type ForwardFromRouterReturn = FunctionReturn + +export type GetDynamicConfigParams = FunctionArguments +export type GetDynamicConfigReturn = FunctionReturn + +export type GetExpectedNextSequenceNumberParams = FunctionArguments +export type GetExpectedNextSequenceNumberReturn = FunctionReturn + +export type GetFeeParams = FunctionArguments +export type GetFeeReturn = FunctionReturn + +export type GetFeeTokenConfigParams = FunctionArguments +export type GetFeeTokenConfigReturn = FunctionReturn + +export type GetNopFeesJuelsParams = FunctionArguments +export type GetNopFeesJuelsReturn = FunctionReturn + +export type GetNopsParams = FunctionArguments +export type GetNopsReturn = FunctionReturn + +export type GetPoolBySourceTokenParams = FunctionArguments +export type GetPoolBySourceTokenReturn = FunctionReturn + +export type GetSenderNonceParams = FunctionArguments +export type GetSenderNonceReturn = FunctionReturn + +export type GetStaticConfigParams = FunctionArguments +export type GetStaticConfigReturn = FunctionReturn + +export type GetSupportedTokensParams = FunctionArguments +export type GetSupportedTokensReturn = FunctionReturn + +export type GetTokenLimitAdminParams = FunctionArguments +export type GetTokenLimitAdminReturn = FunctionReturn + +export type GetTokenTransferFeeConfigParams = FunctionArguments +export type GetTokenTransferFeeConfigReturn = FunctionReturn + +export type LinkAvailableForPaymentParams = FunctionArguments +export type LinkAvailableForPaymentReturn = FunctionReturn + +export type OwnerParams = FunctionArguments +export type OwnerReturn = FunctionReturn + +export type PayNopsParams = FunctionArguments +export type PayNopsReturn = FunctionReturn + +export type SetAdminParams = FunctionArguments +export type SetAdminReturn = FunctionReturn + +export type SetDynamicConfigParams = FunctionArguments +export type SetDynamicConfigReturn = FunctionReturn + +export type SetFeeTokenConfigParams = FunctionArguments +export type SetFeeTokenConfigReturn = FunctionReturn + +export type SetNopsParams = FunctionArguments +export type SetNopsReturn = FunctionReturn + +export type SetRateLimiterConfigParams = FunctionArguments +export type SetRateLimiterConfigReturn = FunctionReturn + +export type SetTokenTransferFeeConfigParams = FunctionArguments +export type SetTokenTransferFeeConfigReturn = FunctionReturn + +export type TransferOwnershipParams = FunctionArguments +export type TransferOwnershipReturn = FunctionReturn + +export type TypeAndVersionParams = FunctionArguments +export type TypeAndVersionReturn = FunctionReturn + +export type WithdrawNonLinkFeesParams = FunctionArguments +export type WithdrawNonLinkFeesReturn = FunctionReturn + diff --git a/src/abi/ccip-router.ts b/src/abi/ccip-router.ts index ff09d0a0..1c62932e 100644 --- a/src/abi/ccip-router.ts +++ b/src/abi/ccip-router.ts @@ -1,130 +1,144 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './ccip-router.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - MessageExecuted: new LogEvent<([messageId: string, sourceChainSelector: bigint, offRamp: string, calldataHash: string] & {messageId: string, sourceChainSelector: bigint, offRamp: string, calldataHash: string})>( - abi, '0x9b877de93ea9895756e337442c657f95a34fc68e7eb988bdfa693d5be83016b6' - ), - OffRampAdded: new LogEvent<([sourceChainSelector: bigint, offRamp: string] & {sourceChainSelector: bigint, offRamp: string})>( - abi, '0xa4bdf64ebdf3316320601a081916a75aa144bcef6c4beeb0e9fb1982cacc6b94' - ), - OffRampRemoved: new LogEvent<([sourceChainSelector: bigint, offRamp: string] & {sourceChainSelector: bigint, offRamp: string})>( - abi, '0xa823809efda3ba66c873364eec120fa0923d9fabda73bc97dd5663341e2d9bcb' - ), - OnRampSet: new LogEvent<([destChainSelector: bigint, onRamp: string] & {destChainSelector: bigint, onRamp: string})>( - abi, '0x1f7d0ec248b80e5c0dde0ee531c4fc8fdb6ce9a2b3d90f560c74acd6a7202f23' - ), - OwnershipTransferRequested: new LogEvent<([from: string, to: string] & {from: string, to: string})>( - abi, '0xed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae1278' - ), - OwnershipTransferred: new LogEvent<([from: string, to: string] & {from: string, to: string})>( - abi, '0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0' - ), + MessageExecuted: event("0x9b877de93ea9895756e337442c657f95a34fc68e7eb988bdfa693d5be83016b6", {"messageId": p.bytes32, "sourceChainSelector": p.uint64, "offRamp": p.address, "calldataHash": p.bytes32}), + OffRampAdded: event("0xa4bdf64ebdf3316320601a081916a75aa144bcef6c4beeb0e9fb1982cacc6b94", {"sourceChainSelector": indexed(p.uint64), "offRamp": p.address}), + OffRampRemoved: event("0xa823809efda3ba66c873364eec120fa0923d9fabda73bc97dd5663341e2d9bcb", {"sourceChainSelector": indexed(p.uint64), "offRamp": p.address}), + OnRampSet: event("0x1f7d0ec248b80e5c0dde0ee531c4fc8fdb6ce9a2b3d90f560c74acd6a7202f23", {"destChainSelector": indexed(p.uint64), "onRamp": p.address}), + OwnershipTransferRequested: event("0xed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae1278", {"from": indexed(p.address), "to": indexed(p.address)}), + OwnershipTransferred: event("0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", {"from": indexed(p.address), "to": indexed(p.address)}), } export const functions = { - MAX_RET_BYTES: new Func<[], {}, number>( - abi, '0x787350e3' - ), - acceptOwnership: new Func<[], {}, []>( - abi, '0x79ba5097' - ), - applyRampUpdates: new Func<[onRampUpdates: Array<([destChainSelector: bigint, onRamp: string] & {destChainSelector: bigint, onRamp: string})>, offRampRemoves: Array<([sourceChainSelector: bigint, offRamp: string] & {sourceChainSelector: bigint, offRamp: string})>, offRampAdds: Array<([sourceChainSelector: bigint, offRamp: string] & {sourceChainSelector: bigint, offRamp: string})>], {onRampUpdates: Array<([destChainSelector: bigint, onRamp: string] & {destChainSelector: bigint, onRamp: string})>, offRampRemoves: Array<([sourceChainSelector: bigint, offRamp: string] & {sourceChainSelector: bigint, offRamp: string})>, offRampAdds: Array<([sourceChainSelector: bigint, offRamp: string] & {sourceChainSelector: bigint, offRamp: string})>}, []>( - abi, '0xda5fcac8' - ), - ccipSend: new Func<[destinationChainSelector: bigint, message: ([receiver: string, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, feeToken: string, extraArgs: string] & {receiver: string, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, feeToken: string, extraArgs: string})], {destinationChainSelector: bigint, message: ([receiver: string, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, feeToken: string, extraArgs: string] & {receiver: string, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, feeToken: string, extraArgs: string})}, string>( - abi, '0x96f4e9f9' - ), - getArmProxy: new Func<[], {}, string>( - abi, '0x5246492f' - ), - getFee: new Func<[destinationChainSelector: bigint, message: ([receiver: string, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, feeToken: string, extraArgs: string] & {receiver: string, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, feeToken: string, extraArgs: string})], {destinationChainSelector: bigint, message: ([receiver: string, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, feeToken: string, extraArgs: string] & {receiver: string, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, feeToken: string, extraArgs: string})}, bigint>( - abi, '0x20487ded' - ), - getOffRamps: new Func<[], {}, Array<([sourceChainSelector: bigint, offRamp: string] & {sourceChainSelector: bigint, offRamp: string})>>( - abi, '0xa40e69c7' - ), - getOnRamp: new Func<[destChainSelector: bigint], {destChainSelector: bigint}, string>( - abi, '0xa8d87a3b' - ), - getSupportedTokens: new Func<[chainSelector: bigint], {chainSelector: bigint}, Array>( - abi, '0xfbca3b74' - ), - getWrappedNative: new Func<[], {}, string>( - abi, '0xe861e907' - ), - isChainSupported: new Func<[chainSelector: bigint], {chainSelector: bigint}, boolean>( - abi, '0xa48a9058' - ), - isOffRamp: new Func<[sourceChainSelector: bigint, offRamp: string], {sourceChainSelector: bigint, offRamp: string}, boolean>( - abi, '0x83826b2b' - ), - owner: new Func<[], {}, string>( - abi, '0x8da5cb5b' - ), - recoverTokens: new Func<[tokenAddress: string, to: string, amount: bigint], {tokenAddress: string, to: string, amount: bigint}, []>( - abi, '0x5f3e849f' - ), - routeMessage: new Func<[message: ([messageId: string, sourceChainSelector: bigint, sender: string, data: string, destTokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>] & {messageId: string, sourceChainSelector: bigint, sender: string, data: string, destTokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>}), gasForCallExactCheck: number, gasLimit: bigint, receiver: string], {message: ([messageId: string, sourceChainSelector: bigint, sender: string, data: string, destTokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>] & {messageId: string, sourceChainSelector: bigint, sender: string, data: string, destTokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>}), gasForCallExactCheck: number, gasLimit: bigint, receiver: string}, ([success: boolean, retData: string, gasUsed: bigint] & {success: boolean, retData: string, gasUsed: bigint})>( - abi, '0x3cf97983' - ), - setWrappedNative: new Func<[wrappedNative: string], {wrappedNative: string}, []>( - abi, '0x52cb60ca' - ), - transferOwnership: new Func<[to: string], {to: string}, []>( - abi, '0xf2fde38b' - ), - typeAndVersion: new Func<[], {}, string>( - abi, '0x181f5a77' - ), + MAX_RET_BYTES: fun("0x787350e3", {}, p.uint16), + acceptOwnership: fun("0x79ba5097", {}, ), + applyRampUpdates: fun("0xda5fcac8", {"onRampUpdates": p.array(p.struct({"destChainSelector": p.uint64, "onRamp": p.address})), "offRampRemoves": p.array(p.struct({"sourceChainSelector": p.uint64, "offRamp": p.address})), "offRampAdds": p.array(p.struct({"sourceChainSelector": p.uint64, "offRamp": p.address}))}, ), + ccipSend: fun("0x96f4e9f9", {"destinationChainSelector": p.uint64, "message": p.struct({"receiver": p.bytes, "data": p.bytes, "tokenAmounts": p.array(p.struct({"token": p.address, "amount": p.uint256})), "feeToken": p.address, "extraArgs": p.bytes})}, p.bytes32), + getArmProxy: fun("0x5246492f", {}, p.address), + getFee: fun("0x20487ded", {"destinationChainSelector": p.uint64, "message": p.struct({"receiver": p.bytes, "data": p.bytes, "tokenAmounts": p.array(p.struct({"token": p.address, "amount": p.uint256})), "feeToken": p.address, "extraArgs": p.bytes})}, p.uint256), + getOffRamps: fun("0xa40e69c7", {}, p.array(p.struct({"sourceChainSelector": p.uint64, "offRamp": p.address}))), + getOnRamp: fun("0xa8d87a3b", {"destChainSelector": p.uint64}, p.address), + getSupportedTokens: fun("0xfbca3b74", {"chainSelector": p.uint64}, p.array(p.address)), + getWrappedNative: fun("0xe861e907", {}, p.address), + isChainSupported: fun("0xa48a9058", {"chainSelector": p.uint64}, p.bool), + isOffRamp: fun("0x83826b2b", {"sourceChainSelector": p.uint64, "offRamp": p.address}, p.bool), + owner: fun("0x8da5cb5b", {}, p.address), + recoverTokens: fun("0x5f3e849f", {"tokenAddress": p.address, "to": p.address, "amount": p.uint256}, ), + routeMessage: fun("0x3cf97983", {"message": p.struct({"messageId": p.bytes32, "sourceChainSelector": p.uint64, "sender": p.bytes, "data": p.bytes, "destTokenAmounts": p.array(p.struct({"token": p.address, "amount": p.uint256}))}), "gasForCallExactCheck": p.uint16, "gasLimit": p.uint256, "receiver": p.address}, {"success": p.bool, "retData": p.bytes, "gasUsed": p.uint256}), + setWrappedNative: fun("0x52cb60ca", {"wrappedNative": p.address}, ), + transferOwnership: fun("0xf2fde38b", {"to": p.address}, ), + typeAndVersion: fun("0x181f5a77", {}, p.string), } export class Contract extends ContractBase { - MAX_RET_BYTES(): Promise { - return this.eth_call(functions.MAX_RET_BYTES, []) + MAX_RET_BYTES() { + return this.eth_call(functions.MAX_RET_BYTES, {}) } - getArmProxy(): Promise { - return this.eth_call(functions.getArmProxy, []) + getArmProxy() { + return this.eth_call(functions.getArmProxy, {}) } - getFee(destinationChainSelector: bigint, message: ([receiver: string, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, feeToken: string, extraArgs: string] & {receiver: string, data: string, tokenAmounts: Array<([token: string, amount: bigint] & {token: string, amount: bigint})>, feeToken: string, extraArgs: string})): Promise { - return this.eth_call(functions.getFee, [destinationChainSelector, message]) + getFee(destinationChainSelector: GetFeeParams["destinationChainSelector"], message: GetFeeParams["message"]) { + return this.eth_call(functions.getFee, {destinationChainSelector, message}) } - getOffRamps(): Promise> { - return this.eth_call(functions.getOffRamps, []) + getOffRamps() { + return this.eth_call(functions.getOffRamps, {}) } - getOnRamp(destChainSelector: bigint): Promise { - return this.eth_call(functions.getOnRamp, [destChainSelector]) + getOnRamp(destChainSelector: GetOnRampParams["destChainSelector"]) { + return this.eth_call(functions.getOnRamp, {destChainSelector}) } - getSupportedTokens(chainSelector: bigint): Promise> { - return this.eth_call(functions.getSupportedTokens, [chainSelector]) + getSupportedTokens(chainSelector: GetSupportedTokensParams["chainSelector"]) { + return this.eth_call(functions.getSupportedTokens, {chainSelector}) } - getWrappedNative(): Promise { - return this.eth_call(functions.getWrappedNative, []) + getWrappedNative() { + return this.eth_call(functions.getWrappedNative, {}) } - isChainSupported(chainSelector: bigint): Promise { - return this.eth_call(functions.isChainSupported, [chainSelector]) + isChainSupported(chainSelector: IsChainSupportedParams["chainSelector"]) { + return this.eth_call(functions.isChainSupported, {chainSelector}) } - isOffRamp(sourceChainSelector: bigint, offRamp: string): Promise { - return this.eth_call(functions.isOffRamp, [sourceChainSelector, offRamp]) + isOffRamp(sourceChainSelector: IsOffRampParams["sourceChainSelector"], offRamp: IsOffRampParams["offRamp"]) { + return this.eth_call(functions.isOffRamp, {sourceChainSelector, offRamp}) } - owner(): Promise { - return this.eth_call(functions.owner, []) + owner() { + return this.eth_call(functions.owner, {}) } - typeAndVersion(): Promise { - return this.eth_call(functions.typeAndVersion, []) + typeAndVersion() { + return this.eth_call(functions.typeAndVersion, {}) } } + +/// Event types +export type MessageExecutedEventArgs = EParams +export type OffRampAddedEventArgs = EParams +export type OffRampRemovedEventArgs = EParams +export type OnRampSetEventArgs = EParams +export type OwnershipTransferRequestedEventArgs = EParams +export type OwnershipTransferredEventArgs = EParams + +/// Function types +export type MAX_RET_BYTESParams = FunctionArguments +export type MAX_RET_BYTESReturn = FunctionReturn + +export type AcceptOwnershipParams = FunctionArguments +export type AcceptOwnershipReturn = FunctionReturn + +export type ApplyRampUpdatesParams = FunctionArguments +export type ApplyRampUpdatesReturn = FunctionReturn + +export type CcipSendParams = FunctionArguments +export type CcipSendReturn = FunctionReturn + +export type GetArmProxyParams = FunctionArguments +export type GetArmProxyReturn = FunctionReturn + +export type GetFeeParams = FunctionArguments +export type GetFeeReturn = FunctionReturn + +export type GetOffRampsParams = FunctionArguments +export type GetOffRampsReturn = FunctionReturn + +export type GetOnRampParams = FunctionArguments +export type GetOnRampReturn = FunctionReturn + +export type GetSupportedTokensParams = FunctionArguments +export type GetSupportedTokensReturn = FunctionReturn + +export type GetWrappedNativeParams = FunctionArguments +export type GetWrappedNativeReturn = FunctionReturn + +export type IsChainSupportedParams = FunctionArguments +export type IsChainSupportedReturn = FunctionReturn + +export type IsOffRampParams = FunctionArguments +export type IsOffRampReturn = FunctionReturn + +export type OwnerParams = FunctionArguments +export type OwnerReturn = FunctionReturn + +export type RecoverTokensParams = FunctionArguments +export type RecoverTokensReturn = FunctionReturn + +export type RouteMessageParams = FunctionArguments +export type RouteMessageReturn = FunctionReturn + +export type SetWrappedNativeParams = FunctionArguments +export type SetWrappedNativeReturn = FunctionReturn + +export type TransferOwnershipParams = FunctionArguments +export type TransferOwnershipReturn = FunctionReturn + +export type TypeAndVersionParams = FunctionArguments +export type TypeAndVersionReturn = FunctionReturn + diff --git a/src/abi/chainlink-feed-registry.ts b/src/abi/chainlink-feed-registry.ts index ad698ce5..f036e88c 100644 --- a/src/abi/chainlink-feed-registry.ts +++ b/src/abi/chainlink-feed-registry.ts @@ -1,219 +1,246 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './chainlink-feed-registry.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - AccessControllerSet: new LogEvent<([accessController: string, sender: string] & {accessController: string, sender: string})>( - abi, '0x953e92b1a6442e9c3242531154a3f6f6eb00b4e9c719ba8118fa6235e4ce89b6' - ), - FeedConfirmed: new LogEvent<([asset: string, denomination: string, latestAggregator: string, previousAggregator: string, nextPhaseId: number, sender: string] & {asset: string, denomination: string, latestAggregator: string, previousAggregator: string, nextPhaseId: number, sender: string})>( - abi, '0x27a180c70f2642f63d1694eb252b7df52e7ab2565e3f67adf7748acb7d82b9bc' - ), - FeedProposed: new LogEvent<([asset: string, denomination: string, proposedAggregator: string, currentAggregator: string, sender: string] & {asset: string, denomination: string, proposedAggregator: string, currentAggregator: string, sender: string})>( - abi, '0xb56c4f88c3e344891ef92e51f036d7116e886f4ea57f5ba93e28b5f44925b9ce' - ), - OwnershipTransferRequested: new LogEvent<([from: string, to: string] & {from: string, to: string})>( - abi, '0xed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae1278' - ), - OwnershipTransferred: new LogEvent<([from: string, to: string] & {from: string, to: string})>( - abi, '0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0' - ), + AccessControllerSet: event("0x953e92b1a6442e9c3242531154a3f6f6eb00b4e9c719ba8118fa6235e4ce89b6", {"accessController": indexed(p.address), "sender": indexed(p.address)}), + FeedConfirmed: event("0x27a180c70f2642f63d1694eb252b7df52e7ab2565e3f67adf7748acb7d82b9bc", {"asset": indexed(p.address), "denomination": indexed(p.address), "latestAggregator": indexed(p.address), "previousAggregator": p.address, "nextPhaseId": p.uint16, "sender": p.address}), + FeedProposed: event("0xb56c4f88c3e344891ef92e51f036d7116e886f4ea57f5ba93e28b5f44925b9ce", {"asset": indexed(p.address), "denomination": indexed(p.address), "proposedAggregator": indexed(p.address), "currentAggregator": p.address, "sender": p.address}), + OwnershipTransferRequested: event("0xed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae1278", {"from": indexed(p.address), "to": indexed(p.address)}), + OwnershipTransferred: event("0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", {"from": indexed(p.address), "to": indexed(p.address)}), } export const functions = { - acceptOwnership: new Func<[], {}, []>( - abi, '0x79ba5097' - ), - confirmFeed: new Func<[base: string, quote: string, aggregator: string], {base: string, quote: string, aggregator: string}, []>( - abi, '0x045abf4b' - ), - decimals: new Func<[base: string, quote: string], {base: string, quote: string}, number>( - abi, '0x58e2d3a8' - ), - description: new Func<[base: string, quote: string], {base: string, quote: string}, string>( - abi, '0xfa820de9' - ), - getAccessController: new Func<[], {}, string>( - abi, '0x16d6b5f6' - ), - getAnswer: new Func<[base: string, quote: string, roundId: bigint], {base: string, quote: string, roundId: bigint}, bigint>( - abi, '0x15cd4ad2' - ), - getCurrentPhaseId: new Func<[base: string, quote: string], {base: string, quote: string}, number>( - abi, '0x30322818' - ), - getFeed: new Func<[base: string, quote: string], {base: string, quote: string}, string>( - abi, '0xd2edb6dd' - ), - getNextRoundId: new Func<[base: string, quote: string, roundId: bigint], {base: string, quote: string, roundId: bigint}, bigint>( - abi, '0xa051538e' - ), - getPhase: new Func<[base: string, quote: string, phaseId: number], {base: string, quote: string, phaseId: number}, ([phaseId: number, startingAggregatorRoundId: bigint, endingAggregatorRoundId: bigint] & {phaseId: number, startingAggregatorRoundId: bigint, endingAggregatorRoundId: bigint})>( - abi, '0xff0601c0' - ), - getPhaseFeed: new Func<[base: string, quote: string, phaseId: number], {base: string, quote: string, phaseId: number}, string>( - abi, '0x52dbeb8b' - ), - getPhaseRange: new Func<[base: string, quote: string, phaseId: number], {base: string, quote: string, phaseId: number}, ([startingRoundId: bigint, endingRoundId: bigint] & {startingRoundId: bigint, endingRoundId: bigint})>( - abi, '0xc1ce86fc' - ), - getPreviousRoundId: new Func<[base: string, quote: string, roundId: bigint], {base: string, quote: string, roundId: bigint}, bigint>( - abi, '0x9e3ff6fd' - ), - getProposedFeed: new Func<[base: string, quote: string], {base: string, quote: string}, string>( - abi, '0x5ad9d9df' - ), - getRoundData: new Func<[base: string, quote: string, _roundId: bigint], {base: string, quote: string, _roundId: bigint}, ([roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint] & {roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint})>( - abi, '0xfc58749e' - ), - getRoundFeed: new Func<[base: string, quote: string, roundId: bigint], {base: string, quote: string, roundId: bigint}, string>( - abi, '0xc639cd91' - ), - getTimestamp: new Func<[base: string, quote: string, roundId: bigint], {base: string, quote: string, roundId: bigint}, bigint>( - abi, '0x91624c95' - ), - isFeedEnabled: new Func<[aggregator: string], {aggregator: string}, boolean>( - abi, '0xb099d43b' - ), - latestAnswer: new Func<[base: string, quote: string], {base: string, quote: string}, bigint>( - abi, '0xd4c282a3' - ), - latestRound: new Func<[base: string, quote: string], {base: string, quote: string}, bigint>( - abi, '0xec62f44b' - ), - latestRoundData: new Func<[base: string, quote: string], {base: string, quote: string}, ([roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint] & {roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint})>( - abi, '0xbcfd032d' - ), - latestTimestamp: new Func<[base: string, quote: string], {base: string, quote: string}, bigint>( - abi, '0x672ff44f' - ), - owner: new Func<[], {}, string>( - abi, '0x8da5cb5b' - ), - proposeFeed: new Func<[base: string, quote: string, aggregator: string], {base: string, quote: string, aggregator: string}, []>( - abi, '0x9eed82b0' - ), - proposedGetRoundData: new Func<[base: string, quote: string, roundId: bigint], {base: string, quote: string, roundId: bigint}, ([id: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint] & {id: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint})>( - abi, '0x8916524a' - ), - proposedLatestRoundData: new Func<[base: string, quote: string], {base: string, quote: string}, ([id: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint] & {id: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint})>( - abi, '0xd0188fc6' - ), - setAccessController: new Func<[_accessController: string], {_accessController: string}, []>( - abi, '0xf08391d8' - ), - transferOwnership: new Func<[to: string], {to: string}, []>( - abi, '0xf2fde38b' - ), - typeAndVersion: new Func<[], {}, string>( - abi, '0x181f5a77' - ), - version: new Func<[base: string, quote: string], {base: string, quote: string}, bigint>( - abi, '0xaf34b03a' - ), + acceptOwnership: fun("0x79ba5097", {}, ), + confirmFeed: fun("0x045abf4b", {"base": p.address, "quote": p.address, "aggregator": p.address}, ), + decimals: fun("0x58e2d3a8", {"base": p.address, "quote": p.address}, p.uint8), + description: fun("0xfa820de9", {"base": p.address, "quote": p.address}, p.string), + getAccessController: fun("0x16d6b5f6", {}, p.address), + getAnswer: fun("0x15cd4ad2", {"base": p.address, "quote": p.address, "roundId": p.uint256}, p.int256), + getCurrentPhaseId: fun("0x30322818", {"base": p.address, "quote": p.address}, p.uint16), + getFeed: fun("0xd2edb6dd", {"base": p.address, "quote": p.address}, p.address), + getNextRoundId: fun("0xa051538e", {"base": p.address, "quote": p.address, "roundId": p.uint80}, p.uint80), + getPhase: fun("0xff0601c0", {"base": p.address, "quote": p.address, "phaseId": p.uint16}, p.struct({"phaseId": p.uint16, "startingAggregatorRoundId": p.uint80, "endingAggregatorRoundId": p.uint80})), + getPhaseFeed: fun("0x52dbeb8b", {"base": p.address, "quote": p.address, "phaseId": p.uint16}, p.address), + getPhaseRange: fun("0xc1ce86fc", {"base": p.address, "quote": p.address, "phaseId": p.uint16}, {"startingRoundId": p.uint80, "endingRoundId": p.uint80}), + getPreviousRoundId: fun("0x9e3ff6fd", {"base": p.address, "quote": p.address, "roundId": p.uint80}, p.uint80), + getProposedFeed: fun("0x5ad9d9df", {"base": p.address, "quote": p.address}, p.address), + getRoundData: fun("0xfc58749e", {"base": p.address, "quote": p.address, "_roundId": p.uint80}, {"roundId": p.uint80, "answer": p.int256, "startedAt": p.uint256, "updatedAt": p.uint256, "answeredInRound": p.uint80}), + getRoundFeed: fun("0xc639cd91", {"base": p.address, "quote": p.address, "roundId": p.uint80}, p.address), + getTimestamp: fun("0x91624c95", {"base": p.address, "quote": p.address, "roundId": p.uint256}, p.uint256), + isFeedEnabled: fun("0xb099d43b", {"aggregator": p.address}, p.bool), + latestAnswer: fun("0xd4c282a3", {"base": p.address, "quote": p.address}, p.int256), + latestRound: fun("0xec62f44b", {"base": p.address, "quote": p.address}, p.uint256), + latestRoundData: fun("0xbcfd032d", {"base": p.address, "quote": p.address}, {"roundId": p.uint80, "answer": p.int256, "startedAt": p.uint256, "updatedAt": p.uint256, "answeredInRound": p.uint80}), + latestTimestamp: fun("0x672ff44f", {"base": p.address, "quote": p.address}, p.uint256), + owner: fun("0x8da5cb5b", {}, p.address), + proposeFeed: fun("0x9eed82b0", {"base": p.address, "quote": p.address, "aggregator": p.address}, ), + proposedGetRoundData: fun("0x8916524a", {"base": p.address, "quote": p.address, "roundId": p.uint80}, {"id": p.uint80, "answer": p.int256, "startedAt": p.uint256, "updatedAt": p.uint256, "answeredInRound": p.uint80}), + proposedLatestRoundData: fun("0xd0188fc6", {"base": p.address, "quote": p.address}, {"id": p.uint80, "answer": p.int256, "startedAt": p.uint256, "updatedAt": p.uint256, "answeredInRound": p.uint80}), + setAccessController: fun("0xf08391d8", {"_accessController": p.address}, ), + transferOwnership: fun("0xf2fde38b", {"to": p.address}, ), + typeAndVersion: fun("0x181f5a77", {}, p.string), + version: fun("0xaf34b03a", {"base": p.address, "quote": p.address}, p.uint256), } export class Contract extends ContractBase { - decimals(base: string, quote: string): Promise { - return this.eth_call(functions.decimals, [base, quote]) + decimals(base: DecimalsParams["base"], quote: DecimalsParams["quote"]) { + return this.eth_call(functions.decimals, {base, quote}) } - description(base: string, quote: string): Promise { - return this.eth_call(functions.description, [base, quote]) + description(base: DescriptionParams["base"], quote: DescriptionParams["quote"]) { + return this.eth_call(functions.description, {base, quote}) } - getAccessController(): Promise { - return this.eth_call(functions.getAccessController, []) + getAccessController() { + return this.eth_call(functions.getAccessController, {}) } - getAnswer(base: string, quote: string, roundId: bigint): Promise { - return this.eth_call(functions.getAnswer, [base, quote, roundId]) + getAnswer(base: GetAnswerParams["base"], quote: GetAnswerParams["quote"], roundId: GetAnswerParams["roundId"]) { + return this.eth_call(functions.getAnswer, {base, quote, roundId}) } - getCurrentPhaseId(base: string, quote: string): Promise { - return this.eth_call(functions.getCurrentPhaseId, [base, quote]) + getCurrentPhaseId(base: GetCurrentPhaseIdParams["base"], quote: GetCurrentPhaseIdParams["quote"]) { + return this.eth_call(functions.getCurrentPhaseId, {base, quote}) } - getFeed(base: string, quote: string): Promise { - return this.eth_call(functions.getFeed, [base, quote]) + getFeed(base: GetFeedParams["base"], quote: GetFeedParams["quote"]) { + return this.eth_call(functions.getFeed, {base, quote}) } - getNextRoundId(base: string, quote: string, roundId: bigint): Promise { - return this.eth_call(functions.getNextRoundId, [base, quote, roundId]) + getNextRoundId(base: GetNextRoundIdParams["base"], quote: GetNextRoundIdParams["quote"], roundId: GetNextRoundIdParams["roundId"]) { + return this.eth_call(functions.getNextRoundId, {base, quote, roundId}) } - getPhase(base: string, quote: string, phaseId: number): Promise<([phaseId: number, startingAggregatorRoundId: bigint, endingAggregatorRoundId: bigint] & {phaseId: number, startingAggregatorRoundId: bigint, endingAggregatorRoundId: bigint})> { - return this.eth_call(functions.getPhase, [base, quote, phaseId]) + getPhase(base: GetPhaseParams["base"], quote: GetPhaseParams["quote"], phaseId: GetPhaseParams["phaseId"]) { + return this.eth_call(functions.getPhase, {base, quote, phaseId}) } - getPhaseFeed(base: string, quote: string, phaseId: number): Promise { - return this.eth_call(functions.getPhaseFeed, [base, quote, phaseId]) + getPhaseFeed(base: GetPhaseFeedParams["base"], quote: GetPhaseFeedParams["quote"], phaseId: GetPhaseFeedParams["phaseId"]) { + return this.eth_call(functions.getPhaseFeed, {base, quote, phaseId}) } - getPhaseRange(base: string, quote: string, phaseId: number): Promise<([startingRoundId: bigint, endingRoundId: bigint] & {startingRoundId: bigint, endingRoundId: bigint})> { - return this.eth_call(functions.getPhaseRange, [base, quote, phaseId]) + getPhaseRange(base: GetPhaseRangeParams["base"], quote: GetPhaseRangeParams["quote"], phaseId: GetPhaseRangeParams["phaseId"]) { + return this.eth_call(functions.getPhaseRange, {base, quote, phaseId}) } - getPreviousRoundId(base: string, quote: string, roundId: bigint): Promise { - return this.eth_call(functions.getPreviousRoundId, [base, quote, roundId]) + getPreviousRoundId(base: GetPreviousRoundIdParams["base"], quote: GetPreviousRoundIdParams["quote"], roundId: GetPreviousRoundIdParams["roundId"]) { + return this.eth_call(functions.getPreviousRoundId, {base, quote, roundId}) } - getProposedFeed(base: string, quote: string): Promise { - return this.eth_call(functions.getProposedFeed, [base, quote]) + getProposedFeed(base: GetProposedFeedParams["base"], quote: GetProposedFeedParams["quote"]) { + return this.eth_call(functions.getProposedFeed, {base, quote}) } - getRoundData(base: string, quote: string, _roundId: bigint): Promise<([roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint] & {roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint})> { - return this.eth_call(functions.getRoundData, [base, quote, _roundId]) + getRoundData(base: GetRoundDataParams["base"], quote: GetRoundDataParams["quote"], _roundId: GetRoundDataParams["_roundId"]) { + return this.eth_call(functions.getRoundData, {base, quote, _roundId}) } - getRoundFeed(base: string, quote: string, roundId: bigint): Promise { - return this.eth_call(functions.getRoundFeed, [base, quote, roundId]) + getRoundFeed(base: GetRoundFeedParams["base"], quote: GetRoundFeedParams["quote"], roundId: GetRoundFeedParams["roundId"]) { + return this.eth_call(functions.getRoundFeed, {base, quote, roundId}) } - getTimestamp(base: string, quote: string, roundId: bigint): Promise { - return this.eth_call(functions.getTimestamp, [base, quote, roundId]) + getTimestamp(base: GetTimestampParams["base"], quote: GetTimestampParams["quote"], roundId: GetTimestampParams["roundId"]) { + return this.eth_call(functions.getTimestamp, {base, quote, roundId}) } - isFeedEnabled(aggregator: string): Promise { - return this.eth_call(functions.isFeedEnabled, [aggregator]) + isFeedEnabled(aggregator: IsFeedEnabledParams["aggregator"]) { + return this.eth_call(functions.isFeedEnabled, {aggregator}) } - latestAnswer(base: string, quote: string): Promise { - return this.eth_call(functions.latestAnswer, [base, quote]) + latestAnswer(base: LatestAnswerParams["base"], quote: LatestAnswerParams["quote"]) { + return this.eth_call(functions.latestAnswer, {base, quote}) } - latestRound(base: string, quote: string): Promise { - return this.eth_call(functions.latestRound, [base, quote]) + latestRound(base: LatestRoundParams["base"], quote: LatestRoundParams["quote"]) { + return this.eth_call(functions.latestRound, {base, quote}) } - latestRoundData(base: string, quote: string): Promise<([roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint] & {roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint})> { - return this.eth_call(functions.latestRoundData, [base, quote]) + latestRoundData(base: LatestRoundDataParams["base"], quote: LatestRoundDataParams["quote"]) { + return this.eth_call(functions.latestRoundData, {base, quote}) } - latestTimestamp(base: string, quote: string): Promise { - return this.eth_call(functions.latestTimestamp, [base, quote]) + latestTimestamp(base: LatestTimestampParams["base"], quote: LatestTimestampParams["quote"]) { + return this.eth_call(functions.latestTimestamp, {base, quote}) } - owner(): Promise { - return this.eth_call(functions.owner, []) + owner() { + return this.eth_call(functions.owner, {}) } - proposedGetRoundData(base: string, quote: string, roundId: bigint): Promise<([id: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint] & {id: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint})> { - return this.eth_call(functions.proposedGetRoundData, [base, quote, roundId]) + proposedGetRoundData(base: ProposedGetRoundDataParams["base"], quote: ProposedGetRoundDataParams["quote"], roundId: ProposedGetRoundDataParams["roundId"]) { + return this.eth_call(functions.proposedGetRoundData, {base, quote, roundId}) } - proposedLatestRoundData(base: string, quote: string): Promise<([id: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint] & {id: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint})> { - return this.eth_call(functions.proposedLatestRoundData, [base, quote]) + proposedLatestRoundData(base: ProposedLatestRoundDataParams["base"], quote: ProposedLatestRoundDataParams["quote"]) { + return this.eth_call(functions.proposedLatestRoundData, {base, quote}) } - typeAndVersion(): Promise { - return this.eth_call(functions.typeAndVersion, []) + typeAndVersion() { + return this.eth_call(functions.typeAndVersion, {}) } - version(base: string, quote: string): Promise { - return this.eth_call(functions.version, [base, quote]) + version(base: VersionParams["base"], quote: VersionParams["quote"]) { + return this.eth_call(functions.version, {base, quote}) } } + +/// Event types +export type AccessControllerSetEventArgs = EParams +export type FeedConfirmedEventArgs = EParams +export type FeedProposedEventArgs = EParams +export type OwnershipTransferRequestedEventArgs = EParams +export type OwnershipTransferredEventArgs = EParams + +/// Function types +export type AcceptOwnershipParams = FunctionArguments +export type AcceptOwnershipReturn = FunctionReturn + +export type ConfirmFeedParams = FunctionArguments +export type ConfirmFeedReturn = FunctionReturn + +export type DecimalsParams = FunctionArguments +export type DecimalsReturn = FunctionReturn + +export type DescriptionParams = FunctionArguments +export type DescriptionReturn = FunctionReturn + +export type GetAccessControllerParams = FunctionArguments +export type GetAccessControllerReturn = FunctionReturn + +export type GetAnswerParams = FunctionArguments +export type GetAnswerReturn = FunctionReturn + +export type GetCurrentPhaseIdParams = FunctionArguments +export type GetCurrentPhaseIdReturn = FunctionReturn + +export type GetFeedParams = FunctionArguments +export type GetFeedReturn = FunctionReturn + +export type GetNextRoundIdParams = FunctionArguments +export type GetNextRoundIdReturn = FunctionReturn + +export type GetPhaseParams = FunctionArguments +export type GetPhaseReturn = FunctionReturn + +export type GetPhaseFeedParams = FunctionArguments +export type GetPhaseFeedReturn = FunctionReturn + +export type GetPhaseRangeParams = FunctionArguments +export type GetPhaseRangeReturn = FunctionReturn + +export type GetPreviousRoundIdParams = FunctionArguments +export type GetPreviousRoundIdReturn = FunctionReturn + +export type GetProposedFeedParams = FunctionArguments +export type GetProposedFeedReturn = FunctionReturn + +export type GetRoundDataParams = FunctionArguments +export type GetRoundDataReturn = FunctionReturn + +export type GetRoundFeedParams = FunctionArguments +export type GetRoundFeedReturn = FunctionReturn + +export type GetTimestampParams = FunctionArguments +export type GetTimestampReturn = FunctionReturn + +export type IsFeedEnabledParams = FunctionArguments +export type IsFeedEnabledReturn = FunctionReturn + +export type LatestAnswerParams = FunctionArguments +export type LatestAnswerReturn = FunctionReturn + +export type LatestRoundParams = FunctionArguments +export type LatestRoundReturn = FunctionReturn + +export type LatestRoundDataParams = FunctionArguments +export type LatestRoundDataReturn = FunctionReturn + +export type LatestTimestampParams = FunctionArguments +export type LatestTimestampReturn = FunctionReturn + +export type OwnerParams = FunctionArguments +export type OwnerReturn = FunctionReturn + +export type ProposeFeedParams = FunctionArguments +export type ProposeFeedReturn = FunctionReturn + +export type ProposedGetRoundDataParams = FunctionArguments +export type ProposedGetRoundDataReturn = FunctionReturn + +export type ProposedLatestRoundDataParams = FunctionArguments +export type ProposedLatestRoundDataReturn = FunctionReturn + +export type SetAccessControllerParams = FunctionArguments +export type SetAccessControllerReturn = FunctionReturn + +export type TransferOwnershipParams = FunctionArguments +export type TransferOwnershipReturn = FunctionReturn + +export type TypeAndVersionParams = FunctionArguments +export type TypeAndVersionReturn = FunctionReturn + +export type VersionParams = FunctionArguments +export type VersionReturn = FunctionReturn + diff --git a/src/abi/curve-lp-token.ts b/src/abi/curve-lp-token.ts index 4d67eacb..94d26e9e 100644 --- a/src/abi/curve-lp-token.ts +++ b/src/abi/curve-lp-token.ts @@ -1,341 +1,386 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './curve-lp-token.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - Transfer: new LogEvent<([sender: string, receiver: string, value: bigint] & {sender: string, receiver: string, value: bigint})>( - abi, '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' - ), - Approval: new LogEvent<([owner: string, spender: string, value: bigint] & {owner: string, spender: string, value: bigint})>( - abi, '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925' - ), - TokenExchange: new LogEvent<([buyer: string, sold_id: bigint, tokens_sold: bigint, bought_id: bigint, tokens_bought: bigint] & {buyer: string, sold_id: bigint, tokens_sold: bigint, bought_id: bigint, tokens_bought: bigint})>( - abi, '0x8b3e96f2b889fa771c53c981b40daf005f63f637f1869f707052d15a3dd97140' - ), - AddLiquidity: new LogEvent<([provider: string, token_amounts: Array, fees: Array, invariant: bigint, token_supply: bigint] & {provider: string, token_amounts: Array, fees: Array, invariant: bigint, token_supply: bigint})>( - abi, '0x26f55a85081d24974e85c6c00045d0f0453991e95873f52bff0d21af4079a768' - ), - RemoveLiquidity: new LogEvent<([provider: string, token_amounts: Array, fees: Array, token_supply: bigint] & {provider: string, token_amounts: Array, fees: Array, token_supply: bigint})>( - abi, '0x7c363854ccf79623411f8995b362bce5eddff18c927edc6f5dbbb5e05819a82c' - ), - RemoveLiquidityOne: new LogEvent<([provider: string, token_amount: bigint, coin_amount: bigint, token_supply: bigint] & {provider: string, token_amount: bigint, coin_amount: bigint, token_supply: bigint})>( - abi, '0x5ad056f2e28a8cec232015406b843668c1e36cda598127ec3b8c59b8c72773a0' - ), - RemoveLiquidityImbalance: new LogEvent<([provider: string, token_amounts: Array, fees: Array, invariant: bigint, token_supply: bigint] & {provider: string, token_amounts: Array, fees: Array, invariant: bigint, token_supply: bigint})>( - abi, '0x2b5508378d7e19e0d5fa338419034731416c4f5b219a10379956f764317fd47e' - ), - RampA: new LogEvent<([old_A: bigint, new_A: bigint, initial_time: bigint, future_time: bigint] & {old_A: bigint, new_A: bigint, initial_time: bigint, future_time: bigint})>( - abi, '0xa2b71ec6df949300b59aab36b55e189697b750119dd349fcfa8c0f779e83c254' - ), - StopRampA: new LogEvent<([A: bigint, t: bigint] & {A: bigint, t: bigint})>( - abi, '0x46e22fb3709ad289f62ce63d469248536dbc78d82b84a3d7e74ad606dc201938' - ), - CommitNewFee: new LogEvent<([new_fee: bigint] & {new_fee: bigint})>( - abi, '0x878eb36b3f197f05821c06953d9bc8f14b332a227b1e26df06a4215bbfe5d73f' - ), - ApplyNewFee: new LogEvent<([fee: bigint] & {fee: bigint})>( - abi, '0xa8715770654f54603947addf38c689adbd7182e21673b28bcf306a957aaba215' - ), + Transfer: event("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", {"sender": indexed(p.address), "receiver": indexed(p.address), "value": p.uint256}), + Approval: event("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", {"owner": indexed(p.address), "spender": indexed(p.address), "value": p.uint256}), + TokenExchange: event("0x8b3e96f2b889fa771c53c981b40daf005f63f637f1869f707052d15a3dd97140", {"buyer": indexed(p.address), "sold_id": p.int128, "tokens_sold": p.uint256, "bought_id": p.int128, "tokens_bought": p.uint256}), + AddLiquidity: event("0x26f55a85081d24974e85c6c00045d0f0453991e95873f52bff0d21af4079a768", {"provider": indexed(p.address), "token_amounts": p.fixedSizeArray(p.uint256, 2), "fees": p.fixedSizeArray(p.uint256, 2), "invariant": p.uint256, "token_supply": p.uint256}), + RemoveLiquidity: event("0x7c363854ccf79623411f8995b362bce5eddff18c927edc6f5dbbb5e05819a82c", {"provider": indexed(p.address), "token_amounts": p.fixedSizeArray(p.uint256, 2), "fees": p.fixedSizeArray(p.uint256, 2), "token_supply": p.uint256}), + RemoveLiquidityOne: event("0x5ad056f2e28a8cec232015406b843668c1e36cda598127ec3b8c59b8c72773a0", {"provider": indexed(p.address), "token_amount": p.uint256, "coin_amount": p.uint256, "token_supply": p.uint256}), + RemoveLiquidityImbalance: event("0x2b5508378d7e19e0d5fa338419034731416c4f5b219a10379956f764317fd47e", {"provider": indexed(p.address), "token_amounts": p.fixedSizeArray(p.uint256, 2), "fees": p.fixedSizeArray(p.uint256, 2), "invariant": p.uint256, "token_supply": p.uint256}), + RampA: event("0xa2b71ec6df949300b59aab36b55e189697b750119dd349fcfa8c0f779e83c254", {"old_A": p.uint256, "new_A": p.uint256, "initial_time": p.uint256, "future_time": p.uint256}), + StopRampA: event("0x46e22fb3709ad289f62ce63d469248536dbc78d82b84a3d7e74ad606dc201938", {"A": p.uint256, "t": p.uint256}), + CommitNewFee: event("0x878eb36b3f197f05821c06953d9bc8f14b332a227b1e26df06a4215bbfe5d73f", {"new_fee": p.uint256}), + ApplyNewFee: event("0xa8715770654f54603947addf38c689adbd7182e21673b28bcf306a957aaba215", {"fee": p.uint256}), } export const functions = { - initialize: new Func<[_name: string, _symbol: string, _coins: Array, _rate_multipliers: Array, _A: bigint, _fee: bigint], {_name: string, _symbol: string, _coins: Array, _rate_multipliers: Array, _A: bigint, _fee: bigint}, []>( - abi, '0xa461b3c8' - ), - decimals: new Func<[], {}, bigint>( - abi, '0x313ce567' - ), - transfer: new Func<[_to: string, _value: bigint], {_to: string, _value: bigint}, boolean>( - abi, '0xa9059cbb' - ), - transferFrom: new Func<[_from: string, _to: string, _value: bigint], {_from: string, _to: string, _value: bigint}, boolean>( - abi, '0x23b872dd' - ), - approve: new Func<[_spender: string, _value: bigint], {_spender: string, _value: bigint}, boolean>( - abi, '0x095ea7b3' - ), - permit: new Func<[_owner: string, _spender: string, _value: bigint, _deadline: bigint, _v: number, _r: string, _s: string], {_owner: string, _spender: string, _value: bigint, _deadline: bigint, _v: number, _r: string, _s: string}, boolean>( - abi, '0xd505accf' - ), - last_price: new Func<[], {}, bigint>( - abi, '0xfde625e6' - ), - ema_price: new Func<[], {}, bigint>( - abi, '0xc24c7c29' - ), - get_balances: new Func<[], {}, Array>( - abi, '0x14f05979' - ), - admin_fee: new Func<[], {}, bigint>( - abi, '0xfee3f7f9' - ), - A: new Func<[], {}, bigint>( - abi, '0xf446c1d0' - ), - A_precise: new Func<[], {}, bigint>( - abi, '0x76a2f0f0' - ), - get_p: new Func<[], {}, bigint>( - abi, '0xf2388acb' - ), - price_oracle: new Func<[], {}, bigint>( - abi, '0x86fc88d3' - ), - get_virtual_price: new Func<[], {}, bigint>( - abi, '0xbb7b8b80' - ), - calc_token_amount: new Func<[_amounts: Array, _is_deposit: boolean], {_amounts: Array, _is_deposit: boolean}, bigint>( - abi, '0xed8e84f3' - ), - 'add_liquidity(uint256[2],uint256)': new Func<[_amounts: Array, _min_mint_amount: bigint], {_amounts: Array, _min_mint_amount: bigint}, bigint>( - abi, '0x0b4c7e4d' - ), - 'add_liquidity(uint256[2],uint256,address)': new Func<[_amounts: Array, _min_mint_amount: bigint, _receiver: string], {_amounts: Array, _min_mint_amount: bigint, _receiver: string}, bigint>( - abi, '0x0c3e4b54' - ), - get_dy: new Func<[i: bigint, j: bigint, dx: bigint], {i: bigint, j: bigint, dx: bigint}, bigint>( - abi, '0x5e0d443f' - ), - 'exchange(int128,int128,uint256,uint256)': new Func<[i: bigint, j: bigint, _dx: bigint, _min_dy: bigint], {i: bigint, j: bigint, _dx: bigint, _min_dy: bigint}, bigint>( - abi, '0x3df02124' - ), - 'exchange(int128,int128,uint256,uint256,address)': new Func<[i: bigint, j: bigint, _dx: bigint, _min_dy: bigint, _receiver: string], {i: bigint, j: bigint, _dx: bigint, _min_dy: bigint, _receiver: string}, bigint>( - abi, '0xddc1f59d' - ), - 'remove_liquidity(uint256,uint256[2])': new Func<[_burn_amount: bigint, _min_amounts: Array], {_burn_amount: bigint, _min_amounts: Array}, Array>( - abi, '0x5b36389c' - ), - 'remove_liquidity(uint256,uint256[2],address)': new Func<[_burn_amount: bigint, _min_amounts: Array, _receiver: string], {_burn_amount: bigint, _min_amounts: Array, _receiver: string}, Array>( - abi, '0x3eb1719f' - ), - 'remove_liquidity_imbalance(uint256[2],uint256)': new Func<[_amounts: Array, _max_burn_amount: bigint], {_amounts: Array, _max_burn_amount: bigint}, bigint>( - abi, '0xe3103273' - ), - 'remove_liquidity_imbalance(uint256[2],uint256,address)': new Func<[_amounts: Array, _max_burn_amount: bigint, _receiver: string], {_amounts: Array, _max_burn_amount: bigint, _receiver: string}, bigint>( - abi, '0x52d2cfdd' - ), - calc_withdraw_one_coin: new Func<[_burn_amount: bigint, i: bigint], {_burn_amount: bigint, i: bigint}, bigint>( - abi, '0xcc2b27d7' - ), - 'remove_liquidity_one_coin(uint256,int128,uint256)': new Func<[_burn_amount: bigint, i: bigint, _min_received: bigint], {_burn_amount: bigint, i: bigint, _min_received: bigint}, bigint>( - abi, '0x1a4d01d2' - ), - 'remove_liquidity_one_coin(uint256,int128,uint256,address)': new Func<[_burn_amount: bigint, i: bigint, _min_received: bigint, _receiver: string], {_burn_amount: bigint, i: bigint, _min_received: bigint, _receiver: string}, bigint>( - abi, '0x081579a5' - ), - ramp_A: new Func<[_future_A: bigint, _future_time: bigint], {_future_A: bigint, _future_time: bigint}, []>( - abi, '0x3c157e64' - ), - stop_ramp_A: new Func<[], {}, []>( - abi, '0x551a6588' - ), - admin_balances: new Func<[i: bigint], {i: bigint}, bigint>( - abi, '0xe2e7d264' - ), - withdraw_admin_fees: new Func<[], {}, []>( - abi, '0x30c54085' - ), - commit_new_fee: new Func<[_new_fee: bigint], {_new_fee: bigint}, []>( - abi, '0xa48eac9d' - ), - apply_new_fee: new Func<[], {}, []>( - abi, '0x4f12fe97' - ), - set_ma_exp_time: new Func<[_ma_exp_time: bigint], {_ma_exp_time: bigint}, []>( - abi, '0x7f3e17cb' - ), - version: new Func<[], {}, string>( - abi, '0x54fd4d50' - ), - coins: new Func<[arg0: bigint], {arg0: bigint}, string>( - abi, '0xc6610657' - ), - balances: new Func<[arg0: bigint], {arg0: bigint}, bigint>( - abi, '0x4903b0d1' - ), - fee: new Func<[], {}, bigint>( - abi, '0xddca3f43' - ), - future_fee: new Func<[], {}, bigint>( - abi, '0x58680d0b' - ), - admin_action_deadline: new Func<[], {}, bigint>( - abi, '0xe66f43f5' - ), - initial_A: new Func<[], {}, bigint>( - abi, '0x5409491a' - ), - future_A: new Func<[], {}, bigint>( - abi, '0xb4b577ad' - ), - initial_A_time: new Func<[], {}, bigint>( - abi, '0x2081066c' - ), - future_A_time: new Func<[], {}, bigint>( - abi, '0x14052288' - ), - name: new Func<[], {}, string>( - abi, '0x06fdde03' - ), - symbol: new Func<[], {}, string>( - abi, '0x95d89b41' - ), - balanceOf: new Func<[arg0: string], {arg0: string}, bigint>( - abi, '0x70a08231' - ), - allowance: new Func<[arg0: string, arg1: string], {arg0: string, arg1: string}, bigint>( - abi, '0xdd62ed3e' - ), - totalSupply: new Func<[], {}, bigint>( - abi, '0x18160ddd' - ), - DOMAIN_SEPARATOR: new Func<[], {}, string>( - abi, '0x3644e515' - ), - nonces: new Func<[arg0: string], {arg0: string}, bigint>( - abi, '0x7ecebe00' - ), - ma_exp_time: new Func<[], {}, bigint>( - abi, '0x1be913a5' - ), - ma_last_time: new Func<[], {}, bigint>( - abi, '0x1ddc3b01' - ), + initialize: fun("0xa461b3c8", {"_name": p.string, "_symbol": p.string, "_coins": p.fixedSizeArray(p.address, 4), "_rate_multipliers": p.fixedSizeArray(p.uint256, 4), "_A": p.uint256, "_fee": p.uint256}, ), + decimals: fun("0x313ce567", {}, p.uint256), + transfer: fun("0xa9059cbb", {"_to": p.address, "_value": p.uint256}, p.bool), + transferFrom: fun("0x23b872dd", {"_from": p.address, "_to": p.address, "_value": p.uint256}, p.bool), + approve: fun("0x095ea7b3", {"_spender": p.address, "_value": p.uint256}, p.bool), + permit: fun("0xd505accf", {"_owner": p.address, "_spender": p.address, "_value": p.uint256, "_deadline": p.uint256, "_v": p.uint8, "_r": p.bytes32, "_s": p.bytes32}, p.bool), + last_price: fun("0xfde625e6", {}, p.uint256), + ema_price: fun("0xc24c7c29", {}, p.uint256), + get_balances: fun("0x14f05979", {}, p.fixedSizeArray(p.uint256, 2)), + admin_fee: fun("0xfee3f7f9", {}, p.uint256), + A: fun("0xf446c1d0", {}, p.uint256), + A_precise: fun("0x76a2f0f0", {}, p.uint256), + get_p: fun("0xf2388acb", {}, p.uint256), + price_oracle: fun("0x86fc88d3", {}, p.uint256), + get_virtual_price: fun("0xbb7b8b80", {}, p.uint256), + calc_token_amount: fun("0xed8e84f3", {"_amounts": p.fixedSizeArray(p.uint256, 2), "_is_deposit": p.bool}, p.uint256), + "add_liquidity(uint256[2],uint256)": fun("0x0b4c7e4d", {"_amounts": p.fixedSizeArray(p.uint256, 2), "_min_mint_amount": p.uint256}, p.uint256), + "add_liquidity(uint256[2],uint256,address)": fun("0x0c3e4b54", {"_amounts": p.fixedSizeArray(p.uint256, 2), "_min_mint_amount": p.uint256, "_receiver": p.address}, p.uint256), + get_dy: fun("0x5e0d443f", {"i": p.int128, "j": p.int128, "dx": p.uint256}, p.uint256), + "exchange(int128,int128,uint256,uint256)": fun("0x3df02124", {"i": p.int128, "j": p.int128, "_dx": p.uint256, "_min_dy": p.uint256}, p.uint256), + "exchange(int128,int128,uint256,uint256,address)": fun("0xddc1f59d", {"i": p.int128, "j": p.int128, "_dx": p.uint256, "_min_dy": p.uint256, "_receiver": p.address}, p.uint256), + "remove_liquidity(uint256,uint256[2])": fun("0x5b36389c", {"_burn_amount": p.uint256, "_min_amounts": p.fixedSizeArray(p.uint256, 2)}, p.fixedSizeArray(p.uint256, 2)), + "remove_liquidity(uint256,uint256[2],address)": fun("0x3eb1719f", {"_burn_amount": p.uint256, "_min_amounts": p.fixedSizeArray(p.uint256, 2), "_receiver": p.address}, p.fixedSizeArray(p.uint256, 2)), + "remove_liquidity_imbalance(uint256[2],uint256)": fun("0xe3103273", {"_amounts": p.fixedSizeArray(p.uint256, 2), "_max_burn_amount": p.uint256}, p.uint256), + "remove_liquidity_imbalance(uint256[2],uint256,address)": fun("0x52d2cfdd", {"_amounts": p.fixedSizeArray(p.uint256, 2), "_max_burn_amount": p.uint256, "_receiver": p.address}, p.uint256), + calc_withdraw_one_coin: fun("0xcc2b27d7", {"_burn_amount": p.uint256, "i": p.int128}, p.uint256), + "remove_liquidity_one_coin(uint256,int128,uint256)": fun("0x1a4d01d2", {"_burn_amount": p.uint256, "i": p.int128, "_min_received": p.uint256}, p.uint256), + "remove_liquidity_one_coin(uint256,int128,uint256,address)": fun("0x081579a5", {"_burn_amount": p.uint256, "i": p.int128, "_min_received": p.uint256, "_receiver": p.address}, p.uint256), + ramp_A: fun("0x3c157e64", {"_future_A": p.uint256, "_future_time": p.uint256}, ), + stop_ramp_A: fun("0x551a6588", {}, ), + admin_balances: fun("0xe2e7d264", {"i": p.uint256}, p.uint256), + withdraw_admin_fees: fun("0x30c54085", {}, ), + commit_new_fee: fun("0xa48eac9d", {"_new_fee": p.uint256}, ), + apply_new_fee: fun("0x4f12fe97", {}, ), + set_ma_exp_time: fun("0x7f3e17cb", {"_ma_exp_time": p.uint256}, ), + version: fun("0x54fd4d50", {}, p.string), + coins: fun("0xc6610657", {"arg0": p.uint256}, p.address), + balances: fun("0x4903b0d1", {"arg0": p.uint256}, p.uint256), + fee: fun("0xddca3f43", {}, p.uint256), + future_fee: fun("0x58680d0b", {}, p.uint256), + admin_action_deadline: fun("0xe66f43f5", {}, p.uint256), + initial_A: fun("0x5409491a", {}, p.uint256), + future_A: fun("0xb4b577ad", {}, p.uint256), + initial_A_time: fun("0x2081066c", {}, p.uint256), + future_A_time: fun("0x14052288", {}, p.uint256), + name: fun("0x06fdde03", {}, p.string), + symbol: fun("0x95d89b41", {}, p.string), + balanceOf: fun("0x70a08231", {"arg0": p.address}, p.uint256), + allowance: fun("0xdd62ed3e", {"arg0": p.address, "arg1": p.address}, p.uint256), + totalSupply: fun("0x18160ddd", {}, p.uint256), + DOMAIN_SEPARATOR: fun("0x3644e515", {}, p.bytes32), + nonces: fun("0x7ecebe00", {"arg0": p.address}, p.uint256), + ma_exp_time: fun("0x1be913a5", {}, p.uint256), + ma_last_time: fun("0x1ddc3b01", {}, p.uint256), } export class Contract extends ContractBase { - decimals(): Promise { - return this.eth_call(functions.decimals, []) + decimals() { + return this.eth_call(functions.decimals, {}) } - last_price(): Promise { - return this.eth_call(functions.last_price, []) + last_price() { + return this.eth_call(functions.last_price, {}) } - ema_price(): Promise { - return this.eth_call(functions.ema_price, []) + ema_price() { + return this.eth_call(functions.ema_price, {}) } - get_balances(): Promise> { - return this.eth_call(functions.get_balances, []) + get_balances() { + return this.eth_call(functions.get_balances, {}) } - admin_fee(): Promise { - return this.eth_call(functions.admin_fee, []) + admin_fee() { + return this.eth_call(functions.admin_fee, {}) } - A(): Promise { - return this.eth_call(functions.A, []) + A() { + return this.eth_call(functions.A, {}) } - A_precise(): Promise { - return this.eth_call(functions.A_precise, []) + A_precise() { + return this.eth_call(functions.A_precise, {}) } - get_p(): Promise { - return this.eth_call(functions.get_p, []) + get_p() { + return this.eth_call(functions.get_p, {}) } - price_oracle(): Promise { - return this.eth_call(functions.price_oracle, []) + price_oracle() { + return this.eth_call(functions.price_oracle, {}) } - get_virtual_price(): Promise { - return this.eth_call(functions.get_virtual_price, []) + get_virtual_price() { + return this.eth_call(functions.get_virtual_price, {}) } - calc_token_amount(_amounts: Array, _is_deposit: boolean): Promise { - return this.eth_call(functions.calc_token_amount, [_amounts, _is_deposit]) + calc_token_amount(_amounts: Calc_token_amountParams["_amounts"], _is_deposit: Calc_token_amountParams["_is_deposit"]) { + return this.eth_call(functions.calc_token_amount, {_amounts, _is_deposit}) } - get_dy(i: bigint, j: bigint, dx: bigint): Promise { - return this.eth_call(functions.get_dy, [i, j, dx]) + get_dy(i: Get_dyParams["i"], j: Get_dyParams["j"], dx: Get_dyParams["dx"]) { + return this.eth_call(functions.get_dy, {i, j, dx}) } - calc_withdraw_one_coin(_burn_amount: bigint, i: bigint): Promise { - return this.eth_call(functions.calc_withdraw_one_coin, [_burn_amount, i]) + calc_withdraw_one_coin(_burn_amount: Calc_withdraw_one_coinParams["_burn_amount"], i: Calc_withdraw_one_coinParams["i"]) { + return this.eth_call(functions.calc_withdraw_one_coin, {_burn_amount, i}) } - admin_balances(i: bigint): Promise { - return this.eth_call(functions.admin_balances, [i]) + admin_balances(i: Admin_balancesParams["i"]) { + return this.eth_call(functions.admin_balances, {i}) } - version(): Promise { - return this.eth_call(functions.version, []) + version() { + return this.eth_call(functions.version, {}) } - coins(arg0: bigint): Promise { - return this.eth_call(functions.coins, [arg0]) + coins(arg0: CoinsParams["arg0"]) { + return this.eth_call(functions.coins, {arg0}) } - balances(arg0: bigint): Promise { - return this.eth_call(functions.balances, [arg0]) + balances(arg0: BalancesParams["arg0"]) { + return this.eth_call(functions.balances, {arg0}) } - fee(): Promise { - return this.eth_call(functions.fee, []) + fee() { + return this.eth_call(functions.fee, {}) } - future_fee(): Promise { - return this.eth_call(functions.future_fee, []) + future_fee() { + return this.eth_call(functions.future_fee, {}) } - admin_action_deadline(): Promise { - return this.eth_call(functions.admin_action_deadline, []) + admin_action_deadline() { + return this.eth_call(functions.admin_action_deadline, {}) } - initial_A(): Promise { - return this.eth_call(functions.initial_A, []) + initial_A() { + return this.eth_call(functions.initial_A, {}) } - future_A(): Promise { - return this.eth_call(functions.future_A, []) + future_A() { + return this.eth_call(functions.future_A, {}) } - initial_A_time(): Promise { - return this.eth_call(functions.initial_A_time, []) + initial_A_time() { + return this.eth_call(functions.initial_A_time, {}) } - future_A_time(): Promise { - return this.eth_call(functions.future_A_time, []) + future_A_time() { + return this.eth_call(functions.future_A_time, {}) } - name(): Promise { - return this.eth_call(functions.name, []) + name() { + return this.eth_call(functions.name, {}) } - symbol(): Promise { - return this.eth_call(functions.symbol, []) + symbol() { + return this.eth_call(functions.symbol, {}) } - balanceOf(arg0: string): Promise { - return this.eth_call(functions.balanceOf, [arg0]) + balanceOf(arg0: BalanceOfParams["arg0"]) { + return this.eth_call(functions.balanceOf, {arg0}) } - allowance(arg0: string, arg1: string): Promise { - return this.eth_call(functions.allowance, [arg0, arg1]) + allowance(arg0: AllowanceParams["arg0"], arg1: AllowanceParams["arg1"]) { + return this.eth_call(functions.allowance, {arg0, arg1}) } - totalSupply(): Promise { - return this.eth_call(functions.totalSupply, []) + totalSupply() { + return this.eth_call(functions.totalSupply, {}) } - DOMAIN_SEPARATOR(): Promise { - return this.eth_call(functions.DOMAIN_SEPARATOR, []) + DOMAIN_SEPARATOR() { + return this.eth_call(functions.DOMAIN_SEPARATOR, {}) } - nonces(arg0: string): Promise { - return this.eth_call(functions.nonces, [arg0]) + nonces(arg0: NoncesParams["arg0"]) { + return this.eth_call(functions.nonces, {arg0}) } - ma_exp_time(): Promise { - return this.eth_call(functions.ma_exp_time, []) + ma_exp_time() { + return this.eth_call(functions.ma_exp_time, {}) } - ma_last_time(): Promise { - return this.eth_call(functions.ma_last_time, []) + ma_last_time() { + return this.eth_call(functions.ma_last_time, {}) } } + +/// Event types +export type TransferEventArgs = EParams +export type ApprovalEventArgs = EParams +export type TokenExchangeEventArgs = EParams +export type AddLiquidityEventArgs = EParams +export type RemoveLiquidityEventArgs = EParams +export type RemoveLiquidityOneEventArgs = EParams +export type RemoveLiquidityImbalanceEventArgs = EParams +export type RampAEventArgs = EParams +export type StopRampAEventArgs = EParams +export type CommitNewFeeEventArgs = EParams +export type ApplyNewFeeEventArgs = EParams + +/// Function types +export type InitializeParams = FunctionArguments +export type InitializeReturn = FunctionReturn + +export type DecimalsParams = FunctionArguments +export type DecimalsReturn = FunctionReturn + +export type TransferParams = FunctionArguments +export type TransferReturn = FunctionReturn + +export type TransferFromParams = FunctionArguments +export type TransferFromReturn = FunctionReturn + +export type ApproveParams = FunctionArguments +export type ApproveReturn = FunctionReturn + +export type PermitParams = FunctionArguments +export type PermitReturn = FunctionReturn + +export type Last_priceParams = FunctionArguments +export type Last_priceReturn = FunctionReturn + +export type Ema_priceParams = FunctionArguments +export type Ema_priceReturn = FunctionReturn + +export type Get_balancesParams = FunctionArguments +export type Get_balancesReturn = FunctionReturn + +export type Admin_feeParams = FunctionArguments +export type Admin_feeReturn = FunctionReturn + +export type AParams = FunctionArguments +export type AReturn = FunctionReturn + +export type A_preciseParams = FunctionArguments +export type A_preciseReturn = FunctionReturn + +export type Get_pParams = FunctionArguments +export type Get_pReturn = FunctionReturn + +export type Price_oracleParams = FunctionArguments +export type Price_oracleReturn = FunctionReturn + +export type Get_virtual_priceParams = FunctionArguments +export type Get_virtual_priceReturn = FunctionReturn + +export type Calc_token_amountParams = FunctionArguments +export type Calc_token_amountReturn = FunctionReturn + +export type Add_liquidityParams_0 = FunctionArguments +export type Add_liquidityReturn_0 = FunctionReturn + +export type Add_liquidityParams_1 = FunctionArguments +export type Add_liquidityReturn_1 = FunctionReturn + +export type Get_dyParams = FunctionArguments +export type Get_dyReturn = FunctionReturn + +export type ExchangeParams_0 = FunctionArguments +export type ExchangeReturn_0 = FunctionReturn + +export type ExchangeParams_1 = FunctionArguments +export type ExchangeReturn_1 = FunctionReturn + +export type Remove_liquidityParams_0 = FunctionArguments +export type Remove_liquidityReturn_0 = FunctionReturn + +export type Remove_liquidityParams_1 = FunctionArguments +export type Remove_liquidityReturn_1 = FunctionReturn + +export type Remove_liquidity_imbalanceParams_0 = FunctionArguments +export type Remove_liquidity_imbalanceReturn_0 = FunctionReturn + +export type Remove_liquidity_imbalanceParams_1 = FunctionArguments +export type Remove_liquidity_imbalanceReturn_1 = FunctionReturn + +export type Calc_withdraw_one_coinParams = FunctionArguments +export type Calc_withdraw_one_coinReturn = FunctionReturn + +export type Remove_liquidity_one_coinParams_0 = FunctionArguments +export type Remove_liquidity_one_coinReturn_0 = FunctionReturn + +export type Remove_liquidity_one_coinParams_1 = FunctionArguments +export type Remove_liquidity_one_coinReturn_1 = FunctionReturn + +export type Ramp_AParams = FunctionArguments +export type Ramp_AReturn = FunctionReturn + +export type Stop_ramp_AParams = FunctionArguments +export type Stop_ramp_AReturn = FunctionReturn + +export type Admin_balancesParams = FunctionArguments +export type Admin_balancesReturn = FunctionReturn + +export type Withdraw_admin_feesParams = FunctionArguments +export type Withdraw_admin_feesReturn = FunctionReturn + +export type Commit_new_feeParams = FunctionArguments +export type Commit_new_feeReturn = FunctionReturn + +export type Apply_new_feeParams = FunctionArguments +export type Apply_new_feeReturn = FunctionReturn + +export type Set_ma_exp_timeParams = FunctionArguments +export type Set_ma_exp_timeReturn = FunctionReturn + +export type VersionParams = FunctionArguments +export type VersionReturn = FunctionReturn + +export type CoinsParams = FunctionArguments +export type CoinsReturn = FunctionReturn + +export type BalancesParams = FunctionArguments +export type BalancesReturn = FunctionReturn + +export type FeeParams = FunctionArguments +export type FeeReturn = FunctionReturn + +export type Future_feeParams = FunctionArguments +export type Future_feeReturn = FunctionReturn + +export type Admin_action_deadlineParams = FunctionArguments +export type Admin_action_deadlineReturn = FunctionReturn + +export type Initial_AParams = FunctionArguments +export type Initial_AReturn = FunctionReturn + +export type Future_AParams = FunctionArguments +export type Future_AReturn = FunctionReturn + +export type Initial_A_timeParams = FunctionArguments +export type Initial_A_timeReturn = FunctionReturn + +export type Future_A_timeParams = FunctionArguments +export type Future_A_timeReturn = FunctionReturn + +export type NameParams = FunctionArguments +export type NameReturn = FunctionReturn + +export type SymbolParams = FunctionArguments +export type SymbolReturn = FunctionReturn + +export type BalanceOfParams = FunctionArguments +export type BalanceOfReturn = FunctionReturn + +export type AllowanceParams = FunctionArguments +export type AllowanceReturn = FunctionReturn + +export type TotalSupplyParams = FunctionArguments +export type TotalSupplyReturn = FunctionReturn + +export type DOMAIN_SEPARATORParams = FunctionArguments +export type DOMAIN_SEPARATORReturn = FunctionReturn + +export type NoncesParams = FunctionArguments +export type NoncesReturn = FunctionReturn + +export type Ma_exp_timeParams = FunctionArguments +export type Ma_exp_timeReturn = FunctionReturn + +export type Ma_last_timeParams = FunctionArguments +export type Ma_last_timeReturn = FunctionReturn + diff --git a/src/abi/curve-registry-exchange.ts b/src/abi/curve-registry-exchange.ts index 1e6218ff..47a55468 100644 --- a/src/abi/curve-registry-exchange.ts +++ b/src/abi/curve-registry-exchange.ts @@ -1,147 +1,172 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './curve-registry-exchange.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - TokenExchange: new LogEvent<([buyer: string, receiver: string, pool: string, token_sold: string, token_bought: string, amount_sold: bigint, amount_bought: bigint] & {buyer: string, receiver: string, pool: string, token_sold: string, token_bought: string, amount_sold: bigint, amount_bought: bigint})>( - abi, '0xbd3eb7bcfdd1721a4eb4f00d0df3ed91bd6f17222f82b2d7bce519d8cab3fe46' - ), - ExchangeMultiple: new LogEvent<([buyer: string, receiver: string, route: Array, swap_params: Array>, pools: Array, amount_sold: bigint, amount_bought: bigint] & {buyer: string, receiver: string, route: Array, swap_params: Array>, pools: Array, amount_sold: bigint, amount_bought: bigint})>( - abi, '0x14b561178ae0f368f40fafd0485c4f7129ea71cdc00b4ce1e5940f9bc659c8b2' - ), + TokenExchange: event("0xbd3eb7bcfdd1721a4eb4f00d0df3ed91bd6f17222f82b2d7bce519d8cab3fe46", {"buyer": indexed(p.address), "receiver": indexed(p.address), "pool": indexed(p.address), "token_sold": p.address, "token_bought": p.address, "amount_sold": p.uint256, "amount_bought": p.uint256}), + ExchangeMultiple: event("0x14b561178ae0f368f40fafd0485c4f7129ea71cdc00b4ce1e5940f9bc659c8b2", {"buyer": indexed(p.address), "receiver": indexed(p.address), "route": p.fixedSizeArray(p.address, 9), "swap_params": p.fixedSizeArray(p.fixedSizeArray(p.uint256, 3), 4), "pools": p.fixedSizeArray(p.address, 4), "amount_sold": p.uint256, "amount_bought": p.uint256}), } export const functions = { - 'exchange_with_best_rate(address,address,uint256,uint256)': new Func<[_from: string, _to: string, _amount: bigint, _expected: bigint], {_from: string, _to: string, _amount: bigint, _expected: bigint}, bigint>( - abi, '0x10e5e303' - ), - 'exchange_with_best_rate(address,address,uint256,uint256,address)': new Func<[_from: string, _to: string, _amount: bigint, _expected: bigint, _receiver: string], {_from: string, _to: string, _amount: bigint, _expected: bigint, _receiver: string}, bigint>( - abi, '0x9f69a6a6' - ), - 'exchange(address,address,address,uint256,uint256)': new Func<[_pool: string, _from: string, _to: string, _amount: bigint, _expected: bigint], {_pool: string, _from: string, _to: string, _amount: bigint, _expected: bigint}, bigint>( - abi, '0x4798ce5b' - ), - 'exchange(address,address,address,uint256,uint256,address)': new Func<[_pool: string, _from: string, _to: string, _amount: bigint, _expected: bigint, _receiver: string], {_pool: string, _from: string, _to: string, _amount: bigint, _expected: bigint, _receiver: string}, bigint>( - abi, '0x1a4c1ca3' - ), - 'exchange_multiple(address[9],uint256[3][4],uint256,uint256)': new Func<[_route: Array, _swap_params: Array>, _amount: bigint, _expected: bigint], {_route: Array, _swap_params: Array>, _amount: bigint, _expected: bigint}, bigint>( - abi, '0x353ca424' - ), - 'exchange_multiple(address[9],uint256[3][4],uint256,uint256,address[4])': new Func<[_route: Array, _swap_params: Array>, _amount: bigint, _expected: bigint, _pools: Array], {_route: Array, _swap_params: Array>, _amount: bigint, _expected: bigint, _pools: Array}, bigint>( - abi, '0x9db4f7aa' - ), - 'exchange_multiple(address[9],uint256[3][4],uint256,uint256,address[4],address)': new Func<[_route: Array, _swap_params: Array>, _amount: bigint, _expected: bigint, _pools: Array, _receiver: string], {_route: Array, _swap_params: Array>, _amount: bigint, _expected: bigint, _pools: Array, _receiver: string}, bigint>( - abi, '0x0651cb35' - ), - 'get_best_rate(address,address,uint256)': new Func<[_from: string, _to: string, _amount: bigint], {_from: string, _to: string, _amount: bigint}, [_: string, _: bigint]>( - abi, '0x4e21df75' - ), - 'get_best_rate(address,address,uint256,address[8])': new Func<[_from: string, _to: string, _amount: bigint, _exclude_pools: Array], {_from: string, _to: string, _amount: bigint, _exclude_pools: Array}, [_: string, _: bigint]>( - abi, '0x488de9af' - ), - get_exchange_amount: new Func<[_pool: string, _from: string, _to: string, _amount: bigint], {_pool: string, _from: string, _to: string, _amount: bigint}, bigint>( - abi, '0x3973e834' - ), - get_input_amount: new Func<[_pool: string, _from: string, _to: string, _amount: bigint], {_pool: string, _from: string, _to: string, _amount: bigint}, bigint>( - abi, '0x7fa5a654' - ), - get_exchange_amounts: new Func<[_pool: string, _from: string, _to: string, _amounts: Array], {_pool: string, _from: string, _to: string, _amounts: Array}, Array>( - abi, '0x4be9ae42' - ), - 'get_exchange_multiple_amount(address[9],uint256[3][4],uint256)': new Func<[_route: Array, _swap_params: Array>, _amount: bigint], {_route: Array, _swap_params: Array>, _amount: bigint}, bigint>( - abi, '0x7b3d22cf' - ), - 'get_exchange_multiple_amount(address[9],uint256[3][4],uint256,address[4])': new Func<[_route: Array, _swap_params: Array>, _amount: bigint, _pools: Array], {_route: Array, _swap_params: Array>, _amount: bigint, _pools: Array}, bigint>( - abi, '0xe6eabf23' - ), - get_calculator: new Func<[_pool: string], {_pool: string}, string>( - abi, '0x5d7dc825' - ), - update_registry_address: new Func<[], {}, boolean>( - abi, '0x4bbc5b1f' - ), - set_calculator: new Func<[_pool: string, _calculator: string], {_pool: string, _calculator: string}, boolean>( - abi, '0x188c7ee5' - ), - set_default_calculator: new Func<[_calculator: string], {_calculator: string}, boolean>( - abi, '0xda3fb2ab' - ), - claim_balance: new Func<[_token: string], {_token: string}, boolean>( - abi, '0x752d53c6' - ), - set_killed: new Func<[_is_killed: boolean], {_is_killed: boolean}, boolean>( - abi, '0x90b22997' - ), - registry: new Func<[], {}, string>( - abi, '0x7b103999' - ), - factory_registry: new Func<[], {}, string>( - abi, '0xf7cbf4c6' - ), - crypto_registry: new Func<[], {}, string>( - abi, '0xf3b8f829' - ), - default_calculator: new Func<[], {}, string>( - abi, '0x3b359fc8' - ), - is_killed: new Func<[], {}, boolean>( - abi, '0x9c868ac0' - ), + "exchange_with_best_rate(address,address,uint256,uint256)": fun("0x10e5e303", {"_from": p.address, "_to": p.address, "_amount": p.uint256, "_expected": p.uint256}, p.uint256), + "exchange_with_best_rate(address,address,uint256,uint256,address)": fun("0x9f69a6a6", {"_from": p.address, "_to": p.address, "_amount": p.uint256, "_expected": p.uint256, "_receiver": p.address}, p.uint256), + "exchange(address,address,address,uint256,uint256)": fun("0x4798ce5b", {"_pool": p.address, "_from": p.address, "_to": p.address, "_amount": p.uint256, "_expected": p.uint256}, p.uint256), + "exchange(address,address,address,uint256,uint256,address)": fun("0x1a4c1ca3", {"_pool": p.address, "_from": p.address, "_to": p.address, "_amount": p.uint256, "_expected": p.uint256, "_receiver": p.address}, p.uint256), + "exchange_multiple(address[9],uint256[3][4],uint256,uint256)": fun("0x353ca424", {"_route": p.fixedSizeArray(p.address, 9), "_swap_params": p.fixedSizeArray(p.fixedSizeArray(p.uint256, 3), 4), "_amount": p.uint256, "_expected": p.uint256}, p.uint256), + "exchange_multiple(address[9],uint256[3][4],uint256,uint256,address[4])": fun("0x9db4f7aa", {"_route": p.fixedSizeArray(p.address, 9), "_swap_params": p.fixedSizeArray(p.fixedSizeArray(p.uint256, 3), 4), "_amount": p.uint256, "_expected": p.uint256, "_pools": p.fixedSizeArray(p.address, 4)}, p.uint256), + "exchange_multiple(address[9],uint256[3][4],uint256,uint256,address[4],address)": fun("0x0651cb35", {"_route": p.fixedSizeArray(p.address, 9), "_swap_params": p.fixedSizeArray(p.fixedSizeArray(p.uint256, 3), 4), "_amount": p.uint256, "_expected": p.uint256, "_pools": p.fixedSizeArray(p.address, 4), "_receiver": p.address}, p.uint256), + "get_best_rate(address,address,uint256)": fun("0x4e21df75", {"_from": p.address, "_to": p.address, "_amount": p.uint256}, {"_0": p.address, "_1": p.uint256}), + "get_best_rate(address,address,uint256,address[8])": fun("0x488de9af", {"_from": p.address, "_to": p.address, "_amount": p.uint256, "_exclude_pools": p.fixedSizeArray(p.address, 8)}, {"_0": p.address, "_1": p.uint256}), + get_exchange_amount: fun("0x3973e834", {"_pool": p.address, "_from": p.address, "_to": p.address, "_amount": p.uint256}, p.uint256), + get_input_amount: fun("0x7fa5a654", {"_pool": p.address, "_from": p.address, "_to": p.address, "_amount": p.uint256}, p.uint256), + get_exchange_amounts: fun("0x4be9ae42", {"_pool": p.address, "_from": p.address, "_to": p.address, "_amounts": p.fixedSizeArray(p.uint256, 100)}, p.fixedSizeArray(p.uint256, 100)), + "get_exchange_multiple_amount(address[9],uint256[3][4],uint256)": fun("0x7b3d22cf", {"_route": p.fixedSizeArray(p.address, 9), "_swap_params": p.fixedSizeArray(p.fixedSizeArray(p.uint256, 3), 4), "_amount": p.uint256}, p.uint256), + "get_exchange_multiple_amount(address[9],uint256[3][4],uint256,address[4])": fun("0xe6eabf23", {"_route": p.fixedSizeArray(p.address, 9), "_swap_params": p.fixedSizeArray(p.fixedSizeArray(p.uint256, 3), 4), "_amount": p.uint256, "_pools": p.fixedSizeArray(p.address, 4)}, p.uint256), + get_calculator: fun("0x5d7dc825", {"_pool": p.address}, p.address), + update_registry_address: fun("0x4bbc5b1f", {}, p.bool), + set_calculator: fun("0x188c7ee5", {"_pool": p.address, "_calculator": p.address}, p.bool), + set_default_calculator: fun("0xda3fb2ab", {"_calculator": p.address}, p.bool), + claim_balance: fun("0x752d53c6", {"_token": p.address}, p.bool), + set_killed: fun("0x90b22997", {"_is_killed": p.bool}, p.bool), + registry: fun("0x7b103999", {}, p.address), + factory_registry: fun("0xf7cbf4c6", {}, p.address), + crypto_registry: fun("0xf3b8f829", {}, p.address), + default_calculator: fun("0x3b359fc8", {}, p.address), + is_killed: fun("0x9c868ac0", {}, p.bool), } export class Contract extends ContractBase { - 'get_best_rate(address,address,uint256)'(_from: string, _to: string, _amount: bigint): Promise<[_: string, _: bigint]> { - return this.eth_call(functions['get_best_rate(address,address,uint256)'], [_from, _to, _amount]) + "get_best_rate(address,address,uint256)"(_from: Get_best_rateParams_0["_from"], _to: Get_best_rateParams_0["_to"], _amount: Get_best_rateParams_0["_amount"]) { + return this.eth_call(functions["get_best_rate(address,address,uint256)"], {_from, _to, _amount}) } - 'get_best_rate(address,address,uint256,address[8])'(_from: string, _to: string, _amount: bigint, _exclude_pools: Array): Promise<[_: string, _: bigint]> { - return this.eth_call(functions['get_best_rate(address,address,uint256,address[8])'], [_from, _to, _amount, _exclude_pools]) + "get_best_rate(address,address,uint256,address[8])"(_from: Get_best_rateParams_1["_from"], _to: Get_best_rateParams_1["_to"], _amount: Get_best_rateParams_1["_amount"], _exclude_pools: Get_best_rateParams_1["_exclude_pools"]) { + return this.eth_call(functions["get_best_rate(address,address,uint256,address[8])"], {_from, _to, _amount, _exclude_pools}) } - get_exchange_amount(_pool: string, _from: string, _to: string, _amount: bigint): Promise { - return this.eth_call(functions.get_exchange_amount, [_pool, _from, _to, _amount]) + get_exchange_amount(_pool: Get_exchange_amountParams["_pool"], _from: Get_exchange_amountParams["_from"], _to: Get_exchange_amountParams["_to"], _amount: Get_exchange_amountParams["_amount"]) { + return this.eth_call(functions.get_exchange_amount, {_pool, _from, _to, _amount}) } - get_input_amount(_pool: string, _from: string, _to: string, _amount: bigint): Promise { - return this.eth_call(functions.get_input_amount, [_pool, _from, _to, _amount]) + get_input_amount(_pool: Get_input_amountParams["_pool"], _from: Get_input_amountParams["_from"], _to: Get_input_amountParams["_to"], _amount: Get_input_amountParams["_amount"]) { + return this.eth_call(functions.get_input_amount, {_pool, _from, _to, _amount}) } - get_exchange_amounts(_pool: string, _from: string, _to: string, _amounts: Array): Promise> { - return this.eth_call(functions.get_exchange_amounts, [_pool, _from, _to, _amounts]) + get_exchange_amounts(_pool: Get_exchange_amountsParams["_pool"], _from: Get_exchange_amountsParams["_from"], _to: Get_exchange_amountsParams["_to"], _amounts: Get_exchange_amountsParams["_amounts"]) { + return this.eth_call(functions.get_exchange_amounts, {_pool, _from, _to, _amounts}) } - 'get_exchange_multiple_amount(address[9],uint256[3][4],uint256)'(_route: Array, _swap_params: Array>, _amount: bigint): Promise { - return this.eth_call(functions['get_exchange_multiple_amount(address[9],uint256[3][4],uint256)'], [_route, _swap_params, _amount]) + "get_exchange_multiple_amount(address[9],uint256[3][4],uint256)"(_route: Get_exchange_multiple_amountParams_0["_route"], _swap_params: Get_exchange_multiple_amountParams_0["_swap_params"], _amount: Get_exchange_multiple_amountParams_0["_amount"]) { + return this.eth_call(functions["get_exchange_multiple_amount(address[9],uint256[3][4],uint256)"], {_route, _swap_params, _amount}) } - 'get_exchange_multiple_amount(address[9],uint256[3][4],uint256,address[4])'(_route: Array, _swap_params: Array>, _amount: bigint, _pools: Array): Promise { - return this.eth_call(functions['get_exchange_multiple_amount(address[9],uint256[3][4],uint256,address[4])'], [_route, _swap_params, _amount, _pools]) + "get_exchange_multiple_amount(address[9],uint256[3][4],uint256,address[4])"(_route: Get_exchange_multiple_amountParams_1["_route"], _swap_params: Get_exchange_multiple_amountParams_1["_swap_params"], _amount: Get_exchange_multiple_amountParams_1["_amount"], _pools: Get_exchange_multiple_amountParams_1["_pools"]) { + return this.eth_call(functions["get_exchange_multiple_amount(address[9],uint256[3][4],uint256,address[4])"], {_route, _swap_params, _amount, _pools}) } - get_calculator(_pool: string): Promise { - return this.eth_call(functions.get_calculator, [_pool]) + get_calculator(_pool: Get_calculatorParams["_pool"]) { + return this.eth_call(functions.get_calculator, {_pool}) } - registry(): Promise { - return this.eth_call(functions.registry, []) + registry() { + return this.eth_call(functions.registry, {}) } - factory_registry(): Promise { - return this.eth_call(functions.factory_registry, []) + factory_registry() { + return this.eth_call(functions.factory_registry, {}) } - crypto_registry(): Promise { - return this.eth_call(functions.crypto_registry, []) + crypto_registry() { + return this.eth_call(functions.crypto_registry, {}) } - default_calculator(): Promise { - return this.eth_call(functions.default_calculator, []) + default_calculator() { + return this.eth_call(functions.default_calculator, {}) } - is_killed(): Promise { - return this.eth_call(functions.is_killed, []) + is_killed() { + return this.eth_call(functions.is_killed, {}) } } + +/// Event types +export type TokenExchangeEventArgs = EParams +export type ExchangeMultipleEventArgs = EParams + +/// Function types +export type Exchange_with_best_rateParams_0 = FunctionArguments +export type Exchange_with_best_rateReturn_0 = FunctionReturn + +export type Exchange_with_best_rateParams_1 = FunctionArguments +export type Exchange_with_best_rateReturn_1 = FunctionReturn + +export type ExchangeParams_0 = FunctionArguments +export type ExchangeReturn_0 = FunctionReturn + +export type ExchangeParams_1 = FunctionArguments +export type ExchangeReturn_1 = FunctionReturn + +export type Exchange_multipleParams_0 = FunctionArguments +export type Exchange_multipleReturn_0 = FunctionReturn + +export type Exchange_multipleParams_1 = FunctionArguments +export type Exchange_multipleReturn_1 = FunctionReturn + +export type Exchange_multipleParams_2 = FunctionArguments +export type Exchange_multipleReturn_2 = FunctionReturn + +export type Get_best_rateParams_0 = FunctionArguments +export type Get_best_rateReturn_0 = FunctionReturn + +export type Get_best_rateParams_1 = FunctionArguments +export type Get_best_rateReturn_1 = FunctionReturn + +export type Get_exchange_amountParams = FunctionArguments +export type Get_exchange_amountReturn = FunctionReturn + +export type Get_input_amountParams = FunctionArguments +export type Get_input_amountReturn = FunctionReturn + +export type Get_exchange_amountsParams = FunctionArguments +export type Get_exchange_amountsReturn = FunctionReturn + +export type Get_exchange_multiple_amountParams_0 = FunctionArguments +export type Get_exchange_multiple_amountReturn_0 = FunctionReturn + +export type Get_exchange_multiple_amountParams_1 = FunctionArguments +export type Get_exchange_multiple_amountReturn_1 = FunctionReturn + +export type Get_calculatorParams = FunctionArguments +export type Get_calculatorReturn = FunctionReturn + +export type Update_registry_addressParams = FunctionArguments +export type Update_registry_addressReturn = FunctionReturn + +export type Set_calculatorParams = FunctionArguments +export type Set_calculatorReturn = FunctionReturn + +export type Set_default_calculatorParams = FunctionArguments +export type Set_default_calculatorReturn = FunctionReturn + +export type Claim_balanceParams = FunctionArguments +export type Claim_balanceReturn = FunctionReturn + +export type Set_killedParams = FunctionArguments +export type Set_killedReturn = FunctionReturn + +export type RegistryParams = FunctionArguments +export type RegistryReturn = FunctionReturn + +export type Factory_registryParams = FunctionArguments +export type Factory_registryReturn = FunctionReturn + +export type Crypto_registryParams = FunctionArguments +export type Crypto_registryReturn = FunctionReturn + +export type Default_calculatorParams = FunctionArguments +export type Default_calculatorReturn = FunctionReturn + +export type Is_killedParams = FunctionArguments +export type Is_killedReturn = FunctionReturn + diff --git a/src/abi/dripper.ts b/src/abi/dripper.ts index 0b5b0e88..c6d483d3 100644 --- a/src/abi/dripper.ts +++ b/src/abi/dripper.ts @@ -1,73 +1,84 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './dripper.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - GovernorshipTransferred: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( - abi, '0xc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a' - ), - PendingGovernorshipTransfer: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( - abi, '0xa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d' - ), + GovernorshipTransferred: event("0xc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a", {"previousGovernor": indexed(p.address), "newGovernor": indexed(p.address)}), + PendingGovernorshipTransfer: event("0xa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d", {"previousGovernor": indexed(p.address), "newGovernor": indexed(p.address)}), } export const functions = { - availableFunds: new Func<[], {}, bigint>( - abi, '0x46fcff4c' - ), - claimGovernance: new Func<[], {}, []>( - abi, '0x5d36b190' - ), - collect: new Func<[], {}, []>( - abi, '0xe5225381' - ), - collectAndRebase: new Func<[], {}, []>( - abi, '0x73796297' - ), - drip: new Func<[], {}, ([lastCollect: bigint, perBlock: bigint] & {lastCollect: bigint, perBlock: bigint})>( - abi, '0x9f678cca' - ), - dripDuration: new Func<[], {}, bigint>( - abi, '0xbb7a632e' - ), - governor: new Func<[], {}, string>( - abi, '0x0c340a24' - ), - isGovernor: new Func<[], {}, boolean>( - abi, '0xc7af3352' - ), - setDripDuration: new Func<[_durationSeconds: bigint], {_durationSeconds: bigint}, []>( - abi, '0x0493a0fa' - ), - transferGovernance: new Func<[_newGovernor: string], {_newGovernor: string}, []>( - abi, '0xd38bfff4' - ), - transferToken: new Func<[_asset: string, _amount: bigint], {_asset: string, _amount: bigint}, []>( - abi, '0x1072cbea' - ), + availableFunds: fun("0x46fcff4c", {}, p.uint256), + claimGovernance: fun("0x5d36b190", {}, ), + collect: fun("0xe5225381", {}, ), + collectAndRebase: fun("0x73796297", {}, ), + drip: fun("0x9f678cca", {}, {"lastCollect": p.uint64, "perBlock": p.uint192}), + dripDuration: fun("0xbb7a632e", {}, p.uint256), + governor: fun("0x0c340a24", {}, p.address), + isGovernor: fun("0xc7af3352", {}, p.bool), + setDripDuration: fun("0x0493a0fa", {"_durationSeconds": p.uint256}, ), + transferGovernance: fun("0xd38bfff4", {"_newGovernor": p.address}, ), + transferToken: fun("0x1072cbea", {"_asset": p.address, "_amount": p.uint256}, ), } export class Contract extends ContractBase { - availableFunds(): Promise { - return this.eth_call(functions.availableFunds, []) + availableFunds() { + return this.eth_call(functions.availableFunds, {}) } - drip(): Promise<([lastCollect: bigint, perBlock: bigint] & {lastCollect: bigint, perBlock: bigint})> { - return this.eth_call(functions.drip, []) + drip() { + return this.eth_call(functions.drip, {}) } - dripDuration(): Promise { - return this.eth_call(functions.dripDuration, []) + dripDuration() { + return this.eth_call(functions.dripDuration, {}) } - governor(): Promise { - return this.eth_call(functions.governor, []) + governor() { + return this.eth_call(functions.governor, {}) } - isGovernor(): Promise { - return this.eth_call(functions.isGovernor, []) + isGovernor() { + return this.eth_call(functions.isGovernor, {}) } } + +/// Event types +export type GovernorshipTransferredEventArgs = EParams +export type PendingGovernorshipTransferEventArgs = EParams + +/// Function types +export type AvailableFundsParams = FunctionArguments +export type AvailableFundsReturn = FunctionReturn + +export type ClaimGovernanceParams = FunctionArguments +export type ClaimGovernanceReturn = FunctionReturn + +export type CollectParams = FunctionArguments +export type CollectReturn = FunctionReturn + +export type CollectAndRebaseParams = FunctionArguments +export type CollectAndRebaseReturn = FunctionReturn + +export type DripParams = FunctionArguments +export type DripReturn = FunctionReturn + +export type DripDurationParams = FunctionArguments +export type DripDurationReturn = FunctionReturn + +export type GovernorParams = FunctionArguments +export type GovernorReturn = FunctionReturn + +export type IsGovernorParams = FunctionArguments +export type IsGovernorReturn = FunctionReturn + +export type SetDripDurationParams = FunctionArguments +export type SetDripDurationReturn = FunctionReturn + +export type TransferGovernanceParams = FunctionArguments +export type TransferGovernanceReturn = FunctionReturn + +export type TransferTokenParams = FunctionArguments +export type TransferTokenReturn = FunctionReturn + diff --git a/src/abi/eac-aggregator-proxy.ts b/src/abi/eac-aggregator-proxy.ts index bb585478..19e0c873 100644 --- a/src/abi/eac-aggregator-proxy.ts +++ b/src/abi/eac-aggregator-proxy.ts @@ -1,167 +1,188 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './eac-aggregator-proxy.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - AnswerUpdated: new LogEvent<([current: bigint, roundId: bigint, updatedAt: bigint] & {current: bigint, roundId: bigint, updatedAt: bigint})>( - abi, '0x0559884fd3a460db3073b7fc896cc77986f16e378210ded43186175bf646fc5f' - ), - NewRound: new LogEvent<([roundId: bigint, startedBy: string, startedAt: bigint] & {roundId: bigint, startedBy: string, startedAt: bigint})>( - abi, '0x0109fc6f55cf40689f02fbaad7af7fe7bbac8a3d2186600afc7d3e10cac60271' - ), - OwnershipTransferRequested: new LogEvent<([from: string, to: string] & {from: string, to: string})>( - abi, '0xed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae1278' - ), - OwnershipTransferred: new LogEvent<([from: string, to: string] & {from: string, to: string})>( - abi, '0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0' - ), + AnswerUpdated: event("0x0559884fd3a460db3073b7fc896cc77986f16e378210ded43186175bf646fc5f", {"current": indexed(p.int256), "roundId": indexed(p.uint256), "updatedAt": p.uint256}), + NewRound: event("0x0109fc6f55cf40689f02fbaad7af7fe7bbac8a3d2186600afc7d3e10cac60271", {"roundId": indexed(p.uint256), "startedBy": indexed(p.address), "startedAt": p.uint256}), + OwnershipTransferRequested: event("0xed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae1278", {"from": indexed(p.address), "to": indexed(p.address)}), + OwnershipTransferred: event("0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", {"from": indexed(p.address), "to": indexed(p.address)}), } export const functions = { - acceptOwnership: new Func<[], {}, []>( - abi, '0x79ba5097' - ), - accessController: new Func<[], {}, string>( - abi, '0xbc43cbaf' - ), - aggregator: new Func<[], {}, string>( - abi, '0x245a7bfc' - ), - confirmAggregator: new Func<[_aggregator: string], {_aggregator: string}, []>( - abi, '0xa928c096' - ), - decimals: new Func<[], {}, number>( - abi, '0x313ce567' - ), - description: new Func<[], {}, string>( - abi, '0x7284e416' - ), - getAnswer: new Func<[_roundId: bigint], {_roundId: bigint}, bigint>( - abi, '0xb5ab58dc' - ), - getRoundData: new Func<[_roundId: bigint], {_roundId: bigint}, ([roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint] & {roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint})>( - abi, '0x9a6fc8f5' - ), - getTimestamp: new Func<[_roundId: bigint], {_roundId: bigint}, bigint>( - abi, '0xb633620c' - ), - latestAnswer: new Func<[], {}, bigint>( - abi, '0x50d25bcd' - ), - latestRound: new Func<[], {}, bigint>( - abi, '0x668a0f02' - ), - latestRoundData: new Func<[], {}, ([roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint] & {roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint})>( - abi, '0xfeaf968c' - ), - latestTimestamp: new Func<[], {}, bigint>( - abi, '0x8205bf6a' - ), - owner: new Func<[], {}, string>( - abi, '0x8da5cb5b' - ), - phaseAggregators: new Func<[_: number], {}, string>( - abi, '0xc1597304' - ), - phaseId: new Func<[], {}, number>( - abi, '0x58303b10' - ), - proposeAggregator: new Func<[_aggregator: string], {_aggregator: string}, []>( - abi, '0xf8a2abd3' - ), - proposedAggregator: new Func<[], {}, string>( - abi, '0xe8c4be30' - ), - proposedGetRoundData: new Func<[_roundId: bigint], {_roundId: bigint}, ([roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint] & {roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint})>( - abi, '0x6001ac53' - ), - proposedLatestRoundData: new Func<[], {}, ([roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint] & {roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint})>( - abi, '0x8f6b4d91' - ), - setController: new Func<[_accessController: string], {_accessController: string}, []>( - abi, '0x92eefe9b' - ), - transferOwnership: new Func<[_to: string], {_to: string}, []>( - abi, '0xf2fde38b' - ), - version: new Func<[], {}, bigint>( - abi, '0x54fd4d50' - ), + acceptOwnership: fun("0x79ba5097", {}, ), + accessController: fun("0xbc43cbaf", {}, p.address), + aggregator: fun("0x245a7bfc", {}, p.address), + confirmAggregator: fun("0xa928c096", {"_aggregator": p.address}, ), + decimals: fun("0x313ce567", {}, p.uint8), + description: fun("0x7284e416", {}, p.string), + getAnswer: fun("0xb5ab58dc", {"_roundId": p.uint256}, p.int256), + getRoundData: fun("0x9a6fc8f5", {"_roundId": p.uint80}, {"roundId": p.uint80, "answer": p.int256, "startedAt": p.uint256, "updatedAt": p.uint256, "answeredInRound": p.uint80}), + getTimestamp: fun("0xb633620c", {"_roundId": p.uint256}, p.uint256), + latestAnswer: fun("0x50d25bcd", {}, p.int256), + latestRound: fun("0x668a0f02", {}, p.uint256), + latestRoundData: fun("0xfeaf968c", {}, {"roundId": p.uint80, "answer": p.int256, "startedAt": p.uint256, "updatedAt": p.uint256, "answeredInRound": p.uint80}), + latestTimestamp: fun("0x8205bf6a", {}, p.uint256), + owner: fun("0x8da5cb5b", {}, p.address), + phaseAggregators: fun("0xc1597304", {"_0": p.uint16}, p.address), + phaseId: fun("0x58303b10", {}, p.uint16), + proposeAggregator: fun("0xf8a2abd3", {"_aggregator": p.address}, ), + proposedAggregator: fun("0xe8c4be30", {}, p.address), + proposedGetRoundData: fun("0x6001ac53", {"_roundId": p.uint80}, {"roundId": p.uint80, "answer": p.int256, "startedAt": p.uint256, "updatedAt": p.uint256, "answeredInRound": p.uint80}), + proposedLatestRoundData: fun("0x8f6b4d91", {}, {"roundId": p.uint80, "answer": p.int256, "startedAt": p.uint256, "updatedAt": p.uint256, "answeredInRound": p.uint80}), + setController: fun("0x92eefe9b", {"_accessController": p.address}, ), + transferOwnership: fun("0xf2fde38b", {"_to": p.address}, ), + version: fun("0x54fd4d50", {}, p.uint256), } export class Contract extends ContractBase { - accessController(): Promise { - return this.eth_call(functions.accessController, []) + accessController() { + return this.eth_call(functions.accessController, {}) } - aggregator(): Promise { - return this.eth_call(functions.aggregator, []) + aggregator() { + return this.eth_call(functions.aggregator, {}) } - decimals(): Promise { - return this.eth_call(functions.decimals, []) + decimals() { + return this.eth_call(functions.decimals, {}) } - description(): Promise { - return this.eth_call(functions.description, []) + description() { + return this.eth_call(functions.description, {}) } - getAnswer(_roundId: bigint): Promise { - return this.eth_call(functions.getAnswer, [_roundId]) + getAnswer(_roundId: GetAnswerParams["_roundId"]) { + return this.eth_call(functions.getAnswer, {_roundId}) } - getRoundData(_roundId: bigint): Promise<([roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint] & {roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint})> { - return this.eth_call(functions.getRoundData, [_roundId]) + getRoundData(_roundId: GetRoundDataParams["_roundId"]) { + return this.eth_call(functions.getRoundData, {_roundId}) } - getTimestamp(_roundId: bigint): Promise { - return this.eth_call(functions.getTimestamp, [_roundId]) + getTimestamp(_roundId: GetTimestampParams["_roundId"]) { + return this.eth_call(functions.getTimestamp, {_roundId}) } - latestAnswer(): Promise { - return this.eth_call(functions.latestAnswer, []) + latestAnswer() { + return this.eth_call(functions.latestAnswer, {}) } - latestRound(): Promise { - return this.eth_call(functions.latestRound, []) + latestRound() { + return this.eth_call(functions.latestRound, {}) } - latestRoundData(): Promise<([roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint] & {roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint})> { - return this.eth_call(functions.latestRoundData, []) + latestRoundData() { + return this.eth_call(functions.latestRoundData, {}) } - latestTimestamp(): Promise { - return this.eth_call(functions.latestTimestamp, []) + latestTimestamp() { + return this.eth_call(functions.latestTimestamp, {}) } - owner(): Promise { - return this.eth_call(functions.owner, []) + owner() { + return this.eth_call(functions.owner, {}) } - phaseAggregators(arg0: number): Promise { - return this.eth_call(functions.phaseAggregators, [arg0]) + phaseAggregators(_0: PhaseAggregatorsParams["_0"]) { + return this.eth_call(functions.phaseAggregators, {_0}) } - phaseId(): Promise { - return this.eth_call(functions.phaseId, []) + phaseId() { + return this.eth_call(functions.phaseId, {}) } - proposedAggregator(): Promise { - return this.eth_call(functions.proposedAggregator, []) + proposedAggregator() { + return this.eth_call(functions.proposedAggregator, {}) } - proposedGetRoundData(_roundId: bigint): Promise<([roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint] & {roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint})> { - return this.eth_call(functions.proposedGetRoundData, [_roundId]) + proposedGetRoundData(_roundId: ProposedGetRoundDataParams["_roundId"]) { + return this.eth_call(functions.proposedGetRoundData, {_roundId}) } - proposedLatestRoundData(): Promise<([roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint] & {roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint})> { - return this.eth_call(functions.proposedLatestRoundData, []) + proposedLatestRoundData() { + return this.eth_call(functions.proposedLatestRoundData, {}) } - version(): Promise { - return this.eth_call(functions.version, []) + version() { + return this.eth_call(functions.version, {}) } } + +/// Event types +export type AnswerUpdatedEventArgs = EParams +export type NewRoundEventArgs = EParams +export type OwnershipTransferRequestedEventArgs = EParams +export type OwnershipTransferredEventArgs = EParams + +/// Function types +export type AcceptOwnershipParams = FunctionArguments +export type AcceptOwnershipReturn = FunctionReturn + +export type AccessControllerParams = FunctionArguments +export type AccessControllerReturn = FunctionReturn + +export type AggregatorParams = FunctionArguments +export type AggregatorReturn = FunctionReturn + +export type ConfirmAggregatorParams = FunctionArguments +export type ConfirmAggregatorReturn = FunctionReturn + +export type DecimalsParams = FunctionArguments +export type DecimalsReturn = FunctionReturn + +export type DescriptionParams = FunctionArguments +export type DescriptionReturn = FunctionReturn + +export type GetAnswerParams = FunctionArguments +export type GetAnswerReturn = FunctionReturn + +export type GetRoundDataParams = FunctionArguments +export type GetRoundDataReturn = FunctionReturn + +export type GetTimestampParams = FunctionArguments +export type GetTimestampReturn = FunctionReturn + +export type LatestAnswerParams = FunctionArguments +export type LatestAnswerReturn = FunctionReturn + +export type LatestRoundParams = FunctionArguments +export type LatestRoundReturn = FunctionReturn + +export type LatestRoundDataParams = FunctionArguments +export type LatestRoundDataReturn = FunctionReturn + +export type LatestTimestampParams = FunctionArguments +export type LatestTimestampReturn = FunctionReturn + +export type OwnerParams = FunctionArguments +export type OwnerReturn = FunctionReturn + +export type PhaseAggregatorsParams = FunctionArguments +export type PhaseAggregatorsReturn = FunctionReturn + +export type PhaseIdParams = FunctionArguments +export type PhaseIdReturn = FunctionReturn + +export type ProposeAggregatorParams = FunctionArguments +export type ProposeAggregatorReturn = FunctionReturn + +export type ProposedAggregatorParams = FunctionArguments +export type ProposedAggregatorReturn = FunctionReturn + +export type ProposedGetRoundDataParams = FunctionArguments +export type ProposedGetRoundDataReturn = FunctionReturn + +export type ProposedLatestRoundDataParams = FunctionArguments +export type ProposedLatestRoundDataReturn = FunctionReturn + +export type SetControllerParams = FunctionArguments +export type SetControllerReturn = FunctionReturn + +export type TransferOwnershipParams = FunctionArguments +export type TransferOwnershipReturn = FunctionReturn + +export type VersionParams = FunctionArguments +export type VersionReturn = FunctionReturn + diff --git a/src/abi/erc20.ts b/src/abi/erc20.ts index 674cfb88..c96a39f3 100644 --- a/src/abi/erc20.ts +++ b/src/abi/erc20.ts @@ -1,71 +1,80 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './erc20.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - Approval: new LogEvent<([owner: string, spender: string, value: bigint] & {owner: string, spender: string, value: bigint})>( - abi, '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925' - ), - Transfer: new LogEvent<([from: string, to: string, value: bigint] & {from: string, to: string, value: bigint})>( - abi, '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' - ), + Approval: event("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", {"owner": indexed(p.address), "spender": indexed(p.address), "value": p.uint256}), + Transfer: event("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", {"from": indexed(p.address), "to": indexed(p.address), "value": p.uint256}), } export const functions = { - name: new Func<[], {}, string>( - abi, '0x06fdde03' - ), - approve: new Func<[_spender: string, _value: bigint], {_spender: string, _value: bigint}, boolean>( - abi, '0x095ea7b3' - ), - totalSupply: new Func<[], {}, bigint>( - abi, '0x18160ddd' - ), - transferFrom: new Func<[_from: string, _to: string, _value: bigint], {_from: string, _to: string, _value: bigint}, boolean>( - abi, '0x23b872dd' - ), - decimals: new Func<[], {}, number>( - abi, '0x313ce567' - ), - balanceOf: new Func<[_owner: string], {_owner: string}, bigint>( - abi, '0x70a08231' - ), - symbol: new Func<[], {}, string>( - abi, '0x95d89b41' - ), - transfer: new Func<[_to: string, _value: bigint], {_to: string, _value: bigint}, boolean>( - abi, '0xa9059cbb' - ), - allowance: new Func<[_owner: string, _spender: string], {_owner: string, _spender: string}, bigint>( - abi, '0xdd62ed3e' - ), + name: fun("0x06fdde03", {}, p.string), + approve: fun("0x095ea7b3", {"_spender": p.address, "_value": p.uint256}, p.bool), + totalSupply: fun("0x18160ddd", {}, p.uint256), + transferFrom: fun("0x23b872dd", {"_from": p.address, "_to": p.address, "_value": p.uint256}, p.bool), + decimals: fun("0x313ce567", {}, p.uint8), + balanceOf: fun("0x70a08231", {"_owner": p.address}, p.uint256), + symbol: fun("0x95d89b41", {}, p.string), + transfer: fun("0xa9059cbb", {"_to": p.address, "_value": p.uint256}, p.bool), + allowance: fun("0xdd62ed3e", {"_owner": p.address, "_spender": p.address}, p.uint256), } export class Contract extends ContractBase { - name(): Promise { - return this.eth_call(functions.name, []) + name() { + return this.eth_call(functions.name, {}) } - totalSupply(): Promise { - return this.eth_call(functions.totalSupply, []) + totalSupply() { + return this.eth_call(functions.totalSupply, {}) } - decimals(): Promise { - return this.eth_call(functions.decimals, []) + decimals() { + return this.eth_call(functions.decimals, {}) } - balanceOf(_owner: string): Promise { - return this.eth_call(functions.balanceOf, [_owner]) + balanceOf(_owner: BalanceOfParams["_owner"]) { + return this.eth_call(functions.balanceOf, {_owner}) } - symbol(): Promise { - return this.eth_call(functions.symbol, []) + symbol() { + return this.eth_call(functions.symbol, {}) } - allowance(_owner: string, _spender: string): Promise { - return this.eth_call(functions.allowance, [_owner, _spender]) + allowance(_owner: AllowanceParams["_owner"], _spender: AllowanceParams["_spender"]) { + return this.eth_call(functions.allowance, {_owner, _spender}) } } + +/// Event types +export type ApprovalEventArgs = EParams +export type TransferEventArgs = EParams + +/// Function types +export type NameParams = FunctionArguments +export type NameReturn = FunctionReturn + +export type ApproveParams = FunctionArguments +export type ApproveReturn = FunctionReturn + +export type TotalSupplyParams = FunctionArguments +export type TotalSupplyReturn = FunctionReturn + +export type TransferFromParams = FunctionArguments +export type TransferFromReturn = FunctionReturn + +export type DecimalsParams = FunctionArguments +export type DecimalsReturn = FunctionReturn + +export type BalanceOfParams = FunctionArguments +export type BalanceOfReturn = FunctionReturn + +export type SymbolParams = FunctionArguments +export type SymbolReturn = FunctionReturn + +export type TransferParams = FunctionArguments +export type TransferReturn = FunctionReturn + +export type AllowanceParams = FunctionArguments +export type AllowanceReturn = FunctionReturn + diff --git a/src/abi/frx-eth-frax-oracle.ts b/src/abi/frx-eth-frax-oracle.ts index 3c6bee1e..873ef71f 100644 --- a/src/abi/frx-eth-frax-oracle.ts +++ b/src/abi/frx-eth-frax-oracle.ts @@ -1,162 +1,182 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './frx-eth-frax-oracle.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - SetMaximumDeviation: new LogEvent<([oldMaxDeviation: bigint, newMaxDeviation: bigint] & {oldMaxDeviation: bigint, newMaxDeviation: bigint})>( - abi, '0x7e2a21727a662d0def125b3d1237f41a099a760d472095091724cd8e56c25bf0' - ), - SetMaximumOracleDelay: new LogEvent<([oldMaxOracleDelay: bigint, newMaxOracleDelay: bigint] & {oldMaxOracleDelay: bigint, newMaxOracleDelay: bigint})>( - abi, '0xd72ef688fa430b6a285b84371ba35e8a8e0762b32c1deb7be9d9c111ca79f5ea' - ), - SetPriceSource: new LogEvent<([oldPriceSource: string, newPriceSource: string] & {oldPriceSource: string, newPriceSource: string})>( - abi, '0x964298b435edfc268e11aa89b342ef1ddac566da6759b6dd15d7aad58a1dc935' - ), - TimelockTransferStarted: new LogEvent<([previousTimelock: string, newTimelock: string] & {previousTimelock: string, newTimelock: string})>( - abi, '0x162998b90abc2507f3953aa797827b03a14c42dbd9a35f09feaf02e0d592773a' - ), - TimelockTransferred: new LogEvent<([previousTimelock: string, newTimelock: string] & {previousTimelock: string, newTimelock: string})>( - abi, '0x31b6c5a04b069b6ec1b3cef44c4e7c1eadd721349cda9823d0b1877b3551cdc6' - ), + SetMaximumDeviation: event("0x7e2a21727a662d0def125b3d1237f41a099a760d472095091724cd8e56c25bf0", {"oldMaxDeviation": p.uint256, "newMaxDeviation": p.uint256}), + SetMaximumOracleDelay: event("0xd72ef688fa430b6a285b84371ba35e8a8e0762b32c1deb7be9d9c111ca79f5ea", {"oldMaxOracleDelay": p.uint256, "newMaxOracleDelay": p.uint256}), + SetPriceSource: event("0x964298b435edfc268e11aa89b342ef1ddac566da6759b6dd15d7aad58a1dc935", {"oldPriceSource": p.address, "newPriceSource": p.address}), + TimelockTransferStarted: event("0x162998b90abc2507f3953aa797827b03a14c42dbd9a35f09feaf02e0d592773a", {"previousTimelock": indexed(p.address), "newTimelock": indexed(p.address)}), + TimelockTransferred: event("0x31b6c5a04b069b6ec1b3cef44c4e7c1eadd721349cda9823d0b1877b3551cdc6", {"previousTimelock": indexed(p.address), "newTimelock": indexed(p.address)}), } export const functions = { - BASE_TOKEN: new Func<[], {}, string>( - abi, '0x210663e4' - ), - QUOTE_TOKEN: new Func<[], {}, string>( - abi, '0x78892cea' - ), - acceptTransferTimelock: new Func<[], {}, []>( - abi, '0xf6ccaad4' - ), - addRoundData: new Func<[_isBadData: boolean, _priceLow: bigint, _priceHigh: bigint, _timestamp: number], {_isBadData: boolean, _priceLow: bigint, _priceHigh: bigint, _timestamp: number}, []>( - abi, '0x45d9f582' - ), - decimals: new Func<[], {}, number>( - abi, '0x313ce567' - ), - description: new Func<[], {}, string>( - abi, '0x7284e416' - ), - getPrices: new Func<[], {}, ([_isBadData: boolean, _priceLow: bigint, _priceHigh: bigint] & {_isBadData: boolean, _priceLow: bigint, _priceHigh: bigint})>( - abi, '0xbd9a548b' - ), - getRoundData: new Func<[_roundId: bigint], {_roundId: bigint}, ([roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint] & {roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint})>( - abi, '0x9a6fc8f5' - ), - lastCorrectRoundId: new Func<[], {}, bigint>( - abi, '0x0f4a05fb' - ), - latestRoundData: new Func<[], {}, ([roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint] & {roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint})>( - abi, '0xfeaf968c' - ), - maximumDeviation: new Func<[], {}, bigint>( - abi, '0x9152c29d' - ), - maximumOracleDelay: new Func<[], {}, bigint>( - abi, '0xcede91a4' - ), - pendingTimelockAddress: new Func<[], {}, string>( - abi, '0x090f3f50' - ), - priceSource: new Func<[], {}, string>( - abi, '0x20531bc9' - ), - renounceTimelock: new Func<[], {}, []>( - abi, '0x4f8b4ae7' - ), - rounds: new Func<[_: bigint], {}, ([priceLow: bigint, priceHigh: bigint, timestamp: number, isBadData: boolean] & {priceLow: bigint, priceHigh: bigint, timestamp: number, isBadData: boolean})>( - abi, '0x8c65c81f' - ), - setMaximumDeviation: new Func<[_newMaxDeviation: bigint], {_newMaxDeviation: bigint}, []>( - abi, '0x2dfa4267' - ), - setMaximumOracleDelay: new Func<[_newMaxOracleDelay: bigint], {_newMaxOracleDelay: bigint}, []>( - abi, '0xd2333be7' - ), - setPriceSource: new Func<[_newPriceSource: string], {_newPriceSource: string}, []>( - abi, '0xbda53107' - ), - supportsInterface: new Func<[interfaceId: string], {interfaceId: string}, boolean>( - abi, '0x01ffc9a7' - ), - timelockAddress: new Func<[], {}, string>( - abi, '0x4bc66f32' - ), - transferTimelock: new Func<[_newTimelock: string], {_newTimelock: string}, []>( - abi, '0x45014095' - ), - version: new Func<[], {}, bigint>( - abi, '0x54fd4d50' - ), + BASE_TOKEN: fun("0x210663e4", {}, p.address), + QUOTE_TOKEN: fun("0x78892cea", {}, p.address), + acceptTransferTimelock: fun("0xf6ccaad4", {}, ), + addRoundData: fun("0x45d9f582", {"_isBadData": p.bool, "_priceLow": p.uint104, "_priceHigh": p.uint104, "_timestamp": p.uint40}, ), + decimals: fun("0x313ce567", {}, p.uint8), + description: fun("0x7284e416", {}, p.string), + getPrices: fun("0xbd9a548b", {}, {"_isBadData": p.bool, "_priceLow": p.uint256, "_priceHigh": p.uint256}), + getRoundData: fun("0x9a6fc8f5", {"_roundId": p.uint80}, {"roundId": p.uint80, "answer": p.int256, "startedAt": p.uint256, "updatedAt": p.uint256, "answeredInRound": p.uint80}), + lastCorrectRoundId: fun("0x0f4a05fb", {}, p.uint80), + latestRoundData: fun("0xfeaf968c", {}, {"roundId": p.uint80, "answer": p.int256, "startedAt": p.uint256, "updatedAt": p.uint256, "answeredInRound": p.uint80}), + maximumDeviation: fun("0x9152c29d", {}, p.uint256), + maximumOracleDelay: fun("0xcede91a4", {}, p.uint256), + pendingTimelockAddress: fun("0x090f3f50", {}, p.address), + priceSource: fun("0x20531bc9", {}, p.address), + renounceTimelock: fun("0x4f8b4ae7", {}, ), + rounds: fun("0x8c65c81f", {"_0": p.uint256}, {"priceLow": p.uint104, "priceHigh": p.uint104, "timestamp": p.uint40, "isBadData": p.bool}), + setMaximumDeviation: fun("0x2dfa4267", {"_newMaxDeviation": p.uint256}, ), + setMaximumOracleDelay: fun("0xd2333be7", {"_newMaxOracleDelay": p.uint256}, ), + setPriceSource: fun("0xbda53107", {"_newPriceSource": p.address}, ), + supportsInterface: fun("0x01ffc9a7", {"interfaceId": p.bytes4}, p.bool), + timelockAddress: fun("0x4bc66f32", {}, p.address), + transferTimelock: fun("0x45014095", {"_newTimelock": p.address}, ), + version: fun("0x54fd4d50", {}, p.uint256), } export class Contract extends ContractBase { - BASE_TOKEN(): Promise { - return this.eth_call(functions.BASE_TOKEN, []) + BASE_TOKEN() { + return this.eth_call(functions.BASE_TOKEN, {}) } - QUOTE_TOKEN(): Promise { - return this.eth_call(functions.QUOTE_TOKEN, []) + QUOTE_TOKEN() { + return this.eth_call(functions.QUOTE_TOKEN, {}) } - decimals(): Promise { - return this.eth_call(functions.decimals, []) + decimals() { + return this.eth_call(functions.decimals, {}) } - description(): Promise { - return this.eth_call(functions.description, []) + description() { + return this.eth_call(functions.description, {}) } - getPrices(): Promise<([_isBadData: boolean, _priceLow: bigint, _priceHigh: bigint] & {_isBadData: boolean, _priceLow: bigint, _priceHigh: bigint})> { - return this.eth_call(functions.getPrices, []) + getPrices() { + return this.eth_call(functions.getPrices, {}) } - getRoundData(_roundId: bigint): Promise<([roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint] & {roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint})> { - return this.eth_call(functions.getRoundData, [_roundId]) + getRoundData(_roundId: GetRoundDataParams["_roundId"]) { + return this.eth_call(functions.getRoundData, {_roundId}) } - lastCorrectRoundId(): Promise { - return this.eth_call(functions.lastCorrectRoundId, []) + lastCorrectRoundId() { + return this.eth_call(functions.lastCorrectRoundId, {}) } - latestRoundData(): Promise<([roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint] & {roundId: bigint, answer: bigint, startedAt: bigint, updatedAt: bigint, answeredInRound: bigint})> { - return this.eth_call(functions.latestRoundData, []) + latestRoundData() { + return this.eth_call(functions.latestRoundData, {}) } - maximumDeviation(): Promise { - return this.eth_call(functions.maximumDeviation, []) + maximumDeviation() { + return this.eth_call(functions.maximumDeviation, {}) } - maximumOracleDelay(): Promise { - return this.eth_call(functions.maximumOracleDelay, []) + maximumOracleDelay() { + return this.eth_call(functions.maximumOracleDelay, {}) } - pendingTimelockAddress(): Promise { - return this.eth_call(functions.pendingTimelockAddress, []) + pendingTimelockAddress() { + return this.eth_call(functions.pendingTimelockAddress, {}) } - priceSource(): Promise { - return this.eth_call(functions.priceSource, []) + priceSource() { + return this.eth_call(functions.priceSource, {}) } - rounds(arg0: bigint): Promise<([priceLow: bigint, priceHigh: bigint, timestamp: number, isBadData: boolean] & {priceLow: bigint, priceHigh: bigint, timestamp: number, isBadData: boolean})> { - return this.eth_call(functions.rounds, [arg0]) + rounds(_0: RoundsParams["_0"]) { + return this.eth_call(functions.rounds, {_0}) } - supportsInterface(interfaceId: string): Promise { - return this.eth_call(functions.supportsInterface, [interfaceId]) + supportsInterface(interfaceId: SupportsInterfaceParams["interfaceId"]) { + return this.eth_call(functions.supportsInterface, {interfaceId}) } - timelockAddress(): Promise { - return this.eth_call(functions.timelockAddress, []) + timelockAddress() { + return this.eth_call(functions.timelockAddress, {}) } - version(): Promise { - return this.eth_call(functions.version, []) + version() { + return this.eth_call(functions.version, {}) } } + +/// Event types +export type SetMaximumDeviationEventArgs = EParams +export type SetMaximumOracleDelayEventArgs = EParams +export type SetPriceSourceEventArgs = EParams +export type TimelockTransferStartedEventArgs = EParams +export type TimelockTransferredEventArgs = EParams + +/// Function types +export type BASE_TOKENParams = FunctionArguments +export type BASE_TOKENReturn = FunctionReturn + +export type QUOTE_TOKENParams = FunctionArguments +export type QUOTE_TOKENReturn = FunctionReturn + +export type AcceptTransferTimelockParams = FunctionArguments +export type AcceptTransferTimelockReturn = FunctionReturn + +export type AddRoundDataParams = FunctionArguments +export type AddRoundDataReturn = FunctionReturn + +export type DecimalsParams = FunctionArguments +export type DecimalsReturn = FunctionReturn + +export type DescriptionParams = FunctionArguments +export type DescriptionReturn = FunctionReturn + +export type GetPricesParams = FunctionArguments +export type GetPricesReturn = FunctionReturn + +export type GetRoundDataParams = FunctionArguments +export type GetRoundDataReturn = FunctionReturn + +export type LastCorrectRoundIdParams = FunctionArguments +export type LastCorrectRoundIdReturn = FunctionReturn + +export type LatestRoundDataParams = FunctionArguments +export type LatestRoundDataReturn = FunctionReturn + +export type MaximumDeviationParams = FunctionArguments +export type MaximumDeviationReturn = FunctionReturn + +export type MaximumOracleDelayParams = FunctionArguments +export type MaximumOracleDelayReturn = FunctionReturn + +export type PendingTimelockAddressParams = FunctionArguments +export type PendingTimelockAddressReturn = FunctionReturn + +export type PriceSourceParams = FunctionArguments +export type PriceSourceReturn = FunctionReturn + +export type RenounceTimelockParams = FunctionArguments +export type RenounceTimelockReturn = FunctionReturn + +export type RoundsParams = FunctionArguments +export type RoundsReturn = FunctionReturn + +export type SetMaximumDeviationParams = FunctionArguments +export type SetMaximumDeviationReturn = FunctionReturn + +export type SetMaximumOracleDelayParams = FunctionArguments +export type SetMaximumOracleDelayReturn = FunctionReturn + +export type SetPriceSourceParams = FunctionArguments +export type SetPriceSourceReturn = FunctionReturn + +export type SupportsInterfaceParams = FunctionArguments +export type SupportsInterfaceReturn = FunctionReturn + +export type TimelockAddressParams = FunctionArguments +export type TimelockAddressReturn = FunctionReturn + +export type TransferTimelockParams = FunctionArguments +export type TransferTimelockReturn = FunctionReturn + +export type VersionParams = FunctionArguments +export type VersionReturn = FunctionReturn + diff --git a/src/abi/governance.ts b/src/abi/governance.ts index 16ee2e26..adde29c3 100644 --- a/src/abi/governance.ts +++ b/src/abi/governance.ts @@ -1,308 +1,346 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './governance.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - LateQuorumVoteExtensionSet: new LogEvent<([oldVoteExtension: bigint, newVoteExtension: bigint] & {oldVoteExtension: bigint, newVoteExtension: bigint})>( - abi, '0x7ca4ac117ed3cdce75c1161d8207c440389b1a15d69d096831664657c07dafc2' - ), - ProposalCanceled: new LogEvent<([proposalId: bigint] & {proposalId: bigint})>( - abi, '0x789cf55be980739dad1d0699b93b58e806b51c9d96619bfa8fe0a28abaa7b30c' - ), - ProposalCreated: new LogEvent<([proposalId: bigint, proposer: string, targets: Array, values: Array, signatures: Array, calldatas: Array, startBlock: bigint, endBlock: bigint, description: string] & {proposalId: bigint, proposer: string, targets: Array, signatures: Array, calldatas: Array, startBlock: bigint, endBlock: bigint, description: string})>( - abi, '0x7d84a6263ae0d98d3329bd7b46bb4e8d6f98cd35a7adb45c274c8b7fd5ebd5e0' - ), - ProposalExecuted: new LogEvent<([proposalId: bigint] & {proposalId: bigint})>( - abi, '0x712ae1383f79ac853f8d882153778e0260ef8f03b504e2866e0593e04d2b291f' - ), - ProposalExtended: new LogEvent<([proposalId: bigint, extendedDeadline: bigint] & {proposalId: bigint, extendedDeadline: bigint})>( - abi, '0x541f725fb9f7c98a30cc9c0ff32fbb14358cd7159c847a3aa20a2bdc442ba511' - ), - ProposalQueued: new LogEvent<([proposalId: bigint, eta: bigint] & {proposalId: bigint, eta: bigint})>( - abi, '0x9a2e42fd6722813d69113e7d0079d3d940171428df7373df9c7f7617cfda2892' - ), - ProposalThresholdSet: new LogEvent<([oldProposalThreshold: bigint, newProposalThreshold: bigint] & {oldProposalThreshold: bigint, newProposalThreshold: bigint})>( - abi, '0xccb45da8d5717e6c4544694297c4ba5cf151d455c9bb0ed4fc7a38411bc05461' - ), - QuorumNumeratorUpdated: new LogEvent<([oldQuorumNumerator: bigint, newQuorumNumerator: bigint] & {oldQuorumNumerator: bigint, newQuorumNumerator: bigint})>( - abi, '0x0553476bf02ef2726e8ce5ced78d63e26e602e4a2257b1f559418e24b4633997' - ), - TimelockChange: new LogEvent<([oldTimelock: string, newTimelock: string] & {oldTimelock: string, newTimelock: string})>( - abi, '0x08f74ea46ef7894f65eabfb5e6e695de773a000b47c529ab559178069b226401' - ), - VoteCast: new LogEvent<([voter: string, proposalId: bigint, support: number, weight: bigint, reason: string] & {voter: string, proposalId: bigint, support: number, weight: bigint, reason: string})>( - abi, '0xb8e138887d0aa13bab447e82de9d5c1777041ecd21ca36ba824ff1e6c07ddda4' - ), - VoteCastWithParams: new LogEvent<([voter: string, proposalId: bigint, support: number, weight: bigint, reason: string, params: string] & {voter: string, proposalId: bigint, support: number, weight: bigint, reason: string, params: string})>( - abi, '0xe2babfbac5889a709b63bb7f598b324e08bc5a4fb9ec647fb3cbc9ec07eb8712' - ), - VotingDelaySet: new LogEvent<([oldVotingDelay: bigint, newVotingDelay: bigint] & {oldVotingDelay: bigint, newVotingDelay: bigint})>( - abi, '0xc565b045403dc03c2eea82b81a0465edad9e2e7fc4d97e11421c209da93d7a93' - ), - VotingPeriodSet: new LogEvent<([oldVotingPeriod: bigint, newVotingPeriod: bigint] & {oldVotingPeriod: bigint, newVotingPeriod: bigint})>( - abi, '0x7e3f7f0708a84de9203036abaa450dccc85ad5ff52f78c170f3edb55cf5e8828' - ), + LateQuorumVoteExtensionSet: event("0x7ca4ac117ed3cdce75c1161d8207c440389b1a15d69d096831664657c07dafc2", {"oldVoteExtension": p.uint64, "newVoteExtension": p.uint64}), + ProposalCanceled: event("0x789cf55be980739dad1d0699b93b58e806b51c9d96619bfa8fe0a28abaa7b30c", {"proposalId": p.uint256}), + ProposalCreated: event("0x7d84a6263ae0d98d3329bd7b46bb4e8d6f98cd35a7adb45c274c8b7fd5ebd5e0", {"proposalId": p.uint256, "proposer": p.address, "targets": p.array(p.address), "values": p.array(p.uint256), "signatures": p.array(p.string), "calldatas": p.array(p.bytes), "startBlock": p.uint256, "endBlock": p.uint256, "description": p.string}), + ProposalExecuted: event("0x712ae1383f79ac853f8d882153778e0260ef8f03b504e2866e0593e04d2b291f", {"proposalId": p.uint256}), + ProposalExtended: event("0x541f725fb9f7c98a30cc9c0ff32fbb14358cd7159c847a3aa20a2bdc442ba511", {"proposalId": indexed(p.uint256), "extendedDeadline": p.uint64}), + ProposalQueued: event("0x9a2e42fd6722813d69113e7d0079d3d940171428df7373df9c7f7617cfda2892", {"proposalId": p.uint256, "eta": p.uint256}), + ProposalThresholdSet: event("0xccb45da8d5717e6c4544694297c4ba5cf151d455c9bb0ed4fc7a38411bc05461", {"oldProposalThreshold": p.uint256, "newProposalThreshold": p.uint256}), + QuorumNumeratorUpdated: event("0x0553476bf02ef2726e8ce5ced78d63e26e602e4a2257b1f559418e24b4633997", {"oldQuorumNumerator": p.uint256, "newQuorumNumerator": p.uint256}), + TimelockChange: event("0x08f74ea46ef7894f65eabfb5e6e695de773a000b47c529ab559178069b226401", {"oldTimelock": p.address, "newTimelock": p.address}), + VoteCast: event("0xb8e138887d0aa13bab447e82de9d5c1777041ecd21ca36ba824ff1e6c07ddda4", {"voter": indexed(p.address), "proposalId": p.uint256, "support": p.uint8, "weight": p.uint256, "reason": p.string}), + VoteCastWithParams: event("0xe2babfbac5889a709b63bb7f598b324e08bc5a4fb9ec647fb3cbc9ec07eb8712", {"voter": indexed(p.address), "proposalId": p.uint256, "support": p.uint8, "weight": p.uint256, "reason": p.string, "params": p.bytes}), + VotingDelaySet: event("0xc565b045403dc03c2eea82b81a0465edad9e2e7fc4d97e11421c209da93d7a93", {"oldVotingDelay": p.uint256, "newVotingDelay": p.uint256}), + VotingPeriodSet: event("0x7e3f7f0708a84de9203036abaa450dccc85ad5ff52f78c170f3edb55cf5e8828", {"oldVotingPeriod": p.uint256, "newVotingPeriod": p.uint256}), } export const functions = { - BALLOT_TYPEHASH: new Func<[], {}, string>( - abi, '0xdeaaa7cc' - ), - COUNTING_MODE: new Func<[], {}, string>( - abi, '0xdd4e2ba5' - ), - EXTENDED_BALLOT_TYPEHASH: new Func<[], {}, string>( - abi, '0x2fe3e261' - ), - cancel: new Func<[proposalId: bigint], {proposalId: bigint}, []>( - abi, '0x40e58ee5' - ), - castVote: new Func<[proposalId: bigint, support: number], {proposalId: bigint, support: number}, bigint>( - abi, '0x56781388' - ), - castVoteBySig: new Func<[proposalId: bigint, support: number, v: number, r: string, s: string], {proposalId: bigint, support: number, v: number, r: string, s: string}, bigint>( - abi, '0x3bccf4fd' - ), - castVoteWithReason: new Func<[proposalId: bigint, support: number, reason: string], {proposalId: bigint, support: number, reason: string}, bigint>( - abi, '0x7b3c71d3' - ), - castVoteWithReasonAndParams: new Func<[proposalId: bigint, support: number, reason: string, params: string], {proposalId: bigint, support: number, reason: string, params: string}, bigint>( - abi, '0x5f398a14' - ), - castVoteWithReasonAndParamsBySig: new Func<[proposalId: bigint, support: number, reason: string, params: string, v: number, r: string, s: string], {proposalId: bigint, support: number, reason: string, params: string, v: number, r: string, s: string}, bigint>( - abi, '0x03420181' - ), - 'execute(address[],uint256[],bytes[],bytes32)': new Func<[targets: Array, values: Array, calldatas: Array, descriptionHash: string], {targets: Array, calldatas: Array, descriptionHash: string}, bigint>( - abi, '0x2656227d' - ), - 'execute(uint256)': new Func<[proposalId: bigint], {proposalId: bigint}, []>( - abi, '0xfe0d94c1' - ), - getActions: new Func<[proposalId: bigint], {proposalId: bigint}, ([targets: Array, values: Array, signatures: Array, calldatas: Array] & {targets: Array, signatures: Array, calldatas: Array})>( - abi, '0x328dd982' - ), - getReceipt: new Func<[proposalId: bigint, voter: string], {proposalId: bigint, voter: string}, ([hasVoted: boolean, support: number, votes: bigint] & {hasVoted: boolean, support: number, votes: bigint})>( - abi, '0xe23a9a52' - ), - getVotes: new Func<[account: string, blockNumber: bigint], {account: string, blockNumber: bigint}, bigint>( - abi, '0xeb9019d4' - ), - getVotesWithParams: new Func<[account: string, blockNumber: bigint, params: string], {account: string, blockNumber: bigint, params: string}, bigint>( - abi, '0x9a802a6d' - ), - hasVoted: new Func<[proposalId: bigint, account: string], {proposalId: bigint, account: string}, boolean>( - abi, '0x43859632' - ), - hashProposal: new Func<[targets: Array, values: Array, calldatas: Array, descriptionHash: string], {targets: Array, calldatas: Array, descriptionHash: string}, bigint>( - abi, '0xc59057e4' - ), - lateQuorumVoteExtension: new Func<[], {}, bigint>( - abi, '0x32b8113e' - ), - name: new Func<[], {}, string>( - abi, '0x06fdde03' - ), - onERC1155BatchReceived: new Func<[_: string, _: string, _: Array, _: Array, _: string], {}, string>( - abi, '0xbc197c81' - ), - onERC1155Received: new Func<[_: string, _: string, _: bigint, _: bigint, _: string], {}, string>( - abi, '0xf23a6e61' - ), - onERC721Received: new Func<[_: string, _: string, _: bigint, _: string], {}, string>( - abi, '0x150b7a02' - ), - proposalDeadline: new Func<[proposalId: bigint], {proposalId: bigint}, bigint>( - abi, '0xc01f9e37' - ), - proposalEta: new Func<[proposalId: bigint], {proposalId: bigint}, bigint>( - abi, '0xab58fb8e' - ), - proposalSnapshot: new Func<[proposalId: bigint], {proposalId: bigint}, bigint>( - abi, '0x2d63f693' - ), - proposalThreshold: new Func<[], {}, bigint>( - abi, '0xb58131b0' - ), - proposals: new Func<[proposalId: bigint], {proposalId: bigint}, ([id: bigint, proposer: string, eta: bigint, startBlock: bigint, endBlock: bigint, forVotes: bigint, againstVotes: bigint, abstainVotes: bigint, canceled: boolean, executed: boolean] & {id: bigint, proposer: string, eta: bigint, startBlock: bigint, endBlock: bigint, forVotes: bigint, againstVotes: bigint, abstainVotes: bigint, canceled: boolean, executed: boolean})>( - abi, '0x013cf08b' - ), - 'propose(address[],uint256[],bytes[],string)': new Func<[targets: Array, values: Array, calldatas: Array, description: string], {targets: Array, calldatas: Array, description: string}, bigint>( - abi, '0x7d5e81e2' - ), - 'propose(address[],uint256[],string[],bytes[],string)': new Func<[targets: Array, values: Array, signatures: Array, calldatas: Array, description: string], {targets: Array, signatures: Array, calldatas: Array, description: string}, bigint>( - abi, '0xda95691a' - ), - 'queue(address[],uint256[],bytes[],bytes32)': new Func<[targets: Array, values: Array, calldatas: Array, descriptionHash: string], {targets: Array, calldatas: Array, descriptionHash: string}, bigint>( - abi, '0x160cbed7' - ), - 'queue(uint256)': new Func<[proposalId: bigint], {proposalId: bigint}, []>( - abi, '0xddf0b009' - ), - quorum: new Func<[blockNumber: bigint], {blockNumber: bigint}, bigint>( - abi, '0xf8ce560a' - ), - quorumDenominator: new Func<[], {}, bigint>( - abi, '0x97c3d334' - ), - quorumNumerator: new Func<[], {}, bigint>( - abi, '0xa7713a70' - ), - quorumVotes: new Func<[], {}, bigint>( - abi, '0x24bc1a64' - ), - relay: new Func<[target: string, value: bigint, data: string], {target: string, value: bigint, data: string}, []>( - abi, '0xc28bc2fa' - ), - setLateQuorumVoteExtension: new Func<[newVoteExtension: bigint], {newVoteExtension: bigint}, []>( - abi, '0xd07f91e9' - ), - setProposalThreshold: new Func<[newProposalThreshold: bigint], {newProposalThreshold: bigint}, []>( - abi, '0xece40cc1' - ), - setVotingDelay: new Func<[newVotingDelay: bigint], {newVotingDelay: bigint}, []>( - abi, '0x70b0f660' - ), - setVotingPeriod: new Func<[newVotingPeriod: bigint], {newVotingPeriod: bigint}, []>( - abi, '0xea0217cf' - ), - state: new Func<[proposalId: bigint], {proposalId: bigint}, number>( - abi, '0x3e4f49e6' - ), - supportsInterface: new Func<[interfaceId: string], {interfaceId: string}, boolean>( - abi, '0x01ffc9a7' - ), - timelock: new Func<[], {}, string>( - abi, '0xd33219b4' - ), - token: new Func<[], {}, string>( - abi, '0xfc0c546a' - ), - updateQuorumNumerator: new Func<[newQuorumNumerator: bigint], {newQuorumNumerator: bigint}, []>( - abi, '0x06f3f9e6' - ), - updateTimelock: new Func<[newTimelock: string], {newTimelock: string}, []>( - abi, '0xa890c910' - ), - version: new Func<[], {}, string>( - abi, '0x54fd4d50' - ), - votingDelay: new Func<[], {}, bigint>( - abi, '0x3932abb1' - ), - votingPeriod: new Func<[], {}, bigint>( - abi, '0x02a251a3' - ), + BALLOT_TYPEHASH: fun("0xdeaaa7cc", {}, p.bytes32), + COUNTING_MODE: fun("0xdd4e2ba5", {}, p.string), + EXTENDED_BALLOT_TYPEHASH: fun("0x2fe3e261", {}, p.bytes32), + cancel: fun("0x40e58ee5", {"proposalId": p.uint256}, ), + castVote: fun("0x56781388", {"proposalId": p.uint256, "support": p.uint8}, p.uint256), + castVoteBySig: fun("0x3bccf4fd", {"proposalId": p.uint256, "support": p.uint8, "v": p.uint8, "r": p.bytes32, "s": p.bytes32}, p.uint256), + castVoteWithReason: fun("0x7b3c71d3", {"proposalId": p.uint256, "support": p.uint8, "reason": p.string}, p.uint256), + castVoteWithReasonAndParams: fun("0x5f398a14", {"proposalId": p.uint256, "support": p.uint8, "reason": p.string, "params": p.bytes}, p.uint256), + castVoteWithReasonAndParamsBySig: fun("0x03420181", {"proposalId": p.uint256, "support": p.uint8, "reason": p.string, "params": p.bytes, "v": p.uint8, "r": p.bytes32, "s": p.bytes32}, p.uint256), + "execute(address[],uint256[],bytes[],bytes32)": fun("0x2656227d", {"targets": p.array(p.address), "values": p.array(p.uint256), "calldatas": p.array(p.bytes), "descriptionHash": p.bytes32}, p.uint256), + "execute(uint256)": fun("0xfe0d94c1", {"proposalId": p.uint256}, ), + getActions: fun("0x328dd982", {"proposalId": p.uint256}, {"targets": p.array(p.address), "values": p.array(p.uint256), "signatures": p.array(p.string), "calldatas": p.array(p.bytes)}), + getReceipt: fun("0xe23a9a52", {"proposalId": p.uint256, "voter": p.address}, p.struct({"hasVoted": p.bool, "support": p.uint8, "votes": p.uint256})), + getVotes: fun("0xeb9019d4", {"account": p.address, "blockNumber": p.uint256}, p.uint256), + getVotesWithParams: fun("0x9a802a6d", {"account": p.address, "blockNumber": p.uint256, "params": p.bytes}, p.uint256), + hasVoted: fun("0x43859632", {"proposalId": p.uint256, "account": p.address}, p.bool), + hashProposal: fun("0xc59057e4", {"targets": p.array(p.address), "values": p.array(p.uint256), "calldatas": p.array(p.bytes), "descriptionHash": p.bytes32}, p.uint256), + lateQuorumVoteExtension: fun("0x32b8113e", {}, p.uint64), + name: fun("0x06fdde03", {}, p.string), + onERC1155BatchReceived: fun("0xbc197c81", {"_0": p.address, "_1": p.address, "_2": p.array(p.uint256), "_3": p.array(p.uint256), "_4": p.bytes}, p.bytes4), + onERC1155Received: fun("0xf23a6e61", {"_0": p.address, "_1": p.address, "_2": p.uint256, "_3": p.uint256, "_4": p.bytes}, p.bytes4), + onERC721Received: fun("0x150b7a02", {"_0": p.address, "_1": p.address, "_2": p.uint256, "_3": p.bytes}, p.bytes4), + proposalDeadline: fun("0xc01f9e37", {"proposalId": p.uint256}, p.uint256), + proposalEta: fun("0xab58fb8e", {"proposalId": p.uint256}, p.uint256), + proposalSnapshot: fun("0x2d63f693", {"proposalId": p.uint256}, p.uint256), + proposalThreshold: fun("0xb58131b0", {}, p.uint256), + proposals: fun("0x013cf08b", {"proposalId": p.uint256}, {"id": p.uint256, "proposer": p.address, "eta": p.uint256, "startBlock": p.uint256, "endBlock": p.uint256, "forVotes": p.uint256, "againstVotes": p.uint256, "abstainVotes": p.uint256, "canceled": p.bool, "executed": p.bool}), + "propose(address[],uint256[],bytes[],string)": fun("0x7d5e81e2", {"targets": p.array(p.address), "values": p.array(p.uint256), "calldatas": p.array(p.bytes), "description": p.string}, p.uint256), + "propose(address[],uint256[],string[],bytes[],string)": fun("0xda95691a", {"targets": p.array(p.address), "values": p.array(p.uint256), "signatures": p.array(p.string), "calldatas": p.array(p.bytes), "description": p.string}, p.uint256), + "queue(address[],uint256[],bytes[],bytes32)": fun("0x160cbed7", {"targets": p.array(p.address), "values": p.array(p.uint256), "calldatas": p.array(p.bytes), "descriptionHash": p.bytes32}, p.uint256), + "queue(uint256)": fun("0xddf0b009", {"proposalId": p.uint256}, ), + quorum: fun("0xf8ce560a", {"blockNumber": p.uint256}, p.uint256), + quorumDenominator: fun("0x97c3d334", {}, p.uint256), + quorumNumerator: fun("0xa7713a70", {}, p.uint256), + quorumVotes: fun("0x24bc1a64", {}, p.uint256), + relay: fun("0xc28bc2fa", {"target": p.address, "value": p.uint256, "data": p.bytes}, ), + setLateQuorumVoteExtension: fun("0xd07f91e9", {"newVoteExtension": p.uint64}, ), + setProposalThreshold: fun("0xece40cc1", {"newProposalThreshold": p.uint256}, ), + setVotingDelay: fun("0x70b0f660", {"newVotingDelay": p.uint256}, ), + setVotingPeriod: fun("0xea0217cf", {"newVotingPeriod": p.uint256}, ), + state: fun("0x3e4f49e6", {"proposalId": p.uint256}, p.uint8), + supportsInterface: fun("0x01ffc9a7", {"interfaceId": p.bytes4}, p.bool), + timelock: fun("0xd33219b4", {}, p.address), + token: fun("0xfc0c546a", {}, p.address), + updateQuorumNumerator: fun("0x06f3f9e6", {"newQuorumNumerator": p.uint256}, ), + updateTimelock: fun("0xa890c910", {"newTimelock": p.address}, ), + version: fun("0x54fd4d50", {}, p.string), + votingDelay: fun("0x3932abb1", {}, p.uint256), + votingPeriod: fun("0x02a251a3", {}, p.uint256), } export class Contract extends ContractBase { - BALLOT_TYPEHASH(): Promise { - return this.eth_call(functions.BALLOT_TYPEHASH, []) + BALLOT_TYPEHASH() { + return this.eth_call(functions.BALLOT_TYPEHASH, {}) } - COUNTING_MODE(): Promise { - return this.eth_call(functions.COUNTING_MODE, []) + COUNTING_MODE() { + return this.eth_call(functions.COUNTING_MODE, {}) } - EXTENDED_BALLOT_TYPEHASH(): Promise { - return this.eth_call(functions.EXTENDED_BALLOT_TYPEHASH, []) + EXTENDED_BALLOT_TYPEHASH() { + return this.eth_call(functions.EXTENDED_BALLOT_TYPEHASH, {}) } - getActions(proposalId: bigint): Promise<([targets: Array, values: Array, signatures: Array, calldatas: Array] & {targets: Array, signatures: Array, calldatas: Array})> { - return this.eth_call(functions.getActions, [proposalId]) + getActions(proposalId: GetActionsParams["proposalId"]) { + return this.eth_call(functions.getActions, {proposalId}) } - getReceipt(proposalId: bigint, voter: string): Promise<([hasVoted: boolean, support: number, votes: bigint] & {hasVoted: boolean, support: number, votes: bigint})> { - return this.eth_call(functions.getReceipt, [proposalId, voter]) + getReceipt(proposalId: GetReceiptParams["proposalId"], voter: GetReceiptParams["voter"]) { + return this.eth_call(functions.getReceipt, {proposalId, voter}) } - getVotes(account: string, blockNumber: bigint): Promise { - return this.eth_call(functions.getVotes, [account, blockNumber]) + getVotes(account: GetVotesParams["account"], blockNumber: GetVotesParams["blockNumber"]) { + return this.eth_call(functions.getVotes, {account, blockNumber}) } - getVotesWithParams(account: string, blockNumber: bigint, params: string): Promise { - return this.eth_call(functions.getVotesWithParams, [account, blockNumber, params]) + getVotesWithParams(account: GetVotesWithParamsParams["account"], blockNumber: GetVotesWithParamsParams["blockNumber"], params: GetVotesWithParamsParams["params"]) { + return this.eth_call(functions.getVotesWithParams, {account, blockNumber, params}) } - hasVoted(proposalId: bigint, account: string): Promise { - return this.eth_call(functions.hasVoted, [proposalId, account]) + hasVoted(proposalId: HasVotedParams["proposalId"], account: HasVotedParams["account"]) { + return this.eth_call(functions.hasVoted, {proposalId, account}) } - hashProposal(targets: Array, values: Array, calldatas: Array, descriptionHash: string): Promise { - return this.eth_call(functions.hashProposal, [targets, values, calldatas, descriptionHash]) + hashProposal(targets: HashProposalParams["targets"], values: HashProposalParams["values"], calldatas: HashProposalParams["calldatas"], descriptionHash: HashProposalParams["descriptionHash"]) { + return this.eth_call(functions.hashProposal, {targets, values, calldatas, descriptionHash}) } - lateQuorumVoteExtension(): Promise { - return this.eth_call(functions.lateQuorumVoteExtension, []) + lateQuorumVoteExtension() { + return this.eth_call(functions.lateQuorumVoteExtension, {}) } - name(): Promise { - return this.eth_call(functions.name, []) + name() { + return this.eth_call(functions.name, {}) } - proposalDeadline(proposalId: bigint): Promise { - return this.eth_call(functions.proposalDeadline, [proposalId]) + proposalDeadline(proposalId: ProposalDeadlineParams["proposalId"]) { + return this.eth_call(functions.proposalDeadline, {proposalId}) } - proposalEta(proposalId: bigint): Promise { - return this.eth_call(functions.proposalEta, [proposalId]) + proposalEta(proposalId: ProposalEtaParams["proposalId"]) { + return this.eth_call(functions.proposalEta, {proposalId}) } - proposalSnapshot(proposalId: bigint): Promise { - return this.eth_call(functions.proposalSnapshot, [proposalId]) + proposalSnapshot(proposalId: ProposalSnapshotParams["proposalId"]) { + return this.eth_call(functions.proposalSnapshot, {proposalId}) } - proposalThreshold(): Promise { - return this.eth_call(functions.proposalThreshold, []) + proposalThreshold() { + return this.eth_call(functions.proposalThreshold, {}) } - proposals(proposalId: bigint): Promise<([id: bigint, proposer: string, eta: bigint, startBlock: bigint, endBlock: bigint, forVotes: bigint, againstVotes: bigint, abstainVotes: bigint, canceled: boolean, executed: boolean] & {id: bigint, proposer: string, eta: bigint, startBlock: bigint, endBlock: bigint, forVotes: bigint, againstVotes: bigint, abstainVotes: bigint, canceled: boolean, executed: boolean})> { - return this.eth_call(functions.proposals, [proposalId]) + proposals(proposalId: ProposalsParams["proposalId"]) { + return this.eth_call(functions.proposals, {proposalId}) } - quorum(blockNumber: bigint): Promise { - return this.eth_call(functions.quorum, [blockNumber]) + quorum(blockNumber: QuorumParams["blockNumber"]) { + return this.eth_call(functions.quorum, {blockNumber}) } - quorumDenominator(): Promise { - return this.eth_call(functions.quorumDenominator, []) + quorumDenominator() { + return this.eth_call(functions.quorumDenominator, {}) } - quorumNumerator(): Promise { - return this.eth_call(functions.quorumNumerator, []) + quorumNumerator() { + return this.eth_call(functions.quorumNumerator, {}) } - quorumVotes(): Promise { - return this.eth_call(functions.quorumVotes, []) + quorumVotes() { + return this.eth_call(functions.quorumVotes, {}) } - state(proposalId: bigint): Promise { - return this.eth_call(functions.state, [proposalId]) + state(proposalId: StateParams["proposalId"]) { + return this.eth_call(functions.state, {proposalId}) } - supportsInterface(interfaceId: string): Promise { - return this.eth_call(functions.supportsInterface, [interfaceId]) + supportsInterface(interfaceId: SupportsInterfaceParams["interfaceId"]) { + return this.eth_call(functions.supportsInterface, {interfaceId}) } - timelock(): Promise { - return this.eth_call(functions.timelock, []) + timelock() { + return this.eth_call(functions.timelock, {}) } - token(): Promise { - return this.eth_call(functions.token, []) + token() { + return this.eth_call(functions.token, {}) } - version(): Promise { - return this.eth_call(functions.version, []) + version() { + return this.eth_call(functions.version, {}) } - votingDelay(): Promise { - return this.eth_call(functions.votingDelay, []) + votingDelay() { + return this.eth_call(functions.votingDelay, {}) } - votingPeriod(): Promise { - return this.eth_call(functions.votingPeriod, []) + votingPeriod() { + return this.eth_call(functions.votingPeriod, {}) } } + +/// Event types +export type LateQuorumVoteExtensionSetEventArgs = EParams +export type ProposalCanceledEventArgs = EParams +export type ProposalCreatedEventArgs = EParams +export type ProposalExecutedEventArgs = EParams +export type ProposalExtendedEventArgs = EParams +export type ProposalQueuedEventArgs = EParams +export type ProposalThresholdSetEventArgs = EParams +export type QuorumNumeratorUpdatedEventArgs = EParams +export type TimelockChangeEventArgs = EParams +export type VoteCastEventArgs = EParams +export type VoteCastWithParamsEventArgs = EParams +export type VotingDelaySetEventArgs = EParams +export type VotingPeriodSetEventArgs = EParams + +/// Function types +export type BALLOT_TYPEHASHParams = FunctionArguments +export type BALLOT_TYPEHASHReturn = FunctionReturn + +export type COUNTING_MODEParams = FunctionArguments +export type COUNTING_MODEReturn = FunctionReturn + +export type EXTENDED_BALLOT_TYPEHASHParams = FunctionArguments +export type EXTENDED_BALLOT_TYPEHASHReturn = FunctionReturn + +export type CancelParams = FunctionArguments +export type CancelReturn = FunctionReturn + +export type CastVoteParams = FunctionArguments +export type CastVoteReturn = FunctionReturn + +export type CastVoteBySigParams = FunctionArguments +export type CastVoteBySigReturn = FunctionReturn + +export type CastVoteWithReasonParams = FunctionArguments +export type CastVoteWithReasonReturn = FunctionReturn + +export type CastVoteWithReasonAndParamsParams = FunctionArguments +export type CastVoteWithReasonAndParamsReturn = FunctionReturn + +export type CastVoteWithReasonAndParamsBySigParams = FunctionArguments +export type CastVoteWithReasonAndParamsBySigReturn = FunctionReturn + +export type ExecuteParams_0 = FunctionArguments +export type ExecuteReturn_0 = FunctionReturn + +export type ExecuteParams_1 = FunctionArguments +export type ExecuteReturn_1 = FunctionReturn + +export type GetActionsParams = FunctionArguments +export type GetActionsReturn = FunctionReturn + +export type GetReceiptParams = FunctionArguments +export type GetReceiptReturn = FunctionReturn + +export type GetVotesParams = FunctionArguments +export type GetVotesReturn = FunctionReturn + +export type GetVotesWithParamsParams = FunctionArguments +export type GetVotesWithParamsReturn = FunctionReturn + +export type HasVotedParams = FunctionArguments +export type HasVotedReturn = FunctionReturn + +export type HashProposalParams = FunctionArguments +export type HashProposalReturn = FunctionReturn + +export type LateQuorumVoteExtensionParams = FunctionArguments +export type LateQuorumVoteExtensionReturn = FunctionReturn + +export type NameParams = FunctionArguments +export type NameReturn = FunctionReturn + +export type OnERC1155BatchReceivedParams = FunctionArguments +export type OnERC1155BatchReceivedReturn = FunctionReturn + +export type OnERC1155ReceivedParams = FunctionArguments +export type OnERC1155ReceivedReturn = FunctionReturn + +export type OnERC721ReceivedParams = FunctionArguments +export type OnERC721ReceivedReturn = FunctionReturn + +export type ProposalDeadlineParams = FunctionArguments +export type ProposalDeadlineReturn = FunctionReturn + +export type ProposalEtaParams = FunctionArguments +export type ProposalEtaReturn = FunctionReturn + +export type ProposalSnapshotParams = FunctionArguments +export type ProposalSnapshotReturn = FunctionReturn + +export type ProposalThresholdParams = FunctionArguments +export type ProposalThresholdReturn = FunctionReturn + +export type ProposalsParams = FunctionArguments +export type ProposalsReturn = FunctionReturn + +export type ProposeParams_0 = FunctionArguments +export type ProposeReturn_0 = FunctionReturn + +export type ProposeParams_1 = FunctionArguments +export type ProposeReturn_1 = FunctionReturn + +export type QueueParams_0 = FunctionArguments +export type QueueReturn_0 = FunctionReturn + +export type QueueParams_1 = FunctionArguments +export type QueueReturn_1 = FunctionReturn + +export type QuorumParams = FunctionArguments +export type QuorumReturn = FunctionReturn + +export type QuorumDenominatorParams = FunctionArguments +export type QuorumDenominatorReturn = FunctionReturn + +export type QuorumNumeratorParams = FunctionArguments +export type QuorumNumeratorReturn = FunctionReturn + +export type QuorumVotesParams = FunctionArguments +export type QuorumVotesReturn = FunctionReturn + +export type RelayParams = FunctionArguments +export type RelayReturn = FunctionReturn + +export type SetLateQuorumVoteExtensionParams = FunctionArguments +export type SetLateQuorumVoteExtensionReturn = FunctionReturn + +export type SetProposalThresholdParams = FunctionArguments +export type SetProposalThresholdReturn = FunctionReturn + +export type SetVotingDelayParams = FunctionArguments +export type SetVotingDelayReturn = FunctionReturn + +export type SetVotingPeriodParams = FunctionArguments +export type SetVotingPeriodReturn = FunctionReturn + +export type StateParams = FunctionArguments +export type StateReturn = FunctionReturn + +export type SupportsInterfaceParams = FunctionArguments +export type SupportsInterfaceReturn = FunctionReturn + +export type TimelockParams = FunctionArguments +export type TimelockReturn = FunctionReturn + +export type TokenParams = FunctionArguments +export type TokenReturn = FunctionReturn + +export type UpdateQuorumNumeratorParams = FunctionArguments +export type UpdateQuorumNumeratorReturn = FunctionReturn + +export type UpdateTimelockParams = FunctionArguments +export type UpdateTimelockReturn = FunctionReturn + +export type VersionParams = FunctionArguments +export type VersionReturn = FunctionReturn + +export type VotingDelayParams = FunctionArguments +export type VotingDelayReturn = FunctionReturn + +export type VotingPeriodParams = FunctionArguments +export type VotingPeriodReturn = FunctionReturn + diff --git a/src/abi/initializable-abstract-strategy.ts b/src/abi/initializable-abstract-strategy.ts index 12cfdcf0..ab6cb44a 100644 --- a/src/abi/initializable-abstract-strategy.ts +++ b/src/abi/initializable-abstract-strategy.ts @@ -1,153 +1,170 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './initializable-abstract-strategy.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - Deposit: new LogEvent<([_asset: string, _pToken: string, _amount: bigint] & {_asset: string, _pToken: string, _amount: bigint})>( - abi, '0x5548c837ab068cf56a2c2479df0882a4922fd203edb7517321831d95078c5f62' - ), - GovernorshipTransferred: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( - abi, '0xc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a' - ), - HarvesterAddressesUpdated: new LogEvent<([_oldHarvesterAddress: string, _newHarvesterAddress: string] & {_oldHarvesterAddress: string, _newHarvesterAddress: string})>( - abi, '0xe48386b84419f4d36e0f96c10cc3510b6fb1a33795620c5098b22472bbe90796' - ), - PTokenAdded: new LogEvent<([_asset: string, _pToken: string] & {_asset: string, _pToken: string})>( - abi, '0xef6485b84315f9b1483beffa32aae9a0596890395e3d7521f1c5fbb51790e765' - ), - PTokenRemoved: new LogEvent<([_asset: string, _pToken: string] & {_asset: string, _pToken: string})>( - abi, '0x16b7600acff27e39a8a96056b3d533045298de927507f5c1d97e4accde60488c' - ), - PendingGovernorshipTransfer: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( - abi, '0xa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d' - ), - RewardTokenAddressesUpdated: new LogEvent<([_oldAddresses: Array, _newAddresses: Array] & {_oldAddresses: Array, _newAddresses: Array})>( - abi, '0x04c0b9649497d316554306e53678d5f5f5dbc3a06f97dec13ff4cfe98b986bbc' - ), - RewardTokenCollected: new LogEvent<([recipient: string, rewardToken: string, amount: bigint] & {recipient: string, rewardToken: string, amount: bigint})>( - abi, '0xf6c07a063ed4e63808eb8da7112d46dbcd38de2b40a73dbcc9353c5a94c72353' - ), - Withdrawal: new LogEvent<([_asset: string, _pToken: string, _amount: bigint] & {_asset: string, _pToken: string, _amount: bigint})>( - abi, '0x2717ead6b9200dd235aad468c9809ea400fe33ac69b5bfaa6d3e90fc922b6398' - ), + Deposit: event("0x5548c837ab068cf56a2c2479df0882a4922fd203edb7517321831d95078c5f62", {"_asset": indexed(p.address), "_pToken": p.address, "_amount": p.uint256}), + GovernorshipTransferred: event("0xc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a", {"previousGovernor": indexed(p.address), "newGovernor": indexed(p.address)}), + HarvesterAddressesUpdated: event("0xe48386b84419f4d36e0f96c10cc3510b6fb1a33795620c5098b22472bbe90796", {"_oldHarvesterAddress": p.address, "_newHarvesterAddress": p.address}), + PTokenAdded: event("0xef6485b84315f9b1483beffa32aae9a0596890395e3d7521f1c5fbb51790e765", {"_asset": indexed(p.address), "_pToken": p.address}), + PTokenRemoved: event("0x16b7600acff27e39a8a96056b3d533045298de927507f5c1d97e4accde60488c", {"_asset": indexed(p.address), "_pToken": p.address}), + PendingGovernorshipTransfer: event("0xa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d", {"previousGovernor": indexed(p.address), "newGovernor": indexed(p.address)}), + RewardTokenAddressesUpdated: event("0x04c0b9649497d316554306e53678d5f5f5dbc3a06f97dec13ff4cfe98b986bbc", {"_oldAddresses": p.array(p.address), "_newAddresses": p.array(p.address)}), + RewardTokenCollected: event("0xf6c07a063ed4e63808eb8da7112d46dbcd38de2b40a73dbcc9353c5a94c72353", {"recipient": p.address, "rewardToken": p.address, "amount": p.uint256}), + Withdrawal: event("0x2717ead6b9200dd235aad468c9809ea400fe33ac69b5bfaa6d3e90fc922b6398", {"_asset": indexed(p.address), "_pToken": p.address, "_amount": p.uint256}), } export const functions = { - assetToPToken: new Func<[_: string], {}, string>( - abi, '0x0fc3b4c4' - ), - checkBalance: new Func<[_asset: string], {_asset: string}, bigint>( - abi, '0x5f515226' - ), - claimGovernance: new Func<[], {}, []>( - abi, '0x5d36b190' - ), - collectRewardTokens: new Func<[], {}, []>( - abi, '0x5a063f63' - ), - deposit: new Func<[_asset: string, _amount: bigint], {_asset: string, _amount: bigint}, []>( - abi, '0x47e7ef24' - ), - depositAll: new Func<[], {}, []>( - abi, '0xde5f6268' - ), - getRewardTokenAddresses: new Func<[], {}, Array>( - abi, '0xf6ca71b0' - ), - governor: new Func<[], {}, string>( - abi, '0x0c340a24' - ), - harvesterAddress: new Func<[], {}, string>( - abi, '0x67c7066c' - ), - initialize: new Func<[_rewardTokenAddresses: Array, _assets: Array, _pTokens: Array], {_rewardTokenAddresses: Array, _assets: Array, _pTokens: Array}, []>( - abi, '0x435356d1' - ), - isGovernor: new Func<[], {}, boolean>( - abi, '0xc7af3352' - ), - platformAddress: new Func<[], {}, string>( - abi, '0xdbe55e56' - ), - removePToken: new Func<[_assetIndex: bigint], {_assetIndex: bigint}, []>( - abi, '0x9136616a' - ), - rewardTokenAddresses: new Func<[_: bigint], {}, string>( - abi, '0x7b2d9b2c' - ), - safeApproveAllTokens: new Func<[], {}, []>( - abi, '0xad1728cb' - ), - setHarvesterAddress: new Func<[_harvesterAddress: string], {_harvesterAddress: string}, []>( - abi, '0xc2e1e3f4' - ), - setPTokenAddress: new Func<[_asset: string, _pToken: string], {_asset: string, _pToken: string}, []>( - abi, '0x0ed57b3a' - ), - setRewardTokenAddresses: new Func<[_rewardTokenAddresses: Array], {_rewardTokenAddresses: Array}, []>( - abi, '0x96d538bb' - ), - supportsAsset: new Func<[_asset: string], {_asset: string}, boolean>( - abi, '0xaa388af6' - ), - transferGovernance: new Func<[_newGovernor: string], {_newGovernor: string}, []>( - abi, '0xd38bfff4' - ), - transferToken: new Func<[_asset: string, _amount: bigint], {_asset: string, _amount: bigint}, []>( - abi, '0x1072cbea' - ), - vaultAddress: new Func<[], {}, string>( - abi, '0x430bf08a' - ), - withdraw: new Func<[_recipient: string, _asset: string, _amount: bigint], {_recipient: string, _asset: string, _amount: bigint}, []>( - abi, '0xd9caed12' - ), - withdrawAll: new Func<[], {}, []>( - abi, '0x853828b6' - ), + assetToPToken: fun("0x0fc3b4c4", {"_0": p.address}, p.address), + checkBalance: fun("0x5f515226", {"_asset": p.address}, p.uint256), + claimGovernance: fun("0x5d36b190", {}, ), + collectRewardTokens: fun("0x5a063f63", {}, ), + deposit: fun("0x47e7ef24", {"_asset": p.address, "_amount": p.uint256}, ), + depositAll: fun("0xde5f6268", {}, ), + getRewardTokenAddresses: fun("0xf6ca71b0", {}, p.array(p.address)), + governor: fun("0x0c340a24", {}, p.address), + harvesterAddress: fun("0x67c7066c", {}, p.address), + initialize: fun("0x435356d1", {"_rewardTokenAddresses": p.array(p.address), "_assets": p.array(p.address), "_pTokens": p.array(p.address)}, ), + isGovernor: fun("0xc7af3352", {}, p.bool), + platformAddress: fun("0xdbe55e56", {}, p.address), + removePToken: fun("0x9136616a", {"_assetIndex": p.uint256}, ), + rewardTokenAddresses: fun("0x7b2d9b2c", {"_0": p.uint256}, p.address), + safeApproveAllTokens: fun("0xad1728cb", {}, ), + setHarvesterAddress: fun("0xc2e1e3f4", {"_harvesterAddress": p.address}, ), + setPTokenAddress: fun("0x0ed57b3a", {"_asset": p.address, "_pToken": p.address}, ), + setRewardTokenAddresses: fun("0x96d538bb", {"_rewardTokenAddresses": p.array(p.address)}, ), + supportsAsset: fun("0xaa388af6", {"_asset": p.address}, p.bool), + transferGovernance: fun("0xd38bfff4", {"_newGovernor": p.address}, ), + transferToken: fun("0x1072cbea", {"_asset": p.address, "_amount": p.uint256}, ), + vaultAddress: fun("0x430bf08a", {}, p.address), + withdraw: fun("0xd9caed12", {"_recipient": p.address, "_asset": p.address, "_amount": p.uint256}, ), + withdrawAll: fun("0x853828b6", {}, ), } export class Contract extends ContractBase { - assetToPToken(arg0: string): Promise { - return this.eth_call(functions.assetToPToken, [arg0]) + assetToPToken(_0: AssetToPTokenParams["_0"]) { + return this.eth_call(functions.assetToPToken, {_0}) } - checkBalance(_asset: string): Promise { - return this.eth_call(functions.checkBalance, [_asset]) + checkBalance(_asset: CheckBalanceParams["_asset"]) { + return this.eth_call(functions.checkBalance, {_asset}) } - getRewardTokenAddresses(): Promise> { - return this.eth_call(functions.getRewardTokenAddresses, []) + getRewardTokenAddresses() { + return this.eth_call(functions.getRewardTokenAddresses, {}) } - governor(): Promise { - return this.eth_call(functions.governor, []) + governor() { + return this.eth_call(functions.governor, {}) } - harvesterAddress(): Promise { - return this.eth_call(functions.harvesterAddress, []) + harvesterAddress() { + return this.eth_call(functions.harvesterAddress, {}) } - isGovernor(): Promise { - return this.eth_call(functions.isGovernor, []) + isGovernor() { + return this.eth_call(functions.isGovernor, {}) } - platformAddress(): Promise { - return this.eth_call(functions.platformAddress, []) + platformAddress() { + return this.eth_call(functions.platformAddress, {}) } - rewardTokenAddresses(arg0: bigint): Promise { - return this.eth_call(functions.rewardTokenAddresses, [arg0]) + rewardTokenAddresses(_0: RewardTokenAddressesParams["_0"]) { + return this.eth_call(functions.rewardTokenAddresses, {_0}) } - supportsAsset(_asset: string): Promise { - return this.eth_call(functions.supportsAsset, [_asset]) + supportsAsset(_asset: SupportsAssetParams["_asset"]) { + return this.eth_call(functions.supportsAsset, {_asset}) } - vaultAddress(): Promise { - return this.eth_call(functions.vaultAddress, []) + vaultAddress() { + return this.eth_call(functions.vaultAddress, {}) } } + +/// Event types +export type DepositEventArgs = EParams +export type GovernorshipTransferredEventArgs = EParams +export type HarvesterAddressesUpdatedEventArgs = EParams +export type PTokenAddedEventArgs = EParams +export type PTokenRemovedEventArgs = EParams +export type PendingGovernorshipTransferEventArgs = EParams +export type RewardTokenAddressesUpdatedEventArgs = EParams +export type RewardTokenCollectedEventArgs = EParams +export type WithdrawalEventArgs = EParams + +/// Function types +export type AssetToPTokenParams = FunctionArguments +export type AssetToPTokenReturn = FunctionReturn + +export type CheckBalanceParams = FunctionArguments +export type CheckBalanceReturn = FunctionReturn + +export type ClaimGovernanceParams = FunctionArguments +export type ClaimGovernanceReturn = FunctionReturn + +export type CollectRewardTokensParams = FunctionArguments +export type CollectRewardTokensReturn = FunctionReturn + +export type DepositParams = FunctionArguments +export type DepositReturn = FunctionReturn + +export type DepositAllParams = FunctionArguments +export type DepositAllReturn = FunctionReturn + +export type GetRewardTokenAddressesParams = FunctionArguments +export type GetRewardTokenAddressesReturn = FunctionReturn + +export type GovernorParams = FunctionArguments +export type GovernorReturn = FunctionReturn + +export type HarvesterAddressParams = FunctionArguments +export type HarvesterAddressReturn = FunctionReturn + +export type InitializeParams = FunctionArguments +export type InitializeReturn = FunctionReturn + +export type IsGovernorParams = FunctionArguments +export type IsGovernorReturn = FunctionReturn + +export type PlatformAddressParams = FunctionArguments +export type PlatformAddressReturn = FunctionReturn + +export type RemovePTokenParams = FunctionArguments +export type RemovePTokenReturn = FunctionReturn + +export type RewardTokenAddressesParams = FunctionArguments +export type RewardTokenAddressesReturn = FunctionReturn + +export type SafeApproveAllTokensParams = FunctionArguments +export type SafeApproveAllTokensReturn = FunctionReturn + +export type SetHarvesterAddressParams = FunctionArguments +export type SetHarvesterAddressReturn = FunctionReturn + +export type SetPTokenAddressParams = FunctionArguments +export type SetPTokenAddressReturn = FunctionReturn + +export type SetRewardTokenAddressesParams = FunctionArguments +export type SetRewardTokenAddressesReturn = FunctionReturn + +export type SupportsAssetParams = FunctionArguments +export type SupportsAssetReturn = FunctionReturn + +export type TransferGovernanceParams = FunctionArguments +export type TransferGovernanceReturn = FunctionReturn + +export type TransferTokenParams = FunctionArguments +export type TransferTokenReturn = FunctionReturn + +export type VaultAddressParams = FunctionArguments +export type VaultAddressReturn = FunctionReturn + +export type WithdrawParams = FunctionArguments +export type WithdrawReturn = FunctionReturn + +export type WithdrawAllParams = FunctionArguments +export type WithdrawAllReturn = FunctionReturn + diff --git a/src/abi/lido.ts b/src/abi/lido.ts index c02a9d3e..1828eb16 100644 --- a/src/abi/lido.ts +++ b/src/abi/lido.ts @@ -1,474 +1,522 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './lido.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - StakingPaused: new LogEvent<[]>( - abi, '0x26d1807b479eaba249c1214b82e4b65bbb0cc73ee8a17901324b1ef1b5904e49' - ), - StakingResumed: new LogEvent<[]>( - abi, '0xedaeeae9aed70c4545d3ab0065713261c9cee8d6cf5c8b07f52f0a65fd91efda' - ), - StakingLimitSet: new LogEvent<([maxStakeLimit: bigint, stakeLimitIncreasePerBlock: bigint] & {maxStakeLimit: bigint, stakeLimitIncreasePerBlock: bigint})>( - abi, '0xce9fddf6179affa1ea7bf36d80a6bf0284e0f3b91f4b2fa6eea2af923e7fac2d' - ), - StakingLimitRemoved: new LogEvent<[]>( - abi, '0x9b2a687c198898fcc32a33bbc610d478f177a73ab7352023e6cc1de5bf12a3df' - ), - CLValidatorsUpdated: new LogEvent<([reportTimestamp: bigint, preCLValidators: bigint, postCLValidators: bigint] & {reportTimestamp: bigint, preCLValidators: bigint, postCLValidators: bigint})>( - abi, '0x1252331d4f3ee8a9f0a3484c4c2fb059c70a047b5dc5482a3ee6415f742d9f2e' - ), - DepositedValidatorsChanged: new LogEvent<([depositedValidators: bigint] & {depositedValidators: bigint})>( - abi, '0xe0aacfc334457703148118055ec794ac17654c6f918d29638ba3b18003cee5ff' - ), - ETHDistributed: new LogEvent<([reportTimestamp: bigint, preCLBalance: bigint, postCLBalance: bigint, withdrawalsWithdrawn: bigint, executionLayerRewardsWithdrawn: bigint, postBufferedEther: bigint] & {reportTimestamp: bigint, preCLBalance: bigint, postCLBalance: bigint, withdrawalsWithdrawn: bigint, executionLayerRewardsWithdrawn: bigint, postBufferedEther: bigint})>( - abi, '0x92dd3cb149a1eebd51fd8c2a3653fd96f30c4ac01d4f850fc16d46abd6c3e92f' - ), - TokenRebased: new LogEvent<([reportTimestamp: bigint, timeElapsed: bigint, preTotalShares: bigint, preTotalEther: bigint, postTotalShares: bigint, postTotalEther: bigint, sharesMintedAsFees: bigint] & {reportTimestamp: bigint, timeElapsed: bigint, preTotalShares: bigint, preTotalEther: bigint, postTotalShares: bigint, postTotalEther: bigint, sharesMintedAsFees: bigint})>( - abi, '0xff08c3ef606d198e316ef5b822193c489965899eb4e3c248cea1a4626c3eda50' - ), - LidoLocatorSet: new LogEvent<([lidoLocator: string] & {lidoLocator: string})>( - abi, '0x61f9416d3c29deb4e424342445a2b132738430becd9fa275e11297c90668b22e' - ), - ELRewardsReceived: new LogEvent<([amount: bigint] & {amount: bigint})>( - abi, '0xd27f9b0c98bdee27044afa149eadcd2047d6399cb6613a45c5b87e6aca76e6b5' - ), - WithdrawalsReceived: new LogEvent<([amount: bigint] & {amount: bigint})>( - abi, '0x6e5086f7e1ab04bd826e77faae35b1bcfe31bd144623361a40ea4af51670b1c3' - ), - Submitted: new LogEvent<([sender: string, amount: bigint, referral: string] & {sender: string, amount: bigint, referral: string})>( - abi, '0x96a25c8ce0baabc1fdefd93e9ed25d8e092a3332f3aa9a41722b5697231d1d1a' - ), - Unbuffered: new LogEvent<([amount: bigint] & {amount: bigint})>( - abi, '0x76a397bea5768d4fca97ef47792796e35f98dc81b16c1de84e28a818e1f97108' - ), - ScriptResult: new LogEvent<([executor: string, script: string, input: string, returnData: string] & {executor: string, script: string, input: string, returnData: string})>( - abi, '0x5229a5dba83a54ae8cb5b51bdd6de9474cacbe9dd332f5185f3a4f4f2e3f4ad9' - ), - RecoverToVault: new LogEvent<([vault: string, token: string, amount: bigint] & {vault: string, token: string, amount: bigint})>( - abi, '0x596caf56044b55fb8c4ca640089bbc2b63cae3e978b851f5745cbb7c5b288e02' - ), - EIP712StETHInitialized: new LogEvent<([eip712StETH: string] & {eip712StETH: string})>( - abi, '0xb80a5409082a3729c9fc139f8b41192c40e85252752df2c07caebd613086ca83' - ), - TransferShares: new LogEvent<([from: string, to: string, sharesValue: bigint] & {from: string, to: string, sharesValue: bigint})>( - abi, '0x9d9c909296d9c674451c0c24f02cb64981eb3b727f99865939192f880a755dcb' - ), - SharesBurnt: new LogEvent<([account: string, preRebaseTokenAmount: bigint, postRebaseTokenAmount: bigint, sharesAmount: bigint] & {account: string, preRebaseTokenAmount: bigint, postRebaseTokenAmount: bigint, sharesAmount: bigint})>( - abi, '0x8b2a1e1ad5e0578c3dd82494156e985dade827a87c573b5c1c7716a32162ad64' - ), - Stopped: new LogEvent<[]>( - abi, '0x7acc84e34091ae817647a4c49116f5cc07f319078ba80f8f5fde37ea7e25cbd6' - ), - Resumed: new LogEvent<[]>( - abi, '0x62451d457bc659158be6e6247f56ec1df424a5c7597f71c20c2bc44e0965c8f9' - ), - Transfer: new LogEvent<([from: string, to: string, value: bigint] & {from: string, to: string, value: bigint})>( - abi, '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' - ), - Approval: new LogEvent<([owner: string, spender: string, value: bigint] & {owner: string, spender: string, value: bigint})>( - abi, '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925' - ), - ContractVersionSet: new LogEvent<([version: bigint] & {version: bigint})>( - abi, '0xfddcded6b4f4730c226821172046b48372d3cd963c159701ae1b7c3bcac541bb' - ), + StakingPaused: event("0x26d1807b479eaba249c1214b82e4b65bbb0cc73ee8a17901324b1ef1b5904e49", {}), + StakingResumed: event("0xedaeeae9aed70c4545d3ab0065713261c9cee8d6cf5c8b07f52f0a65fd91efda", {}), + StakingLimitSet: event("0xce9fddf6179affa1ea7bf36d80a6bf0284e0f3b91f4b2fa6eea2af923e7fac2d", {"maxStakeLimit": p.uint256, "stakeLimitIncreasePerBlock": p.uint256}), + StakingLimitRemoved: event("0x9b2a687c198898fcc32a33bbc610d478f177a73ab7352023e6cc1de5bf12a3df", {}), + CLValidatorsUpdated: event("0x1252331d4f3ee8a9f0a3484c4c2fb059c70a047b5dc5482a3ee6415f742d9f2e", {"reportTimestamp": indexed(p.uint256), "preCLValidators": p.uint256, "postCLValidators": p.uint256}), + DepositedValidatorsChanged: event("0xe0aacfc334457703148118055ec794ac17654c6f918d29638ba3b18003cee5ff", {"depositedValidators": p.uint256}), + ETHDistributed: event("0x92dd3cb149a1eebd51fd8c2a3653fd96f30c4ac01d4f850fc16d46abd6c3e92f", {"reportTimestamp": indexed(p.uint256), "preCLBalance": p.uint256, "postCLBalance": p.uint256, "withdrawalsWithdrawn": p.uint256, "executionLayerRewardsWithdrawn": p.uint256, "postBufferedEther": p.uint256}), + TokenRebased: event("0xff08c3ef606d198e316ef5b822193c489965899eb4e3c248cea1a4626c3eda50", {"reportTimestamp": indexed(p.uint256), "timeElapsed": p.uint256, "preTotalShares": p.uint256, "preTotalEther": p.uint256, "postTotalShares": p.uint256, "postTotalEther": p.uint256, "sharesMintedAsFees": p.uint256}), + LidoLocatorSet: event("0x61f9416d3c29deb4e424342445a2b132738430becd9fa275e11297c90668b22e", {"lidoLocator": p.address}), + ELRewardsReceived: event("0xd27f9b0c98bdee27044afa149eadcd2047d6399cb6613a45c5b87e6aca76e6b5", {"amount": p.uint256}), + WithdrawalsReceived: event("0x6e5086f7e1ab04bd826e77faae35b1bcfe31bd144623361a40ea4af51670b1c3", {"amount": p.uint256}), + Submitted: event("0x96a25c8ce0baabc1fdefd93e9ed25d8e092a3332f3aa9a41722b5697231d1d1a", {"sender": indexed(p.address), "amount": p.uint256, "referral": p.address}), + Unbuffered: event("0x76a397bea5768d4fca97ef47792796e35f98dc81b16c1de84e28a818e1f97108", {"amount": p.uint256}), + ScriptResult: event("0x5229a5dba83a54ae8cb5b51bdd6de9474cacbe9dd332f5185f3a4f4f2e3f4ad9", {"executor": indexed(p.address), "script": p.bytes, "input": p.bytes, "returnData": p.bytes}), + RecoverToVault: event("0x596caf56044b55fb8c4ca640089bbc2b63cae3e978b851f5745cbb7c5b288e02", {"vault": indexed(p.address), "token": indexed(p.address), "amount": p.uint256}), + EIP712StETHInitialized: event("0xb80a5409082a3729c9fc139f8b41192c40e85252752df2c07caebd613086ca83", {"eip712StETH": p.address}), + TransferShares: event("0x9d9c909296d9c674451c0c24f02cb64981eb3b727f99865939192f880a755dcb", {"from": indexed(p.address), "to": indexed(p.address), "sharesValue": p.uint256}), + SharesBurnt: event("0x8b2a1e1ad5e0578c3dd82494156e985dade827a87c573b5c1c7716a32162ad64", {"account": indexed(p.address), "preRebaseTokenAmount": p.uint256, "postRebaseTokenAmount": p.uint256, "sharesAmount": p.uint256}), + Stopped: event("0x7acc84e34091ae817647a4c49116f5cc07f319078ba80f8f5fde37ea7e25cbd6", {}), + Resumed: event("0x62451d457bc659158be6e6247f56ec1df424a5c7597f71c20c2bc44e0965c8f9", {}), + Transfer: event("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", {"from": indexed(p.address), "to": indexed(p.address), "value": p.uint256}), + Approval: event("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", {"owner": indexed(p.address), "spender": indexed(p.address), "value": p.uint256}), + ContractVersionSet: event("0xfddcded6b4f4730c226821172046b48372d3cd963c159701ae1b7c3bcac541bb", {"version": p.uint256}), } export const functions = { - resume: new Func<[], {}, []>( - abi, '0x046f7da2' - ), - name: new Func<[], {}, string>( - abi, '0x06fdde03' - ), - stop: new Func<[], {}, []>( - abi, '0x07da68f5' - ), - hasInitialized: new Func<[], {}, boolean>( - abi, '0x0803fac0' - ), - approve: new Func<[_spender: string, _amount: bigint], {_spender: string, _amount: bigint}, boolean>( - abi, '0x095ea7b3' - ), - STAKING_CONTROL_ROLE: new Func<[], {}, string>( - abi, '0x136dd43c' - ), - totalSupply: new Func<[], {}, bigint>( - abi, '0x18160ddd' - ), - getSharesByPooledEth: new Func<[_ethAmount: bigint], {_ethAmount: bigint}, bigint>( - abi, '0x19208451' - ), - isStakingPaused: new Func<[], {}, boolean>( - abi, '0x1ea7ca89' - ), - transferFrom: new Func<[_sender: string, _recipient: string, _amount: bigint], {_sender: string, _recipient: string, _amount: bigint}, boolean>( - abi, '0x23b872dd' - ), - getEVMScriptExecutor: new Func<[_script: string], {_script: string}, string>( - abi, '0x2914b9bd' - ), - setStakingLimit: new Func<[_maxStakeLimit: bigint, _stakeLimitIncreasePerBlock: bigint], {_maxStakeLimit: bigint, _stakeLimitIncreasePerBlock: bigint}, []>( - abi, '0x2cb5f784' - ), - RESUME_ROLE: new Func<[], {}, string>( - abi, '0x2de03aa1' - ), - finalizeUpgrade_v2: new Func<[_lidoLocator: string, _eip712StETH: string], {_lidoLocator: string, _eip712StETH: string}, []>( - abi, '0x2f85e57c' - ), - decimals: new Func<[], {}, number>( - abi, '0x313ce567' - ), - getRecoveryVault: new Func<[], {}, string>( - abi, '0x32f0a3b5' - ), - DOMAIN_SEPARATOR: new Func<[], {}, string>( - abi, '0x3644e515' - ), - getTotalPooledEther: new Func<[], {}, bigint>( - abi, '0x37cfdaca' - ), - unsafeChangeDepositedValidators: new Func<[_newDepositedValidators: bigint], {_newDepositedValidators: bigint}, []>( - abi, '0x38998624' - ), - PAUSE_ROLE: new Func<[], {}, string>( - abi, '0x389ed267' - ), - increaseAllowance: new Func<[_spender: string, _addedValue: bigint], {_spender: string, _addedValue: bigint}, boolean>( - abi, '0x39509351' - ), - getTreasury: new Func<[], {}, string>( - abi, '0x3b19e84a' - ), - isStopped: new Func<[], {}, boolean>( - abi, '0x3f683b6a' - ), - getBufferedEther: new Func<[], {}, bigint>( - abi, '0x47b714e0' - ), - initialize: new Func<[_lidoLocator: string, _eip712StETH: string], {_lidoLocator: string, _eip712StETH: string}, []>( - abi, '0x485cc955' - ), - receiveELRewards: new Func<[], {}, []>( - abi, '0x4ad509b2' - ), - getWithdrawalCredentials: new Func<[], {}, string>( - abi, '0x56396715' - ), - getCurrentStakeLimit: new Func<[], {}, bigint>( - abi, '0x609c4c6c' - ), - getStakeLimitFullInfo: new Func<[], {}, ([isStakingPaused: boolean, isStakingLimitSet: boolean, currentStakeLimit: bigint, maxStakeLimit: bigint, maxStakeLimitGrowthBlocks: bigint, prevStakeLimit: bigint, prevStakeBlockNumber: bigint] & {isStakingPaused: boolean, isStakingLimitSet: boolean, currentStakeLimit: bigint, maxStakeLimit: bigint, maxStakeLimitGrowthBlocks: bigint, prevStakeLimit: bigint, prevStakeBlockNumber: bigint})>( - abi, '0x665b4b0b' - ), - transferSharesFrom: new Func<[_sender: string, _recipient: string, _sharesAmount: bigint], {_sender: string, _recipient: string, _sharesAmount: bigint}, bigint>( - abi, '0x6d780459' - ), - balanceOf: new Func<[_account: string], {_account: string}, bigint>( - abi, '0x70a08231' - ), - resumeStaking: new Func<[], {}, []>( - abi, '0x7475f913' - ), - getFeeDistribution: new Func<[], {}, ([treasuryFeeBasisPoints: number, insuranceFeeBasisPoints: number, operatorsFeeBasisPoints: number] & {treasuryFeeBasisPoints: number, insuranceFeeBasisPoints: number, operatorsFeeBasisPoints: number})>( - abi, '0x752f77f1' - ), - receiveWithdrawals: new Func<[], {}, []>( - abi, '0x78ffcfe2' - ), - getPooledEthByShares: new Func<[_sharesAmount: bigint], {_sharesAmount: bigint}, bigint>( - abi, '0x7a28fb88' - ), - allowRecoverability: new Func<[token: string], {token: string}, boolean>( - abi, '0x7e7db6e1' - ), - nonces: new Func<[owner: string], {owner: string}, bigint>( - abi, '0x7ecebe00' - ), - appId: new Func<[], {}, string>( - abi, '0x80afdea8' - ), - getOracle: new Func<[], {}, string>( - abi, '0x833b1fce' - ), - eip712Domain: new Func<[], {}, ([name: string, version: string, chainId: bigint, verifyingContract: string] & {name: string, version: string, chainId: bigint, verifyingContract: string})>( - abi, '0x84b0196e' - ), - getContractVersion: new Func<[], {}, bigint>( - abi, '0x8aa10435' - ), - getInitializationBlock: new Func<[], {}, bigint>( - abi, '0x8b3dd749' - ), - transferShares: new Func<[_recipient: string, _sharesAmount: bigint], {_recipient: string, _sharesAmount: bigint}, bigint>( - abi, '0x8fcb4e5b' - ), - symbol: new Func<[], {}, string>( - abi, '0x95d89b41' - ), - getEIP712StETH: new Func<[], {}, string>( - abi, '0x9861f8e5' - ), - transferToVault: new Func<[_: string], {}, []>( - abi, '0x9d4941d8' - ), - canPerform: new Func<[_sender: string, _role: string, _params: Array], {_sender: string, _role: string, _params: Array}, boolean>( - abi, '0xa1658fad' - ), - submit: new Func<[_referral: string], {_referral: string}, bigint>( - abi, '0xa1903eab' - ), - decreaseAllowance: new Func<[_spender: string, _subtractedValue: bigint], {_spender: string, _subtractedValue: bigint}, boolean>( - abi, '0xa457c2d7' - ), - getEVMScriptRegistry: new Func<[], {}, string>( - abi, '0xa479e508' - ), - transfer: new Func<[_recipient: string, _amount: bigint], {_recipient: string, _amount: bigint}, boolean>( - abi, '0xa9059cbb' - ), - deposit: new Func<[_maxDepositsCount: bigint, _stakingModuleId: bigint, _depositCalldata: string], {_maxDepositsCount: bigint, _stakingModuleId: bigint, _depositCalldata: string}, []>( - abi, '0xaa0b7db7' - ), - UNSAFE_CHANGE_DEPOSITED_VALIDATORS_ROLE: new Func<[], {}, string>( - abi, '0xad1394e9' - ), - getBeaconStat: new Func<[], {}, ([depositedValidators: bigint, beaconValidators: bigint, beaconBalance: bigint] & {depositedValidators: bigint, beaconValidators: bigint, beaconBalance: bigint})>( - abi, '0xae2e3538' - ), - removeStakingLimit: new Func<[], {}, []>( - abi, '0xb3320d9a' - ), - handleOracleReport: new Func<[_reportTimestamp: bigint, _timeElapsed: bigint, _clValidators: bigint, _clBalance: bigint, _withdrawalVaultBalance: bigint, _elRewardsVaultBalance: bigint, _sharesRequestedToBurn: bigint, _withdrawalFinalizationBatches: Array, _simulatedShareRate: bigint], {_reportTimestamp: bigint, _timeElapsed: bigint, _clValidators: bigint, _clBalance: bigint, _withdrawalVaultBalance: bigint, _elRewardsVaultBalance: bigint, _sharesRequestedToBurn: bigint, _withdrawalFinalizationBatches: Array, _simulatedShareRate: bigint}, Array>( - abi, '0xbac3f3c5' - ), - getFee: new Func<[], {}, number>( - abi, '0xced72f87' - ), - kernel: new Func<[], {}, string>( - abi, '0xd4aae0c4' - ), - getTotalShares: new Func<[], {}, bigint>( - abi, '0xd5002f2e' - ), - permit: new Func<[_owner: string, _spender: string, _value: bigint, _deadline: bigint, _v: number, _r: string, _s: string], {_owner: string, _spender: string, _value: bigint, _deadline: bigint, _v: number, _r: string, _s: string}, []>( - abi, '0xd505accf' - ), - allowance: new Func<[_owner: string, _spender: string], {_owner: string, _spender: string}, bigint>( - abi, '0xdd62ed3e' - ), - isPetrified: new Func<[], {}, boolean>( - abi, '0xde4796ed' - ), - getLidoLocator: new Func<[], {}, string>( - abi, '0xe654ff17' - ), - canDeposit: new Func<[], {}, boolean>( - abi, '0xe78a5875' - ), - STAKING_PAUSE_ROLE: new Func<[], {}, string>( - abi, '0xeb85262f' - ), - getDepositableEther: new Func<[], {}, bigint>( - abi, '0xf2cfa87d' - ), - sharesOf: new Func<[_account: string], {_account: string}, bigint>( - abi, '0xf5eb42dc' - ), - pauseStaking: new Func<[], {}, []>( - abi, '0xf999c506' - ), - getTotalELRewardsCollected: new Func<[], {}, bigint>( - abi, '0xfa64ebac' - ), + resume: fun("0x046f7da2", {}, ), + name: fun("0x06fdde03", {}, p.string), + stop: fun("0x07da68f5", {}, ), + hasInitialized: fun("0x0803fac0", {}, p.bool), + approve: fun("0x095ea7b3", {"_spender": p.address, "_amount": p.uint256}, p.bool), + STAKING_CONTROL_ROLE: fun("0x136dd43c", {}, p.bytes32), + totalSupply: fun("0x18160ddd", {}, p.uint256), + getSharesByPooledEth: fun("0x19208451", {"_ethAmount": p.uint256}, p.uint256), + isStakingPaused: fun("0x1ea7ca89", {}, p.bool), + transferFrom: fun("0x23b872dd", {"_sender": p.address, "_recipient": p.address, "_amount": p.uint256}, p.bool), + getEVMScriptExecutor: fun("0x2914b9bd", {"_script": p.bytes}, p.address), + setStakingLimit: fun("0x2cb5f784", {"_maxStakeLimit": p.uint256, "_stakeLimitIncreasePerBlock": p.uint256}, ), + RESUME_ROLE: fun("0x2de03aa1", {}, p.bytes32), + finalizeUpgrade_v2: fun("0x2f85e57c", {"_lidoLocator": p.address, "_eip712StETH": p.address}, ), + decimals: fun("0x313ce567", {}, p.uint8), + getRecoveryVault: fun("0x32f0a3b5", {}, p.address), + DOMAIN_SEPARATOR: fun("0x3644e515", {}, p.bytes32), + getTotalPooledEther: fun("0x37cfdaca", {}, p.uint256), + unsafeChangeDepositedValidators: fun("0x38998624", {"_newDepositedValidators": p.uint256}, ), + PAUSE_ROLE: fun("0x389ed267", {}, p.bytes32), + increaseAllowance: fun("0x39509351", {"_spender": p.address, "_addedValue": p.uint256}, p.bool), + getTreasury: fun("0x3b19e84a", {}, p.address), + isStopped: fun("0x3f683b6a", {}, p.bool), + getBufferedEther: fun("0x47b714e0", {}, p.uint256), + initialize: fun("0x485cc955", {"_lidoLocator": p.address, "_eip712StETH": p.address}, ), + receiveELRewards: fun("0x4ad509b2", {}, ), + getWithdrawalCredentials: fun("0x56396715", {}, p.bytes32), + getCurrentStakeLimit: fun("0x609c4c6c", {}, p.uint256), + getStakeLimitFullInfo: fun("0x665b4b0b", {}, {"isStakingPaused": p.bool, "isStakingLimitSet": p.bool, "currentStakeLimit": p.uint256, "maxStakeLimit": p.uint256, "maxStakeLimitGrowthBlocks": p.uint256, "prevStakeLimit": p.uint256, "prevStakeBlockNumber": p.uint256}), + transferSharesFrom: fun("0x6d780459", {"_sender": p.address, "_recipient": p.address, "_sharesAmount": p.uint256}, p.uint256), + balanceOf: fun("0x70a08231", {"_account": p.address}, p.uint256), + resumeStaking: fun("0x7475f913", {}, ), + getFeeDistribution: fun("0x752f77f1", {}, {"treasuryFeeBasisPoints": p.uint16, "insuranceFeeBasisPoints": p.uint16, "operatorsFeeBasisPoints": p.uint16}), + receiveWithdrawals: fun("0x78ffcfe2", {}, ), + getPooledEthByShares: fun("0x7a28fb88", {"_sharesAmount": p.uint256}, p.uint256), + allowRecoverability: fun("0x7e7db6e1", {"token": p.address}, p.bool), + nonces: fun("0x7ecebe00", {"owner": p.address}, p.uint256), + appId: fun("0x80afdea8", {}, p.bytes32), + getOracle: fun("0x833b1fce", {}, p.address), + eip712Domain: fun("0x84b0196e", {}, {"name": p.string, "version": p.string, "chainId": p.uint256, "verifyingContract": p.address}), + getContractVersion: fun("0x8aa10435", {}, p.uint256), + getInitializationBlock: fun("0x8b3dd749", {}, p.uint256), + transferShares: fun("0x8fcb4e5b", {"_recipient": p.address, "_sharesAmount": p.uint256}, p.uint256), + symbol: fun("0x95d89b41", {}, p.string), + getEIP712StETH: fun("0x9861f8e5", {}, p.address), + transferToVault: fun("0x9d4941d8", {"_0": p.address}, ), + canPerform: fun("0xa1658fad", {"_sender": p.address, "_role": p.bytes32, "_params": p.array(p.uint256)}, p.bool), + submit: fun("0xa1903eab", {"_referral": p.address}, p.uint256), + decreaseAllowance: fun("0xa457c2d7", {"_spender": p.address, "_subtractedValue": p.uint256}, p.bool), + getEVMScriptRegistry: fun("0xa479e508", {}, p.address), + transfer: fun("0xa9059cbb", {"_recipient": p.address, "_amount": p.uint256}, p.bool), + deposit: fun("0xaa0b7db7", {"_maxDepositsCount": p.uint256, "_stakingModuleId": p.uint256, "_depositCalldata": p.bytes}, ), + UNSAFE_CHANGE_DEPOSITED_VALIDATORS_ROLE: fun("0xad1394e9", {}, p.bytes32), + getBeaconStat: fun("0xae2e3538", {}, {"depositedValidators": p.uint256, "beaconValidators": p.uint256, "beaconBalance": p.uint256}), + removeStakingLimit: fun("0xb3320d9a", {}, ), + handleOracleReport: fun("0xbac3f3c5", {"_reportTimestamp": p.uint256, "_timeElapsed": p.uint256, "_clValidators": p.uint256, "_clBalance": p.uint256, "_withdrawalVaultBalance": p.uint256, "_elRewardsVaultBalance": p.uint256, "_sharesRequestedToBurn": p.uint256, "_withdrawalFinalizationBatches": p.array(p.uint256), "_simulatedShareRate": p.uint256}, p.fixedSizeArray(p.uint256, 4)), + getFee: fun("0xced72f87", {}, p.uint16), + kernel: fun("0xd4aae0c4", {}, p.address), + getTotalShares: fun("0xd5002f2e", {}, p.uint256), + permit: fun("0xd505accf", {"_owner": p.address, "_spender": p.address, "_value": p.uint256, "_deadline": p.uint256, "_v": p.uint8, "_r": p.bytes32, "_s": p.bytes32}, ), + allowance: fun("0xdd62ed3e", {"_owner": p.address, "_spender": p.address}, p.uint256), + isPetrified: fun("0xde4796ed", {}, p.bool), + getLidoLocator: fun("0xe654ff17", {}, p.address), + canDeposit: fun("0xe78a5875", {}, p.bool), + STAKING_PAUSE_ROLE: fun("0xeb85262f", {}, p.bytes32), + getDepositableEther: fun("0xf2cfa87d", {}, p.uint256), + sharesOf: fun("0xf5eb42dc", {"_account": p.address}, p.uint256), + pauseStaking: fun("0xf999c506", {}, ), + getTotalELRewardsCollected: fun("0xfa64ebac", {}, p.uint256), } export class Contract extends ContractBase { - name(): Promise { - return this.eth_call(functions.name, []) + name() { + return this.eth_call(functions.name, {}) } - hasInitialized(): Promise { - return this.eth_call(functions.hasInitialized, []) + hasInitialized() { + return this.eth_call(functions.hasInitialized, {}) } - STAKING_CONTROL_ROLE(): Promise { - return this.eth_call(functions.STAKING_CONTROL_ROLE, []) + STAKING_CONTROL_ROLE() { + return this.eth_call(functions.STAKING_CONTROL_ROLE, {}) } - totalSupply(): Promise { - return this.eth_call(functions.totalSupply, []) + totalSupply() { + return this.eth_call(functions.totalSupply, {}) } - getSharesByPooledEth(_ethAmount: bigint): Promise { - return this.eth_call(functions.getSharesByPooledEth, [_ethAmount]) + getSharesByPooledEth(_ethAmount: GetSharesByPooledEthParams["_ethAmount"]) { + return this.eth_call(functions.getSharesByPooledEth, {_ethAmount}) } - isStakingPaused(): Promise { - return this.eth_call(functions.isStakingPaused, []) + isStakingPaused() { + return this.eth_call(functions.isStakingPaused, {}) } - getEVMScriptExecutor(_script: string): Promise { - return this.eth_call(functions.getEVMScriptExecutor, [_script]) + getEVMScriptExecutor(_script: GetEVMScriptExecutorParams["_script"]) { + return this.eth_call(functions.getEVMScriptExecutor, {_script}) } - RESUME_ROLE(): Promise { - return this.eth_call(functions.RESUME_ROLE, []) + RESUME_ROLE() { + return this.eth_call(functions.RESUME_ROLE, {}) } - decimals(): Promise { - return this.eth_call(functions.decimals, []) + decimals() { + return this.eth_call(functions.decimals, {}) } - getRecoveryVault(): Promise { - return this.eth_call(functions.getRecoveryVault, []) + getRecoveryVault() { + return this.eth_call(functions.getRecoveryVault, {}) } - DOMAIN_SEPARATOR(): Promise { - return this.eth_call(functions.DOMAIN_SEPARATOR, []) + DOMAIN_SEPARATOR() { + return this.eth_call(functions.DOMAIN_SEPARATOR, {}) } - getTotalPooledEther(): Promise { - return this.eth_call(functions.getTotalPooledEther, []) + getTotalPooledEther() { + return this.eth_call(functions.getTotalPooledEther, {}) } - PAUSE_ROLE(): Promise { - return this.eth_call(functions.PAUSE_ROLE, []) + PAUSE_ROLE() { + return this.eth_call(functions.PAUSE_ROLE, {}) } - getTreasury(): Promise { - return this.eth_call(functions.getTreasury, []) + getTreasury() { + return this.eth_call(functions.getTreasury, {}) } - isStopped(): Promise { - return this.eth_call(functions.isStopped, []) + isStopped() { + return this.eth_call(functions.isStopped, {}) } - getBufferedEther(): Promise { - return this.eth_call(functions.getBufferedEther, []) + getBufferedEther() { + return this.eth_call(functions.getBufferedEther, {}) } - getWithdrawalCredentials(): Promise { - return this.eth_call(functions.getWithdrawalCredentials, []) + getWithdrawalCredentials() { + return this.eth_call(functions.getWithdrawalCredentials, {}) } - getCurrentStakeLimit(): Promise { - return this.eth_call(functions.getCurrentStakeLimit, []) + getCurrentStakeLimit() { + return this.eth_call(functions.getCurrentStakeLimit, {}) } - getStakeLimitFullInfo(): Promise<([isStakingPaused: boolean, isStakingLimitSet: boolean, currentStakeLimit: bigint, maxStakeLimit: bigint, maxStakeLimitGrowthBlocks: bigint, prevStakeLimit: bigint, prevStakeBlockNumber: bigint] & {isStakingPaused: boolean, isStakingLimitSet: boolean, currentStakeLimit: bigint, maxStakeLimit: bigint, maxStakeLimitGrowthBlocks: bigint, prevStakeLimit: bigint, prevStakeBlockNumber: bigint})> { - return this.eth_call(functions.getStakeLimitFullInfo, []) + getStakeLimitFullInfo() { + return this.eth_call(functions.getStakeLimitFullInfo, {}) } - balanceOf(_account: string): Promise { - return this.eth_call(functions.balanceOf, [_account]) + balanceOf(_account: BalanceOfParams["_account"]) { + return this.eth_call(functions.balanceOf, {_account}) } - getFeeDistribution(): Promise<([treasuryFeeBasisPoints: number, insuranceFeeBasisPoints: number, operatorsFeeBasisPoints: number] & {treasuryFeeBasisPoints: number, insuranceFeeBasisPoints: number, operatorsFeeBasisPoints: number})> { - return this.eth_call(functions.getFeeDistribution, []) + getFeeDistribution() { + return this.eth_call(functions.getFeeDistribution, {}) } - getPooledEthByShares(_sharesAmount: bigint): Promise { - return this.eth_call(functions.getPooledEthByShares, [_sharesAmount]) + getPooledEthByShares(_sharesAmount: GetPooledEthBySharesParams["_sharesAmount"]) { + return this.eth_call(functions.getPooledEthByShares, {_sharesAmount}) } - allowRecoverability(token: string): Promise { - return this.eth_call(functions.allowRecoverability, [token]) + allowRecoverability(token: AllowRecoverabilityParams["token"]) { + return this.eth_call(functions.allowRecoverability, {token}) } - nonces(owner: string): Promise { - return this.eth_call(functions.nonces, [owner]) + nonces(owner: NoncesParams["owner"]) { + return this.eth_call(functions.nonces, {owner}) } - appId(): Promise { - return this.eth_call(functions.appId, []) + appId() { + return this.eth_call(functions.appId, {}) } - getOracle(): Promise { - return this.eth_call(functions.getOracle, []) + getOracle() { + return this.eth_call(functions.getOracle, {}) } - eip712Domain(): Promise<([name: string, version: string, chainId: bigint, verifyingContract: string] & {name: string, version: string, chainId: bigint, verifyingContract: string})> { - return this.eth_call(functions.eip712Domain, []) + eip712Domain() { + return this.eth_call(functions.eip712Domain, {}) } - getContractVersion(): Promise { - return this.eth_call(functions.getContractVersion, []) + getContractVersion() { + return this.eth_call(functions.getContractVersion, {}) } - getInitializationBlock(): Promise { - return this.eth_call(functions.getInitializationBlock, []) + getInitializationBlock() { + return this.eth_call(functions.getInitializationBlock, {}) } - symbol(): Promise { - return this.eth_call(functions.symbol, []) + symbol() { + return this.eth_call(functions.symbol, {}) } - getEIP712StETH(): Promise { - return this.eth_call(functions.getEIP712StETH, []) + getEIP712StETH() { + return this.eth_call(functions.getEIP712StETH, {}) } - canPerform(_sender: string, _role: string, _params: Array): Promise { - return this.eth_call(functions.canPerform, [_sender, _role, _params]) + canPerform(_sender: CanPerformParams["_sender"], _role: CanPerformParams["_role"], _params: CanPerformParams["_params"]) { + return this.eth_call(functions.canPerform, {_sender, _role, _params}) } - getEVMScriptRegistry(): Promise { - return this.eth_call(functions.getEVMScriptRegistry, []) + getEVMScriptRegistry() { + return this.eth_call(functions.getEVMScriptRegistry, {}) } - UNSAFE_CHANGE_DEPOSITED_VALIDATORS_ROLE(): Promise { - return this.eth_call(functions.UNSAFE_CHANGE_DEPOSITED_VALIDATORS_ROLE, []) + UNSAFE_CHANGE_DEPOSITED_VALIDATORS_ROLE() { + return this.eth_call(functions.UNSAFE_CHANGE_DEPOSITED_VALIDATORS_ROLE, {}) } - getBeaconStat(): Promise<([depositedValidators: bigint, beaconValidators: bigint, beaconBalance: bigint] & {depositedValidators: bigint, beaconValidators: bigint, beaconBalance: bigint})> { - return this.eth_call(functions.getBeaconStat, []) + getBeaconStat() { + return this.eth_call(functions.getBeaconStat, {}) } - getFee(): Promise { - return this.eth_call(functions.getFee, []) + getFee() { + return this.eth_call(functions.getFee, {}) } - kernel(): Promise { - return this.eth_call(functions.kernel, []) + kernel() { + return this.eth_call(functions.kernel, {}) } - getTotalShares(): Promise { - return this.eth_call(functions.getTotalShares, []) + getTotalShares() { + return this.eth_call(functions.getTotalShares, {}) } - allowance(_owner: string, _spender: string): Promise { - return this.eth_call(functions.allowance, [_owner, _spender]) + allowance(_owner: AllowanceParams["_owner"], _spender: AllowanceParams["_spender"]) { + return this.eth_call(functions.allowance, {_owner, _spender}) } - isPetrified(): Promise { - return this.eth_call(functions.isPetrified, []) + isPetrified() { + return this.eth_call(functions.isPetrified, {}) } - getLidoLocator(): Promise { - return this.eth_call(functions.getLidoLocator, []) + getLidoLocator() { + return this.eth_call(functions.getLidoLocator, {}) } - canDeposit(): Promise { - return this.eth_call(functions.canDeposit, []) + canDeposit() { + return this.eth_call(functions.canDeposit, {}) } - STAKING_PAUSE_ROLE(): Promise { - return this.eth_call(functions.STAKING_PAUSE_ROLE, []) + STAKING_PAUSE_ROLE() { + return this.eth_call(functions.STAKING_PAUSE_ROLE, {}) } - getDepositableEther(): Promise { - return this.eth_call(functions.getDepositableEther, []) + getDepositableEther() { + return this.eth_call(functions.getDepositableEther, {}) } - sharesOf(_account: string): Promise { - return this.eth_call(functions.sharesOf, [_account]) + sharesOf(_account: SharesOfParams["_account"]) { + return this.eth_call(functions.sharesOf, {_account}) } - getTotalELRewardsCollected(): Promise { - return this.eth_call(functions.getTotalELRewardsCollected, []) + getTotalELRewardsCollected() { + return this.eth_call(functions.getTotalELRewardsCollected, {}) } } + +/// Event types +export type StakingPausedEventArgs = EParams +export type StakingResumedEventArgs = EParams +export type StakingLimitSetEventArgs = EParams +export type StakingLimitRemovedEventArgs = EParams +export type CLValidatorsUpdatedEventArgs = EParams +export type DepositedValidatorsChangedEventArgs = EParams +export type ETHDistributedEventArgs = EParams +export type TokenRebasedEventArgs = EParams +export type LidoLocatorSetEventArgs = EParams +export type ELRewardsReceivedEventArgs = EParams +export type WithdrawalsReceivedEventArgs = EParams +export type SubmittedEventArgs = EParams +export type UnbufferedEventArgs = EParams +export type ScriptResultEventArgs = EParams +export type RecoverToVaultEventArgs = EParams +export type EIP712StETHInitializedEventArgs = EParams +export type TransferSharesEventArgs = EParams +export type SharesBurntEventArgs = EParams +export type StoppedEventArgs = EParams +export type ResumedEventArgs = EParams +export type TransferEventArgs = EParams +export type ApprovalEventArgs = EParams +export type ContractVersionSetEventArgs = EParams + +/// Function types +export type ResumeParams = FunctionArguments +export type ResumeReturn = FunctionReturn + +export type NameParams = FunctionArguments +export type NameReturn = FunctionReturn + +export type StopParams = FunctionArguments +export type StopReturn = FunctionReturn + +export type HasInitializedParams = FunctionArguments +export type HasInitializedReturn = FunctionReturn + +export type ApproveParams = FunctionArguments +export type ApproveReturn = FunctionReturn + +export type STAKING_CONTROL_ROLEParams = FunctionArguments +export type STAKING_CONTROL_ROLEReturn = FunctionReturn + +export type TotalSupplyParams = FunctionArguments +export type TotalSupplyReturn = FunctionReturn + +export type GetSharesByPooledEthParams = FunctionArguments +export type GetSharesByPooledEthReturn = FunctionReturn + +export type IsStakingPausedParams = FunctionArguments +export type IsStakingPausedReturn = FunctionReturn + +export type TransferFromParams = FunctionArguments +export type TransferFromReturn = FunctionReturn + +export type GetEVMScriptExecutorParams = FunctionArguments +export type GetEVMScriptExecutorReturn = FunctionReturn + +export type SetStakingLimitParams = FunctionArguments +export type SetStakingLimitReturn = FunctionReturn + +export type RESUME_ROLEParams = FunctionArguments +export type RESUME_ROLEReturn = FunctionReturn + +export type FinalizeUpgrade_v2Params = FunctionArguments +export type FinalizeUpgrade_v2Return = FunctionReturn + +export type DecimalsParams = FunctionArguments +export type DecimalsReturn = FunctionReturn + +export type GetRecoveryVaultParams = FunctionArguments +export type GetRecoveryVaultReturn = FunctionReturn + +export type DOMAIN_SEPARATORParams = FunctionArguments +export type DOMAIN_SEPARATORReturn = FunctionReturn + +export type GetTotalPooledEtherParams = FunctionArguments +export type GetTotalPooledEtherReturn = FunctionReturn + +export type UnsafeChangeDepositedValidatorsParams = FunctionArguments +export type UnsafeChangeDepositedValidatorsReturn = FunctionReturn + +export type PAUSE_ROLEParams = FunctionArguments +export type PAUSE_ROLEReturn = FunctionReturn + +export type IncreaseAllowanceParams = FunctionArguments +export type IncreaseAllowanceReturn = FunctionReturn + +export type GetTreasuryParams = FunctionArguments +export type GetTreasuryReturn = FunctionReturn + +export type IsStoppedParams = FunctionArguments +export type IsStoppedReturn = FunctionReturn + +export type GetBufferedEtherParams = FunctionArguments +export type GetBufferedEtherReturn = FunctionReturn + +export type InitializeParams = FunctionArguments +export type InitializeReturn = FunctionReturn + +export type ReceiveELRewardsParams = FunctionArguments +export type ReceiveELRewardsReturn = FunctionReturn + +export type GetWithdrawalCredentialsParams = FunctionArguments +export type GetWithdrawalCredentialsReturn = FunctionReturn + +export type GetCurrentStakeLimitParams = FunctionArguments +export type GetCurrentStakeLimitReturn = FunctionReturn + +export type GetStakeLimitFullInfoParams = FunctionArguments +export type GetStakeLimitFullInfoReturn = FunctionReturn + +export type TransferSharesFromParams = FunctionArguments +export type TransferSharesFromReturn = FunctionReturn + +export type BalanceOfParams = FunctionArguments +export type BalanceOfReturn = FunctionReturn + +export type ResumeStakingParams = FunctionArguments +export type ResumeStakingReturn = FunctionReturn + +export type GetFeeDistributionParams = FunctionArguments +export type GetFeeDistributionReturn = FunctionReturn + +export type ReceiveWithdrawalsParams = FunctionArguments +export type ReceiveWithdrawalsReturn = FunctionReturn + +export type GetPooledEthBySharesParams = FunctionArguments +export type GetPooledEthBySharesReturn = FunctionReturn + +export type AllowRecoverabilityParams = FunctionArguments +export type AllowRecoverabilityReturn = FunctionReturn + +export type NoncesParams = FunctionArguments +export type NoncesReturn = FunctionReturn + +export type AppIdParams = FunctionArguments +export type AppIdReturn = FunctionReturn + +export type GetOracleParams = FunctionArguments +export type GetOracleReturn = FunctionReturn + +export type Eip712DomainParams = FunctionArguments +export type Eip712DomainReturn = FunctionReturn + +export type GetContractVersionParams = FunctionArguments +export type GetContractVersionReturn = FunctionReturn + +export type GetInitializationBlockParams = FunctionArguments +export type GetInitializationBlockReturn = FunctionReturn + +export type TransferSharesParams = FunctionArguments +export type TransferSharesReturn = FunctionReturn + +export type SymbolParams = FunctionArguments +export type SymbolReturn = FunctionReturn + +export type GetEIP712StETHParams = FunctionArguments +export type GetEIP712StETHReturn = FunctionReturn + +export type TransferToVaultParams = FunctionArguments +export type TransferToVaultReturn = FunctionReturn + +export type CanPerformParams = FunctionArguments +export type CanPerformReturn = FunctionReturn + +export type SubmitParams = FunctionArguments +export type SubmitReturn = FunctionReturn + +export type DecreaseAllowanceParams = FunctionArguments +export type DecreaseAllowanceReturn = FunctionReturn + +export type GetEVMScriptRegistryParams = FunctionArguments +export type GetEVMScriptRegistryReturn = FunctionReturn + +export type TransferParams = FunctionArguments +export type TransferReturn = FunctionReturn + +export type DepositParams = FunctionArguments +export type DepositReturn = FunctionReturn + +export type UNSAFE_CHANGE_DEPOSITED_VALIDATORS_ROLEParams = FunctionArguments +export type UNSAFE_CHANGE_DEPOSITED_VALIDATORS_ROLEReturn = FunctionReturn + +export type GetBeaconStatParams = FunctionArguments +export type GetBeaconStatReturn = FunctionReturn + +export type RemoveStakingLimitParams = FunctionArguments +export type RemoveStakingLimitReturn = FunctionReturn + +export type HandleOracleReportParams = FunctionArguments +export type HandleOracleReportReturn = FunctionReturn + +export type GetFeeParams = FunctionArguments +export type GetFeeReturn = FunctionReturn + +export type KernelParams = FunctionArguments +export type KernelReturn = FunctionReturn + +export type GetTotalSharesParams = FunctionArguments +export type GetTotalSharesReturn = FunctionReturn + +export type PermitParams = FunctionArguments +export type PermitReturn = FunctionReturn + +export type AllowanceParams = FunctionArguments +export type AllowanceReturn = FunctionReturn + +export type IsPetrifiedParams = FunctionArguments +export type IsPetrifiedReturn = FunctionReturn + +export type GetLidoLocatorParams = FunctionArguments +export type GetLidoLocatorReturn = FunctionReturn + +export type CanDepositParams = FunctionArguments +export type CanDepositReturn = FunctionReturn + +export type STAKING_PAUSE_ROLEParams = FunctionArguments +export type STAKING_PAUSE_ROLEReturn = FunctionReturn + +export type GetDepositableEtherParams = FunctionArguments +export type GetDepositableEtherReturn = FunctionReturn + +export type SharesOfParams = FunctionArguments +export type SharesOfReturn = FunctionReturn + +export type PauseStakingParams = FunctionArguments +export type PauseStakingReturn = FunctionReturn + +export type GetTotalELRewardsCollectedParams = FunctionArguments +export type GetTotalELRewardsCollectedReturn = FunctionReturn + diff --git a/src/abi/maverick-pool.ts b/src/abi/maverick-pool.ts index a2ca18eb..002e972a 100644 --- a/src/abi/maverick-pool.ts +++ b/src/abi/maverick-pool.ts @@ -1,175 +1,190 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './maverick-pool.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - AddLiquidity: new LogEvent<([sender: string, tokenId: bigint, binDeltas: Array<([deltaA: bigint, deltaB: bigint, deltaLpBalance: bigint, binId: bigint, kind: number, lowerTick: number, isActive: boolean] & {deltaA: bigint, deltaB: bigint, deltaLpBalance: bigint, binId: bigint, kind: number, lowerTick: number, isActive: boolean})>] & {sender: string, tokenId: bigint, binDeltas: Array<([deltaA: bigint, deltaB: bigint, deltaLpBalance: bigint, binId: bigint, kind: number, lowerTick: number, isActive: boolean] & {deltaA: bigint, deltaB: bigint, deltaLpBalance: bigint, binId: bigint, kind: number, lowerTick: number, isActive: boolean})>})>( - abi, '0x133a027327582be2089f6ca47137e3d337be4ca2cd921e5f0b178c9c2d5b8364' - ), - BinMerged: new LogEvent<([binId: bigint, reserveA: bigint, reserveB: bigint, mergeId: bigint] & {binId: bigint, reserveA: bigint, reserveB: bigint, mergeId: bigint})>( - abi, '0x8ecf1f9da718dc4c174482cdb4e334113856b46a85e5694deeec06d512e8f772' - ), - BinMoved: new LogEvent<([binId: bigint, previousTick: bigint, newTick: bigint] & {binId: bigint, previousTick: bigint, newTick: bigint})>( - abi, '0x42e51620e75096344ac889cc1d899ab619aedbe89a4f6b230ee3cecb849c7e2f' - ), - MigrateBinsUpStack: new LogEvent<([sender: string, binId: bigint, maxRecursion: number] & {sender: string, binId: bigint, maxRecursion: number})>( - abi, '0x6deceb91de75f84acd021df8c6410377aa442257495a79a9e3bfc7eba745853e' - ), - ProtocolFeeCollected: new LogEvent<([protocolFee: bigint, isTokenA: boolean] & {protocolFee: bigint, isTokenA: boolean})>( - abi, '0x292394e5b7a6b75d01122bb2dc85341cefec10b852325db9d3658a452f5eb211' - ), - RemoveLiquidity: new LogEvent<([sender: string, recipient: string, tokenId: bigint, binDeltas: Array<([deltaA: bigint, deltaB: bigint, deltaLpBalance: bigint, binId: bigint, kind: number, lowerTick: number, isActive: boolean] & {deltaA: bigint, deltaB: bigint, deltaLpBalance: bigint, binId: bigint, kind: number, lowerTick: number, isActive: boolean})>] & {sender: string, recipient: string, tokenId: bigint, binDeltas: Array<([deltaA: bigint, deltaB: bigint, deltaLpBalance: bigint, binId: bigint, kind: number, lowerTick: number, isActive: boolean] & {deltaA: bigint, deltaB: bigint, deltaLpBalance: bigint, binId: bigint, kind: number, lowerTick: number, isActive: boolean})>})>( - abi, '0x65da280c1e973a1c5884c38d63e2c2b3c2a3158a0761e76545b64035e2489dfe' - ), - SetProtocolFeeRatio: new LogEvent<([protocolFee: bigint] & {protocolFee: bigint})>( - abi, '0x06e6ba2b10970ecae3ab2c29feb60ab2503358820756ef14a9827b0fa5add30f' - ), - Swap: new LogEvent<([sender: string, recipient: string, tokenAIn: boolean, exactOutput: boolean, amountIn: bigint, amountOut: bigint, activeTick: number] & {sender: string, recipient: string, tokenAIn: boolean, exactOutput: boolean, amountIn: bigint, amountOut: bigint, activeTick: number})>( - abi, '0x3b841dc9ab51e3104bda4f61b41e4271192d22cd19da5ee6e292dc8e2744f713' - ), - TransferLiquidity: new LogEvent<([fromTokenId: bigint, toTokenId: bigint, params: Array<([binId: bigint, amount: bigint] & {binId: bigint, amount: bigint})>] & {fromTokenId: bigint, toTokenId: bigint, params: Array<([binId: bigint, amount: bigint] & {binId: bigint, amount: bigint})>})>( - abi, '0xd384edefdfebd0bb45d82f94aed5ff327fd6510cc6c53ddc78a3ef4a0e7c715c' - ), + AddLiquidity: event("0x133a027327582be2089f6ca47137e3d337be4ca2cd921e5f0b178c9c2d5b8364", {"sender": indexed(p.address), "tokenId": indexed(p.uint256), "binDeltas": p.array(p.struct({"deltaA": p.uint128, "deltaB": p.uint128, "deltaLpBalance": p.uint256, "binId": p.uint128, "kind": p.uint8, "lowerTick": p.int32, "isActive": p.bool}))}), + BinMerged: event("0x8ecf1f9da718dc4c174482cdb4e334113856b46a85e5694deeec06d512e8f772", {"binId": indexed(p.uint128), "reserveA": p.uint128, "reserveB": p.uint128, "mergeId": p.uint128}), + BinMoved: event("0x42e51620e75096344ac889cc1d899ab619aedbe89a4f6b230ee3cecb849c7e2f", {"binId": indexed(p.uint128), "previousTick": p.int128, "newTick": p.int128}), + MigrateBinsUpStack: event("0x6deceb91de75f84acd021df8c6410377aa442257495a79a9e3bfc7eba745853e", {"sender": indexed(p.address), "binId": p.uint128, "maxRecursion": p.uint32}), + ProtocolFeeCollected: event("0x292394e5b7a6b75d01122bb2dc85341cefec10b852325db9d3658a452f5eb211", {"protocolFee": p.uint256, "isTokenA": p.bool}), + RemoveLiquidity: event("0x65da280c1e973a1c5884c38d63e2c2b3c2a3158a0761e76545b64035e2489dfe", {"sender": indexed(p.address), "recipient": indexed(p.address), "tokenId": indexed(p.uint256), "binDeltas": p.array(p.struct({"deltaA": p.uint128, "deltaB": p.uint128, "deltaLpBalance": p.uint256, "binId": p.uint128, "kind": p.uint8, "lowerTick": p.int32, "isActive": p.bool}))}), + SetProtocolFeeRatio: event("0x06e6ba2b10970ecae3ab2c29feb60ab2503358820756ef14a9827b0fa5add30f", {"protocolFee": p.uint256}), + Swap: event("0x3b841dc9ab51e3104bda4f61b41e4271192d22cd19da5ee6e292dc8e2744f713", {"sender": p.address, "recipient": p.address, "tokenAIn": p.bool, "exactOutput": p.bool, "amountIn": p.uint256, "amountOut": p.uint256, "activeTick": p.int32}), + TransferLiquidity: event("0xd384edefdfebd0bb45d82f94aed5ff327fd6510cc6c53ddc78a3ef4a0e7c715c", {"fromTokenId": p.uint256, "toTokenId": p.uint256, "params": p.array(p.struct({"binId": p.uint128, "amount": p.uint128}))}), } export const functions = { - addLiquidity: new Func<[tokenId: bigint, params: Array<([kind: number, pos: number, isDelta: boolean, deltaA: bigint, deltaB: bigint] & {kind: number, pos: number, isDelta: boolean, deltaA: bigint, deltaB: bigint})>, data: string], {tokenId: bigint, params: Array<([kind: number, pos: number, isDelta: boolean, deltaA: bigint, deltaB: bigint] & {kind: number, pos: number, isDelta: boolean, deltaA: bigint, deltaB: bigint})>, data: string}, ([tokenAAmount: bigint, tokenBAmount: bigint, binDeltas: Array<([deltaA: bigint, deltaB: bigint, deltaLpBalance: bigint, binId: bigint, kind: number, lowerTick: number, isActive: boolean] & {deltaA: bigint, deltaB: bigint, deltaLpBalance: bigint, binId: bigint, kind: number, lowerTick: number, isActive: boolean})>] & {tokenAAmount: bigint, tokenBAmount: bigint, binDeltas: Array<([deltaA: bigint, deltaB: bigint, deltaLpBalance: bigint, binId: bigint, kind: number, lowerTick: number, isActive: boolean] & {deltaA: bigint, deltaB: bigint, deltaLpBalance: bigint, binId: bigint, kind: number, lowerTick: number, isActive: boolean})>})>( - abi, '0x9d5f20bb' - ), - balanceOf: new Func<[tokenId: bigint, binId: bigint], {tokenId: bigint, binId: bigint}, bigint>( - abi, '0x6da3bf8b' - ), - binBalanceA: new Func<[], {}, bigint>( - abi, '0x75bbbd73' - ), - binBalanceB: new Func<[], {}, bigint>( - abi, '0xfa158509' - ), - binMap: new Func<[tick: number], {tick: number}, bigint>( - abi, '0xa2ba172f' - ), - binPositions: new Func<[tick: number, kind: bigint], {tick: number, kind: bigint}, bigint>( - abi, '0x83f9c632' - ), - factory: new Func<[], {}, string>( - abi, '0xc45a0155' - ), - fee: new Func<[], {}, bigint>( - abi, '0xddca3f43' - ), - lookback: new Func<[], {}, bigint>( - abi, '0xebcbd281' - ), - getBin: new Func<[binId: bigint], {binId: bigint}, ([reserveA: bigint, reserveB: bigint, mergeBinBalance: bigint, mergeId: bigint, totalSupply: bigint, kind: number, lowerTick: number] & {reserveA: bigint, reserveB: bigint, mergeBinBalance: bigint, mergeId: bigint, totalSupply: bigint, kind: number, lowerTick: number})>( - abi, '0x44a185bb' - ), - getCurrentTwa: new Func<[], {}, bigint>( - abi, '0xd3d3861a' - ), - getState: new Func<[], {}, ([activeTick: number, status: number, binCounter: bigint, protocolFeeRatio: bigint] & {activeTick: number, status: number, binCounter: bigint, protocolFeeRatio: bigint})>( - abi, '0x1865c57d' - ), - getTwa: new Func<[], {}, ([twa: bigint, value: bigint, lastTimestamp: bigint] & {twa: bigint, value: bigint, lastTimestamp: bigint})>( - abi, '0xa4ed496a' - ), - migrateBinUpStack: new Func<[binId: bigint, maxRecursion: number], {binId: bigint, maxRecursion: number}, []>( - abi, '0xc0c5d7fb' - ), - removeLiquidity: new Func<[recipient: string, tokenId: bigint, params: Array<([binId: bigint, amount: bigint] & {binId: bigint, amount: bigint})>], {recipient: string, tokenId: bigint, params: Array<([binId: bigint, amount: bigint] & {binId: bigint, amount: bigint})>}, ([tokenAOut: bigint, tokenBOut: bigint, binDeltas: Array<([deltaA: bigint, deltaB: bigint, deltaLpBalance: bigint, binId: bigint, kind: number, lowerTick: number, isActive: boolean] & {deltaA: bigint, deltaB: bigint, deltaLpBalance: bigint, binId: bigint, kind: number, lowerTick: number, isActive: boolean})>] & {tokenAOut: bigint, tokenBOut: bigint, binDeltas: Array<([deltaA: bigint, deltaB: bigint, deltaLpBalance: bigint, binId: bigint, kind: number, lowerTick: number, isActive: boolean] & {deltaA: bigint, deltaB: bigint, deltaLpBalance: bigint, binId: bigint, kind: number, lowerTick: number, isActive: boolean})>})>( - abi, '0x57c8c7b0' - ), - swap: new Func<[recipient: string, amount: bigint, tokenAIn: boolean, exactOutput: boolean, sqrtPriceLimit: bigint, data: string], {recipient: string, amount: bigint, tokenAIn: boolean, exactOutput: boolean, sqrtPriceLimit: bigint, data: string}, ([amountIn: bigint, amountOut: bigint] & {amountIn: bigint, amountOut: bigint})>( - abi, '0xc51c9029' - ), - tickSpacing: new Func<[], {}, bigint>( - abi, '0xd0c93a7c' - ), - tokenA: new Func<[], {}, string>( - abi, '0x0fc63d10' - ), - tokenAScale: new Func<[], {}, bigint>( - abi, '0x3ab72c10' - ), - tokenB: new Func<[], {}, string>( - abi, '0x5f64b55b' - ), - tokenBScale: new Func<[], {}, bigint>( - abi, '0x21272d4c' - ), - transferLiquidity: new Func<[fromTokenId: bigint, toTokenId: bigint, params: Array<([binId: bigint, amount: bigint] & {binId: bigint, amount: bigint})>], {fromTokenId: bigint, toTokenId: bigint, params: Array<([binId: bigint, amount: bigint] & {binId: bigint, amount: bigint})>}, []>( - abi, '0xd279735f' - ), + addLiquidity: fun("0x9d5f20bb", {"tokenId": p.uint256, "params": p.array(p.struct({"kind": p.uint8, "pos": p.int32, "isDelta": p.bool, "deltaA": p.uint128, "deltaB": p.uint128})), "data": p.bytes}, {"tokenAAmount": p.uint256, "tokenBAmount": p.uint256, "binDeltas": p.array(p.struct({"deltaA": p.uint128, "deltaB": p.uint128, "deltaLpBalance": p.uint256, "binId": p.uint128, "kind": p.uint8, "lowerTick": p.int32, "isActive": p.bool}))}), + balanceOf: fun("0x6da3bf8b", {"tokenId": p.uint256, "binId": p.uint128}, p.uint256), + binBalanceA: fun("0x75bbbd73", {}, p.uint128), + binBalanceB: fun("0xfa158509", {}, p.uint128), + binMap: fun("0xa2ba172f", {"tick": p.int32}, p.uint256), + binPositions: fun("0x83f9c632", {"tick": p.int32, "kind": p.uint256}, p.uint128), + factory: fun("0xc45a0155", {}, p.address), + fee: fun("0xddca3f43", {}, p.uint256), + lookback: fun("0xebcbd281", {}, p.int256), + getBin: fun("0x44a185bb", {"binId": p.uint128}, p.struct({"reserveA": p.uint128, "reserveB": p.uint128, "mergeBinBalance": p.uint128, "mergeId": p.uint128, "totalSupply": p.uint128, "kind": p.uint8, "lowerTick": p.int32})), + getCurrentTwa: fun("0xd3d3861a", {}, p.int256), + getState: fun("0x1865c57d", {}, p.struct({"activeTick": p.int32, "status": p.uint8, "binCounter": p.uint128, "protocolFeeRatio": p.uint64})), + getTwa: fun("0xa4ed496a", {}, p.struct({"twa": p.int96, "value": p.int96, "lastTimestamp": p.uint64})), + migrateBinUpStack: fun("0xc0c5d7fb", {"binId": p.uint128, "maxRecursion": p.uint32}, ), + removeLiquidity: fun("0x57c8c7b0", {"recipient": p.address, "tokenId": p.uint256, "params": p.array(p.struct({"binId": p.uint128, "amount": p.uint128}))}, {"tokenAOut": p.uint256, "tokenBOut": p.uint256, "binDeltas": p.array(p.struct({"deltaA": p.uint128, "deltaB": p.uint128, "deltaLpBalance": p.uint256, "binId": p.uint128, "kind": p.uint8, "lowerTick": p.int32, "isActive": p.bool}))}), + swap: fun("0xc51c9029", {"recipient": p.address, "amount": p.uint256, "tokenAIn": p.bool, "exactOutput": p.bool, "sqrtPriceLimit": p.uint256, "data": p.bytes}, {"amountIn": p.uint256, "amountOut": p.uint256}), + tickSpacing: fun("0xd0c93a7c", {}, p.uint256), + tokenA: fun("0x0fc63d10", {}, p.address), + tokenAScale: fun("0x3ab72c10", {}, p.uint256), + tokenB: fun("0x5f64b55b", {}, p.address), + tokenBScale: fun("0x21272d4c", {}, p.uint256), + transferLiquidity: fun("0xd279735f", {"fromTokenId": p.uint256, "toTokenId": p.uint256, "params": p.array(p.struct({"binId": p.uint128, "amount": p.uint128}))}, ), } export class Contract extends ContractBase { - balanceOf(tokenId: bigint, binId: bigint): Promise { - return this.eth_call(functions.balanceOf, [tokenId, binId]) + balanceOf(tokenId: BalanceOfParams["tokenId"], binId: BalanceOfParams["binId"]) { + return this.eth_call(functions.balanceOf, {tokenId, binId}) } - binBalanceA(): Promise { - return this.eth_call(functions.binBalanceA, []) + binBalanceA() { + return this.eth_call(functions.binBalanceA, {}) } - binBalanceB(): Promise { - return this.eth_call(functions.binBalanceB, []) + binBalanceB() { + return this.eth_call(functions.binBalanceB, {}) } - binMap(tick: number): Promise { - return this.eth_call(functions.binMap, [tick]) + binMap(tick: BinMapParams["tick"]) { + return this.eth_call(functions.binMap, {tick}) } - binPositions(tick: number, kind: bigint): Promise { - return this.eth_call(functions.binPositions, [tick, kind]) + binPositions(tick: BinPositionsParams["tick"], kind: BinPositionsParams["kind"]) { + return this.eth_call(functions.binPositions, {tick, kind}) } - factory(): Promise { - return this.eth_call(functions.factory, []) + factory() { + return this.eth_call(functions.factory, {}) } - fee(): Promise { - return this.eth_call(functions.fee, []) + fee() { + return this.eth_call(functions.fee, {}) } - lookback(): Promise { - return this.eth_call(functions.lookback, []) + lookback() { + return this.eth_call(functions.lookback, {}) } - getBin(binId: bigint): Promise<([reserveA: bigint, reserveB: bigint, mergeBinBalance: bigint, mergeId: bigint, totalSupply: bigint, kind: number, lowerTick: number] & {reserveA: bigint, reserveB: bigint, mergeBinBalance: bigint, mergeId: bigint, totalSupply: bigint, kind: number, lowerTick: number})> { - return this.eth_call(functions.getBin, [binId]) + getBin(binId: GetBinParams["binId"]) { + return this.eth_call(functions.getBin, {binId}) } - getCurrentTwa(): Promise { - return this.eth_call(functions.getCurrentTwa, []) + getCurrentTwa() { + return this.eth_call(functions.getCurrentTwa, {}) } - getState(): Promise<([activeTick: number, status: number, binCounter: bigint, protocolFeeRatio: bigint] & {activeTick: number, status: number, binCounter: bigint, protocolFeeRatio: bigint})> { - return this.eth_call(functions.getState, []) + getState() { + return this.eth_call(functions.getState, {}) } - getTwa(): Promise<([twa: bigint, value: bigint, lastTimestamp: bigint] & {twa: bigint, value: bigint, lastTimestamp: bigint})> { - return this.eth_call(functions.getTwa, []) + getTwa() { + return this.eth_call(functions.getTwa, {}) } - tickSpacing(): Promise { - return this.eth_call(functions.tickSpacing, []) + tickSpacing() { + return this.eth_call(functions.tickSpacing, {}) } - tokenA(): Promise { - return this.eth_call(functions.tokenA, []) + tokenA() { + return this.eth_call(functions.tokenA, {}) } - tokenAScale(): Promise { - return this.eth_call(functions.tokenAScale, []) + tokenAScale() { + return this.eth_call(functions.tokenAScale, {}) } - tokenB(): Promise { - return this.eth_call(functions.tokenB, []) + tokenB() { + return this.eth_call(functions.tokenB, {}) } - tokenBScale(): Promise { - return this.eth_call(functions.tokenBScale, []) + tokenBScale() { + return this.eth_call(functions.tokenBScale, {}) } } + +/// Event types +export type AddLiquidityEventArgs = EParams +export type BinMergedEventArgs = EParams +export type BinMovedEventArgs = EParams +export type MigrateBinsUpStackEventArgs = EParams +export type ProtocolFeeCollectedEventArgs = EParams +export type RemoveLiquidityEventArgs = EParams +export type SetProtocolFeeRatioEventArgs = EParams +export type SwapEventArgs = EParams +export type TransferLiquidityEventArgs = EParams + +/// Function types +export type AddLiquidityParams = FunctionArguments +export type AddLiquidityReturn = FunctionReturn + +export type BalanceOfParams = FunctionArguments +export type BalanceOfReturn = FunctionReturn + +export type BinBalanceAParams = FunctionArguments +export type BinBalanceAReturn = FunctionReturn + +export type BinBalanceBParams = FunctionArguments +export type BinBalanceBReturn = FunctionReturn + +export type BinMapParams = FunctionArguments +export type BinMapReturn = FunctionReturn + +export type BinPositionsParams = FunctionArguments +export type BinPositionsReturn = FunctionReturn + +export type FactoryParams = FunctionArguments +export type FactoryReturn = FunctionReturn + +export type FeeParams = FunctionArguments +export type FeeReturn = FunctionReturn + +export type LookbackParams = FunctionArguments +export type LookbackReturn = FunctionReturn + +export type GetBinParams = FunctionArguments +export type GetBinReturn = FunctionReturn + +export type GetCurrentTwaParams = FunctionArguments +export type GetCurrentTwaReturn = FunctionReturn + +export type GetStateParams = FunctionArguments +export type GetStateReturn = FunctionReturn + +export type GetTwaParams = FunctionArguments +export type GetTwaReturn = FunctionReturn + +export type MigrateBinUpStackParams = FunctionArguments +export type MigrateBinUpStackReturn = FunctionReturn + +export type RemoveLiquidityParams = FunctionArguments +export type RemoveLiquidityReturn = FunctionReturn + +export type SwapParams = FunctionArguments +export type SwapReturn = FunctionReturn + +export type TickSpacingParams = FunctionArguments +export type TickSpacingReturn = FunctionReturn + +export type TokenAParams = FunctionArguments +export type TokenAReturn = FunctionReturn + +export type TokenAScaleParams = FunctionArguments +export type TokenAScaleReturn = FunctionReturn + +export type TokenBParams = FunctionArguments +export type TokenBReturn = FunctionReturn + +export type TokenBScaleParams = FunctionArguments +export type TokenBScaleReturn = FunctionReturn + +export type TransferLiquidityParams = FunctionArguments +export type TransferLiquidityReturn = FunctionReturn + diff --git a/src/abi/multicall.ts b/src/abi/multicall.ts index 4b20dca4..8fc6e2d8 100644 --- a/src/abi/multicall.ts +++ b/src/abi/multicall.ts @@ -1,212 +1,166 @@ -import * as ethers from 'ethers' -import {ContractBase, Func} from './abi.support' - - -const abi = new ethers.Interface([ - { - type: 'function', - name: 'aggregate', - stateMutability: 'nonpayable', - inputs: [ - { - name: 'calls', - type: 'tuple[]', - components: [ - {name: 'target', type: 'address'}, - {name: 'callData', type: 'bytes'}, - ] - } - ], - outputs: [ - {name: 'blockNumber', type: 'uint256'}, - {name: 'returnData', type: 'bytes[]'}, - ] - }, - { - name: 'tryAggregate', - type: 'function', - stateMutability: 'nonpayable', - inputs: [ - {name: 'requireSuccess', type: 'bool'}, - { - name: 'calls', - type: 'tuple[]', - components: [ - {name: 'target', type: 'address'}, - {name: 'callData', type: 'bytes'}, - ] - } - ], - outputs: [ - { - name: 'returnData', - type: 'tuple[]', - components: [ - {name: 'success', type: 'bool'}, - {name: 'returnData', type: 'bytes'}, - ] - }, - ] - } -]) - - -type AnyFunc = Func -type Call = [address: string, bytes: string] - - -const aggregate = new Func<[calls: Call[]], {}, {blockNumber: bigint, returnData: string[]}>( - abi, abi.getFunction('aggregate')!.selector -) - - -const try_aggregate = new Func<[requireSuccess: boolean, calls: Array<[target: string, callData: string]>], {}, Array<{success: boolean, returnData: string}>>( - abi, abi.getFunction('tryAggregate')!.selector -) - - -export type MulticallResult = { - success: true - value: T +import * as p from '@subsquid/evm-codec' +import {fun, ContractBase, type AbiFunction, type FunctionReturn, type FunctionArguments} from '@subsquid/evm-abi' + +const aggregate = fun('0x252dba42', { + calls: p.array(p.struct({ + target: p.address, + callData: p.bytes + })) +}, {blockNumber: p.uint256, returnData: p.array(p.bytes)}) + +const tryAggregate = fun('0xbce38bd7', { + requireSuccess: p.bool, + calls: p.array(p.struct({target: p.address, callData: p.bytes})) +}, p.array(p.struct({success: p.bool, returnData: p.bytes}))) + +export type MulticallResult> = { + success: true + value: FunctionReturn } | { - success: false - returnData?: string - value?: undefined + success: false + returnData?: string + value?: undefined } +type AnyFunc = AbiFunction +type AggregateTuple = [func: T, address: string, args: T extends AnyFunc ? FunctionArguments : never] +type Call = {target: string, callData: string} export class Multicall extends ContractBase { - static aggregate = aggregate - static try_aggregate = try_aggregate - - aggregate( - func: Func, - address: string, - calls: Args[], - paging?: number - ): Promise - - aggregate( - func: Func, - calls: [address: string, args: Args][], - paging?: number - ): Promise - - aggregate( - calls: [func: AnyFunc, address: string, args: any[]][], - paging?: number - ): Promise - - async aggregate(...args: any[]): Promise { - let [calls, funcs, page] = this.makeCalls(args) - let size = calls.length - let results = new Array(size) - for (let [from, to] of splitIntoPages(size, page)) { - let {returnData} = await this.eth_call(aggregate, [calls.slice(from, to)]) - for (let i = from; i < to; i++) { - let data = returnData[i - from] - results[i] = funcs[i].decodeResult(data) - } - } - return results + static aggregate = aggregate + static tryAggregate = tryAggregate + + aggregate( + func: TF, + address: string, + calls: FunctionArguments[], + paging?: number + ): Promise[]> + + aggregate( + func: TF, + calls: [address: string, args: FunctionArguments][], + paging?: number + ): Promise[]> + + aggregate( + calls: AggregateTuple[], + paging?: number + ): Promise + + async aggregate(...args: any[]): Promise { + let [calls, funcs, page] = this.makeCalls(args) + let size = calls.length + let results = new Array(size) + for (let [from, to] of splitIntoPages(size, page)) { + let {returnData} = await this.eth_call(aggregate, {calls: calls.slice(from, to)}) + for (let i = from; i < to; i++) { + let data = returnData[i - from] + results[i] = funcs[i].decodeResult(data) + } } - - tryAggregate( - func: Func, - address: string, - calls: Args[], - paging?: number - ): Promise[]> - - tryAggregate( - func: Func, - calls: [address: string, args: Args][], - paging?: number - ): Promise[]> - - tryAggregate( - calls: [func: AnyFunc, address: string, args: any[]][], - paging?: number - ): Promise[]> - - async tryAggregate(...args: any[]): Promise { - let [calls, funcs, page] = this.makeCalls(args) - let size = calls.length - let results = new Array(size) - for (let [from, to] of splitIntoPages(size, page)) { - let response = await this.eth_call(try_aggregate, [false, calls.slice(from, to)]) - for (let i = from; i < to; i++) { - let res = response[i - from] - if (res.success) { - try { - results[i] = { - success: true, - value: funcs[i].decodeResult(res.returnData) - } - } catch(err: any) { - results[i] = {success: false, returnData: res.returnData} - } - } else { - results[i] = {success: false} - } + return results + } + + tryAggregate( + func: TF, + address: string, + calls: FunctionArguments[], + paging?: number + ): Promise[]> + + tryAggregate( + func: TF, + calls: [address: string, args: FunctionArguments][], + paging?: number + ): Promise[]> + + tryAggregate( + calls: AggregateTuple[], + paging?: number + ): Promise[]> + + async tryAggregate(...args: any[]): Promise { + let [calls, funcs, page] = this.makeCalls(args) + let size = calls.length + let results = new Array(size) + for (let [from, to] of splitIntoPages(size, page)) { + let response = await this.eth_call(tryAggregate, { + requireSuccess: false, + calls: calls.slice(from, to) + }) + for (let i = from; i < to; i++) { + let res = response[i - from] + if (res.success) { + try { + results[i] = { + success: true, + value: funcs[i].decodeResult(res.returnData) } + } catch (err: any) { + results[i] = {success: false, returnData: res.returnData} + } + } else { + results[i] = {success: false} } - return results + } } - - private makeCalls(args: any[]): [calls: Call[], funcs: AnyFunc[], page: number] { - let page = typeof args[args.length-1] == 'number' ? args.pop()! : Number.MAX_SAFE_INTEGER - switch(args.length) { - case 1: { - let list: [func: AnyFunc, address: string, args: any[]][] = args[0] - let calls = new Array(list.length) - let funcs = new Array(list.length) - for (let i = 0; i < list.length; i++) { - let [func, address, args] = list[i] - calls[i] = [address, func.encode(args)] - funcs[i] = func - } - return [calls, funcs, page] - } - case 2: { - let func: AnyFunc = args[0] - let list: [address: string, args: any[]][] = args[1] - let calls = new Array(list.length) - let funcs = new Array(list.length) - for (let i = 0; i < list.length; i++) { - let [address, args] = list[i] - calls[i] = [address, func.encode(args)] - funcs[i] = func - } - return [calls, funcs, page] - } - case 3: { - let func: AnyFunc = args[0] - let address: string = args[1] - let list: any[][] = args[2] - let calls = new Array(list.length) - let funcs = new Array(list.length) - for (let i = 0; i < list.length; i++) { - let args = list[i] - calls[i] = [address, func.encode(args)] - funcs[i] = func - } - return [calls, funcs, page] - } - default: - throw new Error('unexpected number of arguments') + return results + } + + private makeCalls(args: any[]): [calls: Call[], funcs: AnyFunc[], page: number] { + let page = typeof args[args.length - 1] == 'number' ? args.pop()! : Number.MAX_SAFE_INTEGER + switch (args.length) { + case 1: { + let list: AggregateTuple[] = args[0] + let calls: Call[] = new Array(list.length) + let funcs = new Array(list.length) + for (let i = 0; i < list.length; i++) { + let [func, address, args] = list[i] + calls[i] = {target: address, callData: func.encode(args)} + funcs[i] = func + } + return [calls, funcs, page] + } + case 2: { + let func: AnyFunc = args[0] + let list: [address: string, args: any][] = args[1] + let calls: Call[] = new Array(list.length) + let funcs = new Array(list.length) + for (let i = 0; i < list.length; i++) { + let [address, args] = list[i] + calls[i] = {target: address, callData: func.encode(args)} + funcs[i] = func } + return [calls, funcs, page] + } + case 3: { + let func: AnyFunc = args[0] + let address: string = args[1] + let list: any = args[2] + let calls: Call[] = new Array(list.length) + let funcs = new Array(list.length) + for (let i = 0; i < list.length; i++) { + let args = list[i] + calls[i] = {target: address, callData: func.encode(args)} + funcs[i] = func + } + return [calls, funcs, page] + } + default: + throw new Error('unexpected number of arguments') } + } } function* splitIntoPages(size: number, page: number): Iterable<[from: number, to: number]> { - let from = 0 - while (size) { - let step = Math.min(page, size) - let to = from + step - yield [from, to] - size -= step - from = to - } + let from = 0 + while (size) { + let step = Math.min(page, size) + let to = from + step + yield [from, to] + size -= step + from = to + } } diff --git a/src/abi/oeth-oracle-router.ts b/src/abi/oeth-oracle-router.ts index 7da3c5d7..d753b955 100644 --- a/src/abi/oeth-oracle-router.ts +++ b/src/abi/oeth-oracle-router.ts @@ -1,21 +1,23 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './oeth-oracle-router.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const functions = { - cacheDecimals: new Func<[asset: string], {asset: string}, number>( - abi, '0x36b6d944' - ), - price: new Func<[asset: string], {asset: string}, bigint>( - abi, '0xaea91078' - ), + cacheDecimals: fun("0x36b6d944", {"asset": p.address}, p.uint8), + price: fun("0xaea91078", {"asset": p.address}, p.uint256), } export class Contract extends ContractBase { - price(asset: string): Promise { - return this.eth_call(functions.price, [asset]) + price(asset: PriceParams["asset"]) { + return this.eth_call(functions.price, {asset}) } } + +/// Function types +export type CacheDecimalsParams = FunctionArguments +export type CacheDecimalsReturn = FunctionReturn + +export type PriceParams = FunctionArguments +export type PriceReturn = FunctionReturn + diff --git a/src/abi/oeth-zapper.ts b/src/abi/oeth-zapper.ts index d0fd53cc..b4f9d1c3 100644 --- a/src/abi/oeth-zapper.ts +++ b/src/abi/oeth-zapper.ts @@ -1,58 +1,66 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './oeth-zapper.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - Zap: new LogEvent<([minter: string, asset: string, amount: bigint] & {minter: string, asset: string, amount: bigint})>( - abi, '0x9d0b99c299bdb5656c0c9db6e1886c612db5c2881760ea54ab244f6338b4ebd6' - ), + Zap: event("0x9d0b99c299bdb5656c0c9db6e1886c612db5c2881760ea54ab244f6338b4ebd6", {"minter": indexed(p.address), "asset": indexed(p.address), "amount": p.uint256}), } export const functions = { - deposit: new Func<[], {}, bigint>( - abi, '0xd0e30db0' - ), - depositSFRXETH: new Func<[amount: bigint, minOETH: bigint], {amount: bigint, minOETH: bigint}, bigint>( - abi, '0xd443e97d' - ), - frxeth: new Func<[], {}, string>( - abi, '0x6f708a9d' - ), - oeth: new Func<[], {}, string>( - abi, '0xccfe2a69' - ), - sfrxeth: new Func<[], {}, string>( - abi, '0xa07311af' - ), - vault: new Func<[], {}, string>( - abi, '0xfbfa77cf' - ), - weth: new Func<[], {}, string>( - abi, '0x3fc8cef3' - ), + deposit: fun("0xd0e30db0", {}, p.uint256), + depositSFRXETH: fun("0xd443e97d", {"amount": p.uint256, "minOETH": p.uint256}, p.uint256), + frxeth: fun("0x6f708a9d", {}, p.address), + oeth: fun("0xccfe2a69", {}, p.address), + sfrxeth: fun("0xa07311af", {}, p.address), + vault: fun("0xfbfa77cf", {}, p.address), + weth: fun("0x3fc8cef3", {}, p.address), } export class Contract extends ContractBase { - frxeth(): Promise { - return this.eth_call(functions.frxeth, []) + frxeth() { + return this.eth_call(functions.frxeth, {}) } - oeth(): Promise { - return this.eth_call(functions.oeth, []) + oeth() { + return this.eth_call(functions.oeth, {}) } - sfrxeth(): Promise { - return this.eth_call(functions.sfrxeth, []) + sfrxeth() { + return this.eth_call(functions.sfrxeth, {}) } - vault(): Promise { - return this.eth_call(functions.vault, []) + vault() { + return this.eth_call(functions.vault, {}) } - weth(): Promise { - return this.eth_call(functions.weth, []) + weth() { + return this.eth_call(functions.weth, {}) } } + +/// Event types +export type ZapEventArgs = EParams + +/// Function types +export type DepositParams = FunctionArguments +export type DepositReturn = FunctionReturn + +export type DepositSFRXETHParams = FunctionArguments +export type DepositSFRXETHReturn = FunctionReturn + +export type FrxethParams = FunctionArguments +export type FrxethReturn = FunctionReturn + +export type OethParams = FunctionArguments +export type OethReturn = FunctionReturn + +export type SfrxethParams = FunctionArguments +export type SfrxethReturn = FunctionReturn + +export type VaultParams = FunctionArguments +export type VaultReturn = FunctionReturn + +export type WethParams = FunctionArguments +export type WethReturn = FunctionReturn + diff --git a/src/abi/oeth.ts b/src/abi/oeth.ts index 880141c1..2bbbbd0f 100644 --- a/src/abi/oeth.ts +++ b/src/abi/oeth.ts @@ -1,208 +1,238 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './oeth.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - Approval: new LogEvent<([owner: string, spender: string, value: bigint] & {owner: string, spender: string, value: bigint})>( - abi, '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925' - ), - GovernorshipTransferred: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( - abi, '0xc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a' - ), - PendingGovernorshipTransfer: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( - abi, '0xa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d' - ), - TotalSupplyUpdatedHighres: new LogEvent<([totalSupply: bigint, rebasingCredits: bigint, rebasingCreditsPerToken: bigint] & {totalSupply: bigint, rebasingCredits: bigint, rebasingCreditsPerToken: bigint})>( - abi, '0x41645eb819d3011b13f97696a8109d14bfcddfaca7d063ec0564d62a3e257235' - ), - Transfer: new LogEvent<([from: string, to: string, value: bigint] & {from: string, to: string, value: bigint})>( - abi, '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' - ), + Approval: event("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", {"owner": indexed(p.address), "spender": indexed(p.address), "value": p.uint256}), + GovernorshipTransferred: event("0xc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a", {"previousGovernor": indexed(p.address), "newGovernor": indexed(p.address)}), + PendingGovernorshipTransfer: event("0xa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d", {"previousGovernor": indexed(p.address), "newGovernor": indexed(p.address)}), + TotalSupplyUpdatedHighres: event("0x41645eb819d3011b13f97696a8109d14bfcddfaca7d063ec0564d62a3e257235", {"totalSupply": p.uint256, "rebasingCredits": p.uint256, "rebasingCreditsPerToken": p.uint256}), + Transfer: event("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", {"from": indexed(p.address), "to": indexed(p.address), "value": p.uint256}), } export const functions = { - _totalSupply: new Func<[], {}, bigint>( - abi, '0x3eaaf86b' - ), - allowance: new Func<[_owner: string, _spender: string], {_owner: string, _spender: string}, bigint>( - abi, '0xdd62ed3e' - ), - approve: new Func<[_spender: string, _value: bigint], {_spender: string, _value: bigint}, boolean>( - abi, '0x095ea7b3' - ), - balanceOf: new Func<[_account: string], {_account: string}, bigint>( - abi, '0x70a08231' - ), - burn: new Func<[account: string, amount: bigint], {account: string, amount: bigint}, []>( - abi, '0x9dc29fac' - ), - changeSupply: new Func<[_newTotalSupply: bigint], {_newTotalSupply: bigint}, []>( - abi, '0x39a7919f' - ), - claimGovernance: new Func<[], {}, []>( - abi, '0x5d36b190' - ), - creditsBalanceOf: new Func<[_account: string], {_account: string}, [_: bigint, _: bigint]>( - abi, '0xf9854bfc' - ), - creditsBalanceOfHighres: new Func<[_account: string], {_account: string}, [_: bigint, _: bigint, _: boolean]>( - abi, '0xe5c4fffe' - ), - decimals: new Func<[], {}, number>( - abi, '0x313ce567' - ), - decreaseAllowance: new Func<[_spender: string, _subtractedValue: bigint], {_spender: string, _subtractedValue: bigint}, boolean>( - abi, '0xa457c2d7' - ), - governor: new Func<[], {}, string>( - abi, '0x0c340a24' - ), - increaseAllowance: new Func<[_spender: string, _addedValue: bigint], {_spender: string, _addedValue: bigint}, boolean>( - abi, '0x39509351' - ), - initialize: new Func<[_nameArg: string, _symbolArg: string, _vaultAddress: string, _initialCreditsPerToken: bigint], {_nameArg: string, _symbolArg: string, _vaultAddress: string, _initialCreditsPerToken: bigint}, []>( - abi, '0xf542033f' - ), - isGovernor: new Func<[], {}, boolean>( - abi, '0xc7af3352' - ), - isUpgraded: new Func<[_: string], {}, bigint>( - abi, '0x95ef84b9' - ), - mint: new Func<[_account: string, _amount: bigint], {_account: string, _amount: bigint}, []>( - abi, '0x40c10f19' - ), - name: new Func<[], {}, string>( - abi, '0x06fdde03' - ), - nonRebasingCreditsPerToken: new Func<[_: string], {}, bigint>( - abi, '0x609350cd' - ), - nonRebasingSupply: new Func<[], {}, bigint>( - abi, '0xe696393a' - ), - rebaseOptIn: new Func<[], {}, []>( - abi, '0xf51b0fd4' - ), - rebaseOptOut: new Func<[], {}, []>( - abi, '0xc2376dff' - ), - rebaseState: new Func<[_: string], {}, number>( - abi, '0x456ee286' - ), - rebasingCredits: new Func<[], {}, bigint>( - abi, '0x077f22b7' - ), - rebasingCreditsHighres: new Func<[], {}, bigint>( - abi, '0x7d0d66ff' - ), - rebasingCreditsPerToken: new Func<[], {}, bigint>( - abi, '0x6691cb3d' - ), - rebasingCreditsPerTokenHighres: new Func<[], {}, bigint>( - abi, '0x7a46a9c5' - ), - symbol: new Func<[], {}, string>( - abi, '0x95d89b41' - ), - totalSupply: new Func<[], {}, bigint>( - abi, '0x18160ddd' - ), - transfer: new Func<[_to: string, _value: bigint], {_to: string, _value: bigint}, boolean>( - abi, '0xa9059cbb' - ), - transferFrom: new Func<[_from: string, _to: string, _value: bigint], {_from: string, _to: string, _value: bigint}, boolean>( - abi, '0x23b872dd' - ), - transferGovernance: new Func<[_newGovernor: string], {_newGovernor: string}, []>( - abi, '0xd38bfff4' - ), - vaultAddress: new Func<[], {}, string>( - abi, '0x430bf08a' - ), + _totalSupply: fun("0x3eaaf86b", {}, p.uint256), + allowance: fun("0xdd62ed3e", {"_owner": p.address, "_spender": p.address}, p.uint256), + approve: fun("0x095ea7b3", {"_spender": p.address, "_value": p.uint256}, p.bool), + balanceOf: fun("0x70a08231", {"_account": p.address}, p.uint256), + burn: fun("0x9dc29fac", {"account": p.address, "amount": p.uint256}, ), + changeSupply: fun("0x39a7919f", {"_newTotalSupply": p.uint256}, ), + claimGovernance: fun("0x5d36b190", {}, ), + creditsBalanceOf: fun("0xf9854bfc", {"_account": p.address}, {"_0": p.uint256, "_1": p.uint256}), + creditsBalanceOfHighres: fun("0xe5c4fffe", {"_account": p.address}, {"_0": p.uint256, "_1": p.uint256, "_2": p.bool}), + decimals: fun("0x313ce567", {}, p.uint8), + decreaseAllowance: fun("0xa457c2d7", {"_spender": p.address, "_subtractedValue": p.uint256}, p.bool), + governor: fun("0x0c340a24", {}, p.address), + increaseAllowance: fun("0x39509351", {"_spender": p.address, "_addedValue": p.uint256}, p.bool), + initialize: fun("0xf542033f", {"_nameArg": p.string, "_symbolArg": p.string, "_vaultAddress": p.address, "_initialCreditsPerToken": p.uint256}, ), + isGovernor: fun("0xc7af3352", {}, p.bool), + isUpgraded: fun("0x95ef84b9", {"_0": p.address}, p.uint256), + mint: fun("0x40c10f19", {"_account": p.address, "_amount": p.uint256}, ), + name: fun("0x06fdde03", {}, p.string), + nonRebasingCreditsPerToken: fun("0x609350cd", {"_0": p.address}, p.uint256), + nonRebasingSupply: fun("0xe696393a", {}, p.uint256), + rebaseOptIn: fun("0xf51b0fd4", {}, ), + rebaseOptOut: fun("0xc2376dff", {}, ), + rebaseState: fun("0x456ee286", {"_0": p.address}, p.uint8), + rebasingCredits: fun("0x077f22b7", {}, p.uint256), + rebasingCreditsHighres: fun("0x7d0d66ff", {}, p.uint256), + rebasingCreditsPerToken: fun("0x6691cb3d", {}, p.uint256), + rebasingCreditsPerTokenHighres: fun("0x7a46a9c5", {}, p.uint256), + symbol: fun("0x95d89b41", {}, p.string), + totalSupply: fun("0x18160ddd", {}, p.uint256), + transfer: fun("0xa9059cbb", {"_to": p.address, "_value": p.uint256}, p.bool), + transferFrom: fun("0x23b872dd", {"_from": p.address, "_to": p.address, "_value": p.uint256}, p.bool), + transferGovernance: fun("0xd38bfff4", {"_newGovernor": p.address}, ), + vaultAddress: fun("0x430bf08a", {}, p.address), } export class Contract extends ContractBase { - _totalSupply(): Promise { - return this.eth_call(functions._totalSupply, []) + _totalSupply() { + return this.eth_call(functions._totalSupply, {}) } - allowance(_owner: string, _spender: string): Promise { - return this.eth_call(functions.allowance, [_owner, _spender]) + allowance(_owner: AllowanceParams["_owner"], _spender: AllowanceParams["_spender"]) { + return this.eth_call(functions.allowance, {_owner, _spender}) } - balanceOf(_account: string): Promise { - return this.eth_call(functions.balanceOf, [_account]) + balanceOf(_account: BalanceOfParams["_account"]) { + return this.eth_call(functions.balanceOf, {_account}) } - creditsBalanceOf(_account: string): Promise<[_: bigint, _: bigint]> { - return this.eth_call(functions.creditsBalanceOf, [_account]) + creditsBalanceOf(_account: CreditsBalanceOfParams["_account"]) { + return this.eth_call(functions.creditsBalanceOf, {_account}) } - creditsBalanceOfHighres(_account: string): Promise<[_: bigint, _: bigint, _: boolean]> { - return this.eth_call(functions.creditsBalanceOfHighres, [_account]) + creditsBalanceOfHighres(_account: CreditsBalanceOfHighresParams["_account"]) { + return this.eth_call(functions.creditsBalanceOfHighres, {_account}) } - decimals(): Promise { - return this.eth_call(functions.decimals, []) + decimals() { + return this.eth_call(functions.decimals, {}) } - governor(): Promise { - return this.eth_call(functions.governor, []) + governor() { + return this.eth_call(functions.governor, {}) } - isGovernor(): Promise { - return this.eth_call(functions.isGovernor, []) + isGovernor() { + return this.eth_call(functions.isGovernor, {}) } - isUpgraded(arg0: string): Promise { - return this.eth_call(functions.isUpgraded, [arg0]) + isUpgraded(_0: IsUpgradedParams["_0"]) { + return this.eth_call(functions.isUpgraded, {_0}) } - name(): Promise { - return this.eth_call(functions.name, []) + name() { + return this.eth_call(functions.name, {}) } - nonRebasingCreditsPerToken(arg0: string): Promise { - return this.eth_call(functions.nonRebasingCreditsPerToken, [arg0]) + nonRebasingCreditsPerToken(_0: NonRebasingCreditsPerTokenParams["_0"]) { + return this.eth_call(functions.nonRebasingCreditsPerToken, {_0}) } - nonRebasingSupply(): Promise { - return this.eth_call(functions.nonRebasingSupply, []) + nonRebasingSupply() { + return this.eth_call(functions.nonRebasingSupply, {}) } - rebaseState(arg0: string): Promise { - return this.eth_call(functions.rebaseState, [arg0]) + rebaseState(_0: RebaseStateParams["_0"]) { + return this.eth_call(functions.rebaseState, {_0}) } - rebasingCredits(): Promise { - return this.eth_call(functions.rebasingCredits, []) + rebasingCredits() { + return this.eth_call(functions.rebasingCredits, {}) } - rebasingCreditsHighres(): Promise { - return this.eth_call(functions.rebasingCreditsHighres, []) + rebasingCreditsHighres() { + return this.eth_call(functions.rebasingCreditsHighres, {}) } - rebasingCreditsPerToken(): Promise { - return this.eth_call(functions.rebasingCreditsPerToken, []) + rebasingCreditsPerToken() { + return this.eth_call(functions.rebasingCreditsPerToken, {}) } - rebasingCreditsPerTokenHighres(): Promise { - return this.eth_call(functions.rebasingCreditsPerTokenHighres, []) + rebasingCreditsPerTokenHighres() { + return this.eth_call(functions.rebasingCreditsPerTokenHighres, {}) } - symbol(): Promise { - return this.eth_call(functions.symbol, []) + symbol() { + return this.eth_call(functions.symbol, {}) } - totalSupply(): Promise { - return this.eth_call(functions.totalSupply, []) + totalSupply() { + return this.eth_call(functions.totalSupply, {}) } - vaultAddress(): Promise { - return this.eth_call(functions.vaultAddress, []) + vaultAddress() { + return this.eth_call(functions.vaultAddress, {}) } } + +/// Event types +export type ApprovalEventArgs = EParams +export type GovernorshipTransferredEventArgs = EParams +export type PendingGovernorshipTransferEventArgs = EParams +export type TotalSupplyUpdatedHighresEventArgs = EParams +export type TransferEventArgs = EParams + +/// Function types +export type _totalSupplyParams = FunctionArguments +export type _totalSupplyReturn = FunctionReturn + +export type AllowanceParams = FunctionArguments +export type AllowanceReturn = FunctionReturn + +export type ApproveParams = FunctionArguments +export type ApproveReturn = FunctionReturn + +export type BalanceOfParams = FunctionArguments +export type BalanceOfReturn = FunctionReturn + +export type BurnParams = FunctionArguments +export type BurnReturn = FunctionReturn + +export type ChangeSupplyParams = FunctionArguments +export type ChangeSupplyReturn = FunctionReturn + +export type ClaimGovernanceParams = FunctionArguments +export type ClaimGovernanceReturn = FunctionReturn + +export type CreditsBalanceOfParams = FunctionArguments +export type CreditsBalanceOfReturn = FunctionReturn + +export type CreditsBalanceOfHighresParams = FunctionArguments +export type CreditsBalanceOfHighresReturn = FunctionReturn + +export type DecimalsParams = FunctionArguments +export type DecimalsReturn = FunctionReturn + +export type DecreaseAllowanceParams = FunctionArguments +export type DecreaseAllowanceReturn = FunctionReturn + +export type GovernorParams = FunctionArguments +export type GovernorReturn = FunctionReturn + +export type IncreaseAllowanceParams = FunctionArguments +export type IncreaseAllowanceReturn = FunctionReturn + +export type InitializeParams = FunctionArguments +export type InitializeReturn = FunctionReturn + +export type IsGovernorParams = FunctionArguments +export type IsGovernorReturn = FunctionReturn + +export type IsUpgradedParams = FunctionArguments +export type IsUpgradedReturn = FunctionReturn + +export type MintParams = FunctionArguments +export type MintReturn = FunctionReturn + +export type NameParams = FunctionArguments +export type NameReturn = FunctionReturn + +export type NonRebasingCreditsPerTokenParams = FunctionArguments +export type NonRebasingCreditsPerTokenReturn = FunctionReturn + +export type NonRebasingSupplyParams = FunctionArguments +export type NonRebasingSupplyReturn = FunctionReturn + +export type RebaseOptInParams = FunctionArguments +export type RebaseOptInReturn = FunctionReturn + +export type RebaseOptOutParams = FunctionArguments +export type RebaseOptOutReturn = FunctionReturn + +export type RebaseStateParams = FunctionArguments +export type RebaseStateReturn = FunctionReturn + +export type RebasingCreditsParams = FunctionArguments +export type RebasingCreditsReturn = FunctionReturn + +export type RebasingCreditsHighresParams = FunctionArguments +export type RebasingCreditsHighresReturn = FunctionReturn + +export type RebasingCreditsPerTokenParams = FunctionArguments +export type RebasingCreditsPerTokenReturn = FunctionReturn + +export type RebasingCreditsPerTokenHighresParams = FunctionArguments +export type RebasingCreditsPerTokenHighresReturn = FunctionReturn + +export type SymbolParams = FunctionArguments +export type SymbolReturn = FunctionReturn + +export type TotalSupplyParams = FunctionArguments +export type TotalSupplyReturn = FunctionReturn + +export type TransferParams = FunctionArguments +export type TransferReturn = FunctionReturn + +export type TransferFromParams = FunctionArguments +export type TransferFromReturn = FunctionReturn + +export type TransferGovernanceParams = FunctionArguments +export type TransferGovernanceReturn = FunctionReturn + +export type VaultAddressParams = FunctionArguments +export type VaultAddressReturn = FunctionReturn + diff --git a/src/abi/origin-lens.ts b/src/abi/origin-lens.ts index 55cbcda4..23d90f8b 100644 --- a/src/abi/origin-lens.ts +++ b/src/abi/origin-lens.ts @@ -1,149 +1,168 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './origin-lens.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - GovernorshipTransferred: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( - abi, '0xc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a' - ), - PendingGovernorshipTransfer: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( - abi, '0xa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d' - ), - StrategistUpdated: new LogEvent<([_address: string] & {_address: string})>( - abi, '0x869e0abd13cc3a975de7b93be3df1cb2255c802b1cead85963cc79d99f131bee' - ), - StrategyTypeChanged: new LogEvent<([strategyAddr: string, kind: number] & {strategyAddr: string, kind: number})>( - abi, '0x7fab7e3127613cf3a72eafc4bfcb3e179d35d1c69e1d0217c1dd029dc23690bd' - ), + GovernorshipTransferred: event("0xc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a", {"previousGovernor": indexed(p.address), "newGovernor": indexed(p.address)}), + PendingGovernorshipTransfer: event("0xa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d", {"previousGovernor": indexed(p.address), "newGovernor": indexed(p.address)}), + StrategistUpdated: event("0x869e0abd13cc3a975de7b93be3df1cb2255c802b1cead85963cc79d99f131bee", {"_address": p.address}), + StrategyTypeChanged: event("0x7fab7e3127613cf3a72eafc4bfcb3e179d35d1c69e1d0217c1dd029dc23690bd", {"strategyAddr": indexed(p.address), "kind": p.uint8}), } export const functions = { - ETH_ADDR: new Func<[], {}, string>( - abi, '0x7753f47b' - ), - WETH_ADDR: new Func<[], {}, string>( - abi, '0x82dfc5f7' - ), - assetCount: new Func<[], {}, bigint>( - abi, '0xeafe7a74' - ), - assets: new Func<[_: bigint], {}, string>( - abi, '0xcf35bdd0' - ), - cacheStrategies: new Func<[], {}, []>( - abi, '0x44f98829' - ), - claimGovernance: new Func<[], {}, []>( - abi, '0x5d36b190' - ), - curvePoolCoinCount: new Func<[_: string], {}, bigint>( - abi, '0xdd6640c3' - ), - getStrategyAssetBalance: new Func<[strategyAddr: string, asset: string], {strategyAddr: string, asset: string}, bigint>( - abi, '0x3a1d532b' - ), - getStrategyBalances: new Func<[strategyAddr: string], {strategyAddr: string}, ([supportedAssets: Array, assetBalances: Array] & {supportedAssets: Array, assetBalances: Array})>( - abi, '0xe50bf68f' - ), - governor: new Func<[], {}, string>( - abi, '0x0c340a24' - ), - initialize: new Func<[_strategistAddr: string, _strategies: Array, strategyKinds: Array], {_strategistAddr: string, _strategies: Array, strategyKinds: Array}, []>( - abi, '0xe336f8c5' - ), - isGovernor: new Func<[], {}, boolean>( - abi, '0xc7af3352' - ), - oToken: new Func<[], {}, string>( - abi, '0x1a32aad6' - ), - oracleRouter: new Func<[], {}, string>( - abi, '0x55a29e91' - ), - setStrategistAddr: new Func<[_address: string], {_address: string}, []>( - abi, '0x773540b3' - ), - setStrategyKind: new Func<[strategy: string, kind: number], {strategy: string, kind: number}, []>( - abi, '0xaefc61e0' - ), - strategies: new Func<[_: bigint], {}, string>( - abi, '0xd574ea3d' - ), - strategistAddr: new Func<[], {}, string>( - abi, '0x570d8e1d' - ), - strategyConfig: new Func<[_: string], {}, ([supported: boolean, kind: number] & {supported: boolean, kind: number})>( - abi, '0x91450e63' - ), - transferGovernance: new Func<[_newGovernor: string], {_newGovernor: string}, []>( - abi, '0xd38bfff4' - ), - vault: new Func<[], {}, string>( - abi, '0xfbfa77cf' - ), + ETH_ADDR: fun("0x7753f47b", {}, p.address), + WETH_ADDR: fun("0x82dfc5f7", {}, p.address), + assetCount: fun("0xeafe7a74", {}, p.uint256), + assets: fun("0xcf35bdd0", {"_0": p.uint256}, p.address), + cacheStrategies: fun("0x44f98829", {}, ), + claimGovernance: fun("0x5d36b190", {}, ), + curvePoolCoinCount: fun("0xdd6640c3", {"_0": p.address}, p.uint256), + getStrategyAssetBalance: fun("0x3a1d532b", {"strategyAddr": p.address, "asset": p.address}, p.uint256), + getStrategyBalances: fun("0xe50bf68f", {"strategyAddr": p.address}, {"supportedAssets": p.array(p.address), "assetBalances": p.array(p.uint256)}), + governor: fun("0x0c340a24", {}, p.address), + initialize: fun("0xe336f8c5", {"_strategistAddr": p.address, "_strategies": p.array(p.address), "strategyKinds": p.array(p.uint8)}, ), + isGovernor: fun("0xc7af3352", {}, p.bool), + oToken: fun("0x1a32aad6", {}, p.address), + oracleRouter: fun("0x55a29e91", {}, p.address), + setStrategistAddr: fun("0x773540b3", {"_address": p.address}, ), + setStrategyKind: fun("0xaefc61e0", {"strategy": p.address, "kind": p.uint8}, ), + strategies: fun("0xd574ea3d", {"_0": p.uint256}, p.address), + strategistAddr: fun("0x570d8e1d", {}, p.address), + strategyConfig: fun("0x91450e63", {"_0": p.address}, {"supported": p.bool, "kind": p.uint8}), + transferGovernance: fun("0xd38bfff4", {"_newGovernor": p.address}, ), + vault: fun("0xfbfa77cf", {}, p.address), } export class Contract extends ContractBase { - ETH_ADDR(): Promise { - return this.eth_call(functions.ETH_ADDR, []) + ETH_ADDR() { + return this.eth_call(functions.ETH_ADDR, {}) } - WETH_ADDR(): Promise { - return this.eth_call(functions.WETH_ADDR, []) + WETH_ADDR() { + return this.eth_call(functions.WETH_ADDR, {}) } - assetCount(): Promise { - return this.eth_call(functions.assetCount, []) + assetCount() { + return this.eth_call(functions.assetCount, {}) } - assets(arg0: bigint): Promise { - return this.eth_call(functions.assets, [arg0]) + assets(_0: AssetsParams["_0"]) { + return this.eth_call(functions.assets, {_0}) } - curvePoolCoinCount(arg0: string): Promise { - return this.eth_call(functions.curvePoolCoinCount, [arg0]) + curvePoolCoinCount(_0: CurvePoolCoinCountParams["_0"]) { + return this.eth_call(functions.curvePoolCoinCount, {_0}) } - getStrategyAssetBalance(strategyAddr: string, asset: string): Promise { - return this.eth_call(functions.getStrategyAssetBalance, [strategyAddr, asset]) + getStrategyAssetBalance(strategyAddr: GetStrategyAssetBalanceParams["strategyAddr"], asset: GetStrategyAssetBalanceParams["asset"]) { + return this.eth_call(functions.getStrategyAssetBalance, {strategyAddr, asset}) } - getStrategyBalances(strategyAddr: string): Promise<([supportedAssets: Array, assetBalances: Array] & {supportedAssets: Array, assetBalances: Array})> { - return this.eth_call(functions.getStrategyBalances, [strategyAddr]) + getStrategyBalances(strategyAddr: GetStrategyBalancesParams["strategyAddr"]) { + return this.eth_call(functions.getStrategyBalances, {strategyAddr}) } - governor(): Promise { - return this.eth_call(functions.governor, []) + governor() { + return this.eth_call(functions.governor, {}) } - isGovernor(): Promise { - return this.eth_call(functions.isGovernor, []) + isGovernor() { + return this.eth_call(functions.isGovernor, {}) } - oToken(): Promise { - return this.eth_call(functions.oToken, []) + oToken() { + return this.eth_call(functions.oToken, {}) } - oracleRouter(): Promise { - return this.eth_call(functions.oracleRouter, []) + oracleRouter() { + return this.eth_call(functions.oracleRouter, {}) } - strategies(arg0: bigint): Promise { - return this.eth_call(functions.strategies, [arg0]) + strategies(_0: StrategiesParams["_0"]) { + return this.eth_call(functions.strategies, {_0}) } - strategistAddr(): Promise { - return this.eth_call(functions.strategistAddr, []) + strategistAddr() { + return this.eth_call(functions.strategistAddr, {}) } - strategyConfig(arg0: string): Promise<([supported: boolean, kind: number] & {supported: boolean, kind: number})> { - return this.eth_call(functions.strategyConfig, [arg0]) + strategyConfig(_0: StrategyConfigParams["_0"]) { + return this.eth_call(functions.strategyConfig, {_0}) } - vault(): Promise { - return this.eth_call(functions.vault, []) + vault() { + return this.eth_call(functions.vault, {}) } } + +/// Event types +export type GovernorshipTransferredEventArgs = EParams +export type PendingGovernorshipTransferEventArgs = EParams +export type StrategistUpdatedEventArgs = EParams +export type StrategyTypeChangedEventArgs = EParams + +/// Function types +export type ETH_ADDRParams = FunctionArguments +export type ETH_ADDRReturn = FunctionReturn + +export type WETH_ADDRParams = FunctionArguments +export type WETH_ADDRReturn = FunctionReturn + +export type AssetCountParams = FunctionArguments +export type AssetCountReturn = FunctionReturn + +export type AssetsParams = FunctionArguments +export type AssetsReturn = FunctionReturn + +export type CacheStrategiesParams = FunctionArguments +export type CacheStrategiesReturn = FunctionReturn + +export type ClaimGovernanceParams = FunctionArguments +export type ClaimGovernanceReturn = FunctionReturn + +export type CurvePoolCoinCountParams = FunctionArguments +export type CurvePoolCoinCountReturn = FunctionReturn + +export type GetStrategyAssetBalanceParams = FunctionArguments +export type GetStrategyAssetBalanceReturn = FunctionReturn + +export type GetStrategyBalancesParams = FunctionArguments +export type GetStrategyBalancesReturn = FunctionReturn + +export type GovernorParams = FunctionArguments +export type GovernorReturn = FunctionReturn + +export type InitializeParams = FunctionArguments +export type InitializeReturn = FunctionReturn + +export type IsGovernorParams = FunctionArguments +export type IsGovernorReturn = FunctionReturn + +export type OTokenParams = FunctionArguments +export type OTokenReturn = FunctionReturn + +export type OracleRouterParams = FunctionArguments +export type OracleRouterReturn = FunctionReturn + +export type SetStrategistAddrParams = FunctionArguments +export type SetStrategistAddrReturn = FunctionReturn + +export type SetStrategyKindParams = FunctionArguments +export type SetStrategyKindReturn = FunctionReturn + +export type StrategiesParams = FunctionArguments +export type StrategiesReturn = FunctionReturn + +export type StrategistAddrParams = FunctionArguments +export type StrategistAddrReturn = FunctionReturn + +export type StrategyConfigParams = FunctionArguments +export type StrategyConfigReturn = FunctionReturn + +export type TransferGovernanceParams = FunctionArguments +export type TransferGovernanceReturn = FunctionReturn + +export type VaultParams = FunctionArguments +export type VaultReturn = FunctionReturn + diff --git a/src/abi/otoken-vault.ts b/src/abi/otoken-vault.ts index cea63d2a..e8615416 100644 --- a/src/abi/otoken-vault.ts +++ b/src/abi/otoken-vault.ts @@ -1,327 +1,338 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './otoken-vault.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' 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' - ), - SwapAllowedUndervalueChanged: new LogEvent<([_basis: bigint] & {_basis: bigint})>( - abi, '0xf12c00256bee2b6facb111a88a9b1cff86e79132939b44f1353212d6f7469557' - ), - SwapSlippageChanged: new LogEvent<([_asset: string, _basis: bigint] & {_asset: string, _basis: bigint})>( - abi, '0x8d22e9d2cbe8bb65a3c4412bd8970743864512a1a0e004e8d00fb96277b78b94' - ), - Swapped: new LogEvent<([_fromAsset: string, _toAsset: string, _fromAssetAmount: bigint, _toAssetAmount: bigint] & {_fromAsset: string, _toAsset: string, _fromAssetAmount: bigint, _toAssetAmount: bigint})>( - abi, '0xa078c4190abe07940190effc1846be0ccf03ad6007bc9e93f9697d0b460befbb' - ), - SwapperChanged: new LogEvent<([_address: string] & {_address: string})>( - abi, '0x7d7719313229e558c5a3893cad2eb86a86a049156d1d9ebd5c63a8eedefd1c03' - ), - 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' - ), + AllocateThresholdUpdated: event("0x2ec5fb5a3d2703edc461252d92ccd2799c3c74f01d97212b20388207fa17ae45", {"_threshold": p.uint256}), + AssetAllocated: event("0x41b99659f6ba0803f444aff29e5bf6e26dd86a3219aff92119d69710a956ba8d", {"_asset": p.address, "_strategy": p.address, "_amount": p.uint256}), + AssetDefaultStrategyUpdated: event("0xba58ce12801c949fa65f41c46ed108671c219baf945fa48d21026cea99ff252a", {"_asset": p.address, "_strategy": p.address}), + AssetSupported: event("0x4f1ac48525e50059cc1cc6e0e1940ece0dd653a4db4841538d6aef036be2fb7b", {"_asset": p.address}), + CapitalPaused: event("0x71f0e5b62f846a22e0b4d159e516e62fa9c2b8eb570be15f83e67d98a2ee51e0", {}), + CapitalUnpaused: event("0x891ebab18da80ebeeea06b1b1cede098329c4c008906a98370c2ac7a80b571cb", {}), + GovernorshipTransferred: event("0xc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a", {"previousGovernor": indexed(p.address), "newGovernor": indexed(p.address)}), + MaxSupplyDiffChanged: event("0x95201f9c21f26877223b1ff4073936a6484c35495649e60e55730497aeb60d93", {"maxSupplyDiff": p.uint256}), + Mint: event("0x0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885", {"_addr": p.address, "_value": p.uint256}), + NetOusdMintForStrategyThresholdChanged: event("0xc29d6fedbc6bdf267a08166c2b976fbd72aca5d6a769528616f8b9224c8f197f", {"_threshold": p.uint256}), + OusdMetaStrategyUpdated: event("0xa12850fb726e0b2b7b3c9a9342031e1268a8148d0eb06b4bea8613204ffcd2b8", {"_ousdMetaStrategy": p.address}), + PendingGovernorshipTransfer: event("0xa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d", {"previousGovernor": indexed(p.address), "newGovernor": indexed(p.address)}), + PriceProviderUpdated: event("0xb266add5f3044b17d27db796af992cecbe413921b4e8aaaee03c719e16b9806a", {"_priceProvider": p.address}), + RebasePaused: event("0x8cff26a5985614b3d30629cc4ab83824bf115aec971b718d8f2f99562032e972", {}), + RebaseThresholdUpdated: event("0x39367850377ac04920a9a670f2180e7a94d83b15ad302e59875ec58fd10bd37d", {"_threshold": p.uint256}), + RebaseUnpaused: event("0xbc044409505c95b6b851433df96e1beae715c909d8e7c1d6d7ab783300d4e3b9", {}), + Redeem: event("0x222838db2794d11532d940e8dec38ae307ed0b63cd97c233322e221f998767a6", {"_addr": p.address, "_value": p.uint256}), + RedeemFeeUpdated: event("0xd6c7508d6658ccee36b7b7d7fd72e5cbaeefb40c64eff24e9ae7470e846304ee", {"_redeemFeeBps": p.uint256}), + StrategistUpdated: event("0x869e0abd13cc3a975de7b93be3df1cb2255c802b1cead85963cc79d99f131bee", {"_address": p.address}), + StrategyApproved: event("0x960dd94cbb79169f09a4e445d58b895df2d9bffa5b31055d0932d801724a20d1", {"_addr": p.address}), + StrategyRemoved: event("0x09a1db4b80c32706328728508c941a6b954f31eb5affd32f236c1fd405f8fea4", {"_addr": p.address}), + SwapAllowedUndervalueChanged: event("0xf12c00256bee2b6facb111a88a9b1cff86e79132939b44f1353212d6f7469557", {"_basis": p.uint256}), + SwapSlippageChanged: event("0x8d22e9d2cbe8bb65a3c4412bd8970743864512a1a0e004e8d00fb96277b78b94", {"_asset": p.address, "_basis": p.uint256}), + Swapped: event("0xa078c4190abe07940190effc1846be0ccf03ad6007bc9e93f9697d0b460befbb", {"_fromAsset": indexed(p.address), "_toAsset": indexed(p.address), "_fromAssetAmount": p.uint256, "_toAssetAmount": p.uint256}), + SwapperChanged: event("0x7d7719313229e558c5a3893cad2eb86a86a049156d1d9ebd5c63a8eedefd1c03", {"_address": p.address}), + TrusteeAddressChanged: event("0x1e4af5ac389e8cde1bdaa6830881b6c987c62a45cfb3b33d27d805cde3b57750", {"_address": p.address}), + TrusteeFeeBpsChanged: event("0x56287a45051933ea374811b3d5d165033047be5572cac676f7c28b8be4f746c7", {"_basis": p.uint256}), + VaultBufferUpdated: event("0x41ecb23a0e7865b25f38c268b7c3012220d822929e9edff07326e89d5bb822b5", {"_vaultBuffer": p.uint256}), + YieldDistribution: event("0x09516ecf4a8a86e59780a9befc6dee948bc9e60a36e3be68d31ea817ee8d2c80", {"_to": p.address, "_yield": p.uint256, "_fee": p.uint256}), } export const functions = { - allocate: new Func<[], {}, []>( - abi, '0xabaa9916' - ), - assetDefaultStrategies: new Func<[_: string], {}, string>( - abi, '0xa403e4d5' - ), - autoAllocateThreshold: new Func<[], {}, bigint>( - abi, '0x9fa1826e' - ), - burnForStrategy: new Func<[_amount: bigint], {_amount: bigint}, []>( - abi, '0x6217f3ea' - ), - calculateRedeemOutputs: new Func<[_amount: bigint], {_amount: bigint}, Array>( - abi, '0x67bd7ba3' - ), - capitalPaused: new Func<[], {}, boolean>( - abi, '0xe6cc5432' - ), - checkBalance: new Func<[_asset: string], {_asset: string}, bigint>( - abi, '0x5f515226' - ), - claimGovernance: new Func<[], {}, []>( - abi, '0x5d36b190' - ), - getAllAssets: new Func<[], {}, Array>( - abi, '0x2acada4d' - ), - getAllStrategies: new Func<[], {}, Array>( - abi, '0xc3b28864' - ), - getAssetConfig: new Func<[_asset: string], {_asset: string}, ([isSupported: boolean, unitConversion: number, decimals: number, allowedOracleSlippageBps: number] & {isSupported: boolean, unitConversion: number, decimals: number, allowedOracleSlippageBps: number})>( - abi, '0x6ec3ab67' - ), - getAssetCount: new Func<[], {}, bigint>( - abi, '0xa0aead4d' - ), - getStrategyCount: new Func<[], {}, bigint>( - abi, '0x31e19cfa' - ), - governor: new Func<[], {}, string>( - abi, '0x0c340a24' - ), - isGovernor: new Func<[], {}, boolean>( - abi, '0xc7af3352' - ), - isSupportedAsset: new Func<[_asset: string], {_asset: string}, boolean>( - abi, '0x9be918e6' - ), - maxSupplyDiff: new Func<[], {}, bigint>( - abi, '0x8e510b52' - ), - mint: new Func<[_asset: string, _amount: bigint, _minimumOusdAmount: bigint], {_asset: string, _amount: bigint, _minimumOusdAmount: bigint}, []>( - abi, '0x156e29f6' - ), - mintForStrategy: new Func<[_amount: bigint], {_amount: bigint}, []>( - abi, '0xab80dafb' - ), - netOusdMintForStrategyThreshold: new Func<[], {}, bigint>( - abi, '0x7a2202f3' - ), - netOusdMintedForStrategy: new Func<[], {}, bigint>( - abi, '0xe45cc9f0' - ), - ousdMetaStrategy: new Func<[], {}, string>( - abi, '0x18ce56bd' - ), - priceProvider: new Func<[], {}, string>( - abi, '0xb888879e' - ), - priceUnitMint: new Func<[asset: string], {asset: string}, bigint>( - abi, '0x3b8fe28d' - ), - priceUnitRedeem: new Func<[asset: string], {asset: string}, bigint>( - abi, '0x5b60f9fc' - ), - rebase: new Func<[], {}, []>( - abi, '0xaf14052c' - ), - rebasePaused: new Func<[], {}, boolean>( - abi, '0x53ca9f24' - ), - rebaseThreshold: new Func<[], {}, bigint>( - abi, '0x52d38e5d' - ), - redeem: new Func<[_amount: bigint, _minimumUnitAmount: bigint], {_amount: bigint, _minimumUnitAmount: bigint}, []>( - abi, '0x7cbc2373' - ), - redeemAll: new Func<[_minimumUnitAmount: bigint], {_minimumUnitAmount: bigint}, []>( - abi, '0x7136a7a6' - ), - redeemFeeBps: new Func<[], {}, bigint>( - abi, '0x09f6442c' - ), - setAdminImpl: new Func<[newImpl: string], {newImpl: string}, []>( - abi, '0xfc0cfeee' - ), - strategistAddr: new Func<[], {}, string>( - abi, '0x570d8e1d' - ), - totalValue: new Func<[], {}, bigint>( - abi, '0xd4c3eea0' - ), - transferGovernance: new Func<[_newGovernor: string], {_newGovernor: string}, []>( - abi, '0xd38bfff4' - ), - trusteeAddress: new Func<[], {}, string>( - abi, '0x49c1d54d' - ), - trusteeFeeBps: new Func<[], {}, bigint>( - abi, '0x207134b0' - ), - vaultBuffer: new Func<[], {}, bigint>( - abi, '0x1edfe3da' - ), + allocate: fun("0xabaa9916", {}, ), + assetDefaultStrategies: fun("0xa403e4d5", {"_0": p.address}, p.address), + autoAllocateThreshold: fun("0x9fa1826e", {}, p.uint256), + burnForStrategy: fun("0x6217f3ea", {"_amount": p.uint256}, ), + calculateRedeemOutputs: fun("0x67bd7ba3", {"_amount": p.uint256}, p.array(p.uint256)), + capitalPaused: fun("0xe6cc5432", {}, p.bool), + checkBalance: fun("0x5f515226", {"_asset": p.address}, p.uint256), + claimGovernance: fun("0x5d36b190", {}, ), + getAllAssets: fun("0x2acada4d", {}, p.array(p.address)), + getAllStrategies: fun("0xc3b28864", {}, p.array(p.address)), + getAssetConfig: fun("0x6ec3ab67", {"_asset": p.address}, p.struct({"isSupported": p.bool, "unitConversion": p.uint8, "decimals": p.uint8, "allowedOracleSlippageBps": p.uint16})), + getAssetCount: fun("0xa0aead4d", {}, p.uint256), + getStrategyCount: fun("0x31e19cfa", {}, p.uint256), + governor: fun("0x0c340a24", {}, p.address), + isGovernor: fun("0xc7af3352", {}, p.bool), + isSupportedAsset: fun("0x9be918e6", {"_asset": p.address}, p.bool), + maxSupplyDiff: fun("0x8e510b52", {}, p.uint256), + mint: fun("0x156e29f6", {"_asset": p.address, "_amount": p.uint256, "_minimumOusdAmount": p.uint256}, ), + mintForStrategy: fun("0xab80dafb", {"_amount": p.uint256}, ), + netOusdMintForStrategyThreshold: fun("0x7a2202f3", {}, p.uint256), + netOusdMintedForStrategy: fun("0xe45cc9f0", {}, p.int256), + ousdMetaStrategy: fun("0x18ce56bd", {}, p.address), + priceProvider: fun("0xb888879e", {}, p.address), + priceUnitMint: fun("0x3b8fe28d", {"asset": p.address}, p.uint256), + priceUnitRedeem: fun("0x5b60f9fc", {"asset": p.address}, p.uint256), + rebase: fun("0xaf14052c", {}, ), + rebasePaused: fun("0x53ca9f24", {}, p.bool), + rebaseThreshold: fun("0x52d38e5d", {}, p.uint256), + redeem: fun("0x7cbc2373", {"_amount": p.uint256, "_minimumUnitAmount": p.uint256}, ), + redeemAll: fun("0x7136a7a6", {"_minimumUnitAmount": p.uint256}, ), + redeemFeeBps: fun("0x09f6442c", {}, p.uint256), + setAdminImpl: fun("0xfc0cfeee", {"newImpl": p.address}, ), + strategistAddr: fun("0x570d8e1d", {}, p.address), + totalValue: fun("0xd4c3eea0", {}, p.uint256), + transferGovernance: fun("0xd38bfff4", {"_newGovernor": p.address}, ), + trusteeAddress: fun("0x49c1d54d", {}, p.address), + trusteeFeeBps: fun("0x207134b0", {}, p.uint256), + vaultBuffer: fun("0x1edfe3da", {}, p.uint256), } export class Contract extends ContractBase { - assetDefaultStrategies(arg0: string): Promise { - return this.eth_call(functions.assetDefaultStrategies, [arg0]) + assetDefaultStrategies(_0: AssetDefaultStrategiesParams["_0"]) { + return this.eth_call(functions.assetDefaultStrategies, {_0}) } - autoAllocateThreshold(): Promise { - return this.eth_call(functions.autoAllocateThreshold, []) + autoAllocateThreshold() { + return this.eth_call(functions.autoAllocateThreshold, {}) } - calculateRedeemOutputs(_amount: bigint): Promise> { - return this.eth_call(functions.calculateRedeemOutputs, [_amount]) + calculateRedeemOutputs(_amount: CalculateRedeemOutputsParams["_amount"]) { + return this.eth_call(functions.calculateRedeemOutputs, {_amount}) } - capitalPaused(): Promise { - return this.eth_call(functions.capitalPaused, []) + capitalPaused() { + return this.eth_call(functions.capitalPaused, {}) } - checkBalance(_asset: string): Promise { - return this.eth_call(functions.checkBalance, [_asset]) + checkBalance(_asset: CheckBalanceParams["_asset"]) { + return this.eth_call(functions.checkBalance, {_asset}) } - getAllAssets(): Promise> { - return this.eth_call(functions.getAllAssets, []) + getAllAssets() { + return this.eth_call(functions.getAllAssets, {}) } - getAllStrategies(): Promise> { - return this.eth_call(functions.getAllStrategies, []) + getAllStrategies() { + return this.eth_call(functions.getAllStrategies, {}) } - getAssetConfig(_asset: string): Promise<([isSupported: boolean, unitConversion: number, decimals: number, allowedOracleSlippageBps: number] & {isSupported: boolean, unitConversion: number, decimals: number, allowedOracleSlippageBps: number})> { - return this.eth_call(functions.getAssetConfig, [_asset]) + getAssetConfig(_asset: GetAssetConfigParams["_asset"]) { + return this.eth_call(functions.getAssetConfig, {_asset}) } - getAssetCount(): Promise { - return this.eth_call(functions.getAssetCount, []) + getAssetCount() { + return this.eth_call(functions.getAssetCount, {}) } - getStrategyCount(): Promise { - return this.eth_call(functions.getStrategyCount, []) + getStrategyCount() { + return this.eth_call(functions.getStrategyCount, {}) } - governor(): Promise { - return this.eth_call(functions.governor, []) + governor() { + return this.eth_call(functions.governor, {}) } - isGovernor(): Promise { - return this.eth_call(functions.isGovernor, []) + isGovernor() { + return this.eth_call(functions.isGovernor, {}) } - isSupportedAsset(_asset: string): Promise { - return this.eth_call(functions.isSupportedAsset, [_asset]) + isSupportedAsset(_asset: IsSupportedAssetParams["_asset"]) { + return this.eth_call(functions.isSupportedAsset, {_asset}) } - maxSupplyDiff(): Promise { - return this.eth_call(functions.maxSupplyDiff, []) + maxSupplyDiff() { + return this.eth_call(functions.maxSupplyDiff, {}) } - netOusdMintForStrategyThreshold(): Promise { - return this.eth_call(functions.netOusdMintForStrategyThreshold, []) + netOusdMintForStrategyThreshold() { + return this.eth_call(functions.netOusdMintForStrategyThreshold, {}) } - netOusdMintedForStrategy(): Promise { - return this.eth_call(functions.netOusdMintedForStrategy, []) + netOusdMintedForStrategy() { + return this.eth_call(functions.netOusdMintedForStrategy, {}) } - ousdMetaStrategy(): Promise { - return this.eth_call(functions.ousdMetaStrategy, []) + ousdMetaStrategy() { + return this.eth_call(functions.ousdMetaStrategy, {}) } - priceProvider(): Promise { - return this.eth_call(functions.priceProvider, []) + priceProvider() { + return this.eth_call(functions.priceProvider, {}) } - priceUnitMint(asset: string): Promise { - return this.eth_call(functions.priceUnitMint, [asset]) + priceUnitMint(asset: PriceUnitMintParams["asset"]) { + return this.eth_call(functions.priceUnitMint, {asset}) } - priceUnitRedeem(asset: string): Promise { - return this.eth_call(functions.priceUnitRedeem, [asset]) + priceUnitRedeem(asset: PriceUnitRedeemParams["asset"]) { + return this.eth_call(functions.priceUnitRedeem, {asset}) } - rebasePaused(): Promise { - return this.eth_call(functions.rebasePaused, []) + rebasePaused() { + return this.eth_call(functions.rebasePaused, {}) } - rebaseThreshold(): Promise { - return this.eth_call(functions.rebaseThreshold, []) + rebaseThreshold() { + return this.eth_call(functions.rebaseThreshold, {}) } - redeemFeeBps(): Promise { - return this.eth_call(functions.redeemFeeBps, []) + redeemFeeBps() { + return this.eth_call(functions.redeemFeeBps, {}) } - strategistAddr(): Promise { - return this.eth_call(functions.strategistAddr, []) + strategistAddr() { + return this.eth_call(functions.strategistAddr, {}) } - totalValue(): Promise { - return this.eth_call(functions.totalValue, []) + totalValue() { + return this.eth_call(functions.totalValue, {}) } - trusteeAddress(): Promise { - return this.eth_call(functions.trusteeAddress, []) + trusteeAddress() { + return this.eth_call(functions.trusteeAddress, {}) } - trusteeFeeBps(): Promise { - return this.eth_call(functions.trusteeFeeBps, []) + trusteeFeeBps() { + return this.eth_call(functions.trusteeFeeBps, {}) } - vaultBuffer(): Promise { - return this.eth_call(functions.vaultBuffer, []) + vaultBuffer() { + return this.eth_call(functions.vaultBuffer, {}) } } + +/// Event types +export type AllocateThresholdUpdatedEventArgs = EParams +export type AssetAllocatedEventArgs = EParams +export type AssetDefaultStrategyUpdatedEventArgs = EParams +export type AssetSupportedEventArgs = EParams +export type CapitalPausedEventArgs = EParams +export type CapitalUnpausedEventArgs = EParams +export type GovernorshipTransferredEventArgs = EParams +export type MaxSupplyDiffChangedEventArgs = EParams +export type MintEventArgs = EParams +export type NetOusdMintForStrategyThresholdChangedEventArgs = EParams +export type OusdMetaStrategyUpdatedEventArgs = EParams +export type PendingGovernorshipTransferEventArgs = EParams +export type PriceProviderUpdatedEventArgs = EParams +export type RebasePausedEventArgs = EParams +export type RebaseThresholdUpdatedEventArgs = EParams +export type RebaseUnpausedEventArgs = EParams +export type RedeemEventArgs = EParams +export type RedeemFeeUpdatedEventArgs = EParams +export type StrategistUpdatedEventArgs = EParams +export type StrategyApprovedEventArgs = EParams +export type StrategyRemovedEventArgs = EParams +export type SwapAllowedUndervalueChangedEventArgs = EParams +export type SwapSlippageChangedEventArgs = EParams +export type SwappedEventArgs = EParams +export type SwapperChangedEventArgs = EParams +export type TrusteeAddressChangedEventArgs = EParams +export type TrusteeFeeBpsChangedEventArgs = EParams +export type VaultBufferUpdatedEventArgs = EParams +export type YieldDistributionEventArgs = EParams + +/// Function types +export type AllocateParams = FunctionArguments +export type AllocateReturn = FunctionReturn + +export type AssetDefaultStrategiesParams = FunctionArguments +export type AssetDefaultStrategiesReturn = FunctionReturn + +export type AutoAllocateThresholdParams = FunctionArguments +export type AutoAllocateThresholdReturn = FunctionReturn + +export type BurnForStrategyParams = FunctionArguments +export type BurnForStrategyReturn = FunctionReturn + +export type CalculateRedeemOutputsParams = FunctionArguments +export type CalculateRedeemOutputsReturn = FunctionReturn + +export type CapitalPausedParams = FunctionArguments +export type CapitalPausedReturn = FunctionReturn + +export type CheckBalanceParams = FunctionArguments +export type CheckBalanceReturn = FunctionReturn + +export type ClaimGovernanceParams = FunctionArguments +export type ClaimGovernanceReturn = FunctionReturn + +export type GetAllAssetsParams = FunctionArguments +export type GetAllAssetsReturn = FunctionReturn + +export type GetAllStrategiesParams = FunctionArguments +export type GetAllStrategiesReturn = FunctionReturn + +export type GetAssetConfigParams = FunctionArguments +export type GetAssetConfigReturn = FunctionReturn + +export type GetAssetCountParams = FunctionArguments +export type GetAssetCountReturn = FunctionReturn + +export type GetStrategyCountParams = FunctionArguments +export type GetStrategyCountReturn = FunctionReturn + +export type GovernorParams = FunctionArguments +export type GovernorReturn = FunctionReturn + +export type IsGovernorParams = FunctionArguments +export type IsGovernorReturn = FunctionReturn + +export type IsSupportedAssetParams = FunctionArguments +export type IsSupportedAssetReturn = FunctionReturn + +export type MaxSupplyDiffParams = FunctionArguments +export type MaxSupplyDiffReturn = FunctionReturn + +export type MintParams = FunctionArguments +export type MintReturn = FunctionReturn + +export type MintForStrategyParams = FunctionArguments +export type MintForStrategyReturn = FunctionReturn + +export type NetOusdMintForStrategyThresholdParams = FunctionArguments +export type NetOusdMintForStrategyThresholdReturn = FunctionReturn + +export type NetOusdMintedForStrategyParams = FunctionArguments +export type NetOusdMintedForStrategyReturn = FunctionReturn + +export type OusdMetaStrategyParams = FunctionArguments +export type OusdMetaStrategyReturn = FunctionReturn + +export type PriceProviderParams = FunctionArguments +export type PriceProviderReturn = FunctionReturn + +export type PriceUnitMintParams = FunctionArguments +export type PriceUnitMintReturn = FunctionReturn + +export type PriceUnitRedeemParams = FunctionArguments +export type PriceUnitRedeemReturn = FunctionReturn + +export type RebaseParams = FunctionArguments +export type RebaseReturn = FunctionReturn + +export type RebasePausedParams = FunctionArguments +export type RebasePausedReturn = FunctionReturn + +export type RebaseThresholdParams = FunctionArguments +export type RebaseThresholdReturn = FunctionReturn + +export type RedeemParams = FunctionArguments +export type RedeemReturn = FunctionReturn + +export type RedeemAllParams = FunctionArguments +export type RedeemAllReturn = FunctionReturn + +export type RedeemFeeBpsParams = FunctionArguments +export type RedeemFeeBpsReturn = FunctionReturn + +export type SetAdminImplParams = FunctionArguments +export type SetAdminImplReturn = FunctionReturn + +export type StrategistAddrParams = FunctionArguments +export type StrategistAddrReturn = FunctionReturn + +export type TotalValueParams = FunctionArguments +export type TotalValueReturn = FunctionReturn + +export type TransferGovernanceParams = FunctionArguments +export type TransferGovernanceReturn = FunctionReturn + +export type TrusteeAddressParams = FunctionArguments +export type TrusteeAddressReturn = FunctionReturn + +export type TrusteeFeeBpsParams = FunctionArguments +export type TrusteeFeeBpsReturn = FunctionReturn + +export type VaultBufferParams = FunctionArguments +export type VaultBufferReturn = FunctionReturn + diff --git a/src/abi/otoken.ts b/src/abi/otoken.ts index 82d9c674..423009a1 100644 --- a/src/abi/otoken.ts +++ b/src/abi/otoken.ts @@ -1,217 +1,246 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './otoken.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - AccountRebasingDisabled: new LogEvent<([account: string] & {account: string})>( - abi, '0x201ace89ad3f5ab7428b91989f6a50d1998791c7b94a0fa812fd64a57687165e' - ), - AccountRebasingEnabled: new LogEvent<([account: string] & {account: string})>( - abi, '0x19a249fa2050bac8314ac10e3ad420bd9825574bf750f58810c3c7adfc7b1c6f' - ), - Approval: new LogEvent<([owner: string, spender: string, value: bigint] & {owner: string, spender: string, value: bigint})>( - abi, '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925' - ), - GovernorshipTransferred: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( - abi, '0xc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a' - ), - PendingGovernorshipTransfer: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( - abi, '0xa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d' - ), - TotalSupplyUpdatedHighres: new LogEvent<([totalSupply: bigint, rebasingCredits: bigint, rebasingCreditsPerToken: bigint] & {totalSupply: bigint, rebasingCredits: bigint, rebasingCreditsPerToken: bigint})>( - abi, '0x41645eb819d3011b13f97696a8109d14bfcddfaca7d063ec0564d62a3e257235' - ), - Transfer: new LogEvent<([from: string, to: string, value: bigint] & {from: string, to: string, value: bigint})>( - abi, '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' - ), + AccountRebasingDisabled: event("0x201ace89ad3f5ab7428b91989f6a50d1998791c7b94a0fa812fd64a57687165e", {"account": p.address}), + AccountRebasingEnabled: event("0x19a249fa2050bac8314ac10e3ad420bd9825574bf750f58810c3c7adfc7b1c6f", {"account": p.address}), + Approval: event("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", {"owner": indexed(p.address), "spender": indexed(p.address), "value": p.uint256}), + GovernorshipTransferred: event("0xc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a", {"previousGovernor": indexed(p.address), "newGovernor": indexed(p.address)}), + PendingGovernorshipTransfer: event("0xa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d", {"previousGovernor": indexed(p.address), "newGovernor": indexed(p.address)}), + TotalSupplyUpdatedHighres: event("0x41645eb819d3011b13f97696a8109d14bfcddfaca7d063ec0564d62a3e257235", {"totalSupply": p.uint256, "rebasingCredits": p.uint256, "rebasingCreditsPerToken": p.uint256}), + Transfer: event("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", {"from": indexed(p.address), "to": indexed(p.address), "value": p.uint256}), } export const functions = { - _totalSupply: new Func<[], {}, bigint>( - abi, '0x3eaaf86b' - ), - allowance: new Func<[_owner: string, _spender: string], {_owner: string, _spender: string}, bigint>( - abi, '0xdd62ed3e' - ), - approve: new Func<[_spender: string, _value: bigint], {_spender: string, _value: bigint}, boolean>( - abi, '0x095ea7b3' - ), - balanceOf: new Func<[_account: string], {_account: string}, bigint>( - abi, '0x70a08231' - ), - burn: new Func<[account: string, amount: bigint], {account: string, amount: bigint}, []>( - abi, '0x9dc29fac' - ), - changeSupply: new Func<[_newTotalSupply: bigint], {_newTotalSupply: bigint}, []>( - abi, '0x39a7919f' - ), - claimGovernance: new Func<[], {}, []>( - abi, '0x5d36b190' - ), - creditsBalanceOf: new Func<[_account: string], {_account: string}, [_: bigint, _: bigint]>( - abi, '0xf9854bfc' - ), - creditsBalanceOfHighres: new Func<[_account: string], {_account: string}, [_: bigint, _: bigint, _: boolean]>( - abi, '0xe5c4fffe' - ), - decimals: new Func<[], {}, number>( - abi, '0x313ce567' - ), - decreaseAllowance: new Func<[_spender: string, _subtractedValue: bigint], {_spender: string, _subtractedValue: bigint}, boolean>( - abi, '0xa457c2d7' - ), - governanceRebaseOptIn: new Func<[_account: string], {_account: string}, []>( - abi, '0xbaa9c9db' - ), - governor: new Func<[], {}, string>( - abi, '0x0c340a24' - ), - increaseAllowance: new Func<[_spender: string, _addedValue: bigint], {_spender: string, _addedValue: bigint}, boolean>( - abi, '0x39509351' - ), - initialize: new Func<[_nameArg: string, _symbolArg: string, _vaultAddress: string, _initialCreditsPerToken: bigint], {_nameArg: string, _symbolArg: string, _vaultAddress: string, _initialCreditsPerToken: bigint}, []>( - abi, '0xf542033f' - ), - isGovernor: new Func<[], {}, boolean>( - abi, '0xc7af3352' - ), - isUpgraded: new Func<[_: string], {}, bigint>( - abi, '0x95ef84b9' - ), - mint: new Func<[_account: string, _amount: bigint], {_account: string, _amount: bigint}, []>( - abi, '0x40c10f19' - ), - name: new Func<[], {}, string>( - abi, '0x06fdde03' - ), - nonRebasingCreditsPerToken: new Func<[_: string], {}, bigint>( - abi, '0x609350cd' - ), - nonRebasingSupply: new Func<[], {}, bigint>( - abi, '0xe696393a' - ), - rebaseOptIn: new Func<[], {}, []>( - abi, '0xf51b0fd4' - ), - rebaseOptOut: new Func<[], {}, []>( - abi, '0xc2376dff' - ), - rebaseState: new Func<[_: string], {}, number>( - abi, '0x456ee286' - ), - rebasingCredits: new Func<[], {}, bigint>( - abi, '0x077f22b7' - ), - rebasingCreditsHighres: new Func<[], {}, bigint>( - abi, '0x7d0d66ff' - ), - rebasingCreditsPerToken: new Func<[], {}, bigint>( - abi, '0x6691cb3d' - ), - rebasingCreditsPerTokenHighres: new Func<[], {}, bigint>( - abi, '0x7a46a9c5' - ), - symbol: new Func<[], {}, string>( - abi, '0x95d89b41' - ), - totalSupply: new Func<[], {}, bigint>( - abi, '0x18160ddd' - ), - transfer: new Func<[_to: string, _value: bigint], {_to: string, _value: bigint}, boolean>( - abi, '0xa9059cbb' - ), - transferFrom: new Func<[_from: string, _to: string, _value: bigint], {_from: string, _to: string, _value: bigint}, boolean>( - abi, '0x23b872dd' - ), - transferGovernance: new Func<[_newGovernor: string], {_newGovernor: string}, []>( - abi, '0xd38bfff4' - ), - vaultAddress: new Func<[], {}, string>( - abi, '0x430bf08a' - ), + _totalSupply: fun("0x3eaaf86b", {}, p.uint256), + allowance: fun("0xdd62ed3e", {"_owner": p.address, "_spender": p.address}, p.uint256), + approve: fun("0x095ea7b3", {"_spender": p.address, "_value": p.uint256}, p.bool), + balanceOf: fun("0x70a08231", {"_account": p.address}, p.uint256), + burn: fun("0x9dc29fac", {"account": p.address, "amount": p.uint256}, ), + changeSupply: fun("0x39a7919f", {"_newTotalSupply": p.uint256}, ), + claimGovernance: fun("0x5d36b190", {}, ), + creditsBalanceOf: fun("0xf9854bfc", {"_account": p.address}, {"_0": p.uint256, "_1": p.uint256}), + creditsBalanceOfHighres: fun("0xe5c4fffe", {"_account": p.address}, {"_0": p.uint256, "_1": p.uint256, "_2": p.bool}), + decimals: fun("0x313ce567", {}, p.uint8), + decreaseAllowance: fun("0xa457c2d7", {"_spender": p.address, "_subtractedValue": p.uint256}, p.bool), + governanceRebaseOptIn: fun("0xbaa9c9db", {"_account": p.address}, ), + governor: fun("0x0c340a24", {}, p.address), + increaseAllowance: fun("0x39509351", {"_spender": p.address, "_addedValue": p.uint256}, p.bool), + initialize: fun("0xf542033f", {"_nameArg": p.string, "_symbolArg": p.string, "_vaultAddress": p.address, "_initialCreditsPerToken": p.uint256}, ), + isGovernor: fun("0xc7af3352", {}, p.bool), + isUpgraded: fun("0x95ef84b9", {"_0": p.address}, p.uint256), + mint: fun("0x40c10f19", {"_account": p.address, "_amount": p.uint256}, ), + name: fun("0x06fdde03", {}, p.string), + nonRebasingCreditsPerToken: fun("0x609350cd", {"_0": p.address}, p.uint256), + nonRebasingSupply: fun("0xe696393a", {}, p.uint256), + rebaseOptIn: fun("0xf51b0fd4", {}, ), + rebaseOptOut: fun("0xc2376dff", {}, ), + rebaseState: fun("0x456ee286", {"_0": p.address}, p.uint8), + rebasingCredits: fun("0x077f22b7", {}, p.uint256), + rebasingCreditsHighres: fun("0x7d0d66ff", {}, p.uint256), + rebasingCreditsPerToken: fun("0x6691cb3d", {}, p.uint256), + rebasingCreditsPerTokenHighres: fun("0x7a46a9c5", {}, p.uint256), + symbol: fun("0x95d89b41", {}, p.string), + totalSupply: fun("0x18160ddd", {}, p.uint256), + transfer: fun("0xa9059cbb", {"_to": p.address, "_value": p.uint256}, p.bool), + transferFrom: fun("0x23b872dd", {"_from": p.address, "_to": p.address, "_value": p.uint256}, p.bool), + transferGovernance: fun("0xd38bfff4", {"_newGovernor": p.address}, ), + vaultAddress: fun("0x430bf08a", {}, p.address), } export class Contract extends ContractBase { - _totalSupply(): Promise { - return this.eth_call(functions._totalSupply, []) + _totalSupply() { + return this.eth_call(functions._totalSupply, {}) } - allowance(_owner: string, _spender: string): Promise { - return this.eth_call(functions.allowance, [_owner, _spender]) + allowance(_owner: AllowanceParams["_owner"], _spender: AllowanceParams["_spender"]) { + return this.eth_call(functions.allowance, {_owner, _spender}) } - balanceOf(_account: string): Promise { - return this.eth_call(functions.balanceOf, [_account]) + balanceOf(_account: BalanceOfParams["_account"]) { + return this.eth_call(functions.balanceOf, {_account}) } - creditsBalanceOf(_account: string): Promise<[_: bigint, _: bigint]> { - return this.eth_call(functions.creditsBalanceOf, [_account]) + creditsBalanceOf(_account: CreditsBalanceOfParams["_account"]) { + return this.eth_call(functions.creditsBalanceOf, {_account}) } - creditsBalanceOfHighres(_account: string): Promise<[_: bigint, _: bigint, _: boolean]> { - return this.eth_call(functions.creditsBalanceOfHighres, [_account]) + creditsBalanceOfHighres(_account: CreditsBalanceOfHighresParams["_account"]) { + return this.eth_call(functions.creditsBalanceOfHighres, {_account}) } - decimals(): Promise { - return this.eth_call(functions.decimals, []) + decimals() { + return this.eth_call(functions.decimals, {}) } - governor(): Promise { - return this.eth_call(functions.governor, []) + governor() { + return this.eth_call(functions.governor, {}) } - isGovernor(): Promise { - return this.eth_call(functions.isGovernor, []) + isGovernor() { + return this.eth_call(functions.isGovernor, {}) } - isUpgraded(arg0: string): Promise { - return this.eth_call(functions.isUpgraded, [arg0]) + isUpgraded(_0: IsUpgradedParams["_0"]) { + return this.eth_call(functions.isUpgraded, {_0}) } - name(): Promise { - return this.eth_call(functions.name, []) + name() { + return this.eth_call(functions.name, {}) } - nonRebasingCreditsPerToken(arg0: string): Promise { - return this.eth_call(functions.nonRebasingCreditsPerToken, [arg0]) + nonRebasingCreditsPerToken(_0: NonRebasingCreditsPerTokenParams["_0"]) { + return this.eth_call(functions.nonRebasingCreditsPerToken, {_0}) } - nonRebasingSupply(): Promise { - return this.eth_call(functions.nonRebasingSupply, []) + nonRebasingSupply() { + return this.eth_call(functions.nonRebasingSupply, {}) } - rebaseState(arg0: string): Promise { - return this.eth_call(functions.rebaseState, [arg0]) + rebaseState(_0: RebaseStateParams["_0"]) { + return this.eth_call(functions.rebaseState, {_0}) } - rebasingCredits(): Promise { - return this.eth_call(functions.rebasingCredits, []) + rebasingCredits() { + return this.eth_call(functions.rebasingCredits, {}) } - rebasingCreditsHighres(): Promise { - return this.eth_call(functions.rebasingCreditsHighres, []) + rebasingCreditsHighres() { + return this.eth_call(functions.rebasingCreditsHighres, {}) } - rebasingCreditsPerToken(): Promise { - return this.eth_call(functions.rebasingCreditsPerToken, []) + rebasingCreditsPerToken() { + return this.eth_call(functions.rebasingCreditsPerToken, {}) } - rebasingCreditsPerTokenHighres(): Promise { - return this.eth_call(functions.rebasingCreditsPerTokenHighres, []) + rebasingCreditsPerTokenHighres() { + return this.eth_call(functions.rebasingCreditsPerTokenHighres, {}) } - symbol(): Promise { - return this.eth_call(functions.symbol, []) + symbol() { + return this.eth_call(functions.symbol, {}) } - totalSupply(): Promise { - return this.eth_call(functions.totalSupply, []) + totalSupply() { + return this.eth_call(functions.totalSupply, {}) } - vaultAddress(): Promise { - return this.eth_call(functions.vaultAddress, []) + vaultAddress() { + return this.eth_call(functions.vaultAddress, {}) } } + +/// Event types +export type AccountRebasingDisabledEventArgs = EParams +export type AccountRebasingEnabledEventArgs = EParams +export type ApprovalEventArgs = EParams +export type GovernorshipTransferredEventArgs = EParams +export type PendingGovernorshipTransferEventArgs = EParams +export type TotalSupplyUpdatedHighresEventArgs = EParams +export type TransferEventArgs = EParams + +/// Function types +export type _totalSupplyParams = FunctionArguments +export type _totalSupplyReturn = FunctionReturn + +export type AllowanceParams = FunctionArguments +export type AllowanceReturn = FunctionReturn + +export type ApproveParams = FunctionArguments +export type ApproveReturn = FunctionReturn + +export type BalanceOfParams = FunctionArguments +export type BalanceOfReturn = FunctionReturn + +export type BurnParams = FunctionArguments +export type BurnReturn = FunctionReturn + +export type ChangeSupplyParams = FunctionArguments +export type ChangeSupplyReturn = FunctionReturn + +export type ClaimGovernanceParams = FunctionArguments +export type ClaimGovernanceReturn = FunctionReturn + +export type CreditsBalanceOfParams = FunctionArguments +export type CreditsBalanceOfReturn = FunctionReturn + +export type CreditsBalanceOfHighresParams = FunctionArguments +export type CreditsBalanceOfHighresReturn = FunctionReturn + +export type DecimalsParams = FunctionArguments +export type DecimalsReturn = FunctionReturn + +export type DecreaseAllowanceParams = FunctionArguments +export type DecreaseAllowanceReturn = FunctionReturn + +export type GovernanceRebaseOptInParams = FunctionArguments +export type GovernanceRebaseOptInReturn = FunctionReturn + +export type GovernorParams = FunctionArguments +export type GovernorReturn = FunctionReturn + +export type IncreaseAllowanceParams = FunctionArguments +export type IncreaseAllowanceReturn = FunctionReturn + +export type InitializeParams = FunctionArguments +export type InitializeReturn = FunctionReturn + +export type IsGovernorParams = FunctionArguments +export type IsGovernorReturn = FunctionReturn + +export type IsUpgradedParams = FunctionArguments +export type IsUpgradedReturn = FunctionReturn + +export type MintParams = FunctionArguments +export type MintReturn = FunctionReturn + +export type NameParams = FunctionArguments +export type NameReturn = FunctionReturn + +export type NonRebasingCreditsPerTokenParams = FunctionArguments +export type NonRebasingCreditsPerTokenReturn = FunctionReturn + +export type NonRebasingSupplyParams = FunctionArguments +export type NonRebasingSupplyReturn = FunctionReturn + +export type RebaseOptInParams = FunctionArguments +export type RebaseOptInReturn = FunctionReturn + +export type RebaseOptOutParams = FunctionArguments +export type RebaseOptOutReturn = FunctionReturn + +export type RebaseStateParams = FunctionArguments +export type RebaseStateReturn = FunctionReturn + +export type RebasingCreditsParams = FunctionArguments +export type RebasingCreditsReturn = FunctionReturn + +export type RebasingCreditsHighresParams = FunctionArguments +export type RebasingCreditsHighresReturn = FunctionReturn + +export type RebasingCreditsPerTokenParams = FunctionArguments +export type RebasingCreditsPerTokenReturn = FunctionReturn + +export type RebasingCreditsPerTokenHighresParams = FunctionArguments +export type RebasingCreditsPerTokenHighresReturn = FunctionReturn + +export type SymbolParams = FunctionArguments +export type SymbolReturn = FunctionReturn + +export type TotalSupplyParams = FunctionArguments +export type TotalSupplyReturn = FunctionReturn + +export type TransferParams = FunctionArguments +export type TransferReturn = FunctionReturn + +export type TransferFromParams = FunctionArguments +export type TransferFromReturn = FunctionReturn + +export type TransferGovernanceParams = FunctionArguments +export type TransferGovernanceReturn = FunctionReturn + +export type VaultAddressParams = FunctionArguments +export type VaultAddressReturn = FunctionReturn + diff --git a/src/abi/sfrx-eth.ts b/src/abi/sfrx-eth.ts index cc20f44d..c3411386 100644 --- a/src/abi/sfrx-eth.ts +++ b/src/abi/sfrx-eth.ts @@ -1,234 +1,266 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './sfrx-eth.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - Approval: new LogEvent<([owner: string, spender: string, amount: bigint] & {owner: string, spender: string, amount: bigint})>( - abi, '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925' - ), - Deposit: new LogEvent<([caller: string, owner: string, assets: bigint, shares: bigint] & {caller: string, owner: string, assets: bigint, shares: bigint})>( - abi, '0xdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7' - ), - NewRewardsCycle: new LogEvent<([cycleEnd: number, rewardAmount: bigint] & {cycleEnd: number, rewardAmount: bigint})>( - abi, '0x2fa39aac60d1c94cda4ab0e86ae9c0ffab5b926e5b827a4ccba1d9b5b2ef596e' - ), - Transfer: new LogEvent<([from: string, to: string, amount: bigint] & {from: string, to: string, amount: bigint})>( - abi, '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' - ), - Withdraw: new LogEvent<([caller: string, receiver: string, owner: string, assets: bigint, shares: bigint] & {caller: string, receiver: string, owner: string, assets: bigint, shares: bigint})>( - abi, '0xfbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db' - ), + Approval: event("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", {"owner": indexed(p.address), "spender": indexed(p.address), "amount": p.uint256}), + Deposit: event("0xdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7", {"caller": indexed(p.address), "owner": indexed(p.address), "assets": p.uint256, "shares": p.uint256}), + NewRewardsCycle: event("0x2fa39aac60d1c94cda4ab0e86ae9c0ffab5b926e5b827a4ccba1d9b5b2ef596e", {"cycleEnd": indexed(p.uint32), "rewardAmount": p.uint256}), + Transfer: event("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", {"from": indexed(p.address), "to": indexed(p.address), "amount": p.uint256}), + Withdraw: event("0xfbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db", {"caller": indexed(p.address), "receiver": indexed(p.address), "owner": indexed(p.address), "assets": p.uint256, "shares": p.uint256}), } export const functions = { - DOMAIN_SEPARATOR: new Func<[], {}, string>( - abi, '0x3644e515' - ), - allowance: new Func<[_: string, _: string], {}, bigint>( - abi, '0xdd62ed3e' - ), - approve: new Func<[spender: string, amount: bigint], {spender: string, amount: bigint}, boolean>( - abi, '0x095ea7b3' - ), - asset: new Func<[], {}, string>( - abi, '0x38d52e0f' - ), - balanceOf: new Func<[_: string], {}, bigint>( - abi, '0x70a08231' - ), - convertToAssets: new Func<[shares: bigint], {shares: bigint}, bigint>( - abi, '0x07a2d13a' - ), - convertToShares: new Func<[assets: bigint], {assets: bigint}, bigint>( - abi, '0xc6e6f592' - ), - decimals: new Func<[], {}, number>( - abi, '0x313ce567' - ), - deposit: new Func<[assets: bigint, receiver: string], {assets: bigint, receiver: string}, bigint>( - abi, '0x6e553f65' - ), - depositWithSignature: new Func<[assets: bigint, receiver: string, deadline: bigint, approveMax: boolean, v: number, r: string, s: string], {assets: bigint, receiver: string, deadline: bigint, approveMax: boolean, v: number, r: string, s: string}, bigint>( - abi, '0x75e077c3' - ), - lastRewardAmount: new Func<[], {}, bigint>( - abi, '0xbafedcaa' - ), - lastSync: new Func<[], {}, number>( - abi, '0x6917516b' - ), - maxDeposit: new Func<[_: string], {}, bigint>( - abi, '0x402d267d' - ), - maxMint: new Func<[_: string], {}, bigint>( - abi, '0xc63d75b6' - ), - maxRedeem: new Func<[owner: string], {owner: string}, bigint>( - abi, '0xd905777e' - ), - maxWithdraw: new Func<[owner: string], {owner: string}, bigint>( - abi, '0xce96cb77' - ), - mint: new Func<[shares: bigint, receiver: string], {shares: bigint, receiver: string}, bigint>( - abi, '0x94bf804d' - ), - name: new Func<[], {}, string>( - abi, '0x06fdde03' - ), - nonces: new Func<[_: string], {}, bigint>( - abi, '0x7ecebe00' - ), - permit: new Func<[owner: string, spender: string, value: bigint, deadline: bigint, v: number, r: string, s: string], {owner: string, spender: string, value: bigint, deadline: bigint, v: number, r: string, s: string}, []>( - abi, '0xd505accf' - ), - previewDeposit: new Func<[assets: bigint], {assets: bigint}, bigint>( - abi, '0xef8b30f7' - ), - previewMint: new Func<[shares: bigint], {shares: bigint}, bigint>( - abi, '0xb3d7f6b9' - ), - previewRedeem: new Func<[shares: bigint], {shares: bigint}, bigint>( - abi, '0x4cdad506' - ), - previewWithdraw: new Func<[assets: bigint], {assets: bigint}, bigint>( - abi, '0x0a28a477' - ), - pricePerShare: new Func<[], {}, bigint>( - abi, '0x99530b06' - ), - redeem: new Func<[shares: bigint, receiver: string, owner: string], {shares: bigint, receiver: string, owner: string}, bigint>( - abi, '0xba087652' - ), - rewardsCycleEnd: new Func<[], {}, number>( - abi, '0xe7ff69f1' - ), - rewardsCycleLength: new Func<[], {}, number>( - abi, '0x6fcf5e5f' - ), - symbol: new Func<[], {}, string>( - abi, '0x95d89b41' - ), - syncRewards: new Func<[], {}, []>( - abi, '0x72c0c211' - ), - totalAssets: new Func<[], {}, bigint>( - abi, '0x01e1d114' - ), - totalSupply: new Func<[], {}, bigint>( - abi, '0x18160ddd' - ), - transfer: new Func<[to: string, amount: bigint], {to: string, amount: bigint}, boolean>( - abi, '0xa9059cbb' - ), - transferFrom: new Func<[from: string, to: string, amount: bigint], {from: string, to: string, amount: bigint}, boolean>( - abi, '0x23b872dd' - ), - withdraw: new Func<[assets: bigint, receiver: string, owner: string], {assets: bigint, receiver: string, owner: string}, bigint>( - abi, '0xb460af94' - ), + DOMAIN_SEPARATOR: fun("0x3644e515", {}, p.bytes32), + allowance: fun("0xdd62ed3e", {"_0": p.address, "_1": p.address}, p.uint256), + approve: fun("0x095ea7b3", {"spender": p.address, "amount": p.uint256}, p.bool), + asset: fun("0x38d52e0f", {}, p.address), + balanceOf: fun("0x70a08231", {"_0": p.address}, p.uint256), + convertToAssets: fun("0x07a2d13a", {"shares": p.uint256}, p.uint256), + convertToShares: fun("0xc6e6f592", {"assets": p.uint256}, p.uint256), + decimals: fun("0x313ce567", {}, p.uint8), + deposit: fun("0x6e553f65", {"assets": p.uint256, "receiver": p.address}, p.uint256), + depositWithSignature: fun("0x75e077c3", {"assets": p.uint256, "receiver": p.address, "deadline": p.uint256, "approveMax": p.bool, "v": p.uint8, "r": p.bytes32, "s": p.bytes32}, p.uint256), + lastRewardAmount: fun("0xbafedcaa", {}, p.uint192), + lastSync: fun("0x6917516b", {}, p.uint32), + maxDeposit: fun("0x402d267d", {"_0": p.address}, p.uint256), + maxMint: fun("0xc63d75b6", {"_0": p.address}, p.uint256), + maxRedeem: fun("0xd905777e", {"owner": p.address}, p.uint256), + maxWithdraw: fun("0xce96cb77", {"owner": p.address}, p.uint256), + mint: fun("0x94bf804d", {"shares": p.uint256, "receiver": p.address}, p.uint256), + name: fun("0x06fdde03", {}, p.string), + nonces: fun("0x7ecebe00", {"_0": p.address}, p.uint256), + permit: fun("0xd505accf", {"owner": p.address, "spender": p.address, "value": p.uint256, "deadline": p.uint256, "v": p.uint8, "r": p.bytes32, "s": p.bytes32}, ), + previewDeposit: fun("0xef8b30f7", {"assets": p.uint256}, p.uint256), + previewMint: fun("0xb3d7f6b9", {"shares": p.uint256}, p.uint256), + previewRedeem: fun("0x4cdad506", {"shares": p.uint256}, p.uint256), + previewWithdraw: fun("0x0a28a477", {"assets": p.uint256}, p.uint256), + pricePerShare: fun("0x99530b06", {}, p.uint256), + redeem: fun("0xba087652", {"shares": p.uint256, "receiver": p.address, "owner": p.address}, p.uint256), + rewardsCycleEnd: fun("0xe7ff69f1", {}, p.uint32), + rewardsCycleLength: fun("0x6fcf5e5f", {}, p.uint32), + symbol: fun("0x95d89b41", {}, p.string), + syncRewards: fun("0x72c0c211", {}, ), + totalAssets: fun("0x01e1d114", {}, p.uint256), + totalSupply: fun("0x18160ddd", {}, p.uint256), + transfer: fun("0xa9059cbb", {"to": p.address, "amount": p.uint256}, p.bool), + transferFrom: fun("0x23b872dd", {"from": p.address, "to": p.address, "amount": p.uint256}, p.bool), + withdraw: fun("0xb460af94", {"assets": p.uint256, "receiver": p.address, "owner": p.address}, p.uint256), } export class Contract extends ContractBase { - DOMAIN_SEPARATOR(): Promise { - return this.eth_call(functions.DOMAIN_SEPARATOR, []) + DOMAIN_SEPARATOR() { + return this.eth_call(functions.DOMAIN_SEPARATOR, {}) } - allowance(arg0: string, arg1: string): Promise { - return this.eth_call(functions.allowance, [arg0, arg1]) + allowance(_0: AllowanceParams["_0"], _1: AllowanceParams["_1"]) { + return this.eth_call(functions.allowance, {_0, _1}) } - asset(): Promise { - return this.eth_call(functions.asset, []) + asset() { + return this.eth_call(functions.asset, {}) } - balanceOf(arg0: string): Promise { - return this.eth_call(functions.balanceOf, [arg0]) + balanceOf(_0: BalanceOfParams["_0"]) { + return this.eth_call(functions.balanceOf, {_0}) } - convertToAssets(shares: bigint): Promise { - return this.eth_call(functions.convertToAssets, [shares]) + convertToAssets(shares: ConvertToAssetsParams["shares"]) { + return this.eth_call(functions.convertToAssets, {shares}) } - convertToShares(assets: bigint): Promise { - return this.eth_call(functions.convertToShares, [assets]) + convertToShares(assets: ConvertToSharesParams["assets"]) { + return this.eth_call(functions.convertToShares, {assets}) } - decimals(): Promise { - return this.eth_call(functions.decimals, []) + decimals() { + return this.eth_call(functions.decimals, {}) } - lastRewardAmount(): Promise { - return this.eth_call(functions.lastRewardAmount, []) + lastRewardAmount() { + return this.eth_call(functions.lastRewardAmount, {}) } - lastSync(): Promise { - return this.eth_call(functions.lastSync, []) + lastSync() { + return this.eth_call(functions.lastSync, {}) } - maxDeposit(arg0: string): Promise { - return this.eth_call(functions.maxDeposit, [arg0]) + maxDeposit(_0: MaxDepositParams["_0"]) { + return this.eth_call(functions.maxDeposit, {_0}) } - maxMint(arg0: string): Promise { - return this.eth_call(functions.maxMint, [arg0]) + maxMint(_0: MaxMintParams["_0"]) { + return this.eth_call(functions.maxMint, {_0}) } - maxRedeem(owner: string): Promise { - return this.eth_call(functions.maxRedeem, [owner]) + maxRedeem(owner: MaxRedeemParams["owner"]) { + return this.eth_call(functions.maxRedeem, {owner}) } - maxWithdraw(owner: string): Promise { - return this.eth_call(functions.maxWithdraw, [owner]) + maxWithdraw(owner: MaxWithdrawParams["owner"]) { + return this.eth_call(functions.maxWithdraw, {owner}) } - name(): Promise { - return this.eth_call(functions.name, []) + name() { + return this.eth_call(functions.name, {}) } - nonces(arg0: string): Promise { - return this.eth_call(functions.nonces, [arg0]) + nonces(_0: NoncesParams["_0"]) { + return this.eth_call(functions.nonces, {_0}) } - previewDeposit(assets: bigint): Promise { - return this.eth_call(functions.previewDeposit, [assets]) + previewDeposit(assets: PreviewDepositParams["assets"]) { + return this.eth_call(functions.previewDeposit, {assets}) } - previewMint(shares: bigint): Promise { - return this.eth_call(functions.previewMint, [shares]) + previewMint(shares: PreviewMintParams["shares"]) { + return this.eth_call(functions.previewMint, {shares}) } - previewRedeem(shares: bigint): Promise { - return this.eth_call(functions.previewRedeem, [shares]) + previewRedeem(shares: PreviewRedeemParams["shares"]) { + return this.eth_call(functions.previewRedeem, {shares}) } - previewWithdraw(assets: bigint): Promise { - return this.eth_call(functions.previewWithdraw, [assets]) + previewWithdraw(assets: PreviewWithdrawParams["assets"]) { + return this.eth_call(functions.previewWithdraw, {assets}) } - pricePerShare(): Promise { - return this.eth_call(functions.pricePerShare, []) + pricePerShare() { + return this.eth_call(functions.pricePerShare, {}) } - rewardsCycleEnd(): Promise { - return this.eth_call(functions.rewardsCycleEnd, []) + rewardsCycleEnd() { + return this.eth_call(functions.rewardsCycleEnd, {}) } - rewardsCycleLength(): Promise { - return this.eth_call(functions.rewardsCycleLength, []) + rewardsCycleLength() { + return this.eth_call(functions.rewardsCycleLength, {}) } - symbol(): Promise { - return this.eth_call(functions.symbol, []) + symbol() { + return this.eth_call(functions.symbol, {}) } - totalAssets(): Promise { - return this.eth_call(functions.totalAssets, []) + totalAssets() { + return this.eth_call(functions.totalAssets, {}) } - totalSupply(): Promise { - return this.eth_call(functions.totalSupply, []) + totalSupply() { + return this.eth_call(functions.totalSupply, {}) } } + +/// Event types +export type ApprovalEventArgs = EParams +export type DepositEventArgs = EParams +export type NewRewardsCycleEventArgs = EParams +export type TransferEventArgs = EParams +export type WithdrawEventArgs = EParams + +/// Function types +export type DOMAIN_SEPARATORParams = FunctionArguments +export type DOMAIN_SEPARATORReturn = FunctionReturn + +export type AllowanceParams = FunctionArguments +export type AllowanceReturn = FunctionReturn + +export type ApproveParams = FunctionArguments +export type ApproveReturn = FunctionReturn + +export type AssetParams = FunctionArguments +export type AssetReturn = FunctionReturn + +export type BalanceOfParams = FunctionArguments +export type BalanceOfReturn = FunctionReturn + +export type ConvertToAssetsParams = FunctionArguments +export type ConvertToAssetsReturn = FunctionReturn + +export type ConvertToSharesParams = FunctionArguments +export type ConvertToSharesReturn = FunctionReturn + +export type DecimalsParams = FunctionArguments +export type DecimalsReturn = FunctionReturn + +export type DepositParams = FunctionArguments +export type DepositReturn = FunctionReturn + +export type DepositWithSignatureParams = FunctionArguments +export type DepositWithSignatureReturn = FunctionReturn + +export type LastRewardAmountParams = FunctionArguments +export type LastRewardAmountReturn = FunctionReturn + +export type LastSyncParams = FunctionArguments +export type LastSyncReturn = FunctionReturn + +export type MaxDepositParams = FunctionArguments +export type MaxDepositReturn = FunctionReturn + +export type MaxMintParams = FunctionArguments +export type MaxMintReturn = FunctionReturn + +export type MaxRedeemParams = FunctionArguments +export type MaxRedeemReturn = FunctionReturn + +export type MaxWithdrawParams = FunctionArguments +export type MaxWithdrawReturn = FunctionReturn + +export type MintParams = FunctionArguments +export type MintReturn = FunctionReturn + +export type NameParams = FunctionArguments +export type NameReturn = FunctionReturn + +export type NoncesParams = FunctionArguments +export type NoncesReturn = FunctionReturn + +export type PermitParams = FunctionArguments +export type PermitReturn = FunctionReturn + +export type PreviewDepositParams = FunctionArguments +export type PreviewDepositReturn = FunctionReturn + +export type PreviewMintParams = FunctionArguments +export type PreviewMintReturn = FunctionReturn + +export type PreviewRedeemParams = FunctionArguments +export type PreviewRedeemReturn = FunctionReturn + +export type PreviewWithdrawParams = FunctionArguments +export type PreviewWithdrawReturn = FunctionReturn + +export type PricePerShareParams = FunctionArguments +export type PricePerShareReturn = FunctionReturn + +export type RedeemParams = FunctionArguments +export type RedeemReturn = FunctionReturn + +export type RewardsCycleEndParams = FunctionArguments +export type RewardsCycleEndReturn = FunctionReturn + +export type RewardsCycleLengthParams = FunctionArguments +export type RewardsCycleLengthReturn = FunctionReturn + +export type SymbolParams = FunctionArguments +export type SymbolReturn = FunctionReturn + +export type SyncRewardsParams = FunctionArguments +export type SyncRewardsReturn = FunctionReturn + +export type TotalAssetsParams = FunctionArguments +export type TotalAssetsReturn = FunctionReturn + +export type TotalSupplyParams = FunctionArguments +export type TotalSupplyReturn = FunctionReturn + +export type TransferParams = FunctionArguments +export type TransferReturn = FunctionReturn + +export type TransferFromParams = FunctionArguments +export type TransferFromReturn = FunctionReturn + +export type WithdrawParams = FunctionArguments +export type WithdrawReturn = FunctionReturn + diff --git a/src/abi/veogv.ts b/src/abi/veogv.ts index 7d2d0e7b..0955aee0 100644 --- a/src/abi/veogv.ts +++ b/src/abi/veogv.ts @@ -1,235 +1,266 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './veogv.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - Approval: new LogEvent<([owner: string, spender: string, value: bigint] & {owner: string, spender: string, value: bigint})>( - abi, '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925' - ), - DelegateChanged: new LogEvent<([delegator: string, fromDelegate: string, toDelegate: string] & {delegator: string, fromDelegate: string, toDelegate: string})>( - abi, '0x3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f' - ), - DelegateVotesChanged: new LogEvent<([delegate: string, previousBalance: bigint, newBalance: bigint] & {delegate: string, previousBalance: bigint, newBalance: bigint})>( - abi, '0xdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a724' - ), - Reward: new LogEvent<([user: string, amount: bigint] & {user: string, amount: bigint})>( - abi, '0x619caafabdd75649b302ba8419e48cccf64f37f1983ac4727cfb38b57703ffc9' - ), - Stake: new LogEvent<([user: string, lockupId: bigint, amount: bigint, end: bigint, points: bigint] & {user: string, lockupId: bigint, amount: bigint, end: bigint, points: bigint})>( - abi, '0x2720efa4b2dd4f3f8a347da3cbd290a522e9432da9072c5b8e6300496fdde282' - ), - Transfer: new LogEvent<([from: string, to: string, value: bigint] & {from: string, to: string, value: bigint})>( - abi, '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' - ), - Unstake: new LogEvent<([user: string, lockupId: bigint, amount: bigint, end: bigint, points: bigint] & {user: string, lockupId: bigint, amount: bigint, end: bigint, points: bigint})>( - abi, '0x05b744e3e9358bc00ba3cc0c6606a4d6536134dba00b2d2ee4b5de169acd6427' - ), + Approval: event("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", {"owner": indexed(p.address), "spender": indexed(p.address), "value": p.uint256}), + DelegateChanged: event("0x3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f", {"delegator": indexed(p.address), "fromDelegate": indexed(p.address), "toDelegate": indexed(p.address)}), + DelegateVotesChanged: event("0xdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a724", {"delegate": indexed(p.address), "previousBalance": p.uint256, "newBalance": p.uint256}), + Reward: event("0x619caafabdd75649b302ba8419e48cccf64f37f1983ac4727cfb38b57703ffc9", {"user": indexed(p.address), "amount": p.uint256}), + Stake: event("0x2720efa4b2dd4f3f8a347da3cbd290a522e9432da9072c5b8e6300496fdde282", {"user": indexed(p.address), "lockupId": p.uint256, "amount": p.uint256, "end": p.uint256, "points": p.uint256}), + Transfer: event("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", {"from": indexed(p.address), "to": indexed(p.address), "value": p.uint256}), + Unstake: event("0x05b744e3e9358bc00ba3cc0c6606a4d6536134dba00b2d2ee4b5de169acd6427", {"user": indexed(p.address), "lockupId": p.uint256, "amount": p.uint256, "end": p.uint256, "points": p.uint256}), } export const functions = { - DOMAIN_SEPARATOR: new Func<[], {}, string>( - abi, '0x3644e515' - ), - accRewardPerShare: new Func<[], {}, bigint>( - abi, '0x939d6237' - ), - allowance: new Func<[owner: string, spender: string], {owner: string, spender: string}, bigint>( - abi, '0xdd62ed3e' - ), - approve: new Func<[spender: string, amount: bigint], {spender: string, amount: bigint}, boolean>( - abi, '0x095ea7b3' - ), - balanceOf: new Func<[account: string], {account: string}, bigint>( - abi, '0x70a08231' - ), - checkpoints: new Func<[account: string, pos: number], {account: string, pos: number}, ([fromBlock: number, votes: bigint] & {fromBlock: number, votes: bigint})>( - abi, '0xf1127ed8' - ), - collectRewards: new Func<[], {}, []>( - abi, '0x70bb45b3' - ), - decimals: new Func<[], {}, number>( - abi, '0x313ce567' - ), - decreaseAllowance: new Func<[spender: string, subtractedValue: bigint], {spender: string, subtractedValue: bigint}, boolean>( - abi, '0xa457c2d7' - ), - delegate: new Func<[delegatee: string], {delegatee: string}, []>( - abi, '0x5c19a95c' - ), - delegateBySig: new Func<[delegatee: string, nonce: bigint, expiry: bigint, v: number, r: string, s: string], {delegatee: string, nonce: bigint, expiry: bigint, v: number, r: string, s: string}, []>( - abi, '0xc3cda520' - ), - delegates: new Func<[account: string], {account: string}, string>( - abi, '0x587cde1e' - ), - epoch: new Func<[], {}, bigint>( - abi, '0x900cf0cf' - ), - extend: new Func<[lockupId: bigint, duration: bigint], {lockupId: bigint, duration: bigint}, []>( - abi, '0xc89258db' - ), - getPastTotalSupply: new Func<[blockNumber: bigint], {blockNumber: bigint}, bigint>( - abi, '0x8e539e8c' - ), - getPastVotes: new Func<[account: string, blockNumber: bigint], {account: string, blockNumber: bigint}, bigint>( - abi, '0x3a46b1a8' - ), - getVotes: new Func<[account: string], {account: string}, bigint>( - abi, '0x9ab24eb0' - ), - increaseAllowance: new Func<[spender: string, addedValue: bigint], {spender: string, addedValue: bigint}, boolean>( - abi, '0x39509351' - ), - lockups: new Func<[_: string, _: bigint], {}, ([amount: bigint, end: bigint, points: bigint] & {amount: bigint, end: bigint, points: bigint})>( - abi, '0xc93d0b1e' - ), - minStakeDuration: new Func<[], {}, bigint>( - abi, '0x5fec5c64' - ), - name: new Func<[], {}, string>( - abi, '0x06fdde03' - ), - nonces: new Func<[owner: string], {owner: string}, bigint>( - abi, '0x7ecebe00' - ), - numCheckpoints: new Func<[account: string], {account: string}, number>( - abi, '0x6fcfff45' - ), - ogv: new Func<[], {}, string>( - abi, '0x142561cf' - ), - permit: new Func<[owner: string, spender: string, value: bigint, deadline: bigint, v: number, r: string, s: string], {owner: string, spender: string, value: bigint, deadline: bigint, v: number, r: string, s: string}, []>( - abi, '0xd505accf' - ), - previewPoints: new Func<[amount: bigint, duration: bigint], {amount: bigint, duration: bigint}, [_: bigint, _: bigint]>( - abi, '0x4fd0e648' - ), - previewRewards: new Func<[user: string], {user: string}, bigint>( - abi, '0xf166e920' - ), - rewardDebtPerShare: new Func<[_: string], {}, bigint>( - abi, '0x4423bf57' - ), - rewardsSource: new Func<[], {}, string>( - abi, '0xf7240d2f' - ), - 'stake(uint256,uint256,address)': new Func<[amount: bigint, duration: bigint, to: string], {amount: bigint, duration: bigint, to: string}, []>( - abi, '0x7628a37d' - ), - 'stake(uint256,uint256)': new Func<[amount: bigint, duration: bigint], {amount: bigint, duration: bigint}, []>( - abi, '0x7b0472f0' - ), - symbol: new Func<[], {}, string>( - abi, '0x95d89b41' - ), - totalSupply: new Func<[], {}, bigint>( - abi, '0x18160ddd' - ), - transfer: new Func<[_: string, _: bigint], {}, boolean>( - abi, '0xa9059cbb' - ), - transferFrom: new Func<[_: string, _: string, _: bigint], {}, boolean>( - abi, '0x23b872dd' - ), - unstake: new Func<[lockupId: bigint], {lockupId: bigint}, []>( - abi, '0x2e17de78' - ), + DOMAIN_SEPARATOR: fun("0x3644e515", {}, p.bytes32), + accRewardPerShare: fun("0x939d6237", {}, p.uint256), + allowance: fun("0xdd62ed3e", {"owner": p.address, "spender": p.address}, p.uint256), + approve: fun("0x095ea7b3", {"spender": p.address, "amount": p.uint256}, p.bool), + balanceOf: fun("0x70a08231", {"account": p.address}, p.uint256), + checkpoints: fun("0xf1127ed8", {"account": p.address, "pos": p.uint32}, p.struct({"fromBlock": p.uint32, "votes": p.uint224})), + collectRewards: fun("0x70bb45b3", {}, ), + decimals: fun("0x313ce567", {}, p.uint8), + decreaseAllowance: fun("0xa457c2d7", {"spender": p.address, "subtractedValue": p.uint256}, p.bool), + delegate: fun("0x5c19a95c", {"delegatee": p.address}, ), + delegateBySig: fun("0xc3cda520", {"delegatee": p.address, "nonce": p.uint256, "expiry": p.uint256, "v": p.uint8, "r": p.bytes32, "s": p.bytes32}, ), + delegates: fun("0x587cde1e", {"account": p.address}, p.address), + epoch: fun("0x900cf0cf", {}, p.uint256), + extend: fun("0xc89258db", {"lockupId": p.uint256, "duration": p.uint256}, ), + getPastTotalSupply: fun("0x8e539e8c", {"blockNumber": p.uint256}, p.uint256), + getPastVotes: fun("0x3a46b1a8", {"account": p.address, "blockNumber": p.uint256}, p.uint256), + getVotes: fun("0x9ab24eb0", {"account": p.address}, p.uint256), + increaseAllowance: fun("0x39509351", {"spender": p.address, "addedValue": p.uint256}, p.bool), + lockups: fun("0xc93d0b1e", {"_0": p.address, "_1": p.uint256}, {"amount": p.uint128, "end": p.uint128, "points": p.uint256}), + minStakeDuration: fun("0x5fec5c64", {}, p.uint256), + name: fun("0x06fdde03", {}, p.string), + nonces: fun("0x7ecebe00", {"owner": p.address}, p.uint256), + numCheckpoints: fun("0x6fcfff45", {"account": p.address}, p.uint32), + ogv: fun("0x142561cf", {}, p.address), + permit: fun("0xd505accf", {"owner": p.address, "spender": p.address, "value": p.uint256, "deadline": p.uint256, "v": p.uint8, "r": p.bytes32, "s": p.bytes32}, ), + previewPoints: fun("0x4fd0e648", {"amount": p.uint256, "duration": p.uint256}, {"_0": p.uint256, "_1": p.uint256}), + previewRewards: fun("0xf166e920", {"user": p.address}, p.uint256), + rewardDebtPerShare: fun("0x4423bf57", {"_0": p.address}, p.uint256), + rewardsSource: fun("0xf7240d2f", {}, p.address), + "stake(uint256,uint256,address)": fun("0x7628a37d", {"amount": p.uint256, "duration": p.uint256, "to": p.address}, ), + "stake(uint256,uint256)": fun("0x7b0472f0", {"amount": p.uint256, "duration": p.uint256}, ), + symbol: fun("0x95d89b41", {}, p.string), + totalSupply: fun("0x18160ddd", {}, p.uint256), + transfer: fun("0xa9059cbb", {"_0": p.address, "_1": p.uint256}, p.bool), + transferFrom: fun("0x23b872dd", {"_0": p.address, "_1": p.address, "_2": p.uint256}, p.bool), + unstake: fun("0x2e17de78", {"lockupId": p.uint256}, ), } export class Contract extends ContractBase { - DOMAIN_SEPARATOR(): Promise { - return this.eth_call(functions.DOMAIN_SEPARATOR, []) + DOMAIN_SEPARATOR() { + return this.eth_call(functions.DOMAIN_SEPARATOR, {}) } - accRewardPerShare(): Promise { - return this.eth_call(functions.accRewardPerShare, []) + accRewardPerShare() { + return this.eth_call(functions.accRewardPerShare, {}) } - allowance(owner: string, spender: string): Promise { - return this.eth_call(functions.allowance, [owner, spender]) + allowance(owner: AllowanceParams["owner"], spender: AllowanceParams["spender"]) { + return this.eth_call(functions.allowance, {owner, spender}) } - balanceOf(account: string): Promise { - return this.eth_call(functions.balanceOf, [account]) + balanceOf(account: BalanceOfParams["account"]) { + return this.eth_call(functions.balanceOf, {account}) } - checkpoints(account: string, pos: number): Promise<([fromBlock: number, votes: bigint] & {fromBlock: number, votes: bigint})> { - return this.eth_call(functions.checkpoints, [account, pos]) + checkpoints(account: CheckpointsParams["account"], pos: CheckpointsParams["pos"]) { + return this.eth_call(functions.checkpoints, {account, pos}) } - decimals(): Promise { - return this.eth_call(functions.decimals, []) + decimals() { + return this.eth_call(functions.decimals, {}) } - delegates(account: string): Promise { - return this.eth_call(functions.delegates, [account]) + delegates(account: DelegatesParams["account"]) { + return this.eth_call(functions.delegates, {account}) } - epoch(): Promise { - return this.eth_call(functions.epoch, []) + epoch() { + return this.eth_call(functions.epoch, {}) } - getPastTotalSupply(blockNumber: bigint): Promise { - return this.eth_call(functions.getPastTotalSupply, [blockNumber]) + getPastTotalSupply(blockNumber: GetPastTotalSupplyParams["blockNumber"]) { + return this.eth_call(functions.getPastTotalSupply, {blockNumber}) } - getPastVotes(account: string, blockNumber: bigint): Promise { - return this.eth_call(functions.getPastVotes, [account, blockNumber]) + getPastVotes(account: GetPastVotesParams["account"], blockNumber: GetPastVotesParams["blockNumber"]) { + return this.eth_call(functions.getPastVotes, {account, blockNumber}) } - getVotes(account: string): Promise { - return this.eth_call(functions.getVotes, [account]) + getVotes(account: GetVotesParams["account"]) { + return this.eth_call(functions.getVotes, {account}) } - lockups(arg0: string, arg1: bigint): Promise<([amount: bigint, end: bigint, points: bigint] & {amount: bigint, end: bigint, points: bigint})> { - return this.eth_call(functions.lockups, [arg0, arg1]) + lockups(_0: LockupsParams["_0"], _1: LockupsParams["_1"]) { + return this.eth_call(functions.lockups, {_0, _1}) } - minStakeDuration(): Promise { - return this.eth_call(functions.minStakeDuration, []) + minStakeDuration() { + return this.eth_call(functions.minStakeDuration, {}) } - name(): Promise { - return this.eth_call(functions.name, []) + name() { + return this.eth_call(functions.name, {}) } - nonces(owner: string): Promise { - return this.eth_call(functions.nonces, [owner]) + nonces(owner: NoncesParams["owner"]) { + return this.eth_call(functions.nonces, {owner}) } - numCheckpoints(account: string): Promise { - return this.eth_call(functions.numCheckpoints, [account]) + numCheckpoints(account: NumCheckpointsParams["account"]) { + return this.eth_call(functions.numCheckpoints, {account}) } - ogv(): Promise { - return this.eth_call(functions.ogv, []) + ogv() { + return this.eth_call(functions.ogv, {}) } - previewPoints(amount: bigint, duration: bigint): Promise<[_: bigint, _: bigint]> { - return this.eth_call(functions.previewPoints, [amount, duration]) + previewPoints(amount: PreviewPointsParams["amount"], duration: PreviewPointsParams["duration"]) { + return this.eth_call(functions.previewPoints, {amount, duration}) } - previewRewards(user: string): Promise { - return this.eth_call(functions.previewRewards, [user]) + previewRewards(user: PreviewRewardsParams["user"]) { + return this.eth_call(functions.previewRewards, {user}) } - rewardDebtPerShare(arg0: string): Promise { - return this.eth_call(functions.rewardDebtPerShare, [arg0]) + rewardDebtPerShare(_0: RewardDebtPerShareParams["_0"]) { + return this.eth_call(functions.rewardDebtPerShare, {_0}) } - rewardsSource(): Promise { - return this.eth_call(functions.rewardsSource, []) + rewardsSource() { + return this.eth_call(functions.rewardsSource, {}) } - symbol(): Promise { - return this.eth_call(functions.symbol, []) + symbol() { + return this.eth_call(functions.symbol, {}) } - totalSupply(): Promise { - return this.eth_call(functions.totalSupply, []) + totalSupply() { + return this.eth_call(functions.totalSupply, {}) } } + +/// Event types +export type ApprovalEventArgs = EParams +export type DelegateChangedEventArgs = EParams +export type DelegateVotesChangedEventArgs = EParams +export type RewardEventArgs = EParams +export type StakeEventArgs = EParams +export type TransferEventArgs = EParams +export type UnstakeEventArgs = EParams + +/// Function types +export type DOMAIN_SEPARATORParams = FunctionArguments +export type DOMAIN_SEPARATORReturn = FunctionReturn + +export type AccRewardPerShareParams = FunctionArguments +export type AccRewardPerShareReturn = FunctionReturn + +export type AllowanceParams = FunctionArguments +export type AllowanceReturn = FunctionReturn + +export type ApproveParams = FunctionArguments +export type ApproveReturn = FunctionReturn + +export type BalanceOfParams = FunctionArguments +export type BalanceOfReturn = FunctionReturn + +export type CheckpointsParams = FunctionArguments +export type CheckpointsReturn = FunctionReturn + +export type CollectRewardsParams = FunctionArguments +export type CollectRewardsReturn = FunctionReturn + +export type DecimalsParams = FunctionArguments +export type DecimalsReturn = FunctionReturn + +export type DecreaseAllowanceParams = FunctionArguments +export type DecreaseAllowanceReturn = FunctionReturn + +export type DelegateParams = FunctionArguments +export type DelegateReturn = FunctionReturn + +export type DelegateBySigParams = FunctionArguments +export type DelegateBySigReturn = FunctionReturn + +export type DelegatesParams = FunctionArguments +export type DelegatesReturn = FunctionReturn + +export type EpochParams = FunctionArguments +export type EpochReturn = FunctionReturn + +export type ExtendParams = FunctionArguments +export type ExtendReturn = FunctionReturn + +export type GetPastTotalSupplyParams = FunctionArguments +export type GetPastTotalSupplyReturn = FunctionReturn + +export type GetPastVotesParams = FunctionArguments +export type GetPastVotesReturn = FunctionReturn + +export type GetVotesParams = FunctionArguments +export type GetVotesReturn = FunctionReturn + +export type IncreaseAllowanceParams = FunctionArguments +export type IncreaseAllowanceReturn = FunctionReturn + +export type LockupsParams = FunctionArguments +export type LockupsReturn = FunctionReturn + +export type MinStakeDurationParams = FunctionArguments +export type MinStakeDurationReturn = FunctionReturn + +export type NameParams = FunctionArguments +export type NameReturn = FunctionReturn + +export type NoncesParams = FunctionArguments +export type NoncesReturn = FunctionReturn + +export type NumCheckpointsParams = FunctionArguments +export type NumCheckpointsReturn = FunctionReturn + +export type OgvParams = FunctionArguments +export type OgvReturn = FunctionReturn + +export type PermitParams = FunctionArguments +export type PermitReturn = FunctionReturn + +export type PreviewPointsParams = FunctionArguments +export type PreviewPointsReturn = FunctionReturn + +export type PreviewRewardsParams = FunctionArguments +export type PreviewRewardsReturn = FunctionReturn + +export type RewardDebtPerShareParams = FunctionArguments +export type RewardDebtPerShareReturn = FunctionReturn + +export type RewardsSourceParams = FunctionArguments +export type RewardsSourceReturn = FunctionReturn + +export type StakeParams_0 = FunctionArguments +export type StakeReturn_0 = FunctionReturn + +export type StakeParams_1 = FunctionArguments +export type StakeReturn_1 = FunctionReturn + +export type SymbolParams = FunctionArguments +export type SymbolReturn = FunctionReturn + +export type TotalSupplyParams = FunctionArguments +export type TotalSupplyReturn = FunctionReturn + +export type TransferParams = FunctionArguments +export type TransferReturn = FunctionReturn + +export type TransferFromParams = FunctionArguments +export type TransferFromReturn = FunctionReturn + +export type UnstakeParams = FunctionArguments +export type UnstakeReturn = FunctionReturn + diff --git a/src/abi/woeth.ts b/src/abi/woeth.ts index 3f93a435..9c155cdf 100644 --- a/src/abi/woeth.ts +++ b/src/abi/woeth.ts @@ -1,211 +1,240 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './woeth.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - Approval: new LogEvent<([owner: string, spender: string, value: bigint] & {owner: string, spender: string, value: bigint})>( - abi, '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925' - ), - Deposit: new LogEvent<([caller: string, owner: string, assets: bigint, shares: bigint] & {caller: string, owner: string, assets: bigint, shares: bigint})>( - abi, '0xdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7' - ), - GovernorshipTransferred: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( - abi, '0xc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a' - ), - PendingGovernorshipTransfer: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( - abi, '0xa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d' - ), - Transfer: new LogEvent<([from: string, to: string, value: bigint] & {from: string, to: string, value: bigint})>( - abi, '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' - ), - Withdraw: new LogEvent<([caller: string, receiver: string, owner: string, assets: bigint, shares: bigint] & {caller: string, receiver: string, owner: string, assets: bigint, shares: bigint})>( - abi, '0xfbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db' - ), + Approval: event("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", {"owner": indexed(p.address), "spender": indexed(p.address), "value": p.uint256}), + Deposit: event("0xdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7", {"caller": indexed(p.address), "owner": indexed(p.address), "assets": p.uint256, "shares": p.uint256}), + GovernorshipTransferred: event("0xc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a", {"previousGovernor": indexed(p.address), "newGovernor": indexed(p.address)}), + PendingGovernorshipTransfer: event("0xa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d", {"previousGovernor": indexed(p.address), "newGovernor": indexed(p.address)}), + Transfer: event("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", {"from": indexed(p.address), "to": indexed(p.address), "value": p.uint256}), + Withdraw: event("0xfbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db", {"caller": indexed(p.address), "receiver": indexed(p.address), "owner": indexed(p.address), "assets": p.uint256, "shares": p.uint256}), } export const functions = { - allowance: new Func<[owner: string, spender: string], {owner: string, spender: string}, bigint>( - abi, '0xdd62ed3e' - ), - approve: new Func<[spender: string, amount: bigint], {spender: string, amount: bigint}, boolean>( - abi, '0x095ea7b3' - ), - asset: new Func<[], {}, string>( - abi, '0x38d52e0f' - ), - balanceOf: new Func<[account: string], {account: string}, bigint>( - abi, '0x70a08231' - ), - claimGovernance: new Func<[], {}, []>( - abi, '0x5d36b190' - ), - convertToAssets: new Func<[shares: bigint], {shares: bigint}, bigint>( - abi, '0x07a2d13a' - ), - convertToShares: new Func<[assets: bigint], {assets: bigint}, bigint>( - abi, '0xc6e6f592' - ), - decimals: new Func<[], {}, number>( - abi, '0x313ce567' - ), - decreaseAllowance: new Func<[spender: string, subtractedValue: bigint], {spender: string, subtractedValue: bigint}, boolean>( - abi, '0xa457c2d7' - ), - deposit: new Func<[assets: bigint, receiver: string], {assets: bigint, receiver: string}, bigint>( - abi, '0x6e553f65' - ), - governor: new Func<[], {}, string>( - abi, '0x0c340a24' - ), - increaseAllowance: new Func<[spender: string, addedValue: bigint], {spender: string, addedValue: bigint}, boolean>( - abi, '0x39509351' - ), - initialize: new Func<[], {}, []>( - abi, '0x8129fc1c' - ), - isGovernor: new Func<[], {}, boolean>( - abi, '0xc7af3352' - ), - maxDeposit: new Func<[_: string], {}, bigint>( - abi, '0x402d267d' - ), - maxMint: new Func<[_: string], {}, bigint>( - abi, '0xc63d75b6' - ), - maxRedeem: new Func<[owner: string], {owner: string}, bigint>( - abi, '0xd905777e' - ), - maxWithdraw: new Func<[owner: string], {owner: string}, bigint>( - abi, '0xce96cb77' - ), - mint: new Func<[shares: bigint, receiver: string], {shares: bigint, receiver: string}, bigint>( - abi, '0x94bf804d' - ), - name: new Func<[], {}, string>( - abi, '0x06fdde03' - ), - previewDeposit: new Func<[assets: bigint], {assets: bigint}, bigint>( - abi, '0xef8b30f7' - ), - previewMint: new Func<[shares: bigint], {shares: bigint}, bigint>( - abi, '0xb3d7f6b9' - ), - previewRedeem: new Func<[shares: bigint], {shares: bigint}, bigint>( - abi, '0x4cdad506' - ), - previewWithdraw: new Func<[assets: bigint], {assets: bigint}, bigint>( - abi, '0x0a28a477' - ), - redeem: new Func<[shares: bigint, receiver: string, owner: string], {shares: bigint, receiver: string, owner: string}, bigint>( - abi, '0xba087652' - ), - symbol: new Func<[], {}, string>( - abi, '0x95d89b41' - ), - totalAssets: new Func<[], {}, bigint>( - abi, '0x01e1d114' - ), - totalSupply: new Func<[], {}, bigint>( - abi, '0x18160ddd' - ), - transfer: new Func<[recipient: string, amount: bigint], {recipient: string, amount: bigint}, boolean>( - abi, '0xa9059cbb' - ), - transferFrom: new Func<[sender: string, recipient: string, amount: bigint], {sender: string, recipient: string, amount: bigint}, boolean>( - abi, '0x23b872dd' - ), - transferGovernance: new Func<[_newGovernor: string], {_newGovernor: string}, []>( - abi, '0xd38bfff4' - ), - transferToken: new Func<[asset_: string, amount_: bigint], {asset_: string, amount_: bigint}, []>( - abi, '0x1072cbea' - ), - withdraw: new Func<[assets: bigint, receiver: string, owner: string], {assets: bigint, receiver: string, owner: string}, bigint>( - abi, '0xb460af94' - ), + allowance: fun("0xdd62ed3e", {"owner": p.address, "spender": p.address}, p.uint256), + approve: fun("0x095ea7b3", {"spender": p.address, "amount": p.uint256}, p.bool), + asset: fun("0x38d52e0f", {}, p.address), + balanceOf: fun("0x70a08231", {"account": p.address}, p.uint256), + claimGovernance: fun("0x5d36b190", {}, ), + convertToAssets: fun("0x07a2d13a", {"shares": p.uint256}, p.uint256), + convertToShares: fun("0xc6e6f592", {"assets": p.uint256}, p.uint256), + decimals: fun("0x313ce567", {}, p.uint8), + decreaseAllowance: fun("0xa457c2d7", {"spender": p.address, "subtractedValue": p.uint256}, p.bool), + deposit: fun("0x6e553f65", {"assets": p.uint256, "receiver": p.address}, p.uint256), + governor: fun("0x0c340a24", {}, p.address), + increaseAllowance: fun("0x39509351", {"spender": p.address, "addedValue": p.uint256}, p.bool), + initialize: fun("0x8129fc1c", {}, ), + isGovernor: fun("0xc7af3352", {}, p.bool), + maxDeposit: fun("0x402d267d", {"_0": p.address}, p.uint256), + maxMint: fun("0xc63d75b6", {"_0": p.address}, p.uint256), + maxRedeem: fun("0xd905777e", {"owner": p.address}, p.uint256), + maxWithdraw: fun("0xce96cb77", {"owner": p.address}, p.uint256), + mint: fun("0x94bf804d", {"shares": p.uint256, "receiver": p.address}, p.uint256), + name: fun("0x06fdde03", {}, p.string), + previewDeposit: fun("0xef8b30f7", {"assets": p.uint256}, p.uint256), + previewMint: fun("0xb3d7f6b9", {"shares": p.uint256}, p.uint256), + previewRedeem: fun("0x4cdad506", {"shares": p.uint256}, p.uint256), + previewWithdraw: fun("0x0a28a477", {"assets": p.uint256}, p.uint256), + redeem: fun("0xba087652", {"shares": p.uint256, "receiver": p.address, "owner": p.address}, p.uint256), + symbol: fun("0x95d89b41", {}, p.string), + totalAssets: fun("0x01e1d114", {}, p.uint256), + totalSupply: fun("0x18160ddd", {}, p.uint256), + transfer: fun("0xa9059cbb", {"recipient": p.address, "amount": p.uint256}, p.bool), + transferFrom: fun("0x23b872dd", {"sender": p.address, "recipient": p.address, "amount": p.uint256}, p.bool), + transferGovernance: fun("0xd38bfff4", {"_newGovernor": p.address}, ), + transferToken: fun("0x1072cbea", {"asset_": p.address, "amount_": p.uint256}, ), + withdraw: fun("0xb460af94", {"assets": p.uint256, "receiver": p.address, "owner": p.address}, p.uint256), } export class Contract extends ContractBase { - allowance(owner: string, spender: string): Promise { - return this.eth_call(functions.allowance, [owner, spender]) + allowance(owner: AllowanceParams["owner"], spender: AllowanceParams["spender"]) { + return this.eth_call(functions.allowance, {owner, spender}) } - asset(): Promise { - return this.eth_call(functions.asset, []) + asset() { + return this.eth_call(functions.asset, {}) } - balanceOf(account: string): Promise { - return this.eth_call(functions.balanceOf, [account]) + balanceOf(account: BalanceOfParams["account"]) { + return this.eth_call(functions.balanceOf, {account}) } - convertToAssets(shares: bigint): Promise { - return this.eth_call(functions.convertToAssets, [shares]) + convertToAssets(shares: ConvertToAssetsParams["shares"]) { + return this.eth_call(functions.convertToAssets, {shares}) } - convertToShares(assets: bigint): Promise { - return this.eth_call(functions.convertToShares, [assets]) + convertToShares(assets: ConvertToSharesParams["assets"]) { + return this.eth_call(functions.convertToShares, {assets}) } - decimals(): Promise { - return this.eth_call(functions.decimals, []) + decimals() { + return this.eth_call(functions.decimals, {}) } - governor(): Promise { - return this.eth_call(functions.governor, []) + governor() { + return this.eth_call(functions.governor, {}) } - isGovernor(): Promise { - return this.eth_call(functions.isGovernor, []) + isGovernor() { + return this.eth_call(functions.isGovernor, {}) } - maxDeposit(arg0: string): Promise { - return this.eth_call(functions.maxDeposit, [arg0]) + maxDeposit(_0: MaxDepositParams["_0"]) { + return this.eth_call(functions.maxDeposit, {_0}) } - maxMint(arg0: string): Promise { - return this.eth_call(functions.maxMint, [arg0]) + maxMint(_0: MaxMintParams["_0"]) { + return this.eth_call(functions.maxMint, {_0}) } - maxRedeem(owner: string): Promise { - return this.eth_call(functions.maxRedeem, [owner]) + maxRedeem(owner: MaxRedeemParams["owner"]) { + return this.eth_call(functions.maxRedeem, {owner}) } - maxWithdraw(owner: string): Promise { - return this.eth_call(functions.maxWithdraw, [owner]) + maxWithdraw(owner: MaxWithdrawParams["owner"]) { + return this.eth_call(functions.maxWithdraw, {owner}) } - name(): Promise { - return this.eth_call(functions.name, []) + name() { + return this.eth_call(functions.name, {}) } - previewDeposit(assets: bigint): Promise { - return this.eth_call(functions.previewDeposit, [assets]) + previewDeposit(assets: PreviewDepositParams["assets"]) { + return this.eth_call(functions.previewDeposit, {assets}) } - previewMint(shares: bigint): Promise { - return this.eth_call(functions.previewMint, [shares]) + previewMint(shares: PreviewMintParams["shares"]) { + return this.eth_call(functions.previewMint, {shares}) } - previewRedeem(shares: bigint): Promise { - return this.eth_call(functions.previewRedeem, [shares]) + previewRedeem(shares: PreviewRedeemParams["shares"]) { + return this.eth_call(functions.previewRedeem, {shares}) } - previewWithdraw(assets: bigint): Promise { - return this.eth_call(functions.previewWithdraw, [assets]) + previewWithdraw(assets: PreviewWithdrawParams["assets"]) { + return this.eth_call(functions.previewWithdraw, {assets}) } - symbol(): Promise { - return this.eth_call(functions.symbol, []) + symbol() { + return this.eth_call(functions.symbol, {}) } - totalAssets(): Promise { - return this.eth_call(functions.totalAssets, []) + totalAssets() { + return this.eth_call(functions.totalAssets, {}) } - totalSupply(): Promise { - return this.eth_call(functions.totalSupply, []) + totalSupply() { + return this.eth_call(functions.totalSupply, {}) } } + +/// Event types +export type ApprovalEventArgs = EParams +export type DepositEventArgs = EParams +export type GovernorshipTransferredEventArgs = EParams +export type PendingGovernorshipTransferEventArgs = EParams +export type TransferEventArgs = EParams +export type WithdrawEventArgs = EParams + +/// Function types +export type AllowanceParams = FunctionArguments +export type AllowanceReturn = FunctionReturn + +export type ApproveParams = FunctionArguments +export type ApproveReturn = FunctionReturn + +export type AssetParams = FunctionArguments +export type AssetReturn = FunctionReturn + +export type BalanceOfParams = FunctionArguments +export type BalanceOfReturn = FunctionReturn + +export type ClaimGovernanceParams = FunctionArguments +export type ClaimGovernanceReturn = FunctionReturn + +export type ConvertToAssetsParams = FunctionArguments +export type ConvertToAssetsReturn = FunctionReturn + +export type ConvertToSharesParams = FunctionArguments +export type ConvertToSharesReturn = FunctionReturn + +export type DecimalsParams = FunctionArguments +export type DecimalsReturn = FunctionReturn + +export type DecreaseAllowanceParams = FunctionArguments +export type DecreaseAllowanceReturn = FunctionReturn + +export type DepositParams = FunctionArguments +export type DepositReturn = FunctionReturn + +export type GovernorParams = FunctionArguments +export type GovernorReturn = FunctionReturn + +export type IncreaseAllowanceParams = FunctionArguments +export type IncreaseAllowanceReturn = FunctionReturn + +export type InitializeParams = FunctionArguments +export type InitializeReturn = FunctionReturn + +export type IsGovernorParams = FunctionArguments +export type IsGovernorReturn = FunctionReturn + +export type MaxDepositParams = FunctionArguments +export type MaxDepositReturn = FunctionReturn + +export type MaxMintParams = FunctionArguments +export type MaxMintReturn = FunctionReturn + +export type MaxRedeemParams = FunctionArguments +export type MaxRedeemReturn = FunctionReturn + +export type MaxWithdrawParams = FunctionArguments +export type MaxWithdrawReturn = FunctionReturn + +export type MintParams = FunctionArguments +export type MintReturn = FunctionReturn + +export type NameParams = FunctionArguments +export type NameReturn = FunctionReturn + +export type PreviewDepositParams = FunctionArguments +export type PreviewDepositReturn = FunctionReturn + +export type PreviewMintParams = FunctionArguments +export type PreviewMintReturn = FunctionReturn + +export type PreviewRedeemParams = FunctionArguments +export type PreviewRedeemReturn = FunctionReturn + +export type PreviewWithdrawParams = FunctionArguments +export type PreviewWithdrawReturn = FunctionReturn + +export type RedeemParams = FunctionArguments +export type RedeemReturn = FunctionReturn + +export type SymbolParams = FunctionArguments +export type SymbolReturn = FunctionReturn + +export type TotalAssetsParams = FunctionArguments +export type TotalAssetsReturn = FunctionReturn + +export type TotalSupplyParams = FunctionArguments +export type TotalSupplyReturn = FunctionReturn + +export type TransferParams = FunctionArguments +export type TransferReturn = FunctionReturn + +export type TransferFromParams = FunctionArguments +export type TransferFromReturn = FunctionReturn + +export type TransferGovernanceParams = FunctionArguments +export type TransferGovernanceReturn = FunctionReturn + +export type TransferTokenParams = FunctionArguments +export type TransferTokenReturn = FunctionReturn + +export type WithdrawParams = FunctionArguments +export type WithdrawReturn = FunctionReturn + diff --git a/src/abi/x-ogn.ts b/src/abi/x-ogn.ts new file mode 100644 index 00000000..6db15e64 --- /dev/null +++ b/src/abi/x-ogn.ts @@ -0,0 +1,284 @@ +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' + +export const events = { + Approval: event("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", {"owner": indexed(p.address), "spender": indexed(p.address), "value": p.uint256}), + DelegateChanged: event("0x3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f", {"delegator": indexed(p.address), "fromDelegate": indexed(p.address), "toDelegate": indexed(p.address)}), + DelegateVotesChanged: event("0xdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a724", {"delegate": indexed(p.address), "previousBalance": p.uint256, "newBalance": p.uint256}), + Penalty: event("0x322e5021ddf51920f7602154a6c845b34ef1b32704a1fa2c66927b56be280762", {"user": indexed(p.address), "amount": p.uint256}), + Reward: event("0x619caafabdd75649b302ba8419e48cccf64f37f1983ac4727cfb38b57703ffc9", {"user": indexed(p.address), "amount": p.uint256}), + Stake: event("0x2720efa4b2dd4f3f8a347da3cbd290a522e9432da9072c5b8e6300496fdde282", {"user": indexed(p.address), "lockupId": p.uint256, "amount": p.uint256, "end": p.uint256, "points": p.uint256}), + Transfer: event("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", {"from": indexed(p.address), "to": indexed(p.address), "value": p.uint256}), + Unstake: event("0x05b744e3e9358bc00ba3cc0c6606a4d6536134dba00b2d2ee4b5de169acd6427", {"user": indexed(p.address), "lockupId": p.uint256, "amount": p.uint256, "end": p.uint256, "points": p.uint256}), +} + +export const functions = { + DOMAIN_SEPARATOR: fun("0x3644e515", {}, p.bytes32), + accRewardPerShare: fun("0x939d6237", {}, p.uint256), + allowance: fun("0xdd62ed3e", {"owner": p.address, "spender": p.address}, p.uint256), + approve: fun("0x095ea7b3", {"spender": p.address, "amount": p.uint256}, p.bool), + asset: fun("0x38d52e0f", {}, p.address), + balanceOf: fun("0x70a08231", {"account": p.address}, p.uint256), + checkpoints: fun("0xf1127ed8", {"account": p.address, "pos": p.uint32}, p.struct({"fromBlock": p.uint32, "votes": p.uint224})), + collectRewards: fun("0x70bb45b3", {}, ), + decimals: fun("0x313ce567", {}, p.uint8), + decreaseAllowance: fun("0xa457c2d7", {"spender": p.address, "subtractedValue": p.uint256}, p.bool), + delegate: fun("0x5c19a95c", {"delegatee": p.address}, ), + delegateBySig: fun("0xc3cda520", {"delegatee": p.address, "nonce": p.uint256, "expiry": p.uint256, "v": p.uint8, "r": p.bytes32, "s": p.bytes32}, ), + delegates: fun("0x587cde1e", {"account": p.address}, p.address), + epoch: fun("0x900cf0cf", {}, p.uint256), + getPastTotalSupply: fun("0x8e539e8c", {"blockNumber": p.uint256}, p.uint256), + getPastVotes: fun("0x3a46b1a8", {"account": p.address, "blockNumber": p.uint256}, p.uint256), + getVotes: fun("0x9ab24eb0", {"account": p.address}, p.uint256), + increaseAllowance: fun("0x39509351", {"spender": p.address, "addedValue": p.uint256}, p.bool), + lockups: fun("0xc93d0b1e", {"_0": p.address, "_1": p.uint256}, {"amount": p.uint128, "end": p.uint128, "points": p.uint256}), + lockupsCount: fun("0xd1a1ad81", {"user": p.address}, p.uint256), + maxStakeDuration: fun("0x76f70003", {}, p.uint256), + minStakeDuration: fun("0x5fec5c64", {}, p.uint256), + name: fun("0x06fdde03", {}, p.string), + nonces: fun("0x7ecebe00", {"owner": p.address}, p.uint256), + numCheckpoints: fun("0x6fcfff45", {"account": p.address}, p.uint32), + permit: fun("0xd505accf", {"owner": p.address, "spender": p.address, "value": p.uint256, "deadline": p.uint256, "v": p.uint8, "r": p.bytes32, "s": p.bytes32}, ), + previewPoints: fun("0x4fd0e648", {"amount": p.uint256, "duration": p.uint256}, {"_0": p.uint256, "_1": p.uint256}), + previewRewards: fun("0xf166e920", {"user": p.address}, p.uint256), + previewWithdraw: fun("0x488bd7b0", {"amount": p.uint256, "end": p.uint256}, p.uint256), + rewardDebtPerShare: fun("0x4423bf57", {"_0": p.address}, p.uint256), + rewardsSource: fun("0xf7240d2f", {}, p.address), + stake: fun("0x5cd42a92", {"amountIn": p.uint256, "duration": p.uint256, "to": p.address, "stakeRewards": p.bool, "lockupId": p.int256}, ), + symbol: fun("0x95d89b41", {}, p.string), + totalSupply: fun("0x18160ddd", {}, p.uint256), + transfer: fun("0xa9059cbb", {"_0": p.address, "_1": p.uint256}, p.bool), + transferFrom: fun("0x23b872dd", {"_0": p.address, "_1": p.address, "_2": p.uint256}, p.bool), + unstake: fun("0x2e17de78", {"lockupId": p.uint256}, ), +} + +export class Contract extends ContractBase { + + DOMAIN_SEPARATOR() { + return this.eth_call(functions.DOMAIN_SEPARATOR, {}) + } + + accRewardPerShare() { + return this.eth_call(functions.accRewardPerShare, {}) + } + + allowance(owner: AllowanceParams["owner"], spender: AllowanceParams["spender"]) { + return this.eth_call(functions.allowance, {owner, spender}) + } + + asset() { + return this.eth_call(functions.asset, {}) + } + + balanceOf(account: BalanceOfParams["account"]) { + return this.eth_call(functions.balanceOf, {account}) + } + + checkpoints(account: CheckpointsParams["account"], pos: CheckpointsParams["pos"]) { + return this.eth_call(functions.checkpoints, {account, pos}) + } + + decimals() { + return this.eth_call(functions.decimals, {}) + } + + delegates(account: DelegatesParams["account"]) { + return this.eth_call(functions.delegates, {account}) + } + + epoch() { + return this.eth_call(functions.epoch, {}) + } + + getPastTotalSupply(blockNumber: GetPastTotalSupplyParams["blockNumber"]) { + return this.eth_call(functions.getPastTotalSupply, {blockNumber}) + } + + getPastVotes(account: GetPastVotesParams["account"], blockNumber: GetPastVotesParams["blockNumber"]) { + return this.eth_call(functions.getPastVotes, {account, blockNumber}) + } + + getVotes(account: GetVotesParams["account"]) { + return this.eth_call(functions.getVotes, {account}) + } + + lockups(_0: LockupsParams["_0"], _1: LockupsParams["_1"]) { + return this.eth_call(functions.lockups, {_0, _1}) + } + + lockupsCount(user: LockupsCountParams["user"]) { + return this.eth_call(functions.lockupsCount, {user}) + } + + maxStakeDuration() { + return this.eth_call(functions.maxStakeDuration, {}) + } + + minStakeDuration() { + return this.eth_call(functions.minStakeDuration, {}) + } + + name() { + return this.eth_call(functions.name, {}) + } + + nonces(owner: NoncesParams["owner"]) { + return this.eth_call(functions.nonces, {owner}) + } + + numCheckpoints(account: NumCheckpointsParams["account"]) { + return this.eth_call(functions.numCheckpoints, {account}) + } + + previewPoints(amount: PreviewPointsParams["amount"], duration: PreviewPointsParams["duration"]) { + return this.eth_call(functions.previewPoints, {amount, duration}) + } + + previewRewards(user: PreviewRewardsParams["user"]) { + return this.eth_call(functions.previewRewards, {user}) + } + + previewWithdraw(amount: PreviewWithdrawParams["amount"], end: PreviewWithdrawParams["end"]) { + return this.eth_call(functions.previewWithdraw, {amount, end}) + } + + rewardDebtPerShare(_0: RewardDebtPerShareParams["_0"]) { + return this.eth_call(functions.rewardDebtPerShare, {_0}) + } + + rewardsSource() { + return this.eth_call(functions.rewardsSource, {}) + } + + symbol() { + return this.eth_call(functions.symbol, {}) + } + + totalSupply() { + return this.eth_call(functions.totalSupply, {}) + } +} + +/// Event types +export type ApprovalEventArgs = EParams +export type DelegateChangedEventArgs = EParams +export type DelegateVotesChangedEventArgs = EParams +export type PenaltyEventArgs = EParams +export type RewardEventArgs = EParams +export type StakeEventArgs = EParams +export type TransferEventArgs = EParams +export type UnstakeEventArgs = EParams + +/// Function types +export type DOMAIN_SEPARATORParams = FunctionArguments +export type DOMAIN_SEPARATORReturn = FunctionReturn + +export type AccRewardPerShareParams = FunctionArguments +export type AccRewardPerShareReturn = FunctionReturn + +export type AllowanceParams = FunctionArguments +export type AllowanceReturn = FunctionReturn + +export type ApproveParams = FunctionArguments +export type ApproveReturn = FunctionReturn + +export type AssetParams = FunctionArguments +export type AssetReturn = FunctionReturn + +export type BalanceOfParams = FunctionArguments +export type BalanceOfReturn = FunctionReturn + +export type CheckpointsParams = FunctionArguments +export type CheckpointsReturn = FunctionReturn + +export type CollectRewardsParams = FunctionArguments +export type CollectRewardsReturn = FunctionReturn + +export type DecimalsParams = FunctionArguments +export type DecimalsReturn = FunctionReturn + +export type DecreaseAllowanceParams = FunctionArguments +export type DecreaseAllowanceReturn = FunctionReturn + +export type DelegateParams = FunctionArguments +export type DelegateReturn = FunctionReturn + +export type DelegateBySigParams = FunctionArguments +export type DelegateBySigReturn = FunctionReturn + +export type DelegatesParams = FunctionArguments +export type DelegatesReturn = FunctionReturn + +export type EpochParams = FunctionArguments +export type EpochReturn = FunctionReturn + +export type GetPastTotalSupplyParams = FunctionArguments +export type GetPastTotalSupplyReturn = FunctionReturn + +export type GetPastVotesParams = FunctionArguments +export type GetPastVotesReturn = FunctionReturn + +export type GetVotesParams = FunctionArguments +export type GetVotesReturn = FunctionReturn + +export type IncreaseAllowanceParams = FunctionArguments +export type IncreaseAllowanceReturn = FunctionReturn + +export type LockupsParams = FunctionArguments +export type LockupsReturn = FunctionReturn + +export type LockupsCountParams = FunctionArguments +export type LockupsCountReturn = FunctionReturn + +export type MaxStakeDurationParams = FunctionArguments +export type MaxStakeDurationReturn = FunctionReturn + +export type MinStakeDurationParams = FunctionArguments +export type MinStakeDurationReturn = FunctionReturn + +export type NameParams = FunctionArguments +export type NameReturn = FunctionReturn + +export type NoncesParams = FunctionArguments +export type NoncesReturn = FunctionReturn + +export type NumCheckpointsParams = FunctionArguments +export type NumCheckpointsReturn = FunctionReturn + +export type PermitParams = FunctionArguments +export type PermitReturn = FunctionReturn + +export type PreviewPointsParams = FunctionArguments +export type PreviewPointsReturn = FunctionReturn + +export type PreviewRewardsParams = FunctionArguments +export type PreviewRewardsReturn = FunctionReturn + +export type PreviewWithdrawParams = FunctionArguments +export type PreviewWithdrawReturn = FunctionReturn + +export type RewardDebtPerShareParams = FunctionArguments +export type RewardDebtPerShareReturn = FunctionReturn + +export type RewardsSourceParams = FunctionArguments +export type RewardsSourceReturn = FunctionReturn + +export type StakeParams = FunctionArguments +export type StakeReturn = FunctionReturn + +export type SymbolParams = FunctionArguments +export type SymbolReturn = FunctionReturn + +export type TotalSupplyParams = FunctionArguments +export type TotalSupplyReturn = FunctionReturn + +export type TransferParams = FunctionArguments +export type TransferReturn = FunctionReturn + +export type TransferFromParams = FunctionArguments +export type TransferFromReturn = FunctionReturn + +export type UnstakeParams = FunctionArguments +export type UnstakeReturn = FunctionReturn + diff --git a/src/abi/zero-x-exchange.ts b/src/abi/zero-x-exchange.ts index 35a46249..18d12641 100644 --- a/src/abi/zero-x-exchange.ts +++ b/src/abi/zero-x-exchange.ts @@ -1,46 +1,55 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './zero-x-exchange.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const functions = { - FEATURE_NAME: new Func<[], {}, string>( - abi, '0x6ae4b4f7' - ), - FEATURE_VERSION: new Func<[], {}, bigint>( - abi, '0x031b905c' - ), - _sellHeldTokenForTokenToUniswapV3: new Func<[encodedPath: string, sellAmount: bigint, minBuyAmount: bigint, recipient: string], {encodedPath: string, sellAmount: bigint, minBuyAmount: bigint, recipient: string}, bigint>( - abi, '0x4a931ba1' - ), - _sellTokenForTokenToUniswapV3: new Func<[encodedPath: string, sellAmount: bigint, minBuyAmount: bigint, recipient: string, payer: string], {encodedPath: string, sellAmount: bigint, minBuyAmount: bigint, recipient: string, payer: string}, bigint>( - abi, '0x168a6432' - ), - migrate: new Func<[], {}, string>( - abi, '0x8fd3ab80' - ), - sellEthForTokenToUniswapV3: new Func<[encodedPath: string, minBuyAmount: bigint, recipient: string], {encodedPath: string, minBuyAmount: bigint, recipient: string}, bigint>( - abi, '0x3598d8ab' - ), - sellTokenForEthToUniswapV3: new Func<[encodedPath: string, sellAmount: bigint, minBuyAmount: bigint, recipient: string], {encodedPath: string, sellAmount: bigint, minBuyAmount: bigint, recipient: string}, bigint>( - abi, '0x803ba26d' - ), - sellTokenForTokenToUniswapV3: new Func<[encodedPath: string, sellAmount: bigint, minBuyAmount: bigint, recipient: string], {encodedPath: string, sellAmount: bigint, minBuyAmount: bigint, recipient: string}, bigint>( - abi, '0x6af479b2' - ), - uniswapV3SwapCallback: new Func<[amount0Delta: bigint, amount1Delta: bigint, data: string], {amount0Delta: bigint, amount1Delta: bigint, data: string}, []>( - abi, '0xfa461e33' - ), + FEATURE_NAME: fun("0x6ae4b4f7", {}, p.string), + FEATURE_VERSION: fun("0x031b905c", {}, p.uint256), + _sellHeldTokenForTokenToUniswapV3: fun("0x4a931ba1", {"encodedPath": p.bytes, "sellAmount": p.uint256, "minBuyAmount": p.uint256, "recipient": p.address}, p.uint256), + _sellTokenForTokenToUniswapV3: fun("0x168a6432", {"encodedPath": p.bytes, "sellAmount": p.uint256, "minBuyAmount": p.uint256, "recipient": p.address, "payer": p.address}, p.uint256), + migrate: fun("0x8fd3ab80", {}, p.bytes4), + sellEthForTokenToUniswapV3: fun("0x3598d8ab", {"encodedPath": p.bytes, "minBuyAmount": p.uint256, "recipient": p.address}, p.uint256), + sellTokenForEthToUniswapV3: fun("0x803ba26d", {"encodedPath": p.bytes, "sellAmount": p.uint256, "minBuyAmount": p.uint256, "recipient": p.address}, p.uint256), + sellTokenForTokenToUniswapV3: fun("0x6af479b2", {"encodedPath": p.bytes, "sellAmount": p.uint256, "minBuyAmount": p.uint256, "recipient": p.address}, p.uint256), + uniswapV3SwapCallback: fun("0xfa461e33", {"amount0Delta": p.int256, "amount1Delta": p.int256, "data": p.bytes}, ), } export class Contract extends ContractBase { - FEATURE_NAME(): Promise { - return this.eth_call(functions.FEATURE_NAME, []) + FEATURE_NAME() { + return this.eth_call(functions.FEATURE_NAME, {}) } - FEATURE_VERSION(): Promise { - return this.eth_call(functions.FEATURE_VERSION, []) + FEATURE_VERSION() { + return this.eth_call(functions.FEATURE_VERSION, {}) } } + +/// Function types +export type FEATURE_NAMEParams = FunctionArguments +export type FEATURE_NAMEReturn = FunctionReturn + +export type FEATURE_VERSIONParams = FunctionArguments +export type FEATURE_VERSIONReturn = FunctionReturn + +export type _sellHeldTokenForTokenToUniswapV3Params = FunctionArguments +export type _sellHeldTokenForTokenToUniswapV3Return = FunctionReturn + +export type _sellTokenForTokenToUniswapV3Params = FunctionArguments +export type _sellTokenForTokenToUniswapV3Return = FunctionReturn + +export type MigrateParams = FunctionArguments +export type MigrateReturn = FunctionReturn + +export type SellEthForTokenToUniswapV3Params = FunctionArguments +export type SellEthForTokenToUniswapV3Return = FunctionReturn + +export type SellTokenForEthToUniswapV3Params = FunctionArguments +export type SellTokenForEthToUniswapV3Return = FunctionReturn + +export type SellTokenForTokenToUniswapV3Params = FunctionArguments +export type SellTokenForTokenToUniswapV3Return = FunctionReturn + +export type UniswapV3SwapCallbackParams = FunctionArguments +export type UniswapV3SwapCallbackReturn = FunctionReturn + diff --git a/src/oeth/processors/ccip.ts b/src/oeth/processors/ccip.ts index 07205fd0..e267be4e 100644 --- a/src/oeth/processors/ccip.ts +++ b/src/oeth/processors/ccip.ts @@ -91,7 +91,7 @@ export const ccip = (params: { chainId: 1 | 42161 }) => { const ccipSendFunction = traceFilter({ callTo: [ccipRouterAddress], type: ['call'], - callSighash: [ccipRouter.functions.ccipSend.sighash], + callSighash: [ccipRouter.functions.ccipSend.selector], range: { from }, transaction: true, }) diff --git a/src/ousd/processors/strategies/convex-meta-strategy.ts b/src/ousd/processors/strategies/convex-meta-strategy.ts index 0db880d4..81bd11b0 100644 --- a/src/ousd/processors/strategies/convex-meta-strategy.ts +++ b/src/ousd/processors/strategies/convex-meta-strategy.ts @@ -21,7 +21,7 @@ export const convexMetaStrategy: IStrategyData = { traceFilter({ type: ['call'], callTo: ['0x89eb88fedc50fc77ae8a18aad1ca0ac27f777a90'.toLowerCase()], - callSighash: [abstractStrategyAbi.functions.withdrawAll.sighash], + callSighash: [abstractStrategyAbi.functions.withdrawAll.selector], transaction: true, range: { from }, }), diff --git a/src/processor.ts b/src/processor.ts index bb65e77d..4d898f2c 100644 --- a/src/processor.ts +++ b/src/processor.ts @@ -28,7 +28,7 @@ export const createSquidProcessor = ( .setGateway(lookupArchive(archive)) .setRpcEndpoint({ url, - maxBatchCallSize: url.includes('alchemy.com') ? 1 : undefined, + maxBatchCallSize: url.includes('alchemy.com') ? 1 : 100, }) .setRpcDataIngestionSettings({ disabled: process.env.ARCHIVE_ONLY === 'true', diff --git a/src/templates/balancer/balancer.ts b/src/templates/balancer/balancer.ts index be58447f..a03595b7 100644 --- a/src/templates/balancer/balancer.ts +++ b/src/templates/balancer/balancer.ts @@ -93,7 +93,7 @@ export const createBalancerProcessor = ( block.header, BALANCER_VAULT, ) - const [tokens, balances] = await balancerVault.getPoolTokens(poolId) + const { tokens, balances } = await balancerVault.getPoolTokens(poolId) const balance = new BalancerPoolBalance({ id: `${poolAddress}-${block.header.height}`, blockNumber: block.header.height, diff --git a/src/templates/erc20/erc20.ts b/src/templates/erc20/erc20.ts index f648d521..cc07714d 100644 --- a/src/templates/erc20/erc20.ts +++ b/src/templates/erc20/erc20.ts @@ -146,7 +146,7 @@ export const createERC20Tracker = ({ block.header, abi.functions.balanceOf, address, - accounts.map((account) => [account]), + accounts.map((account) => ({ _owner: account })), ) accounts.forEach((account, i) => { if (account === ADDRESS_ZERO) return diff --git a/src/templates/otoken/otoken.ts b/src/templates/otoken/otoken.ts index a4245cda..2b7e891a 100644 --- a/src/templates/otoken/otoken.ts +++ b/src/templates/otoken/otoken.ts @@ -54,8 +54,8 @@ export const createOTokenSetup = type: ['call'], callTo: [address], callSighash: [ - otoken.functions.rebaseOptOut.sighash, - otoken.functions.rebaseOptIn.sighash, + otoken.functions.rebaseOptOut.selector, + otoken.functions.rebaseOptIn.selector, ], transaction: true, range: { from, to: upgrades?.rebaseOptEvents }, // First AccountRebasing appears on 18872285, on OETH @@ -264,12 +264,12 @@ export const createOTokenProcessor = (params: { : (otoken.functions .creditsBalanceOf as unknown as typeof otoken.functions.creditsBalanceOfHighres), params.otokenAddress, - [[data.from], [data.to]], + [{ _account: data.from }, { _account: data.to }], ).then((results) => { if (afterHighResUpgrade) { - return results.map((r) => [r[0], r[1]]) + return results.map((r) => [r._0, r._1]) } else { - return results.map((r) => [r[0] * 1000000000n, r[1] * 1000000000n]) + return results.map((r) => [r._0 * 1000000000n, r._1 * 1000000000n]) } }) as Promise<[bigint, bigint][]>, ]) @@ -504,15 +504,15 @@ export const createOTokenProcessor = (params: { trace.type === 'call' && params.otokenAddress === trace.action.to && (trace.action.sighash === - otoken.functions.governanceRebaseOptIn.sighash || - trace.action.sighash === otoken.functions.rebaseOptIn.sighash || - trace.action.sighash === otoken.functions.rebaseOptOut.sighash) + otoken.functions.governanceRebaseOptIn.selector || + trace.action.sighash === otoken.functions.rebaseOptIn.selector || + trace.action.sighash === otoken.functions.rebaseOptOut.selector) ) { await result.initialize() const timestamp = new Date(block.header.timestamp) const blockNumber = block.header.height const address = - trace.action.sighash === otoken.functions.governanceRebaseOptIn.sighash + trace.action.sighash === otoken.functions.governanceRebaseOptIn.selector ? otoken.functions.governanceRebaseOptIn.decode(trace.action.input) ._account : trace.action.from.toLowerCase() @@ -542,7 +542,7 @@ export const createOTokenProcessor = (params: { status: owner.rebasingOption, }) result.rebaseOptions.push(rebaseOption) - if (trace.action.sighash === otoken.functions.rebaseOptIn.sighash) { + if (trace.action.sighash === otoken.functions.rebaseOptIn.selector) { const afterHighResUpgrade = block.header.height >= (params.Upgrade_CreditsBalanceOfHighRes ?? 0) const otokenContract = new otoken.Contract( @@ -553,17 +553,17 @@ export const createOTokenProcessor = (params: { owner.credits = afterHighResUpgrade ? await otokenContract .creditsBalanceOfHighres(owner.address) - .then((c) => c[0]) + .then((c) => c._0) : await otokenContract .creditsBalanceOf(owner.address) - .then((c) => c[0] * 1000000000n) + .then((c) => c._0 * 1000000000n) owner.rebasingOption = RebasingOption.OptIn rebaseOption.status = RebasingOption.OptIn otokenObject.nonRebasingSupply -= owner.balance otokenObject.rebasingSupply = otokenObject.totalSupply - otokenObject.nonRebasingSupply } - if (trace.action.sighash === otoken.functions.rebaseOptOut.sighash) { + if (trace.action.sighash === otoken.functions.rebaseOptOut.selector) { owner.rebasingOption = RebasingOption.OptOut rebaseOption.status = RebasingOption.OptOut otokenObject.nonRebasingSupply += owner.balance diff --git a/src/templates/strategy/strategy-balancer.ts b/src/templates/strategy/strategy-balancer.ts index 0eb0aace..167a9e92 100644 --- a/src/templates/strategy/strategy-balancer.ts +++ b/src/templates/strategy/strategy-balancer.ts @@ -104,7 +104,8 @@ export const getBalancerStrategyHoldings = async ( block, BALANCER_VAULT, ) - const [poolAssets, balances] = await balancerVault.getPoolTokens(poolId) + const { tokens: poolAssets, balances } = + await balancerVault.getPoolTokens(poolId) const totalStrategyBalance = await strategy['checkBalance()']() // in WETH const eth1 = BigInt('1000000000000000000') diff --git a/src/utils/multicall.ts b/src/utils/multicall.ts index 704f8c1d..1df21e95 100644 --- a/src/utils/multicall.ts +++ b/src/utils/multicall.ts @@ -1,9 +1,15 @@ import { toHex } from 'viem' import { arbitrum, mainnet } from 'viem/chains' -import { Func } from '@abi/abi.support' import { Multicall } from '@abi/multicall' import { Block, Context } from '@processor' +import { + type AbiFunction, + ContractBase, + type FunctionArguments, + type FunctionReturn, + fun, +} from '@subsquid/evm-abi' const MULTICALL_CONTRACTS: Record< number, @@ -18,12 +24,12 @@ const MULTICALL_CONTRACTS: Record< address: '0x842ec2c7d803033edf55e478f461fc547bc54eb2', }, } -export const multicall = async ( +export const multicall = async >( ctx: Context, header: Block['header'], - func: Func, + func: Function, address: string, - calls: Args[], + calls: FunctionArguments[], ) => { const multicallContract = MULTICALL_CONTRACTS[ctx.chain.id] if (multicallContract && header.height >= multicallContract.from) { From 992ef40e735253c8c4df99f2aaa52d74645056b9 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Thu, 16 May 2024 15:09:59 -0700 Subject: [PATCH 02/13] rename x-ogn to exponential-staking, (try and make this generic) --- abi/{x-ogn.json => exponential-staking.json} | 0 src/abi/{x-ogn.ts => exponential-staking.ts} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename abi/{x-ogn.json => exponential-staking.json} (100%) rename src/abi/{x-ogn.ts => exponential-staking.ts} (100%) diff --git a/abi/x-ogn.json b/abi/exponential-staking.json similarity index 100% rename from abi/x-ogn.json rename to abi/exponential-staking.json diff --git a/src/abi/x-ogn.ts b/src/abi/exponential-staking.ts similarity index 100% rename from src/abi/x-ogn.ts rename to src/abi/exponential-staking.ts From ad3b39892d2558f02f1e2dfe4ae1889d88b7a885 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Fri, 17 May 2024 13:09:29 -0700 Subject: [PATCH 03/13] schema, codegen, processor --- .prettierrc | 1 + graphql.config.yml | 5 + schema-exponential-staking.graphql | 104 ++++++++ schema.graphql | 104 ++++++++ .../_exponentialStakingLockupState.ts | 4 + src/model/generated/balancerPool.model.ts | 16 +- .../generated/balancerPoolBalance.model.ts | 17 +- src/model/generated/balancerPoolRate.model.ts | 17 +- src/model/generated/bridgeTransfer.model.ts | 35 ++- .../generated/bridgeTransferState.model.ts | 10 +- src/model/generated/curvePool.model.ts | 14 +- src/model/generated/curvePoolBalance.model.ts | 15 +- src/model/generated/curvePoolRate.model.ts | 13 +- src/model/generated/erc20.model.ts | 12 +- src/model/generated/erc20Balance.model.ts | 15 +- src/model/generated/erc20Holder.model.ts | 11 +- src/model/generated/erc20State.model.ts | 15 +- src/model/generated/erc20Transfer.model.ts | 19 +- src/model/generated/exchangeRate.model.ts | 15 +- .../generated/exponentialStaking.model.ts | 33 +++ .../exponentialStakingAccount.model.ts | 38 +++ ...exponentialStakingDelegateChanged.model.ts | 29 +++ ...entialStakingDelegateVotesChanged.model.ts | 29 +++ .../exponentialStakingLockup.model.ts | 46 ++++ .../exponentialStakingPenalty.model.ts | 26 ++ .../exponentialStakingReward.model.ts | 26 ++ .../exponentialStakingStake.model.ts | 36 +++ .../exponentialStakingUnstake.model.ts | 36 +++ src/model/generated/index.ts | 10 + .../generated/liquidityDailyBalance.model.ts | 13 +- src/model/generated/liquiditySource.model.ts | 6 +- src/model/generated/makerDsrStrategy.model.ts | 9 +- src/model/generated/marshal.ts | 30 --- src/model/generated/maverickPool.model.ts | 10 +- .../generated/maverickPoolBalance.model.ts | 13 +- src/model/generated/nativeBalance.model.ts | 11 +- src/model/generated/oToken.model.ts | 17 +- src/model/generated/oTokenActivity.model.ts | 31 ++- src/model/generated/oTokenAddress.model.ts | 19 +- src/model/generated/oTokenApy.model.ts | 27 +- src/model/generated/oTokenAsset.model.ts | 10 +- src/model/generated/oTokenHistory.model.ts | 17 +- src/model/generated/oTokenRebase.model.ts | 27 +- .../generated/oTokenRebaseOption.model.ts | 12 +- src/model/generated/oTokenVault.model.ts | 15 +- .../oethBalancerMetaPoolStrategy.model.ts | 11 +- .../oethCollateralDailyStat.model.ts | 11 +- src/model/generated/oethCurveLp.model.ts | 19 +- src/model/generated/oethDailyStat.model.ts | 63 +++-- src/model/generated/oethDripper.model.ts | 15 +- src/model/generated/oethFraxStaking.model.ts | 9 +- src/model/generated/oethMorphoAave.model.ts | 9 +- .../oethRewardTokenCollected.model.ts | 15 +- .../generated/oethStrategyDailyStat.model.ts | 9 +- .../oethStrategyHoldingDailyStat.model.ts | 9 +- src/model/generated/oethVault.model.ts | 15 +- src/model/generated/ogv.model.ts | 13 +- src/model/generated/ogvAddress.model.ts | 13 +- src/model/generated/ogvDailyStat.model.ts | 21 +- src/model/generated/ogvLockup.model.ts | 13 +- src/model/generated/ogvLockupTxLog.model.ts | 11 +- src/model/generated/ogvProposal.model.ts | 19 +- src/model/generated/ogvProposalTxLog.model.ts | 6 +- src/model/generated/ogvProposalVote.model.ts | 9 +- src/model/generated/ousdAaveStrategy.model.ts | 13 +- .../ousdCollateralDailyStat.model.ts | 11 +- .../generated/ousdCompoundStrategy.model.ts | 13 +- .../generated/ousdConvexLusdPlus3Crv.model.ts | 13 +- .../generated/ousdConvexStrategy.model.ts | 13 +- src/model/generated/ousdDailyStat.model.ts | 63 +++-- src/model/generated/ousdFluxStrategy.model.ts | 13 +- src/model/generated/ousdMetaStrategy.model.ts | 13 +- src/model/generated/ousdMorphoAave.model.ts | 13 +- .../generated/ousdMorphoCompound.model.ts | 13 +- .../generated/ousdStrategyDailyStat.model.ts | 9 +- .../ousdStrategyHoldingDailyStat.model.ts | 9 +- src/model/generated/ousdVault.model.ts | 13 +- src/model/generated/processingStatus.model.ts | 6 +- src/model/generated/strategyBalance.model.ts | 13 +- .../generated/strategyDailyYield.model.ts | 23 +- src/model/generated/strategyYield.model.ts | 19 +- .../exponential-staking.ts | 238 ++++++++++++++++++ src/templates/exponential-staking/index.ts | 1 + 83 files changed, 1249 insertions(+), 568 deletions(-) create mode 100644 schema-exponential-staking.graphql create mode 100644 src/model/generated/_exponentialStakingLockupState.ts create mode 100644 src/model/generated/exponentialStaking.model.ts create mode 100644 src/model/generated/exponentialStakingAccount.model.ts create mode 100644 src/model/generated/exponentialStakingDelegateChanged.model.ts create mode 100644 src/model/generated/exponentialStakingDelegateVotesChanged.model.ts create mode 100644 src/model/generated/exponentialStakingLockup.model.ts create mode 100644 src/model/generated/exponentialStakingPenalty.model.ts create mode 100644 src/model/generated/exponentialStakingReward.model.ts create mode 100644 src/model/generated/exponentialStakingStake.model.ts create mode 100644 src/model/generated/exponentialStakingUnstake.model.ts create mode 100644 src/templates/exponential-staking/exponential-staking.ts create mode 100644 src/templates/exponential-staking/index.ts diff --git a/.prettierrc b/.prettierrc index 6253f707..185e598f 100644 --- a/.prettierrc +++ b/.prettierrc @@ -3,6 +3,7 @@ "trailingComma": "all", "tabWidth": 2, "semi": false, + "printWidth": 120, "importOrder": [ "", "^@", diff --git a/graphql.config.yml b/graphql.config.yml index c6964b92..1bbeb21f 100644 --- a/graphql.config.yml +++ b/graphql.config.yml @@ -20,6 +20,11 @@ projects: include: - schema-general.graphql - types.graphql + ogn: + schema: schema-exponential-staking.graphql + include: + - schema-general.graphql + - types.graphql ogv: schema: schema-ogv.graphql include: diff --git a/schema-exponential-staking.graphql b/schema-exponential-staking.graphql new file mode 100644 index 00000000..a882ab7f --- /dev/null +++ b/schema-exponential-staking.graphql @@ -0,0 +1,104 @@ +# State +# - Contract +# - Lockups +# - Accounts + +type ExponentialStaking @entity { + id: ID! + chainId: Int! @index + address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index + accRewardPerShare: BigInt! + assetBalance: BigInt! +} + +enum ExponentialStakingLockupState { + Open + Closed +} + +type ExponentialStakingLockup @entity { + id: ID! # `chainId:address:account:lockupId` or `lockupId` + chainId: Int! @index + address: String! @index + account: String! @index + lockupId: BigInt! @index + amount: BigInt! + end: BigInt! + points: BigInt! + withdrawAmount: BigInt! + penalty: BigInt! + state: ExponentialStakingLockupState +} + +type ExponentialStakingAccount @entity { + id: ID! # `chainId:address:account` + chainId: Int! @index + address: String! @index + account: String! @index + votes: BigInt! + balance: BigInt! + previewPoints: BigInt! + previewRewards: BigInt! + previewWithdraw: BigInt! +} + + + +### Events +type ExponentialStakingDelegateChanged @entity { + id: ID! # `chainId:address:account` + chainId: Int! @index + address: String! @index + delegator: String! @index + fromDelegate: String! + toDelegate: String! +} + +type ExponentialStakingDelegateVotesChanged @entity { + id: ID! # `chainId:address:account` + chainId: Int! @index + address: String! @index + delegate: String! @index + previousBalance: BigInt! + newBalance: BigInt! +} + +type ExponentialStakingPenalty @entity { + id: ID! # `chainId:address:account` + chainId: Int! @index + address: String! @index + account: String! @index + amount: BigInt! +} + +type ExponentialStakingReward @entity { + id: ID! # `chainId:address:account` + chainId: Int! @index + address: String! @index + account: String! @index + amount: BigInt! +} + +type ExponentialStakingStake @entity { + id: ID! # `chainId:address:account` + chainId: Int! @index + address: String! @index + account: String! @index + lockupId: BigInt! @index + amount: BigInt! + end: BigInt! + points: BigInt! +} + +type ExponentialStakingUnstake @entity { + id: ID! # `chainId:address:account` + chainId: Int! @index + address: String! @index + account: String! @index + lockupId: BigInt! @index + amount: BigInt! + end: BigInt! + points: BigInt! +} diff --git a/schema.graphql b/schema.graphql index 19fa9955..c47371ea 100644 --- a/schema.graphql +++ b/schema.graphql @@ -1,5 +1,109 @@ # GENERATED, DO NOT MODIFY +# State +# - Contract +# - Lockups +# - Accounts + +type ExponentialStaking @entity { + id: ID! + chainId: Int! @index + address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index + accRewardPerShare: BigInt! + assetBalance: BigInt! +} + +enum ExponentialStakingLockupState { + Open + Closed +} + +type ExponentialStakingLockup @entity { + id: ID! # `chainId:address:account:lockupId` or `lockupId` + chainId: Int! @index + address: String! @index + account: String! @index + lockupId: BigInt! @index + amount: BigInt! + end: BigInt! + points: BigInt! + withdrawAmount: BigInt! + penalty: BigInt! + state: ExponentialStakingLockupState +} + +type ExponentialStakingAccount @entity { + id: ID! # `chainId:address:account` + chainId: Int! @index + address: String! @index + account: String! @index + votes: BigInt! + balance: BigInt! + previewPoints: BigInt! + previewRewards: BigInt! + previewWithdraw: BigInt! +} + + + +### Events +type ExponentialStakingDelegateChanged @entity { + id: ID! # `chainId:address:account` + chainId: Int! @index + address: String! @index + delegator: String! @index + fromDelegate: String! + toDelegate: String! +} + +type ExponentialStakingDelegateVotesChanged @entity { + id: ID! # `chainId:address:account` + chainId: Int! @index + address: String! @index + delegate: String! @index + previousBalance: BigInt! + newBalance: BigInt! +} + +type ExponentialStakingPenalty @entity { + id: ID! # `chainId:address:account` + chainId: Int! @index + address: String! @index + account: String! @index + amount: BigInt! +} + +type ExponentialStakingReward @entity { + id: ID! # `chainId:address:account` + chainId: Int! @index + address: String! @index + account: String! @index + amount: BigInt! +} + +type ExponentialStakingStake @entity { + id: ID! # `chainId:address:account` + chainId: Int! @index + address: String! @index + account: String! @index + lockupId: BigInt! @index + amount: BigInt! + end: BigInt! + points: BigInt! +} + +type ExponentialStakingUnstake @entity { + id: ID! # `chainId:address:account` + chainId: Int! @index + address: String! @index + account: String! @index + lockupId: BigInt! @index + amount: BigInt! + end: BigInt! + points: BigInt! +} type ProcessingStatus @entity { id: ID! timestamp: DateTime! diff --git a/src/model/generated/_exponentialStakingLockupState.ts b/src/model/generated/_exponentialStakingLockupState.ts new file mode 100644 index 00000000..10304f1c --- /dev/null +++ b/src/model/generated/_exponentialStakingLockupState.ts @@ -0,0 +1,4 @@ +export enum ExponentialStakingLockupState { + Open = "Open", + Closed = "Closed", +} diff --git a/src/model/generated/balancerPool.model.ts b/src/model/generated/balancerPool.model.ts index b28784ae..fb8642a4 100644 --- a/src/model/generated/balancerPool.model.ts +++ b/src/model/generated/balancerPool.model.ts @@ -1,4 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, StringColumn as StringColumn_, Index as Index_, IntColumn as IntColumn_} from "@subsquid/typeorm-store" @Entity_() export class BalancerPool { @@ -10,24 +10,24 @@ export class BalancerPool { id!: string @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) address!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) name!: string - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) tokenCount!: number - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) token0!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) token1!: string - @Column_("text", {nullable: true}) + @StringColumn_({nullable: true}) token2!: string | undefined | null - @Column_("text", {nullable: true}) + @StringColumn_({nullable: true}) token3!: string | undefined | null } diff --git a/src/model/generated/balancerPoolBalance.model.ts b/src/model/generated/balancerPoolBalance.model.ts index ac458e8b..9e546b32 100644 --- a/src/model/generated/balancerPoolBalance.model.ts +++ b/src/model/generated/balancerPoolBalance.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class BalancerPoolBalance { @@ -11,25 +10,25 @@ export class BalancerPoolBalance { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) address!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) balance0!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) balance1!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) balance2!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) balance3!: bigint } diff --git a/src/model/generated/balancerPoolRate.model.ts b/src/model/generated/balancerPoolRate.model.ts index a8a42097..5a78c5f6 100644 --- a/src/model/generated/balancerPoolRate.model.ts +++ b/src/model/generated/balancerPoolRate.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class BalancerPoolRate { @@ -11,25 +10,25 @@ export class BalancerPoolRate { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) address!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) rate0!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) rate1!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) rate2!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) rate3!: bigint } diff --git a/src/model/generated/bridgeTransfer.model.ts b/src/model/generated/bridgeTransfer.model.ts index ad46a23a..f874acf2 100644 --- a/src/model/generated/bridgeTransfer.model.ts +++ b/src/model/generated/bridgeTransfer.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class BridgeTransfer { @@ -11,58 +10,58 @@ export class BridgeTransfer { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) txHashIn!: string - @Column_("text", {nullable: true}) + @StringColumn_({nullable: true}) txHashOut!: string | undefined | null @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) messageId!: string @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) bridge!: string @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) transactor!: string @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) sender!: string @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) receiver!: string @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) chainIn!: number - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) chainOut!: number - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) tokenIn!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) tokenOut!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) amountIn!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) amountOut!: bigint - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) state!: number } diff --git a/src/model/generated/bridgeTransferState.model.ts b/src/model/generated/bridgeTransferState.model.ts index a9c7a829..8276c36d 100644 --- a/src/model/generated/bridgeTransferState.model.ts +++ b/src/model/generated/bridgeTransferState.model.ts @@ -1,4 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, StringColumn as StringColumn_} from "@subsquid/typeorm-store" @Entity_() export class BridgeTransferState { @@ -10,17 +10,17 @@ export class BridgeTransferState { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) txHash!: string - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) state!: number } diff --git a/src/model/generated/curvePool.model.ts b/src/model/generated/curvePool.model.ts index efeaeefd..2b0c5675 100644 --- a/src/model/generated/curvePool.model.ts +++ b/src/model/generated/curvePool.model.ts @@ -1,4 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, StringColumn as StringColumn_, Index as Index_, IntColumn as IntColumn_} from "@subsquid/typeorm-store" @Entity_() export class CurvePool { @@ -10,21 +10,21 @@ export class CurvePool { id!: string @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) address!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) name!: string - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) tokenCount!: number - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) token0!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) token1!: string - @Column_("text", {nullable: true}) + @StringColumn_({nullable: true}) token2!: string | undefined | null } diff --git a/src/model/generated/curvePoolBalance.model.ts b/src/model/generated/curvePoolBalance.model.ts index 969a1114..1fa23db9 100644 --- a/src/model/generated/curvePoolBalance.model.ts +++ b/src/model/generated/curvePoolBalance.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class CurvePoolBalance { @@ -11,22 +10,22 @@ export class CurvePoolBalance { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) address!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) balance0!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) balance1!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) balance2!: bigint } diff --git a/src/model/generated/curvePoolRate.model.ts b/src/model/generated/curvePoolRate.model.ts index 6bdabe3b..dfe8504c 100644 --- a/src/model/generated/curvePoolRate.model.ts +++ b/src/model/generated/curvePoolRate.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class CurvePoolRate { @@ -11,19 +10,19 @@ export class CurvePoolRate { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) address!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) name!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) rate!: bigint } diff --git a/src/model/generated/erc20.model.ts b/src/model/generated/erc20.model.ts index 37998202..bf8a20e7 100644 --- a/src/model/generated/erc20.model.ts +++ b/src/model/generated/erc20.model.ts @@ -1,4 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_} from "@subsquid/typeorm-store" @Entity_() export class ERC20 { @@ -13,19 +13,19 @@ export class ERC20 { id!: string @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) chainId!: number @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) address!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) name!: string - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) decimals!: number - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) symbol!: string } diff --git a/src/model/generated/erc20Balance.model.ts b/src/model/generated/erc20Balance.model.ts index cba53f3d..3593f247 100644 --- a/src/model/generated/erc20Balance.model.ts +++ b/src/model/generated/erc20Balance.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, DateTimeColumn as DateTimeColumn_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class ERC20Balance { @@ -14,23 +13,23 @@ export class ERC20Balance { id!: string @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) chainId!: number @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) address!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) account!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) balance!: bigint } diff --git a/src/model/generated/erc20Holder.model.ts b/src/model/generated/erc20Holder.model.ts index 4cd13a04..4c0be6db 100644 --- a/src/model/generated/erc20Holder.model.ts +++ b/src/model/generated/erc20Holder.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class ERC20Holder { @@ -14,15 +13,15 @@ export class ERC20Holder { id!: string @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) chainId!: number - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) address!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) account!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) balance!: bigint } diff --git a/src/model/generated/erc20State.model.ts b/src/model/generated/erc20State.model.ts index 8e1ac6b5..112a7f5f 100644 --- a/src/model/generated/erc20State.model.ts +++ b/src/model/generated/erc20State.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, DateTimeColumn as DateTimeColumn_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class ERC20State { @@ -14,23 +13,23 @@ export class ERC20State { id!: string @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) chainId!: number @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) address!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) totalSupply!: bigint - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) holderCount!: number } diff --git a/src/model/generated/erc20Transfer.model.ts b/src/model/generated/erc20Transfer.model.ts index 268efbcd..ed678004 100644 --- a/src/model/generated/erc20Transfer.model.ts +++ b/src/model/generated/erc20Transfer.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class ERC20Transfer { @@ -11,30 +10,30 @@ export class ERC20Transfer { id!: string @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) chainId!: number - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) txHash!: string - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) address!: string @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) from!: string @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) to!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) value!: bigint } diff --git a/src/model/generated/exchangeRate.model.ts b/src/model/generated/exchangeRate.model.ts index dd870021..b47530ec 100644 --- a/src/model/generated/exchangeRate.model.ts +++ b/src/model/generated/exchangeRate.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" /** * Any entity which has a price associated with it should have that price go in here. @@ -19,22 +18,22 @@ export class ExchangeRate { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) pair!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) base!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) quote!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) rate!: bigint } diff --git a/src/model/generated/exponentialStaking.model.ts b/src/model/generated/exponentialStaking.model.ts new file mode 100644 index 00000000..635fee25 --- /dev/null +++ b/src/model/generated/exponentialStaking.model.ts @@ -0,0 +1,33 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" + +@Entity_() +export class ExponentialStaking { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @IntColumn_({nullable: false}) + chainId!: number + + @Index_() + @StringColumn_({nullable: false}) + address!: string + + @Index_() + @DateTimeColumn_({nullable: false}) + timestamp!: Date + + @Index_() + @IntColumn_({nullable: false}) + blockNumber!: number + + @BigIntColumn_({nullable: false}) + accRewardPerShare!: bigint + + @BigIntColumn_({nullable: false}) + assetBalance!: bigint +} diff --git a/src/model/generated/exponentialStakingAccount.model.ts b/src/model/generated/exponentialStakingAccount.model.ts new file mode 100644 index 00000000..a06fed42 --- /dev/null +++ b/src/model/generated/exponentialStakingAccount.model.ts @@ -0,0 +1,38 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" + +@Entity_() +export class ExponentialStakingAccount { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @IntColumn_({nullable: false}) + chainId!: number + + @Index_() + @StringColumn_({nullable: false}) + address!: string + + @Index_() + @StringColumn_({nullable: false}) + account!: string + + @BigIntColumn_({nullable: false}) + votes!: bigint + + @BigIntColumn_({nullable: false}) + balance!: bigint + + @BigIntColumn_({nullable: false}) + previewPoints!: bigint + + @BigIntColumn_({nullable: false}) + previewRewards!: bigint + + @BigIntColumn_({nullable: false}) + previewWithdraw!: bigint +} diff --git a/src/model/generated/exponentialStakingDelegateChanged.model.ts b/src/model/generated/exponentialStakingDelegateChanged.model.ts new file mode 100644 index 00000000..a29788f6 --- /dev/null +++ b/src/model/generated/exponentialStakingDelegateChanged.model.ts @@ -0,0 +1,29 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_} from "@subsquid/typeorm-store" + +@Entity_() +export class ExponentialStakingDelegateChanged { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @IntColumn_({nullable: false}) + chainId!: number + + @Index_() + @StringColumn_({nullable: false}) + address!: string + + @Index_() + @StringColumn_({nullable: false}) + delegator!: string + + @StringColumn_({nullable: false}) + fromDelegate!: string + + @StringColumn_({nullable: false}) + toDelegate!: string +} diff --git a/src/model/generated/exponentialStakingDelegateVotesChanged.model.ts b/src/model/generated/exponentialStakingDelegateVotesChanged.model.ts new file mode 100644 index 00000000..af8905ab --- /dev/null +++ b/src/model/generated/exponentialStakingDelegateVotesChanged.model.ts @@ -0,0 +1,29 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" + +@Entity_() +export class ExponentialStakingDelegateVotesChanged { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @IntColumn_({nullable: false}) + chainId!: number + + @Index_() + @StringColumn_({nullable: false}) + address!: string + + @Index_() + @StringColumn_({nullable: false}) + delegate!: string + + @BigIntColumn_({nullable: false}) + previousBalance!: bigint + + @BigIntColumn_({nullable: false}) + newBalance!: bigint +} diff --git a/src/model/generated/exponentialStakingLockup.model.ts b/src/model/generated/exponentialStakingLockup.model.ts new file mode 100644 index 00000000..681d3387 --- /dev/null +++ b/src/model/generated/exponentialStakingLockup.model.ts @@ -0,0 +1,46 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" +import {ExponentialStakingLockupState} from "./_exponentialStakingLockupState" + +@Entity_() +export class ExponentialStakingLockup { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @IntColumn_({nullable: false}) + chainId!: number + + @Index_() + @StringColumn_({nullable: false}) + address!: string + + @Index_() + @StringColumn_({nullable: false}) + account!: string + + @Index_() + @BigIntColumn_({nullable: false}) + lockupId!: bigint + + @BigIntColumn_({nullable: false}) + amount!: bigint + + @BigIntColumn_({nullable: false}) + end!: bigint + + @BigIntColumn_({nullable: false}) + points!: bigint + + @BigIntColumn_({nullable: false}) + withdrawAmount!: bigint + + @BigIntColumn_({nullable: false}) + penalty!: bigint + + @Column_("varchar", {length: 6, nullable: true}) + state!: ExponentialStakingLockupState | undefined | null +} diff --git a/src/model/generated/exponentialStakingPenalty.model.ts b/src/model/generated/exponentialStakingPenalty.model.ts new file mode 100644 index 00000000..9c5a9cc6 --- /dev/null +++ b/src/model/generated/exponentialStakingPenalty.model.ts @@ -0,0 +1,26 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" + +@Entity_() +export class ExponentialStakingPenalty { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @IntColumn_({nullable: false}) + chainId!: number + + @Index_() + @StringColumn_({nullable: false}) + address!: string + + @Index_() + @StringColumn_({nullable: false}) + account!: string + + @BigIntColumn_({nullable: false}) + amount!: bigint +} diff --git a/src/model/generated/exponentialStakingReward.model.ts b/src/model/generated/exponentialStakingReward.model.ts new file mode 100644 index 00000000..2fb86c59 --- /dev/null +++ b/src/model/generated/exponentialStakingReward.model.ts @@ -0,0 +1,26 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" + +@Entity_() +export class ExponentialStakingReward { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @IntColumn_({nullable: false}) + chainId!: number + + @Index_() + @StringColumn_({nullable: false}) + address!: string + + @Index_() + @StringColumn_({nullable: false}) + account!: string + + @BigIntColumn_({nullable: false}) + amount!: bigint +} diff --git a/src/model/generated/exponentialStakingStake.model.ts b/src/model/generated/exponentialStakingStake.model.ts new file mode 100644 index 00000000..432e5081 --- /dev/null +++ b/src/model/generated/exponentialStakingStake.model.ts @@ -0,0 +1,36 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" + +@Entity_() +export class ExponentialStakingStake { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @IntColumn_({nullable: false}) + chainId!: number + + @Index_() + @StringColumn_({nullable: false}) + address!: string + + @Index_() + @StringColumn_({nullable: false}) + account!: string + + @Index_() + @BigIntColumn_({nullable: false}) + lockupId!: bigint + + @BigIntColumn_({nullable: false}) + amount!: bigint + + @BigIntColumn_({nullable: false}) + end!: bigint + + @BigIntColumn_({nullable: false}) + points!: bigint +} diff --git a/src/model/generated/exponentialStakingUnstake.model.ts b/src/model/generated/exponentialStakingUnstake.model.ts new file mode 100644 index 00000000..bb0cade1 --- /dev/null +++ b/src/model/generated/exponentialStakingUnstake.model.ts @@ -0,0 +1,36 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" + +@Entity_() +export class ExponentialStakingUnstake { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @IntColumn_({nullable: false}) + chainId!: number + + @Index_() + @StringColumn_({nullable: false}) + address!: string + + @Index_() + @StringColumn_({nullable: false}) + account!: string + + @Index_() + @BigIntColumn_({nullable: false}) + lockupId!: bigint + + @BigIntColumn_({nullable: false}) + amount!: bigint + + @BigIntColumn_({nullable: false}) + end!: bigint + + @BigIntColumn_({nullable: false}) + points!: bigint +} diff --git a/src/model/generated/index.ts b/src/model/generated/index.ts index 7bb851fd..98c3d0ba 100644 --- a/src/model/generated/index.ts +++ b/src/model/generated/index.ts @@ -1,3 +1,13 @@ +export * from "./exponentialStaking.model" +export * from "./exponentialStakingLockup.model" +export * from "./_exponentialStakingLockupState" +export * from "./exponentialStakingAccount.model" +export * from "./exponentialStakingDelegateChanged.model" +export * from "./exponentialStakingDelegateVotesChanged.model" +export * from "./exponentialStakingPenalty.model" +export * from "./exponentialStakingReward.model" +export * from "./exponentialStakingStake.model" +export * from "./exponentialStakingUnstake.model" export * from "./processingStatus.model" export * from "./exchangeRate.model" export * from "./strategyBalance.model" diff --git a/src/model/generated/liquidityDailyBalance.model.ts b/src/model/generated/liquidityDailyBalance.model.ts index 154b250c..cab06fac 100644 --- a/src/model/generated/liquidityDailyBalance.model.ts +++ b/src/model/generated/liquidityDailyBalance.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class LiquidityDailyBalance { @@ -11,19 +10,19 @@ export class LiquidityDailyBalance { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) address!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) token!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) balance!: bigint } diff --git a/src/model/generated/liquiditySource.model.ts b/src/model/generated/liquiditySource.model.ts index dd5a89e0..14fc70d8 100644 --- a/src/model/generated/liquiditySource.model.ts +++ b/src/model/generated/liquiditySource.model.ts @@ -1,4 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_} from "typeorm" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, StringColumn as StringColumn_} from "@subsquid/typeorm-store" import {LiquiditySourceType} from "./_liquiditySourceType" @Entity_() @@ -10,12 +10,12 @@ export class LiquiditySource { @PrimaryColumn_() id!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) address!: string @Column_("varchar", {length: 12, nullable: false}) type!: LiquiditySourceType - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) token!: string } diff --git a/src/model/generated/makerDsrStrategy.model.ts b/src/model/generated/makerDsrStrategy.model.ts index 7c2cbda6..bdc8d3db 100644 --- a/src/model/generated/makerDsrStrategy.model.ts +++ b/src/model/generated/makerDsrStrategy.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class MakerDSRStrategy { @@ -11,13 +10,13 @@ export class MakerDSRStrategy { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) dai!: bigint } diff --git a/src/model/generated/marshal.ts b/src/model/generated/marshal.ts index eaf8d36a..2cf1c3a8 100644 --- a/src/model/generated/marshal.ts +++ b/src/model/generated/marshal.ts @@ -127,36 +127,6 @@ export function nonNull(val: T | undefined | null): T { } -export const bigintTransformer = { - to(x?: bigint) { - return x?.toString() - }, - from(s?: string): bigint | undefined { - return s == null ? undefined : BigInt(s) - } -} - - -export const floatTransformer = { - to(x?: number) { - return x?.toString() - }, - from(s?: string): number | undefined { - return s == null ? undefined : Number(s) - } -} - - -export const bigdecimalTransformer = { - to(x?: any) { - return x?.toString() - }, - from(s?: any): any | undefined { - return s == null ? undefined : decimal.BigDecimal(s) - } -} - - export function enumFromJson(json: unknown, enumObject: E): E[keyof E] { assert(typeof json == 'string', 'invalid enum value') let val = (enumObject as any)[json] diff --git a/src/model/generated/maverickPool.model.ts b/src/model/generated/maverickPool.model.ts index d1744e63..75a3f59a 100644 --- a/src/model/generated/maverickPool.model.ts +++ b/src/model/generated/maverickPool.model.ts @@ -1,4 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, StringColumn as StringColumn_, Index as Index_} from "@subsquid/typeorm-store" @Entity_() export class MaverickPool { @@ -10,15 +10,15 @@ export class MaverickPool { id!: string @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) address!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) name!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) tokenA!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) tokenB!: string } diff --git a/src/model/generated/maverickPoolBalance.model.ts b/src/model/generated/maverickPoolBalance.model.ts index 39e2ace3..7e9c7215 100644 --- a/src/model/generated/maverickPoolBalance.model.ts +++ b/src/model/generated/maverickPoolBalance.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class MaverickPoolBalance { @@ -11,19 +10,19 @@ export class MaverickPoolBalance { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) address!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) binBalanceA!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) binBalanceB!: bigint } diff --git a/src/model/generated/nativeBalance.model.ts b/src/model/generated/nativeBalance.model.ts index 0e76fe8d..295ceb66 100644 --- a/src/model/generated/nativeBalance.model.ts +++ b/src/model/generated/nativeBalance.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class NativeBalance { @@ -14,16 +13,16 @@ export class NativeBalance { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) account!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) balance!: bigint } diff --git a/src/model/generated/oToken.model.ts b/src/model/generated/oToken.model.ts index bd2d9c94..46984426 100644 --- a/src/model/generated/oToken.model.ts +++ b/src/model/generated/oToken.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class OToken { @@ -11,27 +10,27 @@ export class OToken { id!: string @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) chainId!: number @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) otoken!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) totalSupply!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) rebasingSupply!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) nonRebasingSupply!: bigint } diff --git a/src/model/generated/oTokenActivity.model.ts b/src/model/generated/oTokenActivity.model.ts index c1eb131f..47426ab0 100644 --- a/src/model/generated/oTokenActivity.model.ts +++ b/src/model/generated/oTokenActivity.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class OTokenActivity { @@ -11,49 +10,49 @@ export class OTokenActivity { id!: string @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) chainId!: number @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) otoken!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) txHash!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) callDataLast4Bytes!: string - @Column_("text", {nullable: true}) + @StringColumn_({nullable: true}) address!: string | undefined | null - @Column_("text", {nullable: true}) + @StringColumn_({nullable: true}) sighash!: string | undefined | null - @Column_("text", {nullable: true}) + @StringColumn_({nullable: true}) action!: string | undefined | null - @Column_("text", {nullable: true}) + @StringColumn_({nullable: true}) exchange!: string | undefined | null - @Column_("text", {nullable: true}) + @StringColumn_({nullable: true}) interface!: string | undefined | null - @Column_("text", {nullable: true}) + @StringColumn_({nullable: true}) fromSymbol!: string | undefined | null - @Column_("text", {nullable: true}) + @StringColumn_({nullable: true}) toSymbol!: string | undefined | null - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: true}) + @BigIntColumn_({nullable: true}) amount!: bigint | undefined | null } diff --git a/src/model/generated/oTokenAddress.model.ts b/src/model/generated/oTokenAddress.model.ts index f43261f6..22b2c9e3 100644 --- a/src/model/generated/oTokenAddress.model.ts +++ b/src/model/generated/oTokenAddress.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_, OneToMany as OneToMany_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, BooleanColumn as BooleanColumn_, BigIntColumn as BigIntColumn_, DateTimeColumn as DateTimeColumn_, OneToMany as OneToMany_} from "@subsquid/typeorm-store" import {RebasingOption} from "./_rebasingOption" import {OTokenHistory} from "./oTokenHistory.model" @@ -13,33 +12,33 @@ export class OTokenAddress { id!: string @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) chainId!: number @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) otoken!: string @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) address!: string - @Column_("bool", {nullable: false}) + @BooleanColumn_({nullable: false}) isContract!: boolean @Column_("varchar", {length: 6, nullable: false}) rebasingOption!: RebasingOption - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) balance!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) earned!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) credits!: bigint - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) lastUpdated!: Date @OneToMany_(() => OTokenHistory, e => e.address) diff --git a/src/model/generated/oTokenApy.model.ts b/src/model/generated/oTokenApy.model.ts index d3676b85..d4d6076e 100644 --- a/src/model/generated/oTokenApy.model.ts +++ b/src/model/generated/oTokenApy.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, FloatColumn as FloatColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class OTokenAPY { @@ -11,44 +10,44 @@ export class OTokenAPY { id!: string @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) chainId!: number @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) otoken!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) txHash!: string @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) date!: string - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) apr!: number - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) apy!: number - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) apy7DayAvg!: number - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) apy14DayAvg!: number - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) apy30DayAvg!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) rebasingCreditsPerToken!: bigint } diff --git a/src/model/generated/oTokenAsset.model.ts b/src/model/generated/oTokenAsset.model.ts index ba0a9ab0..029be807 100644 --- a/src/model/generated/oTokenAsset.model.ts +++ b/src/model/generated/oTokenAsset.model.ts @@ -1,4 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_} from "@subsquid/typeorm-store" @Entity_() export class OTokenAsset { @@ -10,17 +10,17 @@ export class OTokenAsset { id!: string @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) chainId!: number @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) otoken!: string @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) address!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) symbol!: string } diff --git a/src/model/generated/oTokenHistory.model.ts b/src/model/generated/oTokenHistory.model.ts index 7c4d9828..a0259b06 100644 --- a/src/model/generated/oTokenHistory.model.ts +++ b/src/model/generated/oTokenHistory.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_, ManyToOne as ManyToOne_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, ManyToOne as ManyToOne_, BigIntColumn as BigIntColumn_, DateTimeColumn as DateTimeColumn_} from "@subsquid/typeorm-store" import {OTokenAddress} from "./oTokenAddress.model" import {HistoryType} from "./_historyType" @@ -13,32 +12,32 @@ export class OTokenHistory { id!: string @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) chainId!: number @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) otoken!: string @Index_() @ManyToOne_(() => OTokenAddress, {nullable: true}) address!: OTokenAddress - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) value!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) balance!: bigint - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) txHash!: string @Column_("varchar", {length: 8, nullable: false}) diff --git a/src/model/generated/oTokenRebase.model.ts b/src/model/generated/oTokenRebase.model.ts index 543e59ce..56839f9f 100644 --- a/src/model/generated/oTokenRebase.model.ts +++ b/src/model/generated/oTokenRebase.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_, ManyToOne as ManyToOne_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_, ManyToOne as ManyToOne_} from "@subsquid/typeorm-store" import {OTokenAPY} from "./oTokenApy.model" @Entity_() @@ -12,47 +11,47 @@ export class OTokenRebase { id!: string @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) chainId!: number @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) otoken!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) txHash!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) totalSupply!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) rebasingCredits!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) rebasingCreditsPerToken!: bigint @Index_() @ManyToOne_(() => OTokenAPY, {nullable: true}) apy!: OTokenAPY - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) feeETH!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) feeUSD!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) yieldETH!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) yieldUSD!: bigint } diff --git a/src/model/generated/oTokenRebaseOption.model.ts b/src/model/generated/oTokenRebaseOption.model.ts index 501a0f5b..31170fa7 100644 --- a/src/model/generated/oTokenRebaseOption.model.ts +++ b/src/model/generated/oTokenRebaseOption.model.ts @@ -1,4 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_, ManyToOne as ManyToOne_} from "typeorm" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, ManyToOne as ManyToOne_} from "@subsquid/typeorm-store" import {OTokenAddress} from "./oTokenAddress.model" import {RebasingOption} from "./_rebasingOption" @@ -12,23 +12,23 @@ export class OTokenRebaseOption { id!: string @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) chainId!: number @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) otoken!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) txHash!: string @Index_() diff --git a/src/model/generated/oTokenVault.model.ts b/src/model/generated/oTokenVault.model.ts index 3565a09e..b20f74b2 100644 --- a/src/model/generated/oTokenVault.model.ts +++ b/src/model/generated/oTokenVault.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class OTokenVault { @@ -11,25 +10,25 @@ export class OTokenVault { id!: string @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) chainId!: number @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) otoken!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) address!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) totalValue!: bigint } diff --git a/src/model/generated/oethBalancerMetaPoolStrategy.model.ts b/src/model/generated/oethBalancerMetaPoolStrategy.model.ts index d833757f..c483de85 100644 --- a/src/model/generated/oethBalancerMetaPoolStrategy.model.ts +++ b/src/model/generated/oethBalancerMetaPoolStrategy.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class OETHBalancerMetaPoolStrategy { @@ -11,16 +10,16 @@ export class OETHBalancerMetaPoolStrategy { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) rETH!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) weth!: bigint } diff --git a/src/model/generated/oethCollateralDailyStat.model.ts b/src/model/generated/oethCollateralDailyStat.model.ts index db6a87be..e0cf379f 100644 --- a/src/model/generated/oethCollateralDailyStat.model.ts +++ b/src/model/generated/oethCollateralDailyStat.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" import {OETHDailyStat} from "./oethDailyStat.model" @Entity_() @@ -15,15 +14,15 @@ export class OETHCollateralDailyStat { @ManyToOne_(() => OETHDailyStat, {nullable: true}) dailyStatId!: OETHDailyStat - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) symbol!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) amount!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) price!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) value!: bigint } diff --git a/src/model/generated/oethCurveLp.model.ts b/src/model/generated/oethCurveLp.model.ts index 18f5d689..618e55cd 100644 --- a/src/model/generated/oethCurveLp.model.ts +++ b/src/model/generated/oethCurveLp.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class OETHCurveLP { @@ -11,28 +10,28 @@ export class OETHCurveLP { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) totalSupply!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) eth!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) oeth!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) totalSupplyOwned!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) ethOwned!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) oethOwned!: bigint } diff --git a/src/model/generated/oethDailyStat.model.ts b/src/model/generated/oethDailyStat.model.ts index 1dd57c89..ca7d1a18 100644 --- a/src/model/generated/oethDailyStat.model.ts +++ b/src/model/generated/oethDailyStat.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_, OneToMany as OneToMany_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, DateTimeColumn as DateTimeColumn_, FloatColumn as FloatColumn_, BigIntColumn as BigIntColumn_, OneToMany as OneToMany_} from "@subsquid/typeorm-store" import {OETHStrategyDailyStat} from "./oethStrategyDailyStat.model" import {OETHCollateralDailyStat} from "./oethCollateralDailyStat.model" @@ -16,101 +15,101 @@ export class OETHDailyStat { * Timestamp, eg 2023-10-17 */ @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number /** * Last block number stats were updated */ @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date /** * Timestamp of block number stats were updated */ - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) apr!: number - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) apy!: number - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) apy7DayAvg!: number - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) apy14DayAvg!: number - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) apy30DayAvg!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) totalSupply!: bigint - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) totalSupplyUSD!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) rebasingSupply!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) nonRebasingSupply!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) amoSupply!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) dripperWETH!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) wrappedSupply!: bigint - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) tradingVolumeUSD!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) yieldETH!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) yieldETH7Day!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) yieldETHAllTime!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) yieldUSD!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) yieldUSD7Day!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) yieldUSDAllTime!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) feesETH!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) feesETH7Day!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) feesETHAllTime!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) feesUSD!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) feesUSD7Day!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) feesUSDAllTime!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) pegPrice!: bigint - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) marketCapUSD!: number - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) holdersOverThreshold!: number @OneToMany_(() => OETHStrategyDailyStat, e => e.dailyStatId) diff --git a/src/model/generated/oethDripper.model.ts b/src/model/generated/oethDripper.model.ts index 2de15545..b92b056b 100644 --- a/src/model/generated/oethDripper.model.ts +++ b/src/model/generated/oethDripper.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class OETHDripper { @@ -11,22 +10,22 @@ export class OETHDripper { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) weth!: bigint - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) lastCollectTimestamp!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) dripRatePerBlock!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) dripDuration!: bigint } diff --git a/src/model/generated/oethFraxStaking.model.ts b/src/model/generated/oethFraxStaking.model.ts index 51806dc8..d8a3b7f0 100644 --- a/src/model/generated/oethFraxStaking.model.ts +++ b/src/model/generated/oethFraxStaking.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class OETHFraxStaking { @@ -11,17 +10,17 @@ export class OETHFraxStaking { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number /** * - sfrxETH is what's actually stored here, slightly confusing and may want to change. * - used by balance sheet */ - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) sfrxETH!: bigint } diff --git a/src/model/generated/oethMorphoAave.model.ts b/src/model/generated/oethMorphoAave.model.ts index 23394c8c..35fb3c06 100644 --- a/src/model/generated/oethMorphoAave.model.ts +++ b/src/model/generated/oethMorphoAave.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class OETHMorphoAave { @@ -11,13 +10,13 @@ export class OETHMorphoAave { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) weth!: bigint } diff --git a/src/model/generated/oethRewardTokenCollected.model.ts b/src/model/generated/oethRewardTokenCollected.model.ts index 83eb3ee3..2a9c881a 100644 --- a/src/model/generated/oethRewardTokenCollected.model.ts +++ b/src/model/generated/oethRewardTokenCollected.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class OETHRewardTokenCollected { @@ -11,22 +10,22 @@ export class OETHRewardTokenCollected { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) strategy!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) recipient!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) rewardToken!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) amount!: bigint } diff --git a/src/model/generated/oethStrategyDailyStat.model.ts b/src/model/generated/oethStrategyDailyStat.model.ts index 4c2d8ebd..d556b9c5 100644 --- a/src/model/generated/oethStrategyDailyStat.model.ts +++ b/src/model/generated/oethStrategyDailyStat.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_, OneToMany as OneToMany_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_, OneToMany as OneToMany_} from "@subsquid/typeorm-store" import {OETHDailyStat} from "./oethDailyStat.model" import {OETHStrategyHoldingDailyStat} from "./oethStrategyHoldingDailyStat.model" @@ -16,16 +15,16 @@ export class OETHStrategyDailyStat { @ManyToOne_(() => OETHDailyStat, {nullable: true}) dailyStatId!: OETHDailyStat - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) name!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) total!: bigint /** * Sum of tokens in strategy */ - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) tvl!: bigint /** diff --git a/src/model/generated/oethStrategyHoldingDailyStat.model.ts b/src/model/generated/oethStrategyHoldingDailyStat.model.ts index fa1423c1..5f6e5722 100644 --- a/src/model/generated/oethStrategyHoldingDailyStat.model.ts +++ b/src/model/generated/oethStrategyHoldingDailyStat.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" import {OETHStrategyDailyStat} from "./oethStrategyDailyStat.model" @Entity_() @@ -18,18 +17,18 @@ export class OETHStrategyHoldingDailyStat { /** * Token symbol */ - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) symbol!: string /** * Amount held */ - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) amount!: bigint /** * Total ETH value */ - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) value!: bigint } diff --git a/src/model/generated/oethVault.model.ts b/src/model/generated/oethVault.model.ts index c2853319..6b4e34c6 100644 --- a/src/model/generated/oethVault.model.ts +++ b/src/model/generated/oethVault.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" /** * The Vault entity tracks the OETH vault balance over time. @@ -14,22 +13,22 @@ export class OETHVault { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) weth!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) stETH!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) rETH!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) frxETH!: bigint } diff --git a/src/model/generated/ogv.model.ts b/src/model/generated/ogv.model.ts index 1e1b3fd6..6d34bd25 100644 --- a/src/model/generated/ogv.model.ts +++ b/src/model/generated/ogv.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class OGV { @@ -11,19 +10,19 @@ export class OGV { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) circulating!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) staked!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) total!: bigint } diff --git a/src/model/generated/ogvAddress.model.ts b/src/model/generated/ogvAddress.model.ts index 6d8f018e..63709485 100644 --- a/src/model/generated/ogvAddress.model.ts +++ b/src/model/generated/ogvAddress.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, BigIntColumn as BigIntColumn_, ManyToOne as ManyToOne_, Index as Index_, DateTimeColumn as DateTimeColumn_} from "@subsquid/typeorm-store" @Entity_() export class OGVAddress { @@ -10,22 +9,22 @@ export class OGVAddress { @PrimaryColumn_() id!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) balance!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) staked!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) veogvBalance!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) votingPower!: bigint @Index_() @ManyToOne_(() => OGVAddress, {nullable: true}) delegatee!: OGVAddress | undefined | null - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) lastUpdated!: Date } diff --git a/src/model/generated/ogvDailyStat.model.ts b/src/model/generated/ogvDailyStat.model.ts index a0923f4c..a80d0f05 100644 --- a/src/model/generated/ogvDailyStat.model.ts +++ b/src/model/generated/ogvDailyStat.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_, FloatColumn as FloatColumn_} from "@subsquid/typeorm-store" @Entity_() export class OGVDailyStat { @@ -11,31 +10,31 @@ export class OGVDailyStat { id!: string @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) totalSupply!: bigint - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) totalSupplyUSD!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) totalStaked!: bigint - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) tradingVolumeUSD!: number - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) marketCapUSD!: number - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) priceUSD!: number - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) holdersOverThreshold!: number } diff --git a/src/model/generated/ogvLockup.model.ts b/src/model/generated/ogvLockup.model.ts index 1c7616db..893ba126 100644 --- a/src/model/generated/ogvLockup.model.ts +++ b/src/model/generated/ogvLockup.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_, ManyToOne as ManyToOne_, OneToMany as OneToMany_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, StringColumn as StringColumn_, Index as Index_, ManyToOne as ManyToOne_, OneToMany as OneToMany_, BigIntColumn as BigIntColumn_, DateTimeColumn as DateTimeColumn_} from "@subsquid/typeorm-store" import {OGVAddress} from "./ogvAddress.model" import {OGVLockupTxLog} from "./ogvLockupTxLog.model" @@ -13,7 +12,7 @@ export class OGVLockup { id!: string @Index_() - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) lockupId!: string @Index_() @@ -23,15 +22,15 @@ export class OGVLockup { @OneToMany_(() => OGVLockupTxLog, e => e.ogvLockup) logs!: OGVLockupTxLog[] - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) amount!: bigint - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) end!: Date - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) veogv!: bigint - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date } diff --git a/src/model/generated/ogvLockupTxLog.model.ts b/src/model/generated/ogvLockupTxLog.model.ts index 398efb62..d1671a06 100644 --- a/src/model/generated/ogvLockupTxLog.model.ts +++ b/src/model/generated/ogvLockupTxLog.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, IntColumn as IntColumn_, BigIntColumn as BigIntColumn_, ManyToOne as ManyToOne_, Index as Index_} from "@subsquid/typeorm-store" import {OGVLockupEventType} from "./_ogvLockupEventType" import {OGVLockup} from "./ogvLockup.model" @@ -12,19 +11,19 @@ export class OGVLockupTxLog { @PrimaryColumn_() id!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) hash!: string @Column_("varchar", {length: 8, nullable: false}) event!: OGVLockupEventType - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) totalSupply!: bigint @Index_() diff --git a/src/model/generated/ogvProposal.model.ts b/src/model/generated/ogvProposal.model.ts index 31c35407..f5c317bf 100644 --- a/src/model/generated/ogvProposal.model.ts +++ b/src/model/generated/ogvProposal.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_, OneToMany as OneToMany_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, StringColumn as StringColumn_, ManyToOne as ManyToOne_, Index as Index_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_, OneToMany as OneToMany_, FloatColumn as FloatColumn_} from "@subsquid/typeorm-store" import {OGVAddress} from "./ogvAddress.model" import {OGVProposalState} from "./_ogvProposalState" import {OGVProposalTxLog} from "./ogvProposalTxLog.model" @@ -13,23 +12,23 @@ export class OGVProposal { @PrimaryColumn_() id!: string - @Column_("text", {nullable: true}) + @StringColumn_({nullable: true}) description!: string | undefined | null @Index_() @ManyToOne_(() => OGVAddress, {nullable: true}) proposer!: OGVAddress - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) startBlock!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) endBlock!: bigint - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) lastUpdated!: Date @Column_("varchar", {length: 9, nullable: false}) @@ -38,12 +37,12 @@ export class OGVProposal { @OneToMany_(() => OGVProposalTxLog, e => e.proposal) logs!: OGVProposalTxLog[] - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) quorum!: bigint - @Column_("text", {array: true, nullable: false}) + @StringColumn_({array: true, nullable: false}) choices!: (string | undefined | null)[] - @Column_("numeric", {array: true, nullable: false}) + @FloatColumn_({array: true, nullable: false}) scores!: (number | undefined | null)[] } diff --git a/src/model/generated/ogvProposalTxLog.model.ts b/src/model/generated/ogvProposalTxLog.model.ts index c3e851bb..11a3b11d 100644 --- a/src/model/generated/ogvProposalTxLog.model.ts +++ b/src/model/generated/ogvProposalTxLog.model.ts @@ -1,4 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_} from "typeorm" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, ManyToOne as ManyToOne_, Index as Index_} from "@subsquid/typeorm-store" import {OGVProposalEvent} from "./_ogvProposalEvent" import {OGVProposal} from "./ogvProposal.model" @@ -11,13 +11,13 @@ export class OGVProposalTxLog { @PrimaryColumn_() id!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) hash!: string @Column_("varchar", {length: 8, nullable: false}) event!: OGVProposalEvent - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() diff --git a/src/model/generated/ogvProposalVote.model.ts b/src/model/generated/ogvProposalVote.model.ts index 8e41581e..4be3cf6e 100644 --- a/src/model/generated/ogvProposalVote.model.ts +++ b/src/model/generated/ogvProposalVote.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_, BigIntColumn as BigIntColumn_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_} from "@subsquid/typeorm-store" import {OGVProposal} from "./ogvProposal.model" import {OGVAddress} from "./ogvAddress.model" import {OGVVoteType} from "./_ogvVoteType" @@ -21,15 +20,15 @@ export class OGVProposalVote { @ManyToOne_(() => OGVAddress, {nullable: true}) voter!: OGVAddress - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) weight!: bigint @Column_("varchar", {length: 7, nullable: false}) type!: OGVVoteType - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) txHash!: string - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date } diff --git a/src/model/generated/ousdAaveStrategy.model.ts b/src/model/generated/ousdAaveStrategy.model.ts index 31caa64c..7fc17cae 100644 --- a/src/model/generated/ousdAaveStrategy.model.ts +++ b/src/model/generated/ousdAaveStrategy.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class OUSDAaveStrategy { @@ -11,19 +10,19 @@ export class OUSDAaveStrategy { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) dai!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) usdt!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) usdc!: bigint } diff --git a/src/model/generated/ousdCollateralDailyStat.model.ts b/src/model/generated/ousdCollateralDailyStat.model.ts index 30b3dc41..10397c13 100644 --- a/src/model/generated/ousdCollateralDailyStat.model.ts +++ b/src/model/generated/ousdCollateralDailyStat.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" import {OUSDDailyStat} from "./ousdDailyStat.model" @Entity_() @@ -15,15 +14,15 @@ export class OUSDCollateralDailyStat { @ManyToOne_(() => OUSDDailyStat, {nullable: true}) dailyStatId!: OUSDDailyStat - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) symbol!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) amount!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) price!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) value!: bigint } diff --git a/src/model/generated/ousdCompoundStrategy.model.ts b/src/model/generated/ousdCompoundStrategy.model.ts index f1ea185e..5b95da86 100644 --- a/src/model/generated/ousdCompoundStrategy.model.ts +++ b/src/model/generated/ousdCompoundStrategy.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class OUSDCompoundStrategy { @@ -11,19 +10,19 @@ export class OUSDCompoundStrategy { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) dai!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) usdt!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) usdc!: bigint } diff --git a/src/model/generated/ousdConvexLusdPlus3Crv.model.ts b/src/model/generated/ousdConvexLusdPlus3Crv.model.ts index 3b87e546..6a701c3f 100644 --- a/src/model/generated/ousdConvexLusdPlus3Crv.model.ts +++ b/src/model/generated/ousdConvexLusdPlus3Crv.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class OUSDConvexLUSDPlus3Crv { @@ -11,19 +10,19 @@ export class OUSDConvexLUSDPlus3Crv { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) dai!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) usdt!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) usdc!: bigint } diff --git a/src/model/generated/ousdConvexStrategy.model.ts b/src/model/generated/ousdConvexStrategy.model.ts index 534a3108..0d7a89af 100644 --- a/src/model/generated/ousdConvexStrategy.model.ts +++ b/src/model/generated/ousdConvexStrategy.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class OUSDConvexStrategy { @@ -11,19 +10,19 @@ export class OUSDConvexStrategy { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) dai!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) usdt!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) usdc!: bigint } diff --git a/src/model/generated/ousdDailyStat.model.ts b/src/model/generated/ousdDailyStat.model.ts index b4591ba8..ae5ffc8c 100644 --- a/src/model/generated/ousdDailyStat.model.ts +++ b/src/model/generated/ousdDailyStat.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_, OneToMany as OneToMany_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, DateTimeColumn as DateTimeColumn_, FloatColumn as FloatColumn_, BigIntColumn as BigIntColumn_, OneToMany as OneToMany_} from "@subsquid/typeorm-store" import {OUSDStrategyDailyStat} from "./ousdStrategyDailyStat.model" import {OUSDCollateralDailyStat} from "./ousdCollateralDailyStat.model" @@ -13,95 +12,95 @@ export class OUSDDailyStat { id!: string @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) apr!: number - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) apy!: number - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) apy7DayAvg!: number - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) apy14DayAvg!: number - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) apy30DayAvg!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) totalSupply!: bigint - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) totalSupplyUSD!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) rebasingSupply!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) nonRebasingSupply!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) amoSupply!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) dripperWETH!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) wrappedSupply!: bigint - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) tradingVolumeUSD!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) yieldETH!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) yieldETH7Day!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) yieldETHAllTime!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) yieldUSD!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) yieldUSD7Day!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) yieldUSDAllTime!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) feesETH!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) feesETH7Day!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) feesETHAllTime!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) feesUSD!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) feesUSD7Day!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) feesUSDAllTime!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) pegPrice!: bigint - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) marketCapUSD!: number - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) holdersOverThreshold!: number @OneToMany_(() => OUSDStrategyDailyStat, e => e.dailyStatId) diff --git a/src/model/generated/ousdFluxStrategy.model.ts b/src/model/generated/ousdFluxStrategy.model.ts index 8049aeb9..50ce865e 100644 --- a/src/model/generated/ousdFluxStrategy.model.ts +++ b/src/model/generated/ousdFluxStrategy.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class OUSDFluxStrategy { @@ -11,19 +10,19 @@ export class OUSDFluxStrategy { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) dai!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) usdt!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) usdc!: bigint } diff --git a/src/model/generated/ousdMetaStrategy.model.ts b/src/model/generated/ousdMetaStrategy.model.ts index f239e953..98801081 100644 --- a/src/model/generated/ousdMetaStrategy.model.ts +++ b/src/model/generated/ousdMetaStrategy.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class OUSDMetaStrategy { @@ -11,19 +10,19 @@ export class OUSDMetaStrategy { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) dai!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) usdt!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) usdc!: bigint } diff --git a/src/model/generated/ousdMorphoAave.model.ts b/src/model/generated/ousdMorphoAave.model.ts index eff939e2..8160b321 100644 --- a/src/model/generated/ousdMorphoAave.model.ts +++ b/src/model/generated/ousdMorphoAave.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class OUSDMorphoAave { @@ -11,19 +10,19 @@ export class OUSDMorphoAave { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) dai!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) usdt!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) usdc!: bigint } diff --git a/src/model/generated/ousdMorphoCompound.model.ts b/src/model/generated/ousdMorphoCompound.model.ts index 6b6bae91..39740de8 100644 --- a/src/model/generated/ousdMorphoCompound.model.ts +++ b/src/model/generated/ousdMorphoCompound.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class OUSDMorphoCompound { @@ -11,19 +10,19 @@ export class OUSDMorphoCompound { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) dai!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) usdt!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) usdc!: bigint } diff --git a/src/model/generated/ousdStrategyDailyStat.model.ts b/src/model/generated/ousdStrategyDailyStat.model.ts index 03fbb355..7bd21fe2 100644 --- a/src/model/generated/ousdStrategyDailyStat.model.ts +++ b/src/model/generated/ousdStrategyDailyStat.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_, OneToMany as OneToMany_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_, OneToMany as OneToMany_} from "@subsquid/typeorm-store" import {OUSDDailyStat} from "./ousdDailyStat.model" import {OUSDStrategyHoldingDailyStat} from "./ousdStrategyHoldingDailyStat.model" @@ -16,13 +15,13 @@ export class OUSDStrategyDailyStat { @ManyToOne_(() => OUSDDailyStat, {nullable: true}) dailyStatId!: OUSDDailyStat - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) name!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) total!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) tvl!: bigint @OneToMany_(() => OUSDStrategyHoldingDailyStat, e => e.strategyDailyStatId) diff --git a/src/model/generated/ousdStrategyHoldingDailyStat.model.ts b/src/model/generated/ousdStrategyHoldingDailyStat.model.ts index aff13b8f..e3a26314 100644 --- a/src/model/generated/ousdStrategyHoldingDailyStat.model.ts +++ b/src/model/generated/ousdStrategyHoldingDailyStat.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" import {OUSDStrategyDailyStat} from "./ousdStrategyDailyStat.model" @Entity_() @@ -15,12 +14,12 @@ export class OUSDStrategyHoldingDailyStat { @ManyToOne_(() => OUSDStrategyDailyStat, {nullable: true}) strategyDailyStatId!: OUSDStrategyDailyStat - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) symbol!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) amount!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) value!: bigint } diff --git a/src/model/generated/ousdVault.model.ts b/src/model/generated/ousdVault.model.ts index 21d5378d..dbcf7007 100644 --- a/src/model/generated/ousdVault.model.ts +++ b/src/model/generated/ousdVault.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" /** * The Vault entity tracks the OUSD vault balance over time. @@ -14,19 +13,19 @@ export class OUSDVault { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) dai!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) usdt!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) usdc!: bigint } diff --git a/src/model/generated/processingStatus.model.ts b/src/model/generated/processingStatus.model.ts index 9cc56b77..b860c09b 100644 --- a/src/model/generated/processingStatus.model.ts +++ b/src/model/generated/processingStatus.model.ts @@ -1,4 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_} from "typeorm" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, IntColumn as IntColumn_} from "@subsquid/typeorm-store" @Entity_() export class ProcessingStatus { @@ -9,9 +9,9 @@ export class ProcessingStatus { @PrimaryColumn_() id!: string - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number } diff --git a/src/model/generated/strategyBalance.model.ts b/src/model/generated/strategyBalance.model.ts index 10ef4ea3..c4ae437c 100644 --- a/src/model/generated/strategyBalance.model.ts +++ b/src/model/generated/strategyBalance.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() export class StrategyBalance { @@ -14,19 +13,19 @@ export class StrategyBalance { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) strategy!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) asset!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) balance!: bigint } diff --git a/src/model/generated/strategyDailyYield.model.ts b/src/model/generated/strategyDailyYield.model.ts index 3e6ea8f9..0390acf2 100644 --- a/src/model/generated/strategyDailyYield.model.ts +++ b/src/model/generated/strategyDailyYield.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_, FloatColumn as FloatColumn_} from "@subsquid/typeorm-store" @Entity_() export class StrategyDailyYield { @@ -14,34 +13,34 @@ export class StrategyDailyYield { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) strategy!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) asset!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) balance!: bigint - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) balanceWeight!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) earnings!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) earningsChange!: bigint - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) apr!: number - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) apy!: number } diff --git a/src/model/generated/strategyYield.model.ts b/src/model/generated/strategyYield.model.ts index 460ba25a..df7cf029 100644 --- a/src/model/generated/strategyYield.model.ts +++ b/src/model/generated/strategyYield.model.ts @@ -1,5 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" -import * as marshal from "./marshal" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_, FloatColumn as FloatColumn_} from "@subsquid/typeorm-store" @Entity_() export class StrategyYield { @@ -14,28 +13,28 @@ export class StrategyYield { id!: string @Index_() - @Column_("timestamp with time zone", {nullable: false}) + @DateTimeColumn_({nullable: false}) timestamp!: Date @Index_() - @Column_("int4", {nullable: false}) + @IntColumn_({nullable: false}) blockNumber!: number - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) strategy!: string - @Column_("text", {nullable: false}) + @StringColumn_({nullable: false}) asset!: string - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) balance!: bigint - @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + @FloatColumn_({nullable: false}) balanceWeight!: number - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) earnings!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + @BigIntColumn_({nullable: false}) earningsChange!: bigint } diff --git a/src/templates/exponential-staking/exponential-staking.ts b/src/templates/exponential-staking/exponential-staking.ts new file mode 100644 index 00000000..f2e5a564 --- /dev/null +++ b/src/templates/exponential-staking/exponential-staking.ts @@ -0,0 +1,238 @@ +import * as abi from '@abi/exponential-staking' +import { + ExponentialStakingDelegateChanged, + ExponentialStakingDelegateVotesChanged, + ExponentialStakingLockup, + ExponentialStakingLockupState, + ExponentialStakingPenalty, + ExponentialStakingReward, + ExponentialStakingStake, + ExponentialStakingUnstake, +} from '@model' +import { Block, Context, Log } from '@processor' +import { EvmBatchProcessor } from '@subsquid/evm-processor' +import { TokenAddress } from '@utils/addresses' +import { LogFilter, logFilter } from '@utils/logFilter' + +interface State { + // State Entities + lockup: Map + + // Event Entities + delegateChanged: Map + delegateVotesChanged: Map + penalty: Map + reward: Map + stake: Map + unstake: Map +} + +export const createExponentialStakingTracker = ({ + from, + chainId, + address, +}: { + from: number + chainId: number + address: TokenAddress +}) => { + const delegateChangedFilter = logFilter({ + address: [address], + topic0: [abi.events.DelegateChanged.topic], + range: { from }, + }) + const delegateVotesChangedFilter = logFilter({ + address: [address], + topic0: [abi.events.DelegateVotesChanged.topic], + range: { from }, + }) + const penaltyFilter = logFilter({ + address: [address], + topic0: [abi.events.Penalty.topic], + range: { from }, + }) + const stakeFilter = logFilter({ + address: [address], + topic0: [abi.events.Stake.topic], + range: { from }, + }) + const unstakeFilter = logFilter({ + address: [address], + topic0: [abi.events.Unstake.topic], + range: { from }, + }) + const subProcessors: { + description: string + filter: LogFilter + processor: (ctx: Context, block: Block, log: Log, state: State) => Promise + }[] = [ + // Event Entity Processors + { + description: 'Create DelegateChanged event', + filter: delegateChangedFilter, + processor: async (ctx, block, log, state) => { + const data = abi.events.DelegateChanged.decode(log) + const id = log.id + const entity = new ExponentialStakingDelegateChanged({ + id, + chainId, + address, + delegator: data.delegator, + fromDelegate: data.fromDelegate, + toDelegate: data.toDelegate, + }) + state.delegateChanged.set(id, entity) + }, + }, + { + description: 'Create DelegateVotesChanged event', + filter: delegateVotesChangedFilter, + processor: async (ctx, block, log, state) => { + const data = abi.events.DelegateVotesChanged.decode(log) + const id = log.id + const entity = new ExponentialStakingDelegateVotesChanged({ + id, + chainId, + address, + delegate: data.delegate, + newBalance: data.newBalance, + previousBalance: data.previousBalance, + }) + state.delegateVotesChanged.set(id, entity) + }, + }, + { + description: 'Create Penalty event', + filter: penaltyFilter, + processor: async (ctx, block, log, state) => { + const data = abi.events.Penalty.decode(log) + const id = log.id + const entity = new ExponentialStakingPenalty({ + id, + chainId, + address, + account: data.user, + amount: data.amount, + }) + state.penalty.set(id, entity) + }, + }, + { + description: 'Create Stake event', + filter: stakeFilter, + processor: async (ctx, block, log, state) => { + const data = abi.events.Stake.decode(log) + const id = log.id + const entity = new ExponentialStakingStake({ + id, + chainId, + address, + lockupId: data.lockupId, + account: data.user, + amount: data.amount, + points: data.points, + end: data.end, + }) + state.stake.set(id, entity) + }, + }, + { + description: 'Create Unstake event', + filter: unstakeFilter, + processor: async (ctx, block, log, state) => { + const data = abi.events.Unstake.decode(log) + const id = log.id + const entity = new ExponentialStakingUnstake({ + id, + chainId, + address, + lockupId: data.lockupId, + account: data.user, + amount: data.amount, + points: data.points, + end: data.end, + }) + state.unstake.set(id, entity) + }, + }, + + // State Entity Processors + { + description: 'Handle Stake for Lockup', + filter: stakeFilter, + processor: async (ctx, block, log, state) => { + const data = abi.events.Stake.decode(log) + const id = `${chainId}:${address}:${data.lockupId}` + const entity = new ExponentialStakingLockup({ + id, + chainId, + address, + account: data.user, + lockupId: data.lockupId, + end: data.end, + amount: data.amount, + points: data.points, + withdrawAmount: 0n, + penalty: 0n, + state: ExponentialStakingLockupState.Open, + }) + state.lockup.set(id, entity) + }, + }, + { + description: 'Handle Unstake for Lockup', + filter: unstakeFilter, + processor: async (ctx, block, log, state) => { + const data = abi.events.Unstake.decode(log) + const id = `${chainId}:${address}:${data.lockupId}` + const entity = state.lockup.get(id) ?? (await ctx.store.get(ExponentialStakingLockup, id)) + if (!entity) throw new Error(`Lockup not found: ${id}`) + entity.withdrawAmount = data.amount + entity.penalty = entity.amount - data.amount + entity.state = ExponentialStakingLockupState.Closed + state.lockup.set(id, entity) + }, + }, + ] + + return { + from, + setup(processor: EvmBatchProcessor) { + for (const subProcessor of subProcessors) { + processor.addLog(subProcessor.filter.value) + } + processor.includeAllBlocks({ from }) + }, + async process(ctx: Context) { + const state: State = { + // State Entities + lockup: new Map(), + + // Event Entities + delegateChanged: new Map(), + delegateVotesChanged: new Map(), + penalty: new Map(), + reward: new Map(), + stake: new Map(), + unstake: new Map(), + } + for (const block of ctx.blocks) { + for (const log of block.logs) { + for (const subProcessor of subProcessors) { + if (subProcessor.filter.matches(log)) { + await subProcessor.processor(ctx, block, log, state) + } + } + } + } + await Promise.all([ + ctx.store.insert([...state.delegateChanged.values()]), + ctx.store.insert([...state.delegateVotesChanged.values()]), + ctx.store.insert([...state.penalty.values()]), + ctx.store.insert([...state.reward.values()]), + ctx.store.insert([...state.stake.values()]), + ctx.store.upsert([...state.lockup.values()]), + ]) + }, + } +} diff --git a/src/templates/exponential-staking/index.ts b/src/templates/exponential-staking/index.ts new file mode 100644 index 00000000..f3b3e987 --- /dev/null +++ b/src/templates/exponential-staking/index.ts @@ -0,0 +1 @@ +export * from './exponential-staking' From a88e7d3db9009730f158f98f17c11280a46dd84c Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Fri, 17 May 2024 15:30:50 -0700 Subject: [PATCH 04/13] - copy ogv governance into a governance schema - reorganize so this schema file count isn't so messy --- graphql.config.yml | 33 ++------- package.json | 2 +- schema.graphql | 72 ++++++++++++++++--- .../exponential-staking.graphql | 14 ++-- .../general.graphql | 0 schema/governance.graphql | 57 +++++++++++++++ schema-oeth.graphql => schema/oeth.graphql | 0 schema-ogv.graphql => schema/ogv.graphql | 0 .../otoken.graphql | 0 schema-ousd.graphql => schema/ousd.graphql | 0 .../generated/_governanceProposalEvent.ts | 7 ++ .../generated/_governanceProposalState.ts | 10 +++ src/model/generated/_governanceVoteType.ts | 5 ++ .../generated/governanceProposal.model.ts | 46 ++++++++++++ .../governanceProposalTxLog.model.ts | 26 +++++++ .../generated/governanceProposalVote.model.ts | 33 +++++++++ src/model/generated/index.ts | 6 ++ .../exponential-staking.ts | 28 ++++++-- types.graphql | 3 - 19 files changed, 288 insertions(+), 54 deletions(-) rename schema-exponential-staking.graphql => schema/exponential-staking.graphql (89%) rename schema-general.graphql => schema/general.graphql (100%) create mode 100644 schema/governance.graphql rename schema-oeth.graphql => schema/oeth.graphql (100%) rename schema-ogv.graphql => schema/ogv.graphql (100%) rename schema-otoken.graphql => schema/otoken.graphql (100%) rename schema-ousd.graphql => schema/ousd.graphql (100%) create mode 100644 src/model/generated/_governanceProposalEvent.ts create mode 100644 src/model/generated/_governanceProposalState.ts create mode 100644 src/model/generated/_governanceVoteType.ts create mode 100644 src/model/generated/governanceProposal.model.ts create mode 100644 src/model/generated/governanceProposalTxLog.model.ts create mode 100644 src/model/generated/governanceProposalVote.model.ts diff --git a/graphql.config.yml b/graphql.config.yml index 1bbeb21f..6a635279 100644 --- a/graphql.config.yml +++ b/graphql.config.yml @@ -1,34 +1,9 @@ projects: - combined: - schema: schema.graphql - base: - schema: schema-general.graphql - include: - - types.graphql - otoken: - schema: schema-otoken.graphql - include: - - schema-general.graphql - - types.graphql - oeth: - schema: schema-oeth.graphql + separate: + schema: schema/*.graphql include: - - schema-general.graphql - types.graphql - ousd: - schema: schema-ousd.graphql - include: - - schema-general.graphql - - types.graphql - ogn: - schema: schema-exponential-staking.graphql - include: - - schema-general.graphql - - types.graphql - ogv: - schema: schema-ogv.graphql + combined: + schema: schema.graphql include: - - schema-general.graphql - types.graphql -include: - - types.graphql diff --git a/package.json b/package.json index 8a1811a1..8dd9c17e 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "origin-squid", "private": true, "scripts": { - "codegen": "echo '# GENERATED, DO NOT MODIFY\n' > schema.graphql && cat schema-*.graphql >> schema.graphql && sqd codegen && git add src/model/generated/*", + "codegen": "echo '# GENERATED, DO NOT MODIFY\n' > schema.graphql && cat schema/*.graphql >> schema.graphql && sqd codegen && git add src/model/generated/*", "migration:generate": "sqd down && sqd up && sqd migration:generate && git add db/migrations/*", "generate": "npm-run-all codegen migration:generate", "build": "rm -rf lib && tsc", diff --git a/schema.graphql b/schema.graphql index c47371ea..12953189 100644 --- a/schema.graphql +++ b/schema.graphql @@ -48,9 +48,9 @@ type ExponentialStakingAccount @entity { -### Events +# Events type ExponentialStakingDelegateChanged @entity { - id: ID! # `chainId:address:account` + id: ID! # `chainId:logId` chainId: Int! @index address: String! @index delegator: String! @index @@ -59,7 +59,7 @@ type ExponentialStakingDelegateChanged @entity { } type ExponentialStakingDelegateVotesChanged @entity { - id: ID! # `chainId:address:account` + id: ID! # `chainId:logId` chainId: Int! @index address: String! @index delegate: String! @index @@ -68,7 +68,7 @@ type ExponentialStakingDelegateVotesChanged @entity { } type ExponentialStakingPenalty @entity { - id: ID! # `chainId:address:account` + id: ID! # `chainId:logId` chainId: Int! @index address: String! @index account: String! @index @@ -76,7 +76,7 @@ type ExponentialStakingPenalty @entity { } type ExponentialStakingReward @entity { - id: ID! # `chainId:address:account` + id: ID! # `chainId:logId` chainId: Int! @index address: String! @index account: String! @index @@ -84,7 +84,7 @@ type ExponentialStakingReward @entity { } type ExponentialStakingStake @entity { - id: ID! # `chainId:address:account` + id: ID! # `chainId:logId` chainId: Int! @index address: String! @index account: String! @index @@ -95,7 +95,7 @@ type ExponentialStakingStake @entity { } type ExponentialStakingUnstake @entity { - id: ID! # `chainId:address:account` + id: ID! # `chainId:logId` chainId: Int! @index address: String! @index account: String! @index @@ -386,7 +386,63 @@ type BridgeTransferState @entity { txHash: String! @index state: Int! } -# OETH Vault: 0x39254033945AA2E4809Cc2977E7087BEE48bd7Ab +enum GovernanceProposalState { + Pending + Active + Canceled + Defeated + Succeeded + Queued + Expired + Executed +} + +enum GovernanceProposalEvent { + Created + Queued + Canceled + Extended + Executed +} + +enum GovernanceVoteType { + Against + For + Abstain +} + +type GovernanceProposalTxLog @entity { + id: ID! + hash: String! + event: GovernanceProposalEvent! + timestamp: DateTime! + proposal: GovernanceProposal! @index +} + +type GovernanceProposal @entity { + id: ID! @index + description: String + proposer: String! + timestamp: DateTime! + startBlock: BigInt! + endBlock: BigInt! + lastUpdated: DateTime! + status: GovernanceProposalState! + logs: [GovernanceProposalTxLog]! @derivedFrom(field: "proposal") + quorum: BigInt! + choices: [String]! + scores: [Float]! +} + +type GovernanceProposalVote @entity { + id: ID! + proposal: GovernanceProposal! @index + voter: String! @index + weight: BigInt! + type: GovernanceVoteType! + txHash: String! + timestamp: DateTime! +}# OETH Vault: 0x39254033945AA2E4809Cc2977E7087BEE48bd7Ab """ The Vault entity tracks the OETH vault balance over time. """ diff --git a/schema-exponential-staking.graphql b/schema/exponential-staking.graphql similarity index 89% rename from schema-exponential-staking.graphql rename to schema/exponential-staking.graphql index a882ab7f..118807ea 100644 --- a/schema-exponential-staking.graphql +++ b/schema/exponential-staking.graphql @@ -46,9 +46,9 @@ type ExponentialStakingAccount @entity { -### Events +# Events type ExponentialStakingDelegateChanged @entity { - id: ID! # `chainId:address:account` + id: ID! # `chainId:logId` chainId: Int! @index address: String! @index delegator: String! @index @@ -57,7 +57,7 @@ type ExponentialStakingDelegateChanged @entity { } type ExponentialStakingDelegateVotesChanged @entity { - id: ID! # `chainId:address:account` + id: ID! # `chainId:logId` chainId: Int! @index address: String! @index delegate: String! @index @@ -66,7 +66,7 @@ type ExponentialStakingDelegateVotesChanged @entity { } type ExponentialStakingPenalty @entity { - id: ID! # `chainId:address:account` + id: ID! # `chainId:logId` chainId: Int! @index address: String! @index account: String! @index @@ -74,7 +74,7 @@ type ExponentialStakingPenalty @entity { } type ExponentialStakingReward @entity { - id: ID! # `chainId:address:account` + id: ID! # `chainId:logId` chainId: Int! @index address: String! @index account: String! @index @@ -82,7 +82,7 @@ type ExponentialStakingReward @entity { } type ExponentialStakingStake @entity { - id: ID! # `chainId:address:account` + id: ID! # `chainId:logId` chainId: Int! @index address: String! @index account: String! @index @@ -93,7 +93,7 @@ type ExponentialStakingStake @entity { } type ExponentialStakingUnstake @entity { - id: ID! # `chainId:address:account` + id: ID! # `chainId:logId` chainId: Int! @index address: String! @index account: String! @index diff --git a/schema-general.graphql b/schema/general.graphql similarity index 100% rename from schema-general.graphql rename to schema/general.graphql diff --git a/schema/governance.graphql b/schema/governance.graphql new file mode 100644 index 00000000..06c3373b --- /dev/null +++ b/schema/governance.graphql @@ -0,0 +1,57 @@ +enum GovernanceProposalState { + Pending + Active + Canceled + Defeated + Succeeded + Queued + Expired + Executed +} + +enum GovernanceProposalEvent { + Created + Queued + Canceled + Extended + Executed +} + +enum GovernanceVoteType { + Against + For + Abstain +} + +type GovernanceProposalTxLog @entity { + id: ID! + hash: String! + event: GovernanceProposalEvent! + timestamp: DateTime! + proposal: GovernanceProposal! @index +} + +type GovernanceProposal @entity { + id: ID! @index + description: String + proposer: String! + timestamp: DateTime! + startBlock: BigInt! + endBlock: BigInt! + lastUpdated: DateTime! + status: GovernanceProposalState! + logs: [GovernanceProposalTxLog]! @derivedFrom(field: "proposal") + quorum: BigInt! + choices: [String]! + scores: [Float]! +} + +type GovernanceProposalVote @entity { + id: ID! + proposal: GovernanceProposal! @index + voter: String! @index + weight: BigInt! + type: GovernanceVoteType! + txHash: String! + timestamp: DateTime! +} \ No newline at end of file diff --git a/schema-oeth.graphql b/schema/oeth.graphql similarity index 100% rename from schema-oeth.graphql rename to schema/oeth.graphql diff --git a/schema-ogv.graphql b/schema/ogv.graphql similarity index 100% rename from schema-ogv.graphql rename to schema/ogv.graphql diff --git a/schema-otoken.graphql b/schema/otoken.graphql similarity index 100% rename from schema-otoken.graphql rename to schema/otoken.graphql diff --git a/schema-ousd.graphql b/schema/ousd.graphql similarity index 100% rename from schema-ousd.graphql rename to schema/ousd.graphql diff --git a/src/model/generated/_governanceProposalEvent.ts b/src/model/generated/_governanceProposalEvent.ts new file mode 100644 index 00000000..bffb8eab --- /dev/null +++ b/src/model/generated/_governanceProposalEvent.ts @@ -0,0 +1,7 @@ +export enum GovernanceProposalEvent { + Created = "Created", + Queued = "Queued", + Canceled = "Canceled", + Extended = "Extended", + Executed = "Executed", +} diff --git a/src/model/generated/_governanceProposalState.ts b/src/model/generated/_governanceProposalState.ts new file mode 100644 index 00000000..cc26d44c --- /dev/null +++ b/src/model/generated/_governanceProposalState.ts @@ -0,0 +1,10 @@ +export enum GovernanceProposalState { + Pending = "Pending", + Active = "Active", + Canceled = "Canceled", + Defeated = "Defeated", + Succeeded = "Succeeded", + Queued = "Queued", + Expired = "Expired", + Executed = "Executed", +} diff --git a/src/model/generated/_governanceVoteType.ts b/src/model/generated/_governanceVoteType.ts new file mode 100644 index 00000000..055595bf --- /dev/null +++ b/src/model/generated/_governanceVoteType.ts @@ -0,0 +1,5 @@ +export enum GovernanceVoteType { + Against = "Against", + For = "For", + Abstain = "Abstain", +} diff --git a/src/model/generated/governanceProposal.model.ts b/src/model/generated/governanceProposal.model.ts new file mode 100644 index 00000000..69cc7785 --- /dev/null +++ b/src/model/generated/governanceProposal.model.ts @@ -0,0 +1,46 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_, OneToMany as OneToMany_, FloatColumn as FloatColumn_} from "@subsquid/typeorm-store" +import {GovernanceProposalState} from "./_governanceProposalState" +import {GovernanceProposalTxLog} from "./governanceProposalTxLog.model" + +@Entity_() +export class GovernanceProposal { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @StringColumn_({nullable: true}) + description!: string | undefined | null + + @StringColumn_({nullable: false}) + proposer!: string + + @DateTimeColumn_({nullable: false}) + timestamp!: Date + + @BigIntColumn_({nullable: false}) + startBlock!: bigint + + @BigIntColumn_({nullable: false}) + endBlock!: bigint + + @DateTimeColumn_({nullable: false}) + lastUpdated!: Date + + @Column_("varchar", {length: 9, nullable: false}) + status!: GovernanceProposalState + + @OneToMany_(() => GovernanceProposalTxLog, e => e.proposal) + logs!: GovernanceProposalTxLog[] + + @BigIntColumn_({nullable: false}) + quorum!: bigint + + @StringColumn_({array: true, nullable: false}) + choices!: (string | undefined | null)[] + + @FloatColumn_({array: true, nullable: false}) + scores!: (number | undefined | null)[] +} diff --git a/src/model/generated/governanceProposalTxLog.model.ts b/src/model/generated/governanceProposalTxLog.model.ts new file mode 100644 index 00000000..49ae83dd --- /dev/null +++ b/src/model/generated/governanceProposalTxLog.model.ts @@ -0,0 +1,26 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, ManyToOne as ManyToOne_, Index as Index_} from "@subsquid/typeorm-store" +import {GovernanceProposalEvent} from "./_governanceProposalEvent" +import {GovernanceProposal} from "./governanceProposal.model" + +@Entity_() +export class GovernanceProposalTxLog { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @StringColumn_({nullable: false}) + hash!: string + + @Column_("varchar", {length: 8, nullable: false}) + event!: GovernanceProposalEvent + + @DateTimeColumn_({nullable: false}) + timestamp!: Date + + @Index_() + @ManyToOne_(() => GovernanceProposal, {nullable: true}) + proposal!: GovernanceProposal +} diff --git a/src/model/generated/governanceProposalVote.model.ts b/src/model/generated/governanceProposalVote.model.ts new file mode 100644 index 00000000..adda003a --- /dev/null +++ b/src/model/generated/governanceProposalVote.model.ts @@ -0,0 +1,33 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_, DateTimeColumn as DateTimeColumn_} from "@subsquid/typeorm-store" +import {GovernanceProposal} from "./governanceProposal.model" +import {GovernanceVoteType} from "./_governanceVoteType" + +@Entity_() +export class GovernanceProposalVote { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @ManyToOne_(() => GovernanceProposal, {nullable: true}) + proposal!: GovernanceProposal + + @Index_() + @StringColumn_({nullable: false}) + voter!: string + + @BigIntColumn_({nullable: false}) + weight!: bigint + + @Column_("varchar", {length: 7, nullable: false}) + type!: GovernanceVoteType + + @StringColumn_({nullable: false}) + txHash!: string + + @DateTimeColumn_({nullable: false}) + timestamp!: Date +} diff --git a/src/model/generated/index.ts b/src/model/generated/index.ts index 98c3d0ba..7ab1c53d 100644 --- a/src/model/generated/index.ts +++ b/src/model/generated/index.ts @@ -32,6 +32,12 @@ export * from "./_liquiditySourceType" export * from "./liquidityDailyBalance.model" export * from "./bridgeTransfer.model" export * from "./bridgeTransferState.model" +export * from "./governanceProposalTxLog.model" +export * from "./_governanceProposalEvent" +export * from "./governanceProposal.model" +export * from "./_governanceProposalState" +export * from "./governanceProposalVote.model" +export * from "./_governanceVoteType" export * from "./oethVault.model" export * from "./oethCurveLp.model" export * from "./oethFraxStaking.model" diff --git a/src/templates/exponential-staking/exponential-staking.ts b/src/templates/exponential-staking/exponential-staking.ts index f2e5a564..79e97f5e 100644 --- a/src/templates/exponential-staking/exponential-staking.ts +++ b/src/templates/exponential-staking/exponential-staking.ts @@ -72,7 +72,7 @@ export const createExponentialStakingTracker = ({ filter: delegateChangedFilter, processor: async (ctx, block, log, state) => { const data = abi.events.DelegateChanged.decode(log) - const id = log.id + const id = `${chainId}:${log.id}` const entity = new ExponentialStakingDelegateChanged({ id, chainId, @@ -89,7 +89,7 @@ export const createExponentialStakingTracker = ({ filter: delegateVotesChangedFilter, processor: async (ctx, block, log, state) => { const data = abi.events.DelegateVotesChanged.decode(log) - const id = log.id + const id = `${chainId}:${log.id}` const entity = new ExponentialStakingDelegateVotesChanged({ id, chainId, @@ -106,7 +106,7 @@ export const createExponentialStakingTracker = ({ filter: penaltyFilter, processor: async (ctx, block, log, state) => { const data = abi.events.Penalty.decode(log) - const id = log.id + const id = `${chainId}:${log.id}` const entity = new ExponentialStakingPenalty({ id, chainId, @@ -117,12 +117,28 @@ export const createExponentialStakingTracker = ({ state.penalty.set(id, entity) }, }, + { + description: 'Create Reward event', + filter: penaltyFilter, + processor: async (ctx, block, log, state) => { + const data = abi.events.Reward.decode(log) + const id = `${chainId}:${log.id}` + const entity = new ExponentialStakingReward({ + id, + chainId, + address, + account: data.user, + amount: data.amount, + }) + state.reward.set(id, entity) + }, + }, { description: 'Create Stake event', filter: stakeFilter, processor: async (ctx, block, log, state) => { const data = abi.events.Stake.decode(log) - const id = log.id + const id = `${chainId}:${log.id}` const entity = new ExponentialStakingStake({ id, chainId, @@ -141,7 +157,7 @@ export const createExponentialStakingTracker = ({ filter: unstakeFilter, processor: async (ctx, block, log, state) => { const data = abi.events.Unstake.decode(log) - const id = log.id + const id = `${chainId}:${log.id}` const entity = new ExponentialStakingUnstake({ id, chainId, @@ -155,7 +171,7 @@ export const createExponentialStakingTracker = ({ state.unstake.set(id, entity) }, }, - + // State Entity Processors { description: 'Handle Stake for Lockup', diff --git a/types.graphql b/types.graphql index 41eb3051..b3d0470a 100644 --- a/types.graphql +++ b/types.graphql @@ -16,6 +16,3 @@ scalar BigDecimal scalar Bytes scalar DateTime scalar JSON - - -# OToken Types \ No newline at end of file From 6c90fa2826e5ab6fc9ff560d555eb73bb7819838 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Sat, 18 May 2024 12:33:24 -0700 Subject: [PATCH 05/13] governance schema/template --- package-lock.json | 8 +- package.json | 2 +- schema.graphql | 17 +- schema/governance.graphql | 15 +- schema/ogv.graphql | 2 +- ...ent.ts => _governanceProposalEventType.ts} | 2 +- .../generated/governanceProposal.model.ts | 21 +- ...el.ts => governanceProposalEvent.model.ts} | 8 +- .../generated/governanceProposalVote.model.ts | 8 +- src/model/generated/index.ts | 4 +- src/model/generated/ogvProposal.model.ts | 6 +- src/ogv/post-processors/governance.ts | 144 ++------ .../exponential-staking.ts | 18 +- src/templates/governance/governance.ts | 332 ++++++++++++++++++ src/templates/governance/index.ts | 1 + 15 files changed, 429 insertions(+), 159 deletions(-) rename src/model/generated/{_governanceProposalEvent.ts => _governanceProposalEventType.ts} (75%) rename src/model/generated/{governanceProposalTxLog.model.ts => governanceProposalEvent.model.ts} (75%) create mode 100644 src/templates/governance/governance.ts create mode 100644 src/templates/governance/index.ts diff --git a/package-lock.json b/package-lock.json index e4ce9067..c7e2f6c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,7 +7,7 @@ "name": "origin-squid", "dependencies": { "@subsquid/archive-registry": "^3.3.0", - "@subsquid/evm-processor": "^1.19.0", + "@subsquid/evm-processor": "^1.19.1", "@subsquid/graphql-server": "^4.6.0", "@subsquid/typeorm-migration": "^1.3.0", "@subsquid/typeorm-store": "^1.5.1", @@ -1213,9 +1213,9 @@ } }, "node_modules/@subsquid/evm-processor": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/@subsquid/evm-processor/-/evm-processor-1.19.0.tgz", - "integrity": "sha512-AswCaV3AA/PGj4JRh6rtZoCSvFQBGzFa91ejibm/8uR30WKMbPnjD2HI8QtVchgoWVOXY8QsM+hoeznE4cuzCA==", + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/@subsquid/evm-processor/-/evm-processor-1.19.1.tgz", + "integrity": "sha512-wJIzd5bMDDZmOZ0cgjzobqdFt+UtBRwEb4jtpb47Z4uZuPketrKSxG3njcs3V6DaqbdwAXiHBmWhbo7TMkHjPQ==", "dependencies": { "@subsquid/http-client": "^1.4.0", "@subsquid/logger": "^1.3.3", diff --git a/package.json b/package.json index 8dd9c17e..f8672559 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ }, "dependencies": { "@subsquid/archive-registry": "^3.3.0", - "@subsquid/evm-processor": "^1.19.0", + "@subsquid/evm-processor": "^1.19.1", "@subsquid/graphql-server": "^4.6.0", "@subsquid/typeorm-migration": "^1.3.0", "@subsquid/typeorm-store": "^1.5.1", diff --git a/schema.graphql b/schema.graphql index 12953189..84bbc649 100644 --- a/schema.graphql +++ b/schema.graphql @@ -397,7 +397,7 @@ enum GovernanceProposalState { Executed } -enum GovernanceProposalEvent { +enum GovernanceProposalEventType { Created Queued Canceled @@ -411,16 +411,19 @@ enum GovernanceVoteType { Abstain } -type GovernanceProposalTxLog @entity { +type GovernanceProposalEvent @entity { id: ID! hash: String! - event: GovernanceProposalEvent! + event: GovernanceProposalEventType! timestamp: DateTime! proposal: GovernanceProposal! @index } type GovernanceProposal @entity { id: ID! @index + chainId: Int! + address: String! + proposalId: BigInt! description: String proposer: String! timestamp: DateTime! @@ -428,14 +431,16 @@ type GovernanceProposal @entity { endBlock: BigInt! lastUpdated: DateTime! status: GovernanceProposalState! - logs: [GovernanceProposalTxLog]! @derivedFrom(field: "proposal") + events: [GovernanceProposalEvent]! @derivedFrom(field: "proposal") quorum: BigInt! choices: [String]! - scores: [Float]! + scores: [String]! } type GovernanceProposalVote @entity { id: ID! + chainId: Int! + address: String! proposal: GovernanceProposal! @index voter: String! @index weight: BigInt! @@ -706,7 +711,7 @@ type OGVProposal @entity { logs: [OGVProposalTxLog]! @derivedFrom(field: "proposal") quorum: BigInt! choices: [String]! - scores: [Float]! + scores: [String]! } type OGVProposalVote @entity { diff --git a/schema/governance.graphql b/schema/governance.graphql index 06c3373b..d4bf70f2 100644 --- a/schema/governance.graphql +++ b/schema/governance.graphql @@ -9,7 +9,7 @@ enum GovernanceProposalState { Executed } -enum GovernanceProposalEvent { +enum GovernanceProposalEventType { Created Queued Canceled @@ -23,16 +23,19 @@ enum GovernanceVoteType { Abstain } -type GovernanceProposalTxLog @entity { +type GovernanceProposalEvent @entity { id: ID! hash: String! - event: GovernanceProposalEvent! + event: GovernanceProposalEventType! timestamp: DateTime! proposal: GovernanceProposal! @index } type GovernanceProposal @entity { id: ID! @index + chainId: Int! + address: String! + proposalId: BigInt! description: String proposer: String! timestamp: DateTime! @@ -40,14 +43,16 @@ type GovernanceProposal @entity { endBlock: BigInt! lastUpdated: DateTime! status: GovernanceProposalState! - logs: [GovernanceProposalTxLog]! @derivedFrom(field: "proposal") + events: [GovernanceProposalEvent]! @derivedFrom(field: "proposal") quorum: BigInt! choices: [String]! - scores: [Float]! + scores: [String]! } type GovernanceProposalVote @entity { id: ID! + chainId: Int! + address: String! proposal: GovernanceProposal! @index voter: String! @index weight: BigInt! diff --git a/schema/ogv.graphql b/schema/ogv.graphql index fc39ed88..312b5bea 100644 --- a/schema/ogv.graphql +++ b/schema/ogv.graphql @@ -90,7 +90,7 @@ type OGVProposal @entity { logs: [OGVProposalTxLog]! @derivedFrom(field: "proposal") quorum: BigInt! choices: [String]! - scores: [Float]! + scores: [String]! } type OGVProposalVote @entity { diff --git a/src/model/generated/_governanceProposalEvent.ts b/src/model/generated/_governanceProposalEventType.ts similarity index 75% rename from src/model/generated/_governanceProposalEvent.ts rename to src/model/generated/_governanceProposalEventType.ts index bffb8eab..8a7baab7 100644 --- a/src/model/generated/_governanceProposalEvent.ts +++ b/src/model/generated/_governanceProposalEventType.ts @@ -1,4 +1,4 @@ -export enum GovernanceProposalEvent { +export enum GovernanceProposalEventType { Created = "Created", Queued = "Queued", Canceled = "Canceled", diff --git a/src/model/generated/governanceProposal.model.ts b/src/model/generated/governanceProposal.model.ts index 69cc7785..3d6baf4f 100644 --- a/src/model/generated/governanceProposal.model.ts +++ b/src/model/generated/governanceProposal.model.ts @@ -1,6 +1,6 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_, OneToMany as OneToMany_, FloatColumn as FloatColumn_} from "@subsquid/typeorm-store" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_, DateTimeColumn as DateTimeColumn_, OneToMany as OneToMany_} from "@subsquid/typeorm-store" import {GovernanceProposalState} from "./_governanceProposalState" -import {GovernanceProposalTxLog} from "./governanceProposalTxLog.model" +import {GovernanceProposalEvent} from "./governanceProposalEvent.model" @Entity_() export class GovernanceProposal { @@ -11,6 +11,15 @@ export class GovernanceProposal { @PrimaryColumn_() id!: string + @IntColumn_({nullable: false}) + chainId!: number + + @StringColumn_({nullable: false}) + address!: string + + @BigIntColumn_({nullable: false}) + proposalId!: bigint + @StringColumn_({nullable: true}) description!: string | undefined | null @@ -32,8 +41,8 @@ export class GovernanceProposal { @Column_("varchar", {length: 9, nullable: false}) status!: GovernanceProposalState - @OneToMany_(() => GovernanceProposalTxLog, e => e.proposal) - logs!: GovernanceProposalTxLog[] + @OneToMany_(() => GovernanceProposalEvent, e => e.proposal) + events!: GovernanceProposalEvent[] @BigIntColumn_({nullable: false}) quorum!: bigint @@ -41,6 +50,6 @@ export class GovernanceProposal { @StringColumn_({array: true, nullable: false}) choices!: (string | undefined | null)[] - @FloatColumn_({array: true, nullable: false}) - scores!: (number | undefined | null)[] + @StringColumn_({array: true, nullable: false}) + scores!: (string | undefined | null)[] } diff --git a/src/model/generated/governanceProposalTxLog.model.ts b/src/model/generated/governanceProposalEvent.model.ts similarity index 75% rename from src/model/generated/governanceProposalTxLog.model.ts rename to src/model/generated/governanceProposalEvent.model.ts index 49ae83dd..0cbfb7e2 100644 --- a/src/model/generated/governanceProposalTxLog.model.ts +++ b/src/model/generated/governanceProposalEvent.model.ts @@ -1,10 +1,10 @@ import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, ManyToOne as ManyToOne_, Index as Index_} from "@subsquid/typeorm-store" -import {GovernanceProposalEvent} from "./_governanceProposalEvent" +import {GovernanceProposalEventType} from "./_governanceProposalEventType" import {GovernanceProposal} from "./governanceProposal.model" @Entity_() -export class GovernanceProposalTxLog { - constructor(props?: Partial) { +export class GovernanceProposalEvent { + constructor(props?: Partial) { Object.assign(this, props) } @@ -15,7 +15,7 @@ export class GovernanceProposalTxLog { hash!: string @Column_("varchar", {length: 8, nullable: false}) - event!: GovernanceProposalEvent + event!: GovernanceProposalEventType @DateTimeColumn_({nullable: false}) timestamp!: Date diff --git a/src/model/generated/governanceProposalVote.model.ts b/src/model/generated/governanceProposalVote.model.ts index adda003a..2c10dd63 100644 --- a/src/model/generated/governanceProposalVote.model.ts +++ b/src/model/generated/governanceProposalVote.model.ts @@ -1,4 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_, DateTimeColumn as DateTimeColumn_} from "@subsquid/typeorm-store" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, StringColumn as StringColumn_, ManyToOne as ManyToOne_, Index as Index_, BigIntColumn as BigIntColumn_, DateTimeColumn as DateTimeColumn_} from "@subsquid/typeorm-store" import {GovernanceProposal} from "./governanceProposal.model" import {GovernanceVoteType} from "./_governanceVoteType" @@ -11,6 +11,12 @@ export class GovernanceProposalVote { @PrimaryColumn_() id!: string + @IntColumn_({nullable: false}) + chainId!: number + + @StringColumn_({nullable: false}) + address!: string + @Index_() @ManyToOne_(() => GovernanceProposal, {nullable: true}) proposal!: GovernanceProposal diff --git a/src/model/generated/index.ts b/src/model/generated/index.ts index 7ab1c53d..1254d7c5 100644 --- a/src/model/generated/index.ts +++ b/src/model/generated/index.ts @@ -32,8 +32,8 @@ export * from "./_liquiditySourceType" export * from "./liquidityDailyBalance.model" export * from "./bridgeTransfer.model" export * from "./bridgeTransferState.model" -export * from "./governanceProposalTxLog.model" -export * from "./_governanceProposalEvent" +export * from "./governanceProposalEvent.model" +export * from "./_governanceProposalEventType" export * from "./governanceProposal.model" export * from "./_governanceProposalState" export * from "./governanceProposalVote.model" diff --git a/src/model/generated/ogvProposal.model.ts b/src/model/generated/ogvProposal.model.ts index f5c317bf..5e433bde 100644 --- a/src/model/generated/ogvProposal.model.ts +++ b/src/model/generated/ogvProposal.model.ts @@ -1,4 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, StringColumn as StringColumn_, ManyToOne as ManyToOne_, Index as Index_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_, OneToMany as OneToMany_, FloatColumn as FloatColumn_} from "@subsquid/typeorm-store" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, StringColumn as StringColumn_, ManyToOne as ManyToOne_, Index as Index_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_, OneToMany as OneToMany_} from "@subsquid/typeorm-store" import {OGVAddress} from "./ogvAddress.model" import {OGVProposalState} from "./_ogvProposalState" import {OGVProposalTxLog} from "./ogvProposalTxLog.model" @@ -43,6 +43,6 @@ export class OGVProposal { @StringColumn_({array: true, nullable: false}) choices!: (string | undefined | null)[] - @FloatColumn_({array: true, nullable: false}) - scores!: (number | undefined | null)[] + @StringColumn_({array: true, nullable: false}) + scores!: (string | undefined | null)[] } diff --git a/src/ogv/post-processors/governance.ts b/src/ogv/post-processors/governance.ts index cedb970b..601dba3f 100644 --- a/src/ogv/post-processors/governance.ts +++ b/src/ogv/post-processors/governance.ts @@ -87,10 +87,7 @@ export const process = async (ctx: Context) => { ) { await _processProposalEvents(ctx, result, block, log) } else if ( - [ - governanceAbi.events.VoteCast.topic, - governanceAbi.events.VoteCastWithParams.topic, - ].includes(firstTopic) + [governanceAbi.events.VoteCast.topic, governanceAbi.events.VoteCastWithParams.topic].includes(firstTopic) ) { await _processVoteCast(ctx, result, block, log) } @@ -101,13 +98,7 @@ export const process = async (ctx: Context) => { ctx.log.error('Could not process governance event') } } - await _updateProposalStatuses( - ctx, - result, - block, - goActiveBlock, - goFinishedBlock, - ) + await _updateProposalStatuses(ctx, result, block, goActiveBlock, goFinishedBlock) } await ctx.store.upsert(Array.from(result.addresses.values())) @@ -116,12 +107,7 @@ export const process = async (ctx: Context) => { await ctx.store.upsert(result.votes) } -const _processProposalCreated = async ( - ctx: Context, - result: IProcessResult, - block: Block, - log: Log, -) => { +const _processProposalCreated = async (ctx: Context, result: IProcessResult, block: Block, log: Log) => { // ctx.log.info('_processProposalCreated') const { proposalId, @@ -132,11 +118,7 @@ const _processProposalCreated = async ( } = governanceAbi.events.ProposalCreated.decode(log) const proposer = await _getAddress(ctx, proposerAddr, result) const blockTimestamp = new Date(block.header.timestamp) - const governance = new governanceAbi.Contract( - ctx, - block.header, - GOVERNANCE_ADDRESS, - ) + const governance = new governanceAbi.Contract(ctx, block.header, GOVERNANCE_ADDRESS) const proposal = new OGVProposal({ id: proposalId.toString(), @@ -179,23 +161,17 @@ const proposalStateMap = [ const eventMapper = { [governanceAbi.events.ProposalQueued.topic]: { - decode: governanceAbi.events.ProposalQueued.decode.bind( - governanceAbi.events.ProposalQueued, - ), + decode: governanceAbi.events.ProposalQueued.decode.bind(governanceAbi.events.ProposalQueued), status: OGVProposalState.Queued, event: OGVProposalEvent.Queued, }, [governanceAbi.events.ProposalCanceled.topic]: { - decode: governanceAbi.events.ProposalCanceled.decode.bind( - governanceAbi.events.ProposalCanceled, - ), + decode: governanceAbi.events.ProposalCanceled.decode.bind(governanceAbi.events.ProposalCanceled), status: OGVProposalState.Canceled, event: OGVProposalEvent.Canceled, }, [governanceAbi.events.ProposalExecuted.topic]: { - decode: governanceAbi.events.ProposalExecuted.decode.bind( - governanceAbi.events.ProposalExecuted, - ), + decode: governanceAbi.events.ProposalExecuted.decode.bind(governanceAbi.events.ProposalExecuted), status: OGVProposalState.Executed, event: OGVProposalEvent.Executed, }, @@ -203,16 +179,10 @@ const eventMapper = { const _updateStatusBlocks = () => { goActiveBlock = Number( - pendingProposals.reduce( - (min, p) => (p.startBlock < min ? p.startBlock : min), - BigInt(Number.MAX_SAFE_INTEGER), - ), + pendingProposals.reduce((min, p) => (p.startBlock < min ? p.startBlock : min), BigInt(Number.MAX_SAFE_INTEGER)), ) goFinishedBlock = Number( - activeProposals.reduce( - (min, p) => (p.endBlock < min ? p.endBlock : min), - BigInt(Number.MAX_SAFE_INTEGER), - ), + activeProposals.reduce((min, p) => (p.endBlock < min ? p.endBlock : min), BigInt(Number.MAX_SAFE_INTEGER)), ) } @@ -226,58 +196,34 @@ const _updateProposalStatuses = async ( // Update for Active and post-Active statuses. if (block.header.height > goActiveBlock) { ctx.log.info('block.header.height > goActiveBlock') - for (const proposal of pendingProposals.filter( - (p) => block.header.height > Number(p.startBlock), - )) { + for (const proposal of pendingProposals.filter((p) => block.header.height > Number(p.startBlock))) { await _updateProposalStatus(ctx, result, block, proposal.id) } - pendingProposals = pendingProposals.filter( - (p) => block.header.height <= Number(p.startBlock), - ) + pendingProposals = pendingProposals.filter((p) => block.header.height <= Number(p.startBlock)) } if (block.header.height > goFinishedBlock) { ctx.log.info('block.header.height > goFinishedBlock') - for (const proposal of activeProposals.filter( - (p) => block.header.height > Number(p.endBlock), - )) { + for (const proposal of activeProposals.filter((p) => block.header.height > Number(p.endBlock))) { await _updateProposalStatus(ctx, result, block, proposal.id) } - activeProposals = activeProposals.filter( - (p) => block.header.height <= Number(p.endBlock), - ) + activeProposals = activeProposals.filter((p) => block.header.height <= Number(p.endBlock)) } _updateStatusBlocks() } -const _updateProposalStatus = async ( - ctx: Context, - result: IProcessResult, - block: Block, - proposalId: string, -) => { +const _updateProposalStatus = async (ctx: Context, result: IProcessResult, block: Block, proposalId: string) => { const proposal = await _getProposal(ctx, proposalId, result) proposal.status = await _getProposalState(ctx, block, BigInt(proposalId)) ctx.log.info({ status: proposal.status }, '_updateProposalStatus') - if ( - proposal.status === OGVProposalState.Pending && - !pendingProposals.find((p) => p.id === proposal.id) - ) { + if (proposal.status === OGVProposalState.Pending && !pendingProposals.find((p) => p.id === proposal.id)) { pendingProposals.push(proposal) } - if ( - proposal.status === OGVProposalState.Active && - !activeProposals.find((p) => p.id === proposal.id) - ) { + if (proposal.status === OGVProposalState.Active && !activeProposals.find((p) => p.id === proposal.id)) { activeProposals.push(proposal) } } -const _processProposalEvents = async ( - ctx: Context, - result: IProcessResult, - block: Block, - log: Log, -) => { +const _processProposalEvents = async (ctx: Context, result: IProcessResult, block: Block, log: Log) => { // ctx.log.info('_processProposalEvents') const { decode, status, event } = eventMapper[log.topics[0]]! @@ -298,15 +244,9 @@ const _processProposalEvents = async ( result.proposalLogs.push(proposalTxLog) } -const _processProposalExtended = async ( - ctx: Context, - result: IProcessResult, - block: Block, - log: Log, -) => { +const _processProposalExtended = async (ctx: Context, result: IProcessResult, block: Block, log: Log) => { // ctx.log.info('_processProposalExtended') - const { proposalId, extendedDeadline } = - governanceAbi.events.ProposalExtended.decode(log) + const { proposalId, extendedDeadline } = governanceAbi.events.ProposalExtended.decode(log) const blockTimestamp = new Date(block.header.timestamp) const proposal = await _getProposal(ctx, proposalId.toString(), result) @@ -324,12 +264,7 @@ const _processProposalExtended = async ( result.proposalLogs.push(proposalTxLog) } -const _processVoteCast = async ( - ctx: Context, - result: IProcessResult, - block: Block, - log: Log, -) => { +const _processVoteCast = async (ctx: Context, result: IProcessResult, block: Block, log: Log) => { // ctx.log.info('_processVoteCast') const { proposalId, @@ -344,9 +279,7 @@ const _processVoteCast = async ( const proposal = await _getProposal(ctx, proposalId.toString(), result) const voter = await _getAddress(ctx, voterAddr, result) - const voteType = [OGVVoteType.Against, OGVVoteType.For, OGVVoteType.Abstain][ - parseInt(support.toString()) - ] + const voteType = [OGVVoteType.Against, OGVVoteType.For, OGVVoteType.Abstain][parseInt(support.toString())] const proposalVote = new OGVProposalVote({ id: `${proposalId.toString()}:${log.transactionHash}:${voter.id}`, proposal, @@ -357,40 +290,23 @@ const _processVoteCast = async ( type: voteType, }) - const weightN = Number(formatEther(weight)) const choiceIndex = proposal.choices.indexOf(voteType) if (choiceIndex >= 0) { - proposal.scores[choiceIndex]! += weightN + proposal.scores[choiceIndex] = (BigInt(proposal.scores[choiceIndex]!) + weight).toString() } else { proposal.choices.push(voteType) - proposal.scores.push(weightN) + proposal.scores.push(weight.toString()) } result.votes.push(proposalVote) } -const _getProposalState = async ( - ctx: Context, - block: Block, - proposalId: bigint, -): Promise => { - const governance = new governanceAbi.Contract( - ctx, - block.header, - GOVERNANCE_ADDRESS, - ) - return ( - proposalStateMap[ - parseInt((await governance.state(proposalId)).toString()) - ] || OGVProposalState.Pending - ) +const _getProposalState = async (ctx: Context, block: Block, proposalId: bigint): Promise => { + const governance = new governanceAbi.Contract(ctx, block.header, GOVERNANCE_ADDRESS) + return proposalStateMap[parseInt((await governance.state(proposalId)).toString())] || OGVProposalState.Pending } -const _getAddress = async ( - ctx: Context, - id: string, - result: IProcessResult, -): Promise => { +const _getAddress = async (ctx: Context, id: string, result: IProcessResult): Promise => { id = id.toLowerCase() const { addresses } = result @@ -407,11 +323,7 @@ const _getAddress = async ( return address } -const _getProposal = async ( - ctx: Context, - id: string, - result: IProcessResult, -): Promise => { +const _getProposal = async (ctx: Context, id: string, result: IProcessResult): Promise => { const { proposals } = result if (proposals.has(id)) { diff --git a/src/templates/exponential-staking/exponential-staking.ts b/src/templates/exponential-staking/exponential-staking.ts index 79e97f5e..8877dc0d 100644 --- a/src/templates/exponential-staking/exponential-staking.ts +++ b/src/templates/exponential-staking/exponential-staking.ts @@ -27,15 +27,7 @@ interface State { unstake: Map } -export const createExponentialStakingTracker = ({ - from, - chainId, - address, -}: { - from: number - chainId: number - address: TokenAddress -}) => { +export const createExponentialStakingTracker = ({ from, address }: { from: number; address: TokenAddress }) => { const delegateChangedFilter = logFilter({ address: [address], topic0: [abi.events.DelegateChanged.topic], @@ -71,6 +63,7 @@ export const createExponentialStakingTracker = ({ description: 'Create DelegateChanged event', filter: delegateChangedFilter, processor: async (ctx, block, log, state) => { + const chainId = ctx.chain.id const data = abi.events.DelegateChanged.decode(log) const id = `${chainId}:${log.id}` const entity = new ExponentialStakingDelegateChanged({ @@ -88,6 +81,7 @@ export const createExponentialStakingTracker = ({ description: 'Create DelegateVotesChanged event', filter: delegateVotesChangedFilter, processor: async (ctx, block, log, state) => { + const chainId = ctx.chain.id const data = abi.events.DelegateVotesChanged.decode(log) const id = `${chainId}:${log.id}` const entity = new ExponentialStakingDelegateVotesChanged({ @@ -105,6 +99,7 @@ export const createExponentialStakingTracker = ({ description: 'Create Penalty event', filter: penaltyFilter, processor: async (ctx, block, log, state) => { + const chainId = ctx.chain.id const data = abi.events.Penalty.decode(log) const id = `${chainId}:${log.id}` const entity = new ExponentialStakingPenalty({ @@ -121,6 +116,7 @@ export const createExponentialStakingTracker = ({ description: 'Create Reward event', filter: penaltyFilter, processor: async (ctx, block, log, state) => { + const chainId = ctx.chain.id const data = abi.events.Reward.decode(log) const id = `${chainId}:${log.id}` const entity = new ExponentialStakingReward({ @@ -137,6 +133,7 @@ export const createExponentialStakingTracker = ({ description: 'Create Stake event', filter: stakeFilter, processor: async (ctx, block, log, state) => { + const chainId = ctx.chain.id const data = abi.events.Stake.decode(log) const id = `${chainId}:${log.id}` const entity = new ExponentialStakingStake({ @@ -156,6 +153,7 @@ export const createExponentialStakingTracker = ({ description: 'Create Unstake event', filter: unstakeFilter, processor: async (ctx, block, log, state) => { + const chainId = ctx.chain.id const data = abi.events.Unstake.decode(log) const id = `${chainId}:${log.id}` const entity = new ExponentialStakingUnstake({ @@ -177,6 +175,7 @@ export const createExponentialStakingTracker = ({ description: 'Handle Stake for Lockup', filter: stakeFilter, processor: async (ctx, block, log, state) => { + const chainId = ctx.chain.id const data = abi.events.Stake.decode(log) const id = `${chainId}:${address}:${data.lockupId}` const entity = new ExponentialStakingLockup({ @@ -199,6 +198,7 @@ export const createExponentialStakingTracker = ({ description: 'Handle Unstake for Lockup', filter: unstakeFilter, processor: async (ctx, block, log, state) => { + const chainId = ctx.chain.id const data = abi.events.Unstake.decode(log) const id = `${chainId}:${address}:${data.lockupId}` const entity = state.lockup.get(id) ?? (await ctx.store.get(ExponentialStakingLockup, id)) diff --git a/src/templates/governance/governance.ts b/src/templates/governance/governance.ts new file mode 100644 index 00000000..5e4ae2ca --- /dev/null +++ b/src/templates/governance/governance.ts @@ -0,0 +1,332 @@ +import { add } from 'lodash' +import { Hex } from 'viem' + +import * as governanceAbi from '@abi/governance' +import { + GovernanceProposal, + GovernanceProposalEvent, + GovernanceProposalEventType, + GovernanceProposalState, + GovernanceProposalVote, + GovernanceVoteType, +} from '@model' +import { Block, Context, Log } from '@processor' +import { EvmBatchProcessor } from '@subsquid/evm-processor' +import { env } from '@utils/env' + +interface IProcessResult { + proposals: Map + proposalEvents: GovernanceProposalEvent[] + votes: GovernanceProposalVote[] +} + +const proposalStateMap = [ + GovernanceProposalState.Pending, + GovernanceProposalState.Active, + GovernanceProposalState.Canceled, + GovernanceProposalState.Defeated, + GovernanceProposalState.Succeeded, + GovernanceProposalState.Queued, + GovernanceProposalState.Expired, + GovernanceProposalState.Executed, +] + +const eventMapper = { + [governanceAbi.events.ProposalQueued.topic]: { + decode: governanceAbi.events.ProposalQueued.decode.bind(governanceAbi.events.ProposalQueued), + status: GovernanceProposalState.Queued, + event: GovernanceProposalEventType.Queued, + }, + [governanceAbi.events.ProposalCanceled.topic]: { + decode: governanceAbi.events.ProposalCanceled.decode.bind(governanceAbi.events.ProposalCanceled), + status: GovernanceProposalState.Canceled, + event: GovernanceProposalEventType.Canceled, + }, + [governanceAbi.events.ProposalExecuted.topic]: { + decode: governanceAbi.events.ProposalExecuted.decode.bind(governanceAbi.events.ProposalExecuted), + status: GovernanceProposalState.Executed, + event: GovernanceProposalEventType.Executed, + }, +} + +export const createGovernanceProcessor = ({ from, address }: { from: number; address: Hex }) => { + const setup = (processor: EvmBatchProcessor) => { + processor.addLog({ + address: [address], + topic0: [ + governanceAbi.events.ProposalCreated.topic, + governanceAbi.events.ProposalExecuted.topic, + governanceAbi.events.ProposalExtended.topic, + governanceAbi.events.ProposalQueued.topic, + governanceAbi.events.ProposalCanceled.topic, + governanceAbi.events.VoteCast.topic, + governanceAbi.events.VoteCastWithParams.topic, + ], + range: { from }, + }) + processor.includeAllBlocks({ from }) + } + + let pendingProposals: GovernanceProposal[] = [] + let activeProposals: GovernanceProposal[] = [] + let goActiveBlock = 0 + let goFinishedBlock = 0 + + const initialize = async (ctx: Context) => { + const pending = await ctx.store.findBy(GovernanceProposal, { + status: GovernanceProposalState.Pending, + }) + const active = await ctx.store.findBy(GovernanceProposal, { + status: GovernanceProposalState.Active, + }) + pendingProposals.push(...pending) + activeProposals.push(...active) + } + + const process = async (ctx: Context) => { + if (ctx.blocks[ctx.blocks.length - 1]?.header.height < from) return + + const result: IProcessResult = { + proposals: new Map(), + proposalEvents: [], + votes: [], + } + + _updateStatusBlocks() + for (const block of ctx.blocks) { + for (const log of block.logs) { + if (log.address !== address) continue + + const firstTopic = log.topics[0] + try { + if (firstTopic == governanceAbi.events.ProposalCreated.topic) { + await _processProposalCreated(ctx, result, block, log) + } else if (firstTopic == governanceAbi.events.ProposalExtended.topic) { + await _processProposalExtended(ctx, result, block, log) + } else if ( + [ + governanceAbi.events.ProposalQueued.topic, + governanceAbi.events.ProposalCanceled.topic, + governanceAbi.events.ProposalExecuted.topic, + ].includes(firstTopic) + ) { + await _processProposalEvents(ctx, result, block, log) + } else if ( + [governanceAbi.events.VoteCast.topic, governanceAbi.events.VoteCastWithParams.topic].includes(firstTopic) + ) { + await _processVoteCast(ctx, result, block, log) + } + } catch (e) { + if (!env.BLOCK_FROM) { + throw e + } + ctx.log.error('Could not process governance event') + } + } + await _updateProposalStatuses(ctx, result, block, goActiveBlock, goFinishedBlock) + } + + await ctx.store.upsert(Array.from(result.proposals.values())) + await ctx.store.upsert(result.proposalEvents) + await ctx.store.upsert(result.votes) + } + + const _processProposalCreated = async (ctx: Context, result: IProcessResult, block: Block, log: Log) => { + // ctx.log.info('_processProposalCreated') + const { + proposalId, + proposer: proposerAddr, + description, + startBlock, + endBlock, + } = governanceAbi.events.ProposalCreated.decode(log) + const blockTimestamp = new Date(block.header.timestamp) + const governance = new governanceAbi.Contract(ctx, block.header, address) + + const proposal = new GovernanceProposal({ + id: `${ctx.chain.id}:${address}:${proposalId}`, + chainId: ctx.chain.id, + address, + proposalId, + description, + proposer: proposerAddr.toLowerCase(), + timestamp: blockTimestamp, + startBlock, + endBlock, + lastUpdated: new Date(), + status: GovernanceProposalState.Pending, + quorum: await governance.quorum(BigInt(block.header.height - 1)), + choices: [], + scores: [], + }) + + pendingProposals.push(proposal) + + const proposalTxLog = new GovernanceProposalEvent({ + id: `${ctx.chain.id}:${log.id}`, + proposal, + event: GovernanceProposalEventType.Created, + hash: log.transactionHash, + timestamp: blockTimestamp, + }) + + result.proposals.set(proposalId.toString(), proposal) + result.proposalEvents.push(proposalTxLog) + } + + const _updateStatusBlocks = () => { + goActiveBlock = Number( + pendingProposals.reduce((min, p) => (p.startBlock < min ? p.startBlock : min), BigInt(Number.MAX_SAFE_INTEGER)), + ) + goFinishedBlock = Number( + activeProposals.reduce((min, p) => (p.endBlock < min ? p.endBlock : min), BigInt(Number.MAX_SAFE_INTEGER)), + ) + } + + const _updateProposalStatuses = async ( + ctx: Context, + result: IProcessResult, + block: Block, + goActiveBlock: number, + goFinishedBlock: number, + ) => { + // Update for Active and post-Active statuses. + if (block.header.height > goActiveBlock) { + ctx.log.info('block.header.height > goActiveBlock') + for (const proposal of pendingProposals.filter((p) => block.header.height > Number(p.startBlock))) { + await _updateProposalStatus(ctx, result, block, proposal.id) + } + pendingProposals = pendingProposals.filter((p) => block.header.height <= Number(p.startBlock)) + } + if (block.header.height > goFinishedBlock) { + ctx.log.info('block.header.height > goFinishedBlock') + for (const proposal of activeProposals.filter((p) => block.header.height > Number(p.endBlock))) { + await _updateProposalStatus(ctx, result, block, proposal.id) + } + activeProposals = activeProposals.filter((p) => block.header.height <= Number(p.endBlock)) + } + _updateStatusBlocks() + } + + const _updateProposalStatus = async (ctx: Context, result: IProcessResult, block: Block, proposalId: string) => { + const proposal = await _getProposal(ctx, proposalId, result) + proposal.status = await _getProposalState(ctx, block, BigInt(proposalId)) + ctx.log.info({ status: proposal.status }, '_updateProposalStatus') + if (proposal.status === GovernanceProposalState.Pending && !pendingProposals.find((p) => p.id === proposal.id)) { + pendingProposals.push(proposal) + } + if (proposal.status === GovernanceProposalState.Active && !activeProposals.find((p) => p.id === proposal.id)) { + activeProposals.push(proposal) + } + } + + const _processProposalEvents = async (ctx: Context, result: IProcessResult, block: Block, log: Log) => { + // ctx.log.info('_processProposalEvents') + const { decode, status, event } = eventMapper[log.topics[0]]! + + const { proposalId } = decode(log) + const blockTimestamp = new Date(block.header.timestamp) + + const proposal = await _getProposal(ctx, proposalId.toString(), result) + await _updateProposalStatus(ctx, result, block, proposalId.toString()) + + const proposalTxLog = new GovernanceProposalEvent({ + id: `${ctx.chain.id}:${log.id}`, + proposal, + event, + hash: log.transactionHash, + timestamp: blockTimestamp, + }) + + result.proposalEvents.push(proposalTxLog) + } + + const _processProposalExtended = async (ctx: Context, result: IProcessResult, block: Block, log: Log) => { + // ctx.log.info('_processProposalExtended') + const { proposalId, extendedDeadline } = governanceAbi.events.ProposalExtended.decode(log) + const blockTimestamp = new Date(block.header.timestamp) + + const proposal = await _getProposal(ctx, proposalId.toString(), result) + proposal.endBlock = extendedDeadline + await _updateProposalStatus(ctx, result, block, proposalId.toString()) + + const proposalTxLog = new GovernanceProposalEvent({ + id: `${ctx.chain.id}:${log.id}`, + proposal, + event: GovernanceProposalEventType.Extended, + hash: log.transactionHash, + timestamp: blockTimestamp, + }) + + result.proposalEvents.push(proposalTxLog) + } + + const _processVoteCast = async (ctx: Context, result: IProcessResult, block: Block, log: Log) => { + // ctx.log.info('_processVoteCast') + const { + proposalId, + voter: voterAddr, + weight, + support, + } = log.topics[0] == governanceAbi.events.VoteCast.topic + ? governanceAbi.events.VoteCast.decode(log) + : governanceAbi.events.VoteCastWithParams.decode(log) + const blockTimestamp = new Date(block.header.timestamp) + + const proposal = await _getProposal(ctx, proposalId.toString(), result) + + const voteType = [GovernanceVoteType.Against, GovernanceVoteType.For, GovernanceVoteType.Abstain][ + parseInt(support.toString()) + ] + const proposalVote = new GovernanceProposalVote({ + id: `${ctx.chain.id}:${log.id}`, + chainId: ctx.chain.id, + address, + proposal, + voter: voterAddr.toLowerCase(), + txHash: log.transactionHash, + timestamp: blockTimestamp, + weight, + type: voteType, + }) + + const choiceIndex = proposal.choices.indexOf(voteType) + if (choiceIndex >= 0) { + proposal.scores[choiceIndex] = (BigInt(proposal.scores[choiceIndex]!) + weight).toString() + } else { + proposal.choices.push(voteType) + proposal.scores.push(weight.toString()) + } + + result.votes.push(proposalVote) + } + + const _getProposalState = async ( + ctx: Context, + block: Block, + proposalId: bigint, + ): Promise => { + const governance = new governanceAbi.Contract(ctx, block.header, address) + return ( + proposalStateMap[parseInt((await governance.state(proposalId)).toString())] || GovernanceProposalState.Pending + ) + } + + const _getProposal = async (ctx: Context, id: string, result: IProcessResult): Promise => { + const { proposals } = result + + if (proposals.has(id)) { + return proposals.get(id)! + } + + const proposal = await ctx.store.findOneByOrFail(GovernanceProposal, { + id, + }) + + proposals.set(id, proposal) + + return proposal + } + + return { setup, initialize, process } +} diff --git a/src/templates/governance/index.ts b/src/templates/governance/index.ts new file mode 100644 index 00000000..ad10ccee --- /dev/null +++ b/src/templates/governance/index.ts @@ -0,0 +1 @@ +export * from './governance' From ec0afc36d9907e5614e23ec46fe898831ac8477d Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Tue, 21 May 2024 17:02:37 -0700 Subject: [PATCH 06/13] fixes and additional processing --- abi/fixed-rate-rewards-source.json | 311 ++++++++++++++++++ ...86799972-Data.js => 1716332143675-Data.js} | 162 ++++++++- schema.graphql | 59 +++- schema/exponential-staking.graphql | 2 + schema/fixed-rate-rewards-source.graphql | 52 +++ schema/governance.graphql | 4 + src/abi/fixed-rate-rewards-source.ts | 112 +++++++ src/main-mainnet.ts | 15 +- src/mainnet/processors/erc20s.ts | 11 +- .../exponentialStakingLockup.model.ts | 8 +- .../generated/governanceProposal.model.ts | 12 + .../governorshipTransferred.model.ts | 33 ++ src/model/generated/index.ts | 6 + .../pendingGovernorshipTransfer.model.ts | 33 ++ src/model/generated/rewardCollected.model.ts | 30 ++ .../rewardsPerSecondChanged.model.ts | 33 ++ .../generated/rewardsTargetChange.model.ts | 33 ++ .../generated/strategistUpdated.model.ts | 30 ++ src/templates/erc20-simple/erc20.ts | 51 +-- .../exponential-staking.ts | 4 +- .../fixed-rate-rewards-source.ts | 221 +++++++++++++ .../fixed-rate-rewards-source/index.ts | 1 + src/templates/governance/governance.ts | 54 +-- src/utils/addresses.ts | 40 +-- 24 files changed, 1209 insertions(+), 108 deletions(-) create mode 100644 abi/fixed-rate-rewards-source.json rename db/migrations/{1714686799972-Data.js => 1716332143675-Data.js} (75%) create mode 100644 schema/fixed-rate-rewards-source.graphql create mode 100644 src/abi/fixed-rate-rewards-source.ts create mode 100644 src/model/generated/governorshipTransferred.model.ts create mode 100644 src/model/generated/pendingGovernorshipTransfer.model.ts create mode 100644 src/model/generated/rewardCollected.model.ts create mode 100644 src/model/generated/rewardsPerSecondChanged.model.ts create mode 100644 src/model/generated/rewardsTargetChange.model.ts create mode 100644 src/model/generated/strategistUpdated.model.ts create mode 100644 src/templates/fixed-rate-rewards-source/fixed-rate-rewards-source.ts create mode 100644 src/templates/fixed-rate-rewards-source/index.ts diff --git a/abi/fixed-rate-rewards-source.json b/abi/fixed-rate-rewards-source.json new file mode 100644 index 00000000..3254046e --- /dev/null +++ b/abi/fixed-rate-rewards-source.json @@ -0,0 +1,311 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "_rewardToken", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "InvalidRewardRate", + "type": "error" + }, + { + "inputs": [], + "name": "UnauthorizedCaller", + "type": "error" + }, + { + "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": 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": "uint256", + "name": "amountCollected", + "type": "uint256" + } + ], + "name": "RewardCollected", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "newRPS", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldRPS", + "type": "uint256" + } + ], + "name": "RewardsPerSecondChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "previousTarget", + "type": "address" + } + ], + "name": "RewardsTargetChange", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "StrategistUpdated", + "type": "event" + }, + { + "inputs": [], + "name": "claimGovernance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "collectRewards", + "outputs": [ + { + "internalType": "uint256", + "name": "rewardAmount", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "governor", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_strategistAddr", + "type": "address" + }, + { + "internalType": "address", + "name": "_rewardsTarget", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "isGovernor", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "previewRewards", + "outputs": [ + { + "internalType": "uint256", + "name": "rewardAmount", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rewardConfig", + "outputs": [ + { + "internalType": "uint64", + "name": "lastCollect", + "type": "uint64" + }, + { + "internalType": "uint192", + "name": "rewardsPerSecond", + "type": "uint192" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rewardToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rewardsTarget", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint192", + "name": "_rewardsPerSecond", + "type": "uint192" + } + ], + "name": "setRewardsPerSecond", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_rewardsTarget", + "type": "address" + } + ], + "name": "setRewardsTarget", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "setStrategistAddr", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "strategistAddr", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_newGovernor", + "type": "address" + } + ], + "name": "transferGovernance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/db/migrations/1714686799972-Data.js b/db/migrations/1716332143675-Data.js similarity index 75% rename from db/migrations/1714686799972-Data.js rename to db/migrations/1716332143675-Data.js index f234f79c..2d9d4c51 100644 --- a/db/migrations/1714686799972-Data.js +++ b/db/migrations/1716332143675-Data.js @@ -1,7 +1,77 @@ -module.exports = class Data1714686799972 { - name = 'Data1714686799972' +module.exports = class Data1716332143675 { + name = 'Data1716332143675' async up(db) { + await db.query(`CREATE TABLE "exponential_staking" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "acc_reward_per_share" numeric NOT NULL, "asset_balance" numeric NOT NULL, CONSTRAINT "PK_ec40683ce69d33cf491bd8a5f3c" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_9004da9adf2bb66b8cc9a9ddbd" ON "exponential_staking" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_bf1eab37b83a2261ba42a53b32" ON "exponential_staking" ("address") `) + await db.query(`CREATE INDEX "IDX_12fcf9c28429a1047732dd028b" ON "exponential_staking" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_ed1440d963237e211f39c26c43" ON "exponential_staking" ("block_number") `) + await db.query(`CREATE TABLE "exponential_staking_lockup" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "account" text NOT NULL, "lockup_id" numeric NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "last_updated" TIMESTAMP WITH TIME ZONE NOT NULL, "amount" numeric NOT NULL, "end" numeric NOT NULL, "points" numeric NOT NULL, "withdraw_amount" numeric NOT NULL, "penalty" numeric NOT NULL, "state" character varying(6), CONSTRAINT "PK_d94037fed0429476133dc118edf" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_d9e01c551c9f1a4d7710242ed8" ON "exponential_staking_lockup" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_9c8d024fea4fe0a45d95c801d5" ON "exponential_staking_lockup" ("address") `) + await db.query(`CREATE INDEX "IDX_c31d2fe385b684604bfa071229" ON "exponential_staking_lockup" ("account") `) + await db.query(`CREATE INDEX "IDX_9e8c0b852aeb43e4ca4a44fc70" ON "exponential_staking_lockup" ("lockup_id") `) + await db.query(`CREATE TABLE "exponential_staking_account" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "account" text NOT NULL, "votes" numeric NOT NULL, "balance" numeric NOT NULL, "preview_points" numeric NOT NULL, "preview_rewards" numeric NOT NULL, "preview_withdraw" numeric NOT NULL, CONSTRAINT "PK_b10010a05da6f8fdf0d030c5d82" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_e55574850608a204d5e3068b85" ON "exponential_staking_account" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_f2cf0e2b357e83e3c99c9076cd" ON "exponential_staking_account" ("address") `) + await db.query(`CREATE INDEX "IDX_aa85510db9e37072506a7c6c02" ON "exponential_staking_account" ("account") `) + await db.query(`CREATE TABLE "exponential_staking_delegate_changed" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "delegator" text NOT NULL, "from_delegate" text NOT NULL, "to_delegate" text NOT NULL, CONSTRAINT "PK_e09bddf9ba0a1f924d668027121" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_9de723df03ba620afd586dbbf2" ON "exponential_staking_delegate_changed" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_2c19bc13f9e9c65b521be853b0" ON "exponential_staking_delegate_changed" ("address") `) + await db.query(`CREATE INDEX "IDX_83bb461676640a6666f4c34240" ON "exponential_staking_delegate_changed" ("delegator") `) + await db.query(`CREATE TABLE "exponential_staking_delegate_votes_changed" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "delegate" text NOT NULL, "previous_balance" numeric NOT NULL, "new_balance" numeric NOT NULL, CONSTRAINT "PK_3c0770caf6cd7add1f6c5121d17" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_8bb7224130c6f200d3800d81ad" ON "exponential_staking_delegate_votes_changed" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_8a1b69ff53c4fdf5fbe4b1ef8a" ON "exponential_staking_delegate_votes_changed" ("address") `) + await db.query(`CREATE INDEX "IDX_c61dfffcf23d4988983ceb67e9" ON "exponential_staking_delegate_votes_changed" ("delegate") `) + await db.query(`CREATE TABLE "exponential_staking_penalty" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "account" text NOT NULL, "amount" numeric NOT NULL, CONSTRAINT "PK_6066556e7ac7611aa30852d522c" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_686c1e7635d16ed4974d4fba7e" ON "exponential_staking_penalty" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_e8d2ec04a0cabd68281ffbced0" ON "exponential_staking_penalty" ("address") `) + await db.query(`CREATE INDEX "IDX_8a204e6d28385b4971177fd73b" ON "exponential_staking_penalty" ("account") `) + await db.query(`CREATE TABLE "exponential_staking_reward" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "account" text NOT NULL, "amount" numeric NOT NULL, CONSTRAINT "PK_506c1ea29e2e93a51a250d5d457" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_c2503d0a7f3c5a4176b80b6ee6" ON "exponential_staking_reward" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_af7a218b05626c5b6b3b6a4702" ON "exponential_staking_reward" ("address") `) + await db.query(`CREATE INDEX "IDX_b252d19aa52a4683819bdd94b8" ON "exponential_staking_reward" ("account") `) + await db.query(`CREATE TABLE "exponential_staking_stake" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "account" text NOT NULL, "lockup_id" numeric NOT NULL, "amount" numeric NOT NULL, "end" numeric NOT NULL, "points" numeric NOT NULL, CONSTRAINT "PK_6f31743cbb489b127e964f97bb6" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_c6b9bbec61e2fca250ce7d4a32" ON "exponential_staking_stake" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_9e93319f4c9133472807912986" ON "exponential_staking_stake" ("address") `) + await db.query(`CREATE INDEX "IDX_c38f73385b9aae63c9a8e4cd57" ON "exponential_staking_stake" ("account") `) + await db.query(`CREATE INDEX "IDX_6aa54b83c2205337175f5a6e17" ON "exponential_staking_stake" ("lockup_id") `) + await db.query(`CREATE TABLE "exponential_staking_unstake" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "account" text NOT NULL, "lockup_id" numeric NOT NULL, "amount" numeric NOT NULL, "end" numeric NOT NULL, "points" numeric NOT NULL, CONSTRAINT "PK_2a537c20d900d4efec853755435" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_3a3fa2fd9ffdd64dca1d5ab3b8" ON "exponential_staking_unstake" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_7cd924c25b352e2288137ca23b" ON "exponential_staking_unstake" ("address") `) + await db.query(`CREATE INDEX "IDX_f2dff3c4211d5d57eaf627b6c8" ON "exponential_staking_unstake" ("account") `) + await db.query(`CREATE INDEX "IDX_5eba41d0c2d4d5ff4c5e5c0411" ON "exponential_staking_unstake" ("lockup_id") `) + await db.query(`CREATE TABLE "governorship_transferred" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "previous_governor" text NOT NULL, "new_governor" text NOT NULL, CONSTRAINT "PK_a8377859ab1cb2c7179f248e4e2" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_9ab2b5486d85bd8aa36730fc02" ON "governorship_transferred" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_554f6c0e2738e30856bdc4b725" ON "governorship_transferred" ("address") `) + await db.query(`CREATE INDEX "IDX_d955cfa47fa1ff270a5578ba43" ON "governorship_transferred" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_9d0eb3c05b7d0585f9d8d9eeb0" ON "governorship_transferred" ("block_number") `) + await db.query(`CREATE TABLE "pending_governorship_transfer" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "previous_governor" text NOT NULL, "new_governor" text NOT NULL, CONSTRAINT "PK_68913ab28a55f5a756c70ca31c3" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_92e258fe6b6f9c65cdbe750c65" ON "pending_governorship_transfer" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_0fe23661b80871659e54dda998" ON "pending_governorship_transfer" ("address") `) + await db.query(`CREATE INDEX "IDX_d17c593674455b0554220cf1b0" ON "pending_governorship_transfer" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_2b89e9ec7edc194f9f0a914053" ON "pending_governorship_transfer" ("block_number") `) + await db.query(`CREATE TABLE "reward_collected" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "amount_collected" numeric NOT NULL, CONSTRAINT "PK_b9219358e897a814168f7d9f805" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_0f6ab10957c09ebed8b2fc25c5" ON "reward_collected" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_f6c2334f64b880139f96db37a5" ON "reward_collected" ("address") `) + await db.query(`CREATE INDEX "IDX_fd3d30debdb9c5981471747b9b" ON "reward_collected" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_0ea0eaa90ecddef5213a787419" ON "reward_collected" ("block_number") `) + await db.query(`CREATE TABLE "rewards_per_second_changed" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "new_rps" numeric NOT NULL, "old_rps" numeric NOT NULL, CONSTRAINT "PK_716c2975993acabb52c7e4c1bd6" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_b820e1afc853dffd1556e7b2a6" ON "rewards_per_second_changed" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_fdd9f60fc758695e25ae3ef6ca" ON "rewards_per_second_changed" ("address") `) + await db.query(`CREATE INDEX "IDX_487950908e327e4ccabd36820b" ON "rewards_per_second_changed" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_da9541b9abd658528a015df4cc" ON "rewards_per_second_changed" ("block_number") `) + await db.query(`CREATE TABLE "rewards_target_change" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "target" text NOT NULL, "previous_target" text NOT NULL, CONSTRAINT "PK_99bc1b16e49937a7f1ca2068c58" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_57ca8bf4b751d1de10f44a08d6" ON "rewards_target_change" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_de0fb0e64b2f2012da9e29d277" ON "rewards_target_change" ("address") `) + await db.query(`CREATE INDEX "IDX_e21598b3cc8c9f85c4af20433c" ON "rewards_target_change" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_6b94b5ef03dd72ed73f3209642" ON "rewards_target_change" ("block_number") `) + await db.query(`CREATE TABLE "strategist_updated" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "strategist_address" text NOT NULL, CONSTRAINT "PK_ed7a217e068cbc1762e9c04e68d" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_3ddb234b6c80ea1d59b2922fe4" ON "strategist_updated" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_103140942203924024fcb8fbbd" ON "strategist_updated" ("address") `) + await db.query(`CREATE INDEX "IDX_0d9424ca64d47f409467f3ccc5" ON "strategist_updated" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_3e6d818b5c76a45fdd1b7ff18c" ON "strategist_updated" ("block_number") `) await db.query(`CREATE TABLE "processing_status" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, CONSTRAINT "PK_85f5e2467b74fb70fac1a053021" PRIMARY KEY ("id"))`) await db.query(`CREATE TABLE "exchange_rate" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "pair" text NOT NULL, "base" text NOT NULL, "quote" text NOT NULL, "rate" numeric NOT NULL, CONSTRAINT "PK_5c5d27d2b900ef6cdeef0398472" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_9e23a3f1bf3634820c873a0fe8" ON "exchange_rate" ("timestamp") `) @@ -74,6 +144,12 @@ module.exports = class Data1714686799972 { await db.query(`CREATE INDEX "IDX_374659ae3bd149042388e132be" ON "bridge_transfer_state" ("timestamp") `) await db.query(`CREATE INDEX "IDX_74f93b10ec560e63792dcc877e" ON "bridge_transfer_state" ("block_number") `) await db.query(`CREATE INDEX "IDX_df99bdbf11d4ed57bec0e6c511" ON "bridge_transfer_state" ("tx_hash") `) + await db.query(`CREATE TABLE "governance_proposal" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "proposal_id" numeric NOT NULL, "description" text, "proposer" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "start_block" numeric NOT NULL, "end_block" numeric NOT NULL, "targets" text array NOT NULL, "values" text array NOT NULL, "signatures" text array NOT NULL, "calldatas" text array NOT NULL, "last_updated" TIMESTAMP WITH TIME ZONE NOT NULL, "status" character varying(9) NOT NULL, "quorum" numeric NOT NULL, "choices" text array NOT NULL, "scores" text array NOT NULL, CONSTRAINT "PK_d71b4171baf362416ecfc414531" PRIMARY KEY ("id"))`) + await db.query(`CREATE TABLE "governance_proposal_event" ("id" character varying NOT NULL, "hash" text NOT NULL, "event" character varying(8) NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "proposal_id" character varying, CONSTRAINT "PK_94661d292cb01ea76ba8871ec2b" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_ce984d23fc99c537b8f22fd663" ON "governance_proposal_event" ("proposal_id") `) + await db.query(`CREATE TABLE "governance_proposal_vote" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "voter" text NOT NULL, "weight" numeric NOT NULL, "type" character varying(7) NOT NULL, "tx_hash" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "proposal_id" character varying, CONSTRAINT "PK_e13a15bfb5ccfdec4c19975de87" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_5531af241c24a09c854ead9d55" ON "governance_proposal_vote" ("proposal_id") `) + await db.query(`CREATE INDEX "IDX_adc6eb148ad48697e74d23c722" ON "governance_proposal_vote" ("voter") `) await db.query(`CREATE TABLE "oeth_vault" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "weth" numeric NOT NULL, "st_eth" numeric NOT NULL, "r_eth" numeric NOT NULL, "frx_eth" numeric NOT NULL, CONSTRAINT "PK_9debaa84944fe2be9dc4219ba8f" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_d6298a294864b4eaf793cf35a4" ON "oeth_vault" ("timestamp") `) await db.query(`CREATE INDEX "IDX_e20cb507a673817b2c68720415" ON "oeth_vault" ("block_number") `) @@ -114,7 +190,7 @@ module.exports = class Data1714686799972 { await db.query(`CREATE INDEX "IDX_8be94cd63e35b91adf1301a156" ON "ogv_lockup" ("address_id") `) await db.query(`CREATE TABLE "ogv_lockup_tx_log" ("id" character varying NOT NULL, "hash" text NOT NULL, "event" character varying(8) NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "total_supply" numeric NOT NULL, "ogv_lockup_id" character varying, CONSTRAINT "PK_1c4a8425ce42f0c9da10056adee" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_b49fca291c97d9b55cd91f935f" ON "ogv_lockup_tx_log" ("ogv_lockup_id") `) - await db.query(`CREATE TABLE "ogv_proposal" ("id" character varying NOT NULL, "description" text, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "start_block" numeric NOT NULL, "end_block" numeric NOT NULL, "last_updated" TIMESTAMP WITH TIME ZONE NOT NULL, "status" character varying(9) NOT NULL, "quorum" numeric NOT NULL, "choices" text array NOT NULL, "scores" numeric array NOT NULL, "proposer_id" character varying, CONSTRAINT "PK_b06db02b26fa37882e013579407" PRIMARY KEY ("id"))`) + await db.query(`CREATE TABLE "ogv_proposal" ("id" character varying NOT NULL, "description" text, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "start_block" numeric NOT NULL, "end_block" numeric NOT NULL, "last_updated" TIMESTAMP WITH TIME ZONE NOT NULL, "status" character varying(9) NOT NULL, "quorum" numeric NOT NULL, "choices" text array NOT NULL, "scores" text array NOT NULL, "proposer_id" character varying, CONSTRAINT "PK_b06db02b26fa37882e013579407" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_c62be3f16dfb3e4a09525c85af" ON "ogv_proposal" ("proposer_id") `) await db.query(`CREATE TABLE "ogv_proposal_tx_log" ("id" character varying NOT NULL, "hash" text NOT NULL, "event" character varying(8) NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "proposal_id" character varying, CONSTRAINT "PK_da43c287069bba678ca5c60b1ad" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_5d5f5e10892290ee366d26de7d" ON "ogv_proposal_tx_log" ("proposal_id") `) @@ -215,6 +291,8 @@ module.exports = class Data1714686799972 { await db.query(`CREATE TABLE "ousd_daily_stat" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "apr" numeric NOT NULL, "apy" numeric NOT NULL, "apy7_day_avg" numeric NOT NULL, "apy14_day_avg" numeric NOT NULL, "apy30_day_avg" numeric NOT NULL, "total_supply" numeric NOT NULL, "total_supply_usd" numeric NOT NULL, "rebasing_supply" numeric NOT NULL, "non_rebasing_supply" numeric NOT NULL, "amo_supply" numeric NOT NULL, "dripper_weth" numeric NOT NULL, "wrapped_supply" numeric NOT NULL, "trading_volume_usd" numeric NOT NULL, "yield_eth" numeric NOT NULL, "yield_eth7_day" numeric NOT NULL, "yield_eth_all_time" numeric NOT NULL, "yield_usd" numeric NOT NULL, "yield_usd7_day" numeric NOT NULL, "yield_usd_all_time" numeric NOT NULL, "fees_eth" numeric NOT NULL, "fees_eth7_day" numeric NOT NULL, "fees_eth_all_time" numeric NOT NULL, "fees_usd" numeric NOT NULL, "fees_usd7_day" numeric NOT NULL, "fees_usd_all_time" numeric NOT NULL, "peg_price" numeric NOT NULL, "market_cap_usd" numeric NOT NULL, "holders_over_threshold" integer NOT NULL, CONSTRAINT "PK_f8adaf321a99f2b4b877c262880" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_f9020d89932aad2d0de8923490" ON "ousd_daily_stat" ("block_number") `) await db.query(`CREATE INDEX "IDX_0bb5f72bf5fa59ce8c232caa4c" ON "ousd_daily_stat" ("timestamp") `) + await db.query(`ALTER TABLE "governance_proposal_event" ADD CONSTRAINT "FK_ce984d23fc99c537b8f22fd663a" FOREIGN KEY ("proposal_id") REFERENCES "governance_proposal"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "governance_proposal_vote" ADD CONSTRAINT "FK_5531af241c24a09c854ead9d551" FOREIGN KEY ("proposal_id") REFERENCES "governance_proposal"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) await db.query(`ALTER TABLE "oeth_strategy_holding_daily_stat" ADD CONSTRAINT "FK_4e867f220975e615e6077d860c1" FOREIGN KEY ("strategy_daily_stat_id_id") REFERENCES "oeth_strategy_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) await db.query(`ALTER TABLE "oeth_strategy_daily_stat" ADD CONSTRAINT "FK_6c7096c96a000d8471256ca8fc3" FOREIGN KEY ("daily_stat_id_id") REFERENCES "oeth_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) await db.query(`ALTER TABLE "oeth_collateral_daily_stat" ADD CONSTRAINT "FK_a90045de50406be7bd56efd3ea4" FOREIGN KEY ("daily_stat_id_id") REFERENCES "oeth_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) @@ -234,6 +312,76 @@ module.exports = class Data1714686799972 { } async down(db) { + await db.query(`DROP TABLE "exponential_staking"`) + await db.query(`DROP INDEX "public"."IDX_9004da9adf2bb66b8cc9a9ddbd"`) + await db.query(`DROP INDEX "public"."IDX_bf1eab37b83a2261ba42a53b32"`) + await db.query(`DROP INDEX "public"."IDX_12fcf9c28429a1047732dd028b"`) + await db.query(`DROP INDEX "public"."IDX_ed1440d963237e211f39c26c43"`) + await db.query(`DROP TABLE "exponential_staking_lockup"`) + await db.query(`DROP INDEX "public"."IDX_d9e01c551c9f1a4d7710242ed8"`) + await db.query(`DROP INDEX "public"."IDX_9c8d024fea4fe0a45d95c801d5"`) + await db.query(`DROP INDEX "public"."IDX_c31d2fe385b684604bfa071229"`) + await db.query(`DROP INDEX "public"."IDX_9e8c0b852aeb43e4ca4a44fc70"`) + await db.query(`DROP TABLE "exponential_staking_account"`) + await db.query(`DROP INDEX "public"."IDX_e55574850608a204d5e3068b85"`) + await db.query(`DROP INDEX "public"."IDX_f2cf0e2b357e83e3c99c9076cd"`) + await db.query(`DROP INDEX "public"."IDX_aa85510db9e37072506a7c6c02"`) + await db.query(`DROP TABLE "exponential_staking_delegate_changed"`) + await db.query(`DROP INDEX "public"."IDX_9de723df03ba620afd586dbbf2"`) + await db.query(`DROP INDEX "public"."IDX_2c19bc13f9e9c65b521be853b0"`) + await db.query(`DROP INDEX "public"."IDX_83bb461676640a6666f4c34240"`) + await db.query(`DROP TABLE "exponential_staking_delegate_votes_changed"`) + await db.query(`DROP INDEX "public"."IDX_8bb7224130c6f200d3800d81ad"`) + await db.query(`DROP INDEX "public"."IDX_8a1b69ff53c4fdf5fbe4b1ef8a"`) + await db.query(`DROP INDEX "public"."IDX_c61dfffcf23d4988983ceb67e9"`) + await db.query(`DROP TABLE "exponential_staking_penalty"`) + await db.query(`DROP INDEX "public"."IDX_686c1e7635d16ed4974d4fba7e"`) + await db.query(`DROP INDEX "public"."IDX_e8d2ec04a0cabd68281ffbced0"`) + await db.query(`DROP INDEX "public"."IDX_8a204e6d28385b4971177fd73b"`) + await db.query(`DROP TABLE "exponential_staking_reward"`) + await db.query(`DROP INDEX "public"."IDX_c2503d0a7f3c5a4176b80b6ee6"`) + await db.query(`DROP INDEX "public"."IDX_af7a218b05626c5b6b3b6a4702"`) + await db.query(`DROP INDEX "public"."IDX_b252d19aa52a4683819bdd94b8"`) + await db.query(`DROP TABLE "exponential_staking_stake"`) + await db.query(`DROP INDEX "public"."IDX_c6b9bbec61e2fca250ce7d4a32"`) + await db.query(`DROP INDEX "public"."IDX_9e93319f4c9133472807912986"`) + await db.query(`DROP INDEX "public"."IDX_c38f73385b9aae63c9a8e4cd57"`) + await db.query(`DROP INDEX "public"."IDX_6aa54b83c2205337175f5a6e17"`) + await db.query(`DROP TABLE "exponential_staking_unstake"`) + await db.query(`DROP INDEX "public"."IDX_3a3fa2fd9ffdd64dca1d5ab3b8"`) + await db.query(`DROP INDEX "public"."IDX_7cd924c25b352e2288137ca23b"`) + await db.query(`DROP INDEX "public"."IDX_f2dff3c4211d5d57eaf627b6c8"`) + await db.query(`DROP INDEX "public"."IDX_5eba41d0c2d4d5ff4c5e5c0411"`) + await db.query(`DROP TABLE "governorship_transferred"`) + await db.query(`DROP INDEX "public"."IDX_9ab2b5486d85bd8aa36730fc02"`) + await db.query(`DROP INDEX "public"."IDX_554f6c0e2738e30856bdc4b725"`) + await db.query(`DROP INDEX "public"."IDX_d955cfa47fa1ff270a5578ba43"`) + await db.query(`DROP INDEX "public"."IDX_9d0eb3c05b7d0585f9d8d9eeb0"`) + await db.query(`DROP TABLE "pending_governorship_transfer"`) + await db.query(`DROP INDEX "public"."IDX_92e258fe6b6f9c65cdbe750c65"`) + await db.query(`DROP INDEX "public"."IDX_0fe23661b80871659e54dda998"`) + await db.query(`DROP INDEX "public"."IDX_d17c593674455b0554220cf1b0"`) + await db.query(`DROP INDEX "public"."IDX_2b89e9ec7edc194f9f0a914053"`) + await db.query(`DROP TABLE "reward_collected"`) + await db.query(`DROP INDEX "public"."IDX_0f6ab10957c09ebed8b2fc25c5"`) + await db.query(`DROP INDEX "public"."IDX_f6c2334f64b880139f96db37a5"`) + await db.query(`DROP INDEX "public"."IDX_fd3d30debdb9c5981471747b9b"`) + await db.query(`DROP INDEX "public"."IDX_0ea0eaa90ecddef5213a787419"`) + await db.query(`DROP TABLE "rewards_per_second_changed"`) + await db.query(`DROP INDEX "public"."IDX_b820e1afc853dffd1556e7b2a6"`) + await db.query(`DROP INDEX "public"."IDX_fdd9f60fc758695e25ae3ef6ca"`) + await db.query(`DROP INDEX "public"."IDX_487950908e327e4ccabd36820b"`) + await db.query(`DROP INDEX "public"."IDX_da9541b9abd658528a015df4cc"`) + await db.query(`DROP TABLE "rewards_target_change"`) + await db.query(`DROP INDEX "public"."IDX_57ca8bf4b751d1de10f44a08d6"`) + await db.query(`DROP INDEX "public"."IDX_de0fb0e64b2f2012da9e29d277"`) + await db.query(`DROP INDEX "public"."IDX_e21598b3cc8c9f85c4af20433c"`) + await db.query(`DROP INDEX "public"."IDX_6b94b5ef03dd72ed73f3209642"`) + await db.query(`DROP TABLE "strategist_updated"`) + await db.query(`DROP INDEX "public"."IDX_3ddb234b6c80ea1d59b2922fe4"`) + await db.query(`DROP INDEX "public"."IDX_103140942203924024fcb8fbbd"`) + await db.query(`DROP INDEX "public"."IDX_0d9424ca64d47f409467f3ccc5"`) + await db.query(`DROP INDEX "public"."IDX_3e6d818b5c76a45fdd1b7ff18c"`) await db.query(`DROP TABLE "processing_status"`) await db.query(`DROP TABLE "exchange_rate"`) await db.query(`DROP INDEX "public"."IDX_9e23a3f1bf3634820c873a0fe8"`) @@ -306,6 +454,12 @@ module.exports = class Data1714686799972 { await db.query(`DROP INDEX "public"."IDX_374659ae3bd149042388e132be"`) await db.query(`DROP INDEX "public"."IDX_74f93b10ec560e63792dcc877e"`) await db.query(`DROP INDEX "public"."IDX_df99bdbf11d4ed57bec0e6c511"`) + await db.query(`DROP TABLE "governance_proposal"`) + await db.query(`DROP TABLE "governance_proposal_event"`) + await db.query(`DROP INDEX "public"."IDX_ce984d23fc99c537b8f22fd663"`) + await db.query(`DROP TABLE "governance_proposal_vote"`) + await db.query(`DROP INDEX "public"."IDX_5531af241c24a09c854ead9d55"`) + await db.query(`DROP INDEX "public"."IDX_adc6eb148ad48697e74d23c722"`) await db.query(`DROP TABLE "oeth_vault"`) await db.query(`DROP INDEX "public"."IDX_d6298a294864b4eaf793cf35a4"`) await db.query(`DROP INDEX "public"."IDX_e20cb507a673817b2c68720415"`) @@ -447,6 +601,8 @@ module.exports = class Data1714686799972 { await db.query(`DROP TABLE "ousd_daily_stat"`) await db.query(`DROP INDEX "public"."IDX_f9020d89932aad2d0de8923490"`) await db.query(`DROP INDEX "public"."IDX_0bb5f72bf5fa59ce8c232caa4c"`) + await db.query(`ALTER TABLE "governance_proposal_event" DROP CONSTRAINT "FK_ce984d23fc99c537b8f22fd663a"`) + await db.query(`ALTER TABLE "governance_proposal_vote" DROP CONSTRAINT "FK_5531af241c24a09c854ead9d551"`) await db.query(`ALTER TABLE "oeth_strategy_holding_daily_stat" DROP CONSTRAINT "FK_4e867f220975e615e6077d860c1"`) await db.query(`ALTER TABLE "oeth_strategy_daily_stat" DROP CONSTRAINT "FK_6c7096c96a000d8471256ca8fc3"`) await db.query(`ALTER TABLE "oeth_collateral_daily_stat" DROP CONSTRAINT "FK_a90045de50406be7bd56efd3ea4"`) diff --git a/schema.graphql b/schema.graphql index 84bbc649..e0e6bf73 100644 --- a/schema.graphql +++ b/schema.graphql @@ -26,6 +26,8 @@ type ExponentialStakingLockup @entity { address: String! @index account: String! @index lockupId: BigInt! @index + timestamp: DateTime! + lastUpdated: DateTime! amount: BigInt! end: BigInt! points: BigInt! @@ -104,7 +106,58 @@ type ExponentialStakingUnstake @entity { end: BigInt! points: BigInt! } -type ProcessingStatus @entity { +type GovernorshipTransferred @entity { + id: ID! + chainId: Int! @index + address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index + previousGovernor: String! + newGovernor: String! +} +type PendingGovernorshipTransfer @entity { + id: ID! + chainId: Int! @index + address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index + previousGovernor: String! + newGovernor: String! +} +type RewardCollected @entity { + id: ID! + chainId: Int! @index + address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index + amountCollected: BigInt! +} +type RewardsPerSecondChanged @entity { + id: ID! + chainId: Int! @index + address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index + newRPS: BigInt! + oldRPS: BigInt! +} +type RewardsTargetChange @entity { + id: ID! + chainId: Int! @index + address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index + target: String! + previousTarget: String! +} +type StrategistUpdated @entity { + id: ID! + chainId: Int! @index + address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index + strategistAddress: String! +}type ProcessingStatus @entity { id: ID! timestamp: DateTime! blockNumber: Int! @@ -429,6 +482,10 @@ type GovernanceProposal @entity { timestamp: DateTime! startBlock: BigInt! endBlock: BigInt! + targets: [String]! + values: [String]! + signatures: [String]! + calldatas: [String]! lastUpdated: DateTime! status: GovernanceProposalState! events: [GovernanceProposalEvent]! @derivedFrom(field: "proposal") diff --git a/schema/exponential-staking.graphql b/schema/exponential-staking.graphql index 118807ea..149fd443 100644 --- a/schema/exponential-staking.graphql +++ b/schema/exponential-staking.graphql @@ -24,6 +24,8 @@ type ExponentialStakingLockup @entity { address: String! @index account: String! @index lockupId: BigInt! @index + timestamp: DateTime! + lastUpdated: DateTime! amount: BigInt! end: BigInt! points: BigInt! diff --git a/schema/fixed-rate-rewards-source.graphql b/schema/fixed-rate-rewards-source.graphql new file mode 100644 index 00000000..58ce9bbf --- /dev/null +++ b/schema/fixed-rate-rewards-source.graphql @@ -0,0 +1,52 @@ +type GovernorshipTransferred @entity { + id: ID! + chainId: Int! @index + address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index + previousGovernor: String! + newGovernor: String! +} +type PendingGovernorshipTransfer @entity { + id: ID! + chainId: Int! @index + address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index + previousGovernor: String! + newGovernor: String! +} +type RewardCollected @entity { + id: ID! + chainId: Int! @index + address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index + amountCollected: BigInt! +} +type RewardsPerSecondChanged @entity { + id: ID! + chainId: Int! @index + address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index + newRPS: BigInt! + oldRPS: BigInt! +} +type RewardsTargetChange @entity { + id: ID! + chainId: Int! @index + address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index + target: String! + previousTarget: String! +} +type StrategistUpdated @entity { + id: ID! + chainId: Int! @index + address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index + strategistAddress: String! +} \ No newline at end of file diff --git a/schema/governance.graphql b/schema/governance.graphql index d4bf70f2..d8112fd6 100644 --- a/schema/governance.graphql +++ b/schema/governance.graphql @@ -41,6 +41,10 @@ type GovernanceProposal @entity { timestamp: DateTime! startBlock: BigInt! endBlock: BigInt! + targets: [String]! + values: [String]! + signatures: [String]! + calldatas: [String]! lastUpdated: DateTime! status: GovernanceProposalState! events: [GovernanceProposalEvent]! @derivedFrom(field: "proposal") diff --git a/src/abi/fixed-rate-rewards-source.ts b/src/abi/fixed-rate-rewards-source.ts new file mode 100644 index 00000000..cc873d94 --- /dev/null +++ b/src/abi/fixed-rate-rewards-source.ts @@ -0,0 +1,112 @@ +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' + +export const events = { + GovernorshipTransferred: event("0xc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a", {"previousGovernor": indexed(p.address), "newGovernor": indexed(p.address)}), + PendingGovernorshipTransfer: event("0xa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d", {"previousGovernor": indexed(p.address), "newGovernor": indexed(p.address)}), + RewardCollected: event("0x9026b1dc1bd4688af8f4998f8cacc713a53fba753294da0efe4849a25c26023e", {"amountCollected": p.uint256}), + RewardsPerSecondChanged: event("0xe261f91b5c3d9f16ed2268171bcd375f4aa1fe4b244cfe2e54a7d21be4735d46", {"newRPS": p.uint256, "oldRPS": p.uint256}), + RewardsTargetChange: event("0x41ad0a33748dcbf4495041d0518e1204c1d5f0d65e7dccb51877235361e75f4a", {"target": p.address, "previousTarget": p.address}), + StrategistUpdated: event("0x869e0abd13cc3a975de7b93be3df1cb2255c802b1cead85963cc79d99f131bee", {"_address": p.address}), +} + +export const functions = { + claimGovernance: fun("0x5d36b190", {}, ), + collectRewards: fun("0x70bb45b3", {}, p.uint256), + governor: fun("0x0c340a24", {}, p.address), + initialize: fun("0x485cc955", {"_strategistAddr": p.address, "_rewardsTarget": p.address}, ), + isGovernor: fun("0xc7af3352", {}, p.bool), + previewRewards: fun("0xe0d801dd", {}, p.uint256), + rewardConfig: fun("0x4e94c285", {}, {"lastCollect": p.uint64, "rewardsPerSecond": p.uint192}), + rewardToken: fun("0xf7c618c1", {}, p.address), + rewardsTarget: fun("0x82487844", {}, p.address), + setRewardsPerSecond: fun("0xdc9ec152", {"_rewardsPerSecond": p.uint192}, ), + setRewardsTarget: fun("0x6411466f", {"_rewardsTarget": p.address}, ), + setStrategistAddr: fun("0x773540b3", {"_address": p.address}, ), + strategistAddr: fun("0x570d8e1d", {}, p.address), + transferGovernance: fun("0xd38bfff4", {"_newGovernor": p.address}, ), +} + +export class Contract extends ContractBase { + + governor() { + return this.eth_call(functions.governor, {}) + } + + isGovernor() { + return this.eth_call(functions.isGovernor, {}) + } + + previewRewards() { + return this.eth_call(functions.previewRewards, {}) + } + + rewardConfig() { + return this.eth_call(functions.rewardConfig, {}) + } + + rewardToken() { + return this.eth_call(functions.rewardToken, {}) + } + + rewardsTarget() { + return this.eth_call(functions.rewardsTarget, {}) + } + + strategistAddr() { + return this.eth_call(functions.strategistAddr, {}) + } +} + +/// Event types +export type GovernorshipTransferredEventArgs = EParams +export type PendingGovernorshipTransferEventArgs = EParams +export type RewardCollectedEventArgs = EParams +export type RewardsPerSecondChangedEventArgs = EParams +export type RewardsTargetChangeEventArgs = EParams +export type StrategistUpdatedEventArgs = EParams + +/// Function types +export type ClaimGovernanceParams = FunctionArguments +export type ClaimGovernanceReturn = FunctionReturn + +export type CollectRewardsParams = FunctionArguments +export type CollectRewardsReturn = FunctionReturn + +export type GovernorParams = FunctionArguments +export type GovernorReturn = FunctionReturn + +export type InitializeParams = FunctionArguments +export type InitializeReturn = FunctionReturn + +export type IsGovernorParams = FunctionArguments +export type IsGovernorReturn = FunctionReturn + +export type PreviewRewardsParams = FunctionArguments +export type PreviewRewardsReturn = FunctionReturn + +export type RewardConfigParams = FunctionArguments +export type RewardConfigReturn = FunctionReturn + +export type RewardTokenParams = FunctionArguments +export type RewardTokenReturn = FunctionReturn + +export type RewardsTargetParams = FunctionArguments +export type RewardsTargetReturn = FunctionReturn + +export type SetRewardsPerSecondParams = FunctionArguments +export type SetRewardsPerSecondReturn = FunctionReturn + +export type SetRewardsTargetParams = FunctionArguments +export type SetRewardsTargetReturn = FunctionReturn + +export type SetStrategistAddrParams = FunctionArguments +export type SetStrategistAddrReturn = FunctionReturn + +export type StrategistAddrParams = FunctionArguments +export type StrategistAddrReturn = FunctionReturn + +export type TransferGovernanceParams = FunctionArguments +export type TransferGovernanceReturn = FunctionReturn + diff --git a/src/main-mainnet.ts b/src/main-mainnet.ts index 9effac7d..37ac74fb 100644 --- a/src/main-mainnet.ts +++ b/src/main-mainnet.ts @@ -2,7 +2,11 @@ import 'tsconfig-paths/register' import { run } from '@processor' import * as exchangeRates from '@shared/post-processors/exchange-rates' +import { createExponentialStakingTracker } from '@templates/exponential-staking' +import { createFixedRewardsSourceProcessor } from '@templates/fixed-rate-rewards-source' +import { createGovernanceProcessor } from '@templates/governance' import { processStatus } from '@templates/processor-status' +import { GOVERNANCE_ADDRESS, OGN_REWARDS_SOURCE_ADDRESS, VEOGV_ADDRESS, XOGN_ADDRESS } from '@utils/addresses' import * as curve from './mainnet/processors/curve' import { erc20s } from './mainnet/processors/erc20s' @@ -10,8 +14,15 @@ import * as validate from './mainnet/validators/validate-mainnet' export const processor = { stateSchema: 'mainnet-processor', - processors: [curve, ...erc20s()], - postProcessors: [exchangeRates, processStatus('other')], + processors: [ + curve, + ...erc20s(), + createGovernanceProcessor({ from: 15491391, address: GOVERNANCE_ADDRESS }), + createExponentialStakingTracker({ from: 15089597, address: VEOGV_ADDRESS }), + createExponentialStakingTracker({ from: 19919745, address: XOGN_ADDRESS }), + createFixedRewardsSourceProcessor({ from: 19917521, address: OGN_REWARDS_SOURCE_ADDRESS }), + ], + postProcessors: [exchangeRates, processStatus('mainnet')], validators: [validate], } export default processor diff --git a/src/mainnet/processors/erc20s.ts b/src/mainnet/processors/erc20s.ts index 9ae058d2..3e58c534 100644 --- a/src/mainnet/processors/erc20s.ts +++ b/src/mainnet/processors/erc20s.ts @@ -19,19 +19,18 @@ import { logFilter } from '@utils/logFilter' let initialized = false -const simpleTracks: Record< - string, - Parameters[0] -> = { +const simpleTracks: Record[0]> = { // Origin Specific OGN: { from: 6436154, - // from: 16933090, // oeth deploy date address: tokens.OGN, }, + xOGN: { + from: 19919745, + address: tokens.xOGN, + }, OGV: { from: 14439231, - // from: 16933090, // oeth deploy date address: tokens.OGV, }, } diff --git a/src/model/generated/exponentialStakingLockup.model.ts b/src/model/generated/exponentialStakingLockup.model.ts index 681d3387..74281603 100644 --- a/src/model/generated/exponentialStakingLockup.model.ts +++ b/src/model/generated/exponentialStakingLockup.model.ts @@ -1,4 +1,4 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_, DateTimeColumn as DateTimeColumn_} from "@subsquid/typeorm-store" import {ExponentialStakingLockupState} from "./_exponentialStakingLockupState" @Entity_() @@ -26,6 +26,12 @@ export class ExponentialStakingLockup { @BigIntColumn_({nullable: false}) lockupId!: bigint + @DateTimeColumn_({nullable: false}) + timestamp!: Date + + @DateTimeColumn_({nullable: false}) + lastUpdated!: Date + @BigIntColumn_({nullable: false}) amount!: bigint diff --git a/src/model/generated/governanceProposal.model.ts b/src/model/generated/governanceProposal.model.ts index 3d6baf4f..e7125efe 100644 --- a/src/model/generated/governanceProposal.model.ts +++ b/src/model/generated/governanceProposal.model.ts @@ -35,6 +35,18 @@ export class GovernanceProposal { @BigIntColumn_({nullable: false}) endBlock!: bigint + @StringColumn_({array: true, nullable: false}) + targets!: (string | undefined | null)[] + + @StringColumn_({array: true, nullable: false}) + values!: (string | undefined | null)[] + + @StringColumn_({array: true, nullable: false}) + signatures!: (string | undefined | null)[] + + @StringColumn_({array: true, nullable: false}) + calldatas!: (string | undefined | null)[] + @DateTimeColumn_({nullable: false}) lastUpdated!: Date diff --git a/src/model/generated/governorshipTransferred.model.ts b/src/model/generated/governorshipTransferred.model.ts new file mode 100644 index 00000000..232d9870 --- /dev/null +++ b/src/model/generated/governorshipTransferred.model.ts @@ -0,0 +1,33 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_} from "@subsquid/typeorm-store" + +@Entity_() +export class GovernorshipTransferred { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @IntColumn_({nullable: false}) + chainId!: number + + @Index_() + @StringColumn_({nullable: false}) + address!: string + + @Index_() + @DateTimeColumn_({nullable: false}) + timestamp!: Date + + @Index_() + @IntColumn_({nullable: false}) + blockNumber!: number + + @StringColumn_({nullable: false}) + previousGovernor!: string + + @StringColumn_({nullable: false}) + newGovernor!: string +} diff --git a/src/model/generated/index.ts b/src/model/generated/index.ts index 1254d7c5..b94c0e4a 100644 --- a/src/model/generated/index.ts +++ b/src/model/generated/index.ts @@ -8,6 +8,12 @@ export * from "./exponentialStakingPenalty.model" export * from "./exponentialStakingReward.model" export * from "./exponentialStakingStake.model" export * from "./exponentialStakingUnstake.model" +export * from "./governorshipTransferred.model" +export * from "./pendingGovernorshipTransfer.model" +export * from "./rewardCollected.model" +export * from "./rewardsPerSecondChanged.model" +export * from "./rewardsTargetChange.model" +export * from "./strategistUpdated.model" export * from "./processingStatus.model" export * from "./exchangeRate.model" export * from "./strategyBalance.model" diff --git a/src/model/generated/pendingGovernorshipTransfer.model.ts b/src/model/generated/pendingGovernorshipTransfer.model.ts new file mode 100644 index 00000000..a3d7d387 --- /dev/null +++ b/src/model/generated/pendingGovernorshipTransfer.model.ts @@ -0,0 +1,33 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_} from "@subsquid/typeorm-store" + +@Entity_() +export class PendingGovernorshipTransfer { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @IntColumn_({nullable: false}) + chainId!: number + + @Index_() + @StringColumn_({nullable: false}) + address!: string + + @Index_() + @DateTimeColumn_({nullable: false}) + timestamp!: Date + + @Index_() + @IntColumn_({nullable: false}) + blockNumber!: number + + @StringColumn_({nullable: false}) + previousGovernor!: string + + @StringColumn_({nullable: false}) + newGovernor!: string +} diff --git a/src/model/generated/rewardCollected.model.ts b/src/model/generated/rewardCollected.model.ts new file mode 100644 index 00000000..63a74d96 --- /dev/null +++ b/src/model/generated/rewardCollected.model.ts @@ -0,0 +1,30 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" + +@Entity_() +export class RewardCollected { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @IntColumn_({nullable: false}) + chainId!: number + + @Index_() + @StringColumn_({nullable: false}) + address!: string + + @Index_() + @DateTimeColumn_({nullable: false}) + timestamp!: Date + + @Index_() + @IntColumn_({nullable: false}) + blockNumber!: number + + @BigIntColumn_({nullable: false}) + amountCollected!: bigint +} diff --git a/src/model/generated/rewardsPerSecondChanged.model.ts b/src/model/generated/rewardsPerSecondChanged.model.ts new file mode 100644 index 00000000..76db06a4 --- /dev/null +++ b/src/model/generated/rewardsPerSecondChanged.model.ts @@ -0,0 +1,33 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" + +@Entity_() +export class RewardsPerSecondChanged { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @IntColumn_({nullable: false}) + chainId!: number + + @Index_() + @StringColumn_({nullable: false}) + address!: string + + @Index_() + @DateTimeColumn_({nullable: false}) + timestamp!: Date + + @Index_() + @IntColumn_({nullable: false}) + blockNumber!: number + + @BigIntColumn_({nullable: false}) + newRPS!: bigint + + @BigIntColumn_({nullable: false}) + oldRPS!: bigint +} diff --git a/src/model/generated/rewardsTargetChange.model.ts b/src/model/generated/rewardsTargetChange.model.ts new file mode 100644 index 00000000..336567b2 --- /dev/null +++ b/src/model/generated/rewardsTargetChange.model.ts @@ -0,0 +1,33 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_} from "@subsquid/typeorm-store" + +@Entity_() +export class RewardsTargetChange { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @IntColumn_({nullable: false}) + chainId!: number + + @Index_() + @StringColumn_({nullable: false}) + address!: string + + @Index_() + @DateTimeColumn_({nullable: false}) + timestamp!: Date + + @Index_() + @IntColumn_({nullable: false}) + blockNumber!: number + + @StringColumn_({nullable: false}) + target!: string + + @StringColumn_({nullable: false}) + previousTarget!: string +} diff --git a/src/model/generated/strategistUpdated.model.ts b/src/model/generated/strategistUpdated.model.ts new file mode 100644 index 00000000..daef5211 --- /dev/null +++ b/src/model/generated/strategistUpdated.model.ts @@ -0,0 +1,30 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_} from "@subsquid/typeorm-store" + +@Entity_() +export class StrategistUpdated { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @IntColumn_({nullable: false}) + chainId!: number + + @Index_() + @StringColumn_({nullable: false}) + address!: string + + @Index_() + @DateTimeColumn_({nullable: false}) + timestamp!: Date + + @Index_() + @IntColumn_({nullable: false}) + blockNumber!: number + + @StringColumn_({nullable: false}) + strategistAddress!: string +} diff --git a/src/templates/erc20-simple/erc20.ts b/src/templates/erc20-simple/erc20.ts index c03341e3..391da066 100644 --- a/src/templates/erc20-simple/erc20.ts +++ b/src/templates/erc20-simple/erc20.ts @@ -1,23 +1,11 @@ import * as abi from '@abi/erc20' -import { - ERC20, - ERC20Balance, - ERC20Holder, - ERC20State, - ERC20Transfer, -} from '@model' +import { ERC20, ERC20Balance, ERC20Holder, ERC20State, ERC20Transfer } from '@model' import { Block, Context } from '@processor' import { EvmBatchProcessor } from '@subsquid/evm-processor' import { ADDRESS_ZERO, TokenAddress } from '@utils/addresses' import { logFilter } from '@utils/logFilter' -export const createERC20SimpleTracker = ({ - from, - address, -}: { - from: number - address: TokenAddress -}) => { +export const createERC20SimpleTracker = ({ from, address }: { from: number; address: TokenAddress }) => { let erc20: ERC20 | undefined let lastState: ERC20State | undefined const transferLogFilters = [ @@ -35,11 +23,7 @@ export const createERC20SimpleTracker = ({ try { if (!erc20) { const contract = new abi.Contract(ctx, block.header, address) - const [name, symbol, decimals] = await Promise.all([ - contract.name(), - contract.symbol(), - contract.decimals(), - ]) + const [name, symbol, decimals] = await Promise.all([contract.name(), contract.symbol(), contract.decimals()]) erc20 = new ERC20({ id: `${ctx.chain.id}-${address}`, chainId: ctx.chain.id, @@ -51,10 +35,7 @@ export const createERC20SimpleTracker = ({ await ctx.store.insert(erc20) } } catch (err) { - ctx.log.error( - { height: block.header.height, err }, - 'Failed to get contract name', - ) + ctx.log.error({ height: block.header.height, err }, 'Failed to get contract name') } if (!lastState) { lastState = await ctx.store @@ -101,12 +82,7 @@ export const createERC20SimpleTracker = ({ lastState = state return state } - const createBalance = async ( - ctx: Context, - block: Block, - account: string, - balance: bigint, - ) => { + const createBalance = async (ctx: Context, block: Block, account: string, balance: bigint) => { if (account === ADDRESS_ZERO) return undefined const id = `${ctx.chain.id}-${block.header.height}-${address}-${account}` if (result.balances.has(id)) return result.balances.get(id)! @@ -170,8 +146,7 @@ export const createERC20SimpleTracker = ({ result.transfers.set(transfer.id, transfer) // Skip remaining if `from` and `to` are both address zero. - if (from === to && from === ADDRESS_ZERO) - throw new Error('what the fuck bro') + if (from === to && from === ADDRESS_ZERO) throw new Error('what the fuck bro') const [state, fromHolder, toHolder] = await Promise.all([ await getState(ctx, block), @@ -186,25 +161,17 @@ export const createERC20SimpleTracker = ({ state.totalSupply -= data.value } - // ctx.log.info(`${from} ${to} ${formatEther(data.value)}`) - // Handle From Address Changes if (fromHolder) { fromHolder.balance -= data.value await createBalance(ctx, block, from, fromHolder.balance) - } - if (fromHolder?.balance === 0n) { - state.holderCount += 1 + if (fromHolder.balance === 0n) { + state.holderCount -= 1 + } } // Handle To Address Changes if (toHolder?.balance === 0n && data.value > 0n) { state.holderCount += 1 - if (state.holderCount % 100 === 0) { - ctx.log.info({ - height: block.header.height, - holderCount: state.holderCount, - }) - } } if (toHolder) { toHolder.balance += data.value diff --git a/src/templates/exponential-staking/exponential-staking.ts b/src/templates/exponential-staking/exponential-staking.ts index 8877dc0d..97d649cd 100644 --- a/src/templates/exponential-staking/exponential-staking.ts +++ b/src/templates/exponential-staking/exponential-staking.ts @@ -184,6 +184,8 @@ export const createExponentialStakingTracker = ({ from, address }: { from: numbe address, account: data.user, lockupId: data.lockupId, + timestamp: new Date(block.header.timestamp), + lastUpdated: new Date(block.header.timestamp), end: data.end, amount: data.amount, points: data.points, @@ -203,6 +205,7 @@ export const createExponentialStakingTracker = ({ from, address }: { from: numbe const id = `${chainId}:${address}:${data.lockupId}` const entity = state.lockup.get(id) ?? (await ctx.store.get(ExponentialStakingLockup, id)) if (!entity) throw new Error(`Lockup not found: ${id}`) + entity.lastUpdated = new Date(block.header.timestamp) entity.withdrawAmount = data.amount entity.penalty = entity.amount - data.amount entity.state = ExponentialStakingLockupState.Closed @@ -217,7 +220,6 @@ export const createExponentialStakingTracker = ({ from, address }: { from: numbe for (const subProcessor of subProcessors) { processor.addLog(subProcessor.filter.value) } - processor.includeAllBlocks({ from }) }, async process(ctx: Context) { const state: State = { diff --git a/src/templates/fixed-rate-rewards-source/fixed-rate-rewards-source.ts b/src/templates/fixed-rate-rewards-source/fixed-rate-rewards-source.ts new file mode 100644 index 00000000..3a9d53a3 --- /dev/null +++ b/src/templates/fixed-rate-rewards-source/fixed-rate-rewards-source.ts @@ -0,0 +1,221 @@ +import * as abi from '@abi/fixed-rate-rewards-source' +import { + GovernorshipTransferred, + PendingGovernorshipTransfer, + RewardCollected, + RewardsPerSecondChanged, + RewardsTargetChange, + StrategistUpdated, +} from '@model' +import { Block, Context, Log } from '@processor' +import { EvmBatchProcessor } from '@subsquid/evm-processor' +import { LogFilter, logFilter } from '@utils/logFilter' + +interface State { + // Event Entities + governorshipTransferred: Map + pendingGovernorshipTransfer: Map + rewardCollected: Map + rewardsPerSecondChanged: Map + rewardsTargetChange: Map + strategistUpdated: Map +} + +export const createFixedRewardsSourceProcessor = ({ from, address }: { from: number; address: string }) => { + const governorshipTransferredFilter = logFilter({ + address: [address], + topic0: [abi.events.GovernorshipTransferred.topic], + range: { from }, + }) + const pendingGovernorshipTransferFilter = logFilter({ + address: [address], + topic0: [abi.events.PendingGovernorshipTransfer.topic], + range: { from }, + }) + const rewardCollectedFilter = logFilter({ + address: [address], + topic0: [abi.events.RewardCollected.topic], + range: { from }, + }) + const rewardsPerSecondChangedFilter = logFilter({ + address: [address], + topic0: [abi.events.RewardsPerSecondChanged.topic], + range: { from }, + }) + const rewardsTargetChangeFilter = logFilter({ + address: [address], + topic0: [abi.events.RewardsTargetChange.topic], + range: { from }, + }) + const strategistUpdatedFilter = logFilter({ + address: [address], + topic0: [abi.events.StrategistUpdated.topic], + range: { from }, + }) + + const subProcessors: { + description: string + filter: LogFilter + processor: (ctx: Context, block: Block, log: Log, state: State) => Promise + }[] = [ + { + description: 'Create GovernorshipTransferred event', + filter: governorshipTransferredFilter, + processor: async (ctx: Context, block: Block, log: Log, state: State) => { + const data = abi.events.GovernorshipTransferred.decode(log) + const id = `${ctx.chain.id}:${log.id}` + state.governorshipTransferred.set( + id, + new GovernorshipTransferred({ + id, + chainId: ctx.chain.id, + address, + timestamp: new Date(block.header.timestamp), + blockNumber: block.header.height, + newGovernor: data.newGovernor, + previousGovernor: data.previousGovernor, + }), + ) + }, + }, + { + description: 'Create PendingGovernorshipTransfer event', + filter: pendingGovernorshipTransferFilter, + processor: async (ctx: Context, block: Block, log: Log, state: State) => { + const data = abi.events.PendingGovernorshipTransfer.decode(log) + const id = `${ctx.chain.id}:${log.id}` + state.pendingGovernorshipTransfer.set( + id, + new PendingGovernorshipTransfer({ + id, + chainId: ctx.chain.id, + address, + timestamp: new Date(block.header.timestamp), + blockNumber: block.header.height, + newGovernor: data.newGovernor, + previousGovernor: data.previousGovernor, + }), + ) + }, + }, + { + description: 'Create RewardCollected event', + filter: rewardCollectedFilter, + processor: async (ctx: Context, block: Block, log: Log, state: State) => { + const data = abi.events.RewardCollected.decode(log) + const id = `${ctx.chain.id}:${log.id}` + state.rewardCollected.set( + id, + new RewardCollected({ + id, + chainId: ctx.chain.id, + address, + timestamp: new Date(block.header.timestamp), + blockNumber: block.header.height, + amountCollected: data.amountCollected, + }), + ) + }, + }, + { + description: 'Create RewardsPerSecondChanged event', + filter: rewardsPerSecondChangedFilter, + processor: async (ctx: Context, block: Block, log: Log, state: State) => { + const data = abi.events.RewardsPerSecondChanged.decode(log) + const id = `${ctx.chain.id}:${log.id}` + state.rewardsPerSecondChanged.set( + id, + new RewardsPerSecondChanged({ + id, + chainId: ctx.chain.id, + address, + timestamp: new Date(block.header.timestamp), + blockNumber: block.header.height, + newRPS: data.newRPS, + oldRPS: data.oldRPS, + }), + ) + }, + }, + { + description: 'Create RewardsTargetChange event', + filter: rewardsTargetChangeFilter, + processor: async (ctx: Context, block: Block, log: Log, state: State) => { + const data = abi.events.RewardsTargetChange.decode(log) + const id = `${ctx.chain.id}:${log.id}` + state.rewardsTargetChange.set( + id, + new RewardsTargetChange({ + id, + chainId: ctx.chain.id, + address, + timestamp: new Date(block.header.timestamp), + blockNumber: block.header.height, + previousTarget: data.previousTarget, + target: data.target, + }), + ) + }, + }, + { + description: 'Create StrategistUpdated event', + filter: strategistUpdatedFilter, + processor: async (ctx: Context, block: Block, log: Log, state: State) => { + const data = abi.events.StrategistUpdated.decode(log) + const id = `${ctx.chain.id}:${log.id}` + state.strategistUpdated.set( + id, + new StrategistUpdated({ + id, + chainId: ctx.chain.id, + address, + timestamp: new Date(block.header.timestamp), + blockNumber: block.header.height, + strategistAddress: data._address, + }), + ) + }, + }, + ] + + const setup = (processor: EvmBatchProcessor) => { + for (const subProcessor of subProcessors) { + processor.addLog(subProcessor.filter.value) + } + } + + const process = async (ctx: Context) => { + const state: State = { + // Event Entities + governorshipTransferred: new Map(), + pendingGovernorshipTransfer: new Map(), + rewardCollected: new Map(), + rewardsPerSecondChanged: new Map(), + rewardsTargetChange: new Map(), + strategistUpdated: new Map(), + } + for (const block of ctx.blocks) { + for (const log of block.logs) { + for (const subProcessor of subProcessors) { + if (subProcessor.filter.matches(log)) { + await subProcessor.processor(ctx, block, log, state) + } + } + } + } + await Promise.all([ + ctx.store.insert([...state.governorshipTransferred.values()]), + ctx.store.insert([...state.pendingGovernorshipTransfer.values()]), + ctx.store.insert([...state.rewardCollected.values()]), + ctx.store.insert([...state.rewardsPerSecondChanged.values()]), + ctx.store.insert([...state.rewardsTargetChange.values()]), + ctx.store.insert([...state.strategistUpdated.values()]), + ]) + } + + return { + from, + setup, + process, + } +} diff --git a/src/templates/fixed-rate-rewards-source/index.ts b/src/templates/fixed-rate-rewards-source/index.ts new file mode 100644 index 00000000..4f778dc2 --- /dev/null +++ b/src/templates/fixed-rate-rewards-source/index.ts @@ -0,0 +1 @@ +export * from './fixed-rate-rewards-source' diff --git a/src/templates/governance/governance.ts b/src/templates/governance/governance.ts index 5e4ae2ca..77a6b52e 100644 --- a/src/templates/governance/governance.ts +++ b/src/templates/governance/governance.ts @@ -133,28 +133,27 @@ export const createGovernanceProcessor = ({ from, address }: { from: number; add const _processProposalCreated = async (ctx: Context, result: IProcessResult, block: Block, log: Log) => { // ctx.log.info('_processProposalCreated') - const { - proposalId, - proposer: proposerAddr, - description, - startBlock, - endBlock, - } = governanceAbi.events.ProposalCreated.decode(log) + const data = governanceAbi.events.ProposalCreated.decode(log) const blockTimestamp = new Date(block.header.timestamp) const governance = new governanceAbi.Contract(ctx, block.header, address) const proposal = new GovernanceProposal({ - id: `${ctx.chain.id}:${address}:${proposalId}`, + id: `${ctx.chain.id}:${address}:${data.proposalId}`, chainId: ctx.chain.id, address, - proposalId, - description, - proposer: proposerAddr.toLowerCase(), + proposalId: data.proposalId, + description: data.description, + proposer: data.proposer.toLowerCase(), timestamp: blockTimestamp, - startBlock, - endBlock, + startBlock: data.startBlock, + endBlock: data.endBlock, + signatures: data.signatures, + calldatas: data.calldatas, + values: data.values.map((v) => v.toString()), + targets: data.targets, lastUpdated: new Date(), status: GovernanceProposalState.Pending, + events: [], quorum: await governance.quorum(BigInt(block.header.height - 1)), choices: [], scores: [], @@ -170,7 +169,7 @@ export const createGovernanceProcessor = ({ from, address }: { from: number; add timestamp: blockTimestamp, }) - result.proposals.set(proposalId.toString(), proposal) + result.proposals.set(proposal.id, proposal) result.proposalEvents.push(proposalTxLog) } @@ -194,23 +193,23 @@ export const createGovernanceProcessor = ({ from, address }: { from: number; add if (block.header.height > goActiveBlock) { ctx.log.info('block.header.height > goActiveBlock') for (const proposal of pendingProposals.filter((p) => block.header.height > Number(p.startBlock))) { - await _updateProposalStatus(ctx, result, block, proposal.id) + await _updateProposalStatus(ctx, result, block, proposal.proposalId) } pendingProposals = pendingProposals.filter((p) => block.header.height <= Number(p.startBlock)) } if (block.header.height > goFinishedBlock) { ctx.log.info('block.header.height > goFinishedBlock') for (const proposal of activeProposals.filter((p) => block.header.height > Number(p.endBlock))) { - await _updateProposalStatus(ctx, result, block, proposal.id) + await _updateProposalStatus(ctx, result, block, proposal.proposalId) } activeProposals = activeProposals.filter((p) => block.header.height <= Number(p.endBlock)) } _updateStatusBlocks() } - const _updateProposalStatus = async (ctx: Context, result: IProcessResult, block: Block, proposalId: string) => { + const _updateProposalStatus = async (ctx: Context, result: IProcessResult, block: Block, proposalId: bigint) => { const proposal = await _getProposal(ctx, proposalId, result) - proposal.status = await _getProposalState(ctx, block, BigInt(proposalId)) + proposal.status = await _getProposalState(ctx, block, proposal.proposalId) ctx.log.info({ status: proposal.status }, '_updateProposalStatus') if (proposal.status === GovernanceProposalState.Pending && !pendingProposals.find((p) => p.id === proposal.id)) { pendingProposals.push(proposal) @@ -227,8 +226,8 @@ export const createGovernanceProcessor = ({ from, address }: { from: number; add const { proposalId } = decode(log) const blockTimestamp = new Date(block.header.timestamp) - const proposal = await _getProposal(ctx, proposalId.toString(), result) - await _updateProposalStatus(ctx, result, block, proposalId.toString()) + const proposal = await _getProposal(ctx, proposalId, result) + await _updateProposalStatus(ctx, result, block, proposalId) const proposalTxLog = new GovernanceProposalEvent({ id: `${ctx.chain.id}:${log.id}`, @@ -246,9 +245,9 @@ export const createGovernanceProcessor = ({ from, address }: { from: number; add const { proposalId, extendedDeadline } = governanceAbi.events.ProposalExtended.decode(log) const blockTimestamp = new Date(block.header.timestamp) - const proposal = await _getProposal(ctx, proposalId.toString(), result) + const proposal = await _getProposal(ctx, proposalId, result) proposal.endBlock = extendedDeadline - await _updateProposalStatus(ctx, result, block, proposalId.toString()) + await _updateProposalStatus(ctx, result, block, proposalId) const proposalTxLog = new GovernanceProposalEvent({ id: `${ctx.chain.id}:${log.id}`, @@ -273,7 +272,7 @@ export const createGovernanceProcessor = ({ from, address }: { from: number; add : governanceAbi.events.VoteCastWithParams.decode(log) const blockTimestamp = new Date(block.header.timestamp) - const proposal = await _getProposal(ctx, proposalId.toString(), result) + const proposal = await _getProposal(ctx, proposalId, result) const voteType = [GovernanceVoteType.Against, GovernanceVoteType.For, GovernanceVoteType.Abstain][ parseInt(support.toString()) @@ -312,8 +311,13 @@ export const createGovernanceProcessor = ({ from, address }: { from: number; add ) } - const _getProposal = async (ctx: Context, id: string, result: IProcessResult): Promise => { + const _getProposal = async ( + ctx: Context, + proposalId: bigint, + result: IProcessResult, + ): Promise => { const { proposals } = result + const id = `${ctx.chain.id}:${address}:${proposalId}` if (proposals.has(id)) { return proposals.get(id)! @@ -328,5 +332,5 @@ export const createGovernanceProcessor = ({ from, address }: { from: number; add return proposal } - return { setup, initialize, process } + return { from, setup, initialize, process } } diff --git a/src/utils/addresses.ts b/src/utils/addresses.ts index 5b51a1cc..8d2d71b6 100644 --- a/src/utils/addresses.ts +++ b/src/utils/addresses.ts @@ -11,8 +11,7 @@ export const USDC_ADDRESS = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' export const CRV3_ADDRESS = '0x6c3f90f043a72fa612cbac8115ee7e52bde6e490' export const LUSD_ADDRESS = '0x5f98805a4e8be255a32880fdec7f6728c6568ba0' export const OUSD_VAULT_ADDRESS = '0xe75d77b1865ae93c7eaa3040b038d7aa7bc02f70' -export const OUSD_HARVESTER_ADDRESS = - '0x21fb5812d70b3396880d30e90d9e5c1202266c89' +export const OUSD_HARVESTER_ADDRESS = '0x21fb5812d70b3396880d30e90d9e5c1202266c89' export const OUSD_DRIPPER_ADDRESS = '0x80c898ae5e56f888365e235ceb8cea3eb726cb58' export const OUSD_STABLE_OTOKENS = [OUSD_ADDRESS] @@ -23,8 +22,7 @@ export const OETH_HARVESTER_ADDRESS = `0x0d017afa83eace9f10a8ec5b6e13941664a6785 export const OETH_ZAPPER_ADDRESS = '0x9858e47bcbbe6fbac040519b02d7cd4b2c470c66' export const OETH_DRIPPER_ADDRESS = '0xc0f42f73b8f01849a2dd99753524d4ba14317eb3' export const WOETH_ADDRESS = '0xdcee70654261af21c44c093c300ed3bb97b78192' -export const WOETH_ARBITRUM_ADDRESS = - '0xd8724322f44e5c58d7a815f542036fb17dbbf839' +export const WOETH_ARBITRUM_ADDRESS = '0xd8724322f44e5c58d7a815f542036fb17dbbf839' export const WETH_ADDRESS = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' export const STETH_ADDRESS = '0xae7ab96520de3a18e5e111b5eaab095312d7fe84' @@ -35,40 +33,25 @@ export const SFRXETH_ADDRESS = '0xac3e018457b222d93114458476f3e3416abbe38f' export const BAL_ADDRESS = '0xba100000625a3754423978a60c9317c58a424e3d' -export const OUSD_VAULT_ERC20_ADDRESSES = [ - DAI_ADDRESS, - USDC_ADDRESS, - USDT_ADDRESS, -] +export const OUSD_VAULT_ERC20_ADDRESSES = [DAI_ADDRESS, USDC_ADDRESS, USDT_ADDRESS] -export const OETH_VAULT_ERC20_ADDRESSES = [ - WETH_ADDRESS, - STETH_ADDRESS, - RETH_ADDRESS, - FRXETH_ADDRESS, -] +export const OETH_VAULT_ERC20_ADDRESSES = [WETH_ADDRESS, STETH_ADDRESS, RETH_ADDRESS, FRXETH_ADDRESS] export const OETH_CONVEX_ADDRESS = '0x1827f9ea98e0bf96550b2fc20f7233277fcd7e63' -export const OETH_CURVE_REWARD_LP_ADDRESS = - '0x24b65dc1cf053a8d96872c323d29e86ec43eb33a' -export const OETH_CURVE_LP_ADDRESS = - '0x94b17476a93b3262d87b9a326965d1e91f9c13e7' +export const OETH_CURVE_REWARD_LP_ADDRESS = '0x24b65dc1cf053a8d96872c323d29e86ec43eb33a' +export const OETH_CURVE_LP_ADDRESS = '0x94b17476a93b3262d87b9a326965d1e91f9c13e7' // export const OETH_CURVE_LP_OWNER_ADDRESS = '0xd03be91b1932715709e18021734fcb91bb431715' // export const CONVEX_DEPOSIT = '0xf403c135812408bfbe8713b5a23a04b3d48aae31' -export const OETH_FRAX_STAKING_ADDRESS = - '0x3ff8654d633d4ea0fae24c52aec73b4a20d0d0e5' +export const OETH_FRAX_STAKING_ADDRESS = '0x3ff8654d633d4ea0fae24c52aec73b4a20d0d0e5' -export const OETH_MORPHO_AAVE_ADDRESS = - '0xc1fc9e5ec3058921ea5025d703cbe31764756319' +export const OETH_MORPHO_AAVE_ADDRESS = '0xc1fc9e5ec3058921ea5025d703cbe31764756319' -export const OETH_STRATEGY_BALANCER_ADDRESS = - '0x49109629ac1deb03f2e9b2fe2ac4a623e0e7dfdc' +export const OETH_STRATEGY_BALANCER_ADDRESS = '0x49109629ac1deb03f2e9b2fe2ac4a623e0e7dfdc' export const BALANCER_VAULT = '0xba12222222228d8ba445958a75a0704d566bf2c8' -export const AURA_REWARDS_POOL_ADDRESS = - '0xdd1fe5ad401d4777ce89959b7fa587e569bf125d' +export const AURA_REWARDS_POOL_ADDRESS = '0xdd1fe5ad401d4777ce89959b7fa587e569bf125d' export const GOVERNANCE_ADDRESS = '0x3cdd07c16614059e66344a7b579dab4f9516c0b6' @@ -76,11 +59,14 @@ export const OGN_ADDRESS = '0x8207c1ffc5b6804f6024322ccf34f29c3541ae26' export const OGV_ADDRESS = '0x9c354503c38481a7a7a51629142963f98ecc12d0' export const VEOGV_ADDRESS = '0x0c4576ca1c365868e162554af8e385dc3e7c66d9' +export const XOGN_ADDRESS = '0x63898b3b6ef3d39332082178656e9862bee45c57' +export const OGN_REWARDS_SOURCE_ADDRESS = '0x7609c88e5880e934dd3a75bcfef44e31b1badb8b' // Token Helper Objects & Types export const tokens = { // Origin ERC20 Tokens OGN: OGN_ADDRESS, + xOGN: XOGN_ADDRESS, OGV: OGV_ADDRESS, veOGV: VEOGV_ADDRESS, From f30995416bf870c0b1baa48733bb65d2e816b84a Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Tue, 21 May 2024 17:26:32 -0700 Subject: [PATCH 07/13] less output --- src/templates/governance/governance.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/templates/governance/governance.ts b/src/templates/governance/governance.ts index 77a6b52e..3d1ba5a0 100644 --- a/src/templates/governance/governance.ts +++ b/src/templates/governance/governance.ts @@ -191,14 +191,14 @@ export const createGovernanceProcessor = ({ from, address }: { from: number; add ) => { // Update for Active and post-Active statuses. if (block.header.height > goActiveBlock) { - ctx.log.info('block.header.height > goActiveBlock') + // ctx.log.info('block.header.height > goActiveBlock') for (const proposal of pendingProposals.filter((p) => block.header.height > Number(p.startBlock))) { await _updateProposalStatus(ctx, result, block, proposal.proposalId) } pendingProposals = pendingProposals.filter((p) => block.header.height <= Number(p.startBlock)) } if (block.header.height > goFinishedBlock) { - ctx.log.info('block.header.height > goFinishedBlock') + // ctx.log.info('block.header.height > goFinishedBlock') for (const proposal of activeProposals.filter((p) => block.header.height > Number(p.endBlock))) { await _updateProposalStatus(ctx, result, block, proposal.proposalId) } @@ -210,7 +210,7 @@ export const createGovernanceProcessor = ({ from, address }: { from: number; add const _updateProposalStatus = async (ctx: Context, result: IProcessResult, block: Block, proposalId: bigint) => { const proposal = await _getProposal(ctx, proposalId, result) proposal.status = await _getProposalState(ctx, block, proposal.proposalId) - ctx.log.info({ status: proposal.status }, '_updateProposalStatus') + // ctx.log.info({ status: proposal.status }, '_updateProposalStatus') if (proposal.status === GovernanceProposalState.Pending && !pendingProposals.find((p) => p.id === proposal.id)) { pendingProposals.push(proposal) } From 096e6075c1fbbdfb9a475d59d784c7176aa8b91a Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Wed, 22 May 2024 18:24:07 -0700 Subject: [PATCH 08/13] improvements and fixes + new deployment in v999 --- ...32143675-Data.js => 1716426610413-Data.js} | 292 ++++++++--------- schema.graphql | 74 ++--- schema/exponential-staking.graphql | 48 +-- schema/fixed-rate-rewards-source.graphql | 26 +- src/main-mainnet.ts | 31 +- ...takingLockupState.ts => _esLockupState.ts} | 2 +- ...ingPenalty.model.ts => esAccount.model.ts} | 15 +- ...ed.model.ts => esDelegateChanged.model.ts} | 12 +- ...del.ts => esDelegateVotesChanged.model.ts} | 14 +- ...akingLockup.model.ts => esLockup.model.ts} | 8 +- ...ialStaking.model.ts => esPenalty.model.ts} | 11 +- src/model/generated/esReward.model.ts | 34 ++ ...akingUnstake.model.ts => esStake.model.ts} | 14 +- ...akingStake.model.ts => esUnstake.model.ts} | 14 +- src/model/generated/esYield.model.ts | 39 +++ .../exponentialStakingAccount.model.ts | 38 --- ...exponentialStakingDelegateChanged.model.ts | 29 -- .../exponentialStakingReward.model.ts | 26 -- ....model.ts => frrsRewardCollected.model.ts} | 4 +- ...s => frrsRewardsPerSecondChanged.model.ts} | 4 +- ...el.ts => frrsRewardsTargetChange.model.ts} | 4 +- ...odel.ts => frrsStrategistUpdated.model.ts} | 4 +- src/model/generated/index.ts | 30 +- .../pendingGovernorshipTransfer.model.ts | 33 -- .../exponential-staking.ts | 300 +++++++++++++++--- .../fixed-rate-rewards-source.ts | 95 ++---- 26 files changed, 671 insertions(+), 530 deletions(-) rename db/migrations/{1716332143675-Data.js => 1716426610413-Data.js} (79%) rename src/model/generated/{_exponentialStakingLockupState.ts => _esLockupState.ts} (50%) rename src/model/generated/{exponentialStakingPenalty.model.ts => esAccount.model.ts} (52%) rename src/model/generated/{governorshipTransferred.model.ts => esDelegateChanged.model.ts} (76%) rename src/model/generated/{exponentialStakingDelegateVotesChanged.model.ts => esDelegateVotesChanged.model.ts} (60%) rename src/model/generated/{exponentialStakingLockup.model.ts => esLockup.model.ts} (82%) rename src/model/generated/{exponentialStaking.model.ts => esPenalty.model.ts} (78%) create mode 100644 src/model/generated/esReward.model.ts rename src/model/generated/{exponentialStakingUnstake.model.ts => esStake.model.ts} (67%) rename src/model/generated/{exponentialStakingStake.model.ts => esUnstake.model.ts} (66%) create mode 100644 src/model/generated/esYield.model.ts delete mode 100644 src/model/generated/exponentialStakingAccount.model.ts delete mode 100644 src/model/generated/exponentialStakingDelegateChanged.model.ts delete mode 100644 src/model/generated/exponentialStakingReward.model.ts rename src/model/generated/{rewardCollected.model.ts => frrsRewardCollected.model.ts} (88%) rename src/model/generated/{rewardsPerSecondChanged.model.ts => frrsRewardsPerSecondChanged.model.ts} (87%) rename src/model/generated/{rewardsTargetChange.model.ts => frrsRewardsTargetChange.model.ts} (88%) rename src/model/generated/{strategistUpdated.model.ts => frrsStrategistUpdated.model.ts} (87%) delete mode 100644 src/model/generated/pendingGovernorshipTransfer.model.ts diff --git a/db/migrations/1716332143675-Data.js b/db/migrations/1716426610413-Data.js similarity index 79% rename from db/migrations/1716332143675-Data.js rename to db/migrations/1716426610413-Data.js index 2d9d4c51..d872248d 100644 --- a/db/migrations/1716332143675-Data.js +++ b/db/migrations/1716426610413-Data.js @@ -1,77 +1,80 @@ -module.exports = class Data1716332143675 { - name = 'Data1716332143675' +module.exports = class Data1716426610413 { + name = 'Data1716426610413' async up(db) { - await db.query(`CREATE TABLE "exponential_staking" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "acc_reward_per_share" numeric NOT NULL, "asset_balance" numeric NOT NULL, CONSTRAINT "PK_ec40683ce69d33cf491bd8a5f3c" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_9004da9adf2bb66b8cc9a9ddbd" ON "exponential_staking" ("chain_id") `) - await db.query(`CREATE INDEX "IDX_bf1eab37b83a2261ba42a53b32" ON "exponential_staking" ("address") `) - await db.query(`CREATE INDEX "IDX_12fcf9c28429a1047732dd028b" ON "exponential_staking" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_ed1440d963237e211f39c26c43" ON "exponential_staking" ("block_number") `) - await db.query(`CREATE TABLE "exponential_staking_lockup" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "account" text NOT NULL, "lockup_id" numeric NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "last_updated" TIMESTAMP WITH TIME ZONE NOT NULL, "amount" numeric NOT NULL, "end" numeric NOT NULL, "points" numeric NOT NULL, "withdraw_amount" numeric NOT NULL, "penalty" numeric NOT NULL, "state" character varying(6), CONSTRAINT "PK_d94037fed0429476133dc118edf" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_d9e01c551c9f1a4d7710242ed8" ON "exponential_staking_lockup" ("chain_id") `) - await db.query(`CREATE INDEX "IDX_9c8d024fea4fe0a45d95c801d5" ON "exponential_staking_lockup" ("address") `) - await db.query(`CREATE INDEX "IDX_c31d2fe385b684604bfa071229" ON "exponential_staking_lockup" ("account") `) - await db.query(`CREATE INDEX "IDX_9e8c0b852aeb43e4ca4a44fc70" ON "exponential_staking_lockup" ("lockup_id") `) - await db.query(`CREATE TABLE "exponential_staking_account" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "account" text NOT NULL, "votes" numeric NOT NULL, "balance" numeric NOT NULL, "preview_points" numeric NOT NULL, "preview_rewards" numeric NOT NULL, "preview_withdraw" numeric NOT NULL, CONSTRAINT "PK_b10010a05da6f8fdf0d030c5d82" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_e55574850608a204d5e3068b85" ON "exponential_staking_account" ("chain_id") `) - await db.query(`CREATE INDEX "IDX_f2cf0e2b357e83e3c99c9076cd" ON "exponential_staking_account" ("address") `) - await db.query(`CREATE INDEX "IDX_aa85510db9e37072506a7c6c02" ON "exponential_staking_account" ("account") `) - await db.query(`CREATE TABLE "exponential_staking_delegate_changed" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "delegator" text NOT NULL, "from_delegate" text NOT NULL, "to_delegate" text NOT NULL, CONSTRAINT "PK_e09bddf9ba0a1f924d668027121" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_9de723df03ba620afd586dbbf2" ON "exponential_staking_delegate_changed" ("chain_id") `) - await db.query(`CREATE INDEX "IDX_2c19bc13f9e9c65b521be853b0" ON "exponential_staking_delegate_changed" ("address") `) - await db.query(`CREATE INDEX "IDX_83bb461676640a6666f4c34240" ON "exponential_staking_delegate_changed" ("delegator") `) - await db.query(`CREATE TABLE "exponential_staking_delegate_votes_changed" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "delegate" text NOT NULL, "previous_balance" numeric NOT NULL, "new_balance" numeric NOT NULL, CONSTRAINT "PK_3c0770caf6cd7add1f6c5121d17" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_8bb7224130c6f200d3800d81ad" ON "exponential_staking_delegate_votes_changed" ("chain_id") `) - await db.query(`CREATE INDEX "IDX_8a1b69ff53c4fdf5fbe4b1ef8a" ON "exponential_staking_delegate_votes_changed" ("address") `) - await db.query(`CREATE INDEX "IDX_c61dfffcf23d4988983ceb67e9" ON "exponential_staking_delegate_votes_changed" ("delegate") `) - await db.query(`CREATE TABLE "exponential_staking_penalty" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "account" text NOT NULL, "amount" numeric NOT NULL, CONSTRAINT "PK_6066556e7ac7611aa30852d522c" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_686c1e7635d16ed4974d4fba7e" ON "exponential_staking_penalty" ("chain_id") `) - await db.query(`CREATE INDEX "IDX_e8d2ec04a0cabd68281ffbced0" ON "exponential_staking_penalty" ("address") `) - await db.query(`CREATE INDEX "IDX_8a204e6d28385b4971177fd73b" ON "exponential_staking_penalty" ("account") `) - await db.query(`CREATE TABLE "exponential_staking_reward" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "account" text NOT NULL, "amount" numeric NOT NULL, CONSTRAINT "PK_506c1ea29e2e93a51a250d5d457" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_c2503d0a7f3c5a4176b80b6ee6" ON "exponential_staking_reward" ("chain_id") `) - await db.query(`CREATE INDEX "IDX_af7a218b05626c5b6b3b6a4702" ON "exponential_staking_reward" ("address") `) - await db.query(`CREATE INDEX "IDX_b252d19aa52a4683819bdd94b8" ON "exponential_staking_reward" ("account") `) - await db.query(`CREATE TABLE "exponential_staking_stake" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "account" text NOT NULL, "lockup_id" numeric NOT NULL, "amount" numeric NOT NULL, "end" numeric NOT NULL, "points" numeric NOT NULL, CONSTRAINT "PK_6f31743cbb489b127e964f97bb6" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_c6b9bbec61e2fca250ce7d4a32" ON "exponential_staking_stake" ("chain_id") `) - await db.query(`CREATE INDEX "IDX_9e93319f4c9133472807912986" ON "exponential_staking_stake" ("address") `) - await db.query(`CREATE INDEX "IDX_c38f73385b9aae63c9a8e4cd57" ON "exponential_staking_stake" ("account") `) - await db.query(`CREATE INDEX "IDX_6aa54b83c2205337175f5a6e17" ON "exponential_staking_stake" ("lockup_id") `) - await db.query(`CREATE TABLE "exponential_staking_unstake" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "account" text NOT NULL, "lockup_id" numeric NOT NULL, "amount" numeric NOT NULL, "end" numeric NOT NULL, "points" numeric NOT NULL, CONSTRAINT "PK_2a537c20d900d4efec853755435" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_3a3fa2fd9ffdd64dca1d5ab3b8" ON "exponential_staking_unstake" ("chain_id") `) - await db.query(`CREATE INDEX "IDX_7cd924c25b352e2288137ca23b" ON "exponential_staking_unstake" ("address") `) - await db.query(`CREATE INDEX "IDX_f2dff3c4211d5d57eaf627b6c8" ON "exponential_staking_unstake" ("account") `) - await db.query(`CREATE INDEX "IDX_5eba41d0c2d4d5ff4c5e5c0411" ON "exponential_staking_unstake" ("lockup_id") `) - await db.query(`CREATE TABLE "governorship_transferred" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "previous_governor" text NOT NULL, "new_governor" text NOT NULL, CONSTRAINT "PK_a8377859ab1cb2c7179f248e4e2" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_9ab2b5486d85bd8aa36730fc02" ON "governorship_transferred" ("chain_id") `) - await db.query(`CREATE INDEX "IDX_554f6c0e2738e30856bdc4b725" ON "governorship_transferred" ("address") `) - await db.query(`CREATE INDEX "IDX_d955cfa47fa1ff270a5578ba43" ON "governorship_transferred" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_9d0eb3c05b7d0585f9d8d9eeb0" ON "governorship_transferred" ("block_number") `) - await db.query(`CREATE TABLE "pending_governorship_transfer" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "previous_governor" text NOT NULL, "new_governor" text NOT NULL, CONSTRAINT "PK_68913ab28a55f5a756c70ca31c3" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_92e258fe6b6f9c65cdbe750c65" ON "pending_governorship_transfer" ("chain_id") `) - await db.query(`CREATE INDEX "IDX_0fe23661b80871659e54dda998" ON "pending_governorship_transfer" ("address") `) - await db.query(`CREATE INDEX "IDX_d17c593674455b0554220cf1b0" ON "pending_governorship_transfer" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_2b89e9ec7edc194f9f0a914053" ON "pending_governorship_transfer" ("block_number") `) - await db.query(`CREATE TABLE "reward_collected" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "amount_collected" numeric NOT NULL, CONSTRAINT "PK_b9219358e897a814168f7d9f805" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_0f6ab10957c09ebed8b2fc25c5" ON "reward_collected" ("chain_id") `) - await db.query(`CREATE INDEX "IDX_f6c2334f64b880139f96db37a5" ON "reward_collected" ("address") `) - await db.query(`CREATE INDEX "IDX_fd3d30debdb9c5981471747b9b" ON "reward_collected" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_0ea0eaa90ecddef5213a787419" ON "reward_collected" ("block_number") `) - await db.query(`CREATE TABLE "rewards_per_second_changed" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "new_rps" numeric NOT NULL, "old_rps" numeric NOT NULL, CONSTRAINT "PK_716c2975993acabb52c7e4c1bd6" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_b820e1afc853dffd1556e7b2a6" ON "rewards_per_second_changed" ("chain_id") `) - await db.query(`CREATE INDEX "IDX_fdd9f60fc758695e25ae3ef6ca" ON "rewards_per_second_changed" ("address") `) - await db.query(`CREATE INDEX "IDX_487950908e327e4ccabd36820b" ON "rewards_per_second_changed" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_da9541b9abd658528a015df4cc" ON "rewards_per_second_changed" ("block_number") `) - await db.query(`CREATE TABLE "rewards_target_change" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "target" text NOT NULL, "previous_target" text NOT NULL, CONSTRAINT "PK_99bc1b16e49937a7f1ca2068c58" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_57ca8bf4b751d1de10f44a08d6" ON "rewards_target_change" ("chain_id") `) - await db.query(`CREATE INDEX "IDX_de0fb0e64b2f2012da9e29d277" ON "rewards_target_change" ("address") `) - await db.query(`CREATE INDEX "IDX_e21598b3cc8c9f85c4af20433c" ON "rewards_target_change" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_6b94b5ef03dd72ed73f3209642" ON "rewards_target_change" ("block_number") `) - await db.query(`CREATE TABLE "strategist_updated" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "strategist_address" text NOT NULL, CONSTRAINT "PK_ed7a217e068cbc1762e9c04e68d" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_3ddb234b6c80ea1d59b2922fe4" ON "strategist_updated" ("chain_id") `) - await db.query(`CREATE INDEX "IDX_103140942203924024fcb8fbbd" ON "strategist_updated" ("address") `) - await db.query(`CREATE INDEX "IDX_0d9424ca64d47f409467f3ccc5" ON "strategist_updated" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_3e6d818b5c76a45fdd1b7ff18c" ON "strategist_updated" ("block_number") `) + await db.query(`CREATE TABLE "es_yield" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "asset_balance" numeric NOT NULL, "rewards_per_second" numeric NOT NULL, "apr" numeric NOT NULL, "apy" numeric NOT NULL, CONSTRAINT "PK_52ad2363a2797ab8ce74fa9765a" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_aa3649a103464d797c959294d1" ON "es_yield" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_700ebb527927ee781c0750b0dc" ON "es_yield" ("address") `) + await db.query(`CREATE INDEX "IDX_e2d3a1ddc3f0886f51556442bb" ON "es_yield" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_4fdca11723165347776a9a7110" ON "es_yield" ("block_number") `) + await db.query(`CREATE TABLE "es_lockup" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "account" text NOT NULL, "lockup_id" numeric NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "last_updated" TIMESTAMP WITH TIME ZONE NOT NULL, "amount" numeric NOT NULL, "end" numeric NOT NULL, "points" numeric NOT NULL, "withdraw_amount" numeric NOT NULL, "penalty" numeric NOT NULL, "state" character varying(6), CONSTRAINT "PK_5b189f92ac5becc0db1e5d1f8ad" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_15e9dc0d375d6f2687def01843" ON "es_lockup" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_f3c10b1e75f626e1aaeaa3cfc3" ON "es_lockup" ("address") `) + await db.query(`CREATE INDEX "IDX_5dd7ffdf1c625829f7eb79ee27" ON "es_lockup" ("account") `) + await db.query(`CREATE INDEX "IDX_31b53c3e4649bde773d707b2a0" ON "es_lockup" ("lockup_id") `) + await db.query(`CREATE TABLE "es_account" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "account" text NOT NULL, "vote_balance" numeric NOT NULL, "delegate_to_id" character varying, CONSTRAINT "PK_819b7e05161fa9d1f724b31e1b7" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_eb97a0d869e67af870987d6d85" ON "es_account" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_93fea1d847b38c9982626e5fd1" ON "es_account" ("address") `) + await db.query(`CREATE INDEX "IDX_bc09480c9d1b13806f82337b5e" ON "es_account" ("account") `) + await db.query(`CREATE INDEX "IDX_7b43e7bb90d3b435d074112f57" ON "es_account" ("delegate_to_id") `) + await db.query(`CREATE TABLE "es_delegate_changed" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "delegator" text NOT NULL, "from_delegate" text NOT NULL, "to_delegate" text NOT NULL, CONSTRAINT "PK_4d5857f4fe4904dea337644e603" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_76c1740192ed8b589f7b5a21c8" ON "es_delegate_changed" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_ed5ea936cde8d62b485ce45a13" ON "es_delegate_changed" ("address") `) + await db.query(`CREATE INDEX "IDX_22f639893bc36efe524a3bbca7" ON "es_delegate_changed" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_ed12aa7ace584cc494012a0e5b" ON "es_delegate_changed" ("block_number") `) + await db.query(`CREATE INDEX "IDX_cda0b80789007b35cf5430966f" ON "es_delegate_changed" ("delegator") `) + await db.query(`CREATE TABLE "es_delegate_votes_changed" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "delegate" text NOT NULL, "previous_balance" numeric NOT NULL, "new_balance" numeric NOT NULL, CONSTRAINT "PK_4e8cd459830447ee5dd3a7e802b" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_4e20cdc38777932fadd008f6e4" ON "es_delegate_votes_changed" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_076fb50935afa2f319f1d16752" ON "es_delegate_votes_changed" ("address") `) + await db.query(`CREATE INDEX "IDX_338d2483a33dc74d360d2a44c5" ON "es_delegate_votes_changed" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_e0e6b12e50b95fb9b99c28df90" ON "es_delegate_votes_changed" ("block_number") `) + await db.query(`CREATE INDEX "IDX_bd6f657c57e5a92a8dd3fe6b4e" ON "es_delegate_votes_changed" ("delegate") `) + await db.query(`CREATE TABLE "es_penalty" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "account" text NOT NULL, "amount" numeric NOT NULL, CONSTRAINT "PK_41b7961c4867c2d18f8afa921cc" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_59fa17e121ecd2bead0a71cf85" ON "es_penalty" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_785a65f92c61edd176415e22ad" ON "es_penalty" ("address") `) + await db.query(`CREATE INDEX "IDX_7402aa565f5e2023e310610240" ON "es_penalty" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_8595139811169d26aa210f8a8d" ON "es_penalty" ("block_number") `) + await db.query(`CREATE INDEX "IDX_adc7f2fe26e4a36690a343339b" ON "es_penalty" ("account") `) + await db.query(`CREATE TABLE "es_reward" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "account" text NOT NULL, "amount" numeric NOT NULL, CONSTRAINT "PK_52643252c6b05e1a6d337081d9b" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_e05d0476721dfcf9152b58fc30" ON "es_reward" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_f01dea25da96f8d8eaec9b6f60" ON "es_reward" ("address") `) + await db.query(`CREATE INDEX "IDX_2f3b61cc072d95ad0796b9caa3" ON "es_reward" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_a3d39d7235e278255a5217d1df" ON "es_reward" ("block_number") `) + await db.query(`CREATE INDEX "IDX_b623db55430fefda84dfdf2949" ON "es_reward" ("account") `) + await db.query(`CREATE TABLE "es_stake" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "account" text NOT NULL, "lockup_id" numeric NOT NULL, "amount" numeric NOT NULL, "end" numeric NOT NULL, "points" numeric NOT NULL, CONSTRAINT "PK_86bb48f03d8a3ca01f8d0339c66" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_385357cc5f41796615d8880190" ON "es_stake" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_e7bcc8120e2c256db6ebd01575" ON "es_stake" ("address") `) + await db.query(`CREATE INDEX "IDX_b95e58860bb9ba46d0ec41d246" ON "es_stake" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_d059ea472eb9d10f6be2025d40" ON "es_stake" ("block_number") `) + await db.query(`CREATE INDEX "IDX_2d2f6b568b3145fe6095da5afa" ON "es_stake" ("account") `) + await db.query(`CREATE INDEX "IDX_bcb392795674b2cc0af394864c" ON "es_stake" ("lockup_id") `) + await db.query(`CREATE TABLE "es_unstake" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "account" text NOT NULL, "lockup_id" numeric NOT NULL, "amount" numeric NOT NULL, "end" numeric NOT NULL, "points" numeric NOT NULL, CONSTRAINT "PK_649003a33f9fb327e2f72d8e5df" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_0c51c706a778668dbd5ed9c817" ON "es_unstake" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_9301687673c195770cdd543049" ON "es_unstake" ("address") `) + await db.query(`CREATE INDEX "IDX_13fbe169018991ddcfeb4912cb" ON "es_unstake" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_06c024c53472178d0f5292330a" ON "es_unstake" ("block_number") `) + await db.query(`CREATE INDEX "IDX_0adcdd08da131e76d618b73db7" ON "es_unstake" ("account") `) + await db.query(`CREATE INDEX "IDX_cc43898a790e6e1d4bbf145097" ON "es_unstake" ("lockup_id") `) + await db.query(`CREATE TABLE "frrs_reward_collected" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "amount_collected" numeric NOT NULL, CONSTRAINT "PK_638be8eac1ed06396ae15065985" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_41ff7fbd84f0e932ddff4aaeda" ON "frrs_reward_collected" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_6f8728cf12eedec371ec2b5ac3" ON "frrs_reward_collected" ("address") `) + await db.query(`CREATE INDEX "IDX_fe9c300aa3739b7fedae19bee8" ON "frrs_reward_collected" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_748e8278aa0f4327fdb375ce39" ON "frrs_reward_collected" ("block_number") `) + await db.query(`CREATE TABLE "frrs_rewards_per_second_changed" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "new_rps" numeric NOT NULL, "old_rps" numeric NOT NULL, CONSTRAINT "PK_2673e74455a61c199ae6b457c9e" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_51112ae6ed7acfe5fea9041736" ON "frrs_rewards_per_second_changed" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_27777adfd6d67ce69177e76777" ON "frrs_rewards_per_second_changed" ("address") `) + await db.query(`CREATE INDEX "IDX_0f439534e934e9114e93fe0e0e" ON "frrs_rewards_per_second_changed" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_af32902afcc6d0e38d55b29e68" ON "frrs_rewards_per_second_changed" ("block_number") `) + await db.query(`CREATE TABLE "frrs_rewards_target_change" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "target" text NOT NULL, "previous_target" text NOT NULL, CONSTRAINT "PK_a55f976a8f537dff9d4ed24047f" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_a6f19822f0e09c509963463fbd" ON "frrs_rewards_target_change" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_598a7d310b076cf239ae7bcb51" ON "frrs_rewards_target_change" ("address") `) + await db.query(`CREATE INDEX "IDX_d593e4b975ae4f8d60303b2ba9" ON "frrs_rewards_target_change" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_9410930fcb952fb4003dc2b2be" ON "frrs_rewards_target_change" ("block_number") `) + await db.query(`CREATE TABLE "frrs_strategist_updated" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "strategist_address" text NOT NULL, CONSTRAINT "PK_c71ac16e8ede7acbd61b846676a" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_47dfa32c5be0528074dcf093d6" ON "frrs_strategist_updated" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_2f910a0f9c75adc401d7aa8c0f" ON "frrs_strategist_updated" ("address") `) + await db.query(`CREATE INDEX "IDX_301322e4df8e766e7f4cd892fd" ON "frrs_strategist_updated" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_7f49f2839212126c3d42fb4bf1" ON "frrs_strategist_updated" ("block_number") `) await db.query(`CREATE TABLE "processing_status" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, CONSTRAINT "PK_85f5e2467b74fb70fac1a053021" PRIMARY KEY ("id"))`) await db.query(`CREATE TABLE "exchange_rate" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "pair" text NOT NULL, "base" text NOT NULL, "quote" text NOT NULL, "rate" numeric NOT NULL, CONSTRAINT "PK_5c5d27d2b900ef6cdeef0398472" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_9e23a3f1bf3634820c873a0fe8" ON "exchange_rate" ("timestamp") `) @@ -291,6 +294,7 @@ module.exports = class Data1716332143675 { await db.query(`CREATE TABLE "ousd_daily_stat" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "apr" numeric NOT NULL, "apy" numeric NOT NULL, "apy7_day_avg" numeric NOT NULL, "apy14_day_avg" numeric NOT NULL, "apy30_day_avg" numeric NOT NULL, "total_supply" numeric NOT NULL, "total_supply_usd" numeric NOT NULL, "rebasing_supply" numeric NOT NULL, "non_rebasing_supply" numeric NOT NULL, "amo_supply" numeric NOT NULL, "dripper_weth" numeric NOT NULL, "wrapped_supply" numeric NOT NULL, "trading_volume_usd" numeric NOT NULL, "yield_eth" numeric NOT NULL, "yield_eth7_day" numeric NOT NULL, "yield_eth_all_time" numeric NOT NULL, "yield_usd" numeric NOT NULL, "yield_usd7_day" numeric NOT NULL, "yield_usd_all_time" numeric NOT NULL, "fees_eth" numeric NOT NULL, "fees_eth7_day" numeric NOT NULL, "fees_eth_all_time" numeric NOT NULL, "fees_usd" numeric NOT NULL, "fees_usd7_day" numeric NOT NULL, "fees_usd_all_time" numeric NOT NULL, "peg_price" numeric NOT NULL, "market_cap_usd" numeric NOT NULL, "holders_over_threshold" integer NOT NULL, CONSTRAINT "PK_f8adaf321a99f2b4b877c262880" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_f9020d89932aad2d0de8923490" ON "ousd_daily_stat" ("block_number") `) await db.query(`CREATE INDEX "IDX_0bb5f72bf5fa59ce8c232caa4c" ON "ousd_daily_stat" ("timestamp") `) + await db.query(`ALTER TABLE "es_account" ADD CONSTRAINT "FK_7b43e7bb90d3b435d074112f572" FOREIGN KEY ("delegate_to_id") REFERENCES "es_account"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) await db.query(`ALTER TABLE "governance_proposal_event" ADD CONSTRAINT "FK_ce984d23fc99c537b8f22fd663a" FOREIGN KEY ("proposal_id") REFERENCES "governance_proposal"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) await db.query(`ALTER TABLE "governance_proposal_vote" ADD CONSTRAINT "FK_5531af241c24a09c854ead9d551" FOREIGN KEY ("proposal_id") REFERENCES "governance_proposal"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) await db.query(`ALTER TABLE "oeth_strategy_holding_daily_stat" ADD CONSTRAINT "FK_4e867f220975e615e6077d860c1" FOREIGN KEY ("strategy_daily_stat_id_id") REFERENCES "oeth_strategy_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) @@ -312,76 +316,79 @@ module.exports = class Data1716332143675 { } async down(db) { - await db.query(`DROP TABLE "exponential_staking"`) - await db.query(`DROP INDEX "public"."IDX_9004da9adf2bb66b8cc9a9ddbd"`) - await db.query(`DROP INDEX "public"."IDX_bf1eab37b83a2261ba42a53b32"`) - await db.query(`DROP INDEX "public"."IDX_12fcf9c28429a1047732dd028b"`) - await db.query(`DROP INDEX "public"."IDX_ed1440d963237e211f39c26c43"`) - await db.query(`DROP TABLE "exponential_staking_lockup"`) - await db.query(`DROP INDEX "public"."IDX_d9e01c551c9f1a4d7710242ed8"`) - await db.query(`DROP INDEX "public"."IDX_9c8d024fea4fe0a45d95c801d5"`) - await db.query(`DROP INDEX "public"."IDX_c31d2fe385b684604bfa071229"`) - await db.query(`DROP INDEX "public"."IDX_9e8c0b852aeb43e4ca4a44fc70"`) - await db.query(`DROP TABLE "exponential_staking_account"`) - await db.query(`DROP INDEX "public"."IDX_e55574850608a204d5e3068b85"`) - await db.query(`DROP INDEX "public"."IDX_f2cf0e2b357e83e3c99c9076cd"`) - await db.query(`DROP INDEX "public"."IDX_aa85510db9e37072506a7c6c02"`) - await db.query(`DROP TABLE "exponential_staking_delegate_changed"`) - await db.query(`DROP INDEX "public"."IDX_9de723df03ba620afd586dbbf2"`) - await db.query(`DROP INDEX "public"."IDX_2c19bc13f9e9c65b521be853b0"`) - await db.query(`DROP INDEX "public"."IDX_83bb461676640a6666f4c34240"`) - await db.query(`DROP TABLE "exponential_staking_delegate_votes_changed"`) - await db.query(`DROP INDEX "public"."IDX_8bb7224130c6f200d3800d81ad"`) - await db.query(`DROP INDEX "public"."IDX_8a1b69ff53c4fdf5fbe4b1ef8a"`) - await db.query(`DROP INDEX "public"."IDX_c61dfffcf23d4988983ceb67e9"`) - await db.query(`DROP TABLE "exponential_staking_penalty"`) - await db.query(`DROP INDEX "public"."IDX_686c1e7635d16ed4974d4fba7e"`) - await db.query(`DROP INDEX "public"."IDX_e8d2ec04a0cabd68281ffbced0"`) - await db.query(`DROP INDEX "public"."IDX_8a204e6d28385b4971177fd73b"`) - await db.query(`DROP TABLE "exponential_staking_reward"`) - await db.query(`DROP INDEX "public"."IDX_c2503d0a7f3c5a4176b80b6ee6"`) - await db.query(`DROP INDEX "public"."IDX_af7a218b05626c5b6b3b6a4702"`) - await db.query(`DROP INDEX "public"."IDX_b252d19aa52a4683819bdd94b8"`) - await db.query(`DROP TABLE "exponential_staking_stake"`) - await db.query(`DROP INDEX "public"."IDX_c6b9bbec61e2fca250ce7d4a32"`) - await db.query(`DROP INDEX "public"."IDX_9e93319f4c9133472807912986"`) - await db.query(`DROP INDEX "public"."IDX_c38f73385b9aae63c9a8e4cd57"`) - await db.query(`DROP INDEX "public"."IDX_6aa54b83c2205337175f5a6e17"`) - await db.query(`DROP TABLE "exponential_staking_unstake"`) - await db.query(`DROP INDEX "public"."IDX_3a3fa2fd9ffdd64dca1d5ab3b8"`) - await db.query(`DROP INDEX "public"."IDX_7cd924c25b352e2288137ca23b"`) - await db.query(`DROP INDEX "public"."IDX_f2dff3c4211d5d57eaf627b6c8"`) - await db.query(`DROP INDEX "public"."IDX_5eba41d0c2d4d5ff4c5e5c0411"`) - await db.query(`DROP TABLE "governorship_transferred"`) - await db.query(`DROP INDEX "public"."IDX_9ab2b5486d85bd8aa36730fc02"`) - await db.query(`DROP INDEX "public"."IDX_554f6c0e2738e30856bdc4b725"`) - await db.query(`DROP INDEX "public"."IDX_d955cfa47fa1ff270a5578ba43"`) - await db.query(`DROP INDEX "public"."IDX_9d0eb3c05b7d0585f9d8d9eeb0"`) - await db.query(`DROP TABLE "pending_governorship_transfer"`) - await db.query(`DROP INDEX "public"."IDX_92e258fe6b6f9c65cdbe750c65"`) - await db.query(`DROP INDEX "public"."IDX_0fe23661b80871659e54dda998"`) - await db.query(`DROP INDEX "public"."IDX_d17c593674455b0554220cf1b0"`) - await db.query(`DROP INDEX "public"."IDX_2b89e9ec7edc194f9f0a914053"`) - await db.query(`DROP TABLE "reward_collected"`) - await db.query(`DROP INDEX "public"."IDX_0f6ab10957c09ebed8b2fc25c5"`) - await db.query(`DROP INDEX "public"."IDX_f6c2334f64b880139f96db37a5"`) - await db.query(`DROP INDEX "public"."IDX_fd3d30debdb9c5981471747b9b"`) - await db.query(`DROP INDEX "public"."IDX_0ea0eaa90ecddef5213a787419"`) - await db.query(`DROP TABLE "rewards_per_second_changed"`) - await db.query(`DROP INDEX "public"."IDX_b820e1afc853dffd1556e7b2a6"`) - await db.query(`DROP INDEX "public"."IDX_fdd9f60fc758695e25ae3ef6ca"`) - await db.query(`DROP INDEX "public"."IDX_487950908e327e4ccabd36820b"`) - await db.query(`DROP INDEX "public"."IDX_da9541b9abd658528a015df4cc"`) - await db.query(`DROP TABLE "rewards_target_change"`) - await db.query(`DROP INDEX "public"."IDX_57ca8bf4b751d1de10f44a08d6"`) - await db.query(`DROP INDEX "public"."IDX_de0fb0e64b2f2012da9e29d277"`) - await db.query(`DROP INDEX "public"."IDX_e21598b3cc8c9f85c4af20433c"`) - await db.query(`DROP INDEX "public"."IDX_6b94b5ef03dd72ed73f3209642"`) - await db.query(`DROP TABLE "strategist_updated"`) - await db.query(`DROP INDEX "public"."IDX_3ddb234b6c80ea1d59b2922fe4"`) - await db.query(`DROP INDEX "public"."IDX_103140942203924024fcb8fbbd"`) - await db.query(`DROP INDEX "public"."IDX_0d9424ca64d47f409467f3ccc5"`) - await db.query(`DROP INDEX "public"."IDX_3e6d818b5c76a45fdd1b7ff18c"`) + await db.query(`DROP TABLE "es_yield"`) + await db.query(`DROP INDEX "public"."IDX_aa3649a103464d797c959294d1"`) + await db.query(`DROP INDEX "public"."IDX_700ebb527927ee781c0750b0dc"`) + await db.query(`DROP INDEX "public"."IDX_e2d3a1ddc3f0886f51556442bb"`) + await db.query(`DROP INDEX "public"."IDX_4fdca11723165347776a9a7110"`) + await db.query(`DROP TABLE "es_lockup"`) + await db.query(`DROP INDEX "public"."IDX_15e9dc0d375d6f2687def01843"`) + await db.query(`DROP INDEX "public"."IDX_f3c10b1e75f626e1aaeaa3cfc3"`) + await db.query(`DROP INDEX "public"."IDX_5dd7ffdf1c625829f7eb79ee27"`) + await db.query(`DROP INDEX "public"."IDX_31b53c3e4649bde773d707b2a0"`) + await db.query(`DROP TABLE "es_account"`) + await db.query(`DROP INDEX "public"."IDX_eb97a0d869e67af870987d6d85"`) + await db.query(`DROP INDEX "public"."IDX_93fea1d847b38c9982626e5fd1"`) + await db.query(`DROP INDEX "public"."IDX_bc09480c9d1b13806f82337b5e"`) + await db.query(`DROP INDEX "public"."IDX_7b43e7bb90d3b435d074112f57"`) + await db.query(`DROP TABLE "es_delegate_changed"`) + await db.query(`DROP INDEX "public"."IDX_76c1740192ed8b589f7b5a21c8"`) + await db.query(`DROP INDEX "public"."IDX_ed5ea936cde8d62b485ce45a13"`) + await db.query(`DROP INDEX "public"."IDX_22f639893bc36efe524a3bbca7"`) + await db.query(`DROP INDEX "public"."IDX_ed12aa7ace584cc494012a0e5b"`) + await db.query(`DROP INDEX "public"."IDX_cda0b80789007b35cf5430966f"`) + await db.query(`DROP TABLE "es_delegate_votes_changed"`) + await db.query(`DROP INDEX "public"."IDX_4e20cdc38777932fadd008f6e4"`) + await db.query(`DROP INDEX "public"."IDX_076fb50935afa2f319f1d16752"`) + await db.query(`DROP INDEX "public"."IDX_338d2483a33dc74d360d2a44c5"`) + await db.query(`DROP INDEX "public"."IDX_e0e6b12e50b95fb9b99c28df90"`) + await db.query(`DROP INDEX "public"."IDX_bd6f657c57e5a92a8dd3fe6b4e"`) + await db.query(`DROP TABLE "es_penalty"`) + await db.query(`DROP INDEX "public"."IDX_59fa17e121ecd2bead0a71cf85"`) + await db.query(`DROP INDEX "public"."IDX_785a65f92c61edd176415e22ad"`) + await db.query(`DROP INDEX "public"."IDX_7402aa565f5e2023e310610240"`) + await db.query(`DROP INDEX "public"."IDX_8595139811169d26aa210f8a8d"`) + await db.query(`DROP INDEX "public"."IDX_adc7f2fe26e4a36690a343339b"`) + await db.query(`DROP TABLE "es_reward"`) + await db.query(`DROP INDEX "public"."IDX_e05d0476721dfcf9152b58fc30"`) + await db.query(`DROP INDEX "public"."IDX_f01dea25da96f8d8eaec9b6f60"`) + await db.query(`DROP INDEX "public"."IDX_2f3b61cc072d95ad0796b9caa3"`) + await db.query(`DROP INDEX "public"."IDX_a3d39d7235e278255a5217d1df"`) + await db.query(`DROP INDEX "public"."IDX_b623db55430fefda84dfdf2949"`) + await db.query(`DROP TABLE "es_stake"`) + await db.query(`DROP INDEX "public"."IDX_385357cc5f41796615d8880190"`) + await db.query(`DROP INDEX "public"."IDX_e7bcc8120e2c256db6ebd01575"`) + await db.query(`DROP INDEX "public"."IDX_b95e58860bb9ba46d0ec41d246"`) + await db.query(`DROP INDEX "public"."IDX_d059ea472eb9d10f6be2025d40"`) + await db.query(`DROP INDEX "public"."IDX_2d2f6b568b3145fe6095da5afa"`) + await db.query(`DROP INDEX "public"."IDX_bcb392795674b2cc0af394864c"`) + await db.query(`DROP TABLE "es_unstake"`) + await db.query(`DROP INDEX "public"."IDX_0c51c706a778668dbd5ed9c817"`) + await db.query(`DROP INDEX "public"."IDX_9301687673c195770cdd543049"`) + await db.query(`DROP INDEX "public"."IDX_13fbe169018991ddcfeb4912cb"`) + await db.query(`DROP INDEX "public"."IDX_06c024c53472178d0f5292330a"`) + await db.query(`DROP INDEX "public"."IDX_0adcdd08da131e76d618b73db7"`) + await db.query(`DROP INDEX "public"."IDX_cc43898a790e6e1d4bbf145097"`) + await db.query(`DROP TABLE "frrs_reward_collected"`) + await db.query(`DROP INDEX "public"."IDX_41ff7fbd84f0e932ddff4aaeda"`) + await db.query(`DROP INDEX "public"."IDX_6f8728cf12eedec371ec2b5ac3"`) + await db.query(`DROP INDEX "public"."IDX_fe9c300aa3739b7fedae19bee8"`) + await db.query(`DROP INDEX "public"."IDX_748e8278aa0f4327fdb375ce39"`) + await db.query(`DROP TABLE "frrs_rewards_per_second_changed"`) + await db.query(`DROP INDEX "public"."IDX_51112ae6ed7acfe5fea9041736"`) + await db.query(`DROP INDEX "public"."IDX_27777adfd6d67ce69177e76777"`) + await db.query(`DROP INDEX "public"."IDX_0f439534e934e9114e93fe0e0e"`) + await db.query(`DROP INDEX "public"."IDX_af32902afcc6d0e38d55b29e68"`) + await db.query(`DROP TABLE "frrs_rewards_target_change"`) + await db.query(`DROP INDEX "public"."IDX_a6f19822f0e09c509963463fbd"`) + await db.query(`DROP INDEX "public"."IDX_598a7d310b076cf239ae7bcb51"`) + await db.query(`DROP INDEX "public"."IDX_d593e4b975ae4f8d60303b2ba9"`) + await db.query(`DROP INDEX "public"."IDX_9410930fcb952fb4003dc2b2be"`) + await db.query(`DROP TABLE "frrs_strategist_updated"`) + await db.query(`DROP INDEX "public"."IDX_47dfa32c5be0528074dcf093d6"`) + await db.query(`DROP INDEX "public"."IDX_2f910a0f9c75adc401d7aa8c0f"`) + await db.query(`DROP INDEX "public"."IDX_301322e4df8e766e7f4cd892fd"`) + await db.query(`DROP INDEX "public"."IDX_7f49f2839212126c3d42fb4bf1"`) await db.query(`DROP TABLE "processing_status"`) await db.query(`DROP TABLE "exchange_rate"`) await db.query(`DROP INDEX "public"."IDX_9e23a3f1bf3634820c873a0fe8"`) @@ -601,6 +608,7 @@ module.exports = class Data1716332143675 { await db.query(`DROP TABLE "ousd_daily_stat"`) await db.query(`DROP INDEX "public"."IDX_f9020d89932aad2d0de8923490"`) await db.query(`DROP INDEX "public"."IDX_0bb5f72bf5fa59ce8c232caa4c"`) + await db.query(`ALTER TABLE "es_account" DROP CONSTRAINT "FK_7b43e7bb90d3b435d074112f572"`) await db.query(`ALTER TABLE "governance_proposal_event" DROP CONSTRAINT "FK_ce984d23fc99c537b8f22fd663a"`) await db.query(`ALTER TABLE "governance_proposal_vote" DROP CONSTRAINT "FK_5531af241c24a09c854ead9d551"`) await db.query(`ALTER TABLE "oeth_strategy_holding_daily_stat" DROP CONSTRAINT "FK_4e867f220975e615e6077d860c1"`) diff --git a/schema.graphql b/schema.graphql index e0e6bf73..5e938f1a 100644 --- a/schema.graphql +++ b/schema.graphql @@ -5,22 +5,24 @@ # - Lockups # - Accounts -type ExponentialStaking @entity { +type ESYield @entity { id: ID! chainId: Int! @index address: String! @index timestamp: DateTime! @index blockNumber: Int! @index - accRewardPerShare: BigInt! assetBalance: BigInt! + rewardsPerSecond: BigInt! + apr: Float! + apy: Float! } -enum ExponentialStakingLockupState { +enum ESLockupState { Open Closed } -type ExponentialStakingLockup @entity { +type ESLockup @entity { id: ID! # `chainId:address:account:lockupId` or `lockupId` chainId: Int! @index address: String! @index @@ -33,62 +35,68 @@ type ExponentialStakingLockup @entity { points: BigInt! withdrawAmount: BigInt! penalty: BigInt! - state: ExponentialStakingLockupState + state: ESLockupState } -type ExponentialStakingAccount @entity { +type ESAccount @entity { id: ID! # `chainId:address:account` chainId: Int! @index address: String! @index account: String! @index - votes: BigInt! - balance: BigInt! - previewPoints: BigInt! - previewRewards: BigInt! - previewWithdraw: BigInt! + voteBalance: BigInt! + delegateTo: ESAccount + delegatesFrom: [ESAccount]! @derivedFrom(field: "delegateTo") } - - # Events -type ExponentialStakingDelegateChanged @entity { +type ESDelegateChanged @entity { id: ID! # `chainId:logId` chainId: Int! @index address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index delegator: String! @index fromDelegate: String! toDelegate: String! } -type ExponentialStakingDelegateVotesChanged @entity { +type ESDelegateVotesChanged @entity { id: ID! # `chainId:logId` chainId: Int! @index address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index delegate: String! @index previousBalance: BigInt! newBalance: BigInt! } -type ExponentialStakingPenalty @entity { +type ESPenalty @entity { id: ID! # `chainId:logId` chainId: Int! @index address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index account: String! @index amount: BigInt! } -type ExponentialStakingReward @entity { +type ESReward @entity { id: ID! # `chainId:logId` chainId: Int! @index address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index account: String! @index amount: BigInt! } -type ExponentialStakingStake @entity { +type ESStake @entity { id: ID! # `chainId:logId` chainId: Int! @index address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index account: String! @index lockupId: BigInt! @index amount: BigInt! @@ -96,35 +104,19 @@ type ExponentialStakingStake @entity { points: BigInt! } -type ExponentialStakingUnstake @entity { +type ESUnstake @entity { id: ID! # `chainId:logId` chainId: Int! @index address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index account: String! @index lockupId: BigInt! @index amount: BigInt! end: BigInt! points: BigInt! } -type GovernorshipTransferred @entity { - id: ID! - chainId: Int! @index - address: String! @index - timestamp: DateTime! @index - blockNumber: Int! @index - previousGovernor: String! - newGovernor: String! -} -type PendingGovernorshipTransfer @entity { - id: ID! - chainId: Int! @index - address: String! @index - timestamp: DateTime! @index - blockNumber: Int! @index - previousGovernor: String! - newGovernor: String! -} -type RewardCollected @entity { +type FRRSRewardCollected @entity { id: ID! chainId: Int! @index address: String! @index @@ -132,7 +124,7 @@ type RewardCollected @entity { blockNumber: Int! @index amountCollected: BigInt! } -type RewardsPerSecondChanged @entity { +type FRRSRewardsPerSecondChanged @entity { id: ID! chainId: Int! @index address: String! @index @@ -141,7 +133,7 @@ type RewardsPerSecondChanged @entity { newRPS: BigInt! oldRPS: BigInt! } -type RewardsTargetChange @entity { +type FRRSRewardsTargetChange @entity { id: ID! chainId: Int! @index address: String! @index @@ -150,7 +142,7 @@ type RewardsTargetChange @entity { target: String! previousTarget: String! } -type StrategistUpdated @entity { +type FRRSStrategistUpdated @entity { id: ID! chainId: Int! @index address: String! @index diff --git a/schema/exponential-staking.graphql b/schema/exponential-staking.graphql index 149fd443..381330a9 100644 --- a/schema/exponential-staking.graphql +++ b/schema/exponential-staking.graphql @@ -3,22 +3,24 @@ # - Lockups # - Accounts -type ExponentialStaking @entity { +type ESYield @entity { id: ID! chainId: Int! @index address: String! @index timestamp: DateTime! @index blockNumber: Int! @index - accRewardPerShare: BigInt! assetBalance: BigInt! + rewardsPerSecond: BigInt! + apr: Float! + apy: Float! } -enum ExponentialStakingLockupState { +enum ESLockupState { Open Closed } -type ExponentialStakingLockup @entity { +type ESLockup @entity { id: ID! # `chainId:address:account:lockupId` or `lockupId` chainId: Int! @index address: String! @index @@ -31,62 +33,68 @@ type ExponentialStakingLockup @entity { points: BigInt! withdrawAmount: BigInt! penalty: BigInt! - state: ExponentialStakingLockupState + state: ESLockupState } -type ExponentialStakingAccount @entity { +type ESAccount @entity { id: ID! # `chainId:address:account` chainId: Int! @index address: String! @index account: String! @index - votes: BigInt! - balance: BigInt! - previewPoints: BigInt! - previewRewards: BigInt! - previewWithdraw: BigInt! + voteBalance: BigInt! + delegateTo: ESAccount + delegatesFrom: [ESAccount]! @derivedFrom(field: "delegateTo") } - - # Events -type ExponentialStakingDelegateChanged @entity { +type ESDelegateChanged @entity { id: ID! # `chainId:logId` chainId: Int! @index address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index delegator: String! @index fromDelegate: String! toDelegate: String! } -type ExponentialStakingDelegateVotesChanged @entity { +type ESDelegateVotesChanged @entity { id: ID! # `chainId:logId` chainId: Int! @index address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index delegate: String! @index previousBalance: BigInt! newBalance: BigInt! } -type ExponentialStakingPenalty @entity { +type ESPenalty @entity { id: ID! # `chainId:logId` chainId: Int! @index address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index account: String! @index amount: BigInt! } -type ExponentialStakingReward @entity { +type ESReward @entity { id: ID! # `chainId:logId` chainId: Int! @index address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index account: String! @index amount: BigInt! } -type ExponentialStakingStake @entity { +type ESStake @entity { id: ID! # `chainId:logId` chainId: Int! @index address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index account: String! @index lockupId: BigInt! @index amount: BigInt! @@ -94,10 +102,12 @@ type ExponentialStakingStake @entity { points: BigInt! } -type ExponentialStakingUnstake @entity { +type ESUnstake @entity { id: ID! # `chainId:logId` chainId: Int! @index address: String! @index + timestamp: DateTime! @index + blockNumber: Int! @index account: String! @index lockupId: BigInt! @index amount: BigInt! diff --git a/schema/fixed-rate-rewards-source.graphql b/schema/fixed-rate-rewards-source.graphql index 58ce9bbf..63b59cdb 100644 --- a/schema/fixed-rate-rewards-source.graphql +++ b/schema/fixed-rate-rewards-source.graphql @@ -1,22 +1,4 @@ -type GovernorshipTransferred @entity { - id: ID! - chainId: Int! @index - address: String! @index - timestamp: DateTime! @index - blockNumber: Int! @index - previousGovernor: String! - newGovernor: String! -} -type PendingGovernorshipTransfer @entity { - id: ID! - chainId: Int! @index - address: String! @index - timestamp: DateTime! @index - blockNumber: Int! @index - previousGovernor: String! - newGovernor: String! -} -type RewardCollected @entity { +type FRRSRewardCollected @entity { id: ID! chainId: Int! @index address: String! @index @@ -24,7 +6,7 @@ type RewardCollected @entity { blockNumber: Int! @index amountCollected: BigInt! } -type RewardsPerSecondChanged @entity { +type FRRSRewardsPerSecondChanged @entity { id: ID! chainId: Int! @index address: String! @index @@ -33,7 +15,7 @@ type RewardsPerSecondChanged @entity { newRPS: BigInt! oldRPS: BigInt! } -type RewardsTargetChange @entity { +type FRRSRewardsTargetChange @entity { id: ID! chainId: Int! @index address: String! @index @@ -42,7 +24,7 @@ type RewardsTargetChange @entity { target: String! previousTarget: String! } -type StrategistUpdated @entity { +type FRRSStrategistUpdated @entity { id: ID! chainId: Int! @index address: String! @index diff --git a/src/main-mainnet.ts b/src/main-mainnet.ts index 37ac74fb..f57350ca 100644 --- a/src/main-mainnet.ts +++ b/src/main-mainnet.ts @@ -2,11 +2,18 @@ import 'tsconfig-paths/register' import { run } from '@processor' import * as exchangeRates from '@shared/post-processors/exchange-rates' -import { createExponentialStakingTracker } from '@templates/exponential-staking' -import { createFixedRewardsSourceProcessor } from '@templates/fixed-rate-rewards-source' +import { createESTracker } from '@templates/exponential-staking' +import { createFRRSProcessor } from '@templates/fixed-rate-rewards-source' import { createGovernanceProcessor } from '@templates/governance' import { processStatus } from '@templates/processor-status' -import { GOVERNANCE_ADDRESS, OGN_REWARDS_SOURCE_ADDRESS, VEOGV_ADDRESS, XOGN_ADDRESS } from '@utils/addresses' +import { + GOVERNANCE_ADDRESS, + OGN_ADDRESS, + OGN_REWARDS_SOURCE_ADDRESS, + OGV_ADDRESS, + VEOGV_ADDRESS, + XOGN_ADDRESS, +} from '@utils/addresses' import * as curve from './mainnet/processors/curve' import { erc20s } from './mainnet/processors/erc20s' @@ -18,9 +25,21 @@ export const processor = { curve, ...erc20s(), createGovernanceProcessor({ from: 15491391, address: GOVERNANCE_ADDRESS }), - createExponentialStakingTracker({ from: 15089597, address: VEOGV_ADDRESS }), - createExponentialStakingTracker({ from: 19919745, address: XOGN_ADDRESS }), - createFixedRewardsSourceProcessor({ from: 19917521, address: OGN_REWARDS_SOURCE_ADDRESS }), + createESTracker({ + from: 15089597, + address: VEOGV_ADDRESS, + assetAddress: OGV_ADDRESS, + rewardsAddress: '0x7d82e86cf1496f9485a8ea04012afeb3c7489397', + yieldType: undefined, // We won't calculate for this. + }), + createESTracker({ + from: 19919745, + address: XOGN_ADDRESS, + assetAddress: OGN_ADDRESS, + rewardsAddress: '0x7609c88e5880e934dd3a75bcfef44e31b1badb8b', + yieldType: 'fixed', + }), + createFRRSProcessor({ from: 19917521, address: OGN_REWARDS_SOURCE_ADDRESS }), ], postProcessors: [exchangeRates, processStatus('mainnet')], validators: [validate], diff --git a/src/model/generated/_exponentialStakingLockupState.ts b/src/model/generated/_esLockupState.ts similarity index 50% rename from src/model/generated/_exponentialStakingLockupState.ts rename to src/model/generated/_esLockupState.ts index 10304f1c..3f3003c9 100644 --- a/src/model/generated/_exponentialStakingLockupState.ts +++ b/src/model/generated/_esLockupState.ts @@ -1,4 +1,4 @@ -export enum ExponentialStakingLockupState { +export enum ESLockupState { Open = "Open", Closed = "Closed", } diff --git a/src/model/generated/exponentialStakingPenalty.model.ts b/src/model/generated/esAccount.model.ts similarity index 52% rename from src/model/generated/exponentialStakingPenalty.model.ts rename to src/model/generated/esAccount.model.ts index 9c5a9cc6..6dac75b5 100644 --- a/src/model/generated/exponentialStakingPenalty.model.ts +++ b/src/model/generated/esAccount.model.ts @@ -1,8 +1,8 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_, ManyToOne as ManyToOne_, OneToMany as OneToMany_} from "@subsquid/typeorm-store" @Entity_() -export class ExponentialStakingPenalty { - constructor(props?: Partial) { +export class ESAccount { + constructor(props?: Partial) { Object.assign(this, props) } @@ -22,5 +22,12 @@ export class ExponentialStakingPenalty { account!: string @BigIntColumn_({nullable: false}) - amount!: bigint + voteBalance!: bigint + + @Index_() + @ManyToOne_(() => ESAccount, {nullable: true}) + delegateTo!: ESAccount | undefined | null + + @OneToMany_(() => ESAccount, e => e.delegateTo) + delegatesFrom!: ESAccount[] } diff --git a/src/model/generated/governorshipTransferred.model.ts b/src/model/generated/esDelegateChanged.model.ts similarity index 76% rename from src/model/generated/governorshipTransferred.model.ts rename to src/model/generated/esDelegateChanged.model.ts index 232d9870..aa040cf0 100644 --- a/src/model/generated/governorshipTransferred.model.ts +++ b/src/model/generated/esDelegateChanged.model.ts @@ -1,8 +1,8 @@ import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_} from "@subsquid/typeorm-store" @Entity_() -export class GovernorshipTransferred { - constructor(props?: Partial) { +export class ESDelegateChanged { + constructor(props?: Partial) { Object.assign(this, props) } @@ -25,9 +25,13 @@ export class GovernorshipTransferred { @IntColumn_({nullable: false}) blockNumber!: number + @Index_() + @StringColumn_({nullable: false}) + delegator!: string + @StringColumn_({nullable: false}) - previousGovernor!: string + fromDelegate!: string @StringColumn_({nullable: false}) - newGovernor!: string + toDelegate!: string } diff --git a/src/model/generated/exponentialStakingDelegateVotesChanged.model.ts b/src/model/generated/esDelegateVotesChanged.model.ts similarity index 60% rename from src/model/generated/exponentialStakingDelegateVotesChanged.model.ts rename to src/model/generated/esDelegateVotesChanged.model.ts index af8905ab..516848d2 100644 --- a/src/model/generated/exponentialStakingDelegateVotesChanged.model.ts +++ b/src/model/generated/esDelegateVotesChanged.model.ts @@ -1,8 +1,8 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() -export class ExponentialStakingDelegateVotesChanged { - constructor(props?: Partial) { +export class ESDelegateVotesChanged { + constructor(props?: Partial) { Object.assign(this, props) } @@ -17,6 +17,14 @@ export class ExponentialStakingDelegateVotesChanged { @StringColumn_({nullable: false}) address!: string + @Index_() + @DateTimeColumn_({nullable: false}) + timestamp!: Date + + @Index_() + @IntColumn_({nullable: false}) + blockNumber!: number + @Index_() @StringColumn_({nullable: false}) delegate!: string diff --git a/src/model/generated/exponentialStakingLockup.model.ts b/src/model/generated/esLockup.model.ts similarity index 82% rename from src/model/generated/exponentialStakingLockup.model.ts rename to src/model/generated/esLockup.model.ts index 74281603..5778fbbe 100644 --- a/src/model/generated/exponentialStakingLockup.model.ts +++ b/src/model/generated/esLockup.model.ts @@ -1,9 +1,9 @@ import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_, DateTimeColumn as DateTimeColumn_} from "@subsquid/typeorm-store" -import {ExponentialStakingLockupState} from "./_exponentialStakingLockupState" +import {ESLockupState} from "./_esLockupState" @Entity_() -export class ExponentialStakingLockup { - constructor(props?: Partial) { +export class ESLockup { + constructor(props?: Partial) { Object.assign(this, props) } @@ -48,5 +48,5 @@ export class ExponentialStakingLockup { penalty!: bigint @Column_("varchar", {length: 6, nullable: true}) - state!: ExponentialStakingLockupState | undefined | null + state!: ESLockupState | undefined | null } diff --git a/src/model/generated/exponentialStaking.model.ts b/src/model/generated/esPenalty.model.ts similarity index 78% rename from src/model/generated/exponentialStaking.model.ts rename to src/model/generated/esPenalty.model.ts index 635fee25..de58c13a 100644 --- a/src/model/generated/exponentialStaking.model.ts +++ b/src/model/generated/esPenalty.model.ts @@ -1,8 +1,8 @@ import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() -export class ExponentialStaking { - constructor(props?: Partial) { +export class ESPenalty { + constructor(props?: Partial) { Object.assign(this, props) } @@ -25,9 +25,10 @@ export class ExponentialStaking { @IntColumn_({nullable: false}) blockNumber!: number - @BigIntColumn_({nullable: false}) - accRewardPerShare!: bigint + @Index_() + @StringColumn_({nullable: false}) + account!: string @BigIntColumn_({nullable: false}) - assetBalance!: bigint + amount!: bigint } diff --git a/src/model/generated/esReward.model.ts b/src/model/generated/esReward.model.ts new file mode 100644 index 00000000..ba76f672 --- /dev/null +++ b/src/model/generated/esReward.model.ts @@ -0,0 +1,34 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" + +@Entity_() +export class ESReward { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @IntColumn_({nullable: false}) + chainId!: number + + @Index_() + @StringColumn_({nullable: false}) + address!: string + + @Index_() + @DateTimeColumn_({nullable: false}) + timestamp!: Date + + @Index_() + @IntColumn_({nullable: false}) + blockNumber!: number + + @Index_() + @StringColumn_({nullable: false}) + account!: string + + @BigIntColumn_({nullable: false}) + amount!: bigint +} diff --git a/src/model/generated/exponentialStakingUnstake.model.ts b/src/model/generated/esStake.model.ts similarity index 67% rename from src/model/generated/exponentialStakingUnstake.model.ts rename to src/model/generated/esStake.model.ts index bb0cade1..47f58ebc 100644 --- a/src/model/generated/exponentialStakingUnstake.model.ts +++ b/src/model/generated/esStake.model.ts @@ -1,8 +1,8 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() -export class ExponentialStakingUnstake { - constructor(props?: Partial) { +export class ESStake { + constructor(props?: Partial) { Object.assign(this, props) } @@ -17,6 +17,14 @@ export class ExponentialStakingUnstake { @StringColumn_({nullable: false}) address!: string + @Index_() + @DateTimeColumn_({nullable: false}) + timestamp!: Date + + @Index_() + @IntColumn_({nullable: false}) + blockNumber!: number + @Index_() @StringColumn_({nullable: false}) account!: string diff --git a/src/model/generated/exponentialStakingStake.model.ts b/src/model/generated/esUnstake.model.ts similarity index 66% rename from src/model/generated/exponentialStakingStake.model.ts rename to src/model/generated/esUnstake.model.ts index 432e5081..97a2acc0 100644 --- a/src/model/generated/exponentialStakingStake.model.ts +++ b/src/model/generated/esUnstake.model.ts @@ -1,8 +1,8 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() -export class ExponentialStakingStake { - constructor(props?: Partial) { +export class ESUnstake { + constructor(props?: Partial) { Object.assign(this, props) } @@ -17,6 +17,14 @@ export class ExponentialStakingStake { @StringColumn_({nullable: false}) address!: string + @Index_() + @DateTimeColumn_({nullable: false}) + timestamp!: Date + + @Index_() + @IntColumn_({nullable: false}) + blockNumber!: number + @Index_() @StringColumn_({nullable: false}) account!: string diff --git a/src/model/generated/esYield.model.ts b/src/model/generated/esYield.model.ts new file mode 100644 index 00000000..e19b84bd --- /dev/null +++ b/src/model/generated/esYield.model.ts @@ -0,0 +1,39 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_, FloatColumn as FloatColumn_} from "@subsquid/typeorm-store" + +@Entity_() +export class ESYield { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @IntColumn_({nullable: false}) + chainId!: number + + @Index_() + @StringColumn_({nullable: false}) + address!: string + + @Index_() + @DateTimeColumn_({nullable: false}) + timestamp!: Date + + @Index_() + @IntColumn_({nullable: false}) + blockNumber!: number + + @BigIntColumn_({nullable: false}) + assetBalance!: bigint + + @BigIntColumn_({nullable: false}) + rewardsPerSecond!: bigint + + @FloatColumn_({nullable: false}) + apr!: number + + @FloatColumn_({nullable: false}) + apy!: number +} diff --git a/src/model/generated/exponentialStakingAccount.model.ts b/src/model/generated/exponentialStakingAccount.model.ts deleted file mode 100644 index a06fed42..00000000 --- a/src/model/generated/exponentialStakingAccount.model.ts +++ /dev/null @@ -1,38 +0,0 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" - -@Entity_() -export class ExponentialStakingAccount { - constructor(props?: Partial) { - Object.assign(this, props) - } - - @PrimaryColumn_() - id!: string - - @Index_() - @IntColumn_({nullable: false}) - chainId!: number - - @Index_() - @StringColumn_({nullable: false}) - address!: string - - @Index_() - @StringColumn_({nullable: false}) - account!: string - - @BigIntColumn_({nullable: false}) - votes!: bigint - - @BigIntColumn_({nullable: false}) - balance!: bigint - - @BigIntColumn_({nullable: false}) - previewPoints!: bigint - - @BigIntColumn_({nullable: false}) - previewRewards!: bigint - - @BigIntColumn_({nullable: false}) - previewWithdraw!: bigint -} diff --git a/src/model/generated/exponentialStakingDelegateChanged.model.ts b/src/model/generated/exponentialStakingDelegateChanged.model.ts deleted file mode 100644 index a29788f6..00000000 --- a/src/model/generated/exponentialStakingDelegateChanged.model.ts +++ /dev/null @@ -1,29 +0,0 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_} from "@subsquid/typeorm-store" - -@Entity_() -export class ExponentialStakingDelegateChanged { - constructor(props?: Partial) { - Object.assign(this, props) - } - - @PrimaryColumn_() - id!: string - - @Index_() - @IntColumn_({nullable: false}) - chainId!: number - - @Index_() - @StringColumn_({nullable: false}) - address!: string - - @Index_() - @StringColumn_({nullable: false}) - delegator!: string - - @StringColumn_({nullable: false}) - fromDelegate!: string - - @StringColumn_({nullable: false}) - toDelegate!: string -} diff --git a/src/model/generated/exponentialStakingReward.model.ts b/src/model/generated/exponentialStakingReward.model.ts deleted file mode 100644 index 2fb86c59..00000000 --- a/src/model/generated/exponentialStakingReward.model.ts +++ /dev/null @@ -1,26 +0,0 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" - -@Entity_() -export class ExponentialStakingReward { - constructor(props?: Partial) { - Object.assign(this, props) - } - - @PrimaryColumn_() - id!: string - - @Index_() - @IntColumn_({nullable: false}) - chainId!: number - - @Index_() - @StringColumn_({nullable: false}) - address!: string - - @Index_() - @StringColumn_({nullable: false}) - account!: string - - @BigIntColumn_({nullable: false}) - amount!: bigint -} diff --git a/src/model/generated/rewardCollected.model.ts b/src/model/generated/frrsRewardCollected.model.ts similarity index 88% rename from src/model/generated/rewardCollected.model.ts rename to src/model/generated/frrsRewardCollected.model.ts index 63a74d96..5ca21871 100644 --- a/src/model/generated/rewardCollected.model.ts +++ b/src/model/generated/frrsRewardCollected.model.ts @@ -1,8 +1,8 @@ import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() -export class RewardCollected { - constructor(props?: Partial) { +export class FRRSRewardCollected { + constructor(props?: Partial) { Object.assign(this, props) } diff --git a/src/model/generated/rewardsPerSecondChanged.model.ts b/src/model/generated/frrsRewardsPerSecondChanged.model.ts similarity index 87% rename from src/model/generated/rewardsPerSecondChanged.model.ts rename to src/model/generated/frrsRewardsPerSecondChanged.model.ts index 76db06a4..c8dffcfc 100644 --- a/src/model/generated/rewardsPerSecondChanged.model.ts +++ b/src/model/generated/frrsRewardsPerSecondChanged.model.ts @@ -1,8 +1,8 @@ import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" @Entity_() -export class RewardsPerSecondChanged { - constructor(props?: Partial) { +export class FRRSRewardsPerSecondChanged { + constructor(props?: Partial) { Object.assign(this, props) } diff --git a/src/model/generated/rewardsTargetChange.model.ts b/src/model/generated/frrsRewardsTargetChange.model.ts similarity index 88% rename from src/model/generated/rewardsTargetChange.model.ts rename to src/model/generated/frrsRewardsTargetChange.model.ts index 336567b2..9950b4a3 100644 --- a/src/model/generated/rewardsTargetChange.model.ts +++ b/src/model/generated/frrsRewardsTargetChange.model.ts @@ -1,8 +1,8 @@ import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_} from "@subsquid/typeorm-store" @Entity_() -export class RewardsTargetChange { - constructor(props?: Partial) { +export class FRRSRewardsTargetChange { + constructor(props?: Partial) { Object.assign(this, props) } diff --git a/src/model/generated/strategistUpdated.model.ts b/src/model/generated/frrsStrategistUpdated.model.ts similarity index 87% rename from src/model/generated/strategistUpdated.model.ts rename to src/model/generated/frrsStrategistUpdated.model.ts index daef5211..2cc2933d 100644 --- a/src/model/generated/strategistUpdated.model.ts +++ b/src/model/generated/frrsStrategistUpdated.model.ts @@ -1,8 +1,8 @@ import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_} from "@subsquid/typeorm-store" @Entity_() -export class StrategistUpdated { - constructor(props?: Partial) { +export class FRRSStrategistUpdated { + constructor(props?: Partial) { Object.assign(this, props) } diff --git a/src/model/generated/index.ts b/src/model/generated/index.ts index b94c0e4a..82a71be8 100644 --- a/src/model/generated/index.ts +++ b/src/model/generated/index.ts @@ -1,19 +1,17 @@ -export * from "./exponentialStaking.model" -export * from "./exponentialStakingLockup.model" -export * from "./_exponentialStakingLockupState" -export * from "./exponentialStakingAccount.model" -export * from "./exponentialStakingDelegateChanged.model" -export * from "./exponentialStakingDelegateVotesChanged.model" -export * from "./exponentialStakingPenalty.model" -export * from "./exponentialStakingReward.model" -export * from "./exponentialStakingStake.model" -export * from "./exponentialStakingUnstake.model" -export * from "./governorshipTransferred.model" -export * from "./pendingGovernorshipTransfer.model" -export * from "./rewardCollected.model" -export * from "./rewardsPerSecondChanged.model" -export * from "./rewardsTargetChange.model" -export * from "./strategistUpdated.model" +export * from "./esYield.model" +export * from "./esLockup.model" +export * from "./_esLockupState" +export * from "./esAccount.model" +export * from "./esDelegateChanged.model" +export * from "./esDelegateVotesChanged.model" +export * from "./esPenalty.model" +export * from "./esReward.model" +export * from "./esStake.model" +export * from "./esUnstake.model" +export * from "./frrsRewardCollected.model" +export * from "./frrsRewardsPerSecondChanged.model" +export * from "./frrsRewardsTargetChange.model" +export * from "./frrsStrategistUpdated.model" export * from "./processingStatus.model" export * from "./exchangeRate.model" export * from "./strategyBalance.model" diff --git a/src/model/generated/pendingGovernorshipTransfer.model.ts b/src/model/generated/pendingGovernorshipTransfer.model.ts deleted file mode 100644 index a3d7d387..00000000 --- a/src/model/generated/pendingGovernorshipTransfer.model.ts +++ /dev/null @@ -1,33 +0,0 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_} from "@subsquid/typeorm-store" - -@Entity_() -export class PendingGovernorshipTransfer { - constructor(props?: Partial) { - Object.assign(this, props) - } - - @PrimaryColumn_() - id!: string - - @Index_() - @IntColumn_({nullable: false}) - chainId!: number - - @Index_() - @StringColumn_({nullable: false}) - address!: string - - @Index_() - @DateTimeColumn_({nullable: false}) - timestamp!: Date - - @Index_() - @IntColumn_({nullable: false}) - blockNumber!: number - - @StringColumn_({nullable: false}) - previousGovernor!: string - - @StringColumn_({nullable: false}) - newGovernor!: string -} diff --git a/src/templates/exponential-staking/exponential-staking.ts b/src/templates/exponential-staking/exponential-staking.ts index 97d649cd..7e3cc2f5 100644 --- a/src/templates/exponential-staking/exponential-staking.ts +++ b/src/templates/exponential-staking/exponential-staking.ts @@ -1,33 +1,77 @@ +import dayjs from 'dayjs' + import * as abi from '@abi/exponential-staking' +import * as fixedRewardsAbi from '@abi/fixed-rate-rewards-source' import { - ExponentialStakingDelegateChanged, - ExponentialStakingDelegateVotesChanged, - ExponentialStakingLockup, - ExponentialStakingLockupState, - ExponentialStakingPenalty, - ExponentialStakingReward, - ExponentialStakingStake, - ExponentialStakingUnstake, + ESAccount, + ESDelegateChanged, + ESDelegateVotesChanged, + ESLockup, + ESLockupState, + ESPenalty, + ESReward, + ESStake, + ESUnstake, + ESYield, + FRRSRewardsPerSecondChanged, } from '@model' import { Block, Context, Log } from '@processor' import { EvmBatchProcessor } from '@subsquid/evm-processor' import { TokenAddress } from '@utils/addresses' +import { calculateAPY } from '@utils/calculateAPY' import { LogFilter, logFilter } from '@utils/logFilter' interface State { // State Entities - lockup: Map + account: Map + lockup: Map + yield: Map // Event Entities - delegateChanged: Map - delegateVotesChanged: Map - penalty: Map - reward: Map - stake: Map - unstake: Map + delegateChanged: Map + delegateVotesChanged: Map + penalty: Map + reward: Map + stake: Map + unstake: Map + + // Local State Tracking + rewardsPerSecond: bigint[] } -export const createExponentialStakingTracker = ({ from, address }: { from: number; address: TokenAddress }) => { +/** + * Create an ExponentialStaking contract tracker. + */ +export const createESTracker = ({ + from, + address, + assetAddress, + rewardsAddress, + yieldType, +}: { + from: number + address: TokenAddress + assetAddress: TokenAddress + rewardsAddress: string + yieldType: 'fixed' | undefined +}) => { + const assetTransferFromFilter = logFilter({ + address: [assetAddress], + topic0: [abi.events.Transfer.topic], + topic1: [address], + range: { from }, + }) + const assetTransferToFilter = logFilter({ + address: [assetAddress], + topic0: [abi.events.Transfer.topic], + topic2: [address], + range: { from }, + }) + const fixedRewardsChangeFilter = logFilter({ + address: [rewardsAddress], + topic0: [fixedRewardsAbi.events.RewardsPerSecondChanged.topic], + range: { from }, + }) const delegateChangedFilter = logFilter({ address: [address], topic0: [abi.events.DelegateChanged.topic], @@ -55,21 +99,23 @@ export const createExponentialStakingTracker = ({ from, address }: { from: numbe }) const subProcessors: { description: string - filter: LogFilter - processor: (ctx: Context, block: Block, log: Log, state: State) => Promise + filter: LogFilter | LogFilter[] + processor: (params: { ctx: Context; block: Block; log: Log; state: State }) => Promise }[] = [ // Event Entity Processors { description: 'Create DelegateChanged event', filter: delegateChangedFilter, - processor: async (ctx, block, log, state) => { + processor: async ({ ctx, block, log, state }) => { const chainId = ctx.chain.id const data = abi.events.DelegateChanged.decode(log) const id = `${chainId}:${log.id}` - const entity = new ExponentialStakingDelegateChanged({ + const entity = new ESDelegateChanged({ id, chainId, address, + timestamp: new Date(block.header.timestamp), + blockNumber: block.header.height, delegator: data.delegator, fromDelegate: data.fromDelegate, toDelegate: data.toDelegate, @@ -80,14 +126,16 @@ export const createExponentialStakingTracker = ({ from, address }: { from: numbe { description: 'Create DelegateVotesChanged event', filter: delegateVotesChangedFilter, - processor: async (ctx, block, log, state) => { + processor: async ({ ctx, block, log, state }) => { const chainId = ctx.chain.id const data = abi.events.DelegateVotesChanged.decode(log) const id = `${chainId}:${log.id}` - const entity = new ExponentialStakingDelegateVotesChanged({ + const entity = new ESDelegateVotesChanged({ id, chainId, address, + timestamp: new Date(block.header.timestamp), + blockNumber: block.header.height, delegate: data.delegate, newBalance: data.newBalance, previousBalance: data.previousBalance, @@ -98,14 +146,16 @@ export const createExponentialStakingTracker = ({ from, address }: { from: numbe { description: 'Create Penalty event', filter: penaltyFilter, - processor: async (ctx, block, log, state) => { + processor: async ({ ctx, block, log, state }) => { const chainId = ctx.chain.id const data = abi.events.Penalty.decode(log) const id = `${chainId}:${log.id}` - const entity = new ExponentialStakingPenalty({ + const entity = new ESPenalty({ id, chainId, address, + timestamp: new Date(block.header.timestamp), + blockNumber: block.header.height, account: data.user, amount: data.amount, }) @@ -115,14 +165,16 @@ export const createExponentialStakingTracker = ({ from, address }: { from: numbe { description: 'Create Reward event', filter: penaltyFilter, - processor: async (ctx, block, log, state) => { + processor: async ({ ctx, block, log, state }) => { const chainId = ctx.chain.id const data = abi.events.Reward.decode(log) const id = `${chainId}:${log.id}` - const entity = new ExponentialStakingReward({ + const entity = new ESReward({ id, chainId, address, + timestamp: new Date(block.header.timestamp), + blockNumber: block.header.height, account: data.user, amount: data.amount, }) @@ -132,14 +184,16 @@ export const createExponentialStakingTracker = ({ from, address }: { from: numbe { description: 'Create Stake event', filter: stakeFilter, - processor: async (ctx, block, log, state) => { + processor: async ({ ctx, block, log, state }) => { const chainId = ctx.chain.id const data = abi.events.Stake.decode(log) const id = `${chainId}:${log.id}` - const entity = new ExponentialStakingStake({ + const entity = new ESStake({ id, chainId, address, + timestamp: new Date(block.header.timestamp), + blockNumber: block.header.height, lockupId: data.lockupId, account: data.user, amount: data.amount, @@ -152,14 +206,16 @@ export const createExponentialStakingTracker = ({ from, address }: { from: numbe { description: 'Create Unstake event', filter: unstakeFilter, - processor: async (ctx, block, log, state) => { + processor: async ({ ctx, block, log, state }) => { const chainId = ctx.chain.id const data = abi.events.Unstake.decode(log) const id = `${chainId}:${log.id}` - const entity = new ExponentialStakingUnstake({ + const entity = new ESUnstake({ id, chainId, address, + timestamp: new Date(block.header.timestamp), + blockNumber: block.header.height, lockupId: data.lockupId, account: data.user, amount: data.amount, @@ -172,13 +228,13 @@ export const createExponentialStakingTracker = ({ from, address }: { from: numbe // State Entity Processors { - description: 'Handle Stake for Lockup', + description: 'Handle Stake', filter: stakeFilter, - processor: async (ctx, block, log, state) => { + processor: async ({ ctx, block, log, state }) => { const chainId = ctx.chain.id const data = abi.events.Stake.decode(log) const id = `${chainId}:${address}:${data.lockupId}` - const entity = new ExponentialStakingLockup({ + const entity = new ESLockup({ id, chainId, address, @@ -191,25 +247,124 @@ export const createExponentialStakingTracker = ({ from, address }: { from: numbe points: data.points, withdrawAmount: 0n, penalty: 0n, - state: ExponentialStakingLockupState.Open, + state: ESLockupState.Open, }) state.lockup.set(id, entity) + + const contract = new abi.Contract(ctx, block.header, address) + const account = await getAccount(ctx, state, address, data.user) + account.voteBalance = await contract.getVotes(account.account) + if (account.delegateTo) { + const delegateAccount = await getAccount(ctx, state, address, account.delegateTo.account) + delegateAccount.voteBalance = await contract.getVotes(delegateAccount.account) + } }, }, { - description: 'Handle Unstake for Lockup', + description: 'Handle Unstake', filter: unstakeFilter, - processor: async (ctx, block, log, state) => { + processor: async ({ ctx, block, log, state }) => { const chainId = ctx.chain.id const data = abi.events.Unstake.decode(log) const id = `${chainId}:${address}:${data.lockupId}` - const entity = state.lockup.get(id) ?? (await ctx.store.get(ExponentialStakingLockup, id)) + const entity = state.lockup.get(id) ?? (await ctx.store.get(ESLockup, id)) if (!entity) throw new Error(`Lockup not found: ${id}`) entity.lastUpdated = new Date(block.header.timestamp) entity.withdrawAmount = data.amount entity.penalty = entity.amount - data.amount - entity.state = ExponentialStakingLockupState.Closed + entity.state = ESLockupState.Closed state.lockup.set(id, entity) + + const contract = new abi.Contract(ctx, block.header, address) + const account = await getAccount(ctx, state, address, data.user) + account.voteBalance = await contract.getVotes(account.account) + if (account.delegateTo) { + const delegateAccount = await getAccount(ctx, state, address, account.delegateTo.account) + delegateAccount.voteBalance = await contract.getVotes(delegateAccount.account) + } + }, + }, + { + description: 'Add rewardsPerSecond for local state', + filter: fixedRewardsChangeFilter, + processor: async ({ log, state }) => { + const rewardsPerSecond = fixedRewardsAbi.events.RewardsPerSecondChanged.decode(log).newRPS + state.rewardsPerSecond.push(rewardsPerSecond) + }, + }, + { + description: 'Create Yield Entity', + filter: [assetTransferFromFilter, assetTransferToFilter, fixedRewardsChangeFilter], + processor: async ({ ctx, block, log, state }) => { + if (yieldType !== 'fixed') return + const id = `${ctx.chain.id}:${log.id}` + const assetContract = new abi.Contract(ctx, block.header, assetAddress) + const assetBalance = await assetContract.balanceOf(address) // Could optimize to not use RPC but saving time here. + // Get the latest rewards per second - consider that it might be on this block. + const rpsFromLog = + fixedRewardsChangeFilter.matches(log) && fixedRewardsAbi.events.RewardsPerSecondChanged.decode(log).newRPS + const rpsFromState = + state.rewardsPerSecond.length > 0 && state.rewardsPerSecond[state.rewardsPerSecond.length - 1] + const rewardsPerSecond = + rpsFromLog || + rpsFromState || + (await ctx.store + .findOne(FRRSRewardsPerSecondChanged, { + order: { timestamp: 'desc' }, + where: { chainId: ctx.chain.id, address: rewardsAddress }, + }) + .then((r) => r?.newRPS)) || + 0n + + const apyCalc = calculateAPY( + new Date(block.header.timestamp), + dayjs(block.header.timestamp).add(365.25, 'days').toDate(), + assetBalance, + assetBalance + 60n * 60n * 24n * 36525n * rewardsPerSecond, + ) + const entity = new ESYield({ + id, + chainId: ctx.chain.id, + address, + timestamp: new Date(block.header.timestamp), + blockNumber: block.header.height, + assetBalance, + rewardsPerSecond, + apr: apyCalc.apr, + apy: apyCalc.apy, + }) + + const existing = state.yield.get(id) + if ( + !existing || + (entity.rewardsPerSecond !== existing.rewardsPerSecond && fixedRewardsChangeFilter.matches(log)) + ) { + state.yield.set(id, entity) + } + }, + }, + { + description: 'Add delegate to account', + filter: delegateChangedFilter, + processor: async ({ ctx, log, state }) => { + const data = abi.events.DelegateChanged.decode(log) + const entity = await getAccount(ctx, state, address, data.delegator) + if (data.toDelegate === data.delegator) { + entity.delegateTo = null + } else { + entity.delegateTo = await getAccount(ctx, state, address, data.toDelegate) + } + state.account.set(entity.id, entity) + }, + }, + { + description: 'Update delegate voting balance', + filter: delegateVotesChangedFilter, + processor: async ({ ctx, log, state }) => { + const data = abi.events.DelegateVotesChanged.decode(log) + const entity = await getAccount(ctx, state, address, data.delegate) + entity.voteBalance = data.newBalance + state.account.set(entity.id, entity) }, }, ] @@ -218,27 +373,50 @@ export const createExponentialStakingTracker = ({ from, address }: { from: numbe from, setup(processor: EvmBatchProcessor) { for (const subProcessor of subProcessors) { - processor.addLog(subProcessor.filter.value) + if (Array.isArray(subProcessor.filter)) { + for (const filter of subProcessor.filter) { + processor.addLog(filter.value) + } + } else { + processor.addLog(subProcessor.filter.value) + } + } + if (yieldType) { + processor.addLog(assetTransferFromFilter.value) + processor.addLog(assetTransferToFilter.value) } }, async process(ctx: Context) { const state: State = { // State Entities - lockup: new Map(), + lockup: new Map(), + yield: new Map(), + account: new Map(), // Event Entities - delegateChanged: new Map(), - delegateVotesChanged: new Map(), - penalty: new Map(), - reward: new Map(), - stake: new Map(), - unstake: new Map(), + delegateChanged: new Map(), + delegateVotesChanged: new Map(), + penalty: new Map(), + reward: new Map(), + stake: new Map(), + unstake: new Map(), + + // Local State Tracking + rewardsPerSecond: [], } for (const block of ctx.blocks) { for (const log of block.logs) { for (const subProcessor of subProcessors) { - if (subProcessor.filter.matches(log)) { - await subProcessor.processor(ctx, block, log, state) + if (Array.isArray(subProcessor.filter)) { + for (const filter of subProcessor.filter) { + if (filter.matches(log)) { + await subProcessor.processor({ ctx, block, log, state }) + } + } + } else { + if (subProcessor.filter.matches(log)) { + await subProcessor.processor({ ctx, block, log, state }) + } } } } @@ -249,8 +427,34 @@ export const createExponentialStakingTracker = ({ from, address }: { from: numbe ctx.store.insert([...state.penalty.values()]), ctx.store.insert([...state.reward.values()]), ctx.store.insert([...state.stake.values()]), + ctx.store.upsert([...state.account.values()]), ctx.store.upsert([...state.lockup.values()]), + ctx.store.insert([...state.yield.values()]), ]) }, } } + +const getAccount = async (ctx: Context, state: State, address: string, account: string) => { + const id = `${ctx.chain.id}:${address}:${account}` + const local = state.account.get(id) + if (local) { + return local + } + const existing = await ctx.store.get(ESAccount, { where: { id }, relations: { delegateTo: true } }) + if (existing) { + state.account.set(id, existing) + return existing + } + const created = new ESAccount({ + id, + chainId: ctx.chain.id, + address, + account, + voteBalance: 0n, + delegateTo: undefined, + delegatesFrom: [], + }) + state.account.set(id, created) + return created +} diff --git a/src/templates/fixed-rate-rewards-source/fixed-rate-rewards-source.ts b/src/templates/fixed-rate-rewards-source/fixed-rate-rewards-source.ts index 3a9d53a3..be536eb1 100644 --- a/src/templates/fixed-rate-rewards-source/fixed-rate-rewards-source.ts +++ b/src/templates/fixed-rate-rewards-source/fixed-rate-rewards-source.ts @@ -1,11 +1,9 @@ import * as abi from '@abi/fixed-rate-rewards-source' import { - GovernorshipTransferred, - PendingGovernorshipTransfer, - RewardCollected, - RewardsPerSecondChanged, - RewardsTargetChange, - StrategistUpdated, + FRRSRewardCollected, + FRRSRewardsPerSecondChanged, + FRRSRewardsTargetChange, + FRRSStrategistUpdated, } from '@model' import { Block, Context, Log } from '@processor' import { EvmBatchProcessor } from '@subsquid/evm-processor' @@ -13,25 +11,16 @@ import { LogFilter, logFilter } from '@utils/logFilter' interface State { // Event Entities - governorshipTransferred: Map - pendingGovernorshipTransfer: Map - rewardCollected: Map - rewardsPerSecondChanged: Map - rewardsTargetChange: Map - strategistUpdated: Map + rewardCollected: Map + rewardsPerSecondChanged: Map + rewardsTargetChange: Map + strategistUpdated: Map } -export const createFixedRewardsSourceProcessor = ({ from, address }: { from: number; address: string }) => { - const governorshipTransferredFilter = logFilter({ - address: [address], - topic0: [abi.events.GovernorshipTransferred.topic], - range: { from }, - }) - const pendingGovernorshipTransferFilter = logFilter({ - address: [address], - topic0: [abi.events.PendingGovernorshipTransfer.topic], - range: { from }, - }) +/** + * Create a FixedRateRewardsSource contract processor + */ +export const createFRRSProcessor = ({ from, address }: { from: number; address: string }) => { const rewardCollectedFilter = logFilter({ address: [address], topic0: [abi.events.RewardCollected.topic], @@ -58,46 +47,6 @@ export const createFixedRewardsSourceProcessor = ({ from, address }: { from: num filter: LogFilter processor: (ctx: Context, block: Block, log: Log, state: State) => Promise }[] = [ - { - description: 'Create GovernorshipTransferred event', - filter: governorshipTransferredFilter, - processor: async (ctx: Context, block: Block, log: Log, state: State) => { - const data = abi.events.GovernorshipTransferred.decode(log) - const id = `${ctx.chain.id}:${log.id}` - state.governorshipTransferred.set( - id, - new GovernorshipTransferred({ - id, - chainId: ctx.chain.id, - address, - timestamp: new Date(block.header.timestamp), - blockNumber: block.header.height, - newGovernor: data.newGovernor, - previousGovernor: data.previousGovernor, - }), - ) - }, - }, - { - description: 'Create PendingGovernorshipTransfer event', - filter: pendingGovernorshipTransferFilter, - processor: async (ctx: Context, block: Block, log: Log, state: State) => { - const data = abi.events.PendingGovernorshipTransfer.decode(log) - const id = `${ctx.chain.id}:${log.id}` - state.pendingGovernorshipTransfer.set( - id, - new PendingGovernorshipTransfer({ - id, - chainId: ctx.chain.id, - address, - timestamp: new Date(block.header.timestamp), - blockNumber: block.header.height, - newGovernor: data.newGovernor, - previousGovernor: data.previousGovernor, - }), - ) - }, - }, { description: 'Create RewardCollected event', filter: rewardCollectedFilter, @@ -106,7 +55,7 @@ export const createFixedRewardsSourceProcessor = ({ from, address }: { from: num const id = `${ctx.chain.id}:${log.id}` state.rewardCollected.set( id, - new RewardCollected({ + new FRRSRewardCollected({ id, chainId: ctx.chain.id, address, @@ -125,7 +74,7 @@ export const createFixedRewardsSourceProcessor = ({ from, address }: { from: num const id = `${ctx.chain.id}:${log.id}` state.rewardsPerSecondChanged.set( id, - new RewardsPerSecondChanged({ + new FRRSRewardsPerSecondChanged({ id, chainId: ctx.chain.id, address, @@ -145,7 +94,7 @@ export const createFixedRewardsSourceProcessor = ({ from, address }: { from: num const id = `${ctx.chain.id}:${log.id}` state.rewardsTargetChange.set( id, - new RewardsTargetChange({ + new FRRSRewardsTargetChange({ id, chainId: ctx.chain.id, address, @@ -165,7 +114,7 @@ export const createFixedRewardsSourceProcessor = ({ from, address }: { from: num const id = `${ctx.chain.id}:${log.id}` state.strategistUpdated.set( id, - new StrategistUpdated({ + new FRRSStrategistUpdated({ id, chainId: ctx.chain.id, address, @@ -187,12 +136,10 @@ export const createFixedRewardsSourceProcessor = ({ from, address }: { from: num const process = async (ctx: Context) => { const state: State = { // Event Entities - governorshipTransferred: new Map(), - pendingGovernorshipTransfer: new Map(), - rewardCollected: new Map(), - rewardsPerSecondChanged: new Map(), - rewardsTargetChange: new Map(), - strategistUpdated: new Map(), + rewardCollected: new Map(), + rewardsPerSecondChanged: new Map(), + rewardsTargetChange: new Map(), + strategistUpdated: new Map(), } for (const block of ctx.blocks) { for (const log of block.logs) { @@ -204,8 +151,6 @@ export const createFixedRewardsSourceProcessor = ({ from, address }: { from: num } } await Promise.all([ - ctx.store.insert([...state.governorshipTransferred.values()]), - ctx.store.insert([...state.pendingGovernorshipTransfer.values()]), ctx.store.insert([...state.rewardCollected.values()]), ctx.store.insert([...state.rewardsPerSecondChanged.values()]), ctx.store.insert([...state.rewardsTargetChange.values()]), From c3fd866fbd96aeba833ecd1b36f21bb5849b9a22 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Thu, 23 May 2024 07:38:58 -0700 Subject: [PATCH 09/13] create ESAccount with delegateTo as null, not undefined --- src/templates/exponential-staking/exponential-staking.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/templates/exponential-staking/exponential-staking.ts b/src/templates/exponential-staking/exponential-staking.ts index 7e3cc2f5..f1cbb614 100644 --- a/src/templates/exponential-staking/exponential-staking.ts +++ b/src/templates/exponential-staking/exponential-staking.ts @@ -452,7 +452,7 @@ const getAccount = async (ctx: Context, state: State, address: string, account: address, account, voteBalance: 0n, - delegateTo: undefined, + delegateTo: null, delegatesFrom: [], }) state.account.set(id, created) From 0cdb99f64927a052aff1b381cfde34cdd95a5e8d Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Thu, 23 May 2024 08:11:35 -0700 Subject: [PATCH 10/13] copy ogn processor from x-ogn-legacy branch --- TODO.md | 6 + abi/xogn.json | 1030 +++++++++++++++++ commands.json | 24 + ...26610413-Data.js => 1716476467027-Data.js} | 58 +- package.json | 1 + schema.graphql | 119 +- schema/ogn.graphql | 117 ++ squid.yaml | 5 + src/abi/xogn.ts | 284 +++++ src/main-ogn.ts | 21 + src/model/generated/_ognLockupEventType.ts | 5 + src/model/generated/_ognProposalEvent.ts | 7 + src/model/generated/_ognProposalState.ts | 10 + src/model/generated/_ognVoteType.ts | 5 + src/model/generated/index.ts | 12 + src/model/generated/ogn.model.ts | 28 + src/model/generated/ognAddress.model.ts | 30 + src/model/generated/ognDailyStat.model.ts | 40 + src/model/generated/ognLockup.model.ts | 36 + src/model/generated/ognLockupTxLog.model.ts | 32 + src/model/generated/ognProposal.model.ts | 48 + src/model/generated/ognProposalTxLog.model.ts | 26 + src/model/generated/ognProposalVote.model.ts | 34 + src/ogn/post-processors/daily-stats.ts | 103 ++ src/ogn/post-processors/governance.ts | 341 ++++++ src/ogn/processors/ogn-supply.ts | 42 + src/ogn/processors/ogn.ts | 324 ++++++ 27 files changed, 2785 insertions(+), 3 deletions(-) create mode 100644 TODO.md create mode 100644 abi/xogn.json rename db/migrations/{1716426610413-Data.js => 1716476467027-Data.js} (91%) create mode 100644 schema/ogn.graphql create mode 100644 src/abi/xogn.ts create mode 100644 src/main-ogn.ts create mode 100644 src/model/generated/_ognLockupEventType.ts create mode 100644 src/model/generated/_ognProposalEvent.ts create mode 100644 src/model/generated/_ognProposalState.ts create mode 100644 src/model/generated/_ognVoteType.ts create mode 100644 src/model/generated/ogn.model.ts create mode 100644 src/model/generated/ognAddress.model.ts create mode 100644 src/model/generated/ognDailyStat.model.ts create mode 100644 src/model/generated/ognLockup.model.ts create mode 100644 src/model/generated/ognLockupTxLog.model.ts create mode 100644 src/model/generated/ognProposal.model.ts create mode 100644 src/model/generated/ognProposalTxLog.model.ts create mode 100644 src/model/generated/ognProposalVote.model.ts create mode 100644 src/ogn/post-processors/daily-stats.ts create mode 100644 src/ogn/post-processors/governance.ts create mode 100644 src/ogn/processors/ogn-supply.ts create mode 100644 src/ogn/processors/ogn.ts diff --git a/TODO.md b/TODO.md new file mode 100644 index 00000000..1ad8d37c --- /dev/null +++ b/TODO.md @@ -0,0 +1,6 @@ +- https://github.com/OriginProtocol/ousd-governance/pull/420 + - FixedRateRewardsSource processing? + - Tenderly fork? +- ExponentialStaking + - Consider populating the remaining objects? + - This would require making RPC calls on an interval. Maybe a lower priority. \ No newline at end of file diff --git a/abi/xogn.json b/abi/xogn.json new file mode 100644 index 00000000..02a66b53 --- /dev/null +++ b/abi/xogn.json @@ -0,0 +1,1030 @@ +[ + { + "type": "constructor", + "inputs": [ + { + "name": "asset_", + "type": "address", + "internalType": "address" + }, + { + "name": "epoch_", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "minStakeDuration_", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "rewardsSource_", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "DOMAIN_SEPARATOR", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "accRewardPerShare", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "allowance", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + }, + { + "name": "spender", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "approve", + "inputs": [ + { + "name": "spender", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "asset", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "contract ERC20" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "balanceOf", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "checkpoints", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + }, + { + "name": "pos", + "type": "uint32", + "internalType": "uint32" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple", + "internalType": "struct ERC20Votes.Checkpoint", + "components": [ + { + "name": "fromBlock", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "votes", + "type": "uint224", + "internalType": "uint224" + } + ] + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "collectRewards", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "decimals", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint8", + "internalType": "uint8" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "decreaseAllowance", + "inputs": [ + { + "name": "spender", + "type": "address", + "internalType": "address" + }, + { + "name": "subtractedValue", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "delegate", + "inputs": [ + { + "name": "delegatee", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "delegateBySig", + "inputs": [ + { + "name": "delegatee", + "type": "address", + "internalType": "address" + }, + { + "name": "nonce", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "expiry", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "v", + "type": "uint8", + "internalType": "uint8" + }, + { + "name": "r", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "s", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "delegates", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "epoch", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getPastTotalSupply", + "inputs": [ + { + "name": "blockNumber", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getPastVotes", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + }, + { + "name": "blockNumber", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getVotes", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "increaseAllowance", + "inputs": [ + { + "name": "spender", + "type": "address", + "internalType": "address" + }, + { + "name": "addedValue", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "lockups", + "inputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + }, + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "amount", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "end", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "points", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "lockupsCount", + "inputs": [ + { + "name": "user", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "maxStakeDuration", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "minStakeDuration", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "string", + "internalType": "string" + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "nonces", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "numCheckpoints", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint32", + "internalType": "uint32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "permit", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + }, + { + "name": "spender", + "type": "address", + "internalType": "address" + }, + { + "name": "value", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "deadline", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "v", + "type": "uint8", + "internalType": "uint8" + }, + { + "name": "r", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "s", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "previewPoints", + "inputs": [ + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "duration", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "previewRewards", + "inputs": [ + { + "name": "user", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "previewWithdraw", + "inputs": [ + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "end", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "rewardDebtPerShare", + "inputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "rewardsSource", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "contract RewardsSource" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "stake", + "inputs": [ + { + "name": "amountIn", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "duration", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "to", + "type": "address", + "internalType": "address" + }, + { + "name": "stakeRewards", + "type": "bool", + "internalType": "bool" + }, + { + "name": "lockupId", + "type": "int256", + "internalType": "int256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "symbol", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "string", + "internalType": "string" + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "totalSupply", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "transfer", + "inputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + }, + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "transferFrom", + "inputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + }, + { + "name": "", + "type": "address", + "internalType": "address" + }, + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "unstake", + "inputs": [ + { + "name": "lockupId", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "Approval", + "inputs": [ + { + "name": "owner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "spender", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "value", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "DelegateChanged", + "inputs": [ + { + "name": "delegator", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "fromDelegate", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "toDelegate", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "DelegateVotesChanged", + "inputs": [ + { + "name": "delegate", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "previousBalance", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "newBalance", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Penalty", + "inputs": [ + { + "name": "user", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Reward", + "inputs": [ + { + "name": "user", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Stake", + "inputs": [ + { + "name": "user", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "lockupId", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "end", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "points", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Transfer", + "inputs": [ + { + "name": "from", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "value", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Unstake", + "inputs": [ + { + "name": "user", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "lockupId", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "end", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "points", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "PRBMathUD60x18__Exp2InputTooBig", + "inputs": [ + { + "name": "x", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "PRBMathUD60x18__LogInputTooSmall", + "inputs": [ + { + "name": "x", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "PRBMath__MulDivFixedPointOverflow", + "inputs": [ + { + "name": "prod1", + "type": "uint256", + "internalType": "uint256" + } + ] + } +] diff --git a/commands.json b/commands.json index b7c85b2a..53826fd6 100644 --- a/commands.json +++ b/commands.json @@ -149,6 +149,18 @@ "lib/main-ogv.js" ] }, + "process:ogn": { + "description": "Load .env and start the squid processor", + "deps": [ + "build" + ], + "cmd": [ + "node", + "--require=dotenv/config", + "--require=tsconfig-paths/register", + "lib/main-ogn.js" + ] + }, "process:mainnet": { "description": "Load .env and start the squid processor", "deps": [ @@ -209,6 +221,18 @@ ], "hidden": true }, + "process:ogn:prod": { + "description": "Start the squid processor", + "deps": [ + "migration:apply" + ], + "cmd": [ + "node", + "--require=tsconfig-paths/register", + "lib/main-ogn.js" + ], + "hidden": true + }, "process:mainnet:prod": { "description": "Start the squid processor", "deps": [ diff --git a/db/migrations/1716426610413-Data.js b/db/migrations/1716476467027-Data.js similarity index 91% rename from db/migrations/1716426610413-Data.js rename to db/migrations/1716476467027-Data.js index d872248d..3b9454d5 100644 --- a/db/migrations/1716426610413-Data.js +++ b/db/migrations/1716476467027-Data.js @@ -1,5 +1,5 @@ -module.exports = class Data1716426610413 { - name = 'Data1716426610413' +module.exports = class Data1716476467027 { + name = 'Data1716476467027' async up(db) { await db.query(`CREATE TABLE "es_yield" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "asset_balance" numeric NOT NULL, "rewards_per_second" numeric NOT NULL, "apr" numeric NOT NULL, "apy" numeric NOT NULL, CONSTRAINT "PK_52ad2363a2797ab8ce74fa9765a" PRIMARY KEY ("id"))`) @@ -183,6 +183,26 @@ module.exports = class Data1716426610413 { await db.query(`CREATE TABLE "oeth_reward_token_collected" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "strategy" text NOT NULL, "recipient" text NOT NULL, "reward_token" text NOT NULL, "amount" numeric NOT NULL, CONSTRAINT "PK_47098cc5fbc7cb95c2374fa33cd" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_81a9fa43ae4a6ae63e4103127b" ON "oeth_reward_token_collected" ("timestamp") `) await db.query(`CREATE INDEX "IDX_d36c78b9c3e9d737f067638bc4" ON "oeth_reward_token_collected" ("block_number") `) + await db.query(`CREATE TABLE "ogn" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "circulating" numeric NOT NULL, "staked" numeric NOT NULL, "total" numeric NOT NULL, CONSTRAINT "PK_7a70a9927de8edee1ecaa93948c" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_c23079c2f2a5e62cecdaa4ba3e" ON "ogn" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_84b34667c285778b066dca4bbe" ON "ogn" ("block_number") `) + await db.query(`CREATE TABLE "ogn_address" ("id" character varying NOT NULL, "balance" numeric NOT NULL, "staked" numeric NOT NULL, "xogn_balance" numeric NOT NULL, "voting_power" numeric NOT NULL, "last_updated" TIMESTAMP WITH TIME ZONE NOT NULL, "delegatee_id" character varying, CONSTRAINT "PK_dd5bf6942f895beeed52cbe726b" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_8ad97ec59533410a3467822242" ON "ogn_address" ("delegatee_id") `) + await db.query(`CREATE TABLE "ogn_lockup" ("id" character varying NOT NULL, "lockup_id" text NOT NULL, "amount" numeric NOT NULL, "end" TIMESTAMP WITH TIME ZONE NOT NULL, "xogn" numeric NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "address_id" character varying, CONSTRAINT "PK_cbf31a04e74146c349734d43867" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_38d7bf0eaf6fc6934e199d4791" ON "ogn_lockup" ("lockup_id") `) + await db.query(`CREATE INDEX "IDX_a38f7bb8e83ffb88f8c7be4676" ON "ogn_lockup" ("address_id") `) + await db.query(`CREATE TABLE "ogn_lockup_tx_log" ("id" character varying NOT NULL, "hash" text NOT NULL, "event" character varying(8) NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "total_supply" numeric NOT NULL, "ogn_lockup_id" character varying, CONSTRAINT "PK_aec3dc4bd680e7d8fed772f0899" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_f5efab1b224515ed2df14e1ebf" ON "ogn_lockup_tx_log" ("ogn_lockup_id") `) + await db.query(`CREATE TABLE "ogn_proposal" ("id" character varying NOT NULL, "description" text, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "start_block" numeric NOT NULL, "end_block" numeric NOT NULL, "last_updated" TIMESTAMP WITH TIME ZONE NOT NULL, "status" character varying(9) NOT NULL, "quorum" numeric NOT NULL, "choices" text array NOT NULL, "scores" text array NOT NULL, "proposer_id" character varying, CONSTRAINT "PK_bbf407ef9fe8e6690b21934138a" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_2d074f6338cb22a33155ab29bf" ON "ogn_proposal" ("proposer_id") `) + await db.query(`CREATE TABLE "ogn_proposal_tx_log" ("id" character varying NOT NULL, "hash" text NOT NULL, "event" character varying(8) NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "proposal_id" character varying, CONSTRAINT "PK_fff98ddfd36e07523e8d904f9bf" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_d28fb6515ffd9e89012dea5aa1" ON "ogn_proposal_tx_log" ("proposal_id") `) + await db.query(`CREATE TABLE "ogn_proposal_vote" ("id" character varying NOT NULL, "weight" numeric NOT NULL, "type" character varying(7) NOT NULL, "tx_hash" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "proposal_id" character varying, "voter_id" character varying, CONSTRAINT "PK_80239377cba35bf4169d6595d50" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_a19f392300cd06e787386b28b6" ON "ogn_proposal_vote" ("proposal_id") `) + await db.query(`CREATE INDEX "IDX_9214b544b868819bae7a431c36" ON "ogn_proposal_vote" ("voter_id") `) + await db.query(`CREATE TABLE "ogn_daily_stat" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "total_supply" numeric NOT NULL, "total_supply_usd" numeric NOT NULL, "total_staked" numeric NOT NULL, "trading_volume_usd" numeric NOT NULL, "market_cap_usd" numeric NOT NULL, "price_usd" numeric NOT NULL, "holders_over_threshold" integer NOT NULL, CONSTRAINT "PK_c87054f4663051254b7b2afa536" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_cb4297ef85375ee13a3446b240" ON "ogn_daily_stat" ("block_number") `) + await db.query(`CREATE INDEX "IDX_b96b9849e1e479d743ffb547c9" ON "ogn_daily_stat" ("timestamp") `) await db.query(`CREATE TABLE "ogv" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "circulating" numeric NOT NULL, "staked" numeric NOT NULL, "total" numeric NOT NULL, CONSTRAINT "PK_f16038abf451ce82bd03ea54ee7" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_2418a8b8b92b2f5977be761cf9" ON "ogv" ("timestamp") `) await db.query(`CREATE INDEX "IDX_b8f20bcf48e4aa77e0f48d77db" ON "ogv" ("block_number") `) @@ -300,6 +320,13 @@ module.exports = class Data1716426610413 { await db.query(`ALTER TABLE "oeth_strategy_holding_daily_stat" ADD CONSTRAINT "FK_4e867f220975e615e6077d860c1" FOREIGN KEY ("strategy_daily_stat_id_id") REFERENCES "oeth_strategy_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) await db.query(`ALTER TABLE "oeth_strategy_daily_stat" ADD CONSTRAINT "FK_6c7096c96a000d8471256ca8fc3" FOREIGN KEY ("daily_stat_id_id") REFERENCES "oeth_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) await db.query(`ALTER TABLE "oeth_collateral_daily_stat" ADD CONSTRAINT "FK_a90045de50406be7bd56efd3ea4" FOREIGN KEY ("daily_stat_id_id") REFERENCES "oeth_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ogn_address" ADD CONSTRAINT "FK_8ad97ec59533410a3467822242a" FOREIGN KEY ("delegatee_id") REFERENCES "ogn_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ogn_lockup" ADD CONSTRAINT "FK_a38f7bb8e83ffb88f8c7be46760" FOREIGN KEY ("address_id") REFERENCES "ogn_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ogn_lockup_tx_log" ADD CONSTRAINT "FK_f5efab1b224515ed2df14e1ebfa" FOREIGN KEY ("ogn_lockup_id") REFERENCES "ogn_lockup"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ogn_proposal" ADD CONSTRAINT "FK_2d074f6338cb22a33155ab29bf2" FOREIGN KEY ("proposer_id") REFERENCES "ogn_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ogn_proposal_tx_log" ADD CONSTRAINT "FK_d28fb6515ffd9e89012dea5aa17" FOREIGN KEY ("proposal_id") REFERENCES "ogn_proposal"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ogn_proposal_vote" ADD CONSTRAINT "FK_a19f392300cd06e787386b28b69" FOREIGN KEY ("proposal_id") REFERENCES "ogn_proposal"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ogn_proposal_vote" ADD CONSTRAINT "FK_9214b544b868819bae7a431c369" FOREIGN KEY ("voter_id") REFERENCES "ogn_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) await db.query(`ALTER TABLE "ogv_address" ADD CONSTRAINT "FK_49d26f287904b8b1aef6e9ac2b3" FOREIGN KEY ("delegatee_id") REFERENCES "ogv_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) await db.query(`ALTER TABLE "ogv_lockup" ADD CONSTRAINT "FK_8be94cd63e35b91adf1301a156c" FOREIGN KEY ("address_id") REFERENCES "ogv_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) await db.query(`ALTER TABLE "ogv_lockup_tx_log" ADD CONSTRAINT "FK_b49fca291c97d9b55cd91f935f3" FOREIGN KEY ("ogv_lockup_id") REFERENCES "ogv_lockup"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) @@ -497,6 +524,26 @@ module.exports = class Data1716426610413 { await db.query(`DROP TABLE "oeth_reward_token_collected"`) await db.query(`DROP INDEX "public"."IDX_81a9fa43ae4a6ae63e4103127b"`) await db.query(`DROP INDEX "public"."IDX_d36c78b9c3e9d737f067638bc4"`) + await db.query(`DROP TABLE "ogn"`) + await db.query(`DROP INDEX "public"."IDX_c23079c2f2a5e62cecdaa4ba3e"`) + await db.query(`DROP INDEX "public"."IDX_84b34667c285778b066dca4bbe"`) + await db.query(`DROP TABLE "ogn_address"`) + await db.query(`DROP INDEX "public"."IDX_8ad97ec59533410a3467822242"`) + await db.query(`DROP TABLE "ogn_lockup"`) + await db.query(`DROP INDEX "public"."IDX_38d7bf0eaf6fc6934e199d4791"`) + await db.query(`DROP INDEX "public"."IDX_a38f7bb8e83ffb88f8c7be4676"`) + await db.query(`DROP TABLE "ogn_lockup_tx_log"`) + await db.query(`DROP INDEX "public"."IDX_f5efab1b224515ed2df14e1ebf"`) + await db.query(`DROP TABLE "ogn_proposal"`) + await db.query(`DROP INDEX "public"."IDX_2d074f6338cb22a33155ab29bf"`) + await db.query(`DROP TABLE "ogn_proposal_tx_log"`) + await db.query(`DROP INDEX "public"."IDX_d28fb6515ffd9e89012dea5aa1"`) + await db.query(`DROP TABLE "ogn_proposal_vote"`) + await db.query(`DROP INDEX "public"."IDX_a19f392300cd06e787386b28b6"`) + await db.query(`DROP INDEX "public"."IDX_9214b544b868819bae7a431c36"`) + await db.query(`DROP TABLE "ogn_daily_stat"`) + await db.query(`DROP INDEX "public"."IDX_cb4297ef85375ee13a3446b240"`) + await db.query(`DROP INDEX "public"."IDX_b96b9849e1e479d743ffb547c9"`) await db.query(`DROP TABLE "ogv"`) await db.query(`DROP INDEX "public"."IDX_2418a8b8b92b2f5977be761cf9"`) await db.query(`DROP INDEX "public"."IDX_b8f20bcf48e4aa77e0f48d77db"`) @@ -614,6 +661,13 @@ module.exports = class Data1716426610413 { await db.query(`ALTER TABLE "oeth_strategy_holding_daily_stat" DROP CONSTRAINT "FK_4e867f220975e615e6077d860c1"`) await db.query(`ALTER TABLE "oeth_strategy_daily_stat" DROP CONSTRAINT "FK_6c7096c96a000d8471256ca8fc3"`) await db.query(`ALTER TABLE "oeth_collateral_daily_stat" DROP CONSTRAINT "FK_a90045de50406be7bd56efd3ea4"`) + await db.query(`ALTER TABLE "ogn_address" DROP CONSTRAINT "FK_8ad97ec59533410a3467822242a"`) + await db.query(`ALTER TABLE "ogn_lockup" DROP CONSTRAINT "FK_a38f7bb8e83ffb88f8c7be46760"`) + await db.query(`ALTER TABLE "ogn_lockup_tx_log" DROP CONSTRAINT "FK_f5efab1b224515ed2df14e1ebfa"`) + await db.query(`ALTER TABLE "ogn_proposal" DROP CONSTRAINT "FK_2d074f6338cb22a33155ab29bf2"`) + await db.query(`ALTER TABLE "ogn_proposal_tx_log" DROP CONSTRAINT "FK_d28fb6515ffd9e89012dea5aa17"`) + await db.query(`ALTER TABLE "ogn_proposal_vote" DROP CONSTRAINT "FK_a19f392300cd06e787386b28b69"`) + await db.query(`ALTER TABLE "ogn_proposal_vote" DROP CONSTRAINT "FK_9214b544b868819bae7a431c369"`) await db.query(`ALTER TABLE "ogv_address" DROP CONSTRAINT "FK_49d26f287904b8b1aef6e9ac2b3"`) await db.query(`ALTER TABLE "ogv_lockup" DROP CONSTRAINT "FK_8be94cd63e35b91adf1301a156c"`) await db.query(`ALTER TABLE "ogv_lockup_tx_log" DROP CONSTRAINT "FK_b49fca291c97d9b55cd91f935f3"`) diff --git a/package.json b/package.json index f8672559..caf8e75a 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "process:oeth": "sqd process:oeth", "process:ousd": "sqd process:ousd", "process:ogv": "sqd process:ogv", + "process:ogn": "sqd process:ogn", "process:mainnet": "sqd process:mainnet", "process": "sqd process" }, diff --git a/schema.graphql b/schema.graphql index 5e938f1a..4598e945 100644 --- a/schema.graphql +++ b/schema.graphql @@ -668,7 +668,124 @@ type OETHRewardTokenCollected @entity { recipient: String! rewardToken: String! amount: BigInt! -}type OGV @entity { +}type OGN @entity { + id: ID! + timestamp: DateTime! @index + blockNumber: Int! @index + circulating: BigInt! + staked: BigInt! + total: BigInt! +} + +type OGNAddress @entity { + id: ID! @index + balance: BigInt! + staked: BigInt! + xognBalance: BigInt! + votingPower: BigInt! + delegatee: OGNAddress + lastUpdated: DateTime! +} + +enum OGNLockupEventType { + Staked + Unstaked + Extended +} + +type OGNLockupTxLog @entity { + id: ID! + hash: String! + event: OGNLockupEventType! + timestamp: DateTime! + blockNumber: Int! + totalSupply: BigInt! + ognLockup: OGNLockup! +} + +type OGNLockup @entity { + id: ID! + lockupId: String! @index + address: OGNAddress! @index + logs: [OGNLockupTxLog]! @derivedFrom(field: "ognLockup") + amount: BigInt! + end: DateTime! + xogn: BigInt! # Amount of xogn received + timestamp: DateTime! + # active: Boolean +} + +enum OGNProposalState { + Pending + Active + Canceled + Defeated + Succeeded + Queued + Expired + Executed +} + +enum OGNProposalEvent { + Created + Queued + Canceled + Extended + Executed +} + +enum OGNVoteType { + Against + For + Abstain +} + +type OGNProposalTxLog @entity { + id: ID! + hash: String! + event: OGNProposalEvent! + timestamp: DateTime! + proposal: OGNProposal! @index +} + +type OGNProposal @entity { + id: ID! @index + description: String + proposer: OGNAddress! + timestamp: DateTime! + startBlock: BigInt! + endBlock: BigInt! + lastUpdated: DateTime! + status: OGNProposalState! + logs: [OGNProposalTxLog]! @derivedFrom(field: "proposal") + quorum: BigInt! + choices: [String]! + scores: [String]! +} + +type OGNProposalVote @entity { + id: ID! + proposal: OGNProposal! @index + voter: OGNAddress! @index + weight: BigInt! + type: OGNVoteType! + txHash: String! + timestamp: DateTime! +} + +type OGNDailyStat @entity { + id: ID! + blockNumber: Int! @index + timestamp: DateTime! @index + totalSupply: BigInt! + totalSupplyUSD: Float! + totalStaked: BigInt! + tradingVolumeUSD: Float! + marketCapUSD: Float! + priceUSD: Float! + holdersOverThreshold: Int! +} +type OGV @entity { id: ID! timestamp: DateTime! @index blockNumber: Int! @index diff --git a/schema/ogn.graphql b/schema/ogn.graphql new file mode 100644 index 00000000..9f6bd9cb --- /dev/null +++ b/schema/ogn.graphql @@ -0,0 +1,117 @@ +type OGN @entity { + id: ID! + timestamp: DateTime! @index + blockNumber: Int! @index + circulating: BigInt! + staked: BigInt! + total: BigInt! +} + +type OGNAddress @entity { + id: ID! @index + balance: BigInt! + staked: BigInt! + xognBalance: BigInt! + votingPower: BigInt! + delegatee: OGNAddress + lastUpdated: DateTime! +} + +enum OGNLockupEventType { + Staked + Unstaked + Extended +} + +type OGNLockupTxLog @entity { + id: ID! + hash: String! + event: OGNLockupEventType! + timestamp: DateTime! + blockNumber: Int! + totalSupply: BigInt! + ognLockup: OGNLockup! +} + +type OGNLockup @entity { + id: ID! + lockupId: String! @index + address: OGNAddress! @index + logs: [OGNLockupTxLog]! @derivedFrom(field: "ognLockup") + amount: BigInt! + end: DateTime! + xogn: BigInt! # Amount of xogn received + timestamp: DateTime! + # active: Boolean +} + +enum OGNProposalState { + Pending + Active + Canceled + Defeated + Succeeded + Queued + Expired + Executed +} + +enum OGNProposalEvent { + Created + Queued + Canceled + Extended + Executed +} + +enum OGNVoteType { + Against + For + Abstain +} + +type OGNProposalTxLog @entity { + id: ID! + hash: String! + event: OGNProposalEvent! + timestamp: DateTime! + proposal: OGNProposal! @index +} + +type OGNProposal @entity { + id: ID! @index + description: String + proposer: OGNAddress! + timestamp: DateTime! + startBlock: BigInt! + endBlock: BigInt! + lastUpdated: DateTime! + status: OGNProposalState! + logs: [OGNProposalTxLog]! @derivedFrom(field: "proposal") + quorum: BigInt! + choices: [String]! + scores: [String]! +} + +type OGNProposalVote @entity { + id: ID! + proposal: OGNProposal! @index + voter: OGNAddress! @index + weight: BigInt! + type: OGNVoteType! + txHash: String! + timestamp: DateTime! +} + +type OGNDailyStat @entity { + id: ID! + blockNumber: Int! @index + timestamp: DateTime! @index + totalSupply: BigInt! + totalSupplyUSD: Float! + totalStaked: BigInt! + tradingVolumeUSD: Float! + marketCapUSD: Float! + priceUSD: Float! + holdersOverThreshold: Int! +} diff --git a/squid.yaml b/squid.yaml index d31355bb..f725b648 100644 --- a/squid.yaml +++ b/squid.yaml @@ -37,6 +37,11 @@ deploy: env: RPC_ENV: RPC_ENDPOINT_RETH TS_NODE_BASEURL: './lib' + - name: ogn-processor + cmd: [ "sqd", "process:ogn:prod" ] + env: + RPC_ENV: RPC_ENDPOINT_RETH + TS_NODE_BASEURL: './lib' - name: ousd-processor cmd: [ "sqd", "process:ousd:prod" ] env: diff --git a/src/abi/xogn.ts b/src/abi/xogn.ts new file mode 100644 index 00000000..6db15e64 --- /dev/null +++ b/src/abi/xogn.ts @@ -0,0 +1,284 @@ +import * as p from '@subsquid/evm-codec' +import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' + +export const events = { + Approval: event("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", {"owner": indexed(p.address), "spender": indexed(p.address), "value": p.uint256}), + DelegateChanged: event("0x3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f", {"delegator": indexed(p.address), "fromDelegate": indexed(p.address), "toDelegate": indexed(p.address)}), + DelegateVotesChanged: event("0xdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a724", {"delegate": indexed(p.address), "previousBalance": p.uint256, "newBalance": p.uint256}), + Penalty: event("0x322e5021ddf51920f7602154a6c845b34ef1b32704a1fa2c66927b56be280762", {"user": indexed(p.address), "amount": p.uint256}), + Reward: event("0x619caafabdd75649b302ba8419e48cccf64f37f1983ac4727cfb38b57703ffc9", {"user": indexed(p.address), "amount": p.uint256}), + Stake: event("0x2720efa4b2dd4f3f8a347da3cbd290a522e9432da9072c5b8e6300496fdde282", {"user": indexed(p.address), "lockupId": p.uint256, "amount": p.uint256, "end": p.uint256, "points": p.uint256}), + Transfer: event("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", {"from": indexed(p.address), "to": indexed(p.address), "value": p.uint256}), + Unstake: event("0x05b744e3e9358bc00ba3cc0c6606a4d6536134dba00b2d2ee4b5de169acd6427", {"user": indexed(p.address), "lockupId": p.uint256, "amount": p.uint256, "end": p.uint256, "points": p.uint256}), +} + +export const functions = { + DOMAIN_SEPARATOR: fun("0x3644e515", {}, p.bytes32), + accRewardPerShare: fun("0x939d6237", {}, p.uint256), + allowance: fun("0xdd62ed3e", {"owner": p.address, "spender": p.address}, p.uint256), + approve: fun("0x095ea7b3", {"spender": p.address, "amount": p.uint256}, p.bool), + asset: fun("0x38d52e0f", {}, p.address), + balanceOf: fun("0x70a08231", {"account": p.address}, p.uint256), + checkpoints: fun("0xf1127ed8", {"account": p.address, "pos": p.uint32}, p.struct({"fromBlock": p.uint32, "votes": p.uint224})), + collectRewards: fun("0x70bb45b3", {}, ), + decimals: fun("0x313ce567", {}, p.uint8), + decreaseAllowance: fun("0xa457c2d7", {"spender": p.address, "subtractedValue": p.uint256}, p.bool), + delegate: fun("0x5c19a95c", {"delegatee": p.address}, ), + delegateBySig: fun("0xc3cda520", {"delegatee": p.address, "nonce": p.uint256, "expiry": p.uint256, "v": p.uint8, "r": p.bytes32, "s": p.bytes32}, ), + delegates: fun("0x587cde1e", {"account": p.address}, p.address), + epoch: fun("0x900cf0cf", {}, p.uint256), + getPastTotalSupply: fun("0x8e539e8c", {"blockNumber": p.uint256}, p.uint256), + getPastVotes: fun("0x3a46b1a8", {"account": p.address, "blockNumber": p.uint256}, p.uint256), + getVotes: fun("0x9ab24eb0", {"account": p.address}, p.uint256), + increaseAllowance: fun("0x39509351", {"spender": p.address, "addedValue": p.uint256}, p.bool), + lockups: fun("0xc93d0b1e", {"_0": p.address, "_1": p.uint256}, {"amount": p.uint128, "end": p.uint128, "points": p.uint256}), + lockupsCount: fun("0xd1a1ad81", {"user": p.address}, p.uint256), + maxStakeDuration: fun("0x76f70003", {}, p.uint256), + minStakeDuration: fun("0x5fec5c64", {}, p.uint256), + name: fun("0x06fdde03", {}, p.string), + nonces: fun("0x7ecebe00", {"owner": p.address}, p.uint256), + numCheckpoints: fun("0x6fcfff45", {"account": p.address}, p.uint32), + permit: fun("0xd505accf", {"owner": p.address, "spender": p.address, "value": p.uint256, "deadline": p.uint256, "v": p.uint8, "r": p.bytes32, "s": p.bytes32}, ), + previewPoints: fun("0x4fd0e648", {"amount": p.uint256, "duration": p.uint256}, {"_0": p.uint256, "_1": p.uint256}), + previewRewards: fun("0xf166e920", {"user": p.address}, p.uint256), + previewWithdraw: fun("0x488bd7b0", {"amount": p.uint256, "end": p.uint256}, p.uint256), + rewardDebtPerShare: fun("0x4423bf57", {"_0": p.address}, p.uint256), + rewardsSource: fun("0xf7240d2f", {}, p.address), + stake: fun("0x5cd42a92", {"amountIn": p.uint256, "duration": p.uint256, "to": p.address, "stakeRewards": p.bool, "lockupId": p.int256}, ), + symbol: fun("0x95d89b41", {}, p.string), + totalSupply: fun("0x18160ddd", {}, p.uint256), + transfer: fun("0xa9059cbb", {"_0": p.address, "_1": p.uint256}, p.bool), + transferFrom: fun("0x23b872dd", {"_0": p.address, "_1": p.address, "_2": p.uint256}, p.bool), + unstake: fun("0x2e17de78", {"lockupId": p.uint256}, ), +} + +export class Contract extends ContractBase { + + DOMAIN_SEPARATOR() { + return this.eth_call(functions.DOMAIN_SEPARATOR, {}) + } + + accRewardPerShare() { + return this.eth_call(functions.accRewardPerShare, {}) + } + + allowance(owner: AllowanceParams["owner"], spender: AllowanceParams["spender"]) { + return this.eth_call(functions.allowance, {owner, spender}) + } + + asset() { + return this.eth_call(functions.asset, {}) + } + + balanceOf(account: BalanceOfParams["account"]) { + return this.eth_call(functions.balanceOf, {account}) + } + + checkpoints(account: CheckpointsParams["account"], pos: CheckpointsParams["pos"]) { + return this.eth_call(functions.checkpoints, {account, pos}) + } + + decimals() { + return this.eth_call(functions.decimals, {}) + } + + delegates(account: DelegatesParams["account"]) { + return this.eth_call(functions.delegates, {account}) + } + + epoch() { + return this.eth_call(functions.epoch, {}) + } + + getPastTotalSupply(blockNumber: GetPastTotalSupplyParams["blockNumber"]) { + return this.eth_call(functions.getPastTotalSupply, {blockNumber}) + } + + getPastVotes(account: GetPastVotesParams["account"], blockNumber: GetPastVotesParams["blockNumber"]) { + return this.eth_call(functions.getPastVotes, {account, blockNumber}) + } + + getVotes(account: GetVotesParams["account"]) { + return this.eth_call(functions.getVotes, {account}) + } + + lockups(_0: LockupsParams["_0"], _1: LockupsParams["_1"]) { + return this.eth_call(functions.lockups, {_0, _1}) + } + + lockupsCount(user: LockupsCountParams["user"]) { + return this.eth_call(functions.lockupsCount, {user}) + } + + maxStakeDuration() { + return this.eth_call(functions.maxStakeDuration, {}) + } + + minStakeDuration() { + return this.eth_call(functions.minStakeDuration, {}) + } + + name() { + return this.eth_call(functions.name, {}) + } + + nonces(owner: NoncesParams["owner"]) { + return this.eth_call(functions.nonces, {owner}) + } + + numCheckpoints(account: NumCheckpointsParams["account"]) { + return this.eth_call(functions.numCheckpoints, {account}) + } + + previewPoints(amount: PreviewPointsParams["amount"], duration: PreviewPointsParams["duration"]) { + return this.eth_call(functions.previewPoints, {amount, duration}) + } + + previewRewards(user: PreviewRewardsParams["user"]) { + return this.eth_call(functions.previewRewards, {user}) + } + + previewWithdraw(amount: PreviewWithdrawParams["amount"], end: PreviewWithdrawParams["end"]) { + return this.eth_call(functions.previewWithdraw, {amount, end}) + } + + rewardDebtPerShare(_0: RewardDebtPerShareParams["_0"]) { + return this.eth_call(functions.rewardDebtPerShare, {_0}) + } + + rewardsSource() { + return this.eth_call(functions.rewardsSource, {}) + } + + symbol() { + return this.eth_call(functions.symbol, {}) + } + + totalSupply() { + return this.eth_call(functions.totalSupply, {}) + } +} + +/// Event types +export type ApprovalEventArgs = EParams +export type DelegateChangedEventArgs = EParams +export type DelegateVotesChangedEventArgs = EParams +export type PenaltyEventArgs = EParams +export type RewardEventArgs = EParams +export type StakeEventArgs = EParams +export type TransferEventArgs = EParams +export type UnstakeEventArgs = EParams + +/// Function types +export type DOMAIN_SEPARATORParams = FunctionArguments +export type DOMAIN_SEPARATORReturn = FunctionReturn + +export type AccRewardPerShareParams = FunctionArguments +export type AccRewardPerShareReturn = FunctionReturn + +export type AllowanceParams = FunctionArguments +export type AllowanceReturn = FunctionReturn + +export type ApproveParams = FunctionArguments +export type ApproveReturn = FunctionReturn + +export type AssetParams = FunctionArguments +export type AssetReturn = FunctionReturn + +export type BalanceOfParams = FunctionArguments +export type BalanceOfReturn = FunctionReturn + +export type CheckpointsParams = FunctionArguments +export type CheckpointsReturn = FunctionReturn + +export type CollectRewardsParams = FunctionArguments +export type CollectRewardsReturn = FunctionReturn + +export type DecimalsParams = FunctionArguments +export type DecimalsReturn = FunctionReturn + +export type DecreaseAllowanceParams = FunctionArguments +export type DecreaseAllowanceReturn = FunctionReturn + +export type DelegateParams = FunctionArguments +export type DelegateReturn = FunctionReturn + +export type DelegateBySigParams = FunctionArguments +export type DelegateBySigReturn = FunctionReturn + +export type DelegatesParams = FunctionArguments +export type DelegatesReturn = FunctionReturn + +export type EpochParams = FunctionArguments +export type EpochReturn = FunctionReturn + +export type GetPastTotalSupplyParams = FunctionArguments +export type GetPastTotalSupplyReturn = FunctionReturn + +export type GetPastVotesParams = FunctionArguments +export type GetPastVotesReturn = FunctionReturn + +export type GetVotesParams = FunctionArguments +export type GetVotesReturn = FunctionReturn + +export type IncreaseAllowanceParams = FunctionArguments +export type IncreaseAllowanceReturn = FunctionReturn + +export type LockupsParams = FunctionArguments +export type LockupsReturn = FunctionReturn + +export type LockupsCountParams = FunctionArguments +export type LockupsCountReturn = FunctionReturn + +export type MaxStakeDurationParams = FunctionArguments +export type MaxStakeDurationReturn = FunctionReturn + +export type MinStakeDurationParams = FunctionArguments +export type MinStakeDurationReturn = FunctionReturn + +export type NameParams = FunctionArguments +export type NameReturn = FunctionReturn + +export type NoncesParams = FunctionArguments +export type NoncesReturn = FunctionReturn + +export type NumCheckpointsParams = FunctionArguments +export type NumCheckpointsReturn = FunctionReturn + +export type PermitParams = FunctionArguments +export type PermitReturn = FunctionReturn + +export type PreviewPointsParams = FunctionArguments +export type PreviewPointsReturn = FunctionReturn + +export type PreviewRewardsParams = FunctionArguments +export type PreviewRewardsReturn = FunctionReturn + +export type PreviewWithdrawParams = FunctionArguments +export type PreviewWithdrawReturn = FunctionReturn + +export type RewardDebtPerShareParams = FunctionArguments +export type RewardDebtPerShareReturn = FunctionReturn + +export type RewardsSourceParams = FunctionArguments +export type RewardsSourceReturn = FunctionReturn + +export type StakeParams = FunctionArguments +export type StakeReturn = FunctionReturn + +export type SymbolParams = FunctionArguments +export type SymbolReturn = FunctionReturn + +export type TotalSupplyParams = FunctionArguments +export type TotalSupplyReturn = FunctionReturn + +export type TransferParams = FunctionArguments +export type TransferReturn = FunctionReturn + +export type TransferFromParams = FunctionArguments +export type TransferFromReturn = FunctionReturn + +export type UnstakeParams = FunctionArguments +export type UnstakeReturn = FunctionReturn + diff --git a/src/main-ogn.ts b/src/main-ogn.ts new file mode 100644 index 00000000..eccb0044 --- /dev/null +++ b/src/main-ogn.ts @@ -0,0 +1,21 @@ +import 'tsconfig-paths/register' + +import { run } from '@processor' +import { processStatus } from '@templates/processor-status' + +import * as dailyStats from './ogn/post-processors/daily-stats' +import * as governance from './ogn/post-processors/governance' +import * as ogn from './ogn/processors/ogn' +import * as ognSupply from './ogn/processors/ogn-supply' + +export const processor = { + stateSchema: 'ogn-processor', + processors: [ognSupply, ogn], + postProcessors: [governance, dailyStats, processStatus('ogn')], + validators: [], +} +export default processor + +if (require.main === module) { + run(processor) +} diff --git a/src/model/generated/_ognLockupEventType.ts b/src/model/generated/_ognLockupEventType.ts new file mode 100644 index 00000000..e31399b0 --- /dev/null +++ b/src/model/generated/_ognLockupEventType.ts @@ -0,0 +1,5 @@ +export enum OGNLockupEventType { + Staked = "Staked", + Unstaked = "Unstaked", + Extended = "Extended", +} diff --git a/src/model/generated/_ognProposalEvent.ts b/src/model/generated/_ognProposalEvent.ts new file mode 100644 index 00000000..4fbd049b --- /dev/null +++ b/src/model/generated/_ognProposalEvent.ts @@ -0,0 +1,7 @@ +export enum OGNProposalEvent { + Created = "Created", + Queued = "Queued", + Canceled = "Canceled", + Extended = "Extended", + Executed = "Executed", +} diff --git a/src/model/generated/_ognProposalState.ts b/src/model/generated/_ognProposalState.ts new file mode 100644 index 00000000..93808cf7 --- /dev/null +++ b/src/model/generated/_ognProposalState.ts @@ -0,0 +1,10 @@ +export enum OGNProposalState { + Pending = "Pending", + Active = "Active", + Canceled = "Canceled", + Defeated = "Defeated", + Succeeded = "Succeeded", + Queued = "Queued", + Expired = "Expired", + Executed = "Executed", +} diff --git a/src/model/generated/_ognVoteType.ts b/src/model/generated/_ognVoteType.ts new file mode 100644 index 00000000..469d86ac --- /dev/null +++ b/src/model/generated/_ognVoteType.ts @@ -0,0 +1,5 @@ +export enum OGNVoteType { + Against = "Against", + For = "For", + Abstain = "Abstain", +} diff --git a/src/model/generated/index.ts b/src/model/generated/index.ts index 82a71be8..8ec36416 100644 --- a/src/model/generated/index.ts +++ b/src/model/generated/index.ts @@ -53,6 +53,18 @@ export * from "./oethStrategyDailyStat.model" export * from "./oethStrategyHoldingDailyStat.model" export * from "./oethCollateralDailyStat.model" export * from "./oethRewardTokenCollected.model" +export * from "./ogn.model" +export * from "./ognAddress.model" +export * from "./ognLockupTxLog.model" +export * from "./_ognLockupEventType" +export * from "./ognLockup.model" +export * from "./ognProposalTxLog.model" +export * from "./_ognProposalEvent" +export * from "./ognProposal.model" +export * from "./_ognProposalState" +export * from "./ognProposalVote.model" +export * from "./_ognVoteType" +export * from "./ognDailyStat.model" export * from "./ogv.model" export * from "./ogvAddress.model" export * from "./ogvLockupTxLog.model" diff --git a/src/model/generated/ogn.model.ts b/src/model/generated/ogn.model.ts new file mode 100644 index 00000000..6be40a29 --- /dev/null +++ b/src/model/generated/ogn.model.ts @@ -0,0 +1,28 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" + +@Entity_() +export class OGN { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @DateTimeColumn_({nullable: false}) + timestamp!: Date + + @Index_() + @IntColumn_({nullable: false}) + blockNumber!: number + + @BigIntColumn_({nullable: false}) + circulating!: bigint + + @BigIntColumn_({nullable: false}) + staked!: bigint + + @BigIntColumn_({nullable: false}) + total!: bigint +} diff --git a/src/model/generated/ognAddress.model.ts b/src/model/generated/ognAddress.model.ts new file mode 100644 index 00000000..27eee75d --- /dev/null +++ b/src/model/generated/ognAddress.model.ts @@ -0,0 +1,30 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, BigIntColumn as BigIntColumn_, ManyToOne as ManyToOne_, Index as Index_, DateTimeColumn as DateTimeColumn_} from "@subsquid/typeorm-store" + +@Entity_() +export class OGNAddress { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @BigIntColumn_({nullable: false}) + balance!: bigint + + @BigIntColumn_({nullable: false}) + staked!: bigint + + @BigIntColumn_({nullable: false}) + xognBalance!: bigint + + @BigIntColumn_({nullable: false}) + votingPower!: bigint + + @Index_() + @ManyToOne_(() => OGNAddress, {nullable: true}) + delegatee!: OGNAddress | undefined | null + + @DateTimeColumn_({nullable: false}) + lastUpdated!: Date +} diff --git a/src/model/generated/ognDailyStat.model.ts b/src/model/generated/ognDailyStat.model.ts new file mode 100644 index 00000000..aa3618d5 --- /dev/null +++ b/src/model/generated/ognDailyStat.model.ts @@ -0,0 +1,40 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_, FloatColumn as FloatColumn_} from "@subsquid/typeorm-store" + +@Entity_() +export class OGNDailyStat { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @IntColumn_({nullable: false}) + blockNumber!: number + + @Index_() + @DateTimeColumn_({nullable: false}) + timestamp!: Date + + @BigIntColumn_({nullable: false}) + totalSupply!: bigint + + @FloatColumn_({nullable: false}) + totalSupplyUSD!: number + + @BigIntColumn_({nullable: false}) + totalStaked!: bigint + + @FloatColumn_({nullable: false}) + tradingVolumeUSD!: number + + @FloatColumn_({nullable: false}) + marketCapUSD!: number + + @FloatColumn_({nullable: false}) + priceUSD!: number + + @IntColumn_({nullable: false}) + holdersOverThreshold!: number +} diff --git a/src/model/generated/ognLockup.model.ts b/src/model/generated/ognLockup.model.ts new file mode 100644 index 00000000..8065cc91 --- /dev/null +++ b/src/model/generated/ognLockup.model.ts @@ -0,0 +1,36 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, StringColumn as StringColumn_, Index as Index_, ManyToOne as ManyToOne_, OneToMany as OneToMany_, BigIntColumn as BigIntColumn_, DateTimeColumn as DateTimeColumn_} from "@subsquid/typeorm-store" +import {OGNAddress} from "./ognAddress.model" +import {OGNLockupTxLog} from "./ognLockupTxLog.model" + +@Entity_() +export class OGNLockup { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @StringColumn_({nullable: false}) + lockupId!: string + + @Index_() + @ManyToOne_(() => OGNAddress, {nullable: true}) + address!: OGNAddress + + @OneToMany_(() => OGNLockupTxLog, e => e.ognLockup) + logs!: OGNLockupTxLog[] + + @BigIntColumn_({nullable: false}) + amount!: bigint + + @DateTimeColumn_({nullable: false}) + end!: Date + + @BigIntColumn_({nullable: false}) + xogn!: bigint + + @DateTimeColumn_({nullable: false}) + timestamp!: Date +} diff --git a/src/model/generated/ognLockupTxLog.model.ts b/src/model/generated/ognLockupTxLog.model.ts new file mode 100644 index 00000000..c4a169d7 --- /dev/null +++ b/src/model/generated/ognLockupTxLog.model.ts @@ -0,0 +1,32 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, IntColumn as IntColumn_, BigIntColumn as BigIntColumn_, ManyToOne as ManyToOne_, Index as Index_} from "@subsquid/typeorm-store" +import {OGNLockupEventType} from "./_ognLockupEventType" +import {OGNLockup} from "./ognLockup.model" + +@Entity_() +export class OGNLockupTxLog { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @StringColumn_({nullable: false}) + hash!: string + + @Column_("varchar", {length: 8, nullable: false}) + event!: OGNLockupEventType + + @DateTimeColumn_({nullable: false}) + timestamp!: Date + + @IntColumn_({nullable: false}) + blockNumber!: number + + @BigIntColumn_({nullable: false}) + totalSupply!: bigint + + @Index_() + @ManyToOne_(() => OGNLockup, {nullable: true}) + ognLockup!: OGNLockup +} diff --git a/src/model/generated/ognProposal.model.ts b/src/model/generated/ognProposal.model.ts new file mode 100644 index 00000000..7d83c877 --- /dev/null +++ b/src/model/generated/ognProposal.model.ts @@ -0,0 +1,48 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, StringColumn as StringColumn_, ManyToOne as ManyToOne_, Index as Index_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_, OneToMany as OneToMany_} from "@subsquid/typeorm-store" +import {OGNAddress} from "./ognAddress.model" +import {OGNProposalState} from "./_ognProposalState" +import {OGNProposalTxLog} from "./ognProposalTxLog.model" + +@Entity_() +export class OGNProposal { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @StringColumn_({nullable: true}) + description!: string | undefined | null + + @Index_() + @ManyToOne_(() => OGNAddress, {nullable: true}) + proposer!: OGNAddress + + @DateTimeColumn_({nullable: false}) + timestamp!: Date + + @BigIntColumn_({nullable: false}) + startBlock!: bigint + + @BigIntColumn_({nullable: false}) + endBlock!: bigint + + @DateTimeColumn_({nullable: false}) + lastUpdated!: Date + + @Column_("varchar", {length: 9, nullable: false}) + status!: OGNProposalState + + @OneToMany_(() => OGNProposalTxLog, e => e.proposal) + logs!: OGNProposalTxLog[] + + @BigIntColumn_({nullable: false}) + quorum!: bigint + + @StringColumn_({array: true, nullable: false}) + choices!: (string | undefined | null)[] + + @StringColumn_({array: true, nullable: false}) + scores!: (string | undefined | null)[] +} diff --git a/src/model/generated/ognProposalTxLog.model.ts b/src/model/generated/ognProposalTxLog.model.ts new file mode 100644 index 00000000..6630f40d --- /dev/null +++ b/src/model/generated/ognProposalTxLog.model.ts @@ -0,0 +1,26 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, ManyToOne as ManyToOne_, Index as Index_} from "@subsquid/typeorm-store" +import {OGNProposalEvent} from "./_ognProposalEvent" +import {OGNProposal} from "./ognProposal.model" + +@Entity_() +export class OGNProposalTxLog { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @StringColumn_({nullable: false}) + hash!: string + + @Column_("varchar", {length: 8, nullable: false}) + event!: OGNProposalEvent + + @DateTimeColumn_({nullable: false}) + timestamp!: Date + + @Index_() + @ManyToOne_(() => OGNProposal, {nullable: true}) + proposal!: OGNProposal +} diff --git a/src/model/generated/ognProposalVote.model.ts b/src/model/generated/ognProposalVote.model.ts new file mode 100644 index 00000000..31f6a8f7 --- /dev/null +++ b/src/model/generated/ognProposalVote.model.ts @@ -0,0 +1,34 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_, BigIntColumn as BigIntColumn_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_} from "@subsquid/typeorm-store" +import {OGNProposal} from "./ognProposal.model" +import {OGNAddress} from "./ognAddress.model" +import {OGNVoteType} from "./_ognVoteType" + +@Entity_() +export class OGNProposalVote { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @ManyToOne_(() => OGNProposal, {nullable: true}) + proposal!: OGNProposal + + @Index_() + @ManyToOne_(() => OGNAddress, {nullable: true}) + voter!: OGNAddress + + @BigIntColumn_({nullable: false}) + weight!: bigint + + @Column_("varchar", {length: 7, nullable: false}) + type!: OGNVoteType + + @StringColumn_({nullable: false}) + txHash!: string + + @DateTimeColumn_({nullable: false}) + timestamp!: Date +} diff --git a/src/ogn/post-processors/daily-stats.ts b/src/ogn/post-processors/daily-stats.ts new file mode 100644 index 00000000..a3a79345 --- /dev/null +++ b/src/ogn/post-processors/daily-stats.ts @@ -0,0 +1,103 @@ +import dayjs from 'dayjs' +import utc from 'dayjs/plugin/utc' +import { + FindOptionsOrderValue, + LessThanOrEqual, + MoreThanOrEqual, +} from 'typeorm' + +import { OGN, OGNAddress, OGNDailyStat } from '@model' +import { Context } from '@processor' +import { EvmBatchProcessor } from '@subsquid/evm-processor' +import { applyCoingeckoData } from '@utils/coingecko' + +dayjs.extend(utc) + +export const from = 6436154 + +export const setup = async (processor: EvmBatchProcessor) => { + processor.includeAllBlocks({ from }) +} + +export const process = async (ctx: Context) => { + const firstBlockTimestamp = ctx.blocks.find((b) => b.header.height >= from) + ?.header.timestamp + if (!firstBlockTimestamp) return + + const firstBlock = ctx.blocks[0] + const lastBlock = ctx.blocks[ctx.blocks.length - 1] + const startDate = dayjs.utc(firstBlock.header.timestamp).endOf('day') + const endDate = dayjs.utc(lastBlock.header.timestamp).endOf('day') + + let dates: Date[] = [] + for ( + let date = startDate; + !date.isAfter(endDate); + date = date.add(1, 'day').endOf('day') + ) { + dates.push(date.toDate()) + } + + const dailyStats = [] as OGNDailyStat[] + + for (const date of dates) { + const dailyStatInserts = await updateDailyStats(ctx, date) + if (dailyStatInserts) { + dailyStats.push(dailyStatInserts.dailyStat) + } + } + + if (ctx.isHead) { + const updatedStats = (await applyCoingeckoData(ctx, { + Entity: OGNDailyStat, + coinId: 'origin-protocol', + // startTimestamp: Date.UTC(2023, 4, 17), + })) as OGNDailyStat[] + + const existingIds = dailyStats.map((stat) => stat.id) + dailyStats.push( + ...updatedStats.filter((stat) => existingIds.indexOf(stat.id) < 0), + ) + } + + await ctx.store.upsert(dailyStats) +} + +async function updateDailyStats(ctx: Context, date: Date) { + const queryParams = { + where: { timestamp: LessThanOrEqual(date) }, + order: { timestamp: 'desc' as FindOptionsOrderValue }, + } + + const [lastOgn, holdersOverThreshold] = await Promise.all([ + ctx.store.findOne(OGN, queryParams), + ctx.store.countBy(OGNAddress, { balance: MoreThanOrEqual(10n ** 20n) }), // 100 OGN + ]) + + const allEntities = [lastOgn].filter(Boolean) + if (!lastOgn) { + return null + } + + const mostRecentEntity = allEntities.reduce((highest, current) => { + if (!highest || !current) return current + return current.blockNumber > highest.blockNumber ? current : highest + }) + + const id = date.toISOString().substring(0, 10) + + const dailyStat = new OGNDailyStat({ + id, + blockNumber: mostRecentEntity?.blockNumber, + timestamp: mostRecentEntity?.timestamp, + totalSupply: lastOgn?.total || 0n, + totalStaked: lastOgn?.staked, + totalSupplyUSD: 0, + tradingVolumeUSD: 0, + marketCapUSD: 0, + priceUSD: 0, + holdersOverThreshold, + }) + + return { dailyStat } +} diff --git a/src/ogn/post-processors/governance.ts b/src/ogn/post-processors/governance.ts new file mode 100644 index 00000000..b817f5bf --- /dev/null +++ b/src/ogn/post-processors/governance.ts @@ -0,0 +1,341 @@ +import { formatEther } from 'viem' + +import * as governanceAbi from '@abi/governance' +import { + OGNAddress, + OGNProposal, + OGNProposalEvent, + OGNProposalState, + OGNProposalTxLog, + OGNProposalVote, + OGNVoteType, +} from '@model' +import { Block, Context, Log } from '@processor' +import { EvmBatchProcessor } from '@subsquid/evm-processor' +import { GOVERNANCE_ADDRESS } from '@utils/addresses' +import { env } from '@utils/env' + +export const from = 15491391 // https://etherscan.io/tx/0x0e04e429248c384e6b36229edf8eb5a77bec7023c58808c21b702edfcbc0e0d6 + +interface IProcessResult { + addresses: Map + proposals: Map + proposalLogs: OGNProposalTxLog[] + votes: OGNProposalVote[] +} + +export const setup = (processor: EvmBatchProcessor) => { + processor.addLog({ + address: [GOVERNANCE_ADDRESS], // TODO: Change to OGN Governance Address + topic0: [ + governanceAbi.events.ProposalCreated.topic, + governanceAbi.events.ProposalExecuted.topic, + governanceAbi.events.ProposalExtended.topic, + governanceAbi.events.ProposalQueued.topic, + governanceAbi.events.ProposalCanceled.topic, + governanceAbi.events.VoteCast.topic, + governanceAbi.events.VoteCastWithParams.topic, + ], + range: { from }, + }) + processor.includeAllBlocks({ from }) +} + +let pendingProposals: OGNProposal[] = [] +let activeProposals: OGNProposal[] = [] +let goActiveBlock = 0 +let goFinishedBlock = 0 + +export const initialize = async (ctx: Context) => { + const pending = await ctx.store.findBy(OGNProposal, { + status: OGNProposalState.Pending, + }) + const active = await ctx.store.findBy(OGNProposal, { + status: OGNProposalState.Active, + }) + pendingProposals.push(...pending) + activeProposals.push(...active) +} + +export const process = async (ctx: Context) => { + if (ctx.blocks[ctx.blocks.length - 1]?.header.height < from) return + + const result: IProcessResult = { + addresses: new Map(), + proposals: new Map(), + proposalLogs: [], + votes: [], + } + + _updateStatusBlocks() + for (const block of ctx.blocks) { + for (const log of block.logs) { + if (log.address !== GOVERNANCE_ADDRESS) continue + + const firstTopic = log.topics[0] + try { + if (firstTopic == governanceAbi.events.ProposalCreated.topic) { + await _processProposalCreated(ctx, result, block, log) + } else if (firstTopic == governanceAbi.events.ProposalExtended.topic) { + await _processProposalExtended(ctx, result, block, log) + } else if ( + [ + governanceAbi.events.ProposalQueued.topic, + governanceAbi.events.ProposalCanceled.topic, + governanceAbi.events.ProposalExecuted.topic, + ].includes(firstTopic) + ) { + await _processProposalEvents(ctx, result, block, log) + } else if ( + [governanceAbi.events.VoteCast.topic, governanceAbi.events.VoteCastWithParams.topic].includes(firstTopic) + ) { + await _processVoteCast(ctx, result, block, log) + } + } catch (e) { + if (!env.BLOCK_FROM) { + throw e + } + ctx.log.error('Could not process governance event') + } + } + await _updateProposalStatuses(ctx, result, block, goActiveBlock, goFinishedBlock) + } + + await ctx.store.upsert(Array.from(result.addresses.values())) + await ctx.store.upsert(Array.from(result.proposals.values())) + await ctx.store.upsert(result.proposalLogs) + await ctx.store.upsert(result.votes) +} + +const _processProposalCreated = async (ctx: Context, result: IProcessResult, block: Block, log: Log) => { + // ctx.log.info('_processProposalCreated') + const { + proposalId, + proposer: proposerAddr, + description, + startBlock, + endBlock, + } = governanceAbi.events.ProposalCreated.decode(log) + const proposer = await _getAddress(ctx, proposerAddr, result) + const blockTimestamp = new Date(block.header.timestamp) + const governance = new governanceAbi.Contract(ctx, block.header, GOVERNANCE_ADDRESS) + + const proposal = new OGNProposal({ + id: proposalId.toString(), + description, + proposer, + timestamp: blockTimestamp, + startBlock, + endBlock, + lastUpdated: new Date(), + status: OGNProposalState.Pending, + quorum: await governance.quorum(BigInt(block.header.height - 1)), + choices: [], + scores: [], + }) + + pendingProposals.push(proposal) + + const proposalTxLog = new OGNProposalTxLog({ + id: `${proposalId}:${log.transactionHash}:${log.logIndex}`, + proposal, + event: OGNProposalEvent.Created, + hash: log.transactionHash, + timestamp: blockTimestamp, + }) + + result.proposals.set(proposalId.toString(), proposal) + result.proposalLogs.push(proposalTxLog) +} + +const proposalStateMap = [ + OGNProposalState.Pending, + OGNProposalState.Active, + OGNProposalState.Canceled, + OGNProposalState.Defeated, + OGNProposalState.Succeeded, + OGNProposalState.Queued, + OGNProposalState.Expired, + OGNProposalState.Executed, +] + +const eventMapper = { + [governanceAbi.events.ProposalQueued.topic]: { + decode: governanceAbi.events.ProposalQueued.decode.bind(governanceAbi.events.ProposalQueued), + status: OGNProposalState.Queued, + event: OGNProposalEvent.Queued, + }, + [governanceAbi.events.ProposalCanceled.topic]: { + decode: governanceAbi.events.ProposalCanceled.decode.bind(governanceAbi.events.ProposalCanceled), + status: OGNProposalState.Canceled, + event: OGNProposalEvent.Canceled, + }, + [governanceAbi.events.ProposalExecuted.topic]: { + decode: governanceAbi.events.ProposalExecuted.decode.bind(governanceAbi.events.ProposalExecuted), + status: OGNProposalState.Executed, + event: OGNProposalEvent.Executed, + }, +} + +const _updateStatusBlocks = () => { + goActiveBlock = Number( + pendingProposals.reduce((min, p) => (p.startBlock < min ? p.startBlock : min), BigInt(Number.MAX_SAFE_INTEGER)), + ) + goFinishedBlock = Number( + activeProposals.reduce((min, p) => (p.endBlock < min ? p.endBlock : min), BigInt(Number.MAX_SAFE_INTEGER)), + ) +} + +const _updateProposalStatuses = async ( + ctx: Context, + result: IProcessResult, + block: Block, + goActiveBlock: number, + goFinishedBlock: number, +) => { + // Update for Active and post-Active statuses. + if (block.header.height > goActiveBlock) { + ctx.log.info('block.header.height > goActiveBlock') + for (const proposal of pendingProposals.filter((p) => block.header.height > Number(p.startBlock))) { + await _updateProposalStatus(ctx, result, block, proposal.id) + } + pendingProposals = pendingProposals.filter((p) => block.header.height <= Number(p.startBlock)) + } + if (block.header.height > goFinishedBlock) { + ctx.log.info('block.header.height > goFinishedBlock') + for (const proposal of activeProposals.filter((p) => block.header.height > Number(p.endBlock))) { + await _updateProposalStatus(ctx, result, block, proposal.id) + } + activeProposals = activeProposals.filter((p) => block.header.height <= Number(p.endBlock)) + } + _updateStatusBlocks() +} + +const _updateProposalStatus = async (ctx: Context, result: IProcessResult, block: Block, proposalId: string) => { + const proposal = await _getProposal(ctx, proposalId, result) + proposal.status = await _getProposalState(ctx, block, BigInt(proposalId)) + ctx.log.info({ status: proposal.status }, '_updateProposalStatus') + if (proposal.status === OGNProposalState.Pending && !pendingProposals.find((p) => p.id === proposal.id)) { + pendingProposals.push(proposal) + } + if (proposal.status === OGNProposalState.Active && !activeProposals.find((p) => p.id === proposal.id)) { + activeProposals.push(proposal) + } +} + +const _processProposalEvents = async (ctx: Context, result: IProcessResult, block: Block, log: Log) => { + // ctx.log.info('_processProposalEvents') + const { decode, status, event } = eventMapper[log.topics[0]]! + + const { proposalId } = decode(log) + const blockTimestamp = new Date(block.header.timestamp) + + const proposal = await _getProposal(ctx, proposalId.toString(), result) + await _updateProposalStatus(ctx, result, block, proposalId.toString()) + + const proposalTxLog = new OGNProposalTxLog({ + id: `${proposalId}:${log.transactionHash}:${log.logIndex}`, + proposal, + event, + hash: log.transactionHash, + timestamp: blockTimestamp, + }) + + result.proposalLogs.push(proposalTxLog) +} + +const _processProposalExtended = async (ctx: Context, result: IProcessResult, block: Block, log: Log) => { + // ctx.log.info('_processProposalExtended') + const { proposalId, extendedDeadline } = governanceAbi.events.ProposalExtended.decode(log) + const blockTimestamp = new Date(block.header.timestamp) + + const proposal = await _getProposal(ctx, proposalId.toString(), result) + proposal.endBlock = extendedDeadline + await _updateProposalStatus(ctx, result, block, proposalId.toString()) + + const proposalTxLog = new OGNProposalTxLog({ + id: `${proposalId}:${log.transactionHash}:${log.logIndex}`, + proposal, + event: OGNProposalEvent.Extended, + hash: log.transactionHash, + timestamp: blockTimestamp, + }) + + result.proposalLogs.push(proposalTxLog) +} + +const _processVoteCast = async (ctx: Context, result: IProcessResult, block: Block, log: Log) => { + // ctx.log.info('_processVoteCast') + const { + proposalId, + voter: voterAddr, + weight, + support, + } = log.topics[0] == governanceAbi.events.VoteCast.topic + ? governanceAbi.events.VoteCast.decode(log) + : governanceAbi.events.VoteCastWithParams.decode(log) + const blockTimestamp = new Date(block.header.timestamp) + + const proposal = await _getProposal(ctx, proposalId.toString(), result) + const voter = await _getAddress(ctx, voterAddr, result) + + const voteType = [OGNVoteType.Against, OGNVoteType.For, OGNVoteType.Abstain][parseInt(support.toString())] + const proposalVote = new OGNProposalVote({ + id: `${proposalId.toString()}:${log.transactionHash}:${voter.id}`, + proposal, + voter, + txHash: log.transactionHash, + timestamp: blockTimestamp, + weight, + type: voteType, + }) + + const weightN = Number(formatEther(weight)) + const choiceIndex = proposal.choices.indexOf(voteType) + if (choiceIndex >= 0) { + proposal.scores[choiceIndex]! += weightN + } else { + proposal.choices.push(voteType) + proposal.scores.push(weightN.toString()) + } + + result.votes.push(proposalVote) +} + +const _getProposalState = async (ctx: Context, block: Block, proposalId: bigint): Promise => { + const governance = new governanceAbi.Contract(ctx, block.header, GOVERNANCE_ADDRESS) + return proposalStateMap[parseInt((await governance.state(proposalId)).toString())] || OGNProposalState.Pending +} + +const _getAddress = async (ctx: Context, id: string, result: IProcessResult): Promise => { + id = id.toLowerCase() + const { addresses } = result + + if (addresses.has(id)) { + return addresses.get(id)! + } + + const address = await ctx.store.findOneByOrFail(OGNAddress, { + id, + }) + + addresses.set(id, address) + + return address +} + +const _getProposal = async (ctx: Context, id: string, result: IProcessResult): Promise => { + const { proposals } = result + + if (proposals.has(id)) { + return proposals.get(id)! + } + + const proposal = await ctx.store.findOneByOrFail(OGNProposal, { + id, + }) + + proposals.set(id, proposal) + + return proposal +} diff --git a/src/ogn/processors/ogn-supply.ts b/src/ogn/processors/ogn-supply.ts new file mode 100644 index 00000000..62f5327a --- /dev/null +++ b/src/ogn/processors/ogn-supply.ts @@ -0,0 +1,42 @@ +import * as erc20Abi from '@abi/erc20' +import { OGN } from '@model' +import { Context } from '@processor' +import { EvmBatchProcessor } from '@subsquid/evm-processor' +import { OGN_ADDRESS, XOGN_ADDRESS } from '@utils/addresses' +import { blockFrequencyUpdater } from '@utils/blockFrequencyUpdater' + +export const from = 6436154 // https://etherscan.io/tx/0x9b8a3a8db40b02078f89cec2eed569682a23e37b36c3e462190ef391ebdd1d11 + +export const setup = (processor: EvmBatchProcessor) => { + processor.includeAllBlocks({ + from, + }) +} + +const update = blockFrequencyUpdater({ from }) +export const process = async (ctx: Context) => { + const supplyData: OGN[] = [] + + await update(ctx, async (ctx, block) => { + const ognToken = new erc20Abi.Contract(ctx, block.header, OGN_ADDRESS) + + const [staked, total] = await Promise.all([ + ognToken.balanceOf(XOGN_ADDRESS), + ognToken.totalSupply(), + ]) + const circulating = total - staked + + const supplyAtBlock = new OGN({ + id: `${block.header.height}`, + timestamp: new Date(block.header.timestamp), + blockNumber: block.header.height, + circulating, + staked, + total, + }) + + supplyData.push(supplyAtBlock) + }) + + await ctx.store.insert(supplyData) +} diff --git a/src/ogn/processors/ogn.ts b/src/ogn/processors/ogn.ts new file mode 100644 index 00000000..f271ed9d --- /dev/null +++ b/src/ogn/processors/ogn.ts @@ -0,0 +1,324 @@ +import * as erc20Abi from '@abi/erc20' +import * as xognAbi from '@abi/xogn' +import { + OGNAddress, + OGNLockup, + OGNLockupEventType, + OGNLockupTxLog, +} from '@model' +import { Block, Context, Log } from '@processor' +import { EvmBatchProcessor } from '@subsquid/evm-processor' +import { ADDRESS_ZERO, OGN_ADDRESS, XOGN_ADDRESS } from '@utils/addresses' + +export const from = 6436154 // https://etherscan.io/tx/0x9b8a3a8db40b02078f89cec2eed569682a23e37b36c3e462190ef391ebdd1d11 +export const xognFrom = 19919745 //https://etherscan.io/tx/0x8cc2dd6dc0b049add37561e983ea4f99187900ac12e327dddf56b0001eb9be5c + +interface IProcessResult { + addresses: Map + lockups: Map + lockupEvents: OGNLockupTxLog[] +} + +export const setup = (processor: EvmBatchProcessor) => { + processor.addLog({ + address: [OGN_ADDRESS], + topic0: [erc20Abi.events.Transfer.topic], + range: { from }, + }) + processor.addLog({ + address: [XOGN_ADDRESS], + topic0: [ + xognAbi.events.Transfer, + xognAbi.events.Stake, + xognAbi.events.Unstake, + xognAbi.events.DelegateChanged, + xognAbi.events.DelegateVotesChanged, + ].map((ev) => ev.topic), + range: { from: xognFrom }, + }) +} + +export const process = async (ctx: Context) => { + const result: IProcessResult = { + addresses: new Map(), + lockups: new Map(), + lockupEvents: [], + } + + for (const block of ctx.blocks) { + for (const log of block.logs) { + const firstTopic = log.topics[0] + + if (![XOGN_ADDRESS, OGN_ADDRESS].includes(log.address.toLowerCase())) { + continue + } + + if (firstTopic == xognAbi.events.Transfer.topic) { + await _processTransfer(ctx, result, block, log) + } else if (firstTopic == xognAbi.events.DelegateChanged.topic) { + await _processDelegateChanged(ctx, result, block, log) + } else if (firstTopic == xognAbi.events.DelegateVotesChanged.topic) { + await _processDelegateVotesChanged(ctx, result, block, log) + } else if (firstTopic == xognAbi.events.Stake.topic) { + await _processStake(ctx, result, block, log) + } else if (firstTopic == xognAbi.events.Unstake.topic) { + await _processUnstake(ctx, result, block, log) + } + } + } + + await ctx.store.upsert( + Array.from(result.addresses.values()).sort((a, b) => + a.delegatee?.id ? 1 : -1, + ), + ) + await ctx.store.upsert(Array.from(result.lockups.values())) + await ctx.store.upsert(result.lockupEvents) +} + +const _processTransfer = async ( + ctx: Context, + result: IProcessResult, + block: Block, + log: Log, +) => { + const { addresses } = result + let { from, to, value } = erc20Abi.events.Transfer.decode(log) + + from = from.toLowerCase() + to = to.toLowerCase() + + const isXOGN = log.address.toLowerCase() == XOGN_ADDRESS.toLowerCase() + + const blockTimestamp = new Date(block.header.timestamp) + + if (from != ADDRESS_ZERO) { + const sender = await _getAddress(ctx, from, result) + // TODO: Check sender.balance >= value + if (isXOGN) { + sender.xognBalance -= value + } else { + sender.balance -= value + } + sender.lastUpdated = blockTimestamp + addresses.set(from, sender) + } + + if (to != ADDRESS_ZERO) { + const receiver = await _getAddress(ctx, to, result) + if (isXOGN) { + receiver.xognBalance += value + } else { + receiver.balance += value + } + receiver.lastUpdated = blockTimestamp + addresses.set(to, receiver) + } +} + +const _processDelegateChanged = async ( + ctx: Context, + result: IProcessResult, + block: Block, + log: Log, +) => { + const { addresses } = result + let { delegator, toDelegate } = xognAbi.events.DelegateChanged.decode(log) + delegator = delegator.toLowerCase() + toDelegate = toDelegate.toLowerCase() + + const address = await _getAddress(ctx, delegator, result) + + address.delegatee = await _getAddress(ctx, toDelegate, result) + address.lastUpdated = new Date(block.header.timestamp) + + addresses.set(toDelegate, address.delegatee) + addresses.set(delegator, address) +} + +const _processDelegateVotesChanged = async ( + ctx: Context, + result: IProcessResult, + block: Block, + log: Log, +) => { + const { addresses } = result + let { delegate, newBalance } = + xognAbi.events.DelegateVotesChanged.decode(log) + delegate = delegate.toLowerCase() + + const address = await _getAddress(ctx, delegate, result) + + address.votingPower = newBalance + address.lastUpdated = new Date(block.header.timestamp) + + addresses.set(delegate, address) +} + +const _processStake = async ( + ctx: Context, + result: IProcessResult, + block: Block, + log: Log, +) => { + const { lockups } = result + + const { lockupId, amount, user, points, end } = + xognAbi.events.Stake.decode(log) + const address = await _getAddress(ctx, user, result) + const lockup = await _getLockup(ctx, lockupId.toString(), address, result) + + lockup.amount = amount + lockup.xogn = points + lockup.end = new Date(Number(end) * 1000) + lockup.timestamp = new Date(block.header.timestamp) + lockups.set(lockup.id, lockup) + + // Find last Unstake txLog + const unstakeIndex = result.lockupEvents.findIndex( + (x) => + x.event == OGNLockupEventType.Unstaked && + // Unstake is emitted just before Stake for Extend + x.id == `${log.transactionHash}:${log.logIndex - 1}`, + ) + + if (unstakeIndex >= 0) { + // If it exists, it's an extend + result.lockupEvents[unstakeIndex].event = OGNLockupEventType.Extended + } else { + const xOgnToken = new erc20Abi.Contract(ctx, block.header, XOGN_ADDRESS) + // If not, it's just a new stake + result.lockupEvents.push( + new OGNLockupTxLog({ + id: `${log.transactionHash}:${log.logIndex}`, + hash: log.transactionHash, + event: OGNLockupEventType.Staked, + timestamp: new Date(block.header.timestamp), + blockNumber: block.header.height, + totalSupply: await xOgnToken.totalSupply(), + ognLockup: lockup, + }), + ) + } + + address.staked += amount + + await _updateVotingPowers(ctx, result, block, address) +} + +const _processUnstake = async ( + ctx: Context, + result: IProcessResult, + block: Block, + log: Log, +) => { + const { lockupId, user, amount } = xognAbi.events.Unstake.decode(log) + const address = await _getAddress(ctx, user, result) + const lockup = await _getLockup(ctx, lockupId.toString(), address, result) + const xOgnToken = new erc20Abi.Contract(ctx, block.header, XOGN_ADDRESS) + + result.lockupEvents.push( + new OGNLockupTxLog({ + id: `${log.transactionHash}:${log.logIndex}`, + hash: log.transactionHash, + event: OGNLockupEventType.Unstaked, + timestamp: new Date(block.header.timestamp), + blockNumber: block.header.height, + totalSupply: await xOgnToken.totalSupply(), + ognLockup: lockup, + }), + ) + + address.staked -= amount + + await _updateVotingPowers(ctx, result, block, address) +} + +const _updateVotingPowers = async ( + ctx: Context, + result: IProcessResult, + block: Block, + address: OGNAddress, +) => { + const { addresses } = result + const xogn = new xognAbi.Contract(ctx, block.header, XOGN_ADDRESS) + + address.votingPower = await xogn.getVotes(address.id) + address.lastUpdated = new Date(block.header.timestamp) + addresses.set(address.id, address) + + const delegateeId = address.delegatee?.id + if (delegateeId && delegateeId !== address.id) { + const delegatee = await _getAddress(ctx, address.delegatee?.id!, result) + delegatee.votingPower = await xogn.getVotes(delegateeId) + delegatee.lastUpdated = new Date(block.header.timestamp) + addresses.set(delegateeId, delegatee) + } +} + +const _getAddress = async ( + ctx: Context, + id: string, + result: IProcessResult, +): Promise => { + id = id.toLowerCase() + const { addresses } = result + + if (addresses.has(id)) { + return addresses.get(id)! + } + + let address = await ctx.store.findOneBy(OGNAddress, { + id, + }) + + if (!address) { + address = new OGNAddress({ + id: id.toLowerCase(), + balance: 0n, + staked: 0n, + xognBalance: 0n, + votingPower: 0n, + lastUpdated: new Date(), + }) + } + + addresses.set(id, address) + + return address +} + +const _getLockup = async ( + ctx: Context, + lockupId: string, + address: OGNAddress, + result: IProcessResult, +): Promise => { + const id = `${address.id}:${lockupId}`.toLowerCase() + const { lockups } = result + + if (lockups.has(id)) { + return lockups.get(id)! + } + + let lockup = await ctx.store.findOneBy(OGNLockup, { + id, + }) + + if (!lockup) { + lockup = new OGNLockup({ + id, + address, + lockupId, + amount: 0n, + xogn: 0n, + end: new Date(0), + logs: [], + timestamp: new Date(), + }) + } + + lockups.set(id, lockup) + + return lockup +} From 1eb6c34d3db2bdf60adbf38aede166dc838b1c5e Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Thu, 23 May 2024 08:28:53 -0700 Subject: [PATCH 11/13] remove address from OGN governance --- src/ogn/post-processors/governance.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ogn/post-processors/governance.ts b/src/ogn/post-processors/governance.ts index b817f5bf..1990495f 100644 --- a/src/ogn/post-processors/governance.ts +++ b/src/ogn/post-processors/governance.ts @@ -26,7 +26,7 @@ interface IProcessResult { export const setup = (processor: EvmBatchProcessor) => { processor.addLog({ - address: [GOVERNANCE_ADDRESS], // TODO: Change to OGN Governance Address + address: [], // TODO: Add OGN Governance Address topic0: [ governanceAbi.events.ProposalCreated.topic, governanceAbi.events.ProposalExecuted.topic, From 85c02ef27957d39577d2c508024b381f6e24e756 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Thu, 23 May 2024 09:59:25 -0700 Subject: [PATCH 12/13] add coingecko compat for OGN daily stat --- src/utils/coingecko.ts | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/utils/coingecko.ts b/src/utils/coingecko.ts index 018df3fe..2e7f0fd5 100644 --- a/src/utils/coingecko.ts +++ b/src/utils/coingecko.ts @@ -1,15 +1,12 @@ import { Between, LessThanOrEqual } from 'typeorm' import { parseEther } from 'viem' -import { OETHDailyStat, OGVDailyStat, OUSDDailyStat } from '@model' +import { OETHDailyStat, OGNDailyStat, OGVDailyStat, OUSDDailyStat } from '@model' import { Context } from '@processor' import { queryClient } from '@utils/queryClient' import { EntityClassT } from '@utils/type' -type DailyStat = - | EntityClassT - | EntityClassT - | EntityClassT +type DailyStat = EntityClassT | EntityClassT | EntityClassT export interface CoingeckoDataInput { prices: [number, number][] @@ -25,9 +22,7 @@ export interface CoingeckoDataOutput { } } -export function processCoingeckoData( - data: CoingeckoDataInput, -): CoingeckoDataOutput { +export function processCoingeckoData(data: CoingeckoDataInput): CoingeckoDataOutput { try { const result: CoingeckoDataOutput = {} @@ -86,16 +81,13 @@ export async function applyCoingeckoData( let whereClause = { timestamp: LessThanOrEqual(getStartOfDayTimestamp()), } as any - if (Entity === OGVDailyStat) { + if (Entity === OGVDailyStat || Entity === OGNDailyStat) { whereClause.priceUSD = 0 } else { whereClause.pegPrice = 0n } if (props.startTimestamp) { - whereClause.timestamp = Between( - new Date(props.startTimestamp), - getStartOfDayTimestamp(), - ) + whereClause.timestamp = Between(new Date(props.startTimestamp), getStartOfDayTimestamp()) } const statsWithNoPrice = await ctx.store.findBy(Entity as any, whereClause) @@ -127,12 +119,13 @@ export async function applyCoingeckoData( | OETHDailyStat | OUSDDailyStat | OGVDailyStat + | OGNDailyStat const day = coingeckData[dayId] if (stat && day.prices) { stat.tradingVolumeUSD = day.total_volumes || 0 stat.marketCapUSD = day.market_caps || 0 - if (stat instanceof OGVDailyStat) { + if (stat instanceof OGVDailyStat || stat instanceof OGNDailyStat) { stat.priceUSD = day.prices } else { stat.pegPrice = parseEther(String(day.prices)) From 7d910f3118a01927b7f7458b81575dcd9729e9fa Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Mon, 27 May 2024 08:48:12 -0700 Subject: [PATCH 13/13] fill out more of exponential staking schema - lockup events - fill in balances - waitFor and publish mechanisms for context state - disable new processors for a release --- TODO.md | 6 - ...76467027-Data.js => 1716512235220-Data.js} | 36 ++-- schema.graphql | 54 +++-- schema/exponential-staking.graphql | 54 +++-- src/main-mainnet.ts | 34 +-- src/model/generated/_esLockupEventType.ts | 5 + src/model/generated/esAccount.model.ts | 11 +- src/model/generated/esLockup.model.ts | 6 +- src/model/generated/esLockupEvent.model.ts | 36 ++++ src/model/generated/esToken.model.ts | 28 +++ src/model/generated/index.ts | 5 +- src/shared/erc20.ts | 18 ++ .../exchange-rates/exchange-rates.ts | 72 +------ src/templates/erc20-simple/erc20.ts | 5 +- src/templates/erc20/erc20.ts | 54 ++--- .../exponential-staking.ts | 197 ++++++++++++------ src/utils/calculateAPY.ts | 21 +- src/utils/state.ts | 24 ++- 18 files changed, 414 insertions(+), 252 deletions(-) delete mode 100644 TODO.md rename db/migrations/{1716476467027-Data.js => 1716512235220-Data.js} (97%) create mode 100644 src/model/generated/_esLockupEventType.ts create mode 100644 src/model/generated/esLockupEvent.model.ts create mode 100644 src/model/generated/esToken.model.ts create mode 100644 src/shared/erc20.ts diff --git a/TODO.md b/TODO.md deleted file mode 100644 index 1ad8d37c..00000000 --- a/TODO.md +++ /dev/null @@ -1,6 +0,0 @@ -- https://github.com/OriginProtocol/ousd-governance/pull/420 - - FixedRateRewardsSource processing? - - Tenderly fork? -- ExponentialStaking - - Consider populating the remaining objects? - - This would require making RPC calls on an interval. Maybe a lower priority. \ No newline at end of file diff --git a/db/migrations/1716476467027-Data.js b/db/migrations/1716512235220-Data.js similarity index 97% rename from db/migrations/1716476467027-Data.js rename to db/migrations/1716512235220-Data.js index 3b9454d5..1f5e9708 100644 --- a/db/migrations/1716476467027-Data.js +++ b/db/migrations/1716512235220-Data.js @@ -1,22 +1,27 @@ -module.exports = class Data1716476467027 { - name = 'Data1716476467027' +module.exports = class Data1716512235220 { + name = 'Data1716512235220' async up(db) { + await db.query(`CREATE TABLE "es_token" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "circulating" numeric NOT NULL, "staked" numeric NOT NULL, "total" numeric NOT NULL, CONSTRAINT "PK_69bef9eb94d9a5d42d726d1e661" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_a234e56547c4f8b9135d80444b" ON "es_token" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_588f0be9f9bdc1d8dd29797fec" ON "es_token" ("block_number") `) + await db.query(`CREATE TABLE "es_account" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "account" text NOT NULL, "asset_balance" numeric NOT NULL, "staked_balance" numeric NOT NULL, "balance" numeric NOT NULL, "voting_power" numeric NOT NULL, "delegate_to_id" character varying, CONSTRAINT "PK_819b7e05161fa9d1f724b31e1b7" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_eb97a0d869e67af870987d6d85" ON "es_account" ("chain_id") `) + await db.query(`CREATE INDEX "IDX_93fea1d847b38c9982626e5fd1" ON "es_account" ("address") `) + await db.query(`CREATE INDEX "IDX_bc09480c9d1b13806f82337b5e" ON "es_account" ("account") `) + await db.query(`CREATE INDEX "IDX_7b43e7bb90d3b435d074112f57" ON "es_account" ("delegate_to_id") `) await db.query(`CREATE TABLE "es_yield" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "asset_balance" numeric NOT NULL, "rewards_per_second" numeric NOT NULL, "apr" numeric NOT NULL, "apy" numeric NOT NULL, CONSTRAINT "PK_52ad2363a2797ab8ce74fa9765a" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_aa3649a103464d797c959294d1" ON "es_yield" ("chain_id") `) await db.query(`CREATE INDEX "IDX_700ebb527927ee781c0750b0dc" ON "es_yield" ("address") `) await db.query(`CREATE INDEX "IDX_e2d3a1ddc3f0886f51556442bb" ON "es_yield" ("timestamp") `) await db.query(`CREATE INDEX "IDX_4fdca11723165347776a9a7110" ON "es_yield" ("block_number") `) + await db.query(`CREATE TABLE "es_lockup_event" ("id" character varying NOT NULL, "hash" text NOT NULL, "event" character varying(8) NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "total_supply" numeric NOT NULL, "lockup_id" character varying, CONSTRAINT "PK_67e28e7f997fad22a59f8fd71c1" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_46d53d4fad340d593995583600" ON "es_lockup_event" ("lockup_id") `) await db.query(`CREATE TABLE "es_lockup" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "account" text NOT NULL, "lockup_id" numeric NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "last_updated" TIMESTAMP WITH TIME ZONE NOT NULL, "amount" numeric NOT NULL, "end" numeric NOT NULL, "points" numeric NOT NULL, "withdraw_amount" numeric NOT NULL, "penalty" numeric NOT NULL, "state" character varying(6), CONSTRAINT "PK_5b189f92ac5becc0db1e5d1f8ad" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_15e9dc0d375d6f2687def01843" ON "es_lockup" ("chain_id") `) await db.query(`CREATE INDEX "IDX_f3c10b1e75f626e1aaeaa3cfc3" ON "es_lockup" ("address") `) await db.query(`CREATE INDEX "IDX_5dd7ffdf1c625829f7eb79ee27" ON "es_lockup" ("account") `) await db.query(`CREATE INDEX "IDX_31b53c3e4649bde773d707b2a0" ON "es_lockup" ("lockup_id") `) - await db.query(`CREATE TABLE "es_account" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "account" text NOT NULL, "vote_balance" numeric NOT NULL, "delegate_to_id" character varying, CONSTRAINT "PK_819b7e05161fa9d1f724b31e1b7" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_eb97a0d869e67af870987d6d85" ON "es_account" ("chain_id") `) - await db.query(`CREATE INDEX "IDX_93fea1d847b38c9982626e5fd1" ON "es_account" ("address") `) - await db.query(`CREATE INDEX "IDX_bc09480c9d1b13806f82337b5e" ON "es_account" ("account") `) - await db.query(`CREATE INDEX "IDX_7b43e7bb90d3b435d074112f57" ON "es_account" ("delegate_to_id") `) await db.query(`CREATE TABLE "es_delegate_changed" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "address" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "delegator" text NOT NULL, "from_delegate" text NOT NULL, "to_delegate" text NOT NULL, CONSTRAINT "PK_4d5857f4fe4904dea337644e603" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_76c1740192ed8b589f7b5a21c8" ON "es_delegate_changed" ("chain_id") `) await db.query(`CREATE INDEX "IDX_ed5ea936cde8d62b485ce45a13" ON "es_delegate_changed" ("address") `) @@ -315,6 +320,7 @@ module.exports = class Data1716476467027 { await db.query(`CREATE INDEX "IDX_f9020d89932aad2d0de8923490" ON "ousd_daily_stat" ("block_number") `) await db.query(`CREATE INDEX "IDX_0bb5f72bf5fa59ce8c232caa4c" ON "ousd_daily_stat" ("timestamp") `) await db.query(`ALTER TABLE "es_account" ADD CONSTRAINT "FK_7b43e7bb90d3b435d074112f572" FOREIGN KEY ("delegate_to_id") REFERENCES "es_account"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "es_lockup_event" ADD CONSTRAINT "FK_46d53d4fad340d5939955836004" FOREIGN KEY ("lockup_id") REFERENCES "es_lockup"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) await db.query(`ALTER TABLE "governance_proposal_event" ADD CONSTRAINT "FK_ce984d23fc99c537b8f22fd663a" FOREIGN KEY ("proposal_id") REFERENCES "governance_proposal"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) await db.query(`ALTER TABLE "governance_proposal_vote" ADD CONSTRAINT "FK_5531af241c24a09c854ead9d551" FOREIGN KEY ("proposal_id") REFERENCES "governance_proposal"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) await db.query(`ALTER TABLE "oeth_strategy_holding_daily_stat" ADD CONSTRAINT "FK_4e867f220975e615e6077d860c1" FOREIGN KEY ("strategy_daily_stat_id_id") REFERENCES "oeth_strategy_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) @@ -343,21 +349,26 @@ module.exports = class Data1716476467027 { } async down(db) { + await db.query(`DROP TABLE "es_token"`) + await db.query(`DROP INDEX "public"."IDX_a234e56547c4f8b9135d80444b"`) + await db.query(`DROP INDEX "public"."IDX_588f0be9f9bdc1d8dd29797fec"`) + await db.query(`DROP TABLE "es_account"`) + await db.query(`DROP INDEX "public"."IDX_eb97a0d869e67af870987d6d85"`) + await db.query(`DROP INDEX "public"."IDX_93fea1d847b38c9982626e5fd1"`) + await db.query(`DROP INDEX "public"."IDX_bc09480c9d1b13806f82337b5e"`) + await db.query(`DROP INDEX "public"."IDX_7b43e7bb90d3b435d074112f57"`) await db.query(`DROP TABLE "es_yield"`) await db.query(`DROP INDEX "public"."IDX_aa3649a103464d797c959294d1"`) await db.query(`DROP INDEX "public"."IDX_700ebb527927ee781c0750b0dc"`) await db.query(`DROP INDEX "public"."IDX_e2d3a1ddc3f0886f51556442bb"`) await db.query(`DROP INDEX "public"."IDX_4fdca11723165347776a9a7110"`) + await db.query(`DROP TABLE "es_lockup_event"`) + await db.query(`DROP INDEX "public"."IDX_46d53d4fad340d593995583600"`) await db.query(`DROP TABLE "es_lockup"`) await db.query(`DROP INDEX "public"."IDX_15e9dc0d375d6f2687def01843"`) await db.query(`DROP INDEX "public"."IDX_f3c10b1e75f626e1aaeaa3cfc3"`) await db.query(`DROP INDEX "public"."IDX_5dd7ffdf1c625829f7eb79ee27"`) await db.query(`DROP INDEX "public"."IDX_31b53c3e4649bde773d707b2a0"`) - await db.query(`DROP TABLE "es_account"`) - await db.query(`DROP INDEX "public"."IDX_eb97a0d869e67af870987d6d85"`) - await db.query(`DROP INDEX "public"."IDX_93fea1d847b38c9982626e5fd1"`) - await db.query(`DROP INDEX "public"."IDX_bc09480c9d1b13806f82337b5e"`) - await db.query(`DROP INDEX "public"."IDX_7b43e7bb90d3b435d074112f57"`) await db.query(`DROP TABLE "es_delegate_changed"`) await db.query(`DROP INDEX "public"."IDX_76c1740192ed8b589f7b5a21c8"`) await db.query(`DROP INDEX "public"."IDX_ed5ea936cde8d62b485ce45a13"`) @@ -656,6 +667,7 @@ module.exports = class Data1716476467027 { await db.query(`DROP INDEX "public"."IDX_f9020d89932aad2d0de8923490"`) await db.query(`DROP INDEX "public"."IDX_0bb5f72bf5fa59ce8c232caa4c"`) await db.query(`ALTER TABLE "es_account" DROP CONSTRAINT "FK_7b43e7bb90d3b435d074112f572"`) + await db.query(`ALTER TABLE "es_lockup_event" DROP CONSTRAINT "FK_46d53d4fad340d5939955836004"`) await db.query(`ALTER TABLE "governance_proposal_event" DROP CONSTRAINT "FK_ce984d23fc99c537b8f22fd663a"`) await db.query(`ALTER TABLE "governance_proposal_vote" DROP CONSTRAINT "FK_5531af241c24a09c854ead9d551"`) await db.query(`ALTER TABLE "oeth_strategy_holding_daily_stat" DROP CONSTRAINT "FK_4e867f220975e615e6077d860c1"`) diff --git a/schema.graphql b/schema.graphql index 4598e945..399f5c69 100644 --- a/schema.graphql +++ b/schema.graphql @@ -1,9 +1,28 @@ # GENERATED, DO NOT MODIFY # State -# - Contract -# - Lockups -# - Accounts + +type ESToken @entity { + id: ID! + timestamp: DateTime! @index + blockNumber: Int! @index + circulating: BigInt! + staked: BigInt! + total: BigInt! +} + +type ESAccount @entity { + id: ID! # `chainId:address:account` + chainId: Int! @index + address: String! @index + account: String! @index + assetBalance: BigInt! + stakedBalance: BigInt! + balance: BigInt! + votingPower: BigInt! + delegateTo: ESAccount + delegatesFrom: [ESAccount]! @derivedFrom(field: "delegateTo") +} type ESYield @entity { id: ID! @@ -17,11 +36,6 @@ type ESYield @entity { apy: Float! } -enum ESLockupState { - Open - Closed -} - type ESLockup @entity { id: ID! # `chainId:address:account:lockupId` or `lockupId` chainId: Int! @index @@ -36,16 +50,28 @@ type ESLockup @entity { withdrawAmount: BigInt! penalty: BigInt! state: ESLockupState + events: [ESLockupEvent]! @derivedFrom(field: "lockup") } -type ESAccount @entity { - id: ID! # `chainId:address:account` +enum ESLockupState { + Open + Closed +} + +enum ESLockupEventType { + Staked + Unstaked + Extended +} + +type ESLockupEvent @entity { + id: ID! chainId: Int! @index address: String! @index - account: String! @index - voteBalance: BigInt! - delegateTo: ESAccount - delegatesFrom: [ESAccount]! @derivedFrom(field: "delegateTo") + timestamp: DateTime! @index + blockNumber: Int! @index + event: ESLockupEventType! + lockup: ESLockup! } # Events diff --git a/schema/exponential-staking.graphql b/schema/exponential-staking.graphql index 381330a9..2c637e1c 100644 --- a/schema/exponential-staking.graphql +++ b/schema/exponential-staking.graphql @@ -1,7 +1,26 @@ # State -# - Contract -# - Lockups -# - Accounts + +type ESToken @entity { + id: ID! + timestamp: DateTime! @index + blockNumber: Int! @index + circulating: BigInt! + staked: BigInt! + total: BigInt! +} + +type ESAccount @entity { + id: ID! # `chainId:address:account` + chainId: Int! @index + address: String! @index + account: String! @index + assetBalance: BigInt! + stakedBalance: BigInt! + balance: BigInt! + votingPower: BigInt! + delegateTo: ESAccount + delegatesFrom: [ESAccount]! @derivedFrom(field: "delegateTo") +} type ESYield @entity { id: ID! @@ -15,11 +34,6 @@ type ESYield @entity { apy: Float! } -enum ESLockupState { - Open - Closed -} - type ESLockup @entity { id: ID! # `chainId:address:account:lockupId` or `lockupId` chainId: Int! @index @@ -34,16 +48,28 @@ type ESLockup @entity { withdrawAmount: BigInt! penalty: BigInt! state: ESLockupState + events: [ESLockupEvent]! @derivedFrom(field: "lockup") } -type ESAccount @entity { - id: ID! # `chainId:address:account` +enum ESLockupState { + Open + Closed +} + +enum ESLockupEventType { + Staked + Unstaked + Extended +} + +type ESLockupEvent @entity { + id: ID! chainId: Int! @index address: String! @index - account: String! @index - voteBalance: BigInt! - delegateTo: ESAccount - delegatesFrom: [ESAccount]! @derivedFrom(field: "delegateTo") + timestamp: DateTime! @index + blockNumber: Int! @index + event: ESLockupEventType! + lockup: ESLockup! } # Events diff --git a/src/main-mainnet.ts b/src/main-mainnet.ts index f57350ca..96e58cb3 100644 --- a/src/main-mainnet.ts +++ b/src/main-mainnet.ts @@ -6,14 +6,7 @@ import { createESTracker } from '@templates/exponential-staking' import { createFRRSProcessor } from '@templates/fixed-rate-rewards-source' import { createGovernanceProcessor } from '@templates/governance' import { processStatus } from '@templates/processor-status' -import { - GOVERNANCE_ADDRESS, - OGN_ADDRESS, - OGN_REWARDS_SOURCE_ADDRESS, - OGV_ADDRESS, - VEOGV_ADDRESS, - XOGN_ADDRESS, -} from '@utils/addresses' +import { OGN_ADDRESS, OGN_REWARDS_SOURCE_ADDRESS, XOGN_ADDRESS } from '@utils/addresses' import * as curve from './mainnet/processors/curve' import { erc20s } from './mainnet/processors/erc20s' @@ -24,22 +17,15 @@ export const processor = { processors: [ curve, ...erc20s(), - createGovernanceProcessor({ from: 15491391, address: GOVERNANCE_ADDRESS }), - createESTracker({ - from: 15089597, - address: VEOGV_ADDRESS, - assetAddress: OGV_ADDRESS, - rewardsAddress: '0x7d82e86cf1496f9485a8ea04012afeb3c7489397', - yieldType: undefined, // We won't calculate for this. - }), - createESTracker({ - from: 19919745, - address: XOGN_ADDRESS, - assetAddress: OGN_ADDRESS, - rewardsAddress: '0x7609c88e5880e934dd3a75bcfef44e31b1badb8b', - yieldType: 'fixed', - }), - createFRRSProcessor({ from: 19917521, address: OGN_REWARDS_SOURCE_ADDRESS }), + // createGovernanceProcessor({ from: 0000000000, address: OGN_GOVERNANCE_ADDRESS }), + // createESTracker({ + // from: 19919745, + // address: XOGN_ADDRESS, + // assetAddress: OGN_ADDRESS, + // rewardsAddress: '0x7609c88e5880e934dd3a75bcfef44e31b1badb8b', + // yieldType: 'fixed', + // }), + // createFRRSProcessor({ from: 19917521, address: OGN_REWARDS_SOURCE_ADDRESS }), ], postProcessors: [exchangeRates, processStatus('mainnet')], validators: [validate], diff --git a/src/model/generated/_esLockupEventType.ts b/src/model/generated/_esLockupEventType.ts new file mode 100644 index 00000000..8680fa28 --- /dev/null +++ b/src/model/generated/_esLockupEventType.ts @@ -0,0 +1,5 @@ +export enum ESLockupEventType { + Staked = "Staked", + Unstaked = "Unstaked", + Extended = "Extended", +} diff --git a/src/model/generated/esAccount.model.ts b/src/model/generated/esAccount.model.ts index 6dac75b5..225fb7dc 100644 --- a/src/model/generated/esAccount.model.ts +++ b/src/model/generated/esAccount.model.ts @@ -22,7 +22,16 @@ export class ESAccount { account!: string @BigIntColumn_({nullable: false}) - voteBalance!: bigint + assetBalance!: bigint + + @BigIntColumn_({nullable: false}) + stakedBalance!: bigint + + @BigIntColumn_({nullable: false}) + balance!: bigint + + @BigIntColumn_({nullable: false}) + votingPower!: bigint @Index_() @ManyToOne_(() => ESAccount, {nullable: true}) diff --git a/src/model/generated/esLockup.model.ts b/src/model/generated/esLockup.model.ts index 5778fbbe..d58b591a 100644 --- a/src/model/generated/esLockup.model.ts +++ b/src/model/generated/esLockup.model.ts @@ -1,5 +1,6 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_, DateTimeColumn as DateTimeColumn_} from "@subsquid/typeorm-store" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, BigIntColumn as BigIntColumn_, DateTimeColumn as DateTimeColumn_, OneToMany as OneToMany_} from "@subsquid/typeorm-store" import {ESLockupState} from "./_esLockupState" +import {ESLockupEvent} from "./esLockupEvent.model" @Entity_() export class ESLockup { @@ -49,4 +50,7 @@ export class ESLockup { @Column_("varchar", {length: 6, nullable: true}) state!: ESLockupState | undefined | null + + @OneToMany_(() => ESLockupEvent, e => e.lockup) + events!: ESLockupEvent[] } diff --git a/src/model/generated/esLockupEvent.model.ts b/src/model/generated/esLockupEvent.model.ts new file mode 100644 index 00000000..de60c8cd --- /dev/null +++ b/src/model/generated/esLockupEvent.model.ts @@ -0,0 +1,36 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, ManyToOne as ManyToOne_} from "@subsquid/typeorm-store" +import {ESLockupEventType} from "./_esLockupEventType" +import {ESLockup} from "./esLockup.model" + +@Entity_() +export class ESLockupEvent { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @IntColumn_({nullable: false}) + chainId!: number + + @Index_() + @StringColumn_({nullable: false}) + address!: string + + @Index_() + @DateTimeColumn_({nullable: false}) + timestamp!: Date + + @Index_() + @IntColumn_({nullable: false}) + blockNumber!: number + + @Column_("varchar", {length: 8, nullable: false}) + event!: ESLockupEventType + + @Index_() + @ManyToOne_(() => ESLockup, {nullable: true}) + lockup!: ESLockup +} diff --git a/src/model/generated/esToken.model.ts b/src/model/generated/esToken.model.ts new file mode 100644 index 00000000..390fb3bb --- /dev/null +++ b/src/model/generated/esToken.model.ts @@ -0,0 +1,28 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, DateTimeColumn as DateTimeColumn_, Index as Index_, IntColumn as IntColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" + +@Entity_() +export class ESToken { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @DateTimeColumn_({nullable: false}) + timestamp!: Date + + @Index_() + @IntColumn_({nullable: false}) + blockNumber!: number + + @BigIntColumn_({nullable: false}) + circulating!: bigint + + @BigIntColumn_({nullable: false}) + staked!: bigint + + @BigIntColumn_({nullable: false}) + total!: bigint +} diff --git a/src/model/generated/index.ts b/src/model/generated/index.ts index 8ec36416..67446a77 100644 --- a/src/model/generated/index.ts +++ b/src/model/generated/index.ts @@ -1,7 +1,10 @@ +export * from "./esToken.model" +export * from "./esAccount.model" export * from "./esYield.model" export * from "./esLockup.model" export * from "./_esLockupState" -export * from "./esAccount.model" +export * from "./esLockupEvent.model" +export * from "./_esLockupEventType" export * from "./esDelegateChanged.model" export * from "./esDelegateVotesChanged.model" export * from "./esPenalty.model" diff --git a/src/shared/erc20.ts b/src/shared/erc20.ts new file mode 100644 index 00000000..4f8c0429 --- /dev/null +++ b/src/shared/erc20.ts @@ -0,0 +1,18 @@ +import { ERC20Balance, ERC20Holder, ERC20State, ERC20Transfer } from '@model' +import { Context } from '@processor' +import { publishProcessorState, waitForProcessorState } from '@utils/state' + +interface State { + states: Map + balances: Map + transfers: Map + holders: Map +} + +export const waitForERC20State = (ctx: Context, address: string) => { + return waitForProcessorState(ctx, `erc20-${address}`) +} + +export const publishERC20State = (ctx: Context, address: string, state: State) => { + publishProcessorState(ctx, `erc20-${address}`, state) +} diff --git a/src/shared/post-processors/exchange-rates/exchange-rates.ts b/src/shared/post-processors/exchange-rates/exchange-rates.ts index 6ece7568..a6fa5bf0 100644 --- a/src/shared/post-processors/exchange-rates/exchange-rates.ts +++ b/src/shared/post-processors/exchange-rates/exchange-rates.ts @@ -8,8 +8,7 @@ import { useProcessorState } from '@utils/state' import { Currency, currenciesByAddress } from './currencies' import { getPrice } from './price-routing' -const useExchangeRates = (ctx: Context) => - useProcessorState(ctx, 'exchange-rates', new Map()) +const useExchangeRates = (ctx: Context) => useProcessorState(ctx, 'exchange-rates', new Map()) export const process = async (ctx: Context) => { const [rates] = useExchangeRates(ctx) @@ -19,16 +18,9 @@ export const process = async (ctx: Context) => { } } -export const ensureExchangeRate = async ( - ctx: Context, - block: Block, - base: Currency, - quote: Currency, -) => { - if (currenciesByAddress[base.toLowerCase()]) - base = currenciesByAddress[base.toLowerCase()] - if (currenciesByAddress[quote.toLowerCase()]) - quote = currenciesByAddress[quote.toLowerCase()] +export const ensureExchangeRate = async (ctx: Context, block: Block, base: Currency, quote: Currency) => { + if (currenciesByAddress[base.toLowerCase()]) base = currenciesByAddress[base.toLowerCase()] + if (currenciesByAddress[quote.toLowerCase()]) quote = currenciesByAddress[quote.toLowerCase()] const [exchangeRates] = useExchangeRates(ctx) const pair = `${base}_${quote}` const blockNumber = block.header.height @@ -37,12 +29,10 @@ export const ensureExchangeRate = async ( if (exchangeRate) return exchangeRate const timestamp = new Date(block.header.timestamp) - const price = await getPrice(ctx, block.header.height, base, quote).catch( - (err) => { - ctx.log.info({ base, quote, err, message: err.message }) - throw err - }, - ) + const price = await getPrice(ctx, block.header.height, base, quote).catch((err) => { + ctx.log.info({ base, quote, err, message: err.message }) + throw err + }) if (price) { exchangeRate = new ExchangeRate({ id, @@ -58,48 +48,6 @@ export const ensureExchangeRate = async ( return exchangeRate } -export const ensureExchangeRates = async ( - ctx: Context, - block: Block, - pairs: [Currency, Currency][], -) => { - return await Promise.all( - pairs.map(([base, quote]) => ensureExchangeRate(ctx, block, base, quote)), - ).then(compact) -} - -export const ensureExchangeRatesAverages = async ( - ctx: Context, - block: Block, - from: Date, - to: Date, - pairs: [Currency, Currency][], -) => { - return await Promise.all( - pairs.map(([base, quote]) => - ensureExchangeRate(ctx, block, base, quote) - .then((rate) => { - if (!rate) return [] - return ctx.store - .find(ExchangeRate, { - where: { pair: rate?.pair, timestamp: Between(from, to) }, - }) - .then((rates) => rates.concat(rate!)) - }) - .then((rates) => { - const pair = `${base}_${quote}` - const rate = - rates.reduce((sum, r) => sum + r.rate, 0n) / BigInt(rates.length) - // ctx.log.info( - // `Created average exchange rate of ${rate} using ${rates.length} rates`, - // ) - return new ExchangeRate({ - base: rates[0].base, - quote: rates[0].quote, - pair, - rate, - }) - }), - ), - ) +export const ensureExchangeRates = async (ctx: Context, block: Block, pairs: [Currency, Currency][]) => { + return await Promise.all(pairs.map(([base, quote]) => ensureExchangeRate(ctx, block, base, quote))).then(compact) } diff --git a/src/templates/erc20-simple/erc20.ts b/src/templates/erc20-simple/erc20.ts index 391da066..b7525c88 100644 --- a/src/templates/erc20-simple/erc20.ts +++ b/src/templates/erc20-simple/erc20.ts @@ -1,6 +1,7 @@ import * as abi from '@abi/erc20' import { ERC20, ERC20Balance, ERC20Holder, ERC20State, ERC20Transfer } from '@model' import { Block, Context } from '@processor' +import { publishERC20State } from '@shared/erc20' import { EvmBatchProcessor } from '@subsquid/evm-processor' import { ADDRESS_ZERO, TokenAddress } from '@utils/addresses' import { logFilter } from '@utils/logFilter' @@ -35,7 +36,7 @@ export const createERC20SimpleTracker = ({ from, address }: { from: number; addr await ctx.store.insert(erc20) } } catch (err) { - ctx.log.error({ height: block.header.height, err }, 'Failed to get contract name') + ctx.log.info({ height: block.header.height }, 'Failed to get contract name') } if (!lastState) { lastState = await ctx.store @@ -180,12 +181,14 @@ export const createERC20SimpleTracker = ({ from, address }: { from: number; addr } } } + await Promise.all([ ctx.store.upsert([...result.holders.values()]), ctx.store.insert([...result.states.values()]), ctx.store.insert([...result.balances.values()]), ctx.store.insert([...result.transfers.values()]), ]) + publishERC20State(ctx, address, result) }, } } diff --git a/src/templates/erc20/erc20.ts b/src/templates/erc20/erc20.ts index cc07714d..0e853255 100644 --- a/src/templates/erc20/erc20.ts +++ b/src/templates/erc20/erc20.ts @@ -1,12 +1,7 @@ import * as abi from '@abi/erc20' -import { - ERC20, - ERC20Balance, - ERC20Holder, - ERC20State, - ERC20Transfer, -} from '@model' +import { ERC20, ERC20Balance, ERC20Holder, ERC20State, ERC20Transfer } from '@model' import { Context } from '@processor' +import { publishERC20State } from '@shared/erc20' import { EvmBatchProcessor } from '@subsquid/evm-processor' import { ADDRESS_ZERO, TokenAddress } from '@utils/addresses' import { blockFrequencyTracker } from '@utils/blockFrequencyUpdater' @@ -33,13 +28,9 @@ export const createERC20Tracker = ({ throw new Error('An ERC20 tracker was already created for: ' + address) } duplicateTracker.add(address) - const accountFilterSet = accountFilter - ? new Set(accountFilter.map((account) => account.toLowerCase())) - : undefined + const accountFilterSet = accountFilter ? new Set(accountFilter.map((account) => account.toLowerCase())) : undefined - const intervalTracker = intervalTracking - ? blockFrequencyTracker({ from }) - : undefined + const intervalTracker = intervalTracking ? blockFrequencyTracker({ from }) : undefined let erc20: ERC20 | undefined // Keep an in-memory record of what our current holders are. @@ -68,11 +59,7 @@ export const createERC20Tracker = ({ try { if (!erc20) { const contract = new abi.Contract(ctx, block.header, address) - const [name, symbol, decimals] = await Promise.all([ - contract.name(), - contract.symbol(), - contract.decimals(), - ]) + const [name, symbol, decimals] = await Promise.all([contract.name(), contract.symbol(), contract.decimals()]) erc20 = new ERC20({ id: `${ctx.chain.id}-${address}`, chainId: ctx.chain.id, @@ -84,10 +71,7 @@ export const createERC20Tracker = ({ await ctx.store.insert(erc20) } } catch (err) { - ctx.log.error( - { height: block.header.height, err }, - 'Failed to get contract name', - ) + ctx.log.error({ height: block.header.height, err }, 'Failed to get contract name') } } return { @@ -113,7 +97,7 @@ export const createERC20Tracker = ({ states: new Map(), balances: new Map(), transfers: new Map(), - newHolders: new Map(), + holders: new Map(), removedHolders: new Set(), } for (const block of ctx.blocks) { @@ -133,10 +117,7 @@ export const createERC20Tracker = ({ }) result.states.set(id, state) } - const updateBalances = async ( - accounts: string[], - doStateUpdate = false, - ) => { + const updateBalances = async (accounts: string[], doStateUpdate = false) => { if (accountFilterSet) { accounts = accounts.filter((a) => accountFilterSet.has(a)) } @@ -165,10 +146,10 @@ export const createERC20Tracker = ({ if (balance.balance === 0n) { doStateUpdate = true holders.delete(account) - result.newHolders.delete(account) + result.holders.delete(account) result.removedHolders.add(account) - } else if (!holders.has(account)) { - const newHolder = new ERC20Holder({ + } else { + const holder = new ERC20Holder({ id: `${ctx.chain.id}-${address}-${account}`, chainId: ctx.chain.id, address, @@ -179,8 +160,8 @@ export const createERC20Tracker = ({ doStateUpdate = true holders.add(account) } - result.newHolders.set(newHolder.account, newHolder) - result.removedHolders.delete(newHolder.account) + result.holders.set(holder.account, holder) + result.removedHolders.delete(holder.account) } }) } @@ -227,16 +208,13 @@ export const createERC20Tracker = ({ await updateBalances([...accounts], haveRebase) } await Promise.all([ - ctx.store.upsert([...result.newHolders.values()]), + ctx.store.upsert([...result.holders.values()]), ctx.store.insert([...result.states.values()]), ctx.store.insert([...result.balances.values()]), ctx.store.insert([...result.transfers.values()]), - ctx.store.remove( - [...result.removedHolders.values()].map( - (id) => new ERC20Holder({ id }), - ), - ), + ctx.store.remove([...result.removedHolders.values()].map((id) => new ERC20Holder({ id }))), ]) + publishERC20State(ctx, address, result) }, } } diff --git a/src/templates/exponential-staking/exponential-staking.ts b/src/templates/exponential-staking/exponential-staking.ts index f1cbb614..3d773eb5 100644 --- a/src/templates/exponential-staking/exponential-staking.ts +++ b/src/templates/exponential-staking/exponential-staking.ts @@ -1,5 +1,3 @@ -import dayjs from 'dayjs' - import * as abi from '@abi/exponential-staking' import * as fixedRewardsAbi from '@abi/fixed-rate-rewards-source' import { @@ -7,6 +5,8 @@ import { ESDelegateChanged, ESDelegateVotesChanged, ESLockup, + ESLockupEvent, + ESLockupEventType, ESLockupState, ESPenalty, ESReward, @@ -16,15 +16,17 @@ import { FRRSRewardsPerSecondChanged, } from '@model' import { Block, Context, Log } from '@processor' +import { waitForERC20State } from '@shared/erc20' import { EvmBatchProcessor } from '@subsquid/evm-processor' import { TokenAddress } from '@utils/addresses' -import { calculateAPY } from '@utils/calculateAPY' +import { calculateAPY2, convertApyToApr } from '@utils/calculateAPY' import { LogFilter, logFilter } from '@utils/logFilter' interface State { // State Entities account: Map lockup: Map + lockupEvent: Map yield: Map // Event Entities @@ -39,6 +41,13 @@ interface State { rewardsPerSecond: bigint[] } +interface SubProcessor { + enabled?: boolean + description: string + filter: LogFilter | LogFilter[] + processor: (params: { ctx: Context; block: Block; log: Log; state: State }) => Promise +} + /** * Create an ExponentialStaking contract tracker. */ @@ -97,12 +106,8 @@ export const createESTracker = ({ topic0: [abi.events.Unstake.topic], range: { from }, }) - const subProcessors: { - description: string - filter: LogFilter | LogFilter[] - processor: (params: { ctx: Context; block: Block; log: Log; state: State }) => Promise - }[] = [ - // Event Entity Processors + + const eventProcessors: SubProcessor[] = [ { description: 'Create DelegateChanged event', filter: delegateChangedFilter, @@ -225,8 +230,9 @@ export const createESTracker = ({ state.unstake.set(id, entity) }, }, + ] - // State Entity Processors + const lockupProcessors: SubProcessor[] = [ { description: 'Handle Stake', filter: stakeFilter, @@ -251,12 +257,30 @@ export const createESTracker = ({ }) state.lockup.set(id, entity) + const isExtend = block.logs.find( + (l) => unstakeFilter.matches(l) && abi.events.Unstake.decode(l).lockupId === data.lockupId, + ) + const lockupEventId = `${id}:${log.id}` + state.lockupEvent.set( + lockupEventId, + new ESLockupEvent({ + id, + chainId, + address, + timestamp: new Date(block.header.timestamp), + blockNumber: block.header.height, + lockup: entity, + event: isExtend ? ESLockupEventType.Extended : ESLockupEventType.Unstaked, + }), + ) + const contract = new abi.Contract(ctx, block.header, address) - const account = await getAccount(ctx, state, address, data.user) - account.voteBalance = await contract.getVotes(account.account) + const account = await getAccount(ctx, state, data.user) + account.stakedBalance += data.amount + account.votingPower = await contract.getVotes(account.account) if (account.delegateTo) { - const delegateAccount = await getAccount(ctx, state, address, account.delegateTo.account) - delegateAccount.voteBalance = await contract.getVotes(delegateAccount.account) + const delegateAccount = await getAccount(ctx, state, account.delegateTo.account) + delegateAccount.votingPower = await contract.getVotes(delegateAccount.account) } }, }, @@ -275,15 +299,38 @@ export const createESTracker = ({ entity.state = ESLockupState.Closed state.lockup.set(id, entity) + const isExtend = block.logs.find( + (l) => stakeFilter.matches(l) && abi.events.Stake.decode(l).lockupId === data.lockupId, + ) + if (!isExtend) { + const lockupEventId = `${id}:${log.id}` + state.lockupEvent.set( + lockupEventId, + new ESLockupEvent({ + id, + chainId, + address, + timestamp: new Date(block.header.timestamp), + blockNumber: block.header.height, + lockup: entity, + event: ESLockupEventType.Unstaked, + }), + ) + } + const contract = new abi.Contract(ctx, block.header, address) - const account = await getAccount(ctx, state, address, data.user) - account.voteBalance = await contract.getVotes(account.account) + const account = await getAccount(ctx, state, data.user) + account.votingPower = await contract.getVotes(account.account) + account.stakedBalance -= entity.amount if (account.delegateTo) { - const delegateAccount = await getAccount(ctx, state, address, account.delegateTo.account) - delegateAccount.voteBalance = await contract.getVotes(delegateAccount.account) + const delegateAccount = await getAccount(ctx, state, account.delegateTo.account) + delegateAccount.votingPower = await contract.getVotes(delegateAccount.account) } }, }, + ] + + const yieldProcessors: SubProcessor[] = [ { description: 'Add rewardsPerSecond for local state', filter: fixedRewardsChangeFilter, @@ -294,19 +341,20 @@ export const createESTracker = ({ }, { description: 'Create Yield Entity', + enabled: yieldType === 'fixed', filter: [assetTransferFromFilter, assetTransferToFilter, fixedRewardsChangeFilter], processor: async ({ ctx, block, log, state }) => { - if (yieldType !== 'fixed') return + // TODO: this looks too complicated (?) const id = `${ctx.chain.id}:${log.id}` const assetContract = new abi.Contract(ctx, block.header, assetAddress) const assetBalance = await assetContract.balanceOf(address) // Could optimize to not use RPC but saving time here. // Get the latest rewards per second - consider that it might be on this block. - const rpsFromLog = - fixedRewardsChangeFilter.matches(log) && fixedRewardsAbi.events.RewardsPerSecondChanged.decode(log).newRPS + const rpsLog = block.logs.find((l) => fixedRewardsChangeFilter.matches(l)) + const rpsFromBlock = rpsLog && fixedRewardsAbi.events.RewardsPerSecondChanged.decode(log).newRPS const rpsFromState = state.rewardsPerSecond.length > 0 && state.rewardsPerSecond[state.rewardsPerSecond.length - 1] const rewardsPerSecond = - rpsFromLog || + rpsFromBlock || rpsFromState || (await ctx.store .findOne(FRRSRewardsPerSecondChanged, { @@ -316,12 +364,9 @@ export const createESTracker = ({ .then((r) => r?.newRPS)) || 0n - const apyCalc = calculateAPY( - new Date(block.header.timestamp), - dayjs(block.header.timestamp).add(365.25, 'days').toDate(), - assetBalance, - assetBalance + 60n * 60n * 24n * 36525n * rewardsPerSecond, - ) + const rewardsPerYear = (60n * 60n * 24n * 36525n * rewardsPerSecond) / 100n + const apy = calculateAPY2(assetBalance, assetBalance + rewardsPerYear) + const apr = convertApyToApr(apy) const entity = new ESYield({ id, chainId: ctx.chain.id, @@ -330,8 +375,8 @@ export const createESTracker = ({ blockNumber: block.header.height, assetBalance, rewardsPerSecond, - apr: apyCalc.apr, - apy: apyCalc.apy, + apr, + apy, }) const existing = state.yield.get(id) @@ -343,16 +388,19 @@ export const createESTracker = ({ } }, }, + ] + + const delegationProcessors: SubProcessor[] = [ { description: 'Add delegate to account', filter: delegateChangedFilter, processor: async ({ ctx, log, state }) => { const data = abi.events.DelegateChanged.decode(log) - const entity = await getAccount(ctx, state, address, data.delegator) + const entity = await getAccount(ctx, state, data.delegator) if (data.toDelegate === data.delegator) { entity.delegateTo = null } else { - entity.delegateTo = await getAccount(ctx, state, address, data.toDelegate) + entity.delegateTo = await getAccount(ctx, state, data.toDelegate) } state.account.set(entity.id, entity) }, @@ -362,13 +410,64 @@ export const createESTracker = ({ filter: delegateVotesChangedFilter, processor: async ({ ctx, log, state }) => { const data = abi.events.DelegateVotesChanged.decode(log) - const entity = await getAccount(ctx, state, address, data.delegate) - entity.voteBalance = data.newBalance + const entity = await getAccount(ctx, state, data.delegate) + entity.votingPower = data.newBalance state.account.set(entity.id, entity) }, }, ] + const subProcessors: SubProcessor[] = [ + ...eventProcessors, + ...lockupProcessors, + ...yieldProcessors, + ...delegationProcessors, + ].filter((f) => f.enabled) + + const updateBalances = async (ctx: Context, state: State) => { + // Take updated balances from erc20 processors and update our local balances. + const erc20State = await waitForERC20State(ctx, address) + for (const holder of erc20State.holders.values()) { + const account = await getAccount(ctx, state, holder.account) + account.balance = holder.balance + } + } + + const updateAssetBalances = async (ctx: Context, state: State) => { + const assetERC20State = await waitForERC20State(ctx, assetAddress) + for (const holder of assetERC20State.holders.values()) { + const account = await getAccount(ctx, state, holder.account) + account.assetBalance = holder.balance + } + } + + const getAccount = async (ctx: Context, state: State, account: string) => { + const id = `${ctx.chain.id}:${address}:${account}` + const local = state.account.get(id) + if (local) { + return local + } + const existing = await ctx.store.get(ESAccount, { where: { id }, relations: { delegateTo: true } }) + if (existing) { + state.account.set(id, existing) + return existing + } + const created = new ESAccount({ + id, + chainId: ctx.chain.id, + address, + account, + assetBalance: 0n, + stakedBalance: 0n, + balance: 0n, + votingPower: 0n, + delegateTo: null, + delegatesFrom: [], + }) + state.account.set(id, created) + return created + } + return { from, setup(processor: EvmBatchProcessor) { @@ -381,15 +480,12 @@ export const createESTracker = ({ processor.addLog(subProcessor.filter.value) } } - if (yieldType) { - processor.addLog(assetTransferFromFilter.value) - processor.addLog(assetTransferToFilter.value) - } }, async process(ctx: Context) { const state: State = { // State Entities lockup: new Map(), + lockupEvent: new Map(), yield: new Map(), account: new Map(), @@ -421,6 +517,7 @@ export const createESTracker = ({ } } } + await Promise.all([updateBalances(ctx, state), updateAssetBalances(ctx, state)]) await Promise.all([ ctx.store.insert([...state.delegateChanged.values()]), ctx.store.insert([...state.delegateVotesChanged.values()]), @@ -434,27 +531,3 @@ export const createESTracker = ({ }, } } - -const getAccount = async (ctx: Context, state: State, address: string, account: string) => { - const id = `${ctx.chain.id}:${address}:${account}` - const local = state.account.get(id) - if (local) { - return local - } - const existing = await ctx.store.get(ESAccount, { where: { id }, relations: { delegateTo: true } }) - if (existing) { - state.account.set(id, existing) - return existing - } - const created = new ESAccount({ - id, - chainId: ctx.chain.id, - address, - account, - voteBalance: 0n, - delegateTo: null, - delegatesFrom: [], - }) - state.account.set(id, created) - return created -} diff --git a/src/utils/calculateAPY.ts b/src/utils/calculateAPY.ts index 2dceddb2..f2eae462 100644 --- a/src/utils/calculateAPY.ts +++ b/src/utils/calculateAPY.ts @@ -1,11 +1,6 @@ -import { formatEther } from 'viem' +import { formatEther, formatUnits } from 'viem' -export const calculateAPY = ( - from: Date, - to: Date, - fromAmount: bigint, - toAmount: bigint, -) => { +export const calculateAPY = (from: Date, to: Date, fromAmount: bigint, toAmount: bigint) => { if (fromAmount === 0n || toAmount === 0n) { return { apr: 0, apy: 0 } } @@ -13,9 +8,7 @@ export const calculateAPY = ( const diffTime = to.getTime() - from.getTime() const dayDiff = diffTime / (1000 * 60 * 60 * 24) - const apr = - (Number(formatEther(toAmount)) / Number(formatEther(fromAmount)) - 1) * - (365.25 / dayDiff) + const apr = (Number(formatEther(toAmount)) / Number(formatEther(fromAmount)) - 1) * (365.25 / dayDiff) const periods_per_year = 365.25 / Number(dayDiff) const apy = (1 + apr / periods_per_year) ** periods_per_year - 1 @@ -24,3 +17,11 @@ export const calculateAPY = ( apy: apy || 0, } } + +export const convertApyToApr = (apy: number, compoundingPeriods: number = 365.25): number => { + return compoundingPeriods * (Math.pow(1 + apy, 1 / compoundingPeriods) - 1) +} + +export const calculateAPY2 = (fromAmount: bigint, toAmount: bigint) => { + return +formatUnits(((toAmount - fromAmount) * 10n ** 18n) / fromAmount, 18) +} diff --git a/src/utils/state.ts b/src/utils/state.ts index ac257565..1f6305fe 100644 --- a/src/utils/state.ts +++ b/src/utils/state.ts @@ -1,10 +1,6 @@ import { Context } from '@processor' -export const useProcessorState = ( - ctx: Context, - key: string, - defaultValue: T, -) => { +export const useProcessorState = (ctx: Context, key: string, defaultValue?: T) => { const { __state } = ctx let value = __state.get(key) as T | undefined if (!value) { @@ -12,9 +8,25 @@ export const useProcessorState = ( __state.set(key, value) } return [ - value, + value as T, (value: T) => { __state.set(key, value) }, ] as const } + +export const publishProcessorState = (ctx: Context, key: string, state: T) => { + const [, setState] = useProcessorState(ctx, `waitForProcessorState:${key}`) + const [listeners] = useProcessorState<((state: T) => void)[]>(ctx, `waitForProcessorState-listeners:${key}`, []) + setState(state) + listeners.forEach((listener) => listener(state)) +} + +export const waitForProcessorState = (ctx: Context, key: string) => { + return new Promise((resolve) => { + const [state] = useProcessorState(ctx, `waitForProcessorState:${key}`) + if (state) resolve(state) + const [listeners] = useProcessorState<((state: T) => void)[]>(ctx, `waitForProcessorState-listeners:${key}`, []) + listeners.push(resolve) + }) +}