Skip to content
This repository has been archived by the owner on Nov 29, 2024. It is now read-only.

Commit

Permalink
simplifying
Browse files Browse the repository at this point in the history
  • Loading branch information
thedavidmeister committed Mar 7, 2024
1 parent 328d447 commit f664523
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/trend-trader.rain
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
#tkn-address !The address of TKN to be tracking the price of.
#tkn-decimals !The decimals of TKN to be tracking the price of.
#reserve-address !The address of the reserve token to be tracking price against.
#reserve-decimals !The decimals of the reserve token to be tracking price against.
#mean-cooldown !The mean cooldown time in seconds.
#bounty !The bounty to offer for the trade as normalized 18 decimal reserve amount.
Expand Down Expand Up @@ -69,10 +66,7 @@
#trend-down-factor !The factor to multiply the trend with when the trend is down as normalized 18 decimals.
#calculate-reserve
last-time now: call<times>,
:call<'ensure-cooldown>(
last-time
now
),
:call<'ensure-cooldown>(last-time now),
random-multiplier18: call<'jittery-binomial>(last-time),
jittered-amount-reserve18: decimal18-mul(
decimal18-mul(mean-reserve-amount18 2e18)
Expand All @@ -90,7 +84,7 @@
#sell-calculate-io
trend-ratio _ amount-reserve18 amount-reserve: call<'calculate-reserve>(),
tkn-amount18 last-price-timestamp: uniswap-v2-quote-exact-output<1>(
tkn-address reserve-address amount-reserve
output-token() input-token() amount-reserve
),
:ensure(less-than(last-price-timestamp now) "Sell price change."),
order-output-max18: tkn-amount18,
Expand All @@ -99,7 +93,7 @@
#buy-calculate-io
trend-ratio _ amount-reserve18 amount-reserve: call<'calculate-reserve>(),
tkn-amount18 last-price-timestamp: uniswap-v2-quote-exact-input<1>(
reserve-address tkn-address amount-reserve
output-token() input-token() amount-reserve
),
:ensure(less-than(last-price-timestamp now) "Buy price change."),
order-output-max18: decimal18-add(amount-reserve18 bounty),
Expand Down

0 comments on commit f664523

Please sign in to comment.