Skip to content

Commit

Permalink
add fara staking strategy (snapshot-labs#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
toniqhz authored Sep 15, 2021
1 parent 0ac889f commit 43a114e
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/strategies/faraland-staking/examples.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"name": "Faraland stake query",
"strategy": {
"name": "faraland-staking",
"params": {
"address": "0x3057A6EF2aCf803371315380d21D0193471E3EF8",
"symbol": "FARA"
}
},
"network": "56",
"addresses": [
"0x3f105F78359ad80562B4c34296a87b8e66c584C5"
],
"snapshot": 10913859
}
]
51 changes: 51 additions & 0 deletions src/strategies/faraland-staking/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { getAddress } from '@ethersproject/address';
import { subgraphRequest } from '../../utils';

const FLASHSTAKE_SUBGRAPH_URL = {
'1': 'https://queries-graphnode.faraland.io/subgraphs/name/edwardevans094/farastore-v12',
'56': 'https://queries-graphnode.faraland.io/subgraphs/name/edwardevans094/farastore-v12'
};

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

export async function strategy(
_space,
network,
_provider,
addresses,
options,
snapshot
) {
const params = {
users: {
__args: {
where: {
id_in: addresses.map((address) => address.toLowerCase())
},
first: 1000
},
id: true,
totalStaked: true
}
};

if (snapshot !== 'latest') {
// @ts-ignore
params.users.__args.block = { number: snapshot };
}
const result = await subgraphRequest(
FLASHSTAKE_SUBGRAPH_URL[network],
params
);

const score = {};
if (result && result.users) {
result.users.map((_data) => {
const address = getAddress(_data.id);
score[address] = Number(_data.totalStaked);
});
}

return score || {};
}
2 changes: 2 additions & 0 deletions src/strategies/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import * as yearnVault from './yearn-vault';
import * as fraxFinance from './frax-finance';
import * as moloch from './moloch';
import * as uniswap from './uniswap';
import * as faralandStaking from './faraland-staking';
import * as flashstake from './flashstake';
import * as pancake from './pancake';
import * as synthetix from './synthetix';
Expand Down Expand Up @@ -186,6 +187,7 @@ const strategies = {
masterchef,
sushiswap,
uniswap,
'faraland-staking': faralandStaking,
flashstake,
pancake,
synthetix,
Expand Down

0 comments on commit 43a114e

Please sign in to comment.