Skip to content

Commit

Permalink
Merge pull request #306 from convergence-rfq/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Nagaprasadvr authored May 22, 2024
2 parents 18df032 + 48594db commit 71bc72c
Show file tree
Hide file tree
Showing 57 changed files with 763 additions and 272 deletions.
104 changes: 104 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,109 @@
# @convergence-rfq/cli

## 6.6.18

### Patch Changes

- update getHxroCollateralForSettlement
- Updated dependencies
- @convergence-rfq/sdk@6.6.18

## 6.6.17

### Patch Changes

- finish hxro updateMarkPrice integration
- Updated dependencies
- @convergence-rfq/sdk@6.6.17

## 6.6.16

### Patch Changes

- remove console logs
- Updated dependencies
- @convergence-rfq/sdk@6.6.16

## 6.6.15

### Patch Changes

- experiment hxro updateMarkPrice
- Updated dependencies
- @convergence-rfq/sdk@6.6.15

## 6.6.14

### Patch Changes

- Modify preparePrintTradeSettlement logic
- Updated dependencies
- @convergence-rfq/sdk@6.6.14

## 6.6.13

### Patch Changes

- fix sig verify error
- Updated dependencies
- @convergence-rfq/sdk@6.6.13

## 6.6.12

### Patch Changes

- add updateMarkPrice ix to lockcollateral
- Updated dependencies
- @convergence-rfq/sdk@6.6.12

## 6.6.11

### Patch Changes

- Update hxro collateral logs fetching logic
- Updated dependencies
- @convergence-rfq/sdk@6.6.11

## 6.6.10

### Patch Changes

- Fix an issue with hxro library when the SDK is imported as .mjs
- Updated dependencies
- @convergence-rfq/sdk@6.6.10

## 6.6.9

### Patch Changes

- Disable CU calculations for Create RFQ Txs
- Updated dependencies
- @convergence-rfq/sdk@6.6.9

## 6.6.8

### Patch Changes

- fix FinalizeRFQCOnstruction CU limits
- Updated dependencies
- @convergence-rfq/sdk@6.6.8

## 6.6.7

### Patch Changes

- Add Offset of 1000 CUs to simulates CUs
- Updated dependencies
- @convergence-rfq/sdk@6.6.7

## 6.6.6

### Patch Changes

- ComputeUnits Improvement and implement dynamic Priority fee
- Updated dependencies
- @convergence-rfq/sdk@6.6.6

## 6.6.5

### 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.5",
"version": "6.6.18",
"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.5",
"@convergence-rfq/sdk": "6.6.18",
"@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
78 changes: 78 additions & 0 deletions packages/js/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,83 @@
# @convergence-rfq/sdk

## 6.6.18

### Patch Changes

- update getHxroCollateralForSettlement

## 6.6.17

### Patch Changes

- finish hxro updateMarkPrice integration

## 6.6.16

### Patch Changes

- remove console logs

## 6.6.15

### Patch Changes

- experiment hxro updateMarkPrice

## 6.6.14

### Patch Changes

- Modify preparePrintTradeSettlement logic

## 6.6.13

### Patch Changes

- fix sig verify error

## 6.6.12

### Patch Changes

- add updateMarkPrice ix to lockcollateral

## 6.6.11

### Patch Changes

- Update hxro collateral logs fetching logic

## 6.6.10

### Patch Changes

- Fix an issue with hxro library when the SDK is imported as .mjs

## 6.6.9

### Patch Changes

- Disable CU calculations for Create RFQ Txs

## 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

- ComputeUnits Improvement and implement dynamic Priority fee

## 6.6.5

### Patch Changes
Expand Down
7 changes: 4 additions & 3 deletions 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.5",
"version": "6.6.18",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand Down Expand Up @@ -37,7 +37,8 @@
"lint": "eslint --ext js,ts,tsx src",
"lint:fix": "eslint --fix --ext js,ts,tsx src",
"clean": "rimraf dist",
"build": "yarn clean && tsc && tsc-alias && tsc -p tsconfig.json && tsc-alias -p tsconfig.json && rollup -c",
"build": "yarn clean && yarn build:types && rollup -c",
"build:types": "tsc -p tsconfig.json && tsc-alias -p tsconfig.json",
"test:coverage": "nyc ts-mocha --timeout 100000 tests/**/*.spec.ts",
"test": "ts-mocha --paths --timeout 100000 tests/**/*.spec.ts"
},
Expand All @@ -61,7 +62,7 @@
"@convergence-rfq/vault-operator": "^3.11.0",
"@coral-xyz/anchor": "^0.28.0",
"@coral-xyz/borsh": "^0.28.0",
"@hxronetwork/dexterity-ts": "1.6.16",
"@hxronetwork/dexterity-ts": "1.6.40",
"@mithraic-labs/psy-american": "^0.2.3",
"@mithraic-labs/tokenized-euros": "^0.2.3",
"@noble/ed25519": "^1.7.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/js/src/Convergence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class Convergence {
this.connection = connection;
this.cluster = options.cluster ?? resolveClusterFromConnection(connection);
this.skipPreflight = options.skipPreflight ?? false;
this.transactionPriority = options.transactionPriority ?? 'none';
this.transactionPriority = options.transactionPriority ?? 'normal';
this.use(corePlugins());
}

