Skip to content

Commit

Permalink
Merge pull request #7 from sushiswap/updated_subgraph
Browse files Browse the repository at this point in the history
Updated subgraph
  • Loading branch information
jiro-ono authored Dec 17, 2020
2 parents fc0892e + a2836dc commit 0a11d80
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 26 deletions.
93 changes: 68 additions & 25 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const pageResults = require('graph-results-pager')
const ethers = require('ethers')

const graphAPIEndpoints = {
bento: 'https://api.thegraph.com/subgraphs/name/jiro-ono/bento-trial',
bento: 'https://api.thegraph.com/subgraphs/name/jiro-ono/bento-trial-staging',
}

module.exports = {
Expand All @@ -19,10 +19,10 @@ module.exports = {
properties: [
'id',
'lendingPairsCount',
'lendingPairs { id, asset, borrowOpeningFee, closedCollaterizationRate, collateral, decimals, dev, devFee, exchangeRate, feeTo, feesPendingAmount, interestElasticity, interestPerBlock, lastBlockAccrued, liquidationMultiplier, masterContract, maximumInterestPerBlock, maximumTargetUtilization, name, openCollaterizationRate, oracle, owner, pendingOwner, protocolFee, startingInterestPerBlock, symbol, totalAssetAmount, totalAssetFraction, totalBorrowFraction, totalBorrowAmount, totalCollateralAmount, utilization, block, timestamp }',
'tokens { id, totalSupply, block, timestamp }',
'withdrawals { id, from { id }, to, token { id, totalSupply, block, timestamp }, amount, block, timestamp }',
'deposits { id, from { id }, to { id }, token { id, totalSupply, block, timestamp }, amount, block, timestamp }',
'lendingPairs { id, asset { id, totalSupply, name, symbol, decimals }, borrowOpeningFee, closedCollaterizationRate, collateral { id, totalSupply, name, symbol, decimals }, decimals, dev, devFee, exchangeRate, feeTo, feesPendingAmount, interestElasticity, interestPerBlock, lastBlockAccrued, liquidationMultiplier, masterContract, maximumInterestPerBlock, maximumTargetUtilization, name, openCollaterizationRate, oracle, owner, pendingOwner, protocolFee, startingInterestPerBlock, symbol, totalAssetAmount, totalAssetFraction, totalBorrowFraction, totalBorrowAmount, totalCollateralAmount, utilization, block, timestamp }',
'tokens { id, totalSupply, name, symbol, decimals, block, timestamp }',
'withdrawals { id, from { id }, to { id }, token { id, totalSupply, name, symbol, decimals, block, timestamp }, amount, block, timestamp }',
'deposits { id, from { id }, to { id }, token { id, totalSupply, name, symbol, decimals, block, timestamp }, amount, block, timestamp }',
]
}
})
Expand All @@ -32,10 +32,18 @@ module.exports = {
lendingPairsCount: ethers.BigNumber.from(lendingPairsCount),
lendingPairs: lendingPairs.map(({ id, asset, borrowOpeningFee, closedCollaterizationRate, collateral, decimals, dev, devFee, exchangeRate, feeTo, feesPendingAmount, interestElasticity, interestPerBlock, lastBlockAccrued, liquidationMultiplier, masterContract, maximumInterestPerBlock, maximumTargetUtilization, name, openCollaterizationRate, oracle, owner, pendingOwner, protocolFee, startingInterestPerBlock, symbol, totalAssetAmount, totalAssetFraction, totalBorrowFraction, totalBorrowAmount, totalCollateralAmount, utilization, block, timestamp }) => ({
id: id,
asset: asset,
asset: asset.id,
assetTotalSupply: ethers.BigNumber.from(asset.totalSupply),
assetName: asset.name,
assetSymbol: asset.symbol,
assetDecimals: ethers.BigNumber.from(asset.decimals),
borrowOpeningFee: ethers.BigNumber.from(borrowOpeningFee),
closedCollaterizationRate: ethers.BigNumber.from(closedCollaterizationRate),
collateral: collateral,
collateral: collateral.id,
collateralTotalSupply: ethers.BigNumber.from(collateral.totalSupply),
collateralName: collateral.name,
collateralSymbol: collateral.symbol,
collateralDecimals: ethers.BigNumber.from(collateral.decimals),
decimals: ethers.BigNumber.from(decimals),
dev: dev,
devFee: ethers.BigNumber.from(devFee),
Expand Down Expand Up @@ -66,22 +74,27 @@ module.exports = {
block: ethers.BigNumber.from(block),
timestamp: ethers.BigNumber.from(timestamp)
})),
tokens: tokens.map(({ id, totalSupply, block, timestamp }) => ({
tokens: tokens.map(({ id, totalSupply, name, symbol, decimals, block, timestamp }) => ({
id: id,
totalSupply: ethers.BigNumber.from(totalSupply),
name: name,
symbol: symbol,
decimals: ethers.BigNumber.from(decimals),
block: ethers.BigNumber.from(block),
timestamp: ethers.BigNumber.from(timestamp)
})),
withdrawals: withdrawals.map(({ id, from, to, token, amount, block, timestamp }) => ({
id: id,
from: from.id,
to: to,
to: to.id,
token: token.id,
tokenTotalSupply: ethers.BigNumber.from(token.totalSupply),
tokenName: token.name,
tokenSymbol: token.symbol,
tokenDecimals: ethers.BigNumber.from(token.decimals),
tokenBlock: ethers.BigNumber.from(token.block),
tokenTimestamp: ethers.BigNumber.from(token.timestamp),
amount: ethers.BigNumber.from(amount),
share: ethers.BigNumber.from(share),
block: ethers.BigNumber.from(block),
timestamp: ethers.BigNumber.from(timestamp)
})),
Expand All @@ -90,6 +103,12 @@ module.exports = {
from: from.id,
to: to.id,
token: token.id,
tokenTotalSupply: ethers.BigNumber.from(token.totalSupply),
tokenName: token.name,
tokenSymbol: token.symbol,
tokenDecimals: ethers.BigNumber.from(token.decimals),
tokenBlock: ethers.BigNumber.from(token.block),
tokenTimestamp: ethers.BigNumber.from(token.timestamp),
amount: ethers.BigNumber.from(amount),
block: ethers.BigNumber.from(block),
timestamp: ethers.BigNumber.from(timestamp)
Expand Down Expand Up @@ -129,10 +148,10 @@ module.exports = {
entity: 'lendingPairs',
properties: [
'id',
'asset',
'asset { id, bentoBox { id }, totalSupply, name, symbol, decimals }',
'borrowOpeningFee',
'closedCollaterizationRate',
'collateral',
'collateral { id, bentoBox { id }, totalSupply, name, symbol, decimals }',
'decimals',
'dev',
'devFee',
Expand Down Expand Up @@ -230,7 +249,7 @@ module.exports = {
'id',
'from { id }',
'to { id }',
'token { id, totalSupply }',
'token { id, bentoBox { id }, totalSupply, name, symbol, decimals }',
'amount',
'block',
'timestamp'
Expand All @@ -243,7 +262,11 @@ module.exports = {
from: from.id,
to: to.id,
token: token.id,
tokenBentoBox: token.bentoBox.id,
tokenTotalSupply: ethers.BigNumber.from(token.totalSupply),
tokenName: token.name,
tokenSymbol: token.symbol,
tokenDecimals: token.decimals,
amount: ethers.BigNumber.from(amount),
block: ethers.BigNumber.from(block),
timestamp: ethers.BigNumber.from(timestamp)
Expand All @@ -261,7 +284,7 @@ module.exports = {
'id',
'from { id }',
'to',
'token { id, totalSupply }',
'token { id, bentoBox { id }, totalSupply, name, symbol, decimals }',
'amount',
'block',
'timestamp'
Expand All @@ -274,7 +297,11 @@ module.exports = {
from: from.id,
to: to,
token: token.id,
tokenBentoBox: token.bentoBox.id,
tokenTotalSupply: ethers.BigNumber.from(token.totalSupply),
tokenName: token.name,
tokenSymbol: token.symbol,
tokenDecimals: token.decimals,
amount: ethers.BigNumber.from(amount),
block: ethers.BigNumber.from(block),
timestamp: ethers.BigNumber.from(timestamp)
Expand All @@ -290,16 +317,24 @@ module.exports = {
entity: 'tokens',
properties: [
'id',
'bentoBox { id }',
'totalSupply',
'name',
'symbol',
'decimals',
'block',
'timestamp'
]
}
})
.then(results =>
results.map(({ id, totalSupply, block, timestamp }) => ({
results.map(({ id, bentoBox, totalSupply, name, symbol, decimals, block, timestamp }) => ({
id: id,
bentoBox: bentoBox.id,
totalSupply: ethers.BigNumber.from(totalSupply),
name: name,
symbol: symbol,
decimals: decimals,
block: ethers.BigNumber.from(block),
timestamp: ethers.BigNumber.from(timestamp)
}))
Expand All @@ -318,10 +353,10 @@ module.exports = {
},
properties: [
'id',
'lendingPairs { id, lendingPair { id, asset }, userCollateralAmount, balanceOf, userBorrowFraction, transactions { id, type, lendingPair { id, asset }, token { id, totalSupply }, amount, fraction, poolPercentage, block, timestamp } }',
'bentoData { id, token { id, totalSupply }, amount }',
'withdrawals { id, from { id }, to, token { id, totalSupply }, amount, block, timestamp }',
'deposits { id, from { id }, to { id }, token { id, totalSupply }, amount, block, timestamp }',
'lendingPairs { id, lendingPair { id }, userCollateralAmount, balanceOf, userBorrowFraction, transactions { id, type, lendingPair { id }, token { id }, amount, fraction, poolPercentage, block, timestamp } }',
'bentoData { id, token { id }, amount }',
'withdrawals { id, from { id }, to { id }, token { id, bentoBox { id }, totalSupply, name, symbol, decimals }, amount, block, timestamp }',
'deposits { id, from { id }, to { id }, token { id, bentoBox { id }, totalSupply, name, symbol, decimals }, amount, block, timestamp }',
'block',
'timestamp'
]
Expand All @@ -333,17 +368,14 @@ module.exports = {
leandingPairs: lendingPairs.map(({ id, lendingPair, userCollateralAmount, balanceOf, userBorrowFraction, transactions }) => ({
id: id,
lendingPairId: lendingPair.id,
lendingPairAsset: lendingPair.asset,
userCollateralAmount: ethers.BigNumber.from(userCollateralAmount),
balanceOf: Number(balanceOf),
userBorrowFraction: ethers.BigNumber.from(userBorrowFraction),
transactions: transactions.map(({ id, type, lendingPair, token, amount, fraction, poolPercentage, block, timestamp }) => ({
id: id,
type: type,
lendingPairId: lendingPair.id,
lendingPairAsset: lendingPair.asset,
token: token.id,
tokenTotalSupply: ethers.BigNumber.from(token.totalSupply),
amount: ethers.BigNumber.from(amount),
fraction: ethers.BigNumber.from(fraction),
poolPercentage: ethers.BigNumber.from(poolPercentage),
Expand All @@ -354,15 +386,18 @@ module.exports = {
bentoData: bentoData.map(({ id, token, amount }) => ({
id: id,
tokenId: id,
tokenTotalSupply: ethers.BigNumber.from(token.totalSupply),
amount: ethers.BigNumber.from(amount)
})),
withdrawals: withdrawals.map(({ id, from, to, token, amount, block, timestamp }) => ({
id: id,
from: from.id,
to: to,
to: to.id,
token: token.id,
tokenBentoBox: token.bentoBox.id,
tokenTotalSupply: ethers.BigNumber.from(token.totalSupply),
tokenName: token.name,
tokenSymbol: token.symbol,
tokenDecimals: token.decimals,
amount: ethers.BigNumber.from(amount),
block: ethers.BigNumber.from(block),
timestamp: ethers.BigNumber.from(timestamp)
Expand All @@ -372,7 +407,11 @@ module.exports = {
from: from.id,
to: to.id,
token: token.id,
tokenBentoBox: token.bentoBox.id,
tokenTotalSupply: ethers.BigNumber.from(token.totalSupply),
tokenName: token.name,
tokenSymbol: token.symbol,
tokenDecimals: token.decimals,
amount: ethers.BigNumber.from(amount),
block: ethers.BigNumber.from(block),
timestamp: ethers.BigNumber.from(timestamp)
Expand Down Expand Up @@ -400,7 +439,7 @@ module.exports = {
properties: [
'id',
'owner { id }',
'token { id, totalSupply, block, timestamp }',
'token { id, bentoBox { id }, totalSupply, name, symbol, decimals, block, timestamp }',
'amount'
]
}
Expand All @@ -410,7 +449,11 @@ module.exports = {
id: id,
user: owner.id,
token: token.id,
tokenBentoBox: token.bentoBox.id,
tokenTotalSupply: ethers.BigNumber.from(token.totalSupply),
tokenName: token.name,
tokenSymbol: token.symbol,
tokenDecimals: token.decimals,
tokenLastBlock: ethers.BigNumber.from(token.block),
tokenLastTimestamp: ethers.BigNumber.from(token.timestamp),
amount: ethers.BigNumber.from(amount)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@sushiswap/bento-data",
"license": "MIT",
"version": "0.0.6",
"version": "0.0.7",
"author": "SushiSwap",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 0a11d80

Please sign in to comment.