Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Challenge Task
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OST
BlCh
Challenge Task
Commits
a213d103
Commit
a213d103
authored
4 months ago
by
David Hintermann
Browse files
Options
Downloads
Patches
Plain Diff
wip: add automatic rebalancing
parent
20fb1fb1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!10
feat(rebalancer): rebalance automatically
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Frontend/BackgroundServices/RebalanceService.cs
+1
-1
1 addition, 1 deletion
Frontend/BackgroundServices/RebalanceService.cs
Frontend/PoolV3Client.cs
+1
-2
1 addition, 2 deletions
Frontend/PoolV3Client.cs
grafana/dashboards/totalSupply.json
+139
-39
139 additions, 39 deletions
grafana/dashboards/totalSupply.json
with
141 additions
and
42 deletions
Frontend/BackgroundServices/RebalanceService.cs
+
1
−
1
View file @
a213d103
...
...
@@ -16,7 +16,7 @@ public class RebalanceService : BackgroundService
public
RebalanceService
(
Rebalancer
rebalancer
,
Logger
<
RebalanceService
>
logger
I
Logger
<
RebalanceService
>
logger
)
{
_logger
=
logger
;
...
...
This diff is collapsed.
Click to expand it.
Frontend/PoolV3Client.cs
+
1
−
2
View file @
a213d103
...
...
@@ -165,7 +165,7 @@ public class PoolV3Client
/*
this function should swap the tokens in the pool
*/
public
async
Task
<
decimal
>
SwapAsync
(
string
fromTokenAddress
,
string
toTokenAddress
,
decimal
amount
,
decimal
amountOutMinimum
=
0
,
uint
sqrtPriceLimitX96
=
0
,
bool
doApproval
=
true
)
public
async
Task
SwapAsync
(
string
fromTokenAddress
,
string
toTokenAddress
,
decimal
amount
,
decimal
amountOutMinimum
=
0
,
uint
sqrtPriceLimitX96
=
0
,
bool
doApproval
=
true
)
{
if
(
doApproval
)
...
...
@@ -200,7 +200,6 @@ public class PoolV3Client
SqrtPriceLimitX96
=
sqrtPriceLimitX96
,
};
var
exactInputSingleFunctionTxnReceipt
=
await
contractHandler
.
SendRequestAndWaitForReceiptAsync
(
exactInputSingleFunction
);
return
0.0m
;
}
/// <summary>
...
...
This diff is collapsed.
Click to expand it.
grafana/dashboards/totalSupply.json
+
139
−
39
View file @
a213d103
...
...
@@ -241,7 +241,6 @@
"type"
:
"prometheus"
,
"uid"
:
"PBFA97CFB590B2093"
},
"description"
:
"averaged over 2 minutes"
,
"fieldConfig"
:
{
"defaults"
:
{
"color"
:
{
...
...
@@ -249,7 +248,7 @@
},
"custom"
:
{
"axisBorderShow"
:
false
,
"axisCenteredZero"
:
fals
e
,
"axisCenteredZero"
:
tru
e
,
"axisColorMode"
:
"text"
,
"axisLabel"
:
""
,
"axisPlacement"
:
"auto"
,
...
...
@@ -280,18 +279,13 @@
"mode"
:
"off"
}
},
"decimals"
:
8
,
"mappings"
:
[],
"thresholds"
:
{
"mode"
:
"
absolut
e"
,
"mode"
:
"
percentag
e"
,
"steps"
:
[
{
"color"
:
"green"
,
"value"
:
null
},
{
"color"
:
"red"
,
"value"
:
80
}
]
}
...
...
@@ -299,12 +293,12 @@
"overrides"
:
[]
},
"gridPos"
:
{
"h"
:
14
,
"h"
:
8
,
"w"
:
12
,
"x"
:
0
,
"y"
:
8
},
"id"
:
9
,
"id"
:
12
,
"options"
:
{
"legend"
:
{
"calcs"
:
[],
...
...
@@ -321,13 +315,26 @@
"targets"
:
[
{
"editorMode"
:
"code"
,
"expr"
:
"
avg_over_time(
Marketplace_Potato_Price_ETH
[2m])
"
,
"legendFormat"
:
"
__auto
"
,
"expr"
:
"Marketplace_Potato_Price_ETH
{} * 1/Uniswap_ROCWETH_price_WETH_per_ROC-1
"
,
"legendFormat"
:
"
current
"
,
"range"
:
true
,
"refId"
:
"A"
},
{
"datasource"
:
{
"type"
:
"prometheus"
,
"uid"
:
"PBFA97CFB590B2093"
},
"editorMode"
:
"code"
,
"expr"
:
"avg_over_time(Marketplace_Potato_Price_ETH{}[2m]) * 1/avg_over_time(Uniswap_ROCWETH_price_WETH_per_ROC[2m])-1"
,
"hide"
:
false
,
"instant"
:
false
,
"legendFormat"
:
"avg over 2min"
,
"range"
:
true
,
"refId"
:
"B"
}
],
"title"
:
"Price
of 1
kg Potato
[ETH
]"
,
"title"
:
"
ROC
Price
[
kg Potato]"
,
"type"
:
"timeseries"
},
{
...
...
@@ -441,7 +448,6 @@
}
],
"title"
:
"Total Supply"
,
"transparent"
:
true
,
"type"
:
"timeseries"
},
{
...
...
@@ -718,6 +724,7 @@
"type"
:
"prometheus"
,
"uid"
:
"PBFA97CFB590B2093"
},
"description"
:
"averaged over 2 minutes"
,
"fieldConfig"
:
{
"defaults"
:
{
"color"
:
{
...
...
@@ -756,6 +763,7 @@
"mode"
:
"off"
}
},
"decimals"
:
8
,
"mappings"
:
[],
"thresholds"
:
{
"mode"
:
"absolute"
,
...
...
@@ -774,12 +782,104 @@
"overrides"
:
[]
},
"gridPos"
:
{
"h"
:
8
,
"h"
:
14
,
"w"
:
12
,
"x"
:
0
,
"y"
:
16
},
"id"
:
9
,
"options"
:
{
"legend"
:
{
"calcs"
:
[],
"displayMode"
:
"list"
,
"placement"
:
"bottom"
,
"showLegend"
:
true
},
"tooltip"
:
{
"mode"
:
"single"
,
"sort"
:
"none"
}
},
"pluginVersion"
:
"11.3.0+security-01"
,
"targets"
:
[
{
"editorMode"
:
"code"
,
"expr"
:
"avg_over_time(Marketplace_Potato_Price_ETH[2m])"
,
"legendFormat"
:
"__auto"
,
"range"
:
true
,
"refId"
:
"A"
}
],
"title"
:
"Price of 1kg Potato [ETH]"
,
"type"
:
"timeseries"
},
{
"datasource"
:
{
"type"
:
"prometheus"
,
"uid"
:
"PBFA97CFB590B2093"
},
"fieldConfig"
:
{
"defaults"
:
{
"color"
:
{
"mode"
:
"palette-classic"
},
"custom"
:
{
"axisBorderShow"
:
false
,
"axisCenteredZero"
:
false
,
"axisColorMode"
:
"text"
,
"axisLabel"
:
""
,
"axisPlacement"
:
"auto"
,
"barAlignment"
:
0
,
"barWidthFactor"
:
0.6
,
"drawStyle"
:
"line"
,
"fillOpacity"
:
0
,
"gradientMode"
:
"none"
,
"hideFrom"
:
{
"legend"
:
false
,
"tooltip"
:
false
,
"viz"
:
false
},
"insertNulls"
:
false
,
"lineInterpolation"
:
"linear"
,
"lineWidth"
:
1
,
"pointSize"
:
5
,
"scaleDistribution"
:
{
"type"
:
"linear"
},
"showPoints"
:
"auto"
,
"spanNulls"
:
false
,
"stacking"
:
{
"group"
:
"A"
,
"mode"
:
"none"
},
"thresholdsStyle"
:
{
"mode"
:
"off"
}
},
"mappings"
:
[],
"thresholds"
:
{
"mode"
:
"absolute"
,
"steps"
:
[
{
"color"
:
"green"
,
"value"
:
null
},
{
"color"
:
"red"
,
"value"
:
80
}
]
}
},
"overrides"
:
[]
},
"gridPos"
:
{
"h"
:
8
,
"w"
:
12
,
"x"
:
12
,
"y"
:
22
},
"id"
:
4
,
"id"
:
8
,
"options"
:
{
"legend"
:
{
"calcs"
:
[],
...
...
@@ -795,15 +895,11 @@
"pluginVersion"
:
"11.3.0+security-01"
,
"targets"
:
[
{
"disableTextWrap"
:
false
,
"editorMode"
:
"code"
,
"expr"
:
"Marketplace_Ethereum_Price_CHF * Uniswap_ROCWETH_price_WETH_per_ROC"
,
"fullMetaSearch"
:
false
,
"includeNullMetadata"
:
true
,
"legendFormat"
:
"price"
,
"expr"
:
"avg_over_time(Marketplace_Ethereum_Price_CHF[5m])"
,
"legendFormat"
:
"ETH in CHF averaged 5min"
,
"range"
:
true
,
"refId"
:
"A"
,
"useBackend"
:
false
"refId"
:
"A"
},
{
"datasource"
:
{
...
...
@@ -811,10 +907,10 @@
"uid"
:
"PBFA97CFB590B2093"
},
"editorMode"
:
"code"
,
"expr"
:
"avg_over_time(Marketplace_Ethereum_Price_CHF[
5m]) * avg_over_time(Uniswap_ROCWETH_price_WETH_per_ROC[5
m])"
,
"expr"
:
"avg_over_time(Marketplace_Ethereum_Price_CHF[
2
m])"
,
"hide"
:
false
,
"instant"
:
false
,
"legendFormat"
:
"
Price average over 5
min"
,
"legendFormat"
:
"
ETH in CHF averaged 2
min"
,
"range"
:
true
,
"refId"
:
"B"
},
...
...
@@ -824,15 +920,15 @@
"uid"
:
"PBFA97CFB590B2093"
},
"editorMode"
:
"code"
,
"expr"
:
"
avg_over_time(
Marketplace_Ethereum_Price_CHF
[2m]) * avg_over_time(Uniswap_ROCWETH_price_WETH_per_ROC[2m])
"
,
"expr"
:
"Marketplace_Ethereum_Price_CHF"
,
"hide"
:
false
,
"instant"
:
false
,
"legendFormat"
:
"
Price average over 2 min
"
,
"legendFormat"
:
"
ETH in CHF
"
,
"range"
:
true
,
"refId"
:
"C"
}
],
"title"
:
"
ROC P
rice in CHF"
,
"title"
:
"
ETH p
rice in CHF"
,
"type"
:
"timeseries"
},
{
...
...
@@ -898,10 +994,10 @@
"gridPos"
:
{
"h"
:
8
,
"w"
:
12
,
"x"
:
12
,
"y"
:
22
"x"
:
0
,
"y"
:
30
},
"id"
:
8
,
"id"
:
4
,
"options"
:
{
"legend"
:
{
"calcs"
:
[],
...
...
@@ -917,11 +1013,15 @@
"pluginVersion"
:
"11.3.0+security-01"
,
"targets"
:
[
{
"disableTextWrap"
:
false
,
"editorMode"
:
"code"
,
"expr"
:
"avg_over_time(Marketplace_Ethereum_Price_CHF[5m])"
,
"legendFormat"
:
"ETH in CHF averaged 5min"
,
"expr"
:
"Marketplace_Ethereum_Price_CHF * Uniswap_ROCWETH_price_WETH_per_ROC"
,
"fullMetaSearch"
:
false
,
"includeNullMetadata"
:
true
,
"legendFormat"
:
"price"
,
"range"
:
true
,
"refId"
:
"A"
"refId"
:
"A"
,
"useBackend"
:
false
},
{
"datasource"
:
{
...
...
@@ -929,10 +1029,10 @@
"uid"
:
"PBFA97CFB590B2093"
},
"editorMode"
:
"code"
,
"expr"
:
"avg_over_time(Marketplace_Ethereum_Price_CHF[
2
m])"
,
"expr"
:
"avg_over_time(Marketplace_Ethereum_Price_CHF[
5m]) * avg_over_time(Uniswap_ROCWETH_price_WETH_per_ROC[5
m])"
,
"hide"
:
false
,
"instant"
:
false
,
"legendFormat"
:
"
ETH in CHF averaged 2
min"
,
"legendFormat"
:
"
Price average over 5
min"
,
"range"
:
true
,
"refId"
:
"B"
},
...
...
@@ -942,15 +1042,15 @@
"uid"
:
"PBFA97CFB590B2093"
},
"editorMode"
:
"code"
,
"expr"
:
"Marketplace_Ethereum_Price_CHF"
,
"expr"
:
"
avg_over_time(
Marketplace_Ethereum_Price_CHF
[2m]) * avg_over_time(Uniswap_ROCWETH_price_WETH_per_ROC[2m])
"
,
"hide"
:
false
,
"instant"
:
false
,
"legendFormat"
:
"
ETH in CHF
"
,
"legendFormat"
:
"
Price average over 2 min
"
,
"range"
:
true
,
"refId"
:
"C"
}
],
"title"
:
"
ETH p
rice in CHF"
,
"title"
:
"
ROC P
rice in CHF"
,
"type"
:
"timeseries"
}
],
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment