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

Feat/ Tezos and Plenty #156

Merged
merged 48 commits into from
Aug 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
1cc4a6e
(feat) add tezos chain support
OjusWiZard May 2, 2023
3e9efa5
(feat) add sign from tezos wallet
OjusWiZard May 3, 2023
1da6dba
(fix) chainId type in Tezos TokenInfo
OjusWiZard May 8, 2023
1966d7e
(fix): add missing gasLimitTransaction in Tezosish
OjusWiZard May 9, 2023
52d5e73
(fix) update manualGasPrice
OjusWiZard May 14, 2023
304324f
(fix) update tokens
OjusWiZard Jun 20, 2023
120cf78
(feat) add /nextNonce route
OjusWiZard Jun 20, 2023
7105f66
(fix) API bug fixes and improve compactibility
OjusWiZard Jun 20, 2023
c1133b9
(fix) update test for new compactibility
OjusWiZard Jun 20, 2023
5557cce
(feat) add tezos chain support
OjusWiZard May 2, 2023
240a19c
(fix): add missing gasLimitTransaction in Tezosish
OjusWiZard May 9, 2023
7f386a8
(fix) update test for new compactibility
OjusWiZard Jun 20, 2023
11dba37
(fix) refactor tezos controller
OjusWiZard Jul 11, 2023
f9a36db
(fix) solve dependency conflict
OjusWiZard Jul 12, 2023
819cf80
(feat) add getTokens in Tezos controller
OjusWiZard Jul 12, 2023
137c04a
(fix) gasUsed significance according to eth
OjusWiZard Jul 12, 2023
8f43267
(fix) add custom validateTezosTokenSymbols
OjusWiZard Jul 13, 2023
6cb1d3e
(fix) higher counter error in new taquito version
OjusWiZard Jul 13, 2023
27fa133
(fix) optimise getTokenAllowance
OjusWiZard Jul 13, 2023
31bfa18
(refactor) token list path
OjusWiZard Jul 13, 2023
d9eaa0d
(feat) add missing test for new getTokens route
OjusWiZard Jul 13, 2023
dfaa111
(feat) add tezos chain support
OjusWiZard May 2, 2023
c18e6a2
(fix) solve dependency conflict
OjusWiZard Jul 12, 2023
512caa4
(feat) add plenty connector support
OjusWiZard Jun 21, 2023
3e18ae5
(fix) CTEZ capitalization bug
OjusWiZard Jun 21, 2023
4b99e6a
(feat) add plenty tests
OjusWiZard Jun 21, 2023
9b4c288
(cleanup) comments in plenty.controller.ts
OjusWiZard Jun 23, 2023
1cc356b
(feat) add plenty routes and controllers tests
OjusWiZard Jun 23, 2023
e19cfd7
(fix) update Plenty router contract
OjusWiZard Jul 7, 2023
4ba0677
(chore) add debug logs
OjusWiZard Jul 7, 2023
f5ef81a
(feat) add plenty connector support
OjusWiZard Jun 21, 2023
853e23b
(cleanup) remove lpTokenSupply from pools
OjusWiZard Jul 12, 2023
c89f274
(fix) optimize pool contract fetching
OjusWiZard Jul 12, 2023
40dcc08
(fix) optimize pricing API using analytics API
OjusWiZard Jul 12, 2023
04f12dc
(fix) half the allowedSlippage
OjusWiZard Jul 12, 2023
fa68ed7
(fix) remove ghostnet from plenty config
OjusWiZard Jul 13, 2023
0c84026
(fix) plenty trading type to AMM
OjusWiZard Jul 13, 2023
210e219
(fix) update failing tests according to new config
OjusWiZard Jul 13, 2023
489dc70
(fix) optimise plentyBuyTrade paths
OjusWiZard Jul 13, 2023
eb036ab
remove zigzag
nikspz Jul 17, 2023
2433d6c
(feat) add tezos chain support
OjusWiZard May 2, 2023
6602b27
(fix) solve dependency conflict
OjusWiZard Jul 12, 2023
72b9ec2
(fix) failing /poll test
OjusWiZard Jul 17, 2023
464c203
(fix) failing build from controller
OjusWiZard Jul 17, 2023
765b702
(fix) failing testcase after rebase
OjusWiZard Aug 6, 2023
3e1b3e6
Merge branch 'development' into feat/plenty
nikspz Aug 15, 2023
6e05e42
(fix) add tezos validation message for private key
OjusWiZard Aug 18, 2023
9504cba
Merge branch 'development' into feat/plenty
fengtality Aug 20, 2023
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
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
"@pangolindex/sdk": "^1.1.0",
"@perp/sdk-curie": "^1.16.0",
"@sushiswap/sdk": "^5.0.0-canary.116",
"@taquito/rpc": "^17.0.0",
"@taquito/signer": "^17.0.0",
"@taquito/taquito": "^17.0.0",
"@tinymanorg/tinyman-js-sdk": "^3.0.0",
"@traderjoe-xyz/sdk-v2": "^2.0.5",
"@types/fs-extra": "^9.0.13",
Expand Down Expand Up @@ -151,4 +154,4 @@
"resolutions": {
"web3-utils": "1.7.3"
}
}
}
62 changes: 33 additions & 29 deletions src/amm/amm.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,62 +54,64 @@ import {
getAccountValue,
} from '../connectors/perp/perp.controllers';
import {
getInitializedChain,
getConnector,
} from '../services/connection-manager';
price as plentyPrice,
trade as plentyTrade,
estimateGas as plentyEstimateGas,
} from '../connectors/plenty/plenty.controllers';
import { getInitializedChain, getConnector } from '../services/connection-manager';
import {
Chain as Ethereumish,
Nearish,
NetworkSelectionRequest,
Perpish,
RefAMMish,
Tezosish,
Uniswapish,
UniswapLPish,
} from '../services/common-interfaces';
import { Algorand } from '../chains/algorand/algorand';
import { Tinyman } from '../connectors/tinyman/tinyman';
import { Plenty } from '../connectors/plenty/plenty';

