2022-08-30 18:49:16 +00:00
|
|
|
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;
|
2022-08-30 18:49:16 +00:00
|
|
|
}
|
|
|
|
|
2023-05-09 00:37:23 +00:00
|
|
|
export type LimitList = Record<string, Limit>;
|
2022-08-30 18:49:16 +00:00
|
|
|
|
2023-10-27 10:01:59 +00:00
|
|
|
export const compareUpdateLimit = (baseL: Limit, newL: Limit): Limit => {
|
2024-03-14 11:55:42 +00:00
|
|
|
if (!baseL) {
|
2023-10-27 10:01:59 +00:00
|
|
|
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;
|