diff --git a/src/amm/amm.controllers.ts b/src/amm/amm.controllers.ts index 744097df87..e7f1f4da7c 100644 --- a/src/amm/amm.controllers.ts +++ b/src/amm/amm.controllers.ts @@ -63,6 +63,9 @@ import { trade as plentyTrade, estimateGas as plentyEstimateGas, } from '../connectors/plenty/plenty.controllers'; +import { + positionInfo as orcaPositionInfo, +} from '../connectors/orca/orca.controllers'; import { getInitializedChain, getConnector, @@ -76,11 +79,13 @@ import { Tezosish, Uniswapish, UniswapLPish, + OrcaLPish } from '../services/common-interfaces'; import { Algorand } from '../chains/algorand/algorand'; import { Tinyman } from '../connectors/tinyman/tinyman'; import { Plenty } from '../connectors/plenty/plenty'; import { Osmosis } from '../chains/osmosis/osmosis'; +import { Solana } from '../chains/solana/solana'; import { Carbonamm } from '../connectors/carbon/carbonAMM'; export async function price(req: PriceRequest): Promise { @@ -191,10 +196,18 @@ export async function collectFees( export async function positionInfo( req: PositionRequest ): Promise { - const chain = await getInitializedChain(req.chain, req.network); + const chain = await getInitializedChain(req.chain, req.network); if (chain instanceof Osmosis){ return chain.controller.poolPositions(chain as unknown as Osmosis, req); } + if (chain instanceof Solana){ + const connector: OrcaLPish = await getConnector( + req.chain, + req.network, + req.connector + ); + return orcaPositionInfo(connector, req); + } const connector: UniswapLPish = await getConnector( req.chain, req.network, diff --git a/src/connectors/orca/orca.controllers.ts b/src/connectors/orca/orca.controllers.ts new file mode 100644 index 0000000000..8fba0b4ecf --- /dev/null +++ b/src/connectors/orca/orca.controllers.ts @@ -0,0 +1,22 @@ +import { logger } from '../../services/logger'; +import { latency } from '../../services/base'; +import { PositionRequest, PositionResponse } from '../../amm/amm.requests'; +import { OrcaLPish } from '../../services/common-interfaces'; + +export async function positionInfo( + orcaish: OrcaLPish, + req: PositionRequest + ): Promise { + const startTimestamp: number = Date.now(); + + const posInfo = await orcaish.getPositions(); + + logger.info(`Position info for position ${req.tokenId} retrieved.`); + + return { + network: req.network, + timestamp: startTimestamp, + latency: latency(startTimestamp, Date.now()), + ...posInfo, + }; + } \ No newline at end of file diff --git a/src/connectors/orca/orca.lp.ts b/src/connectors/orca/orca.lp.ts index 8f0d05c02b..fb054aa9ec 100644 --- a/src/connectors/orca/orca.lp.ts +++ b/src/connectors/orca/orca.lp.ts @@ -58,6 +58,13 @@ export class Orca implements OrcaLPish { } async getPositions(): Promise { + if (!this.ready()) { + throw new InitializationError( + SERVICE_UNITIALIZED_ERROR_MESSAGE('Orca'), + SERVICE_UNITIALIZED_ERROR_CODE + ); + } + return { token0: "SOL", token1: "USDC", diff --git a/src/templates/solana.yml b/src/templates/solana.yml index 66f0ab8edf..9afa56e634 100644 --- a/src/templates/solana.yml +++ b/src/templates/solana.yml @@ -1,5 +1,5 @@ networks: - mainnet: + mainnet-beta: nodeURL: https://api.mainnet-beta.solana.com tokenListType: 'FILE' tokenListSource: '/home/gateway/conf/lists/solflare-tokenlist.json'