export async function price(req: PriceRequest): Promise<PriceResponse> {
const chain = await getInitializedChain<Algorand | Ethereumish | Nearish>(
const chain = await getInitializedChain<Algorand | Ethereumish | Nearish | Tezosish>(
req.chain,
req.network
);
const connector: Uniswapish | RefAMMish | Tinyman =
await getConnector<Uniswapish | RefAMMish | Tinyman>(
req.chain,
req.network,
req.connector
);
const connector: Uniswapish | RefAMMish | Tinyman | Plenty = await getConnector<
Uniswapish | RefAMMish | Tinyman | Plenty
>(req.chain, req.network, req.connector);

// we currently use the presence of routerAbi to distinguish Uniswapish from RefAMMish
if ('routerAbi' in connector) {
if (connector instanceof Plenty) {
return plentyPrice(<Tezosish>chain, connector, req);
} else if ('routerAbi' in connector) {
// we currently use the presence of routerAbi to distinguish Uniswapish from RefAMMish
return uniswapPrice(<Ethereumish>chain, connector, req);
} else if (connector instanceof Tinyman) {
return tinymanPrice(chain as unknown as Algorand, connector, req);
} else {
return refPrice(<Nearish>chain, connector, req);
return refPrice(<Nearish>chain, connector as RefAMMish, req);
}
}

export async function trade(req: TradeRequest): Promise<TradeResponse> {
const chain = await getInitializedChain<Algorand | Ethereumish | Nearish>(
const chain = await getInitializedChain<Algorand | Ethereumish | Nearish | Tezosish>(
req.chain,
req.network
);
const connector: Uniswapish | RefAMMish | Tinyman =
await getConnector<Uniswapish | RefAMMish | Tinyman >(
req.chain,
req.network,
req.connector
);
const connector: Uniswapish | RefAMMish | Tinyman | Plenty = await getConnector<
Uniswapish | RefAMMish | Tinyman | Plenty
>(req.chain, req.network, req.connector);

// we currently use the presence of routerAbi to distinguish Uniswapish from RefAMMish
if ('routerAbi' in connector) {
if (connector instanceof Plenty) {
return plentyTrade(<Tezosish>chain, connector, req);
} else if ('routerAbi' in connector) {
// we currently use the presence of routerAbi to distinguish Uniswapish from RefAMMish
return uniswapTrade(<Ethereumish>chain, connector, req);
} else if (connector instanceof Tinyman) {
return tinymanTrade(chain as unknown as Algorand, connector, req);
} else {
return refTrade(<Nearish>chain, connector, req);
return refTrade(<Nearish>chain, connector as RefAMMish, req);
}
}

Expand Down Expand Up @@ -178,21 +180,23 @@ export async function poolPrice(
export async function estimateGas(
req: NetworkSelectionRequest
): Promise<EstimateGasResponse> {
const chain = await getInitializedChain<Algorand | Ethereumish | Nearish>(
const chain = await getInitializedChain<Algorand | Ethereumish | Nearish | Tezosish>(
req.chain,
req.network
);
const connector: Uniswapish | RefAMMish | Tinyman = await getConnector<
Uniswapish | RefAMMish
const connector: Uniswapish | RefAMMish | Tinyman | Plenty = await getConnector<
Uniswapish | RefAMMish | Plenty
>(req.chain, req.network, req.connector);

// we currently use the presence of routerAbi to distinguish Uniswapish from RefAMMish
if ('routerAbi' in connector) {
if (connector instanceof Plenty) {
return plentyEstimateGas(<Tezosish>chain, connector);
} else if ('routerAbi' in connector) {
// we currently use the presence of routerAbi to distinguish Uniswapish from RefAMMish
return uniswapEstimateGas(<Ethereumish>chain, connector);
} else if (connector instanceof Tinyman) {
return tinymanEstimateGas(chain as unknown as Algorand, connector);
} else {
return refEstimateGas(<Nearish>chain, connector);
return refEstimateGas(<Nearish>chain, connector as RefAMMish);
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/chains/chain.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
TransferRequest,
TransferResponse,
} from './injective/injective.requests';
import { validateTezosNonceRequest } from './tezos/tezos.validators';

export const validatePollRequest: RequestValidator = mkRequestValidator([
validateTxHash,
Expand Down Expand Up @@ -155,7 +156,10 @@ export namespace ChainRoutes {
req: Request<{}, {}, NonceRequest>,
res: Response<NonceResponse | string, {}>
) => {
validateNonceRequest(req.body);
if (req.body.chain === 'tezos')
validateTezosNonceRequest(req.body);
else
validateNonceRequest(req.body);
const chain = await getInitializedChain(
req.body.chain,
req.body.network
Expand Down
Loading