From bd6dc481f0264ed827b23e4cb1fe3936ad5baadf Mon Sep 17 00:00:00 2001 From: William Poulin Date: Thu, 14 Dec 2023 17:33:44 -0500 Subject: [PATCH] feat(gains-networks): Add staking positions (6.4.1) (#3154) --- ...rk.staking-v2.contract-position-fetcher.ts | 10 + ...rk.staking-v2.contract-position-fetcher.ts | 61 ++ .../abis/gains-network-staking-v-2.json | 414 ++++++++ .../contracts/viem.contract-factory.ts | 4 + .../contracts/viem/GainsNetworkStakingV2.ts | 974 ++++++++++++++++++ .../gains-network/contracts/viem/index.ts | 2 + .../gains-network/gains-network.module.ts | 4 + ...rk.staking-v2.contract-position-fetcher.ts | 10 + 8 files changed, 1479 insertions(+) create mode 100644 src/apps/gains-network/arbitrum/gains-network.staking-v2.contract-position-fetcher.ts create mode 100644 src/apps/gains-network/common/gains-network.staking-v2.contract-position-fetcher.ts create mode 100644 src/apps/gains-network/contracts/abis/gains-network-staking-v-2.json create mode 100644 src/apps/gains-network/contracts/viem/GainsNetworkStakingV2.ts create mode 100644 src/apps/gains-network/polygon/gains-network.staking-v2.contract-position-fetcher.ts diff --git a/src/apps/gains-network/arbitrum/gains-network.staking-v2.contract-position-fetcher.ts b/src/apps/gains-network/arbitrum/gains-network.staking-v2.contract-position-fetcher.ts new file mode 100644 index 000000000..6eaba0e39 --- /dev/null +++ b/src/apps/gains-network/arbitrum/gains-network.staking-v2.contract-position-fetcher.ts @@ -0,0 +1,10 @@ +import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator'; + +import { GainsNetworkStakingV2ContractPositionFetcher } from '../common/gains-network.staking-v2.contract-position-fetcher'; + +@PositionTemplate() +export class ArbitrumGainsNetworkStakingV2ContractPositionFetcher extends GainsNetworkStakingV2ContractPositionFetcher { + groupLabel = 'Staking'; + + stakingContractAddress = '0x7edde7e5900633f698eab0dbc97de640fc5dc015'; +} diff --git a/src/apps/gains-network/common/gains-network.staking-v2.contract-position-fetcher.ts b/src/apps/gains-network/common/gains-network.staking-v2.contract-position-fetcher.ts new file mode 100644 index 000000000..f8d436321 --- /dev/null +++ b/src/apps/gains-network/common/gains-network.staking-v2.contract-position-fetcher.ts @@ -0,0 +1,61 @@ +import { Inject } from '@nestjs/common'; + +import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface'; +import { getLabelFromToken } from '~app-toolkit/helpers/presentation/image.present'; +import { MetaType } from '~position/position.interface'; +import { ContractPositionTemplatePositionFetcher } from '~position/template/contract-position.template.position-fetcher'; +import { + GetDisplayPropsParams, + GetTokenBalancesParams, + GetTokenDefinitionsParams, +} from '~position/template/contract-position.template.types'; + +import { GainsNetworkViemContractFactory } from '../contracts'; +import { GainsNetworkStakingV2 } from '../contracts/viem'; + +export abstract class GainsNetworkStakingV2ContractPositionFetcher extends ContractPositionTemplatePositionFetcher { + abstract stakingContractAddress: string; + + constructor( + @Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit, + @Inject(GainsNetworkViemContractFactory) protected readonly contractFactory: GainsNetworkViemContractFactory, + ) { + super(appToolkit); + } + + getContract(address: string) { + return this.contractFactory.gainsNetworkStakingV2({ address, network: this.network }); + } + + async getDefinitions() { + return [{ address: this.stakingContractAddress }]; + } + + async getTokenDefinitions({ contract }: GetTokenDefinitionsParams) { + return [ + { + metaType: MetaType.SUPPLIED, + address: await contract.read.gns(), + network: this.network, + }, + { + metaType: MetaType.CLAIMABLE, + address: await contract.read.dai(), + network: this.network, + }, + ]; + } + + async getLabel({ contractPosition }: GetDisplayPropsParams) { + return getLabelFromToken(contractPosition.tokens[0]); + } + + async getTokenBalancesPerPosition({ address, contract }: GetTokenBalancesParams) { + const [suppliedBalance, claimable] = await Promise.all([ + contract.read.stakers([address]), + contract.read.pendingRewardDai([address]), + ]); + + return [suppliedBalance[0], claimable]; + } +} diff --git a/src/apps/gains-network/contracts/abis/gains-network-staking-v-2.json b/src/apps/gains-network/contracts/abis/gains-network-staking-v-2.json new file mode 100644 index 000000000..8c98dd590 --- /dev/null +++ b/src/apps/gains-network/contracts/abis/gains-network-staking-v-2.json @@ -0,0 +1,414 @@ +[ + { "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, + { + "anonymous": false, + "inputs": [{ "indexed": false, "internalType": "uint256", "name": "amountDai", "type": "uint256" }], + "name": "DaiDistributed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "staker", "type": "address" }, + { "indexed": false, "internalType": "uint128", "name": "amountDai", "type": "uint128" } + ], + "name": "DaiHarvested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "staker", "type": "address" }, + { "indexed": false, "internalType": "uint256[]", "name": "ids", "type": "uint256[]" }, + { "indexed": false, "internalType": "uint128", "name": "amountDai", "type": "uint128" } + ], + "name": "DaiHarvestedFromUnlock", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "staker", "type": "address" }, + { "indexed": false, "internalType": "uint256[]", "name": "ids", "type": "uint256[]" }, + { "indexed": false, "internalType": "uint128", "name": "amountGns", "type": "uint128" } + ], + "name": "GnsClaimed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "staker", "type": "address" }, + { "indexed": false, "internalType": "uint128", "name": "amountGns", "type": "uint128" } + ], + "name": "GnsStaked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "staker", "type": "address" }, + { "indexed": false, "internalType": "uint128", "name": "amountGns", "type": "uint128" } + ], + "name": "GnsUnstaked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [{ "indexed": false, "internalType": "uint8", "name": "version", "type": "uint8" }], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" } + ], + "name": "OwnershipTransferStarted", + "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": "manager", "type": "address" }, + { "indexed": false, "internalType": "bool", "name": "authorized", "type": "bool" } + ], + "name": "UnlockManagerUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "staker", "type": "address" }, + { "indexed": true, "internalType": "uint256", "name": "index", "type": "uint256" } + ], + "name": "UnlockScheduleRevoked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "staker", "type": "address" }, + { "indexed": true, "internalType": "uint256", "name": "index", "type": "uint256" }, + { + "components": [ + { "internalType": "uint128", "name": "totalGns", "type": "uint128" }, + { "internalType": "uint128", "name": "claimedGns", "type": "uint128" }, + { "internalType": "uint128", "name": "debtDai", "type": "uint128" }, + { "internalType": "uint48", "name": "start", "type": "uint48" }, + { "internalType": "uint48", "name": "duration", "type": "uint48" }, + { "internalType": "bool", "name": "revocable", "type": "bool" }, + { "internalType": "enum GNSStakingInterfaceV6_4_1.UnlockType", "name": "unlockType", "type": "uint8" }, + { "internalType": "uint16", "name": "__placeholder", "type": "uint16" } + ], + "indexed": false, + "internalType": "struct GNSStakingInterfaceV6_4_1.UnlockSchedule", + "name": "schedule", + "type": "tuple" + } + ], + "name": "UnlockScheduled", + "type": "event" + }, + { + "inputs": [], + "name": "accDaiPerToken", + "outputs": [{ "internalType": "uint128", "name": "", "type": "uint128" }], + "stateMutability": "view", + "type": "function" + }, + { "inputs": [], "name": "acceptOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [{ "internalType": "uint256[]", "name": "_ids", "type": "uint256[]" }], + "name": "claimUnlockedGns", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { "internalType": "uint128", "name": "totalGns", "type": "uint128" }, + { "internalType": "uint48", "name": "start", "type": "uint48" }, + { "internalType": "uint48", "name": "duration", "type": "uint48" }, + { "internalType": "bool", "name": "revocable", "type": "bool" }, + { "internalType": "enum GNSStakingInterfaceV6_4_1.UnlockType", "name": "unlockType", "type": "uint8" } + ], + "internalType": "struct GNSStakingInterfaceV6_4_1.UnlockScheduleInput", + "name": "_schedule", + "type": "tuple" + }, + { "internalType": "address", "name": "_staker", "type": "address" } + ], + "name": "createUnlockSchedule", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "dai", + "outputs": [{ "internalType": "contract TokenInterfaceV5", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "_amountDai", "type": "uint256" }], + "name": "distributeRewardDai", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_staker", "type": "address" }, + { "internalType": "uint256", "name": "_index", "type": "uint256" } + ], + "name": "getUnlockSchedules", + "outputs": [ + { + "components": [ + { "internalType": "uint128", "name": "totalGns", "type": "uint128" }, + { "internalType": "uint128", "name": "claimedGns", "type": "uint128" }, + { "internalType": "uint128", "name": "debtDai", "type": "uint128" }, + { "internalType": "uint48", "name": "start", "type": "uint48" }, + { "internalType": "uint48", "name": "duration", "type": "uint48" }, + { "internalType": "bool", "name": "revocable", "type": "bool" }, + { "internalType": "enum GNSStakingInterfaceV6_4_1.UnlockType", "name": "unlockType", "type": "uint8" }, + { "internalType": "uint16", "name": "__placeholder", "type": "uint16" } + ], + "internalType": "struct GNSStakingInterfaceV6_4_1.UnlockSchedule", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "_staker", "type": "address" }], + "name": "getUnlockSchedules", + "outputs": [ + { + "components": [ + { "internalType": "uint128", "name": "totalGns", "type": "uint128" }, + { "internalType": "uint128", "name": "claimedGns", "type": "uint128" }, + { "internalType": "uint128", "name": "debtDai", "type": "uint128" }, + { "internalType": "uint48", "name": "start", "type": "uint48" }, + { "internalType": "uint48", "name": "duration", "type": "uint48" }, + { "internalType": "bool", "name": "revocable", "type": "bool" }, + { "internalType": "enum GNSStakingInterfaceV6_4_1.UnlockType", "name": "unlockType", "type": "uint8" }, + { "internalType": "uint16", "name": "__placeholder", "type": "uint16" } + ], + "internalType": "struct GNSStakingInterfaceV6_4_1.UnlockSchedule[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "gns", + "outputs": [{ "internalType": "contract TokenInterfaceV5", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "gnsBalance", + "outputs": [{ "internalType": "uint128", "name": "", "type": "uint128" }], + "stateMutability": "view", + "type": "function" + }, + { "inputs": [], "name": "harvestDai", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [{ "internalType": "uint256[]", "name": "_ids", "type": "uint256[]" }], + "name": "harvestDaiAll", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256[]", "name": "_ids", "type": "uint256[]" }], + "name": "harvestDaiFromUnlock", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" }, + { "internalType": "contract TokenInterfaceV5", "name": "_gns", "type": "address" }, + { "internalType": "contract TokenInterfaceV5", "name": "_dai", "type": "address" } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "_staker", "type": "address" }], + "name": "pendingRewardDai", + "outputs": [{ "internalType": "uint128", "name": "", "type": "uint128" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_staker", "type": "address" }, + { "internalType": "uint256[]", "name": "_ids", "type": "uint256[]" } + ], + "name": "pendingRewardDaiFromUnlocks", + "outputs": [{ "internalType": "uint128", "name": "pending", "type": "uint128" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "_staker", "type": "address" }], + "name": "pendingRewardDaiFromUnlocks", + "outputs": [{ "internalType": "uint128", "name": "pending", "type": "uint128" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { "internalType": "uint128", "name": "totalGns", "type": "uint128" }, + { "internalType": "uint128", "name": "claimedGns", "type": "uint128" }, + { "internalType": "uint128", "name": "debtDai", "type": "uint128" }, + { "internalType": "uint48", "name": "start", "type": "uint48" }, + { "internalType": "uint48", "name": "duration", "type": "uint48" }, + { "internalType": "bool", "name": "revocable", "type": "bool" }, + { "internalType": "enum GNSStakingInterfaceV6_4_1.UnlockType", "name": "unlockType", "type": "uint8" }, + { "internalType": "uint16", "name": "__placeholder", "type": "uint16" } + ], + "internalType": "struct GNSStakingInterfaceV6_4_1.UnlockSchedule", + "name": "_schedule", + "type": "tuple" + }, + { "internalType": "uint48", "name": "_timestamp", "type": "uint48" } + ], + "name": "releasableGns", + "outputs": [{ "internalType": "uint128", "name": "", "type": "uint128" }], + "stateMutability": "pure", + "type": "function" + }, + { "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { "internalType": "address", "name": "_staker", "type": "address" }, + { "internalType": "uint256", "name": "_id", "type": "uint256" } + ], + "name": "revokeUnlockSchedule", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_manager", "type": "address" }, + { "internalType": "bool", "name": "_authorized", "type": "bool" } + ], + "name": "setUnlockManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint128", "name": "_amountGns", "type": "uint128" }], + "name": "stakeGns", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "stakers", + "outputs": [ + { "internalType": "uint128", "name": "stakedGns", "type": "uint128" }, + { "internalType": "uint128", "name": "debtDai", "type": "uint128" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "_staker", "type": "address" }], + "name": "totalGnsStaked", + "outputs": [{ "internalType": "uint128", "name": "", "type": "uint128" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "unlockManagers", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { "internalType": "uint128", "name": "totalGns", "type": "uint128" }, + { "internalType": "uint128", "name": "claimedGns", "type": "uint128" }, + { "internalType": "uint128", "name": "debtDai", "type": "uint128" }, + { "internalType": "uint48", "name": "start", "type": "uint48" }, + { "internalType": "uint48", "name": "duration", "type": "uint48" }, + { "internalType": "bool", "name": "revocable", "type": "bool" }, + { "internalType": "enum GNSStakingInterfaceV6_4_1.UnlockType", "name": "unlockType", "type": "uint8" }, + { "internalType": "uint16", "name": "__placeholder", "type": "uint16" } + ], + "internalType": "struct GNSStakingInterfaceV6_4_1.UnlockSchedule", + "name": "_schedule", + "type": "tuple" + }, + { "internalType": "uint48", "name": "_timestamp", "type": "uint48" } + ], + "name": "unlockedGns", + "outputs": [{ "internalType": "uint128", "name": "", "type": "uint128" }], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint128", "name": "_amountGns", "type": "uint128" }], + "name": "unstakeGns", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/src/apps/gains-network/contracts/viem.contract-factory.ts b/src/apps/gains-network/contracts/viem.contract-factory.ts index 81e739c69..0ce526908 100644 --- a/src/apps/gains-network/contracts/viem.contract-factory.ts +++ b/src/apps/gains-network/contracts/viem.contract-factory.ts @@ -7,6 +7,7 @@ import { GainsNetworkGToken__factory, GainsNetworkLockedDepositNft__factory, GainsNetworkStaking__factory, + GainsNetworkStakingV2__factory, } from './viem'; type ContractOpts = { address: string; network: Network }; @@ -24,4 +25,7 @@ export class GainsNetworkViemContractFactory { gainsNetworkStaking({ address, network }: ContractOpts) { return GainsNetworkStaking__factory.connect(address, this.appToolkit.getViemNetworkProvider(network)); } + gainsNetworkStakingV2({ address, network }: ContractOpts) { + return GainsNetworkStakingV2__factory.connect(address, this.appToolkit.getViemNetworkProvider(network)); + } } diff --git a/src/apps/gains-network/contracts/viem/GainsNetworkStakingV2.ts b/src/apps/gains-network/contracts/viem/GainsNetworkStakingV2.ts new file mode 100644 index 000000000..3e7b73631 --- /dev/null +++ b/src/apps/gains-network/contracts/viem/GainsNetworkStakingV2.ts @@ -0,0 +1,974 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import { getContract, GetContractReturnType, PublicClient } from 'viem'; + +export const gainsNetworkStakingV2Abi = [ + { + inputs: [], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'amountDai', + type: 'uint256', + }, + ], + name: 'DaiDistributed', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'staker', + type: 'address', + }, + { + indexed: false, + internalType: 'uint128', + name: 'amountDai', + type: 'uint128', + }, + ], + name: 'DaiHarvested', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'staker', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256[]', + name: 'ids', + type: 'uint256[]', + }, + { + indexed: false, + internalType: 'uint128', + name: 'amountDai', + type: 'uint128', + }, + ], + name: 'DaiHarvestedFromUnlock', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'staker', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256[]', + name: 'ids', + type: 'uint256[]', + }, + { + indexed: false, + internalType: 'uint128', + name: 'amountGns', + type: 'uint128', + }, + ], + name: 'GnsClaimed', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'staker', + type: 'address', + }, + { + indexed: false, + internalType: 'uint128', + name: 'amountGns', + type: 'uint128', + }, + ], + name: 'GnsStaked', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'staker', + type: 'address', + }, + { + indexed: false, + internalType: 'uint128', + name: 'amountGns', + type: 'uint128', + }, + ], + name: 'GnsUnstaked', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint8', + name: 'version', + type: 'uint8', + }, + ], + name: 'Initialized', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'previousOwner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'OwnershipTransferStarted', + 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: 'manager', + type: 'address', + }, + { + indexed: false, + internalType: 'bool', + name: 'authorized', + type: 'bool', + }, + ], + name: 'UnlockManagerUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'staker', + type: 'address', + }, + { + indexed: true, + internalType: 'uint256', + name: 'index', + type: 'uint256', + }, + ], + name: 'UnlockScheduleRevoked', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'staker', + type: 'address', + }, + { + indexed: true, + internalType: 'uint256', + name: 'index', + type: 'uint256', + }, + { + components: [ + { + internalType: 'uint128', + name: 'totalGns', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'claimedGns', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'debtDai', + type: 'uint128', + }, + { + internalType: 'uint48', + name: 'start', + type: 'uint48', + }, + { + internalType: 'uint48', + name: 'duration', + type: 'uint48', + }, + { + internalType: 'bool', + name: 'revocable', + type: 'bool', + }, + { + internalType: 'enum GNSStakingInterfaceV6_4_1.UnlockType', + name: 'unlockType', + type: 'uint8', + }, + { + internalType: 'uint16', + name: '__placeholder', + type: 'uint16', + }, + ], + indexed: false, + internalType: 'struct GNSStakingInterfaceV6_4_1.UnlockSchedule', + name: 'schedule', + type: 'tuple', + }, + ], + name: 'UnlockScheduled', + type: 'event', + }, + { + inputs: [], + name: 'accDaiPerToken', + outputs: [ + { + internalType: 'uint128', + name: '', + type: 'uint128', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'acceptOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256[]', + name: '_ids', + type: 'uint256[]', + }, + ], + name: 'claimUnlockedGns', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + components: [ + { + internalType: 'uint128', + name: 'totalGns', + type: 'uint128', + }, + { + internalType: 'uint48', + name: 'start', + type: 'uint48', + }, + { + internalType: 'uint48', + name: 'duration', + type: 'uint48', + }, + { + internalType: 'bool', + name: 'revocable', + type: 'bool', + }, + { + internalType: 'enum GNSStakingInterfaceV6_4_1.UnlockType', + name: 'unlockType', + type: 'uint8', + }, + ], + internalType: 'struct GNSStakingInterfaceV6_4_1.UnlockScheduleInput', + name: '_schedule', + type: 'tuple', + }, + { + internalType: 'address', + name: '_staker', + type: 'address', + }, + ], + name: 'createUnlockSchedule', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'dai', + outputs: [ + { + internalType: 'contract TokenInterfaceV5', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_amountDai', + type: 'uint256', + }, + ], + name: 'distributeRewardDai', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_staker', + type: 'address', + }, + { + internalType: 'uint256', + name: '_index', + type: 'uint256', + }, + ], + name: 'getUnlockSchedules', + outputs: [ + { + components: [ + { + internalType: 'uint128', + name: 'totalGns', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'claimedGns', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'debtDai', + type: 'uint128', + }, + { + internalType: 'uint48', + name: 'start', + type: 'uint48', + }, + { + internalType: 'uint48', + name: 'duration', + type: 'uint48', + }, + { + internalType: 'bool', + name: 'revocable', + type: 'bool', + }, + { + internalType: 'enum GNSStakingInterfaceV6_4_1.UnlockType', + name: 'unlockType', + type: 'uint8', + }, + { + internalType: 'uint16', + name: '__placeholder', + type: 'uint16', + }, + ], + internalType: 'struct GNSStakingInterfaceV6_4_1.UnlockSchedule', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_staker', + type: 'address', + }, + ], + name: 'getUnlockSchedules', + outputs: [ + { + components: [ + { + internalType: 'uint128', + name: 'totalGns', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'claimedGns', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'debtDai', + type: 'uint128', + }, + { + internalType: 'uint48', + name: 'start', + type: 'uint48', + }, + { + internalType: 'uint48', + name: 'duration', + type: 'uint48', + }, + { + internalType: 'bool', + name: 'revocable', + type: 'bool', + }, + { + internalType: 'enum GNSStakingInterfaceV6_4_1.UnlockType', + name: 'unlockType', + type: 'uint8', + }, + { + internalType: 'uint16', + name: '__placeholder', + type: 'uint16', + }, + ], + internalType: 'struct GNSStakingInterfaceV6_4_1.UnlockSchedule[]', + name: '', + type: 'tuple[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'gns', + outputs: [ + { + internalType: 'contract TokenInterfaceV5', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'gnsBalance', + outputs: [ + { + internalType: 'uint128', + name: '', + type: 'uint128', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'harvestDai', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256[]', + name: '_ids', + type: 'uint256[]', + }, + ], + name: 'harvestDaiAll', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256[]', + name: '_ids', + type: 'uint256[]', + }, + ], + name: 'harvestDaiFromUnlock', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_owner', + type: 'address', + }, + { + internalType: 'contract TokenInterfaceV5', + name: '_gns', + type: 'address', + }, + { + internalType: 'contract TokenInterfaceV5', + name: '_dai', + type: 'address', + }, + ], + name: 'initialize', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'owner', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'pendingOwner', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_staker', + type: 'address', + }, + ], + name: 'pendingRewardDai', + outputs: [ + { + internalType: 'uint128', + name: '', + type: 'uint128', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_staker', + type: 'address', + }, + { + internalType: 'uint256[]', + name: '_ids', + type: 'uint256[]', + }, + ], + name: 'pendingRewardDaiFromUnlocks', + outputs: [ + { + internalType: 'uint128', + name: 'pending', + type: 'uint128', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_staker', + type: 'address', + }, + ], + name: 'pendingRewardDaiFromUnlocks', + outputs: [ + { + internalType: 'uint128', + name: 'pending', + type: 'uint128', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + components: [ + { + internalType: 'uint128', + name: 'totalGns', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'claimedGns', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'debtDai', + type: 'uint128', + }, + { + internalType: 'uint48', + name: 'start', + type: 'uint48', + }, + { + internalType: 'uint48', + name: 'duration', + type: 'uint48', + }, + { + internalType: 'bool', + name: 'revocable', + type: 'bool', + }, + { + internalType: 'enum GNSStakingInterfaceV6_4_1.UnlockType', + name: 'unlockType', + type: 'uint8', + }, + { + internalType: 'uint16', + name: '__placeholder', + type: 'uint16', + }, + ], + internalType: 'struct GNSStakingInterfaceV6_4_1.UnlockSchedule', + name: '_schedule', + type: 'tuple', + }, + { + internalType: 'uint48', + name: '_timestamp', + type: 'uint48', + }, + ], + name: 'releasableGns', + outputs: [ + { + internalType: 'uint128', + name: '', + type: 'uint128', + }, + ], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [], + name: 'renounceOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_staker', + type: 'address', + }, + { + internalType: 'uint256', + name: '_id', + type: 'uint256', + }, + ], + name: 'revokeUnlockSchedule', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_manager', + type: 'address', + }, + { + internalType: 'bool', + name: '_authorized', + type: 'bool', + }, + ], + name: 'setUnlockManager', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint128', + name: '_amountGns', + type: 'uint128', + }, + ], + name: 'stakeGns', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'stakers', + outputs: [ + { + internalType: 'uint128', + name: 'stakedGns', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'debtDai', + type: 'uint128', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_staker', + type: 'address', + }, + ], + name: 'totalGnsStaked', + outputs: [ + { + internalType: 'uint128', + name: '', + type: 'uint128', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'transferOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'unlockManagers', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + components: [ + { + internalType: 'uint128', + name: 'totalGns', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'claimedGns', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'debtDai', + type: 'uint128', + }, + { + internalType: 'uint48', + name: 'start', + type: 'uint48', + }, + { + internalType: 'uint48', + name: 'duration', + type: 'uint48', + }, + { + internalType: 'bool', + name: 'revocable', + type: 'bool', + }, + { + internalType: 'enum GNSStakingInterfaceV6_4_1.UnlockType', + name: 'unlockType', + type: 'uint8', + }, + { + internalType: 'uint16', + name: '__placeholder', + type: 'uint16', + }, + ], + internalType: 'struct GNSStakingInterfaceV6_4_1.UnlockSchedule', + name: '_schedule', + type: 'tuple', + }, + { + internalType: 'uint48', + name: '_timestamp', + type: 'uint48', + }, + ], + name: 'unlockedGns', + outputs: [ + { + internalType: 'uint128', + name: '', + type: 'uint128', + }, + ], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint128', + name: '_amountGns', + type: 'uint128', + }, + ], + name: 'unstakeGns', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const; + +export type GainsNetworkStakingV2 = typeof gainsNetworkStakingV2Abi; +export type GainsNetworkStakingV2Contract = GetContractReturnType; + +export class GainsNetworkStakingV2__factory { + static connect(address: string, client: PublicClient) { + return getContract({ address, abi: gainsNetworkStakingV2Abi, publicClient: client }); + } +} diff --git a/src/apps/gains-network/contracts/viem/index.ts b/src/apps/gains-network/contracts/viem/index.ts index 635a36a9f..fadca45c7 100644 --- a/src/apps/gains-network/contracts/viem/index.ts +++ b/src/apps/gains-network/contracts/viem/index.ts @@ -4,8 +4,10 @@ export type { GainsNetworkGToken } from './GainsNetworkGToken'; export type { GainsNetworkLockedDepositNft } from './GainsNetworkLockedDepositNft'; +export type { GainsNetworkStakingV2 } from './GainsNetworkStakingV2'; export type { GainsNetworkStaking } from './GainsNetworkStaking'; export { GainsNetworkGToken__factory } from './GainsNetworkGToken'; export { GainsNetworkLockedDepositNft__factory } from './GainsNetworkLockedDepositNft'; +export { GainsNetworkStakingV2__factory } from './GainsNetworkStakingV2'; export { GainsNetworkStaking__factory } from './GainsNetworkStaking'; diff --git a/src/apps/gains-network/gains-network.module.ts b/src/apps/gains-network/gains-network.module.ts index 899bb9989..1515f1aa1 100644 --- a/src/apps/gains-network/gains-network.module.ts +++ b/src/apps/gains-network/gains-network.module.ts @@ -4,10 +4,12 @@ import { AbstractApp } from '~app/app.dynamic-module'; import { ArbitrumGainsNetworkGTokenTokenFetcher } from './arbitrum/gains-network.g-token.token-fetcher'; import { ArbitrumGainsNetworkLockedContractPositionFetcher } from './arbitrum/gains-network.locked.contract-position-fetcher'; +import { ArbitrumGainsNetworkStakingV2ContractPositionFetcher } from './arbitrum/gains-network.staking-v2.contract-position-fetcher'; import { ArbitrumGainsNetworkStakingContractPositionFetcher } from './arbitrum/gains-network.staking.contract-position-fetcher'; import { GainsNetworkViemContractFactory } from './contracts'; import { PolygonGainsNetworkGTokenTokenFetcher } from './polygon/gains-network.g-token.token-fetcher'; import { PolygonGainsNetworkLockedContractPositionFetcher } from './polygon/gains-network.locked.contract-position-fetcher'; +import { PolygonGainsNetworkStakingV2ContractPositionFetcher } from './polygon/gains-network.staking-v2.contract-position-fetcher'; import { PolygonGainsNetworkStakingContractPositionFetcher } from './polygon/gains-network.staking.contract-position-fetcher'; @Module({ @@ -17,10 +19,12 @@ import { PolygonGainsNetworkStakingContractPositionFetcher } from './polygon/gai ArbitrumGainsNetworkGTokenTokenFetcher, ArbitrumGainsNetworkStakingContractPositionFetcher, ArbitrumGainsNetworkLockedContractPositionFetcher, + ArbitrumGainsNetworkStakingV2ContractPositionFetcher, // Polygon PolygonGainsNetworkStakingContractPositionFetcher, PolygonGainsNetworkGTokenTokenFetcher, PolygonGainsNetworkLockedContractPositionFetcher, + PolygonGainsNetworkStakingV2ContractPositionFetcher, ], }) export class GainsNetworkAppModule extends AbstractApp() {} diff --git a/src/apps/gains-network/polygon/gains-network.staking-v2.contract-position-fetcher.ts b/src/apps/gains-network/polygon/gains-network.staking-v2.contract-position-fetcher.ts new file mode 100644 index 000000000..fb68cc34d --- /dev/null +++ b/src/apps/gains-network/polygon/gains-network.staking-v2.contract-position-fetcher.ts @@ -0,0 +1,10 @@ +import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator'; + +import { GainsNetworkStakingV2ContractPositionFetcher } from '../common/gains-network.staking-v2.contract-position-fetcher'; + +@PositionTemplate() +export class PolygonGainsNetworkStakingV2ContractPositionFetcher extends GainsNetworkStakingV2ContractPositionFetcher { + groupLabel = 'Staking'; + + stakingContractAddress = '0x8c74b2256ffb6705f14ada8e86fbd654e0e2beca'; +}