diff --git a/package.json b/package.json index b92ecb3..54c755a 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "lint": "eslint . --fix --ignore-path .gitignore" }, "dependencies": { + "@isaacs/ttlcache": "^1.4.1", "@mdi/font": "6.9.96", "color": "^4.2.3", "core-js": "^3.29.0", diff --git a/src/blockchain/transaction.js b/src/blockchain/transaction.js index 4fed97a..03d5810 100644 --- a/src/blockchain/transaction.js +++ b/src/blockchain/transaction.js @@ -1,9 +1,9 @@ import {nav, uuid} from "@/misc.js"; -import {newContract, vaultContract} from "@/blockchain/contract.js"; +import {vaultContract} from "@/blockchain/contract.js"; import {ensureVault, provider, switchChain, useWalletStore} from "@/blockchain/wallet.js"; import {toRaw} from "vue"; import {useChartOrderStore} from "@/orderbuild.js"; -import {timestamp} from "@/common.js"; +import {placementFee} from "@/fees.js"; export const TransactionState = { Created: 0, // user requested a transaction @@ -176,29 +176,6 @@ export class PlaceOrderTransaction extends Transaction { } -// todo move to orderlib -async function placementFee(vault, order, window = 300) { - // If the fees are about to change within `window` seconds of now, we send the higher native amount of the two fees. - // If the fees sent are too much, the vault will refund the sender. - const v = await vaultContract(vault, provider) - const feeManagerAddr = await v.feeManager() - const feeManager = await newContract(feeManagerAddr, 'IFeeManager', provider) - const [sched, changeTimestamp] = await Promise.all([feeManager.fees(), feeManager.proposedFeeActivationTime()]) - console.log('sched', order, sched) - // single order placement selector - const placementFeeSelector = 'placementFee((address,address,(uint8,uint24),uint256,uint256,bool,bool,bool,uint64,(uint16,bool,bool,bool,bool,bool,bool,bool,bool,uint16,uint24,uint32,uint32,(uint32,uint32),(uint32,uint32))[]),(uint8,uint8,uint8,uint8,uint8))' - let [orderFee, gasFee] = await v[placementFeeSelector](order, [...sched]) - console.log('placementFee', orderFee, gasFee) - if (Number(changeTimestamp) - timestamp() < window) { - const nextSched = await feeManager.proposedFees() - const [nextOrderFee, nextGasFee] = await v[placementFeeSelector](order, [...nextSched]) - if (nextOrderFee + nextGasFee > orderFee + gasFee) - [orderFee, gasFee] = [nextOrderFee, nextGasFee] - } - return [orderFee, gasFee] -} - - export class CancelOrderTransaction extends Transaction { constructor(chainId, index) { super(chainId, TransactionType.CancelOrder) diff --git a/src/components/chart/DCABuilder.vue b/src/components/chart/DCABuilder.vue index 53b369a..2fae81b 100644 --- a/src/components/chart/DCABuilder.vue +++ b/src/components/chart/DCABuilder.vue @@ -11,6 +11,7 @@