-
Notifications
You must be signed in to change notification settings - Fork 503
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
Rebrand Visor => Gamma, track registry contract #532
Open
l0c4t0r
wants to merge
7
commits into
ConcourseOpen:staging
Choose a base branch
from
l0c4t0r:gamma_registry
base: staging
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 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2c8104a
Clipper Polygon & Ethereum mainnet adapters
EdoAPP e6f8854
Fix autogenerated comments
EdoAPP 5a9eeeb
Update ethereum start timestamp
EdoAPP 7df595b
Merge pull request #496 from shipyard-software/clipper-adapter
arman37 d0ff45e
Visor rebrand => Gamma, track registry contract
l0c4t0r a3c0900
Merge branch 'staging' of github-loc:ConcourseOpen/DeFi-Pulse-Adapter…
l0c4t0r 7ac7ec0
Fix merge conflict
l0c4t0r 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,30 @@ | ||
{ | ||
"token0": { | ||
"inputs": [], | ||
"name": "token0", | ||
"outputs": [ | ||
{ "internalType": "contract IERC20", "name": "", "type": "address" } | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
"token1": { | ||
"inputs": [], | ||
"name": "token1", | ||
"outputs": [ | ||
{ "internalType": "contract IERC20", "name": "", "type": "address" } | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
"getTotalAmounts": { | ||
"inputs": [], | ||
"name": "getTotalAmounts", | ||
"outputs": [ | ||
{ "internalType": "uint256", "name": "total0", "type": "uint256" }, | ||
{ "internalType": "uint256", "name": "total1", "type": "uint256" } | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
} | ||
} |
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,105 @@ | ||
/*================================================== | ||
Modules | ||
==================================================*/ | ||
|
||
const BigNumber = require('bignumber.js'); | ||
const sdk = require('../../sdk'); | ||
const hypervisorABI = require('./abis/hypervisor.json'); | ||
|
||
/*================================================== | ||
Constants | ||
==================================================*/ | ||
|
||
const HYPE_REGISTRY = "0x31CcDb5bd6322483bebD0787e1DABd1Bf1f14946" | ||
|
||
/*================================================== | ||
TVL | ||
==================================================*/ | ||
|
||
async function tvl(timestamp, block) { | ||
|
||
// Set ETH placeholder in balances | ||
const ethAddress = '0x0000000000000000000000000000000000000000'; | ||
let balances = { | ||
[ethAddress]: '0', // ETH | ||
}; | ||
|
||
const hypervisorCalls = await sdk.api.util.getLogs({ | ||
keys: ['data'], | ||
toBlock: block, | ||
target: HYPE_REGISTRY, | ||
fromBlock: 13659998, | ||
topic: 'HypeAdded(address,uint256)', | ||
}).then( | ||
({output}) => output.map( | ||
logItem => ({ | ||
target: `0x${logItem.data.substr(26, 40)}`.toLowerCase() | ||
}) | ||
) | ||
); | ||
|
||
// Make call to hypervisor to get token and balance | ||
const hypeData = await Promise.all([ | ||
sdk.api.abi.multiCall({ | ||
abi: hypervisorABI.token0, | ||
calls: hypervisorCalls, | ||
block, | ||
}).then( | ||
({output}) => output.map( | ||
item => item.output | ||
) | ||
), | ||
sdk.api.abi.multiCall({ | ||
abi: hypervisorABI.token1, | ||
calls: hypervisorCalls, | ||
block, | ||
}).then( | ||
({output}) => output.map( | ||
item => item.output | ||
) | ||
), | ||
sdk.api.abi.multiCall({ | ||
abi: hypervisorABI.getTotalAmounts, | ||
calls: hypervisorCalls, | ||
block, | ||
}).then( | ||
({output}) => output.map( | ||
(item) => ({ | ||
success: item.success, | ||
total0: item.success ? item.output.total0 : 0, | ||
total1: item.success ? item.output.total1 : 0, | ||
}) | ||
) | ||
) | ||
]) | ||
|
||
let token0Addresses = hypeData[0] | ||
let token1Addresses = hypeData[1] | ||
let tokenAmounts = hypeData[2] | ||
|
||
for (const [index, amounts] of tokenAmounts.entries()) { | ||
if (amounts.success) { | ||
let address0 = token0Addresses[index] | ||
let address1 = token1Addresses[index] | ||
let balance0 = amounts.total0 | ||
let balance1 = amounts.total1 | ||
|
||
balances[address0] = BigNumber(balances[address0] || 0).plus(balance0).toFixed() | ||
balances[address1] = BigNumber(balances[address1] || 0).plus(balance1).toFixed() | ||
} | ||
} | ||
|
||
return balances; | ||
} | ||
|
||
/*================================================== | ||
Exports | ||
==================================================*/ | ||
|
||
module.exports = { | ||
name: 'Gamma', | ||
token: 'GAMMA', | ||
category: 'assets', // allowed values as shown on DefiPulse: 'Derivatives', 'DEXes', 'Lending', 'Payments', 'Assets' | ||
start: 1623078120, // June 7, 2021 23:02 | ||
tvl | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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.
Thanks for the pull request.
Could you fix this left over conflict here?
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.
Ah missed this while merging in. Fixed now, thanks.