Skip to content
This repository was archived by the owner on Aug 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 4 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
8 changes: 8 additions & 0 deletions src/strategies/defi-app-voting/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This strategy returns total voting power on Defi App, based on HOME and sHOME

Here is an example of parameters:

{
"lockingContract": "0xC9714F8f036087d801f38C4105194e150d3a1864",
"homeToken": "0x4BfAa776991E85e5f8b1255461cbbd216cFc714f"
}
19 changes: 19 additions & 0 deletions src/strategies/defi-app-voting/examples.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[
{
"name": "sHOME - Base",
"strategy": {
"name": "defi-app-voting",
"params": {
"lockingContract": "0xcfb0c58ac2db2269b4a794e615c9f4c559556da0",
"homeToken": "0xc8688a66f2588ff3064e87e9bad666c281d41af3"
}
},
"network": "8453",
"addresses": [
"0xFD79F3E5E5641266c46Aa7F19144Ff7F19a637C7",
"0x4011091Dbe57bd4521F598616fe4BB3978ea3005",
"0x2eAA7327e9B5Ff46bc2B7452acE9e44A1528eb84"
],
"snapshot": 31224505
}
]
52 changes: 52 additions & 0 deletions src/strategies/defi-app-voting/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { BigNumberish } from '@ethersproject/bignumber';
import { formatUnits } from '@ethersproject/units';
import { Multicaller } from '../../utils';

export const author = 'JD0x2e';
export const version = '0.1.2';

const mfdAbi = [
'function getUserLocks(address) view returns (tuple(uint256 amount, uint256 unlockTime, uint256 multiplier, uint256 duration, uint256 lockCreationTime)[])'
];

const erc20Abi = ['function balanceOf(address) view returns (uint256)'];

const toJsNum = (bn: BigNumberish) => parseFloat(formatUnits(bn));

