-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
150 additions
and
44 deletions.
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
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,79 @@ | ||
import { ethereum } from "@graphprotocol/graph-ts"; | ||
import { StrategyVault, StrategyVaultAccount, StrategyVaultCapacity, StrategyVaultMaturity, StrategyVaultTrade } from "../generated/schema"; | ||
|
||
function getVault(id: string): StrategyVault { | ||
let entity = StrategyVault.load(id); | ||
if (entity == null) { | ||
entity = new StrategyVault(id); | ||
} | ||
return entity as StrategyVault | ||
} | ||
|
||
function getVaultAccount(vault: string, account: string): StrategyVaultAccount { | ||
let id = vault + ":" + account | ||
let entity = StrategyVaultAccount.load(id); | ||
if (entity == null) { | ||
entity = new StrategyVaultAccount(id); | ||
entity.strategyVault = vault | ||
entity.account = account | ||
} | ||
|
||
return entity as StrategyVaultAccount | ||
} | ||
|
||
function getVaultMaturity(vault: string, maturity: i32): StrategyVaultMaturity { | ||
let id = vault + ":" + maturity.toString() | ||
let entity = StrategyVaultMaturity.load(id); | ||
if (entity == null) { | ||
entity = new StrategyVaultMaturity(id); | ||
entity.strategyVault = vault | ||
entity.maturity = maturity | ||
} | ||
|
||
return entity as StrategyVaultMaturity | ||
} | ||
|
||
function getVaultCapacity(vault: string): StrategyVaultCapacity { | ||
let id = vault | ||
let entity = StrategyVaultCapacity.load(id); | ||
if (entity == null) { | ||
entity = new StrategyVaultCapacity(id); | ||
entity.strategyVault = vault | ||
} | ||
|
||
return entity as StrategyVaultCapacity | ||
} | ||
|
||
function getVaultTrade( | ||
vault: string, | ||
maturity: i32, | ||
account: string, | ||
event: ethereum.Event | ||
): StrategyVaultTrade { | ||
let id = ( | ||
vault + ':' | ||
+ maturity.toString() + ':' | ||
+ account.toString() + ':' | ||
+ event.transaction.hash.toHexString() + ':' | ||
+ event.logIndex.toString() | ||
); | ||
|
||
let entity = new StrategyVaultTrade(id); | ||
entity.blockHash = event.block.hash; | ||
entity.blockNumber = event.block.number.toI32(); | ||
entity.timestamp = event.block.timestamp.toI32(); | ||
entity.transactionHash = event.transaction.hash; | ||
entity.transactionOrigin = event.transaction.from; | ||
entity.isVaultAction = vault == account | ||
entity.strategyVaultMaturity = vault + ":" + maturity.toString() | ||
if (vault != account) { | ||
entity.strategyVaultAccount = vault + ":" + account | ||
} | ||
|
||
return entity | ||
} | ||
|
||
export function handleVaultUpdated() | ||
export function handleVaultPauseStatus() | ||
export function handleVaultUpdateSecondaryBorrowCapacity() | ||
export function handleVaultBorrowCapacityChange() |
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