solana.js: added priorityFees to createFeed methods
This commit is contained in:
parent
b55a594548
commit
87c9092ea0
|
@ -976,10 +976,10 @@ export class AggregatorAccount extends Account<types.AggregatorAccountData> {
|
|||
)
|
||||
)
|
||||
: null,
|
||||
basePriorityFee: params.basePriorityFee ?? 0,
|
||||
priorityFeeBump: params.priorityFeeBump ?? 0,
|
||||
priorityFeeBumpPeriod: params.priorityFeeBumpPeriod ?? 0,
|
||||
maxPriorityFeeMultiplier: params.maxPriorityFeeMultiplier ?? 0,
|
||||
basePriorityFee: params.basePriorityFee ?? null,
|
||||
priorityFeeBump: params.priorityFeeBump ?? null,
|
||||
priorityFeeBumpPeriod: params.priorityFeeBumpPeriod ?? null,
|
||||
maxPriorityFeeMultiplier: params.maxPriorityFeeMultiplier ?? null,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
@ -333,7 +333,7 @@ export class CrankAccount extends Account<types.CrankAccountData> {
|
|||
num?: number,
|
||||
unixTimestamp?: number
|
||||
): Promise<PublicKey[]> {
|
||||
console.log(`unix: ${unixTimestamp}`);
|
||||
|
||||
const now = unixTimestamp ?? Math.floor(Date.now() / 1000);
|
||||
const crankRows = await this.peakNextWithTime(num);
|
||||
return crankRows
|
||||
|
|
|
@ -572,6 +572,28 @@ export class QueueAccount extends Account<types.OracleQueueAccountData> {
|
|||
|
||||
txns.push(permissionInit);
|
||||
|
||||
// set priority fees
|
||||
if (
|
||||
params.basePriorityFee !== undefined ||
|
||||
params.priorityFeeBump !== undefined ||
|
||||
params.priorityFeeBumpPeriod !== undefined ||
|
||||
params.maxPriorityFeeMultiplier !== undefined
|
||||
) {
|
||||
const setAggregatorConfig = await aggregatorAccount.setConfigInstruction(
|
||||
payer,
|
||||
{
|
||||
force: true,
|
||||
authority: params.authority,
|
||||
basePriorityFee: params.basePriorityFee,
|
||||
priorityFeeBump: params.priorityFeeBump,
|
||||
priorityFeeBumpPeriod: params.priorityFeeBumpPeriod,
|
||||
maxPriorityFeeMultiplier: params.maxPriorityFeeMultiplier,
|
||||
}
|
||||
);
|
||||
|
||||
post.push(setAggregatorConfig);
|
||||
}
|
||||
|
||||
for await (const { job, weight } of jobs) {
|
||||
const addJobTxn = aggregatorAccount.addJobInstruction(payer, {
|
||||
job: job,
|
||||
|
@ -1381,6 +1403,11 @@ export type CreateQueueFeedParams = Omit<
|
|||
crankPubkey?: PublicKey;
|
||||
crankDataBuffer?: PublicKey;
|
||||
historyLimit?: number;
|
||||
} & {
|
||||
basePriorityFee?: number;
|
||||
priorityFeeBump?: number;
|
||||
priorityFeeBumpPeriod?: number;
|
||||
maxPriorityFeeMultiplier?: number;
|
||||
} & Partial<LeaseInitParams> &
|
||||
Partial<PermissionSetParams> & {
|
||||
// job params
|
||||
|
|
|
@ -24,6 +24,11 @@ export class AggregatorJson implements CreateQueueFeedParams {
|
|||
disableCrank: boolean;
|
||||
crankIndex?: number;
|
||||
|
||||
basePriorityFee?: number;
|
||||
priorityFeeBump?: number;
|
||||
priorityFeeBumpPeriod?: number;
|
||||
maxPriorityFeeMultiplier?: number;
|
||||
|
||||
// lease params
|
||||
fundAmount: number;
|
||||
|
||||
|
@ -63,6 +68,22 @@ export class AggregatorJson implements CreateQueueFeedParams {
|
|||
this.disableCrank = parseBoolean(object, 'disableCrank', false);
|
||||
this.crankIndex =
|
||||
'crankIndex' in object ? Number(object.crankIndex) : undefined;
|
||||
this.basePriorityFee =
|
||||
'basePriorityFee' in object
|
||||
? Number.parseInt(object.basePriorityFee)
|
||||
: undefined;
|
||||
this.priorityFeeBump =
|
||||
'priorityFeeBump' in object
|
||||
? Number.parseInt(object.priorityFeeBump)
|
||||
: undefined;
|
||||
this.priorityFeeBumpPeriod =
|
||||
'priorityFeeBumpPeriod' in object
|
||||
? Number.parseInt(object.priorityFeeBumpPeriod)
|
||||
: undefined;
|
||||
this.maxPriorityFeeMultiplier =
|
||||
'maxPriorityFeeMultiplier' in object
|
||||
? Number.parseInt(object.maxPriorityFeeMultiplier)
|
||||
: undefined;
|
||||
|
||||
// lease
|
||||
this.fundAmount = parseNumber(object, 'fundAmount', 0);
|
||||
|
|
|
@ -12,7 +12,6 @@ import {
|
|||
QueueAccount,
|
||||
} from '../src';
|
||||
import { OracleJob } from '@switchboard-xyz/common';
|
||||
import BN from 'bn.js';
|
||||
|
||||
describe('Aggregator Tests', () => {
|
||||
let ctx: TestContext;
|
||||
|
@ -379,4 +378,61 @@ describe('Aggregator Tests', () => {
|
|||
`Failed to setConfig on aggregator`
|
||||
);
|
||||
});
|
||||
|
||||
it('Sets priority fees during feed creation', async () => {
|
||||
const basePriorityFee = 10000;
|
||||
const priorityFeeBump = 1000;
|
||||
const priorityFeeBumpPeriod = 60;
|
||||
const maxPriorityFeeMultiplier = 10;
|
||||
|
||||
const [myAggregatorAccount] = await queueAccount.createFeed({
|
||||
queueAuthority: queueAuthority,
|
||||
batchSize: 1,
|
||||
minRequiredOracleResults: 1,
|
||||
minRequiredJobResults: 1,
|
||||
minUpdateDelaySeconds: 60,
|
||||
fundAmount: 2.5,
|
||||
enable: true,
|
||||
basePriorityFee,
|
||||
priorityFeeBump,
|
||||
priorityFeeBumpPeriod,
|
||||
maxPriorityFeeMultiplier,
|
||||
jobs: [
|
||||
{ pubkey: jobAccount.publicKey },
|
||||
{
|
||||
weight: 2,
|
||||
data: OracleJob.encodeDelimited(
|
||||
OracleJob.fromObject({
|
||||
tasks: [
|
||||
{
|
||||
valueTask: {
|
||||
value: 1,
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
).finish(),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const myAggregator = await myAggregatorAccount.loadData();
|
||||
|
||||
assert(
|
||||
myAggregator.basePriorityFee === basePriorityFee,
|
||||
`basePriorityFee mismatch, expected ${basePriorityFee}, received ${myAggregator.basePriorityFee}`
|
||||
);
|
||||
assert(
|
||||
myAggregator.priorityFeeBump === priorityFeeBump,
|
||||
`priorityFeeBump mismatch, expected ${priorityFeeBump}, received ${myAggregator.priorityFeeBump}`
|
||||
);
|
||||
assert(
|
||||
myAggregator.priorityFeeBumpPeriod === priorityFeeBumpPeriod,
|
||||
`priorityFeeBumpPeriod mismatch, expected ${priorityFeeBumpPeriod}, received ${myAggregator.priorityFeeBumpPeriod}`
|
||||
);
|
||||
assert(
|
||||
myAggregator.maxPriorityFeeMultiplier === maxPriorityFeeMultiplier,
|
||||
`maxPriorityFeeMultiplier mismatch, expected ${maxPriorityFeeMultiplier}, received ${myAggregator.maxPriorityFeeMultiplier}`
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -109,7 +109,6 @@ export async function setupTest(): Promise<TestContext> {
|
|||
: Keypair.generate();
|
||||
|
||||
const programId = getProgramId(cluster);
|
||||
console.log(`PROGRAM_ID: ${programId.toBase58()}`);
|
||||
|
||||
const program = await sbv2.SwitchboardProgram.load(
|
||||
cluster,
|
||||
|
|
Loading…
Reference in New Issue