Adjusted bid selection and improve UX.

This commit is contained in:
Filipe Soccol
2024-11-07 17:53:20 -03:00
parent b487949482
commit 5b49fdcffd
11 changed files with 178 additions and 158 deletions

View File

@@ -4,20 +4,41 @@ const verifyNetworkLiquidity = (
tokenValue: number,
walletAddress: string,
validDepositList: ValidDeposit[]
): ValidDeposit | undefined => {
const element = validDepositList.find((element) => {
const remaining = element.remaining;
if (
tokenValue!! <= remaining &&
tokenValue!! != 0 &&
element.seller !== walletAddress
) {
return true;
}
return false;
});
): ValidDeposit[] => {
const filteredDepositList = validDepositList
.filter((element) => {
const remaining = element.remaining;
if (
tokenValue!! <= remaining &&
tokenValue!! != 0 &&
element.seller !== walletAddress
) {
return true;
}
return false;
})
.sort((a, b) => {
return b.remaining - a.remaining;
});
return element;
const uniqueNetworkDeposits = filteredDepositList.reduce(
(acc: ValidDeposit[], current) => {
const existingNetwork = acc.find(
(deposit) => deposit.network === current.network
);
if (!existingNetwork) {
acc.push(current);
}
return acc;
},
[]
);
console.log(
"uniqueNetworkDeposits",
JSON.stringify(uniqueNetworkDeposits, null, 2)
);
return uniqueNetworkDeposits;
};
export { verifyNetworkLiquidity };