Skip to content

Commit 1adc1e7

Browse files
authored
Merge pull request #56 from balancer/update-reclamms
update reclamms
2 parents d619286 + d04da57 commit 1adc1e7

16 files changed

+176
-87
lines changed

subgraphs/v3-pools/abis/ReClammPool.json

Lines changed: 137 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
{
2222
"internalType": "uint256",
23-
"name": "priceShiftDailyRate",
23+
"name": "dailyPriceShiftExponent",
2424
"type": "uint256"
2525
},
2626
{
@@ -72,6 +72,11 @@
7272
"name": "BaseOutOfBounds",
7373
"type": "error"
7474
},
75+
{
76+
"inputs": [],
77+
"name": "DailyPriceShiftExponentTooHigh",
78+
"type": "error"
79+
},
7580
{
7681
"inputs": [],
7782
"name": "ECDSAInvalidSignature",
@@ -142,22 +147,6 @@
142147
"name": "FourthRootPriceRatioDeltaBelowMin",
143148
"type": "error"
144149
},
145-
{
146-
"inputs": [
147-
{
148-
"internalType": "uint256",
149-
"name": "resolvedStartTime",
150-
"type": "uint256"
151-
},
152-
{
153-
"internalType": "uint256",
154-
"name": "endTime",
155-
"type": "uint256"
156-
}
157-
],
158-
"name": "GradualUpdateTimeTravel",
159-
"type": "error"
160-
},
161150
{
162151
"inputs": [
163152
{
@@ -194,11 +183,32 @@
194183
"name": "InvalidShortString",
195184
"type": "error"
196185
},
186+
{
187+
"inputs": [
188+
{
189+
"internalType": "uint256",
190+
"name": "resolvedStartTime",
191+
"type": "uint256"
192+
},
193+
{
194+
"internalType": "uint256",
195+
"name": "endTime",
196+
"type": "uint256"
197+
}
198+
],
199+
"name": "InvalidStartTime",
200+
"type": "error"
201+
},
197202
{
198203
"inputs": [],
199204
"name": "InvalidStartTime",
200205
"type": "error"
201206
},
207+
{
208+
"inputs": [],
209+
"name": "InvalidToken",
210+
"type": "error"
211+
},
202212
{
203213
"inputs": [],
204214
"name": "NegativeAmountOut",
@@ -229,11 +239,6 @@
229239
"name": "PriceRatioUpdateDurationTooShort",
230240
"type": "error"
231241
},
232-
{
233-
"inputs": [],
234-
"name": "PriceShiftDailyRateTooHigh",
235-
"type": "error"
236-
},
237242
{
238243
"inputs": [],
239244
"name": "ProductOutOfBounds",
@@ -361,6 +366,25 @@
361366
"name": "CenterednessMarginUpdated",
362367
"type": "event"
363368
},
369+
{
370+
"anonymous": false,
371+
"inputs": [
372+
{
373+
"indexed": false,
374+
"internalType": "uint256",
375+
"name": "dailyPriceShiftExponent",
376+
"type": "uint256"
377+
},
378+
{
379+
"indexed": false,
380+
"internalType": "uint256",
381+
"name": "dailyPriceShiftBase",
382+
"type": "uint256"
383+
}
384+
],
385+
"name": "DailyPriceShiftExponentUpdated",
386+
"type": "event"
387+
},
364388
{
365389
"anonymous": false,
366390
"inputs": [],
@@ -411,25 +435,6 @@
411435
"name": "PriceRatioStateUpdated",
412436
"type": "event"
413437
},
414-
{
415-
"anonymous": false,
416-
"inputs": [
417-
{
418-
"indexed": false,
419-
"internalType": "uint256",
420-
"name": "priceShiftDailyRate",
421-
"type": "uint256"
422-
},
423-
{
424-
"indexed": false,
425-
"internalType": "uint256",
426-
"name": "priceShiftDailyRateInSeconds",
427-
"type": "uint256"
428-
}
429-
],
430-
"name": "PriceShiftDailyRateUpdated",
431-
"type": "event"
432-
},
433438
{
434439
"anonymous": false,
435440
"inputs": [
@@ -669,10 +674,34 @@
669674
"outputs": [
670675
{
671676
"internalType": "uint256",
672-
"name": "balanceRatio",
677+
"name": "",
678+
"type": "uint256"
679+
}
680+
],
681+
"stateMutability": "view",
682+
"type": "function"
683+
},
684+
{
685+
"inputs": [
686+
{
687+
"internalType": "contract IERC20",
688+
"name": "referenceToken",
689+
"type": "address"
690+
},
691+
{
692+
"internalType": "uint256",
693+
"name": "referenceAmountIn",
673694
"type": "uint256"
674695
}
675696
],
697+
"name": "computeInitialBalances",
698+
"outputs": [
699+
{
700+
"internalType": "uint256[]",
701+
"name": "initialBalances",
702+
"type": "uint256[]"
703+
}
704+
],
676705
"stateMutability": "view",
677706
"type": "function"
678707
},
@@ -865,6 +894,32 @@
865894
"stateMutability": "view",
866895
"type": "function"
867896
},
897+
{
898+
"inputs": [],
899+
"name": "getDailyPriceShiftBase",
900+
"outputs": [
901+
{
902+
"internalType": "uint256",
903+
"name": "",
904+
"type": "uint256"
905+
}
906+
],
907+
"stateMutability": "view",
908+
"type": "function"
909+
},
910+
{
911+
"inputs": [],
912+
"name": "getDailyPriceShiftExponent",
913+
"outputs": [
914+
{
915+
"internalType": "uint256",
916+
"name": "",
917+
"type": "uint256"
918+
}
919+
],
920+
"stateMutability": "view",
921+
"type": "function"
922+
},
868923
{
869924
"inputs": [],
870925
"name": "getHookFlags",
@@ -1048,19 +1103,6 @@
10481103
"stateMutability": "view",
10491104
"type": "function"
10501105
},
1051-
{
1052-
"inputs": [],
1053-
"name": "getPriceShiftDailyRateInSeconds",
1054-
"outputs": [
1055-
{
1056-
"internalType": "uint256",
1057-
"name": "",
1058-
"type": "uint256"
1059-
}
1060-
],
1061-
"stateMutability": "view",
1062-
"type": "function"
1063-
},
10641106
{
10651107
"inputs": [],
10661108
"name": "getRate",
@@ -1112,7 +1154,7 @@
11121154
},
11131155
{
11141156
"internalType": "uint256",
1115-
"name": "priceShiftDailyRateInSeconds",
1157+
"name": "dailyPriceShiftBase",
11161158
"type": "uint256"
11171159
},
11181160
{
@@ -1202,7 +1244,7 @@
12021244
},
12031245
{
12041246
"internalType": "uint256",
1205-
"name": "initialPriceShiftDailyRate",
1247+
"name": "initialDailyPriceShiftExponent",
12061248
"type": "uint256"
12071249
},
12081250
{
@@ -1232,7 +1274,7 @@
12321274
},
12331275
{
12341276
"internalType": "uint256",
1235-
"name": "maxPriceShiftDailyRate",
1277+
"name": "maxDailyPriceShiftExponent",
12361278
"type": "uint256"
12371279
},
12381280
{
@@ -1358,6 +1400,24 @@
13581400
"stateMutability": "view",
13591401
"type": "function"
13601402
},
1403+
{
1404+
"inputs": [],
1405+
"name": "isPoolWithinTargetRangeUsingCurrentVirtualBalances",
1406+
"outputs": [
1407+
{
1408+
"internalType": "bool",
1409+
"name": "isWithinTargetRange",
1410+
"type": "bool"
1411+
},
1412+
{
1413+
"internalType": "bool",
1414+
"name": "virtualBalancesChanged",
1415+
"type": "bool"
1416+
}
1417+
],
1418+
"stateMutability": "view",
1419+
"type": "function"
1420+
},
13611421
{
13621422
"inputs": [],
13631423
"name": "name",
@@ -2067,6 +2127,25 @@
20672127
"stateMutability": "nonpayable",
20682128
"type": "function"
20692129
},
2130+
{
2131+
"inputs": [
2132+
{
2133+
"internalType": "uint256",
2134+
"name": "newDailyPriceShiftExponent",
2135+
"type": "uint256"
2136+
}
2137+
],
2138+
"name": "setDailyPriceShiftExponent",
2139+
"outputs": [
2140+
{
2141+
"internalType": "uint256",
2142+
"name": "",
2143+
"type": "uint256"
2144+
}
2145+
],
2146+
"stateMutability": "nonpayable",
2147+
"type": "function"
2148+
},
20702149
{
20712150
"inputs": [
20722151
{
@@ -2096,19 +2175,6 @@
20962175
"stateMutability": "nonpayable",
20972176
"type": "function"
20982177
},
2099-
{
2100-
"inputs": [
2101-
{
2102-
"internalType": "uint256",
2103-
"name": "newPriceShiftDailyRate",
2104-
"type": "uint256"
2105-
}
2106-
],
2107-
"name": "setPriceShiftDailyRate",
2108-
"outputs": [],
2109-
"stateMutability": "nonpayable",
2110-
"type": "function"
2111-
},
21122178
{
21132179
"inputs": [
21142180
{

subgraphs/v3-pools/schema.graphql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ type ReClammParams @entity {
144144
"The last virtual balances of the pool"
145145
lastVirtualBalances: [BigInt!]!
146146
"Represents how fast the pool can move the virtual balances per day"
147-
priceShiftDailyRateInSeconds: BigInt!
147+
dailyPriceShiftExponent: BigInt!
148+
"Internal time constant used to update virtual balances (1 - tau)"
149+
dailyPriceShiftBase: BigInt!
148150
"The centeredness margin of the pool"
149151
centerednessMargin: BigInt!
150152
"The current fourth root price ratio, an interpolation of the price ratio state"

subgraphs/v3-pools/src/mappings/reclamm.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import { ReClammPool } from "../types/ReClammPoolFactory/ReClammPool";
66
import { ReClammParams } from "../types/schema";
77
import { ReClammPool as ReClammPoolTemplate } from "../types/templates";
88
import {
9+
DailyPriceShiftExponentUpdated,
910
CenterednessMarginUpdated,
10-
LastTimestampUpdated,
1111
PriceRatioStateUpdated,
12-
PriceShiftDailyRateUpdated,
1312
VirtualBalancesUpdated,
13+
LastTimestampUpdated,
1414
} from "../types/templates/ReClammPool/ReClammPool";
1515

1616
function handleReClammPoolParams(poolAddress: Address): Bytes {
@@ -22,8 +22,7 @@ function handleReClammPoolParams(poolAddress: Address): Bytes {
2222
reClammParams.lastTimestamp = reClammData.lastTimestamp;
2323
reClammParams.lastVirtualBalances = reClammData.lastVirtualBalances;
2424
reClammParams.centerednessMargin = reClammData.centerednessMargin;
25-
reClammParams.priceShiftDailyRateInSeconds =
26-
reClammData.priceShiftDailyRateInSeconds;
25+
reClammParams.dailyPriceShiftBase = reClammData.dailyPriceShiftBase;
2726
reClammParams.currentFourthRootPriceRatio =
2827
reClammData.currentFourthRootPriceRatio;
2928
reClammParams.startFourthRootPriceRatio =
@@ -33,6 +32,9 @@ function handleReClammPoolParams(poolAddress: Address): Bytes {
3332
reClammData.priceRatioUpdateStartTime;
3433
reClammParams.priceRatioUpdateEndTime = reClammData.priceRatioUpdateEndTime;
3534

35+
let dailyPriceShiftExponent = reClamm.getDailyPriceShiftExponent();
36+
reClammParams.dailyPriceShiftExponent = dailyPriceShiftExponent;
37+
3638
reClammParams.save();
3739

3840
return reClammParams.id;
@@ -78,11 +80,12 @@ export function handleReClammVirtualBalancesUpdated(
7880
pool.save();
7981
}
8082

81-
export function handleReClammPriceShiftDailyRateUpdated(
82-
event: PriceShiftDailyRateUpdated
83+
export function handleDailyPriceShiftExponentUpdated(
84+
event: DailyPriceShiftExponentUpdated
8385
): void {
8486
let pool = ReClammParams.load(event.address) as ReClammParams;
85-
pool.priceShiftDailyRateInSeconds = event.params.priceShiftDailyRateInSeconds;
87+
pool.dailyPriceShiftBase = event.params.dailyPriceShiftBase;
88+
pool.dailyPriceShiftExponent = event.params.dailyPriceShiftExponent;
8689
pool.save();
8790
}
8891

subgraphs/v3-pools/subgraph.base.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ templates:
231231
handler: handleReClammLastTimestampUpdated
232232
- event: PriceRatioStateUpdated(uint256,uint256,uint256,uint256)
233233
handler: handleReClammPriceRatioStateUpdated
234-
- event: PriceShiftDailyRateUpdated(uint256,uint256)
235-
handler: handleReClammPriceShiftDailyRateUpdated
234+
- event: DailyPriceShiftExponentUpdated(uint256,uint256)
235+
handler: handleReClammDailyPriceShiftExponentUpdated
236236
- event: VirtualBalancesUpdated(uint256,uint256)
237237
handler: handleReClammVirtualBalancesUpdated
238238
file: ./src/mappings/reclamm.ts

0 commit comments

Comments
 (0)