Skip to content

Commit

Permalink
add todos
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffywu committed Aug 3, 2022
1 parent ab424fb commit 23c37a9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/vaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ export function getVault(id: string): StrategyVault {
let entity = StrategyVault.load(id)
if (entity == null) {
entity = new StrategyVault(id)
let vaultAddress = Address.fromString(id);
let vaultAddress = Address.fromString(id)
let vaultContract = IStrategyVault.bind(vaultAddress)

// This identifier must exist in order for the UI to function properly
let strategy = vaultContract.strategy()
entity.strategy = strategy;
entity.strategy = strategy

let name = vaultContract.try_name()
if (name.reverted) {
Expand Down Expand Up @@ -248,7 +248,7 @@ export function handleVaultUpdated(event: VaultUpdated): void {
let notional = Notional.bind(event.address)
let vaultConfig = notional.getVaultConfig(event.params.vault)

vault.vaultAddress = event.params.vault;
vault.vaultAddress = event.params.vault
vault.primaryBorrowCurrency = vaultConfig.borrowCurrencyId.toString()
vault.minAccountBorrowSize = vaultConfig.minAccountBorrowSize
vault.minCollateralRatioBasisPoints = vaultConfig.minCollateralRatio.toI32()
Expand Down Expand Up @@ -468,6 +468,7 @@ export function handleVaultEnterPosition(event: VaultEnterPosition): void {
updateVaultMarkets(vault, event)
updateNTokenPortfolio(getNToken(vault.primaryBorrowCurrency), event, null)
let accountAfter = updateVaultAccount(vault, event.params.account, event)
// TODO: VaultEnterMaturity has more metadata not available here...
setVaultTrade(vault.id, accountBefore, accountAfter, "EnterPosition", event)
}

Expand All @@ -486,6 +487,8 @@ export function handleVaultRollPosition(event: VaultRollPosition): void {
updateVaultMarkets(vault, event)
updateNTokenPortfolio(getNToken(vault.primaryBorrowCurrency), event, null)
let accountAfter = updateVaultAccount(vault, event.params.account, event)
// TODO: VaultEnterMaturity has more metadata not available here, we should attempt to detect
// if this is a roll position or enter position based on the previous maturity
setVaultTrade(vault.id, accountBefore, accountAfter, "RollPosition", event)
}

Expand Down

0 comments on commit 23c37a9

Please sign in to comment.