Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pbdao-staking] add pbdao-staking strategy #1218

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/strategies/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ import * as starlayVeBalanceOfLockerId from './starlay-ve-balance-of-locker-id';
import * as winrStaking from './winr-staking';
import * as spaceid from './spaceid';
import * as seedifyHoldStakingFarming from './seedify-cumulative-voting-power-hodl-staking-farming';
import * as pbdaoStaking from './pbdao-staking';

const strategies = {
'cap-voting-power': capVotingPower,
Expand Down Expand Up @@ -900,8 +901,8 @@ const strategies = {
'starlay-ve-balance-of-locker-id': starlayVeBalanceOfLockerId,
'winr-staking': winrStaking,
spaceid,
'seedify-cumulative-voting-power-hodl-staking-farming':
seedifyHoldStakingFarming
'seedify-cumulative-voting-power-hodl-staking-farming': seedifyHoldStakingFarming,
'pbdao-staking': pbdaoStaking
};

Object.keys(strategies).forEach(function (strategyName) {
Expand Down
36 changes: 36 additions & 0 deletions src/strategies/pbdao-staking/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# PB DAO stakers and holders strategy

This strategy return the balances of the voters for PB DAO project from staking pool.

## Accepted options

- **staking:** PB DAO staking pool address.

## Examples

```JSON
[
{
"name": "PBDAO Staker and Holders",
"strategy": {
"name": "pbdao-staking",
"params": {
"staking": "0x0A44B248C871dEcFcC46427207543e39f5234590",
"symbol": "PBDAO",
"decimals": 0
}
},
"network": "1",
"addresses": [
"0xcb5C730A85795b20C1fdB543B64B2ED164333803",
"0x4252a493899D1E2D1573Ff4084446C095C75055E",
"0x24d19f100ba142543a863fc2294b188e35ab55b9"
],
"snapshot": 13439719
}
]




```
19 changes: 19 additions & 0 deletions src/strategies/pbdao-staking/examples.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[
{
"name": "PBDAO Staker and Holders",
"strategy": {
"name": "pbdao-staking",
"params": {
"staking": "0x68483E34A38DDABF956536C30aB96960f821EAd0"

}
},
"network": "5",
"addresses": [
"0x7C0Df718F7C55FCDacad80d654092D5dfD2ce1dA",
"0x1924560F4b53CC35b1559359c2Bf8a1c22833596",
"0x0Cbe93D85a6de8258E797962eB59249e39D1d069"
],
"snapshot": 9287186
}
]
52 changes: 52 additions & 0 deletions src/strategies/pbdao-staking/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { Multicaller } from '../../utils';
import { BigNumberish } from '@ethersproject/bignumber';
import { formatUnits } from '@ethersproject/units';

export const author = 'PB';
export const version = '0.1.0';

// to interact with the staking and token contracts.
const stakingAbi = [
'function depositsOf(address account) external view virtual override returns (uint256)'
];

export async function strategy(
space: string,
network: string,
provider: any,
addresses: string[],
options: any,
snapshot: number
): Promise<Record<string, number>> {
const blockTag = typeof snapshot === 'number' ? snapshot : 'latest';

const stakingPool = new Multicaller(network, provider, stakingAbi, {
blockTag
});

addresses.forEach((address) => {
stakingPool.call(address, options.staking, 'depositsOf', [address]);
});

const result: Record<string, BigNumberish> = await stakingPool.execute();

return Object.fromEntries(
Object.entries(result).map(([address, balance]) => {
console.log(address, balance);
return [address, parseFloat(formatUnits(balance, options.decimals))];
})
);
// try {
// const [stakingResponse] = await Promise.all([stakingPool.execute()]);
// return Object.fromEntries(
// addresses.map((address) => {
// const stakingCount = stakingResponse[address].length;
// return [address, stakingCount];
// })
// );
// } catch (error) {
// console.error('Error retrieving staking data:', error);
// return {};
// }
}
Loading