Skip to content

Commit

Permalink
bug: remove belief_price for now
Browse files Browse the repository at this point in the history
  • Loading branch information
SirTLB committed Sep 4, 2023
1 parent 53fd6a4 commit 52d8988
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
7 changes: 3 additions & 4 deletions src/chains/defaults/messages/getSwapMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { MsgExecuteContract } from "cosmjs-types/cosmwasm/wasm/v1/tx";

import { Asset, isNativeAsset } from "../../../core/types/base/asset";
import { Pool } from "../../../core/types/base/pool";
import { DefaultSwapMessage } from "../../../core/types/messages/swapmessages";

/**
*
Expand All @@ -14,13 +13,13 @@ export function getSwapMessage(
offerAsset: Asset,
walletAddress: string,
beliefPrice: string,
maxSpread = 0.05,
maxSpread = 0.005,
) {
const msg: DefaultSwapMessage = {
const msg = {
swap: {
max_spread: String(maxSpread),
offer_asset: offerAsset,
belief_price: beliefPrice,
// belief_price: beliefPrice,
},
};
const encodedMsgObject: EncodeObject = {
Expand Down
29 changes: 15 additions & 14 deletions src/chains/inj/messages/getOrderbookArbMessage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { EncodeObject } from "@cosmjs/proto-signing";
import { BigNumberInBase } from "@injectivelabs/utils/dist/cjs/classes";

import { OptimalOrderbookTrade } from "../../../core/arbitrage/optimizers/orderbookOptimizer";
import { toChainAsset, toChainPrice } from "../../../core/types/base/asset";
Expand Down Expand Up @@ -38,21 +37,23 @@ export function getOrderbookArbMessages(
};
const msg0 = getMarketSpotOrderMessage(arbTrade, publicAddress, offerAsset1, 1);

const decimals = arbTrade.path.orderbook.baseAssetDecimals - arbTrade.path.orderbook.quoteAssetDecimals;

let orderSize = +new BigNumberInBase(arbTrade.outGivenIn).toWei(decimals).toFixed();

const belief_price = String(
Math.round((orderSize / arbTrade.outGivenIn) * 100000 * (10 ^ decimals)) / 100000 / (10 ^ decimals),
const [outGivenIn1, outInfo1] = outGivenIn(arbTrade.path.pool, {
amount: String(arbTrade.outGivenIn),
info: offerAsset1.info,
});

const belief_price = toChainPrice(
{
amount: String(arbTrade.outGivenIn),
info: offerAsset1.info,
},
{ amount: String(outGivenIn1), info: outInfo1 },
);
orderSize =
Math.floor(orderSize / arbTrade.path.orderbook.minQuantityIncrement) *
arbTrade.path.orderbook.minQuantityIncrement;

const offerAsset = {
amount: String(orderSize),
const offerAsset = toChainAsset({
amount: String(arbTrade.outGivenIn),
info: offerAsset1.info,
};
});

const msg1 = getSwapMessage(arbTrade.path.pool, offerAsset, publicAddress, belief_price);

return [[msg0, msg1], 2];
Expand Down

0 comments on commit 52d8988

Please sign in to comment.