-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.graphql
More file actions
180 lines (161 loc) · 4.59 KB
/
schema.graphql
File metadata and controls
180 lines (161 loc) · 4.59 KB
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
type Pool @entity(immutable: false) {
id: Bytes! # pool address
assetSymbol: String!
assetToken: Bytes! # xToken address
assetTokenName: String
assetTokenSymbol: String
assetTokenDecimals: Int
reserveToken: Bytes! # reserve token address
reserveTokenSymbol: String
reserveTokenDecimals: Int
oracle: Oracle! # oracle
poolStrategy: Strategy! # strategy
poolCycleManager: Bytes!
poolLiquidityManager: Bytes!
poolInterestRate: BigInt # Current interest rate (scaled by BPS)
poolUtilizationRatio: BigInt # Current utilization ratio (scaled by BPS)
createdAt: BigInt!
updatedAt: BigInt!
isVerified: Boolean!
# Asset Pool Data
assetSupply: BigInt
reserveBackingAsset: BigInt
aggregatePoolReserves: BigInt
cycleTotalDeposits: BigInt
cycleTotalRedemptions: BigInt
# Liquidity Manager Data
totalLPLiquidityCommited: BigInt!
totalLPCollateral: BigInt!
lpCount: BigInt!
cycleTotalAddLiquidityAmount: BigInt!
cycleTotalReduceLiquidityAmount: BigInt!
# Cycle Manager Data
cycleState: String # enum: POOL_ACTIVE, POOL_REBALANCING_OFFCHAIN, POOL_REBALANCING_ONCHAIN, POOL_HALTED
cycleIndex: BigInt!
lastCycleActionDateTime: BigInt
cyclePriceOpen: BigInt
cyclePriceClose: BigInt
cycleInterestAmount: BigInt
rebalancedLPs: BigInt!
prevRebalancePrice: BigInt!
# Relations
users: [UserPosition!]! @derivedFrom(field: "pool")
lpPositions: [LPPosition!]! @derivedFrom(field: "pool")
}
type Oracle @entity(immutable: false) {
id: Bytes! # oracle address
assetSymbol: String!
assetPrice: BigInt
ohlcOpen: BigInt
ohlcHigh: BigInt
ohlcLow: BigInt
ohlcClose: BigInt
ohlcTimestamp: BigInt
lastUpdated: BigInt
isVerified: Boolean!
createdAt: BigInt!
updatedAt: BigInt!
splitDetected: Boolean
preSplitPrice: BigInt
# Relations
pool: [Pool!]! @derivedFrom(field: "oracle")
}
type Strategy @entity(immutable: false) {
id: Bytes! # strategy address
isVerified: Boolean!
baseInterestRate: BigInt
interestRate1: BigInt
maxInterestRate: BigInt
utilizationTier1: BigInt
utilizationTier2: BigInt
protocolFee: BigInt
feeRecipient: Bytes
isYieldBearing: Boolean
# Collateral parameters
userHealthyCollateralRatio: BigInt
userLiquidationThreshold: BigInt
lpHealthyCollateralRatio: BigInt
lpLiquidationThreshold: BigInt
lpLiquidationReward: BigInt
# Cycle parameters
rebalanceLength: BigInt
oracleUpdateThreshold: BigInt
#Halt parameters
haltThreshold: BigInt
haltLiquidityPercent: BigInt
haltFeePercent: BigInt
haltRequestThreshold: BigInt
createdAt: BigInt!
updatedAt: BigInt!
# Relation
pools: [Pool!]! @derivedFrom(field: "poolStrategy")
}
# Entity to track user positions
type UserPosition @entity(immutable: false) {
id: ID! # user address + pool address
user: Bytes! # user address
pool: Pool!
assetAmount: BigInt!
depositAmount: BigInt!
collateralAmount: BigInt!
createdAt: BigInt!
updatedAt: BigInt!
}
# Entity to track user requests
type UserRequest @entity(immutable: false) {
id: ID! # user address + pool address + requestCycle
requestType: String! # NONE, DEPOSIT, REDEEM, LIQUIDATE
amount: BigInt!
collateralAmount: BigInt!
requestCycle: BigInt!
liquidator: Bytes # only set if requestType is LIQUIDATE
createdAt: BigInt!
updatedAt: BigInt!
}
# Entity to track LP positions
type LPPosition @entity(immutable: false) {
id: ID! # lp address + pool address
lp: Bytes! # lp address
pool: Pool!
isLPActive: Boolean!
liquidityCommitment: BigInt!
collateralAmount: BigInt!
interestAccrued: BigInt!
delegateAddress: Bytes # address of the delegate that manages the LP rebalance
# Health metrics
liquidityHealth: Int # 3 = Healthy, 2 = Warning, 1 = Liquidatable
# LP analytics
assetShare: BigInt!
lastRebalanceCycle: BigInt!
lastRebalancePrice: BigInt!
createdAt: BigInt!
updatedAt: BigInt!
}
# Entity to track LP requests
type LPRequest @entity(immutable: false) {
id: ID! # lp address + pool address + requestCycle
requestType: String! # NONE, ADD_LIQUIDITY, REDUCE_LIQUIDITY, LIQUIDATE
requestAmount: BigInt!
requestCycle: BigInt!
liquidator: Bytes # only set if requestType is LIQUIDATE
createdAt: BigInt!
updatedAt: BigInt!
}
# Entity to track fee collection
type FeeEvent @entity(immutable: false) {
id: ID! # tx hash + log index
pool: Pool!
user: Bytes!
amount: BigInt!
timestamp: BigInt!
transactionHash: Bytes!
blockNumber: BigInt!
}
type CycleManagerPool @entity(immutable: true) {
id: Bytes! # cycleManager address
pool: Bytes!
}
type LiquidityManagerPool @entity(immutable: true) {
id: Bytes! # liquidityManager address
pool: Bytes!
}