Rename to autoWithdrawMaxFeeTotal

This commit is contained in:
ekzyis 2024-10-19 16:21:50 +02:00
parent d06f89d707
commit c97ce2627b
11 changed files with 21 additions and 21 deletions

View File

@ -650,7 +650,7 @@ async function upsertWallet (
const { const {
autoWithdrawThreshold, autoWithdrawThreshold,
autoWithdrawMaxFeePercent, autoWithdrawMaxFeePercent,
autoWithdrawMaxBaseFee, autoWithdrawMaxFeeTotal,
enabled, enabled,
priority priority
} = settings } = settings
@ -661,7 +661,7 @@ async function upsertWallet (
data: { data: {
autoWithdrawMaxFeePercent, autoWithdrawMaxFeePercent,
autoWithdrawThreshold, autoWithdrawThreshold,
autoWithdrawMaxBaseFee autoWithdrawMaxFeeTotal
} }
}) })
] ]

View File

@ -182,7 +182,7 @@ export default gql`
withdrawMaxFeeDefault: Int! withdrawMaxFeeDefault: Int!
autoWithdrawThreshold: Int autoWithdrawThreshold: Int
autoWithdrawMaxFeePercent: Float autoWithdrawMaxFeePercent: Float
autoWithdrawMaxBaseFee: Int autoWithdrawMaxFeeTotal: Int
} }
type UserOptional { type UserOptional {

View File

@ -91,7 +91,7 @@ const typeDefs = `
input AutowithdrawSettings { input AutowithdrawSettings {
autoWithdrawThreshold: Int! autoWithdrawThreshold: Int!
autoWithdrawMaxFeePercent: Float! autoWithdrawMaxFeePercent: Float!
autoWithdrawMaxBaseFee: Int! autoWithdrawMaxFeeTotal: Int!
priority: Int priority: Int
enabled: Boolean enabled: Boolean
} }

View File

