Skip to content

Commit

Permalink
Update Snapshot.js version and lint fixes (snapshot-labs#69)
Browse files Browse the repository at this point in the history
* Update snapshot.js to 0.2.8 version

* Lint fixes
  • Loading branch information
ChaituVR authored Sep 20, 2021
1 parent f74ff85 commit 3cf07eb
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 34 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@ethersproject/strings": "^5.0.5",
"@ethersproject/units": "^5.0.3",
"@ethersproject/wallet": "^5.4.0",
"@snapshot-labs/snapshot.js": "^0.2.3",
"@snapshot-labs/snapshot.js": "^0.2.8",
"@uniswap/sdk-core": "^3.0.1",
"@uniswap/v3-sdk": "^3.3.1",
"cross-fetch": "^3.0.6",
Expand Down
7 changes: 2 additions & 5 deletions src/strategies/coordinape/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,12 @@ export async function strategy(
});
const gifts = await res.json();
const scores = {};
gifts.forEach(gift => {
gifts.forEach((gift) => {
const address = getAddress(gift.recipient_address);
if (!scores[address]) scores[address] = 0;
scores[address] += gift.tokens;
});
return Object.fromEntries(
addresses.map(address => [
address,
scores[getAddress(address)] || 0
])
addresses.map((address) => [address, scores[getAddress(address)] || 0])
);
}
6 changes: 4 additions & 2 deletions src/strategies/faraland-staking/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ 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'
'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';
Expand Down
4 changes: 2 additions & 2 deletions src/strategies/has-rock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export async function strategy(

const result = {} as any;

addresses.forEach((address, x) => {
addresses.forEach((address) => {
let addressRocks = 0;
response.forEach((rockObject, i) => {
response.forEach((rockObject) => {
if (rockObject.owner == address) {
addressRocks++;
}
Expand Down
25 changes: 11 additions & 14 deletions src/strategies/iotex-staked-balance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,17 @@ export async function strategy(
) {
const height = typeof snapshot === 'number' ? snapshot : 10000000000;
const apiUrl = getUrl(network);
const response = await fetch(
`${apiUrl}/api.StakingService.GetVoteByHeight`,
{
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
address: addresses,
height
})
}
);
const response = await fetch(`${apiUrl}/api.StakingService.GetVoteByHeight`, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
address: addresses,
height
})
});

const ret: ApiReturn = await response.json();
return Object.fromEntries(
Expand Down
6 changes: 4 additions & 2 deletions src/strategies/sunrisegaming-staking/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function strategy(
const blockTag = typeof snapshot === 'number' ? snapshot : 'latest';

// Get staked LP in staking constract
let stakedRes = await multicall(
const stakedRes = await multicall(
network,
provider,
masterChefAbi,
Expand All @@ -40,7 +40,9 @@ export async function strategy(

return Object.fromEntries(
stakedRes.map((stakedInfo, i) => {
const parsedAmount = parseFloat(formatUnits(bn(stakedInfo.amount), options.decimal));
const parsedAmount = parseFloat(
formatUnits(bn(stakedInfo.amount), options.decimal)
);
return [addresses[i], parsedAmount];
})
);
Expand Down
4 changes: 2 additions & 2 deletions src/strategies/sunrisegaming-univ2-lp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export async function strategy(
res = res.slice(2);

// Get staked LP in staking constract
let stakedRes = await multicall(
const stakedRes = await multicall(
network,
provider,
masterChefAbi,
Expand All @@ -68,7 +68,7 @@ export async function strategy(
// How much tokens user has from LP tokens
const usersTokensFromLp = res.slice(0, addresses.length).map((amount, i) => {
const totalLp = bn(amount).add(bn(stakedRes[i].amount)); // decimal: 18

// (LP + StakedLP) x token.balanceOf(LPToken) / LPToken.totalSupply()
return totalLp.mul(totalTokensInPool).div(lpTokenTotalSupply); // decimal: options.decimal
});
Expand Down

0 comments on commit 3cf07eb

Please sign in to comment.