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

[staked-daomaker-bsc] New strategy #1419

Open
wants to merge 1 commit 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
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))
])
);
Comment on lines +19 to +34
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @iHux3 You can use contract-call strategy here instead of a new strategy, let me know :)

}
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
}
}
}