Skip to content

Commit

Permalink
Refactor staking TVL calculation to use helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
0xTea committed Jan 14, 2025
1 parent e066684 commit e68dd8a
Showing 1 changed file with 2 additions and 36 deletions.
38 changes: 2 additions & 36 deletions projects/paragons-dao/index.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,14 @@
const sdk = require('@defillama/sdk');
const { staking } = require('../helper/staking');

const stakingContract = '0x51e025cb3ee0b99a84f7fb80994198281e29aa3e';
const stakedToken = '0xeff2A458E464b07088bDB441C21A42AB4b61e07E';

const tokenAbi = {
name: 'balanceOf',
inputs: [
{
type: 'address',
name: 'account',
},
],
outputs: [
{
type: 'uint256',
name: '',
},
],
stateMutability: 'view',
type: 'function',
};

async function stakingTvl(_, _b, _cb, { api }) {
const balances = {};

// Fetch the balance of staked tokens in the staking contract
const { output: stakedBalance } = await sdk.api.abi.call({
abi: tokenAbi,
target: stakedToken,
params: [stakingContract],
chain: 'base'
});

// Add the staked token balance to the balances object
sdk.util.sumSingleBalance(balances, `base:${stakedToken}`, stakedBalance);

return balances;
}

module.exports = {
methodology: 'TVL of ParagonsDAO corresponds to the staking of PDT tokens in the staking contract.',
start: 18751707, // Update with the block or timestamp when staking started
base: {
tvl: async () => ({}), // leave protocol TVL as empty
staking: stakingTvl,
staking: staking(stakingContract, stakedToken),
},
};

0 comments on commit e68dd8a

Please sign in to comment.