Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
bonustrack committed Apr 5, 2021
2 parents 5884304 + a0adc54 commit 3c32298
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/strategies/defidollar/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { formatUnits } from '@ethersproject/units';
import { BigNumber } from '@ethersproject/bignumber';
import { multicall } from '../../utils';

export const author = 'atvanguard';
Expand Down Expand Up @@ -152,14 +153,13 @@ export async function strategy(

let response = await multicall(network, provider, abi, queries, { blockTag });
response = response.map((r) => r[0]);

const n = addresses.length;

const dfdEarned = response.slice(0, n);
const dfdClaimed = response.slice(n, 2 * n);
const sushiEthDusdEarned = response.slice(2 * n, 3 * n);
const ppfs = response[4 * n];
const ibDFD = response.slice(3 * n, 4 * n).map((r) => r.mul(ppfs));
const ibDFD = response.slice(3 * n, 4 * n).map((r) => r.mul(ppfs).div(BigNumber.from(10).pow(18)));
response = response.slice(4 * n + 1);

return Object.fromEntries(
Expand Down
2 changes: 2 additions & 0 deletions src/strategies/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import { strategy as mushrooms } from './mushrooms';
import { strategy as curioCardsErc20Weighted } from './curio-cards-erc20-weighted';
import { strategy as renNodes } from './ren-nodes';
import { strategy as multisigOwners } from './multisig-owners';
import { strategy as trancheStaking } from './tranche-staking';
import { strategy as pepemon } from './pepemon';
import { strategy as erc1155AllBalancesOf } from './erc1155-all-balances-of';

Expand Down Expand Up @@ -142,6 +143,7 @@ export default {
'curio-cards-erc20-weighted': curioCardsErc20Weighted,
'ren-nodes': renNodes,
'multisig-owners': multisigOwners,
'tranche-staking': trancheStaking,
pepemon,
'erc1155-all-balances-of': erc1155AllBalancesOf
};
21 changes: 21 additions & 0 deletions src/strategies/tranche-staking/examples.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[
{
"name": "Example query",
"strategy": {
"name": "tranche-staking",
"params": {
"address": "0x5ce49f584257606426498bfd16d770c50bb20254",
"tokenAddress": "0x0AeE8703D34DD9aE107386d3eFF22AE75Dd616D1",
"symbol": "SLICE",
"decimals": 18,
"start": 12113995
}
},
"network": "1",
"addresses": [
"0xd2ddb0e1c223a873c77ee80497e9d82c1002e483",
"0xbfdc3fe26553ac0c6041c1e6e0081f95b8c824b3"
],
"snapshot": 12114000
}
]
58 changes: 58 additions & 0 deletions src/strategies/tranche-staking/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { formatUnits } from '@ethersproject/units';
import { multicall } from '../../utils';

export const author = 'ayush-jibrel';
export const version = '0.1.0';

const abi = [
{
constant: true,
inputs: [
{
internalType: 'address',
name: 'user',
type: 'address'
},
{
internalType: 'address',
name: 'token',
type: 'address'
}
],
name: 'balanceOf',
outputs: [
{
internalType: 'uint256',
name: '',
type: 'uint256'
}
],
payable: false,
stateMutability: 'view',
type: 'function'
}
];

export async function strategy(
space,
network,
provider,
addresses,
options,
snapshot
) {
const blockTag = typeof snapshot === 'number' ? snapshot : 'latest';
const response = await multicall(
network,
provider,
abi,
addresses.map((address: any) => [options.address, 'balanceOf', [address, options.tokenAddress]]),
{ blockTag }
);
return Object.fromEntries(
response.map((value, i) => [
addresses[i],
parseFloat(formatUnits(value.toString(), options.decimals))
])
);
}

0 comments on commit 3c32298

Please sign in to comment.