diff --git a/strategies/wlth/limit-order-single.rain b/strategies/wlth/limit-order-single.rain deleted file mode 100644 index ed3a963..0000000 --- a/strategies/wlth/limit-order-single.rain +++ /dev/null @@ -1,183 +0,0 @@ -# Limit Order Strategy -# 1 buy and sell target -# Set buy price and amount and sell price and amount -# 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% - -networks: - base: - rpc: https://mainnet.base.org - chain-id: 8453 - network-id: 8453 - currency: ETH - -subgraphs: - base: https://api.thegraph.com/subgraphs/name/h20liquidity/base-0x2aee87 - -orderbooks: - base: - address: 0x2AeE87D75CD000583DAEC7A28db103B1c0c18b76 - network: base - subgraph: base - -deployers: - base: - address: 0xfca89cD12Ba1346b1ac570ed988AB43b812733fe - network: base - -tokens: - base-wlth: - network: base - address: 0x99b2B1A2aDB02B38222ADcD057783D7e5D1FCC7D - base-usdc: - network: base - address: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 - -orders: - base-wlth-sell: - orderbook: base - inputs: - - token: base-usdc - vault-id: - outputs: - - token: base-wlth - vault-id: - base-wlth-buy: - orderbook: base - inputs: - - token: base-wlth - vault-id: - outputs: - - token: base-usdc - vault-id: - -scenarios: - limit-order: - network: base - deployer: base - orderbook: base - bindings: - # Ask for now, registry in future. - uniswap-words: 0xbc609623F5020f6Fc7481024862cD5EE3FFf52D7 - orderbook-subparser: 0x8f037f2a3fF2dee510486D9C63A47A245991a4C1 - - scenarios: - buy: - bindings: - # io-ratio is calculated as 1 divided by the token price - # So 1/(WLTH priced in USDC) - io-ratio-1: 100 - - # amount is the trade size - ouptut-amount-1: 100 - - scenarios: - prod: - bindings: - plottables: '''plottables-prod' - chart: - runs: 1 - bindings: - plottables: '''plottables-plot' - sell: - bindings: - # io-ratio is calculated as 1 divided by the token price - # So USDC priced in WLTH - io-ratio-1: 100 - - # amount is the trade size - ouptut-amount-1: 100 - - scenarios: - prod: - bindings: - plottables: '''plottables-prod' - chart: - runs: 1 - bindings: - plottables: '''plottables-plot' - -charts: - base-wlth-buy-metrics: - scenario: limit-order.buy.metric - metrics: - - label: io-ratio-1 - value: 0.3.0 - - label: amount-1 - value: 0.3.1 - - base-wlth-sell-metrics: - scenario: limit-order.sell.metric - metrics: - - label: io-ratio-1 - value: 0.3.0 - - label: amount-1 - value: 0.3.1 - -deployments: - base-wlth-buy: - scenario: limit-order.buy.prod - order: base-wlth-buy - base-wlth-sell: - scenario: limit-order.sell.prod - order: base-wlth-sell - ---- -#uniswap-words !The subparser for the Uniswap words -#orderbook-subparser !The subparser for the Orderbook words - -#io-ratio-1 !IO ratio for first order. -#ouptut-amount-1 !Output amount for first order. - -#count-key "count-key" -#plottables !Binding to plot values. - -#plottables-prod - :; - -#plottables-plot - _: io-ratio-1, - _: ouptut-amount-1, - -#calculate-io - using-words-from uniswap-words orderbook-subparser - - trade-count-key: hash(order-hash() count-key), - trade-count: get(trade-count-key), - _ _:call<'get-ratio-amount>(trade-count), - :call<'plottables>(); - -#handle-io - trade-count-key: hash(order-hash() count-key), - trade-count: get(trade-count-key), - :set(trade-count-key add(trade-count 1)); - -#get-ratio-amount - trade-count: , - output-amount: if(equal-to(trade-count 0) - ouptut-amount-1 - if(equal-to(trade-count 1) - ouptut-amount-2 - if(equal-to(trade-count 2) - ouptut-amount-3 - 1 - ) - ) - ), - io-ratio: if(equal-to(trade-count 0) - io-ratio-1 - if(equal-to(trade-count 1) - io-ratio-2 - if(equal-to(trade-count 2) - io-ratio-3 - max-value() - ) - ) - ); - diff --git a/strategies/wlth/wlth-limit-order-single.rain b/strategies/wlth/wlth-limit-order-single.rain new file mode 100644 index 0000000..fe54a0a --- /dev/null +++ b/strategies/wlth/wlth-limit-order-single.rain @@ -0,0 +1,185 @@ +# Limit Order Strategy +# 5 buy and sell targets +# Each target you set buy price and amount and sell price and amount +# 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% + +networks: + base-community: + rpc: https://rpc.ankr.com/base/8e4cac5728d95471ae55724953c7ae6f19a227ac05146276f09717692b732dae + chain-id: 8453 + network-id: 8453 + currency: ETH + +subgraphs: + base-community: https://api.thegraph.com/subgraphs/name/h20liquidity/base-0x2aee87 + +orderbooks: + base-community: + address: 0x2AeE87D75CD000583DAEC7A28db103B1c0c18b76 + network: base-community + subgraph: base-community + +deployers: + base-community: + address: 0x56394785a22b3BE25470a0e03eD9E0a939C47b9b + network: base-community + +tokens: + base-wlth: + network: base-community + address: 0x99b2B1A2aDB02B38222ADcD057783D7e5D1FCC7D + base-usdc: + network: base-community + address: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 + +orders: + # vault-id generated with `openssl rand -hex 32` + base-wlth-sell: + orderbook: base-community + inputs: + - token: base-usdc + vault-id: 0xbc203ee43d814ca260b6400b46f2a3362e6bb0306291ced89ba06856626cc548 + outputs: + - token: base-wlth + vault-id: 0xbc203ee43d814ca260b6400b46f2a3362e6bb0306291ced89ba06856626cc548 + base-wlth-buy: + orderbook: base-community + inputs: + - token: base-wlth + vault-id: 0xaa376e00ebecd7042fccde4feb69390a78001ecea37352f1dab8b3d9023f54f7 + outputs: + - token: base-usdc + vault-id: 0xaa376e00ebecd7042fccde4feb69390a78001ecea37352f1dab8b3d9023f54f7 + +scenarios: + limit-orders: + network: base-community + deployer: base-community + orderbook: base-community + bindings: + # Ask for now, registry in future. + uniswap-words: 0xD6B34F97d4A8Cb38D0544dB241CB3f335866f490 + orderbook-subparser: 0x8D96ea3EF24D7123882c51CE4325b89bc0d63f9e + scenarios: + buy: + bindings: + # io-ratio and amount for first order. + io-ratio-1: 35 + ouptut-amount-1: 1 + scenarios: + prod: + bindings: + plottables: '''plottables-prod' + get-trade-count: '''get-trade-count-prod' + metric: + runs: 1 + bindings: + plottables: '''plottables-metric' + get-trade-count: '''get-trade-count-prod' + sell: + bindings: + # io-ratio and amount for first order. + io-ratio-1: 0.02 + ouptut-amount-1: 50 + scenarios: + prod: + bindings: + plottables: '''plottables-prod' + get-trade-count: '''get-trade-count-prod' + metric: + runs: 1 + bindings: + plottables: '''plottables-metric' + get-trade-count: '''get-trade-count-prod' + + +charts: + base-wlth-buy-metrics: + scenario: limit-orders.buy.metric + metrics: + - label: io-ratio-1 + value: 0.3.2 + - label: amount-1 + value: 0.3.3 + + base-wlth-sell-metrics: + scenario: limit-orders.sell.metric + metrics: + - label: io-ratio-1 + value: 0.3.2 + - label: amount-1 + value: 0.3.3 + +deployments: + base-wlth-buy: + scenario: limit-orders.buy.prod + order: base-wlth-buy + base-wlth-sell: + scenario: limit-orders.sell.prod + order: base-wlth-sell +--- +#uniswap-words !The subparser for the Uniswap words +#orderbook-subparser !The subparser for the Orderbook words + +#io-ratio-1 !IO ratio for first order. +#ouptut-amount-1 !Output amount for first order. + +#io-ratio-2 !IO ratio for second order. +#ouptut-amount-2 !Output amount for second order. + +#io-ratio-3 !IO ratio for third order. +#ouptut-amount-3 !Output amount for third order. + +#io-ratio-4 !IO ratio for fourth order. +#ouptut-amount-4 !Output amount for fourth order. + +#io-ratio-5 !IO ratio for fifth order. +#ouptut-amount-5 !Output amount for fifth order. + +#count-key "count-key" +#plottables !Binding to plot values. +#get-trade-count !Binding to get trade count. +#test-trade-count !Test trade count for plotting. + +#plottables-prod + _ _: ; + +#plottables-metric + amount io-ratio: , + _: io-ratio-1, + _: ouptut-amount-1; + +#get-trade-count-prod + trade-count-key: hash(order-hash() count-key), + trade-count: get(trade-count-key); + +#get-ratio-amount + trade-count: call<'get-trade-count>(), + ouput-amount: conditions( + equal-to(trade-count 0) ouptut-amount-1 + "Max order count" + ), + io-ratio: conditions( + equal-to(trade-count 0) io-ratio-1 + "Max order count" + ); + +#calculate-io + using-words-from uniswap-words orderbook-subparser + + trade-count + final-amount + final-ratio: call<'get-ratio-amount>(), + :call<'plottables>(final-amount final-ratio); + +#handle-io + trade-count-key: hash(order-hash() count-key), + trade-count: get(trade-count-key), + :set(trade-count-key add(trade-count 1)); \ No newline at end of file