Skip to content

Commit

Permalink
added subgraph urls, more accurate accounting
Browse files Browse the repository at this point in the history
  • Loading branch information
d10r committed Jan 2, 2025
1 parent 4ebb435 commit 0d0cb30
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/strategies/superfluid-vesting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ In order for this intent to become executable, the sender also needs to
- grant the necessary ACL permissions to the VestingScheduler contract
- have enough funds available when needed

Note: In order to create a vesting schedule with hard guarantees of sucessful execution, a vesting sender needs to be a contract which is pre-funded and has no means to withdraw funds.
Note: In order to create a vesting schedule with hard guarantees of successful execution, a vesting sender needs to be a contract which is pre-funded and has no means to withdraw funds.

## Voting

Expand Down
17 changes: 11 additions & 6 deletions src/strategies/superfluid-vesting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ export const author = 'd10r';
export const version = '0.1.0';

const SUBGRAPH_URL_MAP = {
'10':
'https://subgrapher.snapshot.org/subgraph/arbitrum/6YMD95vYriDkmTJewC2vYubqVZrc6vdk3Sp3mR3YCQUw',
'8453':
'https://subgrapher.snapshot.org/subgraph/arbitrum/4Zp6n8jcsJMBNa3GY9RZwoK4SLjoagwXGq6GhUQNMgSM'
'https://subgrapher.snapshot.org/subgraph/arbitrum/4Zp6n8jcsJMBNa3GY9RZwoK4SLjoagwXGq6GhUQNMgSM',
'11155420':
'https://subgrapher.snapshot.org/subgraph/arbitrum/5UctBWuaQgr2HVSG6XtAKt5shyjg9snGvD6F424FcjMN'
};

export async function strategy(
Expand All @@ -23,8 +27,6 @@ export async function strategy(
throw new Error('Subgraph URL not specified');
}

console.log(`subgraphUrl: ${subgraphUrl}`);

const query = {
vestingSchedules: {
__args: {
Expand All @@ -43,7 +45,8 @@ export async function strategy(
endDate: true,
flowRate: true,
cliffAndFlowExecutedAt: true,
receiver: true
receiver: true,
remainderAmount: true
}
};

Expand All @@ -64,9 +67,10 @@ export async function strategy(
const cliffAndFlowDate = BigInt(schedule.cliffAndFlowDate);
const flowRate = BigInt(schedule.flowRate);
const cliffAmount = BigInt(schedule.cliffAmount);
const remainderAmount = BigInt(schedule.remainderAmount);

// the initial vesting amount
const fullAmount = cliffAmount + flowRate * (endDate - cliffAndFlowDate);
const fullAmount = cliffAmount + flowRate * (endDate - cliffAndFlowDate) + remainderAmount;

// the remaining amount which hasn't yet vested
let remainingAmount = fullAmount;
Expand All @@ -85,7 +89,8 @@ export async function strategy(
return Object.fromEntries(
processedMap.map(item => [
getAddress(item.schedule.receiver),
Number(item.remainingAmount) / 1e18
// in theory remainingAmount could become negative, thus we cap at 0
Math.max(Number(item.remainingAmount) / 1e18, 0)
])
);
}

0 comments on commit 0d0cb30

Please sign in to comment.