Expand Down
14 changes: 9 additions & 5 deletions packages/js/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
export const TRANSACTION_PRIORITY_FEE_MAP = {
export const COMPUTE_UNIT_PRICE_IN_MICRO_LAMPORTS_MAP = {
none: 0,
normal: 5_000,
high: 15_000,
turbo: 25_000,
normal: 5000,
high: 15000,
turbo: 25000,
};

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
Expand Up @@ -18,6 +18,7 @@ import { addDecimals } from '../../../utils/conversions';
import { Convergence } from '../../../Convergence';
import { protocolCache } from '../../protocolModule/cache';
import { collateralMintCache } from '../cache';
import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers';
const Key = 'FundCollateralOperation' as const;

/**
Expand Down Expand Up @@ -158,9 +159,8 @@ export const fundCollateralBuilder = async (
const collateralMint = await collateralMintCache.get(convergence);
const collateralDecimals = collateralMint.decimals;

return TransactionBuilder.make()
const txBuilder = TransactionBuilder.make()
.setFeePayer(payer)
.addTxPriorityFeeIx(convergence)
.add({
instruction: createFundCollateralInstruction(
{
Expand All @@ -178,4 +178,6 @@ export const fundCollateralBuilder = async (
signers: [user],
key: 'fundCollateral',
});
await addComputeBudgetIxsIfNeeded(txBuilder, convergence);
return txBuilder;
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
TransactionBuilderOptions,
} from '../../../utils/TransactionBuilder';
import { protocolCache } from '../../protocolModule/cache';
import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers';

const Key = 'InitializeCollateralOperation' as const;

Expand Down Expand Up @@ -196,21 +197,24 @@ export const initializeCollateralBuilder = async (

const rfqProgram = convergence.programs().getRfq(programs);

return TransactionBuilder.make<InitializeCollateralBuilderContext>()
.setFeePayer(user)
.addTxPriorityFeeIx(convergence)
.add({
instruction: createInitializeCollateralInstruction(
{
user: user.publicKey,
protocol,
collateralMint,
collateralToken,
collateralInfo,
},
rfqProgram.address
),
signers: [user],
key: 'initializeCollateral',
});
const txBuilder =
TransactionBuilder.make<InitializeCollateralBuilderContext>()
.setFeePayer(user)
.add({
instruction: createInitializeCollateralInstruction(
{
user: user.publicKey,
protocol,
collateralMint,
collateralToken,
collateralInfo,
},
rfqProgram.address
),
signers: [user],
key: 'initializeCollateral',
});
await addComputeBudgetIxsIfNeeded(txBuilder, convergence);

return txBuilder;
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import { protocolCache } from '../../protocolModule/cache';
import { collateralMintCache } from '../cache';
import { addDecimals } from '../../..//utils/conversions';
import { addComputeBudgetIxsIfNeeded } from '@/utils/helpers';

const Key = 'WithdrawCollateralOperation' as const;

Expand Down Expand Up @@ -182,9 +183,8 @@ export const withdrawCollateralBuilder = async (
const collateralMint = await collateralMintCache.get(convergence);
const collateralDecimals = collateralMint.decimals;

return TransactionBuilder.make<WithdrawCollateralBuilderContext>()
const txBuilder = TransactionBuilder.make<WithdrawCollateralBuilderContext>()
.setFeePayer(user)
.addTxPriorityFeeIx(convergence)
.add({
instruction: createWithdrawCollateralInstruction(
{
Expand All @@ -202,4 +202,7 @@ export const withdrawCollateralBuilder = async (
signers: [user],
key: 'withdrawCollateral',
});

await addComputeBudgetIxsIfNeeded(txBuilder, convergence);
return txBuilder;
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ export const hxroManifestCache = useCache(async (cvg: Convergence) => {
console.debug = () => {};
let manifest: any; // dexterity doesn't export a type for a manifest
try {
manifest = await dexterity.getManifest(
// @ts-ignore the next line fixes a strange issue with dexterity default export when imported from .mjs files
const getManifest = dexterity.getManifest ?? dexterity.default.getManifest;

manifest = await getManifest(
cvg.connection.rpcEndpoint,
true,
new CvgWallet(cvg)
Expand Down
Loading

0 comments on commit 71bc72c

Please sign in to comment.