Skip to content

Commit

Permalink
wlth-dca-streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth2207 committed Jul 8, 2024
1 parent bb96faa commit 8a6d1e4
Show file tree
Hide file tree
Showing 4 changed files with 681 additions and 78 deletions.
141 changes: 67 additions & 74 deletions strategies/wlth/dca-streaming.rain → strategies/dca-streaming.rain
Original file line number Diff line number Diff line change
@@ -1,76 +1,69 @@
# Strategy: Streaming DCA
# Strategy cost averages output token against the input token for an input-ouput token pair,
# buy offering tokens at a fixed rate per unit time which can be provided in the bindings, along with a minimum
# io-ratio for the order.
# Bounty auction to pay for gas denominated in input token terms, with a min and max bounty offered for the trade.
# Since the strategy has a per-second budget, any external order taker can offer any amount of input token and
# take the output tokens from the orderbook provided the trade pays for the gas as well. So even if multiple order
# takers come in and try to take the order, the strategy just cost averages the tokens for a taker and
# calculates the budget amount for next. This prevents external takers to DDos the order as ouput amount is calculated
# for each taker individually.
#
# Target Network: Base
# Quote (Input / Incoming): USDC or WLTH
# Base (Output / Outgoing): WLTH or USDC
# Token contract: https://basescan.org/address/0x99b2B1A2aDB02B38222ADcD057783D7e5D1FCC7D
# Token github: NA
# Liquidity protocol: Uniswap V3
# Liquidity pool address: https://www.dextools.io/app/en/base/pair-explorer/0x1536ee1506e24e5a36be99c73136cd82907a902e?t=1717921711270
# Liquidity pool fee: 0.3%
#
# Strategy Description:
# - Strategy cost averages output token against the input token for an input-ouput token pair,
# buy offering tokens at a fixed rate per unit time which can be provided in the bindings, along with a minimum
# io-ratio for the order.
# - Bounty auction to pay for gas denominated in input token terms, with a min and max bounty offered for the trade.
# - Since the strategy has a per-second budget, any external order taker can offer any amount of input token and
# take the output tokens from the orderbook provided the trade pays for the gas as well. So even if multiple order
# takers come in and try to take the order, the strategy just cost averages the tokens for a taker and
# calculates the budget amount for next. This prevents external takers to DDos the order as ouput amount is calculated
# for each taker individually.

networks:
base-community:
rpc: https://mainnet.base.org
chain-id: 8453
network-id: 8453
currency: ETH
polygon-dolz:
rpc: https://polygon-mainnet.g.alchemy.com/v2/y3BXawVv5uuP_g8BaDlKbKoTBGHo9zD9
chain-id: 137
network-id: 137
currency: MATIC

subgraphs:
base-community: https://api.thegraph.com/subgraphs/name/h20liquidity/base-0x2aee87
polygon-dolz: https://api.thegraph.com/subgraphs/name/h20liquidity/polygon-0xc95a5f8e

orderbooks:
base-community:
address: 0x2AeE87D75CD000583DAEC7A28db103B1c0c18b76
network: base-community
subgraph: base-community
polygon-dolz:
address: 0xc95A5f8eFe14d7a20BD2E5BAFEC4E71f8Ce0B9A6
network: polygon-dolz
subgraph: polygon-dolz

deployers:
base-community:
address: 0xfca89cD12Ba1346b1ac570ed988AB43b812733fe
network: base-community
polygon-dolz:
address: 0xB3aC858bEAf7814892d3946A8C109A7D701DF8E7
network: polygon-dolz

tokens:
base-wlth:
network: base-community
address: 0x99b2B1A2aDB02B38222ADcD057783D7e5D1FCC7D
base-usdc:
network: base-community
address: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
polygon-dolz:
network: polygon-dolz
address: 0x6ab4E20f36ca48B61ECd66c0450fDf665Fa130be
polygon-usdt:
network: polygon-dolz
address: 0xc2132D05D31c914a87C6611C10748AEb04B58e8F

