Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev change tx priority and rpc #301

Merged
merged 3 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# @convergence-rfq/cli

## 6.6.8

### Patch Changes

- fix FinalizeRFQCOnstruction CU limits
- Updated dependencies
- @convergence-rfq/[email protected]

## 6.6.7

### Patch Changes

- Add Offset of 1000 CUs to simulates CUs
- Updated dependencies
- @convergence-rfq/[email protected]

## 6.6.6

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@convergence-rfq/cli",
"description": "Official Convergence CLI",
"version": "6.6.6",
"version": "6.6.8",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand Down Expand Up @@ -47,7 +47,7 @@
"cli": "ts-node src/index.ts"
},
"dependencies": {
"@convergence-rfq/sdk": "6.6.6",
"@convergence-rfq/sdk": "6.6.8",
"@solana/web3.js": "^1.87.6",
"@types/cookie": "^0.5.1",
"commander": "^10.0.0"
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/cvg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const createCvg = async (opts: Opts): Promise<Convergence> => {
const buffer = JSON.parse(readFileSync(opts.keypairFile, 'utf8'));
const user = Keypair.fromSecretKey(new Uint8Array(buffer));
const txPriorityString: string = opts.txPriorityFee;

const txPriority = resolveTxPriorityArg(txPriorityString);
const cvg = new Convergence(
new Connection(opts.rpcEndpoint, {
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ export const resolveTxPriorityArg = (
txPriority: string
): TransactionPriority => {
switch (txPriority) {
case 'dynamic':
return 'dynamic';
case 'none':
return 'none';
case 'normal':
Expand Down
12 changes: 12 additions & 0 deletions packages/js/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @convergence-rfq/sdk

## 6.6.8

### Patch Changes

- fix FinalizeRFQCOnstruction CU limits

## 6.6.7

### Patch Changes

- Add Offset of 1000 CUs to simulates CUs

## 6.6.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/js/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@convergence-rfq/sdk",
"description": "Official Convergence RFQ SDK",
"version": "6.6.6",
"version": "6.6.8",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand Down
2 changes: 2 additions & 0 deletions packages/js/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ export const HXRO_COLLATERAL_LOG_INDEX = 7;
export const DEFAULT_COMPUTE_UNITS = 200_000;

export const DEFAULT_COMPUTE_UNIT_PRICE = 5000;

export const DEFAULT_COMPUTE_UNITS_OFFSET = 1000;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createFinalizeRfqConstructionInstruction } from '@convergence-rfq/rfq';
import { PublicKey } from '@solana/web3.js';
import { ComputeBudgetProgram, PublicKey } from '@solana/web3.js';

import { SendAndConfirmTransactionResponse } from '../../rpcModule';
import { assertRfq, Rfq } from '../models';
Expand Down Expand Up @@ -192,7 +192,7 @@
programs,
});

legs =

Check warning on line 195 in packages/js/src/plugins/rfqModule/operations/finalizeRfqConstruction.ts

View workflow job for this annotation

GitHub Actions / tests (18.x, 1.14.18)

'legs' is assigned a value but never used
legs ?? (await convergence.rfqs().findRfqByAddress({ address: rfq })).legs;

collateralInfo = collateralInfo ?? collateralInfoPda;
Expand All @@ -205,6 +205,12 @@
.setContext({
rfq,
})
.add({
instruction: ComputeBudgetProgram.setComputeUnitLimit({
units: 300000,
}),
signers: [],
})
.add({
instruction: createFinalizeRfqConstructionInstruction(
{
Expand All @@ -221,6 +227,6 @@
key: 'finalizeRfqConstruction',
});

await addComputeBudgetIxsIfNeeded(txBuilder, convergence);
await addComputeBudgetIxsIfNeeded(txBuilder, convergence, true);
return txBuilder;
};
9 changes: 7 additions & 2 deletions packages/js/src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import {
} from '@solana/web3.js';
import { TransactionBuilder } from './TransactionBuilder';
import { Convergence } from '@/Convergence';
import { DEFAULT_COMPUTE_UNITS, DEFAULT_COMPUTE_UNIT_PRICE } from '@/constants';
import {
DEFAULT_COMPUTE_UNITS,
DEFAULT_COMPUTE_UNITS_OFFSET,
DEFAULT_COMPUTE_UNIT_PRICE,
} from '@/constants';

type EstimatedPriorityFee = {
microLamports: number;
Expand Down Expand Up @@ -38,6 +42,7 @@ export const getEstimatedPriorityFee = async (
0
);
avgPriorityFee /= recentPriorityFeeData.length;
avgPriorityFee = Math.ceil(avgPriorityFee);

return {
microLamports: avgPriorityFee,
Expand Down Expand Up @@ -84,7 +89,7 @@ export const getComputeUnitsToBeConsumed = async (
throw new Error('Failed to get units consumed');
}
return {
unitsConsumed,
unitsConsumed: unitsConsumed + DEFAULT_COMPUTE_UNITS_OFFSET,
};
} catch (error) {
return null;
Expand Down
Loading