-
Notifications
You must be signed in to change notification settings - Fork 811
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix-split-delegation-returned-address-not-…
…checksummed
- Loading branch information
Showing
73 changed files
with
2,375 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
SNAPSHOT_API_STRATEGY_SALT=12345 # Salt for the snapshot API strategy to send a key in header (optional) | ||
PASSPORT_API_KEY= # API key for the passport API (optional for other strategies) | ||
PASSPORT_SCORER_ID= # Scorer ID for the passport API (optional for other strategies) | ||
MOXIE_API_KEY= # API key for the moxie APIs (optional for other strategies) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Botto Dao Governance strategy | ||
|
||
It returns the BOTTO balance of the voters participating in the governance and in the liquidity mining program | ||
|
||
Here is an example of parameters: | ||
```json | ||
[ | ||
{ | ||
"name": "Botto Dao Governance strategy", | ||
"strategy": { | ||
"name": "botto-dao", | ||
"params": { | ||
"token": "0x9dfad1b7102d46b1b197b90095b5c4e9f5845bba", | ||
"stakingAddress": "0x19CD3998f106eCC40eE7668c19C47e18b491e8a6", | ||
"miningAddress": "0xf8515Cae6915838543bCD7756F39268CE8F853Fd", | ||
"liquidityAddress": "0x9ff68f61ca5eb0c6606dc517a9d44001e564bb66", | ||
"symbol": "BOTTO", | ||
"decimals": 18 | ||
} | ||
}, | ||
"network": "1", | ||
"addresses": [ | ||
"0xf2b10b41961f6bc3801e7946dabe5572158a78a5", | ||
"0xea32cf979bdaf8d3bb4121d58515d4623a27f3e0", | ||
"0x7173d417cfa1cdec794fa21f4ca8a71d181b2ca0", | ||
"0x58787f1659b2fd8853918dab6d4a1565569e6044", | ||
"0x7dbc5f88986db946f1d5987edfbf9c6917230fa2" | ||
], | ||
"snapshot": 13808330 | ||
} | ||
] | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[ | ||
{ | ||
"name": "Botto Dao Base Governance strategy", | ||
"strategy": { | ||
"name": "botto-dao-base", | ||
"params": { | ||
"token": "0x24914cb6bd01e6a0cf2a9c0478e33c25926e6a0c", | ||
"stakingAddress": "0x8a7a5991aAf142B43E58253Bd6791e240084F0A9", | ||
"symbol": "BOTTO", | ||
"decimals": 18 | ||
} | ||
}, | ||
"network": "8453", | ||
"addresses": [ | ||
"0x85D906C217Bb4c7b7f7CDE0D4318fAfa02f6F01d", | ||
"0x276Dfeec6F5772156B19116d76D1E3DEB3B6F0b4", | ||
"0x56768B032Fc12D2e911eF654B0054e26a58cef74", | ||
"0x7173d417cfa1cdec794fa21f4ca8a71d181b2ca0", | ||
"0x58787f1659b2fd8853918dab6d4a1565569e6044", | ||
"0x7dbc5f88986db946f1d5987edfbf9c6917230fa2" | ||
], | ||
"snapshot": 23250193 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { BigNumberish } from '@ethersproject/bignumber'; | ||
import { formatUnits } from '@ethersproject/units'; | ||
import { Multicaller } from '../../utils'; | ||
|
||
export const author = 'agustinjch'; | ||
export const version = '1.0.0'; | ||
|
||
const abi = ['function userStakes(address) external view returns(uint256)']; | ||
|
||
export async function strategy( | ||
space, | ||
network, | ||
provider, | ||
addresses, | ||
options, | ||
snapshot | ||
): Promise<Record<string, number>> { | ||
const blockTag = typeof snapshot === 'number' ? snapshot : 'latest'; | ||
const _formatUnits = (value) => | ||
parseFloat(formatUnits(value, options.decimals)); | ||
|
||
const multiBalances = new Multicaller(network, provider, abi, { | ||
blockTag | ||
}); | ||
|
||
addresses.forEach((address) => { | ||
multiBalances.call( | ||
address + '-stakedBotto', | ||
options.stakingAddress, | ||
'userStakes', | ||
[address] | ||
); | ||
}); | ||
|
||
const balances: Record<string, BigNumberish> = await multiBalances.execute(); | ||
|
||
const result = Object.fromEntries( | ||
addresses.map((adr) => { | ||
const stakedBotto = _formatUnits(balances[adr + '-stakedBotto'] || 0); | ||
return [adr, stakedBotto]; | ||
}) | ||
); | ||
|
||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[ | ||
{ | ||
"name": "Example query", | ||
"strategy": { | ||
"name": "cookie-staking", | ||
"params": { | ||
"address": "0x036b6BA384656151471f348fccf5c2818b9223aE", | ||
"decimals": 18 | ||
} | ||
}, | ||
"network": "56", | ||
"addresses": [ | ||
"0xaE7EF51F517380Ca0211A60BeA83596080ddF478", | ||
"0xd0825555aA656c56e687A6412d40534ba7f0E096", | ||
"0x7018b9aB744cd438De14e9186De43698A29A7aAA" | ||
], | ||
"snapshot": 43137800 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { Multicaller } from '../../utils'; | ||
import { formatUnits } from '@ethersproject/units'; | ||
import { BigNumber } from '@ethersproject/bignumber'; | ||
|
||
export const author = 'spaceh3ad'; | ||
export const version = '0.1.0'; | ||
|
||
const abi = [ | ||
'function users(uint256,address) view returns (uint256 shares, uint256 lastDepositedTime, uint256 totalInvested, uint256 totalClaimed)' | ||
]; | ||
|
||
interface UserData { | ||
shares: BigNumber; | ||
lastDepositedTime: BigNumber; | ||
totalInvested: BigNumber; | ||
totalClaimed: BigNumber; | ||
} | ||
|
||
export async function strategy( | ||
space, | ||
network, | ||
provider, | ||
addresses, | ||
options, | ||
snapshot | ||
) { | ||
const blockTag = typeof snapshot === 'number' ? snapshot : 'latest'; | ||
|
||
const multi = new Multicaller(network, provider, abi, { blockTag }); | ||
|
||
const poolIds = 11; | ||
|
||
// Prepare multicall | ||
addresses.forEach((address) => { | ||
for (let poolId = 0; poolId < poolIds; poolId++) { | ||
multi.call(`${address}-${poolId}`, options.address, 'users', [ | ||
poolId, | ||
address | ||
]); | ||
} | ||
}); | ||
|
||
// Typecast result to Record<string, UserData> | ||
const result = (await multi.execute()) as Record<string, UserData>; | ||
|
||
// Initialize a mapping for user totals | ||
const userTotals: { [address: string]: BigNumber } = {}; | ||
|
||
// Process the result | ||
for (const [key, userData] of Object.entries(result)) { | ||
const address = key.split('-')[0]; | ||
|
||
const totalInvested = BigNumber.from(userData.totalInvested); | ||
const totalClaimed = BigNumber.from(userData.totalClaimed); | ||
|
||
if (!userTotals[address]) { | ||
userTotals[address] = BigNumber.from(0); | ||
} | ||
|
||
const amount = totalInvested.sub(totalClaimed); | ||
|
||
userTotals[address] = userTotals[address].add(amount); | ||
} | ||
|
||
const formattedResult = Object.fromEntries( | ||
addresses.map((address) => [ | ||
address, | ||
parseFloat( | ||
formatUnits( | ||
userTotals[address] || BigNumber.from(0), | ||
options.decimals || 18 | ||
) | ||
) | ||
]) | ||
); | ||
|
||
return formattedResult; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"type": "object", | ||
"definitions": { | ||
"Strategy": { | ||
"title": "Strategy", | ||
"type": "object", | ||
"properties": { | ||
"address": { | ||
"type": "string", | ||
"pattern": "^0x[a-fA-F0-9]{40}$", | ||
"minLength": 42, | ||
"maxLength": 42 | ||
}, | ||
"decimals": { | ||
"type": "integer", | ||
"minimum": 0 | ||
} | ||
}, | ||
"required": ["address"], | ||
"additionalProperties": false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.