Skip to content

Commit 25ef409

Browse files
authored
Merge pull request #231 from VenusProtocol/update-underlying-names
Update underlying names
2 parents 307067c + 61390c3 commit 25ef409

File tree

7 files changed

+50
-4
lines changed

7 files changed

+50
-4
lines changed

packages/isolated-pools-abis/Bep20.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,5 +218,18 @@
218218
],
219219
"name": "Transfer",
220220
"type": "event"
221+
},
222+
{
223+
"anonymous": false,
224+
"inputs": [
225+
{
226+
"indexed": true,
227+
"internalType": "address",
228+
"name": "implementation",
229+
"type": "address"
230+
}
231+
],
232+
"name": "Upgraded",
233+
"type": "event"
221234
}
222235
]

packages/utils/src/testing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const assertEqual = (
1313
subgraphValue,
1414
`
1515
${key} incorrect on ${
16-
entity.id
16+
entity.address
1717
} Contract: ${contractValue?.toString()}; Subgraph: ${subgraphValue};`,
1818
);
1919
} catch (e) {

subgraphs/isolated-pools/schema.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type Pool @entity {
3838
"""
3939
ERC20 Token
4040
"""
41-
type Token @entity(immutable: true) {
41+
type Token @entity {
4242
"Address of the asset"
4343
id: Bytes!
4444
"Address of the asset"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Upgraded } from '../../generated/templates/Underlying/BEP20';
2+
import { BEP20 } from '../../generated/PoolRegistry/BEP20';
3+
import { getOrCreateToken } from '../operations/getOrCreate';
4+
5+
export function handleUpgraded(event: Upgraded): void {
6+
const token = getOrCreateToken(event.address);
7+
const erc20 = BEP20.bind(event.address);
8+
token.name = erc20.name();
9+
token.symbol = erc20.symbol();
10+
token.save();
11+
}

subgraphs/isolated-pools/src/operations/create.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { Address, BigInt } from '@graphprotocol/graph-ts';
22

33
import { Comptroller as ComptrollerContract } from '../../generated/PoolRegistry/Comptroller';
44
import { PoolRegistry as PoolRegistryContract } from '../../generated/PoolRegistry/PoolRegistry';
5-
import { VToken as VTokenDataSource } from '../../generated/templates';
5+
import {
6+
Underlying as UnderlyingDataSource,
7+
VToken as VTokenDataSource,
8+
} from '../../generated/templates';
69
import {
710
BadDebtIncreased,
811
Borrow,
@@ -111,6 +114,7 @@ export function createMarket(
111114
const vTokenContract = VTokenContract.bind(vTokenAddress);
112115
const poolComptroller = Comptroller.bind(comptroller);
113116
const underlyingAddress = vTokenContract.underlying();
117+
UnderlyingDataSource.create(underlyingAddress);
114118

115119
const market = new Market(vTokenAddress);
116120

subgraphs/isolated-pools/src/operations/get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
export const getPool = (comptroller: Address): Pool | null => {
1212
const pool = Pool.load(getPoolId(comptroller));
1313
if (!pool) {
14-
log.error('Pool {} not found', [comptroller.toString()]);
14+
log.error('Pool {} not found', [comptroller.toHexString()]);
1515
}
1616
return pool as Pool;
1717
};

subgraphs/isolated-pools/template.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,24 @@ templates:
155155
handler: handleBadDebtRecovered
156156
- event: HealBorrow(indexed address,indexed address,uint256)
157157
handler: handleHealBorrow
158+
- name: Underlying
159+
kind: ethereum/contract
160+
network: {{ network }}
161+
source:
162+
abi: BEP20
163+
mapping:
164+
abis:
165+
- name: BEP20
166+
file: ../../packages/isolated-pools-abis/Bep20.json
167+
kind: ethereum/events
168+
apiVersion: 0.0.9
169+
language: wasm/assemblyscript
170+
file: ./src/mappings/underlying.ts
171+
entities:
172+
- Token
173+
eventHandlers:
174+
- event: Upgraded(indexed address)
175+
handler: handleUpgraded
158176
- name: RewardsDistributor
159177
kind: ethereum/contract
160178
network: {{ network }}

0 commit comments

Comments
 (0)