Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[spooky-lp-sonic] Added spooky-lp-sonic strategy and updated index.ts #1677

Merged
merged 6 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/strategies/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,11 @@ import * as morphoDelegation from './morpho-delegation';
import * as lizcoinStrategy2024 from './lizcoin-strategy-2024';
import * as realt from './realt';
import * as superfluidVesting from './superfluid-vesting';
import * as spookyLpSonic from './spooky-lp-sonic';
import * as synapse from './synapse';

const strategies = {
'spooky-lp-sonic': spookyLpSonic,
'delegatexyz-erc721-balance-of': delegatexyzErc721BalanceOf,
'giveth-balances-supply-weighted': givethBalancesSupplyWeighted,
'giveth-gnosis-balance-supply-weighted-v3':
Expand Down
13 changes: 13 additions & 0 deletions src/strategies/spooky-lp-sonic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# LP Liquidity Position for $BOO Pools [Sonic]
This strategy calculates the liquidity position of users in pools where $BOO is one of the tokens. It utilizes data from a subgraph to compute the net liquidity by analyzing mint and burn events.

## Overview
The strategy queries the following pools:

Pool 1: 0x686d873a9e0696afaca0bc163dcc95b577d9e3e8 wS/BOO
Pool 2: 0xf4dcfaa2711908a8c61d9516d84b24ffdae241db WETH/BOO
Pool 3: 0xb7228a39cdd2c734064fc95c54e75910ff06eed6 USDC.E/BOO
Pool 4: 0x84d4716c1cf4d7b1b1c247ad69b62fa72ccc46d7 wS/BOO
Pool 5: 0xaa4ee51f55f9baa7cf180fbaf2688cc35fdc8012 BOO/TONS

The strategy uses a subgraph to fetch mint and burn events, calculates the net liquidity position, and assigns scores to the provided addresses based on their activity.
17 changes: 17 additions & 0 deletions src/strategies/spooky-lp-sonic/examples.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"name": "Example query",
"strategy": {
"name": "spooky-lp-sonic"
},
"network": "1",
"addresses": [
"0xf83e546bd2959c22f1715ecaffc03d39b8d0fa96",
"0x02fa5640f5D948f14C9195fB2873D832A49f0A5f",
"0xFE2fb8587760c8d5960CB7A5BA2f2299EdF10506",
"0x593B0c00078A741eB440c7B9Dde999bdD40Aa1F9",
"0x159b567635aea41170aafaf1f832185344c56fba"
],
"snapshot": 11437846
}
]
88 changes: 88 additions & 0 deletions src/strategies/spooky-lp-sonic/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { subgraphRequest } from '../../utils';
import { getAddress } from '@ethersproject/address';

const MY_SUBGRAPH_URL = {
'1': 'https://api.0xgraph.xyz/api/public/28820bd2-ad8b-4d40-a142-ce8d7c786f66/subgraphs/spookyswap/v3/v0.0.1/gn'
};

export const author = '0xaaiden';
export const version = '0.1.0';

export async function strategy(
space,
network,
provider,
addresses,
options,
snapshot
) {
const poolIds = [
"0x686d873a9e0696afaca0bc163dcc95b577d9e3e8",
"0xf4dcfaa2711908a8c61d9516d84b24ffdae241db",
"0xb7228a39cdd2c734064fc95c54e75910ff06eed6",
"0x84d4716c1cf4d7b1b1c247ad69b62fa72ccc46d7",
"0xaa4ee51f55f9baa7cf180fbaf2688cc35fdc8012",
];

const subgraphURL = MY_SUBGRAPH_URL[network];
const score = {};
addresses.forEach((address) => {
score[getAddress(address)] = 0;
});

for (const poolId of poolIds) {
const params = {
mints: {
__args: {
where: {
pool_: { id: poolId },
origin_in: addresses.map((address) => address.toLowerCase())
}
},
origin: true,
timestamp: true,
amount: true,
pool: { id: true }
},
burns: {
__args: {
where: {
pool_: { id: poolId },
origin_in: addresses.map((address) => address.toLowerCase())
}
},
origin: true,
timestamp: true,
amount: true,
pool: { id: true }
}
};

if (snapshot !== 'latest') {
// @ts-ignore
params.mints.__args.where.transaction_ = { blockNumber_lte: snapshot };
// @ts-ignore
params.burns.__args.where.transaction_ = { blockNumber_lte: snapshot };
}

const result = await subgraphRequest(subgraphURL, params);
if (result && (result.mints || result.burns)) {
const mints = result.mints;
const burns = result.burns;

mints.forEach((mint) => {
const userAddress = getAddress(mint.origin);
const amount = parseFloat(mint.amount);
score[userAddress] += amount;
});

burns.forEach((burn) => {
const userAddress = getAddress(burn.origin);
const amount = parseFloat(burn.amount);
score[userAddress] -= amount;
});
}
}

return score || {};
}
Loading