Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip on recharging grid #315

Merged
merged 10 commits into from
Dec 18, 2024
120 changes: 90 additions & 30 deletions public/_strategies/raindex/3-grid/grid.rain
Original file line number Diff line number Diff line change
Expand Up @@ -158,28 +158,28 @@ orders:
scenarios:
base:
orderbook: base
runs: 1
bindings:
raindex-subparser: 0x662dFd6d5B6DF94E07A60954901D3001c24F856a
tranche-space-min-headroom: 0.25
tranche-space-recharge-delay: 300
ethereum:
orderbook: ethereum
runs: 1
bindings:
raindex-subparser: 0x22410e2a46261a1B1e3899a072f303022801C764
tranche-space-min-headroom: 0.25
tranche-space-recharge-delay: 300
bsc:
orderbook: bsc
runs: 1
bindings:
raindex-subparser: 0x662dFd6d5B6DF94E07A60954901D3001c24F856a
tranche-space-min-headroom: 0.25
tranche-space-recharge-delay: 300
polygon:
orderbook: polygon
runs: 1
bindings:
raindex-subparser: 0xF9323B7d23c655122Fb0272D989b83E105cBcf9d
tranche-space-min-headroom: 0.25
tranche-space-recharge-delay: 300

deployments:
base-usdc-weth:
Expand Down Expand Up @@ -228,6 +228,20 @@ gui:
- binding: tranche-size
name: Tranche size in ETH (e.g. 1)
min: 0
- binding: seconds-per-tranche
name: Time to recharge one grid tranche in seconds (0 is disabled).
min: 0
presets:
- name: Disabled (0)
value: 0
- name: 1 hour (3600)
value: 3600
- name: 6 hours (21600)
value: 21600
- name: 12 hours (43200)
value: 43200
- name: 24 hours (86400)
value: 86400

- deployment: ethereum-weth-pai
name: Grid sell PAI for WETH on Ethereum.
Expand All @@ -250,6 +264,20 @@ gui:
- binding: tranche-size
name: Tranche size in PAI (e.g. 1000)
min: 0
- binding: seconds-per-tranche
name: Time to recharge one grid tranche in seconds (0 is disabled).
min: 0
presets:
- name: Disabled (0)
value: 0
- name: 1 hour (3600)
value: 3600
- name: 6 hours (21600)
value: 21600
- name: 12 hours (43200)
value: 43200
- name: 24 hours (86400)
value: 86400

- deployment: ethereum-weth-mnw
name: Grid sell MNW for WETH on Ethereum.
Expand All @@ -272,6 +300,20 @@ gui:
- binding: tranche-size
name: Tranche size in MNW (e.g. 2000)
min: 0
- binding: seconds-per-tranche
name: Time to recharge one grid tranche in seconds (0 is disabled).
min: 0
presets:
- name: Disabled (0)
value: 0
- name: 1 hour (3600)
value: 3600
- name: 6 hours (21600)
value: 21600
- name: 12 hours (43200)
value: 43200
- name: 24 hours (86400)
value: 86400

- deployment: bsc-busd-tft
name: Grid sell TFT for BUSD on BSC.
Expand All @@ -295,6 +337,20 @@ gui:
- binding: tranche-size
name: Tranche size in TFT (e.g. 1000)
min: 0
- binding: seconds-per-tranche
name: Time to recharge one grid tranche in seconds (0 is disabled).
min: 0
presets:
- name: Disabled (0)
value: 0
- name: 1 hour (3600)
value: 3600
- name: 6 hours (21600)
value: 21600
- name: 12 hours (43200)
value: 43200
- name: 24 hours (86400)
value: 86400

- deployment: polygon-usdc-ioen
name: Grid sell IOEN for USDC on Polygon.
Expand All @@ -318,30 +374,20 @@ gui:
- binding: tranche-size
name: Tranche size in IOEN (e.g. 100000)
min: 0

- deployment: polygon-weth-mnw
name: Grid sell MNW for WETH on Polygon.
description:
Grid sell MNW for WETH on Polygon Mainnet.
deposits:
- token: polygon-mnw
- binding: seconds-per-tranche
name: Time to recharge one grid tranche in seconds (0 is disabled).
min: 0
presets:
- 1000
- 10000
- 100000
fields:
- binding: baseline-io-ratio
name: Baseline WETH per MNW (e.g. 0.00012)
min: 0
- binding: io-ratio-growth
name: IO ratio growth per tranche (e.g. 0.00001)
min: 0
- binding: tranche-size
name: Tranche size in MNW (e.g. 2000)
min: 0


- name: Disabled (0)
value: 0
- name: 1 hour (3600)
value: 3600
- name: 6 hours (21600)
value: 21600
- name: 12 hours (43200)
value: 43200
- name: 24 hours (86400)
value: 86400
---

#raindex-subparser !The subparser for Raindex.
Expand All @@ -351,6 +397,8 @@ gui:
#tranche-size !The size of each tranche in amount token.

#tranche-space-min-headroom !The minimum headroom for the tranche space.
#tranche-space-recharge-delay !The delay before the tranche space recharges.
#seconds-per-tranche !The number of seconds per tranche to recharge.

#handle-add-order
:;
Expand Down Expand Up @@ -380,12 +428,18 @@ gui:
)
"Trade causes dust."
),
:call<'set-last-tranche-space>(tranche-space-after);
:call<'set-last-tranche-space>(tranche-space-after),
:call<'set-last-trade-time>();

#calculate-tranche
last-tranche-space: call<'get-last-tranche-space>(),
current-tranche-floor: floor(last-tranche-space),
current-tranche-headroom: headroom(last-tranche-space),
last-trade-time: call<'get-last-trade-time>(),
current-time: now(),
recharge-duration: saturating-sub(current-time add(last-trade-time tranche-space-recharge-delay)),
recharged-tranche-space: every(seconds-per-tranche div(recharge-duration any(seconds-per-tranche max-value()))),
tranche-space-now: saturating-sub(last-tranche-space recharged-tranche-space),
current-tranche-floor: floor(tranche-space-now),
current-tranche-headroom: headroom(tranche-space-now),
tranche-total-size: tranche-size;

#linear-growth
Expand All @@ -397,4 +451,10 @@ gui:

#set-last-tranche-space
tranche-space:,
:set(order-hash() tranche-space);
:set(order-hash() tranche-space);

#get-last-trade-time
_: get(hash(order-hash()));

#set-last-trade-time
:set(hash(order-hash()) now());
Loading