From ec884bda436bd11ba592b8ebeeb4869da939c597 Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Thu, 12 Dec 2024 19:30:39 +0400 Subject: [PATCH 1/6] wip on recharging grid --- public/_strategies/raindex/3-grid/grid.rain | 25 ++++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/public/_strategies/raindex/3-grid/grid.rain b/public/_strategies/raindex/3-grid/grid.rain index 0b5b9c7c..917adaca 100644 --- a/public/_strategies/raindex/3-grid/grid.rain +++ b/public/_strategies/raindex/3-grid/grid.rain @@ -9,7 +9,7 @@ networks: ethereum: rpc: https://rpc.ankr.com/eth chain-id: 1 - network-id: 1 + network-id: 1 currency: ETH bsc: rpc: https://rpc.ankr.com/bsc @@ -210,7 +210,7 @@ gui: - binding: tranche-size name: Tranche size in ETH (e.g. 1) min: 0 - + - deployment: ethereum-weth-pai name: Grid sell PAI for WETH on Ethereum. description: @@ -253,7 +253,7 @@ gui: min: 0 - binding: tranche-size name: Tranche size in MNW (e.g. 2000) - min: 0 + min: 0 - deployment: bsc-busd-tft name: Grid sell TFT for BUSD on BSC. @@ -310,6 +310,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 :; @@ -343,8 +345,13 @@ gui: #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: div(recharge-duration seconds-per-tranche), + 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 @@ -356,4 +363,10 @@ gui: #set-last-tranche-space tranche-space:, - :set(order-hash() tranche-space); \ No newline at end of file + :set(order-hash() tranche-space); + +#get-last-trade-time + _: get(hash(order-hash())); + +#set-last-trade-time + :set(hash(order-hash()) now()); \ No newline at end of file From ced8e8308fa8fbed2a50fa1b566b489efcbdb1c7 Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Thu, 12 Dec 2024 20:05:58 +0400 Subject: [PATCH 2/6] wip on recharging grid --- public/_strategies/raindex/3-grid/grid.rain | 123 +++++++++++++++----- 1 file changed, 95 insertions(+), 28 deletions(-) diff --git a/public/_strategies/raindex/3-grid/grid.rain b/public/_strategies/raindex/3-grid/grid.rain index 917adaca..08a6bca4 100644 --- a/public/_strategies/raindex/3-grid/grid.rain +++ b/public/_strategies/raindex/3-grid/grid.rain @@ -141,47 +141,45 @@ orders: - token: polygon-ioen scenarios: - base: - orderbook: base - runs: 1 - bindings: - raindex-subparser: 0x662dFd6d5B6DF94E07A60954901D3001c24F856a - tranche-space-min-headroom: 0.25 - ethereum: - orderbook: ethereum - runs: 1 - bindings: - raindex-subparser: 0x22410e2a46261a1B1e3899a072f303022801C764 - tranche-space-min-headroom: 0.25 - bsc: - orderbook: bsc - runs: 1 - bindings: - raindex-subparser: 0x662dFd6d5B6DF94E07A60954901D3001c24F856a - tranche-space-min-headroom: 0.25 - polygon: - orderbook: polygon + simple: runs: 1 bindings: - raindex-subparser: 0xF9323B7d23c655122Fb0272D989b83E105cBcf9d tranche-space-min-headroom: 0.25 + tranche-space-recharge-delay: 300 + scenarios: + base: + orderbook: base + bindings: + raindex-subparser: 0x662dFd6d5B6DF94E07A60954901D3001c24F856a + ethereum: + orderbook: ethereum + bindings: + raindex-subparser: 0x22410e2a46261a1B1e3899a072f303022801C764 + bsc: + orderbook: bsc + bindings: + raindex-subparser: 0x662dFd6d5B6DF94E07A60954901D3001c24F856a + polygon: + orderbook: polygon + bindings: + raindex-subparser: 0xF9323B7d23c655122Fb0272D989b83E105cBcf9d deployments: base-usdc-weth: order: base-usdc-weth - scenario: base + scenario: simple.base ethereum-weth-pai: order: ethereum-weth-pai - scenario: ethereum + scenario: simple.ethereum ethereum-weth-mnw: order: ethereum-weth-mnw - scenario: ethereum + scenario: simple.ethereum bsc-busd-tft: order: bsc-busd-tft - scenario: bsc + scenario: simple.bsc polygon-usdc-ioen: order: polygon-usdc-ioen - scenario: polygon + scenario: simple.polygon gui: name: Grid @@ -210,6 +208,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. @@ -232,6 +244,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. @@ -254,6 +280,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. @@ -277,6 +317,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. @@ -300,7 +354,20 @@ gui: - binding: tranche-size name: Tranche size in IOEN (e.g. 100000) 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 --- #raindex-subparser !The subparser for Raindex. @@ -348,7 +415,7 @@ gui: 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: div(recharge-duration seconds-per-tranche), + 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), From da1b38ebc47978f7fb4bf8f4f13f2e78f4205305 Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Sat, 14 Dec 2024 21:00:15 +0400 Subject: [PATCH 3/6] fix grid --- public/_strategies/raindex/3-grid/grid.rain | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/_strategies/raindex/3-grid/grid.rain b/public/_strategies/raindex/3-grid/grid.rain index cd9d3593..cbeb96d6 100644 --- a/public/_strategies/raindex/3-grid/grid.rain +++ b/public/_strategies/raindex/3-grid/grid.rain @@ -164,18 +164,22 @@ scenarios: scenarios: base: orderbook: base + network: base bindings: raindex-subparser: 0x662dFd6d5B6DF94E07A60954901D3001c24F856a ethereum: orderbook: ethereum + network: ethereum bindings: raindex-subparser: 0x22410e2a46261a1B1e3899a072f303022801C764 bsc: orderbook: bsc + network: bsc bindings: raindex-subparser: 0x662dFd6d5B6DF94E07A60954901D3001c24F856a polygon: orderbook: polygon + network: polygon bindings: raindex-subparser: 0xF9323B7d23c655122Fb0272D989b83E105cBcf9d From a356ae5b48da83c5b2373bbd092aa8a641a55a5e Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Sat, 14 Dec 2024 21:13:47 +0400 Subject: [PATCH 4/6] fix grid --- public/_strategies/raindex/3-grid/grid.rain | 4 ---- 1 file changed, 4 deletions(-) diff --git a/public/_strategies/raindex/3-grid/grid.rain b/public/_strategies/raindex/3-grid/grid.rain index cbeb96d6..cd9d3593 100644 --- a/public/_strategies/raindex/3-grid/grid.rain +++ b/public/_strategies/raindex/3-grid/grid.rain @@ -164,22 +164,18 @@ scenarios: scenarios: base: orderbook: base - network: base bindings: raindex-subparser: 0x662dFd6d5B6DF94E07A60954901D3001c24F856a ethereum: orderbook: ethereum - network: ethereum bindings: raindex-subparser: 0x22410e2a46261a1B1e3899a072f303022801C764 bsc: orderbook: bsc - network: bsc bindings: raindex-subparser: 0x662dFd6d5B6DF94E07A60954901D3001c24F856a polygon: orderbook: polygon - network: polygon bindings: raindex-subparser: 0xF9323B7d23c655122Fb0272D989b83E105cBcf9d From 96ac46a78adad7d8601bc97d04e76f1f84bfd9a6 Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Mon, 16 Dec 2024 14:49:56 +0400 Subject: [PATCH 5/6] remove simple --- public/_strategies/raindex/3-grid/grid.rain | 52 +++++++++++---------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/public/_strategies/raindex/3-grid/grid.rain b/public/_strategies/raindex/3-grid/grid.rain index cd9d3593..36d56261 100644 --- a/public/_strategies/raindex/3-grid/grid.rain +++ b/public/_strategies/raindex/3-grid/grid.rain @@ -156,48 +156,50 @@ orders: - token: polygon-ioen scenarios: - simple: - runs: 1 + base: + orderbook: base + bindings: + raindex-subparser: 0x662dFd6d5B6DF94E07A60954901D3001c24F856a + tranche-space-min-headroom: 0.25 + tranche-space-recharge-delay: 300 + ethereum: + orderbook: ethereum + bindings: + raindex-subparser: 0x22410e2a46261a1B1e3899a072f303022801C764 + tranche-space-min-headroom: 0.25 + tranche-space-recharge-delay: 300 + bsc: + orderbook: bsc + bindings: + raindex-subparser: 0x662dFd6d5B6DF94E07A60954901D3001c24F856a + tranche-space-min-headroom: 0.25 + tranche-space-recharge-delay: 300 + polygon: + orderbook: polygon bindings: + raindex-subparser: 0xF9323B7d23c655122Fb0272D989b83E105cBcf9d tranche-space-min-headroom: 0.25 tranche-space-recharge-delay: 300 - scenarios: - base: - orderbook: base - bindings: - raindex-subparser: 0x662dFd6d5B6DF94E07A60954901D3001c24F856a - ethereum: - orderbook: ethereum - bindings: - raindex-subparser: 0x22410e2a46261a1B1e3899a072f303022801C764 - bsc: - orderbook: bsc - bindings: - raindex-subparser: 0x662dFd6d5B6DF94E07A60954901D3001c24F856a - polygon: - orderbook: polygon - bindings: - raindex-subparser: 0xF9323B7d23c655122Fb0272D989b83E105cBcf9d deployments: base-usdc-weth: order: base-usdc-weth - scenario: simple.base + scenario: base ethereum-weth-pai: order: ethereum-weth-pai - scenario: simple.ethereum + scenario: ethereum ethereum-weth-mnw: order: ethereum-weth-mnw - scenario: simple.ethereum + scenario: ethereum bsc-busd-tft: order: bsc-busd-tft - scenario: simple.bsc + scenario: bsc polygon-usdc-ioen: order: polygon-usdc-ioen - scenario: simple.polygon + scenario: polygon polygon-weth-mnw: order: polygon-weth-mnw - scenario: simple.polygon + scenario: polygon gui: name: Grid From 39e38c9b144ffc9a6f45b403c72c366228f2db59 Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Mon, 16 Dec 2024 16:52:33 +0400 Subject: [PATCH 6/6] set last trade grid --- public/_strategies/raindex/3-grid/grid.rain | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/_strategies/raindex/3-grid/grid.rain b/public/_strategies/raindex/3-grid/grid.rain index 36d56261..e7d220b7 100644 --- a/public/_strategies/raindex/3-grid/grid.rain +++ b/public/_strategies/raindex/3-grid/grid.rain @@ -428,7 +428,8 @@ 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>(),