orders:
# vault-id generated with `openssl rand -hex 32`
polygon-wlth-sell:
orderbook: polygon-wlth
polygon-dolz-sell:
orderbook: polygon-dolz
inputs:
- token: polygon-usdt
vault-id: 0x6049f8ee79b82dd5bc82b368114bb0a69f34d539b04b43208241e1f68da134a8
outputs:
- token: polygon-wlth
- token: polygon-dolz
vault-id: 0x6049f8ee79b82dd5bc82b368114bb0a69f34d539b04b43208241e1f68da134a8
polygon-wlth-buy:
orderbook: polygon-wlth
polygon-dolz-buy:
orderbook: polygon-dolz
inputs:
- token: polygon-wlth
- token: polygon-dolz
vault-id: 0x6049f8ee79b82dd5bc82b368114bb0a69f34d539b04b43208241e1f68da134a8
outputs:
- token: polygon-usdt
vault-id: 0x6049f8ee79b82dd5bc82b368114bb0a69f34d539b04b43208241e1f68da134a8

scenarios:
streaming-dca:
network: base-community
deployer: base-community
orderbook: base-community
network: polygon-dolz
deployer: polygon-dolz
orderbook: polygon-dolz
bindings:
# Ask for now, registry in future.
uniswap-words: 0xbc609623F5020f6Fc7481024862cD5EE3FFf52D7
Expand All @@ -81,17 +74,17 @@ scenarios:
uniswap-v3-init-code: '[uniswap-v3-init-code]'

scenarios:
sell-wlth:
sell-dolz:
bindings:
# Input and Output token addresses are from perspective of order.
input-token-address: 0xc2132D05D31c914a87C6611C10748AEb04B58e8F
output-token-address: 0x6ab4E20f36ca48B61ECd66c0450fDf665Fa130be

# If the order's input-output tokens are NOT paired on the uniswap v3 pool,
# then the reserve token address is the address of the token which is paired with order's output token on uniswapv3 pool.
# Eg: If WLTH is paired with WETH on the uniswap v3 pool for a USDT-WLTH order, reserve token address is the WETH address.
# Eg: If DOLZ is paired with WETH on the uniswap v3 pool for a USDT-DOLZ order, reserve token address is the WETH address.
# If the order's input-output tokens are paired on the uniswap v3 pool, then reserve token address is same as the input token address.
# Eg: For WLTH/USDT pair where USDT is also the order's input token, reserve token address is same as the input token address.
# Eg: For DOLZ/USDT pair where USDT is also the order's input token, reserve token address is same as the input token address.
reserve-token-address: 0xc2132D05D31c914a87C6611C10748AEb04B58e8F

# Ratio multiplier for calculating the io-ratio.
Expand Down Expand Up @@ -135,7 +128,7 @@ scenarios:
prod:
bindings:
# Minimum input/output token ratio accepatble for the order.
# Eg: For sell WLTH, min-ratio is the minimum USDT/WLTH value to sell above.
# Eg: For sell DOLZ, min-ratio is the minimum USDT/DOLZ value to sell above.
min-ratio: 0.005
plottables: '''plottables-prod'
get-last-time: '''get-last-time-prod'
Expand All @@ -154,17 +147,17 @@ scenarios:
get-last-time: '''get-last-time-prod'
ensure-ratio: '''ensure-ratio-prod'

buy-wlth:
buy-dolz:
bindings:
# Input and Output token addresses from perspective of order
input-token-address: 0x6ab4E20f36ca48B61ECd66c0450fDf665Fa130be
output-token-address: 0xc2132D05D31c914a87C6611C10748AEb04B58e8F

# If the order's input-output tokens are NOT paired on the uniswap v3 pool,
# then the reserve token address is the address of the token which is paired with order's output token on uniswapv3 pool.
# Eg: If WLTH is paired with WETH on the uniswap v3 pool for a USDT-WLTH order, reserve token address is the WETH address.
# Eg: If DOLZ is paired with WETH on the uniswap v3 pool for a USDT-DOLZ order, reserve token address is the WETH address.
# If the order's input-output tokens are paired on the uniswap v3 pool, then reserve token address is same as the input token address.
# Eg: For WLTH/USDT pair where USDT is also the order's input token, reserve token address is same as the input token address.
# Eg: For DOLZ/USDT pair where USDT is also the order's input token, reserve token address is same as the input token address.
reserve-token-address: 0x6ab4E20f36ca48B61ECd66c0450fDf665Fa130be

