Skip to content

Commit

Permalink
(wip) dummy position route working
Browse files Browse the repository at this point in the history
  • Loading branch information
fengtality committed Aug 21, 2024
1 parent a862249 commit ea8dc47
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/amm/amm.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<PriceResponse> {
Expand Down Expand Up @@ -191,10 +196,18 @@ export async function collectFees(
export async function positionInfo(
req: PositionRequest
): Promise<PositionResponse> {
const chain = await getInitializedChain<Ethereumish | Osmosis>(req.chain, req.network);
const chain = await getInitializedChain<Ethereumish | Osmosis | Solana>(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<OrcaLPish>(
req.chain,
req.network,
req.connector
);
return orcaPositionInfo(connector, req);
}
const connector: UniswapLPish = await getConnector<UniswapLPish>(
req.chain,
req.network,
Expand Down
22 changes: 22 additions & 0 deletions src/connectors/orca/orca.controllers.ts
Original file line number Diff line number Diff line change
@@ -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<PositionResponse> {
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,
};
}
7 changes: 7 additions & 0 deletions src/connectors/orca/orca.lp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ export class Orca implements OrcaLPish {
}

async getPositions(): Promise<PositionInfo> {
if (!this.ready()) {
throw new InitializationError(
SERVICE_UNITIALIZED_ERROR_MESSAGE('Orca'),
SERVICE_UNITIALIZED_ERROR_CODE
);
}

return {
token0: "SOL",
token1: "USDC",
Expand Down
2 changes: 1 addition & 1 deletion src/templates/solana.yml
Original file line number Diff line number Diff line change
@@ -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'
Expand Down

0 comments on commit ea8dc47

Please sign in to comment.