Skip to content

Commit

Permalink
add subgraph
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruv-chauhan committed Jan 6, 2025
1 parent fd25a9b commit 8257a9b
Show file tree
Hide file tree
Showing 8 changed files with 1,090 additions and 1 deletion.
34 changes: 34 additions & 0 deletions deployment/deployment.json
Original file line number Diff line number Diff line change
Expand Up @@ -13970,5 +13970,39 @@
}
}
}
},
"superlend": {
"schema": "lending",
"base": "aave-forks",
"protocol": "superlend",
"project": "superlend",
"deployments": {
"superlend-etherlink-mainnet": {
"network": "etherlink-mainnet",
"status": "prod",
"versions": {
"schema": "3.1.0",
"subgraph": "1.0.0",
"methodology": "1.0.0"
},
"files": {
"template": "superlend.template.yaml"
},
"options": {
"prepare:yaml": true,
"prepare:constants": false
},
"services": {
"hosted-service": {
"slug": "superlend-etherlink-mainnet",
"query-id": "superlend-etherlink-mainnet"
},
"decentralized-network": {
"slug": "superlend-etherlink-mainnet",
"query-id": "todo"
}
}
}
}
}
}
1 change: 0 additions & 1 deletion subgraphs/aave-forks/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"network": "etherlink-mainnet",
"factory": {
"address": "0x5ccf60c7e10547c5389e9cbff543e5d0db9f4fec",
"startBlock": 3283856
},
"lendingPoolConfigurator": {
"address": "0x30f6880bb1cf780a49eb4ef64e64585780aae060",
"startBlock": 3283856
},
"LendingPool": {
"address": "0x3bd16d195786fb2f509f2e2d7f69920262ef114d",
"startBlock": 3283856
},
"graftEnabled": false,
"subgraphId": "",
"graftStartBlock": 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
specVersion: 1.0.0
schema:
file: ./schema.graphql
indexerHints:
prune: auto
{{#graftEnabled}}
description: ...
features:
- grafting
graft:
base: {{subgraphId}} # Subgraph ID of base subgraph
block: {{graftStartBlock}} # Block number
{{/graftEnabled}}
dataSources:
- kind: ethereum
name: LendingPoolAddressesProvider
network: {{ network }}
source:
abi: LendingPoolAddressesProvider
address: "{{ factory.address }}"
startBlock: {{ factory.startBlock }}
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities: []
abis:
- name: LendingPoolAddressesProvider
file: ./abis/aave-v3/LendingPoolAddressesProvider.json
eventHandlers:
- event: PriceOracleUpdated(indexed address,indexed address)
handler: handlePriceOracleUpdated
file: ./protocols/superlend/src/mapping.ts
- kind: ethereum
name: LendingPoolConfigurator
network: {{ network }}
source:
abi: LendingPoolConfigurator
address: "{{ lendingPoolConfigurator.address }}"
startBlock: {{ lendingPoolConfigurator.startBlock }}
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities: []
abis:
- name: LendingPoolConfigurator
file: ./abis/aave-v3/LendingPoolConfigurator.json
- name: ERC20
file: ./abis/ERC20.json
- name: ERC20NameBytes
file: ./abis/ERC20NameBytes.json
- name: ERC20SymbolBytes
file: ./abis/ERC20SymbolBytes.json
- name: AToken
file: ./abis/aave-v3/AToken.json
eventHandlers:
- event: CollateralConfigurationChanged(indexed address,uint256,uint256,uint256)
handler: handleCollateralConfigurationChanged
- event: ReserveActive(indexed address,bool)
handler: handleReserveActive
- event: ReserveBorrowing(indexed address,bool)
handler: handleReserveBorrowing
- event: ReserveFrozen(indexed address,bool)
handler: handleReserveFrozen
- event: ReserveInitialized(indexed address,indexed address,address,address,address)
handler: handleReserveInitialized
- event: ReservePaused(indexed address,bool)
handler: handleReservePaused
- event: ReserveFactorChanged(indexed address,uint256,uint256)
handler: handleReserveFactorChanged
- event: LiquidationProtocolFeeChanged(indexed address,uint256,uint256)
handler: handleLiquidationProtocolFeeChanged
- event: FlashloanPremiumTotalUpdated(uint128,uint128)
handler: handleFlashloanPremiumTotalUpdated
- event: FlashloanPremiumToProtocolUpdated(uint128,uint128)
handler: handleFlashloanPremiumToProtocolUpdated
- event: SiloedBorrowingChanged(indexed address,bool,bool)
handler: handleSiloedBorrowingChanged
file: ./protocols/superlend/src/mapping.ts
- kind: ethereum
name: LendingPool
network: {{ network }}
source:
abi: LendingPool
address: "{{ LendingPool.address }}"
startBlock: {{ LendingPool.startBlock }}
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities: []
abis:
- name: LendingPool
file: ./abis/aave-v3/LendingPool.json
- name: ERC20
file: ./abis/ERC20.json
- name: ERC20NameBytes
file: ./abis/ERC20NameBytes.json
- name: ERC20SymbolBytes
file: ./abis/ERC20SymbolBytes.json
- name: AaveOracle
file: ./abis/aave-v3/AaveOracle.json
- name: IPriceOracleGetter
file: ./abis/IPriceOracleGetter.json
- name: AToken
file: ./abis/aave-v3/AToken.json
- name: StableDebtToken
file: ./abis/aave-v3/StableDebtToken.json
- name: VariableDebtToken
file: ./abis/aave-v3/VariableDebtToken.json
eventHandlers:
- event: Borrow(indexed address,address,indexed address,uint256,uint8,uint256,indexed uint16)
handler: handleBorrow
- event: SwapBorrowRateMode(indexed address,indexed address,uint8)
handler: handleSwapBorrowRateMode
- event: LiquidationCall(indexed address,indexed address,indexed address,uint256,uint256,address,bool)
handler: handleLiquidationCall
receipt: true
- event: Repay(indexed address,indexed address,indexed address,uint256,bool)
handler: handleRepay
receipt: true
- event: ReserveDataUpdated(indexed address,uint256,uint256,uint256,uint256,uint256)
handler: handleReserveDataUpdated
receipt: true
- event: Supply(indexed address,address,indexed address,uint256,indexed uint16)
handler: handleDeposit
- event: Withdraw(indexed address,indexed address,indexed address,uint256)
handler: handleWithdraw
- event: ReserveUsedAsCollateralEnabled(indexed address,indexed address)
handler: handleReserveUsedAsCollateralEnabled
- event: ReserveUsedAsCollateralDisabled(indexed address,indexed address)
handler: handleReserveUsedAsCollateralDisabled
- event: FlashLoan(indexed address,address,indexed address,uint256,uint8,uint256,indexed uint16)
handler: handleFlashloan
- event: UserEModeSet(indexed address,uint8)
handler: handleUserEModeSet
- event: MintedToTreasury(indexed address,uint256)
handler: handleMintedToTreasury
file: ./protocols/superlend/src/mapping.ts
templates:
- kind: ethereum
name: AToken
network: {{ network }}
source:
abi: AToken
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities: []
abis:
- name: AToken
file: ./abis/aave-v3/AToken.json
- name: ERC20
file: ./abis/ERC20.json
eventHandlers:
- event: Transfer(indexed address,indexed address,uint256)
handler: handleCollateralTransfer
receipt: true
file: ./protocols/superlend/src/mapping.ts
- kind: ethereum
name: StableDebtToken
network: {{ network }}
source:
abi: StableDebtToken
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities: []
abis:
- name: StableDebtToken
file: ./abis/aave-v3/StableDebtToken.json
- name: ERC20
file: ./abis/ERC20.json
eventHandlers:
- event: Transfer(indexed address,indexed address,uint256)
handler: handleStableTransfer
file: ./protocols/superlend/src/mapping.ts
- kind: ethereum
name: VariableDebtToken
network: {{ network }}
source:
abi: VariableDebtToken
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities: []
abis:
- name: VariableDebtToken
file: ./abis/aave-v3/VariableDebtToken.json
- name: ERC20
file: ./abis/ERC20.json
eventHandlers:
- event: Transfer(indexed address,indexed address,uint256)
handler: handleVariableTransfer
file: ./protocols/superlend/src/mapping.ts
71 changes: 71 additions & 0 deletions subgraphs/aave-forks/protocols/superlend/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import {
Address,
ByteArray,
crypto,
dataSource,
log,
} from "@graphprotocol/graph-ts";
import { Network, ZERO_ADDRESS } from "../../../src/constants";

///////////////////////////////
///// Etherlink Addresses /////
///////////////////////////////

export const USDC_TOKEN_ADDRESS = "0x796ea11fa2dd751ed01b53c372ffdb4aaa8f00f9";

/////////////////////////////
///// Protocol Specific /////
/////////////////////////////

export namespace Protocol {
export const PROTOCOL = "Superlend";
export const NAME = "Superlend v3";
export const SLUG = "superlend-v3";
}

export const AAVE_DECIMALS = 8;

export namespace InterestRateMode {
export const NONE = 0 as i32;
export const STABLE = 1 as i32;
export const VARIABLE = 2 as i32;
}

////////////////////////////
///// Network Specific /////
////////////////////////////

export class NetworkSpecificConstant {
constructor(
public readonly protocolAddress: Address, // aka, PoolAddressesProviderRegistry
public readonly network: string
) {}
}

export function getNetworkSpecificConstant(): NetworkSpecificConstant {
const network = dataSource.network();
if (equalsIgnoreCase(network, Network.ETHERLINK_MAINNET)) {
return new NetworkSpecificConstant(
Address.fromString("0xa5cf001755d54e5e84a45757e1637f29f0a19f2f"),
Network.ETHERLINK_MAINNET
);
} else {
log.error("[getNetworkSpecificConstant] Unsupported network: {}", [
network,
]);
return new NetworkSpecificConstant(Address.fromString(ZERO_ADDRESS), "");
}
}

export function equalsIgnoreCase(a: string, b: string): boolean {
return a.replace("-", "_").toLowerCase() == b.replace("-", "_").toLowerCase();
}

// Context keys
export const PROTOCOL_ID_KEY = "protocolId";
export const POOL_ADDRESSES_PROVIDER_ID_KEY = "poolAddressesProviderId";

export const BALANCE_TRANSFER_SIGNATURE = crypto.keccak256(
ByteArray.fromUTF8("BalanceTransfer(address,address,uint256,uint256)")
);
export const BALANCE_TRANSFER_DATA_TYPE = "(uint256,uint256)";
Loading

0 comments on commit 8257a9b

Please sign in to comment.