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

Squads integration #290

Merged
merged 3 commits into from
Apr 1, 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
11 changes: 11 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @convergence-rfq/cli

## 6.5.0

### Minor Changes

- Replace risk engine program with a simplified one, add squads integration

### Patch Changes

- Updated dependencies
- @convergence-rfq/[email protected]

## 6.4.2

### 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.4.2",
"version": "6.5.0",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand Down Expand Up @@ -47,7 +47,7 @@
"cli": "ts-node src/index.ts"
},
"dependencies": {
"@convergence-rfq/sdk": "6.4.2",
"@convergence-rfq/sdk": "6.5.0",
"@solana/web3.js": "^1.87.6",
"@types/cookie": "^0.5.1",
"commander": "^10.0.0"
Expand Down
118 changes: 0 additions & 118 deletions packages/cli/src/actions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { PublicKey, LAMPORTS_PER_SOL } from '@solana/web3.js';
import {
token,
toRiskCategoryInfo,
toScenario,
devnetAirdrops,
PriceOracle,
SpotLegInstrument,
Expand Down Expand Up @@ -33,7 +31,6 @@ import {
logTx,
logError,
logTokenAccount,
logRiskEngineConfig,
logRegisteredMint,
logCollateral,
logToken,
Expand Down Expand Up @@ -497,121 +494,6 @@ export const getCollateral = async (opts: Opts) => {
}
};

// Risk engine

export const initializeRiskEngine = async (opts: Opts) => {
const cvg = await createCvg(opts);
try {
const { response } = await expirationRetry(
() =>
cvg.riskEngine().initializeConfig({
collateralMintDecimals: opts.collateralMintDecimals,
minCollateralRequirement: opts.minCollateralRequirement,
collateralForFixedQuoteAmountRfqCreation:
opts.collateralForFixedQuoteAmountRfqCreation,
safetyPriceShiftFactor: opts.safetyPriceShiftFactor,
overallSafetyFactor: opts.overallSafetyFace,
acceptedOracleStaleness: opts.acceptedOracleStaleness,
acceptedOracleConfidenceIntervalPortion:
opts.acceptedOracleConfidenceIntervalPortion,
}),
opts
);
logResponse(response);
} catch (e) {
logError(e);
}
};

export const updateRiskEngine = async (opts: Opts) => {
const cvg = await createCvg(opts);
try {
const { response } = await expirationRetry(
() =>
cvg.riskEngine().updateConfig({
collateralMintDecimals: opts.collateralMintDecimals,
minCollateralRequirement: opts.minCollateralRequirement,
collateralForFixedQuoteAmountRfqCreation:
opts.collateralForFixedQuoteAmountRfqCreation,
safetyPriceShiftFactor: opts.safetyPriceShiftFactor,
overallSafetyFactor: opts.overallSafetyFace,
acceptedOracleStaleness: opts.acceptedOracleStaleness,
acceptedOracleConfidenceIntervalPortion:
opts.acceptedOracleConfidenceIntervalPortion,
}),
opts
);
logResponse(response);
} catch (e) {
logError(e);
}
};
export const closeRiskEngine = async (opts: Opts) => {
const cvg = await createCvg(opts);
try {
const { response } = await cvg.riskEngine().closeConfig();
logResponse(response);
} catch (e) {
logError(e);
}
};

export const getRiskEngineConfig = async (opts: Opts) => {
const cvg = await createCvg(opts);
try {
const config = await cvg.riskEngine().fetchConfig();
logRiskEngineConfig(config);
} catch (e) {
logError(e);
}
};

export const setRiskEngineInstrumentType = async (opts: Opts) => {
const cvg = await createCvg(opts);
try {
const { response } = await expirationRetry(
() =>
cvg.riskEngine().setInstrumentType({
instrumentProgram: new PublicKey(opts.program),
instrumentType: opts.type,
}),
opts
);
logResponse(response);
} catch (e) {
logError(e);
}
};

export const setRiskEngineCategoriesInfo = async (opts: Opts) => {
const newValue = opts.newValue.split(',').map((x: string) => parseFloat(x));
const cvg = await createCvg(opts);
try {
const { response } = await expirationRetry(
() =>
cvg.riskEngine().setRiskCategoriesInfo({
changes: [
{
value: toRiskCategoryInfo(newValue[0], newValue[1], [
toScenario(newValue[2], newValue[3]),
toScenario(newValue[4], newValue[5]),
toScenario(newValue[6], newValue[7]),
toScenario(newValue[8], newValue[9]),
toScenario(newValue[10], newValue[11]),
toScenario(newValue[12], newValue[13]),
]),
category: opts.category,
},
],
}),
opts
);
logResponse(response);
} catch (e) {
logError(e);
}
};

// Devnet and localnet helpers

export const airdrop = async (opts: Opts) => {
Expand Down
2 changes: 0 additions & 2 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Command } from 'commander';

import {
riskEngineGroup,
protocolGroup,
collateralGroup,
airdropGroup,
Expand All @@ -16,7 +15,6 @@ export const makeCli = (): Command => {
airdropGroup,
tokenGroup,
protocolGroup,
riskEngineGroup,
collateralGroup,
rfqGroup,
hxroGroup,
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/groups/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export * from './airdrop';
export * from './collateral';
export * from './protocol';
export * from './rfq';
export * from './riskEngine';
export * from './token';
export * from './hxro';
export * from './spotInstrument';
124 changes: 0 additions & 124 deletions packages/cli/src/groups/riskEngine.ts

This file was deleted.

16 changes: 0 additions & 16 deletions packages/cli/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,22 +120,6 @@ export const logProtocol = (p: Protocol): void => {
});
};

export const logRiskEngineConfig = (r: any): void => {
l('Address:', r.address.toString());
l(
'Minimal collateral requirement:',
N(r.minCollateralRequirement.toString())
);
l(
'Collateral for fixed quote amount RFQ creation:',
N(r.collateralForFixedQuoteAmountRfqCreation.toString())
);
l('Collateral mint decimals:', N(r.collateralMintDecimals.toString()));
l('Safety price shift factor:', N(r.safetyPriceShiftFactor.toString()));
l('Overall safety factor:', r.overallSafetyFactor);
r.riskCategoriesInfo.map(logRiskCategoryInfo);
};

export const logRiskCategoryInfo = (c: any): void => {
const formatRatio = (x: any) => {
return [x.baseAssetPriceChange, x.volatilityChange].join('/');
Expand Down
Loading
Loading