-
Notifications
You must be signed in to change notification settings - Fork 781
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
[derpdex-xderp-yield-booster]Added derpdex-xderp-yield-booster strategy #1375
Open
geckocoding
wants to merge
1
commit into
snapshot-labs:master
Choose a base branch
from
derpdex-official:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# derpdex-xderp-yield-booster | ||
|
||
This is the DerpDEX xDERP strategy for yield booster users, it returns the balances of the allocated tokens in yield booster for the users. | ||
|
||
Here is an example of parameters: | ||
|
||
```json | ||
{ | ||
"address": "0xd377088F3026536682Bf58Cc74448a5B31490C46", | ||
"symbol": "xDERP", | ||
"decimals": 18 | ||
} | ||
``` |
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,20 @@ | ||
[ | ||
{ | ||
"name": "Example query", | ||
"strategy": { | ||
"name": "derpdex-xderp-yield-booster", | ||
"params": { | ||
"address": "0xd377088F3026536682Bf58Cc74448a5B31490C46", | ||
"symbol": "xDERP", | ||
"decimals": 18 | ||
} | ||
}, | ||
"network": "324", | ||
"addresses": [ | ||
"0x440097Cebd3b8C20ec43bA4A9395e252BF41dcCc", | ||
"0x945bB7BD5AD143279647825544Ab94395D435d15", | ||
"0x01043868e5079cE26ba2694638B2282Ccae7BA53" | ||
], | ||
"snapshot": 21537650 | ||
} | ||
] |
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,34 @@ | ||
import { BigNumberish } from '@ethersproject/bignumber'; | ||
import { formatUnits } from '@ethersproject/units'; | ||
import { Multicaller } from '../../utils'; | ||
|
||
export const author = 'bonustrack'; | ||
export const version = '0.1.1'; | ||
|
||
const abi = [ | ||
'function userTotalAllocations(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'; | ||
|
||
const multi = new Multicaller(network, provider, abi, { blockTag }); | ||
addresses.forEach((address) => | ||
multi.call(address, options.address, 'userTotalAllocations', [address]) | ||
); | ||
const result: Record<string, BigNumberish> = await multi.execute(); | ||
|
||
return Object.fromEntries( | ||
Object.entries(result).map(([address, balance]) => [ | ||
address, | ||
parseFloat(formatUnits(balance, options.decimals)) | ||
]) | ||
); | ||
} |
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 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$ref": "#/definitions/Strategy", | ||
"definitions": { | ||
"Strategy": { | ||
"title": "Strategy", | ||
"type": "object", | ||
"properties": { | ||
"symbol": { | ||
"type": "string", | ||
"title": "Symbol", | ||
"examples": ["e.g. xDERP"], | ||
"maxLength": 16 | ||
}, | ||
"address": { | ||
"type": "string", | ||
"title": "Contract address", | ||
"examples": ["e.g. 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984"], | ||
"pattern": "^0x[a-fA-F0-9]{40}$", | ||
"minLength": 42, | ||
"maxLength": 42 | ||
}, | ||
"decimals": { | ||
"type": "number", | ||
"title": "Decimals", | ||
"examples": ["e.g. 18"] | ||
} | ||
}, | ||
"required": ["address", "decimals"], | ||
"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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @geckocoding You can directly use contract-call strategy in your space, no need to create a seperate one. :) let me know