# Ratio multiplier for calculating the io-ratio.
Expand Down Expand Up @@ -208,7 +201,7 @@ scenarios:
prod:
bindings:
# Minimum input/output token ratio
# Eg: For buy WLTH, min-ratio is the minimum WLTH/USDT value to buy above.
# Eg: For buy DOLZ, min-ratio is the minimum DOLZ/USDT value to buy above.
min-ratio: 70
plottables: '''plottables-prod'
get-last-time: '''get-last-time-prod'
Expand All @@ -229,17 +222,17 @@ scenarios:

charts:
sell-streaming-dca:
scenario: streaming-dca.sell-wlth.chart
scenario: streaming-dca.sell-dolz.chart
metrics:
- label: WLTH Per second rate
- label: DOLZ Per second rate
value: 0.6.0
description: Amount of WLTH tokens sold per second.
- label: WLTH sold per hour
description: Amount of DOLZ tokens sold per second.
- label: DOLZ sold per hour
value: 0.6.1
description: Amount of WLTH tokens sold per hour.
- label: WLTH sold per day
description: Amount of DOLZ tokens sold per hour.
- label: DOLZ sold per day
value: 0.6.2
description: Amount of WLTH tokens sold per day.
description: Amount of DOLZ tokens sold per day.
- label: Minimum bounty
value: 0.6.3
description: Minimum bounty offered in USDT tokens.
Expand All @@ -258,9 +251,9 @@ charts:
value: 0.6.8

sell-dca-simulation:
scenario: streaming-dca.sell-wlth.chart
scenario: streaming-dca.sell-dolz.chart
plots:
Number of WLTH tokens sold vs time difference:
Number of DOLZ tokens sold vs time difference:
marks:
- type: line
options:
Expand All @@ -274,7 +267,7 @@ charts:
y: 0.4

buy-streaming-dca:
scenario: streaming-dca.buy-wlth.chart
scenario: streaming-dca.buy-dolz.chart
metrics:
- label: USDT Per second rate
value: 0.6.0
Expand All @@ -287,10 +280,10 @@ charts:
description: Amount of USDT tokens sold per day.
- label: Minimum bounty
value: 0.6.3
description: Minimum bounty offered in WLTH tokens.
description: Minimum bounty offered in DOLZ tokens.
- label: Maximum bounty
value: 0.6.4
description: Maximum bounty offered in WLTH tokens.
description: Maximum bounty offered in DOLZ tokens.
- label: Bounty auction start
value: 0.6.5
description: Number of seconds after which the bounty auction strats after order evals.
Expand All @@ -303,7 +296,7 @@ charts:
value: 0.6.8

buy-dca-simulation:
scenario: streaming-dca.buy-wlth.chart
scenario: streaming-dca.buy-dolz.chart
plots:
Number of USDT tokens sold vs time difference:
marks:
Expand All @@ -320,12 +313,12 @@ charts:


deployments:
base-wlth-dca:
scenario: streaming-dca.sell-wlth.prod
order: polygon-wlth-sell
base-usdc-dca:
scenario: streaming-dca.buy-wlth.prod
order: polygon-wlth-buy
dolz-dca:
scenario: streaming-dca.sell-dolz.prod
order: polygon-dolz-sell
usdt-dca:
scenario: streaming-dca.buy-dolz.prod
order: polygon-dolz-buy
---
#input-token-address !Order input token address.
#output-token-address !Order output token address.
Expand Down Expand Up @@ -445,4 +438,4 @@ deployments:
:call<'plottables>();

#handle-io
:;
:;
Loading

0 comments on commit 8a6d1e4

Please sign in to comment.