Skip to content

Commit 6c16b3d

Browse files
feat: flrp validators and delegator
TICKET: WIN-7084
1 parent 4cbc0e5 commit 6c16b3d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

modules/sdk-coin-flrp/src/lib/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ export const MINIMUM_FEE = '1000000'; // 1M nanoFLR minimum fee
3030

3131
// Validator constants
3232
export const MIN_DELEGATION_FEE_BASIS_POINTS = 20000; // 2% minimum delegation fee
33+
export const BASIS_POINTS_DIVISOR = 10000; // Divisor to convert basis points to decimal
34+
export const PERCENTAGE_MULTIPLIER = 100; // Multiplier to convert decimal to percentage
3335

3436
// Transaction ID prefix
3537
export const TRANSACTION_ID_PREFIX = 'flare-atomic-tx-'; // Prefix for transaction IDs

modules/sdk-coin-flrp/src/lib/permissionlessValidatorTxBuilder.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import { Tx } from './iface';
55
import { TransactionWithExtensions } from './types';
66
import {
77
ADD_PERMISSIONLESS_VALIDATOR_TYPE,
8+
BASIS_POINTS_DIVISOR,
89
BLS_PUBLIC_KEY_COMPRESSED_LENGTH,
910
BLS_PUBLIC_KEY_UNCOMPRESSED_LENGTH,
1011
BLS_SIGNATURE_LENGTH,
1112
MIN_DELEGATION_FEE_BASIS_POINTS,
13+
PERCENTAGE_MULTIPLIER,
1214
} from './constants';
1315
import { createHexRegex } from './utils';
1416

@@ -162,9 +164,12 @@ export class PermissionlessValidatorTxBuilder extends AtomicTransactionBuilder {
162164
*/
163165
validateDelegationFeeRate(delegationFeeRate: number): void {
164166
// For Flare, use a minimum delegation fee of 2% (20000 basis points)
165-
const minDelegationFee = MIN_DELEGATION_FEE_BASIS_POINTS; // 2%
167+
const minDelegationFee = MIN_DELEGATION_FEE_BASIS_POINTS;
166168
if (delegationFeeRate < minDelegationFee) {
167-
throw new BuildTransactionError(`Delegation fee cannot be less than ${minDelegationFee} basis points (2%)`);
169+
const minDelegationFeePercent = (minDelegationFee / BASIS_POINTS_DIVISOR) * PERCENTAGE_MULTIPLIER;
170+
throw new BuildTransactionError(
171+
`Delegation fee cannot be less than ${minDelegationFee} basis points (${minDelegationFeePercent}%)`
172+
);
168173
}
169174
}
170175

0 commit comments

Comments
 (0)