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

[spacefi-blp] add blp strategy #1394

Merged
merged 9 commits into from
Jan 25, 2024
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 @@ -243,6 +243,7 @@ import * as erc1155weighted from './erc1155-weighted-by-id';
import * as stakersAndHolders from './stakers-and-holders';
import * as banksyDao from './banksy-dao';
import * as spacey2025 from './spacey2025';
import * as spacefiBlp from './spacefi-blp';
import * as sandmanDao from './sandman-dao';
import * as veBalanceOfAt from './ve-balance-of-at';
import * as veRibbon from './ve-ribbon';
Expand Down Expand Up @@ -663,6 +664,7 @@ const strategies = {
'stakers-and-holders': stakersAndHolders,
'banksy-dao': banksyDao,
spacey2025: spacey2025,
'spacefi-blp': spacefiBlp,
'sandman-dao': sandmanDao,
've-balance-of-at': veBalanceOfAt,
've-ribbon': veRibbon,
Expand Down
33 changes: 33 additions & 0 deletions src/strategies/spacefi-blp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# spacefi-blp

This strategy returns the assets of nft and xspace in spacefi, including staking and in the market

Here is an example of parameters:

```json
[
{
"name": "Example query",
"strategy": {
"name": "spacefi-blp",
"params": {
"blpAddress": "0x67B6c6E67F8f2CD1948ECD02221D141CBa3A4984",
"symbol": "blp",
"decimals": 18
}
},
"network": "324",
"addresses": [
"0x8633500EF5c41CE955B4958AD5e61ca58A2B3cB6",
"0xAc2fbBC12cEe75158C38c5Ca34EfBb6343aFdcB3",
"0xb4B72F3843154B37580721ba9233fE86Da6e0416",
"0x89023d1284F565aF9Ad115ACDb2F512d35024723",
"0xEeC60E6a0Ca0F80Fa16e0E2267Ff4C2c1A46a447",
"0xfC87549072F3217140E7046d88D3873C8bF3B014",
"0xb6cE6Dd21598f24E840Bf2D43D8d4a1d57faEf4E",
"0x524E2631ceBFce2aF66FAcDBB160aC94A00751B3"
],
"snapshot": 24739965
}
]
```
25 changes: 25 additions & 0 deletions src/strategies/spacefi-blp/examples.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[
{
"name": "Example query",
"strategy": {
"name": "spacefi-blp",
"params": {
"blpAddress": "0x67B6c6E67F8f2CD1948ECD02221D141CBa3A4984",
"symbol": "blp",
"decimals": 18
}
},
"network": "324",
"addresses": [
"0x8633500EF5c41CE955B4958AD5e61ca58A2B3cB6",
"0xAc2fbBC12cEe75158C38c5Ca34EfBb6343aFdcB3",
"0xb4B72F3843154B37580721ba9233fE86Da6e0416",
"0x89023d1284F565aF9Ad115ACDb2F512d35024723",
"0xEeC60E6a0Ca0F80Fa16e0E2267Ff4C2c1A46a447",
"0xfC87549072F3217140E7046d88D3873C8bF3B014",
"0xb6cE6Dd21598f24E840Bf2D43D8d4a1d57faEf4E",
"0x524E2631ceBFce2aF66FAcDBB160aC94A00751B3"
],
"snapshot": 24739965
}
]
36 changes: 36 additions & 0 deletions src/strategies/spacefi-blp/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { BigNumberish } from '@ethersproject/bignumber';
import { formatUnits } from '@ethersproject/units';
import { Multicaller } from '../../utils';

export const author = 'SpaceFinance';
export const version = '0.1.0';

const abi = [
'function userInfo(address account) external view returns (uint256,uint256,uint256)'
];

export async function strategy(
space,
network,
provider,
addresses,
options,
snapshot
) {
const blockTag = typeof snapshot === 'number' ? snapshot : 'latest';
const { blpAddress, decimals } = options;

const multi = new Multicaller(network, provider, abi, { blockTag });
addresses.forEach((address) =>
multi.call(address, blpAddress, 'userInfo', [address])
);
const result: Record<string, [BigNumberish, BigNumberish, BigNumberish]> = await multi.execute();

return Object.fromEntries(
Object.entries(result).map(([address, blp]) => [
address,
(Number(formatUnits(blp[0], decimals)) +
Number(formatUnits(blp[2], decimals)))
])
);
}
Loading