robosats/frontend/src/models/Limit.model.ts

24 lines
697 B
TypeScript
Raw Normal View History

export interface Limit {
2022-09-09 17:18:04 +00:00
code: string;
price: number;
min_amount: number;
max_amount: number;
max_bondless_amount: number;
}
export type LimitList = Record<string, Limit>;
export const compareUpdateLimit = (baseL: Limit, newL: Limit): Limit => {
2024-03-14 11:55:42 +00:00
if (!baseL) {
return newL;
} else {
const price = (baseL.price + newL.price) / 2;
const max_amount = Math.max(baseL.max_amount, newL.max_amount);
const min_amount = Math.min(baseL.min_amount, newL.min_amount);
const max_bondless_amount = Math.max(baseL.max_bondless_amount, newL.max_bondless_amount);
return { code: newL.code, price, max_amount, min_amount, max_bondless_amount };
}
};
2022-09-09 17:18:04 +00:00
export default Limit;