-
Notifications
You must be signed in to change notification settings - Fork 241
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
feat(#major); eBTC; new subgraph #2301
Closed
Closed
Changes from all commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
ec49472
feat: price feed mappings including native btc price
gosuto-inzasheru df1daa4
feat: add support for hosted subgraph
gosuto-inzasheru e0ac3da
chore: record cli commands in notes
gosuto-inzasheru 56c9755
chore: add urls
gosuto-inzasheru c089ce0
chore: yaml is always being built, no bool needed
gosuto-inzasheru ac9b6c3
Merge branch 'messari:master' into feat/sdk_pivot
gosuto-inzasheru 7fff7c3
chore: add goerli bpt pools
gosuto-inzasheru 9b80d8a
chore: consolidate sdk constants
gosuto-inzasheru df408af
fix: `constants.ts` got moved
gosuto-inzasheru 18cdd15
fix: add missing type helper
gosuto-inzasheru 2d4f042
feat: add `ActivePool` data source
gosuto-inzasheru 264c215
fix: adjust relative import dir
gosuto-inzasheru a3746b3
fix: only comment actual lines in the functions
gosuto-inzasheru ea331db
fix: `decimalValue` needs to be `i32`
gosuto-inzasheru a97040c
fix: `decimalValue` needs to be of type `i32`
gosuto-inzasheru e435522
fix: add `PRICE_FEED` constant
gosuto-inzasheru 3a6b4b5
perf: grab blocks and timestamps from actual event
gosuto-inzasheru 24b3b0b
feat: update market with ebtc specifics
gosuto-inzasheru c576297
Merge pull request #21 from Badger-Finance/feat/init_protocol
gosuto-inzasheru 015d1dd
refactor: add helper for instantiating data manager
gosuto-inzasheru adf0f81
chore: rename `_ERC20` to `ERC20`
gosuto-inzasheru 4d14147
refactor: use data and token managers instead of custom functions
gosuto-inzasheru 2be5864
chore: remove unused imports
gosuto-inzasheru 45db46e
refactor: move all erc20 interfaces to `PriceFeed`
gosuto-inzasheru 4d38a32
fix: correct name for protocol
gosuto-inzasheru 5ef84cc
chore: clean up comments
gosuto-inzasheru c2b3977
chore: bump schema and sdk
gosuto-inzasheru e2f84c7
feat: handle `CdpUpdated`
gosuto-inzasheru 9fe2cac
docs: add query that returns most important fields
gosuto-inzasheru 3aeb340
fix: erc20 interface for prices is different from erc20
gosuto-inzasheru 0bd8ffc
fix: more erc20 related changes
gosuto-inzasheru 72dd798
Merge pull request #22 from Badger-Finance/feat/leverage_token_manager
gosuto-inzasheru b91c5d8
chore: update prices sdk to newer version
gosuto-inzasheru a241cda
Merge pull request #23 from Badger-Finance/chore/update_sdk_prices
gosuto-inzasheru 6df8c23
chore: include abi
gosuto-inzasheru a6e3549
chore: include `BorrowerOperations` in template
gosuto-inzasheru e7901de
feat: track all events for now
gosuto-inzasheru 3156e2a
feat: handle user deposits and withdrawals
gosuto-inzasheru 32a75e7
feat: handle flash loans
gosuto-inzasheru 903a679
fix: revert to previous price lib
gosuto-inzasheru fcaca03
chore: move `handelSystemDeployed` to `ActivePool`
gosuto-inzasheru 0b7e947
fix: `handleSystemDeployed` is now in `ActivePool`
gosuto-inzasheru af160cd
fix: each data source needs its reference to the jsons
gosuto-inzasheru 3bccffb
fix: functions need to be exported explicitly
gosuto-inzasheru 08e8a86
docs: add instructions for deploying a scaffold subgraph
gosuto-inzasheru a5c7aed
chore: move `createLiquidate` to `CdpManager`
gosuto-inzasheru a9c3dc3
docs: extend query with lending protocol fields
gosuto-inzasheru 1b9be2f
feat: handle liquidations
gosuto-inzasheru 7714e36
fix: `CdpManager` needs price oracle abis
gosuto-inzasheru de0af46
feat: add borrows and repays, fix when delta is zero
gosuto-inzasheru 1795d2b
docs: add `flashloans` to query
gosuto-inzasheru 8074111
fix: listen for `CdpLiquidated` instead of `Liquidation`
gosuto-inzasheru af0b95d
docs: add liquidates to query
gosuto-inzasheru f2c9109
chore: add note about price calc
gosuto-inzasheru 75e15ee
Merge pull request #24 from Badger-Finance/feat/include_borrow_ops
gosuto-inzasheru 28a248b
Merge branch 'master' into feat/sdk_pivot
gosuto-inzasheru 69966f8
style: lint for upstream
gosuto-inzasheru e06587e
perf: remove unused imports
gosuto-inzasheru cb073db
Merge branch 'master' into feat/sdk_pivot
gosuto-inzasheru 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 |
---|---|---|
|
@@ -9148,5 +9148,38 @@ | |
} | ||
} | ||
} | ||
}, | ||
"ebtc": { | ||
"schema": "lending", | ||
"base": "ebtc", | ||
"protocol": "ebtc", | ||
"project": "ebtc", | ||
"deployments": { | ||
"ebtc-goerli": { | ||
"network": "goerli", | ||
"status": "dev", | ||
"versions": { | ||
"schema": "3.0.1", | ||
"subgraph": "0.0.1", | ||
"methodology": "0.0.1" | ||
Comment on lines
+9163
to
+9164
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Start version is |
||
}, | ||
"files": { | ||
"template": "ebtc.template.yaml" | ||
}, | ||
"options": { | ||
"prepare:constants": true | ||
}, | ||
"services": { | ||
"decentralized-network": { | ||
"slug": "ebtc-goerli", | ||
"query-id": "QmdZphstRBDgd6teT5dhQDZ84H6bsqwTy8tEj579JFhqwU" | ||
}, | ||
"hosted-service": { | ||
"slug": "ebtc-goerli", | ||
"query-id": "ebtc-goerli" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -24,6 +24,7 @@ enum Network { | |
OSMOSIS | ||
MATIC # aka Polygon | ||
GNOSIS | ||
GOERLI | ||
} | ||
|
||
enum ProtocolType { | ||
|
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,122 @@ | ||
/* eslint-disable @typescript-eslint/no-magic-numbers */ | ||
import { Address, BigInt } from "@graphprotocol/graph-ts"; | ||
import { Configurations, OracleContract } from "../common/types"; | ||
|
||
export const NETWORK_STRING = "goerli"; | ||
|
||
/////////////////////////////////////////////////////////////////////////// | ||
///////////////////// CALCULATIONS/ORACLE CONTRACT //////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
|
||
export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract(); | ||
export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract(); | ||
export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract(); | ||
export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract(); | ||
|
||
/////////////////////////////////////////////////////////////////////////// | ||
///////////////////////////// CURVE CONTRACT ////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
|
||
export const CURVE_CALCULATIONS_ADDRESS = new OracleContract(); | ||
export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = []; | ||
|
||
/////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////// UNISWAP FORKS CONTRACT //////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
|
||
export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = [ | ||
new OracleContract("0x7a250d5630b4cf539739df2c5dacb4c659f2488d", 2822883), // Uniswap | ||
]; | ||
|
||
/////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////// BLACKLISTED TOKENS //////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
|
||
export const YEARN_LENS_BLACKLIST: Address[] = []; | ||
export const AAVE_ORACLE_BLACKLIST: Address[] = []; | ||
export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = []; | ||
export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = []; | ||
|
||
/////////////////////////////////////////////////////////////////////////// | ||
//////////////////////////// HARDCODED STABLES //////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
|
||
export const HARDCODED_STABLES: Address[] = []; | ||
|
||
/////////////////////////////////////////////////////////////////////////// | ||
///////////////////////////////// HELPERS ///////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
|
||
export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6); | ||
|
||
export const ETH_ADDRESS = Address.fromString( | ||
"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" | ||
); | ||
export const WETH_ADDRESS = Address.fromString( | ||
"0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6" | ||
); | ||
export const USDC_ADDRESS = Address.fromString( | ||
"0xd87ba7a50b2e7e660f678a895e4b72e7cb4ccd9c" | ||
); | ||
|
||
export class config implements Configurations { | ||
network(): string { | ||
return NETWORK_STRING; | ||
} | ||
|
||
yearnLens(): OracleContract { | ||
return YEARN_LENS_CONTRACT_ADDRESS; | ||
} | ||
chainLink(): OracleContract { | ||
return CHAIN_LINK_CONTRACT_ADDRESS; | ||
} | ||
yearnLensBlacklist(): Address[] { | ||
return YEARN_LENS_BLACKLIST; | ||
} | ||
|
||
aaveOracle(): OracleContract { | ||
return AAVE_ORACLE_CONTRACT_ADDRESS; | ||
} | ||
aaveOracleBlacklist(): Address[] { | ||
return AAVE_ORACLE_BLACKLIST; | ||
} | ||
|
||
curveCalculations(): OracleContract { | ||
return CURVE_CALCULATIONS_ADDRESS; | ||
} | ||
curveCalculationsBlacklist(): Address[] { | ||
return CURVE_CALCULATIONS_BLACKSLIST; | ||
} | ||
|
||
sushiCalculations(): OracleContract { | ||
return SUSHISWAP_CALCULATIONS_ADDRESS; | ||
} | ||
sushiCalculationsBlacklist(): Address[] { | ||
return SUSHI_CALCULATIONS_BLACKSLIST; | ||
} | ||
|
||
uniswapForks(): OracleContract[] { | ||
return UNISWAP_FORKS_ROUTER_ADDRESSES; | ||
} | ||
curveRegistry(): OracleContract[] { | ||
return CURVE_REGISTRY_ADDRESSES; | ||
} | ||
|
||
hardcodedStables(): Address[] { | ||
return HARDCODED_STABLES; | ||
} | ||
|
||
ethAddress(): Address { | ||
return ETH_ADDRESS; | ||
} | ||
wethAddress(): Address { | ||
return WETH_ADDRESS; | ||
} | ||
usdcAddress(): Address { | ||
return USDC_ADDRESS; | ||
} | ||
|
||
usdcTokenDecimals(): BigInt { | ||
return USDC_TOKEN_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,2 @@ | ||
# gets generated from constants.mustache | ||
src/constants.ts |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can probably be merged into the README.md and the |
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,56 @@ | ||
### URLs | ||
|
||
- `hosted-service`: https://thegraph.com/hosted-service/subgraph/badger-finance/ebtc-goerli | ||
- `decentralized-network`: https://testnet.thegraph.com/explorer/subgraphs/HgyK4pup4x75snqPrvTbbzeRsqPExHXmf2zRJPiXFjiU | ||
|
||
### Goerli | ||
|
||
- https://docs.chain.link/data-feeds/price-feeds/addresses#Goerli%20Testnet | ||
- collEthCLFeed: `0xb4c4a493AB6356497713A78FFA6c60FB53517c63` | ||
- ethBtcCLFeed: `0x779877A7B0D9E8603169DdbD7836e478b4624789` | ||
- testMsig (account holder for decentralised subgraph studio): `0xfA87ce273f8C254F345Bc7de42F30e2d2FEe6779` | ||
- ebtc/wbtc bpt pool: `0x070d3BDf2cd2e7067AFADC40857E8b657a057417` | ||
- ebtc/collateral bpt pool: `0xB1d4d8eFe062C83F1e7C816E9fbd74D752927250` | ||
|
||
### CLI Commands | ||
|
||
``` | ||
graph auth --product subgraph-studio *** | ||
messari b -l -s subgraph-studio ebtc -r ebtc-goerli -v 0.0.0 -d | ||
``` | ||
|
||
``` | ||
graph auth --product hosted-service *** | ||
messari b -l -s hosted-service ebtc -r badger-finance -d | ||
``` | ||
|
||
``` | ||
graph init --product=hosted-service --protocol=ethereum --from-contract=0x7Cbde961F8aDB94c8A7660Abe1f3e647dbB8513f --network=goerli --index-events --start-block=9129595 --contract-name=CdpManager badger-finance/ebtc-goerli-scaffold | ||
|
||
cd ebtc-goerli-scaffold | ||
|
||
***change graph-cli and graph-ts version to "*" in package.json*** | ||
|
||
yarn | ||
|
||
yarn codegen && yarn build && yarn deploy | ||
``` | ||
|
||
**NOTE: Omit the `-d` for a dry run without deployment** | ||
|
||
### Test GQL Queries | ||
|
||
`PriceFeed`: | ||
|
||
``` | ||
{ | ||
tokens(first: 5) { | ||
id | ||
name | ||
symbol | ||
decimals | ||
lastPriceUSD | ||
lastPriceBlockNumber | ||
} | ||
} | ||
``` |
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,147 @@ | ||
{ | ||
protocols { | ||
borrowerPermissionType | ||
collateralizationType | ||
cumulativeProtocolSideRevenueUSD | ||
cumulativeSupplySideRevenueUSD | ||
cumulativeTotalRevenueUSD | ||
cumulativeUniqueUsers | ||
id | ||
lenderPermissionType | ||
lendingType | ||
methodologyVersion | ||
name | ||
network | ||
poolCreatorPermissionType | ||
protocol | ||
protocolControlledValueUSD | ||
riskType | ||
schemaVersion | ||
slug | ||
subgraphVersion | ||
totalPoolCount | ||
totalValueLockedUSD | ||
type | ||
... on LendingProtocol { | ||
borrowCount | ||
borrowerPermissionType | ||
collateralizationType | ||
cumulativeBorrowUSD | ||
cumulativeDepositUSD | ||
cumulativeLiquidateUSD | ||
cumulativePositionCount | ||
cumulativeProtocolSideRevenueUSD | ||
cumulativeSupplySideRevenueUSD | ||
cumulativeTotalRevenueUSD | ||
cumulativeUniqueBorrowers | ||
cumulativeUniqueDepositors | ||
cumulativeUniqueLiquidatees | ||
cumulativeUniqueLiquidators | ||
cumulativeUniqueUsers | ||
depositCount | ||
flashloanCount | ||
id | ||
lenderPermissionType | ||
lendingType | ||
liquidationCount | ||
methodologyVersion | ||
mintedTokenSupplies | ||
name | ||
network | ||
openPositionCount | ||
poolCreatorPermissionType | ||
protocol | ||
protocolControlledValueUSD | ||
repayCount | ||
rewardTokenEmissionsAmount | ||
rewardTokenEmissionsUSD | ||
riskType | ||
schemaVersion | ||
slug | ||
subgraphVersion | ||
totalBorrowBalanceUSD | ||
totalDepositBalanceUSD | ||
totalPoolCount | ||
totalValueLockedUSD | ||
transactionCount | ||
transferCount | ||
type | ||
withdrawCount | ||
} | ||
} | ||
tokens { | ||
decimals | ||
id | ||
lastPriceBlockNumber | ||
lastPriceUSD | ||
name | ||
symbol | ||
type | ||
} | ||
accounts { | ||
borrowCount | ||
closedPositionCount | ||
depositCount | ||
flashloanCount | ||
id | ||
liquidateCount | ||
liquidationCount | ||
openPositionCount | ||
positionCount | ||
receivedCount | ||
repayCount | ||
rewardsClaimedUSD | ||
transferredCount | ||
withdrawCount | ||
} | ||
positions { | ||
balance | ||
blockNumberClosed | ||
blockNumberOpened | ||
borrowCount | ||
depositCount | ||
hashClosed | ||
hashOpened | ||
id | ||
isCollateral | ||
isIsolated | ||
liquidationCount | ||
receivedCount | ||
repayCount | ||
side | ||
timestampClosed | ||
timestampOpened | ||
transferredCount | ||
type | ||
withdrawCount | ||
} | ||
flashloans { | ||
amount | ||
amountUSD | ||
blockNumber | ||
feeAmount | ||
feeAmountUSD | ||
gasLimit | ||
gasPrice | ||
gasUsed | ||
hash | ||
id | ||
logIndex | ||
nonce | ||
timestamp | ||
} | ||
liquidates { | ||
amount | ||
amountUSD | ||
blockNumber | ||
gasLimit | ||
gasPrice | ||
gasUsed | ||
hash | ||
id | ||
logIndex | ||
nonce | ||
profitUSD | ||
timestamp | ||
} | ||
} |
Oops, something went wrong.
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.
When ebtc is deployed on mainnet, will we just change this? As a note, I think we will want to wait until a mainnet deployment to merge this PR too