Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

add oracle.bot.ts 33% drastic random price moment to allow HALTED state #287

Merged
merged 1 commit into from
Nov 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/module.playground/bot/oracle.bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ const PriceDirectionFunctions: Record<PriceDirection, PriceDirectionFunction> =
return price.minus(price.times(priceChange))
},
[PriceDirection.RANDOM]: (price: BigNumber, priceChange: BigNumber) => {
return BigNumber.random().gt(0.5)
? price.plus(priceChange)
: BigNumber.max(price.minus(priceChange), 1)
const change = price.times(priceChange)
if (BigNumber.random().gt(0.5)) {
return price.plus(change)
} else {
return price.minus(change)
}
},
[PriceDirection.STABLE]: (price: BigNumber, priceChange: BigNumber) => {
return price
Expand Down Expand Up @@ -87,13 +90,13 @@ export class OracleBot {
{
token: 'CR50',
amount: new BigNumber(5000),
change: new BigNumber(50),
change: new BigNumber(0.33),
direction: PriceDirection.RANDOM
},
{
token: 'TR50',
amount: new BigNumber(5000),
change: new BigNumber(50),
change: new BigNumber(0.33),
direction: PriceDirection.RANDOM
},
{
Expand Down