This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.graphql
180 lines (161 loc) · 4.8 KB
/
schema.graphql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# ~~~~~~~~~~~~~~~~~
# ~~~~~ ENUMS ~~~~~
# ~~~~~~~~~~~~~~~~~
enum AccountType {
Locked
Liquid
}
enum EndowmentType {
Charity
Normal
}
enum StrategyApprovalState {
NOT_APPROVED
APPROVED
WITHDRAW_ONLY
DEPRECATED
}
# ~~~~~~~~~~~~~~~~
# ~~~ ENTITIES ~~~
# ~~~~~~~~~~~~~~~~
type User @entity(immutable: true) {
id: Bytes! # set as wallet/contract address
multiSigs: [MultiSigOwner]! @derivedFrom(field: "owner")
applicationProposals: [ApplicationProposal]! @derivedFrom(field: "proposer")
tokenAllowances: [EndowmentTokenAllowanceSpender]! @derivedFrom(field: "spender")
beneficiaryOf: [Endowment!]! @derivedFrom(field: "beneficiaryWallet")
}
type MultiSig @entity {
id: String!
address: Bytes!
owners: [MultiSigOwner!]! @derivedFrom(field: "multiSig")
transactions: [MultiSigTransaction!]! @derivedFrom(field: "multiSig")
transactionExpiry: BigInt!
requireExecution: Boolean!
approvalsRequired: BigInt!
}
type MultiSigOwner @entity {
id: String! # set as MultiSig.id.concat(User.id)
multiSig: MultiSig!
owner: User!
active: Boolean!
}
type MultiSigTransaction @entity {
id: String! # set as MutiSig.id.concat(Transaction.id)
transactionId: BigInt!
multiSig: MultiSig!
proposer: User!
executed: Boolean!
expiry: BigInt!
metadata: Bytes!
blockTimestamp: BigInt!
confirmations: [TransactionConfirmation!]! @derivedFrom(field: "transaction")
}
type TransactionConfirmation @entity {
id: String! # MultiSigTransaction.id.concat(User.id)
transaction: MultiSigTransaction!
owner: User!
confirmed: Boolean!
}
type ApplicationProposal @entity {
id: String! # Proposal ID
executed: Boolean!
charityName: String!
proposer: User!
expiry: BigInt!
metadata: Bytes!
blockTimestamp: BigInt!
confirmations: [ApplicationConfirmation]! @derivedFrom(field: "proposal")
}
type ApplicationConfirmation @entity {
id: String! # set as (Proposal ID + User Addr)
proposal: ApplicationProposal!
owner: User!
confirmed: Boolean!
}
### Accounts - Endowment
type Endowment @entity {
id: String! # Endowment ID as string
endowmentType: EndowmentType!
name: String
beneficiaryEndowment: Endowment
beneficiaryWallet: User
beneficiaryOf: [Endowment!]! @derivedFrom(field: "beneficiaryEndowment")
balancesLocked: [EndowmentTokenLocked]! @derivedFrom(field: "endowment")
balancesLiquid: [EndowmentTokenLiquid]! @derivedFrom(field: "endowment")
deposits: [EndowmentDepositTransaction]! @derivedFrom(field: "endowment")
withdrawals: [EndowmentWithdrawTransaction]! @derivedFrom(field: "endowment")
swaps: [EndowmentSwapTransaction]! @derivedFrom(field: "endowment")
}
type EndowmentTokenLocked @entity {
id: String! # set as Endowment.id.concat(Token contract addr)`
endowment: Endowment!
token: Bytes!
amount: BigInt!
}
type EndowmentTokenLiquid @entity {
id: String! # set as Endowment.id.concat(Token contract addr)`
endowment: Endowment!
token: Bytes!
amount: BigInt!
allowanceOutstanding: BigInt!
allowanceSpenders: [EndowmentTokenAllowanceSpender]! @derivedFrom(field: "token")
}
type EndowmentTokenAllowanceSpender @entity {
id: String! # set as EndowmenTokenLiquid.id.concat(User.id)`
token: EndowmentTokenLiquid!
spender: User!
amount: BigInt!
}
type EndowmentDepositTransaction @entity(immutable: true) {
id: Bytes! # transaction hash
endowment: Endowment!
token: Bytes!
amountLocked: BigInt!
amountLiquid: BigInt!
blockTimestamp: BigInt!
}
type EndowmentWithdrawTransaction @entity(immutable: true) {
id: Bytes! # transaction hash
endowment: Endowment!
accountType: AccountType!
token: Bytes!
amount: BigInt!
beneficiaryEndowId: Int
beneficiaryAddr: Bytes
blockTimestamp: BigInt!
}
type EndowmentSwapTransaction @entity(immutable: true) {
id: Bytes! # transaction Hash
endowment: Endowment!
accountType: AccountType!
tokenIn: Bytes!
amountIn: BigInt!
tokenOut: Bytes!
amountOut: BigInt!
blockTimestamp: BigInt!
}
type Strategy @entity {
id: Bytes! # strategy selector
network: String!
state: StrategyApprovalState!
vaultLocked: Bytes! # vault might be deployed on another network, so no need to directly tie it to Vault below
vaultLiquid: Bytes! # vault might be deployed on another network, so no need to directly tie it to Vault below
}
type Vault @entity {
id: Bytes! # Vault.address
type: AccountType!
strategyId: Bytes! # vault might be deployed on another network, so no need to directly tie it to Strategy
address: Bytes!
baseToken: Bytes!
yieldToken: Bytes!
totalShares: BigInt!
shares: [VaultShare!]! @derivedFrom(field: "vault")
}
type VaultShare @entity {
id: String! # Vault.id.concat(Endowment.id)
vault: Vault!
endowmentId: String! # we save only Endowment ID so that this entity can be used even on chains where there are no Endowments deployed
deposited: BigInt!
shares: BigInt!
}