export async function strategy(
space,
network,
provider,
addresses,
options,
snapshot
): Promise<Record<string, number>> {
const blockTag = typeof snapshot === 'number' ? snapshot : 'latest';

const MFD_CONTRACT = options.lockingContract;
const HOME_TOKEN = options.homeToken;

const locksMulticaller = new Multicaller(network, provider, mfdAbi, { blockTag });
const homeMulticaller = new Multicaller(network, provider, erc20Abi, { blockTag });

addresses.forEach((address) => {
locksMulticaller.call(address, MFD_CONTRACT, 'getUserLocks', [address]);
homeMulticaller.call(address, HOME_TOKEN, 'balanceOf', [address]);
});

const [lockResults, homeBalances] = await Promise.all([
locksMulticaller.execute(),
homeMulticaller.execute()
]);

return Object.fromEntries(
addresses.map((address) => {
const locks = lockResults[address] ?? [];
const sHome = locks.reduce((acc, lock) => acc + toJsNum(lock.amount), 0);
const home = toJsNum(homeBalances[address] ?? 0);

const weightedPower = sHome * 0.8 + home * 0.2;
return [address, weightedPower];
})
);
}
20 changes: 11 additions & 9 deletions src/strategies/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ import * as tombFinance from './tomb-finance';
import * as trancheStakingSLICE from './tranche-staking-slice';
import * as unipoolUniv2Lp from './unipool-univ2-lp';
import * as unipoolXSushi from './unipool-xsushi';
import * as defiAppVoting from './defi-app-voting';
import * as taraxaDelegation from './taraxa-delegation';
import * as poap from './poap';
import * as poapWithWeight from './poap-with-weight';
Expand Down Expand Up @@ -492,7 +493,7 @@ const strategies = {
'delegatexyz-erc721-balance-of': delegatexyzErc721BalanceOf,
'giveth-balances-supply-weighted': givethBalancesSupplyWeighted,
'giveth-gnosis-balance-supply-weighted-v3':
givethGnosisBalanceSupplyWeightedV3,
givethGnosisBalanceSupplyWeightedV3,
'minime-balance-vs-supply-weighted': minimeBalanceVsSupplyWeighted,
'cap-voting-power': capVotingPower,
'izumi-veizi': izumiVeiZi,
Expand Down Expand Up @@ -555,7 +556,7 @@ const strategies = {
'erc721-with-tokenid': erc721WithTokenId,
'erc721-with-tokenid-range-weights': erc721WithTokenIdRangeWeights,
'erc721-with-tokenid-range-weights-simple':
erc721WithTokenIdRangeWeightsSimple,
erc721WithTokenIdRangeWeightsSimple,
'erc721-with-tokenid-weighted': erc721WithTokenIdWeighted,
'erc721-with-metadata': erc721WithMetadata,
'erc721-with-metadata-by-ownerof': erc721WithMetadataByOwnerOf,
Expand Down Expand Up @@ -690,7 +691,7 @@ const strategies = {
'sunrisegaming-staking': sunriseGamingStaking,
'single-staking-autocompound-balanceof': singleStakingAutoCompoundBalanceOf,
'single-staking-longtermstaking-balanceof':
singleStakingLongTermStakingBalanceOf,
singleStakingLongTermStakingBalanceOf,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @JD0x2e Make sure there are no other changes in this file, I think it is lint issue, else everything looks good :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChaituVR I've fixed this

'single-staking-pools-balanceof': singleStakingPoolsBalanceOf,
'hopr-stake-and-balance-qv': hoprStakeAndBalanceQV,
'hopr-bridged-balance': hoprBridgedBalance,
Expand All @@ -699,6 +700,7 @@ const strategies = {
'loot-character-guilds': lootCharacterGuilds,
'comp-like-votes-inclusive': compLikeVotesInclusive,
mstable,
'defi-app-voting': defiAppVoting,
'hashes-voting': hashesVoting,
'hashflow-vehft': hashflowVeHft,
'aavegotchi-wagmi-guild': aavegotchiWagmiGuild,
Expand Down Expand Up @@ -732,7 +734,7 @@ const strategies = {
'snet-stakers': snetStakers,
'snet-liquidity-providers': snetLiquidityProviders,
'unstackedtoadz-and-stackedtoadz-stakers':
unstackedToadzAndStackedToadzStakers,
unstackedToadzAndStackedToadzStakers,
'ocean-dao-brightid': oceanDAOBrightID,
membership: membership,
'lydia-gov-vault': lydiaGovVault,
Expand Down Expand Up @@ -835,7 +837,7 @@ const strategies = {
'nation3-passport-coop-with-delegations': nation3CoopPassportWithDelegations,
'erc20-tokens-per-uni': erc20TokensPerUni,
'bancor-standard-rewards-underlying-balance':
bancorStandardRewardsUnderlyingBalance,
bancorStandardRewardsUnderlyingBalance,
'sd-vote-boost': sdVoteBoost,
'sd-vote-boost-twavp': sdVoteBoostTWAVP,
spreadsheet,
Expand Down Expand Up @@ -872,7 +874,7 @@ const strategies = {
'hats-protocol-single-vote-per-org': hatsProtocolSingleVotePerOrg,
'karma-discord-roles': karmaDiscordRoles,
'seedify-cumulative-voting-power-hodl-staking-farming':
seedifyHoldStakingFarming,
seedifyHoldStakingFarming,
'staked-morekudasai': stakedMoreKudasai,
'sablier-v1-deposit': sablierV1Deposit,
'sablier-v2': sablierV2,
Expand All @@ -885,7 +887,7 @@ const strategies = {
'sd-gauge-less-vote-boost': sdGaugeLessVoteBoost,
'sd-gauge-less-vote-boost-crosschain': sdGaugeLessVoteBoostCrosschain,
'sd-gauge-less-vote-boost-crosschain-spectra':
sdGaugeLessVoteBoostCrosschainSpectra,
sdGaugeLessVoteBoostCrosschainSpectra,
'sdvote-balanceof-twavp-pool': sdVoteBalanceOfTwavpPool,
'sd-vote-boost-twavp-vsdtoken': sdVoteBoostTWAVPVsdToken,
'sd-vote-boost-twavp-vsdcrv-crosschain': sdVoteBoostTWAVPVCrossChain,
Expand Down Expand Up @@ -932,7 +934,7 @@ const strategies = {
'total-axion-shares': totalAxionShares,
'unipool-same-token': unipoolSameToken,
'vendor-v2-borrower-collateral-balance-of':
vendorV2BorrowerCollateralBalanceOf,
vendorV2BorrowerCollateralBalanceOf,
'volt-voting-power': voltVotingPower,
'xdai-stakers-and-holders': xdaiStakersAndHolders,
'urbit-galaxies': urbitGalaxies,
Expand All @@ -943,7 +945,7 @@ const strategies = {
'a51-vault-balance': a51VaultBalance,
'quickswap-v3': quickswapv3,
'balance-of-with-bazaar-batch-auction-linear-vesting-power':
balanceOfWithBazaarBatchAuctionLinearVestingPower,
balanceOfWithBazaarBatchAuctionLinearVestingPower,
'staking-balance-of-v1': stakingBalanceOfV1,
'staking-balance-of-v2': stakingBalanceOfV2,
'garden-stakes': gardenStakes,
Expand Down
Loading