@ -14,7 +14,7 @@ export function autowithdrawInitial ({ me }) {
return { return {
autoWithdrawThreshold: autoWithdrawThreshold({ me }), autoWithdrawThreshold: autoWithdrawThreshold({ me }),
autoWithdrawMaxFeePercent: isNumber(me?.privates?.autoWithdrawMaxFeePercent) ? me?.privates?.autoWithdrawMaxFeePercent : 1, autoWithdrawMaxFeePercent: isNumber(me?.privates?.autoWithdrawMaxFeePercent) ? me?.privates?.autoWithdrawMaxFeePercent : 1,
autoWithdrawMaxBaseFee: isNumber(me?.privates?.autoWithdrawMaxBaseFee) ? me?.privates?.autoWithdrawMaxBaseFee : 1 autoWithdrawMaxFeeTotal: isNumber(me?.privates?.autoWithdrawMaxFeeTotal) ? me?.privates?.autoWithdrawMaxFeeTotal : 1
} }
} }
@ -72,7 +72,7 @@ export function AutowithdrawSettings ({ wallet }) {
/> />
<Input <Input
label='max fee total' label='max fee total'
name='autoWithdrawMaxBaseFee' name='autoWithdrawMaxFeeTotal'
hint='max fee for any withdrawal amount' hint='max fee for any withdrawal amount'
append={<InputGroup.Text className='text-monospace'>sats</InputGroup.Text>} append={<InputGroup.Text className='text-monospace'>sats</InputGroup.Text>}
required required

View File

@ -27,7 +27,7 @@ ${STREAK_FIELDS}
noReferralLinks noReferralLinks
fiatCurrency fiatCurrency
autoWithdrawMaxFeePercent autoWithdrawMaxFeePercent
autoWithdrawMaxBaseFee autoWithdrawMaxFeeTotal
autoWithdrawThreshold autoWithdrawThreshold
withdrawMaxFeeDefault withdrawMaxFeeDefault
satsFilter satsFilter

View File

@ -367,7 +367,7 @@ export const autowithdrawSchemaMembers = {
enabled: boolean(), enabled: boolean(),
autoWithdrawThreshold: intValidator.required('required').min(0, 'must be at least 0').max(msatsToSats(BALANCE_LIMIT_MSATS), `must be at most ${abbrNum(msatsToSats(BALANCE_LIMIT_MSATS))}`), autoWithdrawThreshold: intValidator.required('required').min(0, 'must be at least 0').max(msatsToSats(BALANCE_LIMIT_MSATS), `must be at most ${abbrNum(msatsToSats(BALANCE_LIMIT_MSATS))}`),
autoWithdrawMaxFeePercent: floatValidator.required('required').min(0, 'must be at least 0').max(50, 'must not exceed 50'), autoWithdrawMaxFeePercent: floatValidator.required('required').min(0, 'must be at least 0').max(50, 'must not exceed 50'),
autoWithdrawMaxBaseFee: intValidator.required('required').min(0, 'must be at least 0').max(1_000, 'must not exceed 1000') autoWithdrawMaxFeeTotal: intValidator.required('required').min(0, 'must be at least 0').max(1_000, 'must not exceed 1000')
} }
export const lnAddrAutowithdrawSchema = object({ export const lnAddrAutowithdrawSchema = object({

View File

@ -1,8 +0,0 @@
-- AlterTable
ALTER TABLE "users" ADD COLUMN "autoWithdrawMaxBaseFee" INTEGER;
-- set max_base_fee for users with autowithdrawals enabled to not interfere with them.
-- we set it to 0 instead of 1 because that preserves old behavior.
UPDATE "users"
SET "autoWithdrawMaxBaseFee" = 0
WHERE "autoWithdrawMaxFeePercent" IS NOT NULL;

View File

@ -0,0 +1,8 @@
-- AlterTable
ALTER TABLE "users" ADD COLUMN "autoWithdrawMaxFeeTotal" INTEGER;
-- set max total fee for users with autowithdrawals enabled to not interfere with them.
-- we set it to 0 instead of 1 because that preserves old behavior.
UPDATE "users"
SET "autoWithdrawMaxFeeTotal" = 0
WHERE "autoWithdrawMaxFeePercent" IS NOT NULL;

View File

@ -118,7 +118,7 @@ model User {
lnAddr String? lnAddr String?
autoWithdrawMaxFeePercent Float? autoWithdrawMaxFeePercent Float?
autoWithdrawThreshold Int? autoWithdrawThreshold Int?
autoWithdrawMaxBaseFee Int? autoWithdrawMaxFeeTotal Int?
muters Mute[] @relation("muter") muters Mute[] @relation("muter")
muteds Mute[] @relation("muted") muteds Mute[] @relation("muted")
ArcOut Arc[] @relation("fromUser") ArcOut Arc[] @relation("fromUser")

View File

@ -296,7 +296,7 @@ function useServerConfig (wallet) {
const saveConfig = useCallback(async ({ const saveConfig = useCallback(async ({
autoWithdrawThreshold, autoWithdrawThreshold,
autoWithdrawMaxFeePercent, autoWithdrawMaxFeePercent,
autoWithdrawMaxBaseFee, autoWithdrawMaxFeeTotal,
priority, priority,
enabled, enabled,
...config ...config
@ -311,7 +311,7 @@ function useServerConfig (wallet) {
settings: { settings: {
autoWithdrawThreshold: Number(autoWithdrawThreshold), autoWithdrawThreshold: Number(autoWithdrawThreshold),
autoWithdrawMaxFeePercent: Number(autoWithdrawMaxFeePercent), autoWithdrawMaxFeePercent: Number(autoWithdrawMaxFeePercent),
autoWithdrawMaxBaseFee: Number(autoWithdrawMaxBaseFee), autoWithdrawMaxFeeTotal: Number(autoWithdrawMaxFeeTotal),
priority, priority,
enabled enabled
}, },

View File

@ -7,7 +7,7 @@ export async function autoWithdraw ({ data: { id }, models, lnd }) {
if ( if (
user.autoWithdrawThreshold === null || user.autoWithdrawThreshold === null ||
user.autoWithdrawMaxFeePercent === null || user.autoWithdrawMaxFeePercent === null ||
user.autoWithdrawMaxBaseFee === null) return user.autoWithdrawMaxFeeTotal === null) return
const threshold = satsToMsats(user.autoWithdrawThreshold) const threshold = satsToMsats(user.autoWithdrawThreshold)
const excess = Number(user.msats - threshold) const excess = Number(user.msats - threshold)
@ -18,7 +18,7 @@ export async function autoWithdraw ({ data: { id }, models, lnd }) {
// floor fee to nearest sat but still denominated in msats // floor fee to nearest sat but still denominated in msats
const maxFeeMsats = msatsSatsFloor(Math.max( const maxFeeMsats = msatsSatsFloor(Math.max(
Math.ceil(excess * (user.autoWithdrawMaxFeePercent / 100.0)), Math.ceil(excess * (user.autoWithdrawMaxFeePercent / 100.0)),
Number(satsToMsats(user.autoWithdrawMaxBaseFee)) Number(satsToMsats(user.autoWithdrawMaxFeeTotal))
)) ))
// msats will be floored by createInvoice if it needs to be // msats will be floored by createInvoice if it needs to be
const msats = BigInt(excess) - maxFeeMsats const msats = BigInt(excess) - maxFeeMsats