Skip to content

Commit

Permalink
remove unuse params
Browse files Browse the repository at this point in the history
  • Loading branch information
lehieuhust committed Aug 21, 2023
1 parent e5e8c55 commit bd5764c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 40 deletions.
5 changes: 1 addition & 4 deletions packages/market-maker/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,12 @@ const totalOrders = 5;
const orderConfig: MakeOrderConfig = {
cancelPercentage,
buyPercentage,
spreadMax,
spreadMin,
sellDepth,
buyDepth,
oraiThreshold,
usdtThreshold,
spreadMatch,
spreadCancel,
totalOrders
spreadCancel
};
const [orderIntervalMin, orderIntervalMax] = process.env.ORDER_INTERVAL_RANGE
? process.env.ORDER_INTERVAL_RANGE.split(",").map(Number)
Expand Down
37 changes: 1 addition & 36 deletions packages/market-maker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,20 @@ import { ExecuteInstruction } from '@cosmjs/cosmwasm-stargate';

export type MakeOrderConfig = {
makeProfit?: boolean;
spreadMin: number;
spreadMax: number;
buyPercentage: number;
cancelPercentage: number;
sellDepth: number;
buyDepth: number;
oraiThreshold: number;
usdtThreshold: number;
spreadMatch: number;
spreadCancel: number,
totalOrders: number;
spreadCancel: number;
};

const getRandomSpread = (min: number, max: number) => {
return getRandomRange(min * atomic, max * atomic) / atomic;
};

const generateOrderMsg = (oraiPrice: number, usdtContractAddress: Addr, { spreadMin, spreadMax, buyPercentage, totalOrders, sellDepth, buyDepth, makeProfit }: MakeOrderConfig): OraiswapLimitOrderTypes.ExecuteMsg => {
const spread = getRandomSpread(spreadMin, spreadMax);
// buy percentage is 55%
const direction: OrderDirection = getRandomPercentage() < buyPercentage * 100 ? 'buy' : 'sell';
// if make profit then buy lower, sell higher than market
const oraiPriceEntry = getSpreadPrice(oraiPrice, spread * (direction === 'buy' ? 1 : -1) * (makeProfit ? -1 : 1));

const totalUsdtVolume = sellDepth + buyDepth;
const usdtVolume = Math.round(totalUsdtVolume / totalOrders);
const oraiVolume = Math.round(usdtVolume / oraiPriceEntry);

return {
submit_order: {
assets: [
{
info: {
native_token: { denom: 'orai' }
},
amount: oraiVolume.toString()
},
{
info: {
token: { contract_addr: usdtContractAddress }
},
amount: usdtVolume.toString()
}
],
direction
}
};
};

const generateMatchOrders = async (oraiPrice: number, usdtContractAddress: Addr, orderbookAddress: Addr, sender: UserWallet, spread: number, assetInfos: AssetInfo[], direction: OrderDirection, limit: 10, { buyPercentage, sellDepth, buyDepth }: MakeOrderConfig): Promise<OraiswapLimitOrderTypes.ExecuteMsg[]> => {
const upperPriceLimit = oraiPrice * (1 + spread);
const lowerPriceLimit = oraiPrice * (1 - spread);
Expand Down

0 comments on commit bd5764c

Please sign in to comment.