From 78e3d832319431511181654679e3ff03bbe25a82 Mon Sep 17 00:00:00 2001 From: immasandwich Date: Mon, 25 Jul 2022 10:23:01 -0400 Subject: [PATCH] feat(polygon): Add claimable rewards for Polygon MATIC staking (#948) --- .../abis/polygon-validator-share.json | 551 ++++++++ .../contracts/ethers/PolygonValidatorShare.ts | 1123 +++++++++++++++++ src/apps/polygon/contracts/ethers/common.ts | 30 + .../PolygonValidatorShare__factory.ts | 1029 +++++++++++++++ .../contracts/ethers/factories/index.ts | 4 + src/apps/polygon/contracts/ethers/index.ts | 6 + src/apps/polygon/contracts/index.ts | 9 + .../ethereum/polygon.balance-fetcher.ts | 57 +- ...lygon.staking.contract-position-fetcher.ts | 4 +- 9 files changed, 2796 insertions(+), 17 deletions(-) create mode 100644 src/apps/polygon/contracts/abis/polygon-validator-share.json create mode 100644 src/apps/polygon/contracts/ethers/PolygonValidatorShare.ts create mode 100644 src/apps/polygon/contracts/ethers/common.ts create mode 100644 src/apps/polygon/contracts/ethers/factories/PolygonValidatorShare__factory.ts create mode 100644 src/apps/polygon/contracts/ethers/factories/index.ts create mode 100644 src/apps/polygon/contracts/ethers/index.ts diff --git a/src/apps/polygon/contracts/abis/polygon-validator-share.json b/src/apps/polygon/contracts/abis/polygon-validator-share.json new file mode 100644 index 000000000..86464c5fa --- /dev/null +++ b/src/apps/polygon/contracts/abis/polygon-validator-share.json @@ -0,0 +1,551 @@ +[ + { + "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": "previousOwner", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" } + ], + "name": "OwnershipTransferred", + "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" + }, + { + "constant": true, + "inputs": [], + "name": "activeAmount", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "internalType": "address", "name": "owner", "type": "address" }, + { "internalType": "address", "name": "spender", "type": "address" } + ], + "name": "allowance", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "approve", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "owner", "type": "address" }], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "uint256", "name": "_amount", "type": "uint256" }, + { "internalType": "uint256", "name": "_minSharesToMint", "type": "uint256" } + ], + "name": "buyVoucher", + "outputs": [{ "internalType": "uint256", "name": "amountToDeposit", "type": "uint256" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "commissionRate_deprecated", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "subtractedValue", "type": "uint256" } + ], + "name": "decreaseAllowance", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "delegation", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "address payable", "name": "destination", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "drain", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "eventsHub", + "outputs": [{ "internalType": "contract EventsHub", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "exchangeRate", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "user", "type": "address" }], + "name": "getLiquidRewards", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getRewardPerShare", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "user", "type": "address" }], + "name": "getTotalStake", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" }, + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "addedValue", "type": "uint256" } + ], + "name": "increaseAllowance", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "initalRewardPerShare", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "uint256", "name": "_validatorId", "type": "uint256" }, + { "internalType": "address", "name": "_stakingLogger", "type": "address" }, + { "internalType": "address", "name": "_stakeManager", "type": "address" } + ], + "name": "initialize", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "isOwner", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "lastCommissionUpdate_deprecated", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "lock", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "locked", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "user", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "migrateIn", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "user", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "migrateOut", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "minAmount", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "restake", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" }, + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "rewardPerShare", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "uint256", "name": "claimAmount", "type": "uint256" }, + { "internalType": "uint256", "name": "maximumSharesToBurn", "type": "uint256" } + ], + "name": "sellVoucher", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "uint256", "name": "claimAmount", "type": "uint256" }, + { "internalType": "uint256", "name": "maximumSharesToBurn", "type": "uint256" } + ], + "name": "sellVoucher_new", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "uint256", "name": "validatorStake", "type": "uint256" }, + { "internalType": "uint256", "name": "delegatedAmount", "type": "uint256" }, + { "internalType": "uint256", "name": "totalAmountToSlash", "type": "uint256" } + ], + "name": "slash", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "stakeManager", + "outputs": [{ "internalType": "contract IStakeManager", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "stakingLogger", + "outputs": [{ "internalType": "contract StakingInfo", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalStake_deprecated", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "transfer", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "from", "type": "address" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "transferFrom", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], + "name": "transferOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "unbondNonces", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "unbonds", + "outputs": [ + { "internalType": "uint256", "name": "shares", "type": "uint256" }, + { "internalType": "uint256", "name": "withdrawEpoch", "type": "uint256" } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "name": "unbonds_new", + "outputs": [ + { "internalType": "uint256", "name": "shares", "type": "uint256" }, + { "internalType": "uint256", "name": "withdrawEpoch", "type": "uint256" } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "unlock", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "unstakeClaimTokens", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "uint256", "name": "unbondNonce", "type": "uint256" }], + "name": "unstakeClaimTokens_new", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "bool", "name": "_delegation", "type": "bool" }], + "name": "updateDelegation", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "validatorId", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "validatorRewards_deprecated", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "withdrawExchangeRate", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "withdrawPool", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "withdrawRewards", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "withdrawShares", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] diff --git a/src/apps/polygon/contracts/ethers/PolygonValidatorShare.ts b/src/apps/polygon/contracts/ethers/PolygonValidatorShare.ts new file mode 100644 index 000000000..e0a044804 --- /dev/null +++ b/src/apps/polygon/contracts/ethers/PolygonValidatorShare.ts @@ -0,0 +1,1123 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BigNumberish, + BytesLike, + CallOverrides, + ContractTransaction, + Overrides, + PopulatedTransaction, + Signer, + utils, +} from 'ethers'; +import type { FunctionFragment, Result, EventFragment } from '@ethersproject/abi'; +import type { Listener, Provider } from '@ethersproject/providers'; +import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from './common'; + +export interface PolygonValidatorShareInterface extends utils.Interface { + functions: { + 'activeAmount()': FunctionFragment; + 'allowance(address,address)': FunctionFragment; + 'approve(address,uint256)': FunctionFragment; + 'balanceOf(address)': FunctionFragment; + 'buyVoucher(uint256,uint256)': FunctionFragment; + 'commissionRate_deprecated()': FunctionFragment; + 'decreaseAllowance(address,uint256)': FunctionFragment; + 'delegation()': FunctionFragment; + 'drain(address,address,uint256)': FunctionFragment; + 'eventsHub()': FunctionFragment; + 'exchangeRate()': FunctionFragment; + 'getLiquidRewards(address)': FunctionFragment; + 'getRewardPerShare()': FunctionFragment; + 'getTotalStake(address)': FunctionFragment; + 'increaseAllowance(address,uint256)': FunctionFragment; + 'initalRewardPerShare(address)': FunctionFragment; + 'initialize(uint256,address,address)': FunctionFragment; + 'isOwner()': FunctionFragment; + 'lastCommissionUpdate_deprecated()': FunctionFragment; + 'lock()': FunctionFragment; + 'locked()': FunctionFragment; + 'migrateIn(address,uint256)': FunctionFragment; + 'migrateOut(address,uint256)': FunctionFragment; + 'minAmount()': FunctionFragment; + 'owner()': FunctionFragment; + 'renounceOwnership()': FunctionFragment; + 'restake()': FunctionFragment; + 'rewardPerShare()': FunctionFragment; + 'sellVoucher(uint256,uint256)': FunctionFragment; + 'sellVoucher_new(uint256,uint256)': FunctionFragment; + 'slash(uint256,uint256,uint256)': FunctionFragment; + 'stakeManager()': FunctionFragment; + 'stakingLogger()': FunctionFragment; + 'totalStake_deprecated()': FunctionFragment; + 'totalSupply()': FunctionFragment; + 'transfer(address,uint256)': FunctionFragment; + 'transferFrom(address,address,uint256)': FunctionFragment; + 'transferOwnership(address)': FunctionFragment; + 'unbondNonces(address)': FunctionFragment; + 'unbonds(address)': FunctionFragment; + 'unbonds_new(address,uint256)': FunctionFragment; + 'unlock()': FunctionFragment; + 'unstakeClaimTokens()': FunctionFragment; + 'unstakeClaimTokens_new(uint256)': FunctionFragment; + 'updateDelegation(bool)': FunctionFragment; + 'validatorId()': FunctionFragment; + 'validatorRewards_deprecated()': FunctionFragment; + 'withdrawExchangeRate()': FunctionFragment; + 'withdrawPool()': FunctionFragment; + 'withdrawRewards()': FunctionFragment; + 'withdrawShares()': FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | 'activeAmount' + | 'allowance' + | 'approve' + | 'balanceOf' + | 'buyVoucher' + | 'commissionRate_deprecated' + | 'decreaseAllowance' + | 'delegation' + | 'drain' + | 'eventsHub' + | 'exchangeRate' + | 'getLiquidRewards' + | 'getRewardPerShare' + | 'getTotalStake' + | 'increaseAllowance' + | 'initalRewardPerShare' + | 'initialize' + | 'isOwner' + | 'lastCommissionUpdate_deprecated' + | 'lock' + | 'locked' + | 'migrateIn' + | 'migrateOut' + | 'minAmount' + | 'owner' + | 'renounceOwnership' + | 'restake' + | 'rewardPerShare' + | 'sellVoucher' + | 'sellVoucher_new' + | 'slash' + | 'stakeManager' + | 'stakingLogger' + | 'totalStake_deprecated' + | 'totalSupply' + | 'transfer' + | 'transferFrom' + | 'transferOwnership' + | 'unbondNonces' + | 'unbonds' + | 'unbonds_new' + | 'unlock' + | 'unstakeClaimTokens' + | 'unstakeClaimTokens_new' + | 'updateDelegation' + | 'validatorId' + | 'validatorRewards_deprecated' + | 'withdrawExchangeRate' + | 'withdrawPool' + | 'withdrawRewards' + | 'withdrawShares', + ): FunctionFragment; + + encodeFunctionData(functionFragment: 'activeAmount', values?: undefined): string; + encodeFunctionData(functionFragment: 'allowance', values: [string, string]): string; + encodeFunctionData(functionFragment: 'approve', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'balanceOf', values: [string]): string; + encodeFunctionData(functionFragment: 'buyVoucher', values: [BigNumberish, BigNumberish]): string; + encodeFunctionData(functionFragment: 'commissionRate_deprecated', values?: undefined): string; + encodeFunctionData(functionFragment: 'decreaseAllowance', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'delegation', values?: undefined): string; + encodeFunctionData(functionFragment: 'drain', values: [string, string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'eventsHub', values?: undefined): string; + encodeFunctionData(functionFragment: 'exchangeRate', values?: undefined): string; + encodeFunctionData(functionFragment: 'getLiquidRewards', values: [string]): string; + encodeFunctionData(functionFragment: 'getRewardPerShare', values?: undefined): string; + encodeFunctionData(functionFragment: 'getTotalStake', values: [string]): string; + encodeFunctionData(functionFragment: 'increaseAllowance', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'initalRewardPerShare', values: [string]): string; + encodeFunctionData(functionFragment: 'initialize', values: [BigNumberish, string, string]): string; + encodeFunctionData(functionFragment: 'isOwner', values?: undefined): string; + encodeFunctionData(functionFragment: 'lastCommissionUpdate_deprecated', values?: undefined): string; + encodeFunctionData(functionFragment: 'lock', values?: undefined): string; + encodeFunctionData(functionFragment: 'locked', values?: undefined): string; + encodeFunctionData(functionFragment: 'migrateIn', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'migrateOut', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'minAmount', values?: undefined): string; + encodeFunctionData(functionFragment: 'owner', values?: undefined): string; + encodeFunctionData(functionFragment: 'renounceOwnership', values?: undefined): string; + encodeFunctionData(functionFragment: 'restake', values?: undefined): string; + encodeFunctionData(functionFragment: 'rewardPerShare', values?: undefined): string; + encodeFunctionData(functionFragment: 'sellVoucher', values: [BigNumberish, BigNumberish]): string; + encodeFunctionData(functionFragment: 'sellVoucher_new', values: [BigNumberish, BigNumberish]): string; + encodeFunctionData(functionFragment: 'slash', values: [BigNumberish, BigNumberish, BigNumberish]): string; + encodeFunctionData(functionFragment: 'stakeManager', values?: undefined): string; + encodeFunctionData(functionFragment: 'stakingLogger', values?: undefined): string; + encodeFunctionData(functionFragment: 'totalStake_deprecated', values?: undefined): string; + encodeFunctionData(functionFragment: 'totalSupply', values?: undefined): string; + encodeFunctionData(functionFragment: 'transfer', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'transferFrom', values: [string, string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'transferOwnership', values: [string]): string; + encodeFunctionData(functionFragment: 'unbondNonces', values: [string]): string; + encodeFunctionData(functionFragment: 'unbonds', values: [string]): string; + encodeFunctionData(functionFragment: 'unbonds_new', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'unlock', values?: undefined): string; + encodeFunctionData(functionFragment: 'unstakeClaimTokens', values?: undefined): string; + encodeFunctionData(functionFragment: 'unstakeClaimTokens_new', values: [BigNumberish]): string; + encodeFunctionData(functionFragment: 'updateDelegation', values: [boolean]): string; + encodeFunctionData(functionFragment: 'validatorId', values?: undefined): string; + encodeFunctionData(functionFragment: 'validatorRewards_deprecated', values?: undefined): string; + encodeFunctionData(functionFragment: 'withdrawExchangeRate', values?: undefined): string; + encodeFunctionData(functionFragment: 'withdrawPool', values?: undefined): string; + encodeFunctionData(functionFragment: 'withdrawRewards', values?: undefined): string; + encodeFunctionData(functionFragment: 'withdrawShares', values?: undefined): string; + + decodeFunctionResult(functionFragment: 'activeAmount', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'allowance', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'approve', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'balanceOf', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'buyVoucher', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'commissionRate_deprecated', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'decreaseAllowance', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'delegation', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'drain', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'eventsHub', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'exchangeRate', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getLiquidRewards', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getRewardPerShare', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'getTotalStake', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'increaseAllowance', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'initalRewardPerShare', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'initialize', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'isOwner', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'lastCommissionUpdate_deprecated', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'lock', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'locked', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'migrateIn', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'migrateOut', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'minAmount', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'owner', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'renounceOwnership', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'restake', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'rewardPerShare', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'sellVoucher', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'sellVoucher_new', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'slash', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'stakeManager', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'stakingLogger', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'totalStake_deprecated', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'totalSupply', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'transfer', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'transferFrom', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'transferOwnership', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'unbondNonces', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'unbonds', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'unbonds_new', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'unlock', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'unstakeClaimTokens', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'unstakeClaimTokens_new', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'updateDelegation', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'validatorId', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'validatorRewards_deprecated', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'withdrawExchangeRate', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'withdrawPool', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'withdrawRewards', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'withdrawShares', data: BytesLike): Result; + + events: { + 'Approval(address,address,uint256)': EventFragment; + 'OwnershipTransferred(address,address)': EventFragment; + 'Transfer(address,address,uint256)': EventFragment; + }; + + getEvent(nameOrSignatureOrTopic: 'Approval'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'OwnershipTransferred'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Transfer'): EventFragment; +} + +export interface ApprovalEventObject { + owner: string; + spender: string; + value: BigNumber; +} +export type ApprovalEvent = TypedEvent<[string, string, BigNumber], ApprovalEventObject>; + +export type ApprovalEventFilter = TypedEventFilter; + +export interface OwnershipTransferredEventObject { + previousOwner: string; + newOwner: string; +} +export type OwnershipTransferredEvent = TypedEvent<[string, string], OwnershipTransferredEventObject>; + +export type OwnershipTransferredEventFilter = TypedEventFilter; + +export interface TransferEventObject { + from: string; + to: string; + value: BigNumber; +} +export type TransferEvent = TypedEvent<[string, string, BigNumber], TransferEventObject>; + +export type TransferEventFilter = TypedEventFilter; + +export interface PolygonValidatorShare extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: PolygonValidatorShareInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined, + ): Promise>; + + listeners(eventFilter?: TypedEventFilter): Array>; + listeners(eventName?: string): Array; + removeAllListeners(eventFilter: TypedEventFilter): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + activeAmount(overrides?: CallOverrides): Promise<[BigNumber]>; + + allowance(owner: string, spender: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + approve( + spender: string, + value: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + balanceOf(owner: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + buyVoucher( + _amount: BigNumberish, + _minSharesToMint: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + commissionRate_deprecated(overrides?: CallOverrides): Promise<[BigNumber]>; + + decreaseAllowance( + spender: string, + subtractedValue: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + delegation(overrides?: CallOverrides): Promise<[boolean]>; + + drain( + token: string, + destination: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + eventsHub(overrides?: CallOverrides): Promise<[string]>; + + exchangeRate(overrides?: CallOverrides): Promise<[BigNumber]>; + + getLiquidRewards(user: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + getRewardPerShare(overrides?: CallOverrides): Promise<[BigNumber]>; + + getTotalStake(user: string, overrides?: CallOverrides): Promise<[BigNumber, BigNumber]>; + + increaseAllowance( + spender: string, + addedValue: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + initalRewardPerShare(arg0: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + initialize( + _validatorId: BigNumberish, + _stakingLogger: string, + _stakeManager: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + isOwner(overrides?: CallOverrides): Promise<[boolean]>; + + lastCommissionUpdate_deprecated(overrides?: CallOverrides): Promise<[BigNumber]>; + + lock(overrides?: Overrides & { from?: string | Promise }): Promise; + + locked(overrides?: CallOverrides): Promise<[boolean]>; + + migrateIn( + user: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + migrateOut( + user: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + minAmount(overrides?: CallOverrides): Promise<[BigNumber]>; + + owner(overrides?: CallOverrides): Promise<[string]>; + + renounceOwnership(overrides?: Overrides & { from?: string | Promise }): Promise; + + restake(overrides?: Overrides & { from?: string | Promise }): Promise; + + rewardPerShare(overrides?: CallOverrides): Promise<[BigNumber]>; + + sellVoucher( + claimAmount: BigNumberish, + maximumSharesToBurn: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + sellVoucher_new( + claimAmount: BigNumberish, + maximumSharesToBurn: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + slash( + validatorStake: BigNumberish, + delegatedAmount: BigNumberish, + totalAmountToSlash: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + stakeManager(overrides?: CallOverrides): Promise<[string]>; + + stakingLogger(overrides?: CallOverrides): Promise<[string]>; + + totalStake_deprecated(overrides?: CallOverrides): Promise<[BigNumber]>; + + totalSupply(overrides?: CallOverrides): Promise<[BigNumber]>; + + transfer( + to: string, + value: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + transferFrom( + from: string, + to: string, + value: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + transferOwnership( + newOwner: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + unbondNonces(arg0: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + unbonds( + arg0: string, + overrides?: CallOverrides, + ): Promise<[BigNumber, BigNumber] & { shares: BigNumber; withdrawEpoch: BigNumber }>; + + unbonds_new( + arg0: string, + arg1: BigNumberish, + overrides?: CallOverrides, + ): Promise<[BigNumber, BigNumber] & { shares: BigNumber; withdrawEpoch: BigNumber }>; + + unlock(overrides?: Overrides & { from?: string | Promise }): Promise; + + unstakeClaimTokens(overrides?: Overrides & { from?: string | Promise }): Promise; + + unstakeClaimTokens_new( + unbondNonce: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + updateDelegation( + _delegation: boolean, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + validatorId(overrides?: CallOverrides): Promise<[BigNumber]>; + + validatorRewards_deprecated(overrides?: CallOverrides): Promise<[BigNumber]>; + + withdrawExchangeRate(overrides?: CallOverrides): Promise<[BigNumber]>; + + withdrawPool(overrides?: CallOverrides): Promise<[BigNumber]>; + + withdrawRewards(overrides?: Overrides & { from?: string | Promise }): Promise; + + withdrawShares(overrides?: CallOverrides): Promise<[BigNumber]>; + }; + + activeAmount(overrides?: CallOverrides): Promise; + + allowance(owner: string, spender: string, overrides?: CallOverrides): Promise; + + approve( + spender: string, + value: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + balanceOf(owner: string, overrides?: CallOverrides): Promise; + + buyVoucher( + _amount: BigNumberish, + _minSharesToMint: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + commissionRate_deprecated(overrides?: CallOverrides): Promise; + + decreaseAllowance( + spender: string, + subtractedValue: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + delegation(overrides?: CallOverrides): Promise; + + drain( + token: string, + destination: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + eventsHub(overrides?: CallOverrides): Promise; + + exchangeRate(overrides?: CallOverrides): Promise; + + getLiquidRewards(user: string, overrides?: CallOverrides): Promise; + + getRewardPerShare(overrides?: CallOverrides): Promise; + + getTotalStake(user: string, overrides?: CallOverrides): Promise<[BigNumber, BigNumber]>; + + increaseAllowance( + spender: string, + addedValue: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + initalRewardPerShare(arg0: string, overrides?: CallOverrides): Promise; + + initialize( + _validatorId: BigNumberish, + _stakingLogger: string, + _stakeManager: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + isOwner(overrides?: CallOverrides): Promise; + + lastCommissionUpdate_deprecated(overrides?: CallOverrides): Promise; + + lock(overrides?: Overrides & { from?: string | Promise }): Promise; + + locked(overrides?: CallOverrides): Promise; + + migrateIn( + user: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + migrateOut( + user: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + minAmount(overrides?: CallOverrides): Promise; + + owner(overrides?: CallOverrides): Promise; + + renounceOwnership(overrides?: Overrides & { from?: string | Promise }): Promise; + + restake(overrides?: Overrides & { from?: string | Promise }): Promise; + + rewardPerShare(overrides?: CallOverrides): Promise; + + sellVoucher( + claimAmount: BigNumberish, + maximumSharesToBurn: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + sellVoucher_new( + claimAmount: BigNumberish, + maximumSharesToBurn: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + slash( + validatorStake: BigNumberish, + delegatedAmount: BigNumberish, + totalAmountToSlash: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + stakeManager(overrides?: CallOverrides): Promise; + + stakingLogger(overrides?: CallOverrides): Promise; + + totalStake_deprecated(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer( + to: string, + value: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + transferFrom( + from: string, + to: string, + value: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + transferOwnership( + newOwner: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + unbondNonces(arg0: string, overrides?: CallOverrides): Promise; + + unbonds( + arg0: string, + overrides?: CallOverrides, + ): Promise<[BigNumber, BigNumber] & { shares: BigNumber; withdrawEpoch: BigNumber }>; + + unbonds_new( + arg0: string, + arg1: BigNumberish, + overrides?: CallOverrides, + ): Promise<[BigNumber, BigNumber] & { shares: BigNumber; withdrawEpoch: BigNumber }>; + + unlock(overrides?: Overrides & { from?: string | Promise }): Promise; + + unstakeClaimTokens(overrides?: Overrides & { from?: string | Promise }): Promise; + + unstakeClaimTokens_new( + unbondNonce: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + updateDelegation( + _delegation: boolean, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + validatorId(overrides?: CallOverrides): Promise; + + validatorRewards_deprecated(overrides?: CallOverrides): Promise; + + withdrawExchangeRate(overrides?: CallOverrides): Promise; + + withdrawPool(overrides?: CallOverrides): Promise; + + withdrawRewards(overrides?: Overrides & { from?: string | Promise }): Promise; + + withdrawShares(overrides?: CallOverrides): Promise; + + callStatic: { + activeAmount(overrides?: CallOverrides): Promise; + + allowance(owner: string, spender: string, overrides?: CallOverrides): Promise; + + approve(spender: string, value: BigNumberish, overrides?: CallOverrides): Promise; + + balanceOf(owner: string, overrides?: CallOverrides): Promise; + + buyVoucher(_amount: BigNumberish, _minSharesToMint: BigNumberish, overrides?: CallOverrides): Promise; + + commissionRate_deprecated(overrides?: CallOverrides): Promise; + + decreaseAllowance(spender: string, subtractedValue: BigNumberish, overrides?: CallOverrides): Promise; + + delegation(overrides?: CallOverrides): Promise; + + drain(token: string, destination: string, amount: BigNumberish, overrides?: CallOverrides): Promise; + + eventsHub(overrides?: CallOverrides): Promise; + + exchangeRate(overrides?: CallOverrides): Promise; + + getLiquidRewards(user: string, overrides?: CallOverrides): Promise; + + getRewardPerShare(overrides?: CallOverrides): Promise; + + getTotalStake(user: string, overrides?: CallOverrides): Promise<[BigNumber, BigNumber]>; + + increaseAllowance(spender: string, addedValue: BigNumberish, overrides?: CallOverrides): Promise; + + initalRewardPerShare(arg0: string, overrides?: CallOverrides): Promise; + + initialize( + _validatorId: BigNumberish, + _stakingLogger: string, + _stakeManager: string, + overrides?: CallOverrides, + ): Promise; + + isOwner(overrides?: CallOverrides): Promise; + + lastCommissionUpdate_deprecated(overrides?: CallOverrides): Promise; + + lock(overrides?: CallOverrides): Promise; + + locked(overrides?: CallOverrides): Promise; + + migrateIn(user: string, amount: BigNumberish, overrides?: CallOverrides): Promise; + + migrateOut(user: string, amount: BigNumberish, overrides?: CallOverrides): Promise; + + minAmount(overrides?: CallOverrides): Promise; + + owner(overrides?: CallOverrides): Promise; + + renounceOwnership(overrides?: CallOverrides): Promise; + + restake(overrides?: CallOverrides): Promise<[BigNumber, BigNumber]>; + + rewardPerShare(overrides?: CallOverrides): Promise; + + sellVoucher(claimAmount: BigNumberish, maximumSharesToBurn: BigNumberish, overrides?: CallOverrides): Promise; + + sellVoucher_new( + claimAmount: BigNumberish, + maximumSharesToBurn: BigNumberish, + overrides?: CallOverrides, + ): Promise; + + slash( + validatorStake: BigNumberish, + delegatedAmount: BigNumberish, + totalAmountToSlash: BigNumberish, + overrides?: CallOverrides, + ): Promise; + + stakeManager(overrides?: CallOverrides): Promise; + + stakingLogger(overrides?: CallOverrides): Promise; + + totalStake_deprecated(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer(to: string, value: BigNumberish, overrides?: CallOverrides): Promise; + + transferFrom(from: string, to: string, value: BigNumberish, overrides?: CallOverrides): Promise; + + transferOwnership(newOwner: string, overrides?: CallOverrides): Promise; + + unbondNonces(arg0: string, overrides?: CallOverrides): Promise; + + unbonds( + arg0: string, + overrides?: CallOverrides, + ): Promise<[BigNumber, BigNumber] & { shares: BigNumber; withdrawEpoch: BigNumber }>; + + unbonds_new( + arg0: string, + arg1: BigNumberish, + overrides?: CallOverrides, + ): Promise<[BigNumber, BigNumber] & { shares: BigNumber; withdrawEpoch: BigNumber }>; + + unlock(overrides?: CallOverrides): Promise; + + unstakeClaimTokens(overrides?: CallOverrides): Promise; + + unstakeClaimTokens_new(unbondNonce: BigNumberish, overrides?: CallOverrides): Promise; + + updateDelegation(_delegation: boolean, overrides?: CallOverrides): Promise; + + validatorId(overrides?: CallOverrides): Promise; + + validatorRewards_deprecated(overrides?: CallOverrides): Promise; + + withdrawExchangeRate(overrides?: CallOverrides): Promise; + + withdrawPool(overrides?: CallOverrides): Promise; + + withdrawRewards(overrides?: CallOverrides): Promise; + + withdrawShares(overrides?: CallOverrides): Promise; + }; + + filters: { + 'Approval(address,address,uint256)'( + owner?: string | null, + spender?: string | null, + value?: null, + ): ApprovalEventFilter; + Approval(owner?: string | null, spender?: string | null, value?: null): ApprovalEventFilter; + + 'OwnershipTransferred(address,address)'( + previousOwner?: string | null, + newOwner?: string | null, + ): OwnershipTransferredEventFilter; + OwnershipTransferred(previousOwner?: string | null, newOwner?: string | null): OwnershipTransferredEventFilter; + + 'Transfer(address,address,uint256)'(from?: string | null, to?: string | null, value?: null): TransferEventFilter; + Transfer(from?: string | null, to?: string | null, value?: null): TransferEventFilter; + }; + + estimateGas: { + activeAmount(overrides?: CallOverrides): Promise; + + allowance(owner: string, spender: string, overrides?: CallOverrides): Promise; + + approve( + spender: string, + value: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + balanceOf(owner: string, overrides?: CallOverrides): Promise; + + buyVoucher( + _amount: BigNumberish, + _minSharesToMint: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + commissionRate_deprecated(overrides?: CallOverrides): Promise; + + decreaseAllowance( + spender: string, + subtractedValue: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + delegation(overrides?: CallOverrides): Promise; + + drain( + token: string, + destination: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + eventsHub(overrides?: CallOverrides): Promise; + + exchangeRate(overrides?: CallOverrides): Promise; + + getLiquidRewards(user: string, overrides?: CallOverrides): Promise; + + getRewardPerShare(overrides?: CallOverrides): Promise; + + getTotalStake(user: string, overrides?: CallOverrides): Promise; + + increaseAllowance( + spender: string, + addedValue: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + initalRewardPerShare(arg0: string, overrides?: CallOverrides): Promise; + + initialize( + _validatorId: BigNumberish, + _stakingLogger: string, + _stakeManager: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + isOwner(overrides?: CallOverrides): Promise; + + lastCommissionUpdate_deprecated(overrides?: CallOverrides): Promise; + + lock(overrides?: Overrides & { from?: string | Promise }): Promise; + + locked(overrides?: CallOverrides): Promise; + + migrateIn( + user: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + migrateOut( + user: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + minAmount(overrides?: CallOverrides): Promise; + + owner(overrides?: CallOverrides): Promise; + + renounceOwnership(overrides?: Overrides & { from?: string | Promise }): Promise; + + restake(overrides?: Overrides & { from?: string | Promise }): Promise; + + rewardPerShare(overrides?: CallOverrides): Promise; + + sellVoucher( + claimAmount: BigNumberish, + maximumSharesToBurn: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + sellVoucher_new( + claimAmount: BigNumberish, + maximumSharesToBurn: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + slash( + validatorStake: BigNumberish, + delegatedAmount: BigNumberish, + totalAmountToSlash: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + stakeManager(overrides?: CallOverrides): Promise; + + stakingLogger(overrides?: CallOverrides): Promise; + + totalStake_deprecated(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer( + to: string, + value: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + transferFrom( + from: string, + to: string, + value: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + transferOwnership( + newOwner: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + unbondNonces(arg0: string, overrides?: CallOverrides): Promise; + + unbonds(arg0: string, overrides?: CallOverrides): Promise; + + unbonds_new(arg0: string, arg1: BigNumberish, overrides?: CallOverrides): Promise; + + unlock(overrides?: Overrides & { from?: string | Promise }): Promise; + + unstakeClaimTokens(overrides?: Overrides & { from?: string | Promise }): Promise; + + unstakeClaimTokens_new( + unbondNonce: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + updateDelegation( + _delegation: boolean, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + validatorId(overrides?: CallOverrides): Promise; + + validatorRewards_deprecated(overrides?: CallOverrides): Promise; + + withdrawExchangeRate(overrides?: CallOverrides): Promise; + + withdrawPool(overrides?: CallOverrides): Promise; + + withdrawRewards(overrides?: Overrides & { from?: string | Promise }): Promise; + + withdrawShares(overrides?: CallOverrides): Promise; + }; + + populateTransaction: { + activeAmount(overrides?: CallOverrides): Promise; + + allowance(owner: string, spender: string, overrides?: CallOverrides): Promise; + + approve( + spender: string, + value: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + balanceOf(owner: string, overrides?: CallOverrides): Promise; + + buyVoucher( + _amount: BigNumberish, + _minSharesToMint: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + commissionRate_deprecated(overrides?: CallOverrides): Promise; + + decreaseAllowance( + spender: string, + subtractedValue: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + delegation(overrides?: CallOverrides): Promise; + + drain( + token: string, + destination: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + eventsHub(overrides?: CallOverrides): Promise; + + exchangeRate(overrides?: CallOverrides): Promise; + + getLiquidRewards(user: string, overrides?: CallOverrides): Promise; + + getRewardPerShare(overrides?: CallOverrides): Promise; + + getTotalStake(user: string, overrides?: CallOverrides): Promise; + + increaseAllowance( + spender: string, + addedValue: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + initalRewardPerShare(arg0: string, overrides?: CallOverrides): Promise; + + initialize( + _validatorId: BigNumberish, + _stakingLogger: string, + _stakeManager: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + isOwner(overrides?: CallOverrides): Promise; + + lastCommissionUpdate_deprecated(overrides?: CallOverrides): Promise; + + lock(overrides?: Overrides & { from?: string | Promise }): Promise; + + locked(overrides?: CallOverrides): Promise; + + migrateIn( + user: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + migrateOut( + user: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + minAmount(overrides?: CallOverrides): Promise; + + owner(overrides?: CallOverrides): Promise; + + renounceOwnership(overrides?: Overrides & { from?: string | Promise }): Promise; + + restake(overrides?: Overrides & { from?: string | Promise }): Promise; + + rewardPerShare(overrides?: CallOverrides): Promise; + + sellVoucher( + claimAmount: BigNumberish, + maximumSharesToBurn: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + sellVoucher_new( + claimAmount: BigNumberish, + maximumSharesToBurn: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + slash( + validatorStake: BigNumberish, + delegatedAmount: BigNumberish, + totalAmountToSlash: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + stakeManager(overrides?: CallOverrides): Promise; + + stakingLogger(overrides?: CallOverrides): Promise; + + totalStake_deprecated(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer( + to: string, + value: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + transferFrom( + from: string, + to: string, + value: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + transferOwnership( + newOwner: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + unbondNonces(arg0: string, overrides?: CallOverrides): Promise; + + unbonds(arg0: string, overrides?: CallOverrides): Promise; + + unbonds_new(arg0: string, arg1: BigNumberish, overrides?: CallOverrides): Promise; + + unlock(overrides?: Overrides & { from?: string | Promise }): Promise; + + unstakeClaimTokens(overrides?: Overrides & { from?: string | Promise }): Promise; + + unstakeClaimTokens_new( + unbondNonce: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + updateDelegation( + _delegation: boolean, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + validatorId(overrides?: CallOverrides): Promise; + + validatorRewards_deprecated(overrides?: CallOverrides): Promise; + + withdrawExchangeRate(overrides?: CallOverrides): Promise; + + withdrawPool(overrides?: CallOverrides): Promise; + + withdrawRewards(overrides?: Overrides & { from?: string | Promise }): Promise; + + withdrawShares(overrides?: CallOverrides): Promise; + }; +} diff --git a/src/apps/polygon/contracts/ethers/common.ts b/src/apps/polygon/contracts/ethers/common.ts new file mode 100644 index 000000000..6cfb10425 --- /dev/null +++ b/src/apps/polygon/contracts/ethers/common.ts @@ -0,0 +1,30 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { Listener } from '@ethersproject/providers'; +import type { Event, EventFilter } from 'ethers'; + +export interface TypedEvent = any, TArgsObject = any> extends Event { + args: TArgsArray & TArgsObject; +} + +export interface TypedEventFilter<_TEvent extends TypedEvent> extends EventFilter {} + +export interface TypedListener { + (...listenerArg: [...__TypechainArgsArray, TEvent]): void; +} + +type __TypechainArgsArray = T extends TypedEvent ? U : never; + +export interface OnEvent { + (eventFilter: TypedEventFilter, listener: TypedListener): TRes; + (eventName: string, listener: Listener): TRes; +} + +export type MinEthersFactory = { + deploy(...a: ARGS[]): Promise; +}; + +export type GetContractTypeFromFactory = F extends MinEthersFactory ? C : never; + +export type GetARGsTypeFromFactory = F extends MinEthersFactory ? Parameters : never; diff --git a/src/apps/polygon/contracts/ethers/factories/PolygonValidatorShare__factory.ts b/src/apps/polygon/contracts/ethers/factories/PolygonValidatorShare__factory.ts new file mode 100644 index 000000000..fb02631ac --- /dev/null +++ b/src/apps/polygon/contracts/ethers/factories/PolygonValidatorShare__factory.ts @@ -0,0 +1,1029 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { PolygonValidatorShare, PolygonValidatorShareInterface } from '../PolygonValidatorShare'; + +const _abi = [ + { + 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: 'previousOwner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'OwnershipTransferred', + 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', + }, + { + constant: true, + inputs: [], + name: 'activeAmount', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [ + { + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + ], + name: 'allowance', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + ], + name: 'approve', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [ + { + internalType: 'address', + name: 'owner', + type: 'address', + }, + ], + name: 'balanceOf', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { + internalType: 'uint256', + name: '_amount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '_minSharesToMint', + type: 'uint256', + }, + ], + name: 'buyVoucher', + outputs: [ + { + internalType: 'uint256', + name: 'amountToDeposit', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'commissionRate_deprecated', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'subtractedValue', + type: 'uint256', + }, + ], + name: 'decreaseAllowance', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'delegation', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { + internalType: 'address', + name: 'token', + type: 'address', + }, + { + internalType: 'address payable', + name: 'destination', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'drain', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'eventsHub', + outputs: [ + { + internalType: 'contract EventsHub', + name: '', + type: 'address', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'exchangeRate', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [ + { + internalType: 'address', + name: 'user', + type: 'address', + }, + ], + name: 'getLiquidRewards', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'getRewardPerShare', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [ + { + internalType: 'address', + name: 'user', + type: 'address', + }, + ], + name: 'getTotalStake', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'addedValue', + type: 'uint256', + }, + ], + name: 'increaseAllowance', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'initalRewardPerShare', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { + internalType: 'uint256', + name: '_validatorId', + type: 'uint256', + }, + { + internalType: 'address', + name: '_stakingLogger', + type: 'address', + }, + { + internalType: 'address', + name: '_stakeManager', + type: 'address', + }, + ], + name: 'initialize', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'isOwner', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'lastCommissionUpdate_deprecated', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [], + name: 'lock', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'locked', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { + internalType: 'address', + name: 'user', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'migrateIn', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: false, + inputs: [ + { + internalType: 'address', + name: 'user', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'migrateOut', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'minAmount', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'owner', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [], + name: 'renounceOwnership', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: false, + inputs: [], + name: 'restake', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'rewardPerShare', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { + internalType: 'uint256', + name: 'claimAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'maximumSharesToBurn', + type: 'uint256', + }, + ], + name: 'sellVoucher', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: false, + inputs: [ + { + internalType: 'uint256', + name: 'claimAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'maximumSharesToBurn', + type: 'uint256', + }, + ], + name: 'sellVoucher_new', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: false, + inputs: [ + { + internalType: 'uint256', + name: 'validatorStake', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'delegatedAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'totalAmountToSlash', + type: 'uint256', + }, + ], + name: 'slash', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'stakeManager', + outputs: [ + { + internalType: 'contract IStakeManager', + name: '', + type: 'address', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'stakingLogger', + outputs: [ + { + internalType: 'contract StakingInfo', + name: '', + type: 'address', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'totalStake_deprecated', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'totalSupply', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + ], + name: 'transfer', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: false, + inputs: [ + { + internalType: 'address', + name: 'from', + type: 'address', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + ], + name: 'transferFrom', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: false, + inputs: [ + { + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'transferOwnership', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'unbondNonces', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'unbonds', + outputs: [ + { + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'withdrawEpoch', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + name: 'unbonds_new', + outputs: [ + { + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'withdrawEpoch', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [], + name: 'unlock', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: false, + inputs: [], + name: 'unstakeClaimTokens', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: false, + inputs: [ + { + internalType: 'uint256', + name: 'unbondNonce', + type: 'uint256', + }, + ], + name: 'unstakeClaimTokens_new', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: false, + inputs: [ + { + internalType: 'bool', + name: '_delegation', + type: 'bool', + }, + ], + name: 'updateDelegation', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'validatorId', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'validatorRewards_deprecated', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'withdrawExchangeRate', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'withdrawPool', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [], + name: 'withdrawRewards', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'withdrawShares', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, +]; + +export class PolygonValidatorShare__factory { + static readonly abi = _abi; + static createInterface(): PolygonValidatorShareInterface { + return new utils.Interface(_abi) as PolygonValidatorShareInterface; + } + static connect(address: string, signerOrProvider: Signer | Provider): PolygonValidatorShare { + return new Contract(address, _abi, signerOrProvider) as PolygonValidatorShare; + } +} diff --git a/src/apps/polygon/contracts/ethers/factories/index.ts b/src/apps/polygon/contracts/ethers/factories/index.ts new file mode 100644 index 000000000..2d7d925ab --- /dev/null +++ b/src/apps/polygon/contracts/ethers/factories/index.ts @@ -0,0 +1,4 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export { PolygonValidatorShare__factory } from './PolygonValidatorShare__factory'; diff --git a/src/apps/polygon/contracts/ethers/index.ts b/src/apps/polygon/contracts/ethers/index.ts new file mode 100644 index 000000000..a4139ab3c --- /dev/null +++ b/src/apps/polygon/contracts/ethers/index.ts @@ -0,0 +1,6 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export type { PolygonValidatorShare } from './PolygonValidatorShare'; +export * as factories from './factories'; +export { PolygonValidatorShare__factory } from './factories/PolygonValidatorShare__factory'; diff --git a/src/apps/polygon/contracts/index.ts b/src/apps/polygon/contracts/index.ts index 4c2c657c6..0f5140775 100644 --- a/src/apps/polygon/contracts/index.ts +++ b/src/apps/polygon/contracts/index.ts @@ -3,6 +3,9 @@ import { Injectable, Inject } from '@nestjs/common'; import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface'; import { ContractFactory } from '~contract/contracts'; import { Network } from '~types/network.interface'; + +import { PolygonValidatorShare__factory } from './ethers'; + // eslint-disable-next-line type ContractOpts = { address: string; network: Network }; @@ -11,4 +14,10 @@ export class PolygonContractFactory extends ContractFactory { constructor(@Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit) { super((network: Network) => appToolkit.getNetworkProvider(network)); } + + polygonValidatorShare({ address, network }: ContractOpts) { + return PolygonValidatorShare__factory.connect(address, this.appToolkit.getNetworkProvider(network)); + } } + +export type { PolygonValidatorShare } from './ethers'; diff --git a/src/apps/polygon/ethereum/polygon.balance-fetcher.ts b/src/apps/polygon/ethereum/polygon.balance-fetcher.ts index 9247f3751..ea134d06b 100644 --- a/src/apps/polygon/ethereum/polygon.balance-fetcher.ts +++ b/src/apps/polygon/ethereum/polygon.balance-fetcher.ts @@ -8,8 +8,10 @@ import { Register } from '~app-toolkit/decorators'; import { presentBalanceFetcherResponse } from '~app-toolkit/helpers/presentation/balance-fetcher-response.present'; import { BalanceFetcher } from '~balance/balance-fetcher.interface'; import { ContractPositionBalance } from '~position/position-balance.interface'; +import { isClaimable, isSupplied } from '~position/position.utils'; import { Network } from '~types/network.interface'; +import { PolygonContractFactory } from '../contracts'; import { POLYGON_DEFINITION } from '../polygon.definition'; import { PolygonStakingContractPositionDataProps } from './polygon.staking.contract-position-fetcher'; @@ -36,9 +38,14 @@ const network = Network.ETHEREUM_MAINNET; @Register.BalanceFetcher(POLYGON_DEFINITION.id, network) export class EthereumPolygonBalanceFetcher implements BalanceFetcher { - constructor(@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit) {} + constructor( + @Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit, + @Inject(PolygonContractFactory) private readonly polygonContractFactory: PolygonContractFactory, + ) {} async getDelegatedBalances(address: string) { + const multicall = this.appToolkit.getMulticall(network); + const data = await this.appToolkit.helpers.theGraphHelper.gqlFetchAll({ endpoint: GQL_ENDPOINT, query: DELEGATED_MATIC_QUERY, @@ -54,20 +61,40 @@ export class EthereumPolygonBalanceFetcher implements BalanceFetcher { network, }); - const balances = data.delegators.map(delegator => { - const position = positions.find(v => v.dataProps.validatorId === Number(delegator.validatorId)); - if (!position) return null; - - const tokens = [drillBalance(position.tokens[0], delegator.delegatedAmount)]; - const balanceUSD = sumBy(tokens, v => v.balanceUSD); - const balance: ContractPositionBalance = { - ...position, - tokens, - balanceUSD, - }; - - return balance; - }); + const balances = await Promise.all( + data.delegators.map(async delegator => { + const position = positions.find(v => v.dataProps.validatorId === Number(delegator.validatorId)); + if (!position) return null; + + const contract = this.polygonContractFactory.polygonValidatorShare({ + address: position.dataProps.validatorShareAddress, + network, + }); + + const [balanceRaw, claimableBalanceRaw] = await Promise.all([ + multicall.wrap(contract).balanceOf(address), + multicall.wrap(contract).getLiquidRewards(address), + ]); + + const suppliedToken = position.tokens.find(isSupplied); + const claimableToken = position.tokens.find(isClaimable); + if (!suppliedToken || !claimableToken) return null; + + const tokens = [ + drillBalance(suppliedToken, balanceRaw.toString()), + drillBalance(claimableToken, claimableBalanceRaw.toString()), + ]; + + const balanceUSD = sumBy(tokens, v => v.balanceUSD); + const balance: ContractPositionBalance = { + ...position, + tokens, + balanceUSD, + }; + + return balance; + }), + ); return compact(balances); } diff --git a/src/apps/polygon/ethereum/polygon.staking.contract-position-fetcher.ts b/src/apps/polygon/ethereum/polygon.staking.contract-position-fetcher.ts index 40659afd9..b9a8eecc4 100644 --- a/src/apps/polygon/ethereum/polygon.staking.contract-position-fetcher.ts +++ b/src/apps/polygon/ethereum/polygon.staking.contract-position-fetcher.ts @@ -8,7 +8,7 @@ import { CacheOnInterval } from '~cache/cache-on-interval.decorator'; import { ContractType } from '~position/contract.interface'; import { PositionFetcher } from '~position/position-fetcher.interface'; import { ContractPosition } from '~position/position.interface'; -import { supplied } from '~position/position.utils'; +import { claimable, supplied } from '~position/position.utils'; import { Network } from '~types/network.interface'; import { POLYGON_DEFINITION } from '../polygon.definition'; @@ -73,7 +73,7 @@ export class EthereumPolygonStakingContractPositionFetcher implements PositionFe const maticPosStakingAddress = '0x5e3ef299fddf15eaa0432e6e66473ace8c13d908'; const maticAddress = '0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0'; const maticToken = baseTokens.find(v => v.address === maticAddress)!; - const tokens = [supplied(maticToken)]; + const tokens = [supplied(maticToken), claimable(maticToken)]; const label = `Delegated ${getLabelFromToken(maticToken)}: ${validator.name} (ID: ${validator.id})`; const images = getImagesFromToken(maticToken);