Rename to autoWithdrawMaxFeeTotal
This commit is contained in:
parent
d06f89d707
commit
c97ce2627b
|
@ -650,7 +650,7 @@ async function upsertWallet (
|
|||
const {
|
||||
autoWithdrawThreshold,
|
||||
autoWithdrawMaxFeePercent,
|
||||
autoWithdrawMaxBaseFee,
|
||||
autoWithdrawMaxFeeTotal,
|
||||
enabled,
|
||||
priority
|
||||
} = settings
|
||||
|
@ -661,7 +661,7 @@ async function upsertWallet (
|
|||
data: {
|
||||
autoWithdrawMaxFeePercent,
|
||||
autoWithdrawThreshold,
|
||||
autoWithdrawMaxBaseFee
|
||||
autoWithdrawMaxFeeTotal
|
||||
}
|
||||
})
|
||||
]
|
||||
|
|
|
@ -182,7 +182,7 @@ export default gql`
|
|||
withdrawMaxFeeDefault: Int!
|
||||
autoWithdrawThreshold: Int
|
||||
autoWithdrawMaxFeePercent: Float
|
||||
autoWithdrawMaxBaseFee: Int
|
||||
autoWithdrawMaxFeeTotal: Int
|
||||
}
|
||||
|
||||
type UserOptional {
|
||||
|
|
|
@ -91,7 +91,7 @@ const typeDefs = `
|
|||
input AutowithdrawSettings {
|
||||
autoWithdrawThreshold: Int!
|
||||
autoWithdrawMaxFeePercent: Float!
|
||||
autoWithdrawMaxBaseFee: Int!
|
||||
autoWithdrawMaxFeeTotal: Int!
|
||||
priority: Int
|
||||
enabled: Boolean
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ export function autowithdrawInitial ({ me }) {
|
|||
return {
|
||||
autoWithdrawThreshold: autoWithdrawThreshold({ me }),
|
||||
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
|
||||
label='max fee total'
|
||||
name='autoWithdrawMaxBaseFee'
|
||||
name='autoWithdrawMaxFeeTotal'
|
||||
hint='max fee for any withdrawal amount'
|
||||
append={<InputGroup.Text className='text-monospace'>sats</InputGroup.Text>}
|
||||
required
|
||||
|
|
|
@ -27,7 +27,7 @@ ${STREAK_FIELDS}
|
|||
noReferralLinks
|
||||
fiatCurrency
|
||||
autoWithdrawMaxFeePercent
|
||||
autoWithdrawMaxBaseFee
|
||||
autoWithdrawMaxFeeTotal
|
||||
autoWithdrawThreshold
|
||||
withdrawMaxFeeDefault
|
||||
satsFilter
|
||||
|
|
|
@ -367,7 +367,7 @@ export const autowithdrawSchemaMembers = {
|
|||
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))}`),
|
||||
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({
|
||||
|
|
|
@ -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;
|
|
@ -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;
|
|
@ -118,7 +118,7 @@ model User {
|
|||
lnAddr String?
|
||||
autoWithdrawMaxFeePercent Float?
|
||||
autoWithdrawThreshold Int?
|
||||
autoWithdrawMaxBaseFee Int?
|
||||
autoWithdrawMaxFeeTotal Int?
|
||||
muters Mute[] @relation("muter")
|
||||
muteds Mute[] @relation("muted")
|
||||
ArcOut Arc[] @relation("fromUser")
|
||||
|
|
|
@ -296,7 +296,7 @@ function useServerConfig (wallet) {
|
|||
const saveConfig = useCallback(async ({
|
||||
autoWithdrawThreshold,
|
||||
autoWithdrawMaxFeePercent,
|
||||
autoWithdrawMaxBaseFee,
|
||||
autoWithdrawMaxFeeTotal,
|
||||
priority,
|
||||
enabled,
|
||||
...config
|
||||
|
@ -311,7 +311,7 @@ function useServerConfig (wallet) {
|
|||
settings: {
|
||||
autoWithdrawThreshold: Number(autoWithdrawThreshold),
|
||||
autoWithdrawMaxFeePercent: Number(autoWithdrawMaxFeePercent),
|
||||
autoWithdrawMaxBaseFee: Number(autoWithdrawMaxBaseFee),
|
||||
autoWithdrawMaxFeeTotal: Number(autoWithdrawMaxFeeTotal),
|
||||
priority,
|
||||
enabled
|
||||
},
|
||||
|
|
|
@ -7,7 +7,7 @@ export async function autoWithdraw ({ data: { id }, models, lnd }) {
|
|||
if (
|
||||
user.autoWithdrawThreshold === null ||
|
||||
user.autoWithdrawMaxFeePercent === null ||
|
||||
user.autoWithdrawMaxBaseFee === null) return
|
||||
user.autoWithdrawMaxFeeTotal === null) return
|
||||
|
||||
const threshold = satsToMsats(user.autoWithdrawThreshold)
|
||||
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
|
||||
const maxFeeMsats = msatsSatsFloor(Math.max(
|
||||
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
|
||||
const msats = BigInt(excess) - maxFeeMsats
|
||||
|
|
Loading…
Reference in New Issue