Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
feat(silo-finance): Added STIP claimables on Arbitrum (#3170)
Browse files Browse the repository at this point in the history
  • Loading branch information
wpoulin authored Jan 2, 2024
1 parent 7b4be46 commit 18b4058
Show file tree
Hide file tree
Showing 6 changed files with 991 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { Inject } from '@nestjs/common';

import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface';
import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator';
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 { SiloFinanceViemContractFactory } from '../contracts';
import { SiloStipController } from '../contracts/viem';

@PositionTemplate()
export class ArbitrumSiloFinanceClaimableContractPositionFetcher extends ContractPositionTemplatePositionFetcher<SiloStipController> {
groupLabel = 'Claimables';

constructor(
@Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit,
@Inject(SiloFinanceViemContractFactory) protected readonly contractFactory: SiloFinanceViemContractFactory,
) {
super(appToolkit);
}

getContract(address: string) {
return this.contractFactory.siloStipController({ address, network: this.network });
}

async getDefinitions() {
return [{ address: '0xd592f705bdc8c1b439bd4d665ed99c4faad5a680' }];
}

async getTokenDefinitions({ contract }: GetTokenDefinitionsParams<SiloStipController>) {
return [
{
metaType: MetaType.SUPPLIED,
address: await contract.read.REWARD_TOKEN(),
network: this.network,
},
];
}

async getLabel({ contractPosition }: GetDisplayPropsParams<SiloStipController>) {
return getLabelFromToken(contractPosition.tokens[0]);
}

async getTokenBalancesPerPosition({ address, contract }: GetTokenBalancesParams<SiloStipController>) {
return [await contract.read.getUserUnclaimedRewards([address])];
}
}
276 changes: 276 additions & 0 deletions src/apps/silo-finance/contracts/abis/silo-stip-controller.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,276 @@
[
{
"inputs": [
{ "internalType": "contract IERC20", "name": "rewardToken", "type": "address" },
{ "internalType": "address", "name": "emissionManager", "type": "address" }
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{ "inputs": [], "name": "ClaimerUnauthorized", "type": "error" },
{ "inputs": [], "name": "IndexOverflow", "type": "error" },
{ "inputs": [], "name": "IndexOverflowAtEmissionsPerSecond", "type": "error" },
{ "inputs": [], "name": "InvalidConfiguration", "type": "error" },
{ "inputs": [], "name": "InvalidToAddress", "type": "error" },
{ "inputs": [], "name": "InvalidUserAddress", "type": "error" },
{ "inputs": [], "name": "OnlyEmissionManager", "type": "error" },
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "asset", "type": "address" },
{ "indexed": false, "internalType": "uint256", "name": "emission", "type": "uint256" }
],
"name": "AssetConfigUpdated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "asset", "type": "address" },
{ "indexed": false, "internalType": "uint256", "name": "index", "type": "uint256" }
],
"name": "AssetIndexUpdated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "user", "type": "address" },
{ "indexed": true, "internalType": "address", "name": "claimer", "type": "address" }
],
"name": "ClaimerSet",
"type": "event"
},
{
"anonymous": false,
"inputs": [{ "indexed": false, "internalType": "uint256", "name": "newDistributionEnd", "type": "uint256" }],
"name": "DistributionEndUpdated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "user", "type": "address" },
{ "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" }
],
"name": "RewardsAccrued",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "user", "type": "address" },
{ "indexed": true, "internalType": "address", "name": "to", "type": "address" },
{ "indexed": true, "internalType": "address", "name": "claimer", "type": "address" },
{ "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" }
],
"name": "RewardsClaimed",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "user", "type": "address" },
{ "indexed": true, "internalType": "address", "name": "asset", "type": "address" },
{ "indexed": false, "internalType": "uint256", "name": "index", "type": "uint256" }
],
"name": "UserIndexUpdated",
"type": "event"
},
{
"inputs": [],
"name": "DISTRIBUTION_END",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "EMISSION_MANAGER",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "PRECISION",
"outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "REVISION",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "REWARD_TOKEN",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "TEN_POW_PRECISION",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "", "type": "address" }],
"name": "assets",
"outputs": [
{ "internalType": "uint104", "name": "emissionPerSecond", "type": "uint104" },
{ "internalType": "uint104", "name": "index", "type": "uint104" },
{ "internalType": "uint40", "name": "lastUpdateTimestamp", "type": "uint40" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address[]", "name": "assets", "type": "address[]" },
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
{ "internalType": "address", "name": "to", "type": "address" }
],
"name": "claimRewards",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address[]", "name": "assets", "type": "address[]" },
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
{ "internalType": "address", "name": "user", "type": "address" },
{ "internalType": "address", "name": "to", "type": "address" }
],
"name": "claimRewardsOnBehalf",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address[]", "name": "assets", "type": "address[]" },
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
],
"name": "claimRewardsToSelf",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address[]", "name": "assets", "type": "address[]" },
{ "internalType": "uint256[]", "name": "emissionsPerSecond", "type": "uint256[]" }
],
"name": "configureAssets",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "asset", "type": "address" }],
"name": "getAssetData",
"outputs": [
{ "internalType": "uint256", "name": "", "type": "uint256" },
{ "internalType": "uint256", "name": "", "type": "uint256" },
{ "internalType": "uint256", "name": "", "type": "uint256" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "user", "type": "address" }],
"name": "getClaimer",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getDistributionEnd",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address[]", "name": "assets", "type": "address[]" },
{ "internalType": "address", "name": "user", "type": "address" }
],
"name": "getRewardsBalance",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "user", "type": "address" },
{ "internalType": "address", "name": "asset", "type": "address" }
],
"name": "getUserAssetData",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "_user", "type": "address" }],
"name": "getUserUnclaimedRewards",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "user", "type": "address" },
{ "internalType": "uint256", "name": "totalSupply", "type": "uint256" },
{ "internalType": "uint256", "name": "userBalance", "type": "uint256" }
],
"name": "handleAction",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "notificationReceiverPing",
"outputs": [{ "internalType": "bytes4", "name": "", "type": "bytes4" }],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "", "type": "address" },
{ "internalType": "address", "name": "_from", "type": "address" },
{ "internalType": "address", "name": "_to", "type": "address" },
{ "internalType": "uint256", "name": "_amount", "type": "uint256" }
],
"name": "onAfterTransfer",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{ "inputs": [], "name": "rescueRewards", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
{
"inputs": [
{ "internalType": "address", "name": "user", "type": "address" },
{ "internalType": "address", "name": "caller", "type": "address" }
],
"name": "setClaimer",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "distributionEnd", "type": "uint256" }],
"name": "setDistributionEnd",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
5 changes: 4 additions & 1 deletion src/apps/silo-finance/contracts/viem.contract-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Injectable, Inject } from '@nestjs/common';
import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface';
import { Network } from '~types/network.interface';

import { SiloIncentives__factory } from './viem';
import { SiloIncentives__factory, SiloStipController__factory } from './viem';

type ContractOpts = { address: string; network: Network };

Expand All @@ -14,4 +14,7 @@ export class SiloFinanceViemContractFactory {
siloIncentives({ address, network }: ContractOpts) {
return SiloIncentives__factory.connect(address, this.appToolkit.getViemNetworkProvider(network));
}
siloStipController({ address, network }: ContractOpts) {
return SiloStipController__factory.connect(address, this.appToolkit.getViemNetworkProvider(network));
}
}
Loading

0 comments on commit 18b4058

Please sign in to comment.