Skip to content

Commit

Permalink
merge snapshot (#2)
Browse files Browse the repository at this point in the history
* added flexible voucher strategies [erc3525-flexible-voucher] (snapshot-labs#740)

* add vesting voucher strategies

* vesting-voucher rename erc3525-vesting-voucher

* Update src/strategies/erc3525-vesting-voucher/index.ts

Co-authored-by: Chaitanya <[email protected]>

* Update src/strategies/erc3525-vesting-voucher/index.ts

Co-authored-by: Chaitanya <[email protected]>

* optimization

* erc3525 vesting voucher logical change

* added flexible voucher strategies

* erc3525 vesting voucher change amount  value

* restore

* restore

Co-authored-by: Chaitanya <[email protected]>

* new strategy: decaying voting power for staked ERC 1155s [echelon-cached-erc1155-decay] (snapshot-labs#753)

* decaying erc1155 pk voting power

* update decay rate

* add readme

* Update src/strategies/echelon-cached-erc1155-decay/index.ts

Co-authored-by: Chaitanya <[email protected]>

Co-authored-by: Chaitanya <[email protected]>

* erc3525 vesting voucher change amount take value [erc3525-vesting-voucher] (snapshot-labs#758)

* add vesting voucher strategies

* vesting-voucher rename erc3525-vesting-voucher

* Update src/strategies/erc3525-vesting-voucher/index.ts

Co-authored-by: Chaitanya <[email protected]>

* Update src/strategies/erc3525-vesting-voucher/index.ts

Co-authored-by: Chaitanya <[email protected]>

* optimization

* erc3525 vesting voucher logical change

* added flexible voucher strategies

* erc3525 vesting voucher change amount  value

* restore

* restore

* erc3525 vesting voucher change amount take value

* Restore accidentally deleted code

Co-authored-by: Chaitanya <[email protected]>

* feat: add harmony-staking strategy [harmony-staking] (snapshot-labs#757)

* feat: add harmony-staking strategy

calculates votes of validators through the total balance delegated to
them (including self delegation)

* chore: move author and name below imports

Co-authored-by: Chaitanya <[email protected]>

* Automated lint (snapshot-labs#759)

Co-authored-by: ChaituVR <[email protected]>

* fix(deps): update dependency @snapshot-labs/snapshot.js to ^0.4.14 (snapshot-labs#761)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update dependency @snapshot-labs/snapshot.js to ^0.4.15 (snapshot-labs#762)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat: prepo vesting contract weighted voting [prepo-vesting] (snapshot-labs#755)

* feat: prepo vesting contract weighted voting

* refactor: move prepo vesting to middle of list

* feat: add schema

* feat: added readme.md

* refactor: adjust parameters

* feat: update README.md

* feat: add symbol example to README.md

* feat: testing command

* feat: rearrange

* feat: update README.md

* feat: finalize README.md

* feat: capitalize Contract Address in schema.json

* fix: edited wrong file

* feat: capitalize Contract Address in schema.json

* feat: update README.md

* feat: update default symbol

* fix: symbol should not be required

* feat: rename variables to match formula in readme

* feat: resolve conflict

* feat: readme.md

* feat: add a strategy to calc blance with subgraph (snapshot-labs#748)

Co-authored-by: Chaitanya <[email protected]>

* erc3525 vesting voucher claim coefficient updated [erc3525-vesting-voucher] (snapshot-labs#763)

* add vesting voucher strategies

* vesting-voucher rename erc3525-vesting-voucher

* Update src/strategies/erc3525-vesting-voucher/index.ts

Co-authored-by: Chaitanya <[email protected]>

* Update src/strategies/erc3525-vesting-voucher/index.ts

Co-authored-by: Chaitanya <[email protected]>

* optimization

* erc3525 vesting voucher logical change

* added flexible voucher strategies

* erc3525 vesting voucher change amount  value

* restore

* restore

* erc3525 vesting voucher change amount take value

* Restore accidentally deleted code

* erc3525 vesting voucher claim coefficient updated

Co-authored-by: Chaitanya <[email protected]>

* fix(deps): update dependency @snapshot-labs/snapshot.js to ^0.4.16 (snapshot-labs#764)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update dependency @snapshot-labs/snapshot.js to ^0.4.18 (snapshot-labs#767)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* erc3525 flexible voucher claim coefficient updated [erc3525-flexible-voucher] (snapshot-labs#766)

* add vesting voucher strategies

* vesting-voucher rename erc3525-vesting-voucher

* Update src/strategies/erc3525-vesting-voucher/index.ts

Co-authored-by: Chaitanya <[email protected]>

* Update src/strategies/erc3525-vesting-voucher/index.ts

Co-authored-by: Chaitanya <[email protected]>

* optimization

* erc3525 vesting voucher logical change

* added flexible voucher strategies

* erc3525 vesting voucher change amount  value

* restore

* restore

* erc3525 vesting voucher change amount take value

* Restore accidentally deleted code

* erc3525 vesting voucher claim coefficient updated

* erc3525 flexible voucher claim coefficient updated

Co-authored-by: Chaitanya <[email protected]>

* feat: Add vlAURA to veBAL balanceOf strategy [aura-balance-of-vlaura-vebal] (snapshot-labs#777)

* feat: Add vlAURA to veBAL balanceOf strategy

* feat: Add vlAURA to veBAL balanceOf strategy

* maturities coefficient parameter type change [erc3525-flexible-voucher] (snapshot-labs#773)

* add vesting voucher strategies

* vesting-voucher rename erc3525-vesting-voucher

* Update src/strategies/erc3525-vesting-voucher/index.ts

Co-authored-by: Chaitanya <[email protected]>

* Update src/strategies/erc3525-vesting-voucher/index.ts

Co-authored-by: Chaitanya <[email protected]>

* optimization

* erc3525 vesting voucher logical change

* added flexible voucher strategies

* erc3525 vesting voucher change amount  value

* restore

* restore

* erc3525 vesting voucher change amount take value

* Restore accidentally deleted code

* erc3525 vesting voucher claim coefficient updated

* erc3525 flexible voucher claim coefficient updated

* erc3525 flexible voucher maturities coefficient parameter type change

Co-authored-by: Chaitanya <[email protected]>

* Proxy Protocol ERC1155 [proxyprotocol-erc1155-balance-of] (snapshot-labs#774)

* Proxy Protocol ERC1155

* ABI/version number suggestions from code review

Co-authored-by: Chaitanya <[email protected]>

* Call ERC1155 balance of

Co-authored-by: Chaitanya <[email protected]>

* fix(deps): update dependency @snapshot-labs/snapshot.js to ^0.4.19 (snapshot-labs#778)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Proxy Protocol ERC721 [proxyprotocol-erc721-balance-of] (snapshot-labs#775)

* Proxy Protocol Erc721

* Call ERC721 balance of and change example NFT

* Proxy Protocol ERC20 [proxyprotocol-erc20-balance-of] (snapshot-labs#776)

* Proxy Protocol ERC20

* Call erc-20

* Remove delegation.json (snapshot-labs#779)

* Add validations strategies (snapshot-labs#772)

* Add getVp and getDelegations functions

* Update dependencies

* Export functions getVp and getDelegations

* Remove unused file

* Add validations strategies

* Add test for validation

* Add pkg script for validation test

* [gooddollar-multichain] New strategy (snapshot-labs#683)

* feat:multichain-max strategy

* feat: math strategy to support multichains

* add: limit to 1,122 and two strategies

* Revert "feat: math strategy to support multichains"

This reverts commit 77bb89a.

* fix: index

* add: apply code review changes

* fix: index

* fix: index

* fix: lint

* Update multichain documentation (snapshot-labs#780)

* Remove block subgraph documentation from multichain Readme

* Update

* [orca-pod] Orca pods strategy (snapshot-labs#770)

* [orca-pods] Orca pods strategy

* Rename and fixes

* Automated lint (snapshot-labs#781)

Co-authored-by: ChaituVR <[email protected]>

* Documentaion update for erc20-with-balance and holds-tokens (snapshot-labs#783)

* Documentaion update for erc20-with-balance and holds-tokens

* Documentaion update for erc20-with-balance and holds-tokens

* Add Arrow vesting contract strategy (snapshot-labs#784)

* fix(deps): update dependency @snapshot-labs/snapshot.js to ^0.4.20 (snapshot-labs#785)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Automated lint (snapshot-labs#786)

Co-authored-by: ChaituVR <[email protected]>

Co-authored-by: charq <[email protected]>
Co-authored-by: Chaitanya <[email protected]>
Co-authored-by: Brandon <[email protected]>
Co-authored-by: Max <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: ChaituVR <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Weizard <[email protected]>
Co-authored-by: 0xButterfield <[email protected]>
Co-authored-by: Justin Huang <[email protected]>
Co-authored-by: Fabien <[email protected]>
Co-authored-by: sirpy <[email protected]>
Co-authored-by: BrassLion <[email protected]>
  • Loading branch information
14 people authored Aug 22, 2022
1 parent a21a70d commit fa8a06a
Show file tree
Hide file tree
Showing 64 changed files with 1,980 additions and 111 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"test": "jest -i strategy.test.ts",
"test:vp": "jest -i vp.test.ts",
"test:delegation": "jest -i delegation.test.ts",
"test:validation": "jest -i validation.test.ts",
"prepublishOnly": "npm run build",
"postinstall": "npm run build",
"postbuild": "copyfiles -u 1 \"src/**/*.md\" dist/ && copyfiles -u 1 \"src/**/*.json\" dist/",
Expand All @@ -33,7 +34,7 @@
"@ethersproject/strings": "^5.6.1",
"@ethersproject/units": "^5.6.1",
"@ethersproject/wallet": "^5.6.2",
"@snapshot-labs/snapshot.js": "^0.4.13",
"@snapshot-labs/snapshot.js": "^0.4.20",
"@uniswap/sdk-core": "^3.0.1",
"@uniswap/v3-sdk": "^3.9.0",
"copyfiles": "^2.4.1",
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import strategies from './strategies';
import validations from './validations';
import utils from './utils';

export default {
strategies,
validations,
utils
};
24 changes: 24 additions & 0 deletions src/strategies/arrow-vesting/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# arrow-vesting

This strategy returns voters underlying token balance for a given Arrow vesting contract factory.

Token balance for is address is equal to the sum of the locked balance in all vesting contracts holding it
as a beneficiary.

## Params

- `address` - (**Required**, `string`) Address of ERC20 token contract
- `symbol` - (**Optional**, `string`) Symbol of ERC20 token
- `decimals` - (**Required**, `number`) Decimal precision for ERC20 token
- `vestingFactory` - (**Required**, `string`) Address of Vesting Escrow Factory that creates vesting contracts holding ERC20 tokens

Here is an example of parameters:

```json
{
"address": "0x78b3C724A2F663D11373C4a1978689271895256f",
"symbol": "ARROW",
"decimals": 18,
"vestingFactory": "0xB93427b83573C8F27a08A909045c3e809610411a"
}
```
23 changes: 23 additions & 0 deletions src/strategies/arrow-vesting/examples.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
{
"name": "Example query",
"strategy": {
"name": "arrow-vesting",
"params": {
"address": "0x78b3C724A2F663D11373C4a1978689271895256f",
"symbol": "ARROW",
"decimals": 18,
"vestingFactory": "0xB93427b83573C8F27a08A909045c3e809610411a"
}
},
"network": "10",
"addresses": [
"0xaDc17e5f0e9F755C717B2beE43B590260034b852",
"0xB66f08DBd7A59B32e98033b9A1da08B5793DAb79",
"0x5b8eD2A2CfFCD474B2E688fdeA21CB5c4350E575",
"0x03b5Dc2CE78a7bEe9F66DD619b291595a2E166BB",
"0x06A61f56de8c6a2735D1Dea68340D201ddEd7348"
],
"snapshot": 18879362
}
]
112 changes: 112 additions & 0 deletions src/strategies/arrow-vesting/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import { BigNumberish, BigNumber } from '@ethersproject/bignumber';
import { Contract } from '@ethersproject/contracts';
import { formatUnits } from '@ethersproject/units';
import { Multicaller } from '../../utils';

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

const vestingFactoryAbi = [
'function escrows_length() public view returns (uint256)',
'function escrows(uint256 index) public view returns (address)'
];

const vestingContractAbi = [
'function recipient() public view returns (address)'
];

const tokenAbi = [
'function balanceOf(address account) 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';

// Get all vesting contract addresses.
const vestingFactory = new Contract(
options.vestingFactory,
vestingFactoryAbi,
provider
);

const vestingContractCount = await vestingFactory.escrows_length();

const vestingFactoryMulti = new Multicaller(
network,
provider,
vestingFactoryAbi,
{ blockTag }
);

[...Array(vestingContractCount.toNumber()).keys()].forEach((contractIdx) => {
vestingFactoryMulti.call(contractIdx, options.vestingFactory, 'escrows', [
contractIdx
]);
});

const vestingContracts: Record<number, string> =
await vestingFactoryMulti.execute();

// Get all beneficiaries of vesting contracts.
const vestingContractMulti = new Multicaller(
network,
provider,
vestingContractAbi,
{ blockTag }
);

Object.values(vestingContracts).forEach((vestingContractAddress) => {
vestingContractMulti.call(
vestingContractAddress,
vestingContractAddress,
'recipient',
[]
);
});

const vestingContractRecipients: Record<string, string> =
await vestingContractMulti.execute();

// Get all balances of vesting contracts.
const tokenMulti = new Multicaller(network, provider, tokenAbi, { blockTag });

Object.values(vestingContracts).forEach((vestingContractAddress) => {
tokenMulti.call(vestingContractAddress, options.address, 'balanceOf', [
vestingContractAddress
]);
});

const vestingContractBalances: Record<string, BigNumberish> =
await tokenMulti.execute();

// Sum all vesting contract balances by recipient over requested addresses.
const addressBalances: Record<string, BigNumber> = {};

addresses.forEach((address) => {
addressBalances[address] = BigNumber.from(0);
});

Object.values(vestingContracts).forEach((vestingContractAddress) => {
const recipient = vestingContractRecipients[vestingContractAddress];

if (recipient in addressBalances) {
addressBalances[recipient] = addressBalances[recipient].add(
vestingContractBalances[vestingContractAddress]
);
}
});

return Object.fromEntries(
Object.entries(addressBalances).map(([address, balance]) => [
address,
parseFloat(formatUnits(balance, options.decimals))
])
);
}
30 changes: 30 additions & 0 deletions src/strategies/aura-balance-of-vlaura-vebal/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# aura-balance-of-vlaura-vebal

This strategy returns proportional voting power for vlAURA holders based on system owned veBAL.

The voting power is based on the raw balance, rather than delegated voting power.

For example:
- there are 10000 vlAURA total supply
- a user has 2000 vlAURA (raw balance)
- Aura's voterProxy owns 100k veBAL

In this example, the user has 20k veBAL balance as they own 20% of the vlAURA voting power.

_Note: When depositing to the auraLocker, a user does not receive vlAURA until the next epoch has begun (Thursday at 00:00 UTC)_

## Params

- `auraLocker` - (**Required**, `string`) Address of AuraLocker (vlAURA) contract
- `auraVoterProxy` - (**Required**, `string`) Address of Aura VoterProxy contract
- `votingEscrow` - (**Required**, `string`) Address of Balancer VotingEscrow contract

Here is an example of parameters:

```json
{
"auraLocker": "0x3Fa73f1E5d8A792C80F426fc8F84FBF7Ce9bBCAC",
"auraVoterProxy": "0xaF52695E1bB01A16D33D7194C28C42b10e0Dbec2",
"votingEscrow": "0xC128a9954e6c874eA3d62ce62B468bA073093F25"
}
```
20 changes: 20 additions & 0 deletions src/strategies/aura-balance-of-vlaura-vebal/examples.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"name": "Example query",
"strategy": {
"name": "aura-balance-of-vlaura-vebal",
"params": {
"auraLocker": "0x3Fa73f1E5d8A792C80F426fc8F84FBF7Ce9bBCAC",
"auraVoterProxy": "0xaF52695E1bB01A16D33D7194C28C42b10e0Dbec2",
"votingEscrow": "0xC128a9954e6c874eA3d62ce62B468bA073093F25"
}
},
"network": "1",
"addresses": [
"0x512fce9B07Ce64590849115EE6B32fd40eC0f5F3",
"0x808af82545A721C06D1FcCEbea915a6F5128BeF9",
"0x0CAd1d5ea8b4EeE26959cC00B4A3677f7A11e40F"
],
"snapshot": 15276577
}
]
58 changes: 58 additions & 0 deletions src/strategies/aura-balance-of-vlaura-vebal/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { BigNumber } from '@ethersproject/bignumber';
import { formatUnits } from '@ethersproject/units';
import { Multicaller } from '../../utils';

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

const abi = [
'function balanceOf(address account) public view returns (uint256)',
'function totalSupply() public view returns (uint256)'
];

interface Params {
auraLocker: string;
auraVoterProxy: string;
votingEscrow: string;
}

interface Response {
vlAuraTotalSupply: BigNumber;
vlAuraBalance: Record<string, BigNumber>;
veBalOwnedByAura: BigNumber;
}

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

const multi = new Multicaller(network, provider, abi, { blockTag });
multi.call('vlAuraTotalSupply', options.auraLocker, 'totalSupply', []);
addresses.forEach((address) =>
multi.call(`vlAuraBalance.${address}`, options.auraLocker, 'balanceOf', [
address
])
);
multi.call('veBalOwnedByAura', options.votingEscrow, 'balanceOf', [
options.auraVoterProxy
]);
const res: Response = await multi.execute();

return Object.fromEntries(
Object.entries(res.vlAuraBalance).map(([address, balance]) => [
address,
parseFloat(
formatUnits(
res.veBalOwnedByAura.mul(balance).div(res.vlAuraTotalSupply),
18
)
)
])
);
}
38 changes: 38 additions & 0 deletions src/strategies/aura-balance-of-vlaura-vebal/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "#/definitions/Strategy",
"definitions": {
"Strategy": {
"title": "Strategy",
"type": "object",
"properties": {
"auraLocker": {
"type": "string",
"title": "auraLocker",
"examples": ["e.g. 0x3Fa73f1E5d8A792C80F426fc8F84FBF7Ce9bBCAC"],
"pattern": "^0x[a-fA-F0-9]{40}$",
"minLength": 42,
"maxLength": 42
},
"auraVoterProxy": {
"type": "string",
"title": "auraVoterProxy",
"examples": ["e.g. 0xaF52695E1bB01A16D33D7194C28C42b10e0Dbec2"],
"pattern": "^0x[a-fA-F0-9]{40}$",
"minLength": 42,
"maxLength": 42
},
"votingEscrow": {
"type": "string",
"title": "votingEscrow",
"examples": ["e.g. 0xC128a9954e6c874eA3d62ce62B468bA073093F25"],
"pattern": "^0x[a-fA-F0-9]{40}$",
"minLength": 42,
"maxLength": 42
}
},
"required": ["auraLocker", "auraVoterProxy", "votingEscrow"],
"additionalProperties": false
}
}
}
24 changes: 24 additions & 0 deletions src/strategies/balance-of-subgraph/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Balance of subgraph

To calculate the token balance including user's EOA and smart wallet, we developed this strategy. Developers can create their own subparagraphs using the below scheme, and the score will be calculated as a result.

```
users{
id
amount
}
```


## Example

The space config will look like this:

```JSON
{
// subgraphURL for the request
"subGraphURL": "https://api.thegraph.com/subgraphs/name/dinngodev/furucombo-tokenomics-mainnet",
// scoreMultiplier can be used to increase users' scores by a certain magnitude
"scoreMultiplier": 1,
}
```
17 changes: 17 additions & 0 deletions src/strategies/balance-of-subgraph/examples.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"name": "Example query",
"strategy": {
"name": "balance-of-subgraph",
"params": {
"subGraphURL": "https://api.thegraph.com/subgraphs/name/dinngodev/furucombo-tokenomics-mainnet"
}
},
"network": "1",
"addresses": [
"0xe4ef29545db14e252AeC1c660A004e2408Dc62d2",
"0xa3c1c91403f0026b9dd086882adbc8cdbc3b3cfb"
],
"snapshot": 14716396
}
]
Loading

0 comments on commit fa8a06a

Please sign in to comment.