Skip to content

Commit 6404a47

Browse files
committed
wip
1 parent cd86fc7 commit 6404a47

File tree

7 files changed

+33
-327
lines changed

7 files changed

+33
-327
lines changed

subgraphs/fx-protocol/abis/ERC20.json

Lines changed: 0 additions & 222 deletions
This file was deleted.

subgraphs/fx-protocol/protocols/fx-protocol/config/templates/fx.protocol.template.yaml

Lines changed: 2 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,14 @@ dataSources:
2727
file: ./abis/TreasuryV2.json
2828
- name: PoolManager
2929
file: ./abis/PoolManager.json
30-
- name: ERC20
31-
file: ./abis/ERC20.json
3230
- name: Pool
3331
file: ./abis/Pool.json
3432

3533
###########################################
3634
############## Price Oracle ###############
3735
###########################################
3836
# ERC20
39-
- name: _ERC20
37+
- name: ERC20
4038
file: ./abis/Prices/ERC20.json
4139
# Curve Contracts
4240
- name: CurvePool
@@ -67,8 +65,6 @@ dataSources:
6765
eventHandlers:
6866
- event: Harvest(indexed address,indexed address,uint256,uint256,uint256,uint256)
6967
handler: handleHarvest
70-
- event: RegisterPool(indexed address)
71-
handler: handleRegisterPool
7268
file: ./src/mappings/poolManagerMappings.ts
7369

7470
{{#treasuryContracts}}
@@ -90,16 +86,14 @@ dataSources:
9086
file: ./abis/TreasuryV2.json
9187
- name: PoolManager
9288
file: ./abis/PoolManager.json
93-
- name: ERC20
94-
file: ./abis/ERC20.json
9589
- name: Pool
9690
file: ./abis/Pool.json
9791

9892
###########################################
9993
############## Price Oracle ###############
10094
###########################################
10195
# ERC20
102-
- name: _ERC20
96+
- name: ERC20
10397
file: ./abis/Prices/ERC20.json
10498
# Curve Contracts
10599
- name: CurvePool
@@ -132,61 +126,3 @@ dataSources:
132126
handler: handleHarvest
133127
file: ./src/mappings/treasuryTokenMappings.ts
134128
{{/treasuryContracts}}
135-
136-
templates:
137-
- kind: ethereum/contract
138-
name: Pool
139-
network: {{ network }}
140-
source:
141-
abi: Pool
142-
mapping:
143-
kind: ethereum/events
144-
apiVersion: 0.0.7
145-
language: wasm/assemblyscript
146-
entities: []
147-
abis:
148-
- name: Pool
149-
file: ./abis/Pool.json
150-
- name: TreasuryV2
151-
file: ./abis/TreasuryV2.json
152-
- name: PoolManager
153-
file: ./abis/PoolManager.json
154-
- name: ERC20
155-
file: ./abis/ERC20.json
156-
157-
###########################################
158-
############## Price Oracle ###############
159-
###########################################
160-
# ERC20
161-
- name: _ERC20
162-
file: ./abis/Prices/ERC20.json
163-
# Curve Contracts
164-
- name: CurvePool
165-
file: ./abis/Prices/Curve/Pool.json
166-
- name: CurveRegistry
167-
file: ./abis/Prices/Curve/Registry.json
168-
- name: CalculationsCurve
169-
file: ./abis/Prices/Calculations/Curve.json
170-
# YearnLens Contracts
171-
- name: YearnLensContract
172-
file: ./abis/Prices/YearnLens.json
173-
# Aave Oracle Contract
174-
- name: AaveOracleContract
175-
file: ./abis/Prices/AaveOracle.json
176-
# SushiSwap Contracts
177-
- name: CalculationsSushiSwap
178-
file: ./abis/Prices/Calculations/SushiSwap.json
179-
# ChainLink Contracts
180-
- name: ChainLinkContract
181-
file: ./abis/Prices/ChainLink.json
182-
# Uniswap Contracts
183-
- name: UniswapRouter
184-
file: ./abis/Prices/Uniswap/Router.json
185-
- name: UniswapFactory
186-
file: ./abis/Prices/Uniswap/Factory.json
187-
- name: UniswapPair
188-
file: ./abis/Prices/Uniswap/Pair.json
189-
eventHandlers:
190-
- event: PositionSnapshot(uint256,int16,uint256,uint256,uint256)
191-
handler: handlePositionSnapshot
192-
file: ./src/mappings/poolMappings.ts

subgraphs/fx-protocol/src/common/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export const ETH_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
2323
export const WETH_ADDRESS = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
2424
export const POOL_MANAGER_ADDRESS =
2525
"0x250893CA4Ba5d05626C785e8da758026928FCD24";
26+
export const POOL_ADDRESS = "0x6ecfa38fee8a5277b91efda204c235814f0122e8";
27+
export const FX_USD_ADDRESS = "0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0";
2628

2729
////////////////////////
2830
///// Type Helpers /////

subgraphs/fx-protocol/src/common/initializers.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,12 @@ export function updatePoolTVLV1(pool: Pool): void {
8585
constants.BIGINT_ZERO,
8686
);
8787

88-
pool.setInputTokenBalances([baseTokenTotalSupply], true);
88+
const baseTokenTotalSupplyWrapped = readValue<BigInt>(
89+
contract.try_getWrapppedValue(baseTokenTotalSupply),
90+
constants.BIGINT_ZERO,
91+
);
92+
93+
pool.setInputTokenBalances([baseTokenTotalSupplyWrapped], true);
8994
}
9095

9196
export function updatePoolOutputTokenSupplyV1(pool: Pool): void {
@@ -103,14 +108,7 @@ export function getOrCreatePoolV2(poolAddress: Address, sdk: SDK): Pool {
103108
const pool = sdk.Pools.loadPool(poolAddress);
104109

105110
if (!pool.isInitialized) {
106-
const poolManagerContract = PoolContract.bind(
107-
Address.fromString(constants.POOL_MANAGER_ADDRESS),
108-
);
109-
const inputToken = readValue<Address>(
110-
poolManagerContract.try_collateralToken(),
111-
constants.NULL.TYPE_ADDRESS,
112-
);
113-
111+
const inputToken = Address.fromString(constants.FX_USD_ADDRESS);
114112
const outputToken = sdk.Tokens.getOrCreateToken(poolAddress);
115113

116114
pool.initialize(

subgraphs/fx-protocol/src/mappings/poolManagerMappings.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1-
import { initializeSDKFromEvent } from "../common/initializers";
2-
import { Pool as PoolTemplate } from "../../generated/templates";
3-
import { RegisterPool, Harvest } from "../../generated/PoolManager/PoolManager";
1+
import {
2+
getOrCreatePoolV2,
3+
initializeSDKFromEvent,
4+
updatePoolTVLV2,
5+
} from "../common/initializers";
6+
import * as constants from "../common/constants";
7+
import { Address } from "@graphprotocol/graph-ts";
8+
import { Harvest } from "../../generated/PoolManager/PoolManager";
49

510
export function handleHarvest(event: Harvest): void {
611
const sdk = initializeSDKFromEvent(event);
712

13+
const pool = getOrCreatePoolV2(
14+
Address.fromString(constants.POOL_ADDRESS),
15+
sdk,
16+
);
17+
18+
updatePoolTVLV2(pool);
19+
820
const account = sdk.Accounts.loadAccount(event.transaction.from);
921
account.trackActivity();
1022
}
11-
12-
export function handleRegisterPool(event: RegisterPool): void {
13-
PoolTemplate.create(event.params.pool);
14-
}

0 commit comments

Comments
 (0)