Skip to content

Commit 7d2d735

Browse files
committed
revert balance fallback for now
1 parent 9798610 commit 7d2d735

File tree

2 files changed

+38
-69
lines changed

2 files changed

+38
-69
lines changed

adapters/balance/index.ts

Lines changed: 36 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -33,32 +33,13 @@ export async function latest(
3333
return res;
3434
}
3535

36-
async function getStoredEmissions(adapter: string, sectionKey: string): Promise<CliffAdapterResult[]> {
37-
try {
38-
const r = await fetch(`https://api.llama.fi/emission/${adapter}`).then((r) => r.json());
39-
if (!r.body) return [];
40-
const data = JSON.parse(r.body);
41-
const section = data.documentedData?.data?.find((s: any) => s.label === sectionKey);
42-
if (!section?.data) return [];
43-
44-
return section.data.map((d: any) => ({
45-
type: "cliff" as const,
46-
start: d.timestamp,
47-
amount: d.rawEmission || d.unlocked || 0
48-
}));
49-
} catch {
50-
return [];
51-
}
52-
}
53-
5436
export async function balance(
5537
owners: string[],
5638
target: string,
5739
chain: any,
5840
adapter: string,
5941
timestampDeployed: number,
60-
backfill: boolean = false,
61-
sectionKey?: string
42+
backfill: boolean = false
6243
): Promise<CliffAdapterResult[]> {
6344
let trackedTimestamp: number;
6445
let decimals: number;
@@ -74,48 +55,41 @@ export async function balance(
7455
}),
7556
]);
7657

77-
try {
78-
const chainData = await findBlockHeightArray(trackedTimestamp, chain);
58+
const chainData = await findBlockHeightArray(trackedTimestamp, chain);
7959

80-
await PromisePool.withConcurrency(10)
81-
.for(Object.keys(chainData))
82-
.process(async (block) =>
83-
target == GAS_TOKEN
84-
? await PromisePool.withConcurrency(10)
85-
.for(owners)
86-
.process(async (target) => {
87-
getBalance({
88-
target,
89-
block: Number(block),
90-
chain,
91-
}).then((r: any) => {
92-
if (!r.output)
93-
throw new Error(`balance call failed for ${adapter}`);
94-
if (!chainData[block].result) chainData[block].result = 0;
95-
chainData[block].result += Number(r.output);
96-
});
97-
})
98-
: await multiCall({
99-
calls: owners.map((o: string) => ({ target, params: [o] })),
100-
abi: "erc20:balanceOf",
101-
chain,
102-
block,
103-
requery: true,
104-
}).then((r: (number | null)[]) => {
105-
if (r.includes(null))
106-
throw new Error(`balance call failed for ${adapter}`);
107-
chainData[block].result = r.reduce(
108-
(p: number, c: any) => Number(p) + Number(c),
109-
0,
110-
);
111-
}),
112-
);
60+
await PromisePool.withConcurrency(10)
61+
.for(Object.keys(chainData))
62+
.process(async (block) =>
63+
target == GAS_TOKEN
64+
? await PromisePool.withConcurrency(10)
65+
.for(owners)
66+
.process(async (target) => {
67+
getBalance({
68+
target,
69+
block: Number(block),
70+
chain,
71+
}).then((r: any) => {
72+
if (!r.output)
73+
throw new Error(`balance call failed for ${adapter}`);
74+
if (!chainData[block].result) chainData[block].result = 0;
75+
chainData[block].result += Number(r.output);
76+
});
77+
})
78+
: await multiCall({
79+
calls: owners.map((o: string) => ({ target, params: [o] })),
80+
abi: "erc20:balanceOf",
81+
chain,
82+
block,
83+
requery: true,
84+
}).then((r: (number | null)[]) => {
85+
if (r.includes(null))
86+
throw new Error(`balance call failed for ${adapter}`);
87+
chainData[block].result = r.reduce(
88+
(p: number, c: any) => Number(p) + Number(c),
89+
0,
90+
);
91+
}),
92+
);
11393

114-
return filterRawAmounts(chainData, decimals);
115-
} catch {
116-
if (sectionKey) {
117-
return await getStoredEmissions(adapter, sectionKey);
118-
}
119-
return [];
120-
}
94+
return filterRawAmounts(chainData, decimals);
12195
}

protocols/merit-circle.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const token = "0x949D48EcA67b17269629c7194F4b727d4Ef9E5d6";
66
const chain = "ethereum";
77
const qty = 1e9;
88
const realtime =
9-
(holder: string, deployed: number, sectionKey: string) => async (backfill: boolean) =>
10-
balance([holder], token, chain, "merit-circle", deployed, backfill, sectionKey).then(
9+
(holder: string, deployed: number) => async (backfill: boolean) =>
10+
balance([holder], token, chain, "merit-circle", deployed, backfill).then(
1111
(s: CliffAdapterResult[]) =>
1212
s.filter((c: CliffAdapterResult) => c.amount < 1e8),
1313
);
@@ -16,29 +16,24 @@ const merit: Protocol = {
1616
"Community Incentives": realtime(
1717
"0x56475a4a8D00b6F7b01E0879CBbba609707aef6b",
1818
1641513600,
19-
"Community Incentives",
2019
),
2120
Contributors: realtime(
2221
"0x97173277FED329ee844BAfa44D7719ad372a7150",
2322
1668124800,
24-
"Contributors",
2523
),
2624
"DAO Treasury": realtime(
2725
"0x7e9e4c0876B2102F33A1d82117Cc73B7FddD0032",
2826
1635548400,
29-
"DAO Treasury",
3027
),
3128
"Early Contributors": realtime(
3229
"0xB5A0cbB4fC7294642216Cd7AFbc3525B24316cbc",
3330
1652137200,
34-
"Early Contributors",
3531
),
3632
"Liquidity Rewards": manualCliff(1633042800, qty * 0.1),
3733
"Public Distribution": manualCliff(1633042800, qty * 0.075),
3834
"Retroactive Rewards": realtime(
3935
"0x4f6d9907fBc54feDeA9296860d36E14ccC348F7A",
4036
1640649600,
41-
"Retroactive Rewards",
4237
),
4338
meta: {
4439
notes: [],

0 commit comments

Comments
 (0)