forked from snapshot-labs/snapshot-strategies
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sunrisegaming-staking] Add sunrisegaming-staking strategy (snapshot-…
…labs#62) * add sunrisegaming-staking * Update src/strategies/sunrisegaming-staking/index.ts Co-authored-by: Chaitanya <[email protected]> * Update src/strategies/sunrisegaming-staking/index.ts Co-authored-by: Chaitanya <[email protected]> Co-authored-by: Chaitanya <[email protected]>
- Loading branch information
1 parent
0415b60
commit 1e77583
Showing
4 changed files
with
91 additions
and
0 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
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,15 @@ | ||
# Sunrise Gaming Staking Token | ||
|
||
This strategy returns balances of the underlying token in Sunrise Staking pools | ||
|
||
Here is an example of parameters: | ||
|
||
```json | ||
{ | ||
"symbol": "SUNC", | ||
"decimals": 18, | ||
"tokenAddress": "0x692accdd8b86692427e0aa4752ae917df01cc56f", | ||
"stakingAddress": "0x7dbE40ac6bB41A5FE4Fa2C74f31d7DEFBC793B58", | ||
"poolIndex": 0 | ||
} | ||
``` |
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,27 @@ | ||
[ | ||
{ | ||
"name": "Sunrise Staked token", | ||
"strategy": { | ||
"name": "sunrisegaming-staking", | ||
"params": { | ||
"symbol": "SUNC", | ||
"decimals": 18, | ||
"tokenAddress": "0x692accdd8b86692427e0aa4752ae917df01cc56f", | ||
"stakingAddress": "0x7dbE40ac6bB41A5FE4Fa2C74f31d7DEFBC793B58", | ||
"poolIndex": 0 | ||
} | ||
}, | ||
"network": "1", | ||
"addresses": [ | ||
"0x7dbe40ac6bb41a5fe4fa2c74f31d7defbc793b58", | ||
"0x26533020822f9b28c801e6beb772ef74dfe0c81e", | ||
"0x75bd5989ce8f962a1864d8a0af8bfb5130805722", | ||
"0x7505afcd576bb995577a944bccdb5c54c7d5ec45", | ||
"0x930af93baa5f2c2f71bafd5a2fd7b1d47a61c352", | ||
"0xbc444050d78107872c0262452fff004da9208258", | ||
"0x26533020822f9b28c801e6beb772ef74dfe0c81e", | ||
"0x45e049241b69df70cead33ef5a41d2d0a128ce01" | ||
], | ||
"snapshot": 13229798 | ||
} | ||
] |
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,47 @@ | ||
import { multicall } from '../../utils'; | ||
import { formatUnits } from '@ethersproject/units'; | ||
import { BigNumber } from '@ethersproject/bignumber'; | ||
|
||
export const author = 'sunrisedao'; | ||
export const version = '0.1.0'; | ||
|
||
const masterChefAbi = [ | ||
'function userInfo(uint256, address) view returns (uint256 amount, uint256 rewardDebt)' | ||
]; | ||
|
||
function bn(num: any): BigNumber { | ||
return BigNumber.from(num.toString()); | ||
} | ||
|
||
export async function strategy( | ||
_space, | ||
network, | ||
provider, | ||
addresses, | ||
options, | ||
snapshot | ||
) { | ||
const blockTag = typeof snapshot === 'number' ? snapshot : 'latest'; | ||
|
||
// Get staked LP in staking constract | ||
let stakedRes = await multicall( | ||
network, | ||
provider, | ||
masterChefAbi, | ||
[ | ||
...addresses.map((address: any) => [ | ||
options.stakingAddress, | ||
'userInfo', | ||
[options.poolIndex, address] | ||
]) | ||
], | ||
{ blockTag } | ||
); | ||
|
||
return Object.fromEntries( | ||
stakedRes.map((stakedInfo, i) => { | ||
const parsedAmount = parseFloat(formatUnits(bn(stakedInfo.amount), options.decimal)); | ||
return [addresses[i], parsedAmount]; | ||
}) | ||
); | ||
} |