Skip to content

Commit

Permalink
chore: update contracts (#128)
Browse files Browse the repository at this point in the history
* chore: update contracts

* fix: cleanup

* fix: PT ABI

* fix: imports

* fix: format

* fix: semantic
  • Loading branch information
matstyler authored Dec 14, 2023
1 parent 0f452be commit a11277b
Show file tree
Hide file tree
Showing 43 changed files with 83,930 additions and 54,447 deletions.
635 changes: 0 additions & 635 deletions abis/CurvePoolFactory.json

This file was deleted.

16,723 changes: 16,723 additions & 0 deletions abis/Factory.json

Large diffs are not rendered by default.

44,304 changes: 30,304 additions & 14,000 deletions abis/LPVault.json

Large diffs are not rendered by default.

4,523 changes: 0 additions & 4,523 deletions abis/LPVaultFactory.json

This file was deleted.

49,043 changes: 25,508 additions & 23,535 deletions abis/PrincipalToken.json

Large diffs are not rendered by default.

8,286 changes: 0 additions & 8,286 deletions abis/PrincipalTokenFactory.json

This file was deleted.

13,237 changes: 10,795 additions & 2,442 deletions abis/Registry.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"deploy": "graph deploy perspectivefi/spectra-mainnet --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy:local": "graph deploy perspectivefi/spectra-mainnet --debug --ipfs http://localhost:5001 --node http://127.0.0.1:8020",
"deploy:goerli": "graph deploy perspectivefi/spectra-goerli subgraph.goerli.yaml --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy:test": "graph deploy matstyler/spectra-subgraph subgraph.goerli.yaml --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"generate-config:local": "node ./src/scripts/subgraphConfigGenerator.js local",
"generate-config": "node ./src/scripts/subgraphConfigGenerator.js",
"generate-config:goerli": "node ./src/scripts/subgraphConfigGenerator.js goerli",
Expand Down
53 changes: 13 additions & 40 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,19 @@ type ValueInTime @entity {
# Factory
####################

type FutureVaultFactory @entity {
type Factory @entity {
id: ID!
createdAtTimestamp: BigInt!
old: FutureVaultFactory
address: Bytes!
createdAtTimestamp: BigInt!

oldFactory: Bytes
oldRegistry: Bytes
registry: Bytes
curveFactory: Bytes

poolFactory: PoolFactory
deployedFutures: [Future!]! @derivedFrom(field: "futureVaultFactory")
deployedPools: [Pool!]! @derivedFrom(field: "futureVaultFactory")
deployedFutures: [Future!]! @derivedFrom(field: "factory")
deployedPools: [Pool!]! @derivedFrom(field: "factory")
deployedLPVaults: [LPVault!]! @derivedFrom(field: "factory")
}

####################
Expand Down Expand Up @@ -205,10 +209,8 @@ type Future @entity {
symbol: String!
name: String!

futureVaultFactory: FutureVaultFactory
factory: Factory

"how big is the fee setup for that future"
daoFeeRate: BigInt!
unclaimedFees: BigInt!
"sum of the collected fees"
totalCollectedFees: BigInt!
Expand Down Expand Up @@ -337,21 +339,6 @@ type APRInTime @entity {
lpVault: LPVault
}

type PoolFactory @entity {
id: ID!
address: Bytes!
createdAtTimestamp: BigInt!

"it will be Curve by default but we will be able to index others as well"
ammProvider: AMM!
feeReceiver: Account!
admin: Bytes!

futureVaultFactory: FutureVaultFactory

pools: [Pool!]! @derivedFrom(field: "factory")
}

type Pool @entity {
id: ID!
address: Bytes!
Expand All @@ -367,10 +354,8 @@ type Pool @entity {
futureAdminFeeRate: BigInt!
futureAdminFeeDeadline: BigInt!

futureVaultFactory: FutureVaultFactory
factory: Factory
futureVault: Future
"to be able to follow all the pools created by a factory"
factory: PoolFactory

liquidityToken: Asset!
assets: [AssetAmount!]
Expand Down Expand Up @@ -404,17 +389,6 @@ type Transfer @entity {
# LPVaults
####################

type LPVaultFactory @entity {
id: ID!
createdAtTimestamp: BigInt!
address: Bytes!

registry: Bytes
oldRegistry: Bytes

deployedLPVaults: [LPVault!]! @derivedFrom(field: "lpVaultFactory")
}

type LPVaultInterest @entity {
id: ID!
chainId: Int!
Expand All @@ -431,14 +405,13 @@ type LPVault @entity {
createdAtTimestamp: BigInt!
expirationAtTimestamp: BigInt!

lpVaultFactory: LPVaultFactory!
factory: Factory!
future: Future!
pool: Pool

state: FutureState!
fee: BigInt

poolIndex: BigInt
underlying: Asset!
ibt: Asset!
totalAssets: BigInt!
Expand Down
21 changes: 8 additions & 13 deletions schema.puml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ enum FutureState {

'#####################################

class FutureVaultFactory {
class factory {
id: ID!
createdAtTimestamp: BigInt!
address: Bytes!

+ old: FutureVaultFactory
+ old: factory
+ poolFactory: PoolFactory
}

Expand All @@ -67,9 +67,7 @@ class PoolFactory {
createdAtTimestamp
admin

+ ammProvider
+ feeReceiver
+ futureVaultFactory
+ factory
+ pools: [ ]
}

Expand Down Expand Up @@ -214,8 +212,6 @@ class Transfer {
'#####################################


AMM --> PoolFactory : ammProvider

AssetType --> Asset : type

TransactionType -> Transaction : type
Expand All @@ -226,19 +222,18 @@ FeeClaim::feeCollector <---> Account : collectedFees
FeeClaim::future ---> Future::feeClaims : feeClaims
FeeClaim::pool ---> Pool : feeClaims

PoolFactory::futureVaultFactory --> FutureVaultFactory::poolFactory : poolFactory
PoolFactory::factory --> factory::poolFactory : poolFactory
PoolFactory::pools --> Pool::factory : factory

FutureVaultFactory ---> Pool::futureVaultFactory : futureVaultFactory
FutureVaultFactory ---> Future::futureVaultFactory : futureVaultFactory
factory ---> Pool::factory : factory
factory ---> Future::factory : factory

Future ---> FutureVaultFactory::deployedFutures : deployedFutures
Future ---> factory::deployedFutures : deployedFutures
Future ---> Asset::futureVault : futureVault

Pool ---> AccountAsset : pool
Pool ---> FutureVaultFactory::deployedPools : deployedPools
Pool ---> factory::deployedPools : deployedPools

Account ---> PoolFactory::feeReceiver : feeReceiver
Account ---> Transfer::from : from
Account ---> Transfer::to : to

Expand Down
7 changes: 3 additions & 4 deletions src/configs/goerli.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"network": "goerli",
"startBlock": 8817188,
"startBlock": 8849329,

"registry": "0x11a3E4968C696D57b9A29e658f6e4e74f75f2099",
"principalTokenFactory": "0x67EA66C810da020F9B49A97815AdC7BD5d9F8e1e",
"lpVaultFactory": "0x72cDBa0356B2DE62435e5dCbb487BBBD0Da21330"
"registry": "0xd06873A2ce9bF0884FDDE4ecDBA9d953468D7C86",
"factory": "0xe70e11661725BC297a804d22Ce96606D7dE09Af5"
}
3 changes: 1 addition & 2 deletions src/configs/local.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
"startBlock": 0,

"registry": "0x0000000000000000000000000000000000000000",
"principalTokenFactory": "0x0000000000000000000000000000000000000000",
"lpVaultFactory": "0x0000000000000000000000000000000000000000"
"factory": "0x0000000000000000000000000000000000000000"
}
3 changes: 1 addition & 2 deletions src/configs/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
"startBlock": 0,

"registry": "0x0000000000000000000000000000000000000000",
"principalTokenFactory": "0x0000000000000000000000000000000000000000",
"lpVaultFactory": "0x0000000000000000000000000000000000000000"
"factory": "0x0000000000000000000000000000000000000000"
}
32 changes: 0 additions & 32 deletions src/entities/CurvePoolFactory.ts

This file was deleted.

39 changes: 39 additions & 0 deletions src/entities/Factory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Address, BigInt, log } from "@graphprotocol/graph-ts"

import { Factory as FactoryContract } from "../../generated/Factory/Factory"
import { Factory } from "../../generated/schema"
import { ZERO_ADDRESS } from "../constants"

export function createFactory(
registry: Address,
address: Address,
timestamp: BigInt
): Factory {
let factory = new Factory(address.toHex())
factory.address = address
factory.createdAtTimestamp = timestamp

factory.registry = registry

let curveFactory = getCurveFactory(address)

factory.curveFactory = curveFactory

return factory
}

export function getCurveFactory(factoryAddress: Address): Address {
const factoryContract = FactoryContract.bind(factoryAddress)

let curveFactoryCall = factoryContract.try_getCurveFactory()

if (!curveFactoryCall.reverted) {
return curveFactoryCall.value
}

log.warning("getCurveFactory() call reverted for {}", [
factoryAddress.toHex(),
])

return ZERO_ADDRESS
}
14 changes: 0 additions & 14 deletions src/entities/FutureVault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,6 @@ export function getExpirationTimestamp(futureVault: Address): BigInt {
return ZERO_BI
}

export function getFeeRate(futureVault: Address): BigInt {
const futureContract = PrincipalToken.bind(futureVault)

let protocolFeeCall = futureContract.try_getProtocolFee()

if (!protocolFeeCall.reverted) {
return protocolFeeCall.value
}

log.warning("getProtocolFee() call reverted for {}", [futureVault.toHex()])

return ZERO_BI
}

export function getUnclaimedFees(futureVault: Address): BigInt {
const futureContract = PrincipalToken.bind(futureVault)

Expand Down
71 changes: 0 additions & 71 deletions src/entities/FutureVaultFactory.ts

This file was deleted.

14 changes: 0 additions & 14 deletions src/entities/LPVaultFactory.ts

This file was deleted.

Loading

0 comments on commit a11277b

Please sign in to comment.