Skip to content

Commit

Permalink
staked-daomaker-bsc
Browse files Browse the repository at this point in the history
  • Loading branch information
iHux3 committed Mar 4, 2024
1 parent ec4fb9a commit 3c36825
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/strategies/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ import * as vendorV2BorrowerCollateralBalanceOf from './vendor-v2-borrower-colla
import * as voltVotingPower from './volt-voting-power';
import * as xdaiStakersAndHolders from './xdai-stakers-and-holders';
import * as minimeBalanceVsSupplyWeighted from './minime-balance-vs-supply-weighted';
import * as stakedDaomakerBsc from "./staked-daomaker-bsc"

const strategies = {
'minime-balance-vs-supply-weighted': minimeBalanceVsSupplyWeighted,
Expand Down Expand Up @@ -833,7 +834,8 @@ const strategies = {
vendorV2BorrowerCollateralBalanceOf,
'volt-voting-power': voltVotingPower,
'xdai-stakers-and-holders': xdaiStakersAndHolders,
'urbit-galaxies': urbitGalaxies
'urbit-galaxies': urbitGalaxies,
'staked-daomaker-bsc': stakedDaomakerBsc
};

Object.keys(strategies).forEach(function (strategyName) {
Expand Down
13 changes: 13 additions & 0 deletions src/strategies/staked-daomaker-bsc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# staked-daomaker-bsc

It returns the staked amount of DAO on BSC of the voters.

Here is an example of parameters:

```json
{
"address": "0x598CA79eee092A084B5f168c4196EdB80EA22781",
"symbol": "DAO",
"decimals": 18
}
```
22 changes: 22 additions & 0 deletions src/strategies/staked-daomaker-bsc/examples.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
{
"name": "Example query",
"strategy": {
"name": "staked-daomaker-bsc",
"params": {
"address": "0x598CA79eee092A084B5f168c4196EdB80EA22781",
"symbol": "DAO",
"decimals": 18
}
},
"network": "56",
"addresses": [
"0xa93065e0Ef01908c9bD016c1D78c0C2F7Fa7D523",
"0x8a146531630850fE1d158c922bDA620BDDF12766",
"0x3fF8CAc8ce2449ACe1C47FeBd8F3687D043f0C12",
"0x70E828Ba093C5fad8202d7b1870809b40077C2Fd",
"0xBd2d3ef0146B6b949DcA131576D3b6D33e2bD6cD"
],
"snapshot": 36679354
}
]
35 changes: 35 additions & 0 deletions src/strategies/staked-daomaker-bsc/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { BigNumberish } from '@ethersproject/bignumber';
import { formatUnits } from '@ethersproject/units';
import { Multicaller } from '../../utils';

export const author = 'bonustrack';
export const version = '0.1.1';

const abi = [
'function users(address account) external view returns (uint256, uint256, uint256)'
];

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

const multi = new Multicaller(network, provider, abi, { blockTag });
addresses.forEach((address) =>
multi.call(address, options.address, 'users', [address])
);

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

return Object.fromEntries(
Object.entries(result).map(([address, data]) => [
address,
parseFloat(formatUnits(data[0], options.decimals))
])
);
}
34 changes: 34 additions & 0 deletions src/strategies/staked-daomaker-bsc/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "#/definitions/Strategy",
"definitions": {
"Strategy": {
"title": "Strategy",
"type": "object",
"properties": {
"symbol": {
"type": "string",
"title": "Symbol",
"examples": ["e.g. UNI"],
"maxLength": 16
},
"address": {
"type": "string",
"title": "Contract address",
"examples": ["e.g. 0x598CA79eee092A084B5f168c4196EdB80EA22781"],
"pattern": "^0x[a-fA-F0-9]{40}$",
"minLength": 42,
"maxLength": 42
},
"decimals": {
"type": "number",
"title": "Decimals",
"examples": ["e.g. 18"],
"minimum": 0
}
},
"required": ["address", "decimals"],
"additionalProperties": false
}
}
}

0 comments on commit 3c36825

Please sign in to comment.