Skip to content

Commit

Permalink
chore: change average price calculation approach (#87)
Browse files Browse the repository at this point in the history
* chore: change average price calculation approach

* chore: update version

* chore: add recipient for dca created event

* chore: update version

---------

Co-authored-by: collin <[email protected]>
Co-authored-by: collin-aftermath <[email protected]>
  • Loading branch information
3 people authored Sep 30, 2024
1 parent 5172db2 commit f897d59
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions src/packages/dca/api/dcaApiCasting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class DcaApiCasting {
timestamp: eventOnChain.timestampMs,
txnDigest: eventOnChain.id.txDigest,
type: eventOnChain.type,
recipient: Helpers.addLeadingZeroesToType(fields.recipient),
};
};

Expand Down Expand Up @@ -176,10 +177,6 @@ export class DcaApiCasting {
coin: outputCoinType,
amount: totalBought,
},
averagePrice:
tradesPrepared.length > 0
? totalBought / BigInt(tradesPrepared.length)
: BigInt(0),
totalSpent: totalSpent,
intervalMs: Number(response.frequency_ms),
totalTrades: totalOrdersAmount,
Expand Down
2 changes: 1 addition & 1 deletion src/packages/dca/dcaTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export interface DcaOrderOverviewObject {
coin: CoinType;
amount: Balance;
};
averagePrice: Balance;
totalSpent: Balance;
intervalMs: Timestamp;
totalTrades: number;
Expand Down Expand Up @@ -125,6 +124,7 @@ export interface DcaCreatedOrderEvent extends Event {
minAmountOut: Balance;
maxAmountOut: Balance;
remainingTrades: bigint;
recipient: SuiAddress;
}

export interface DcaClosedOrderEvent extends Event {
Expand Down

0 comments on commit f897d59

Please sign in to comment.