Skip to content

Commit

Permalink
Merge pull request #62 from DODOEX/feat/add-pool-widget
Browse files Browse the repository at this point in the history
Feat/add pool widget
  • Loading branch information
junjieit authored Dec 18, 2024
2 parents 5efe987 + 4564d39 commit 9065ac0
Show file tree
Hide file tree
Showing 223 changed files with 26,075 additions and 3,831 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ cache
.npmrc

#lingui
.linguirc.local
.linguirc.local
packages/dodoex-widgets/src/widgets/PoolWidget/AMMV3/sdks/contracts
46 changes: 46 additions & 0 deletions packages/doc/src/stories/widgets/AMMV3Create.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { SwapWidgetApi } from '@dodoex/api';
import { AddLiquidityV3, SwapWidgetProps, Widget } from '@dodoex/widgets';
import React from 'react';

export default {
title: 'Widgets/AddLiquidityV3',
component: 'div',
};

export const Primary = (props: any) => {
const [config, setConfig] = React.useState<SwapWidgetProps>({});
const { projectId, apiKey, ...other } = props;
React.useEffect(() => {
if (projectId && apiKey) {
const dodoService = new SwapWidgetApi();
dodoService
.getConfigSwapWidgetProps(projectId, apiKey)
.then(({ swapWidgetProps }) => {
setConfig(swapWidgetProps);
});
}
}, [projectId, apiKey]);

return (
<Widget {...config} {...other} apikey={apiKey}>
<AddLiquidityV3
handleGoBack={() => window.alert('handleGoBack')}
handleGoToPoolList={() => window.alert('handleGoToPoolList')}
params={{
from: '0x8f2a9f23d5d70226491b0c10365de88f64cd4a01',
to: '0xd05553bc85fa8c004073d91097b7611cd5e478f5',
fee: '100',
}}
/>
</Widget>
);
};

Primary.args = {
projectId: 'project2',
apiKey: 'ee53d6b75b12aceed4',
width: '100%',
height: '100%',
noDocumentLink: true,
// onlyChainId: 1,
};
59 changes: 59 additions & 0 deletions packages/doc/src/stories/widgets/AMMV3PositionManage.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { SwapWidgetApi } from '@dodoex/api';
import { AMMV3PositionManage, SwapWidgetProps, Widget } from '@dodoex/widgets';
import React from 'react';

export default {
title: 'Widgets/AMMV3PositionManage',
component: 'div',
};

export const Primary = (props: any) => {
const [config, setConfig] = React.useState<SwapWidgetProps>({});
const { projectId, apiKey, ...other } = props;
React.useEffect(() => {
if (projectId && apiKey) {
const dodoService = new SwapWidgetApi();
dodoService
.getConfigSwapWidgetProps(projectId, apiKey)
.then(({ swapWidgetProps }) => {
setConfig(swapWidgetProps);
});
}
}, [projectId, apiKey]);

return (
<Widget {...config} {...other} apikey={apiKey}>
<AMMV3PositionManage
chainId={11155111}
baseToken={{
address: '0x163D876AF3949f45D934870a1783A040Cf717Bc5',
decimals: 18,
symbol: 'uni_test2',
name: 'uni_test2',
chainId: 11155111,
}}
quoteToken={{
address: '0x444d30Eeb001Dc8B7B96cEF088381418B82f9441',
decimals: 6,
symbol: 'uni_test3',
name: 'uni_test3',
chainId: 11155111,
}}
// feeAmount={500}
// tokenId={'25235'}
feeAmount={500}
tokenId={'4'}
onClose={() => window.alert('onClose')}
/>
</Widget>
);
};

Primary.args = {
projectId: 'project2',
apiKey: 'ee53d6b75b12aceed4',
width: '100%',
height: '100%',
noDocumentLink: true,
// onlyChainId: 1,
};
59 changes: 59 additions & 0 deletions packages/doc/src/stories/widgets/AMMV3PositionsView.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { SwapWidgetApi } from '@dodoex/api';
import { AMMV3PositionsView, SwapWidgetProps, Widget } from '@dodoex/widgets';
import React from 'react';

export default {
title: 'Widgets/AMMV3PositionsView',
component: 'div',
};

export const Primary = (props: any) => {
const [config, setConfig] = React.useState<SwapWidgetProps>({});
const { projectId, apiKey, ...other } = props;
React.useEffect(() => {
if (projectId && apiKey) {
const dodoService = new SwapWidgetApi();
dodoService
.getConfigSwapWidgetProps(projectId, apiKey)
.then(({ swapWidgetProps }) => {
setConfig(swapWidgetProps);
});
}
}, [projectId, apiKey]);

return (
<Widget {...config} {...other} apikey={apiKey}>
<AMMV3PositionsView
chainId={11155111}
baseToken={{
address: '0x163D876AF3949f45D934870a1783A040Cf717Bc5',
decimals: 18,
symbol: 'uni_test2',
name: 'uni_test2',
chainId: 11155111,
}}
quoteToken={{
address: '0x444d30Eeb001Dc8B7B96cEF088381418B82f9441',
decimals: 6,
symbol: 'uni_test3',
name: 'uni_test3',
chainId: 11155111,
}}
feeAmount={500}
onClose={() => window.alert('onClose')}
handleGoToAddLiquidityV3={() =>
window.alert('handleGoToAddLiquidityV3')
}
/>
</Widget>
);
};

Primary.args = {
projectId: 'project2',
apiKey: 'ee53d6b75b12aceed4',
width: '100%',
height: '100%',
noDocumentLink: true,
// onlyChainId: 1,
};
55 changes: 54 additions & 1 deletion packages/doc/src/stories/widgets/Pool.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,57 @@ export const Primary = (props: any) => {
});
}
}, [projectId, apiKey]);
return <PoolWidget {...config} {...other} apikey={apiKey} />;
return (
<PoolWidget
{...config}
tokenList={[
{
address: '0x7D381e6a9c23A0E6969658f6B8Eba57A4Dbf93a0',
symbol: 'USDT',
name: 'USDT',
decimals: 18,
chainId: 11155111,
},
{
address: '0xf86Ed431954d101eaC10F3eBC19E6EaeD1291365',
symbol: 'test',
name: 'test',
decimals: 18,
chainId: 11155111,
},
{
address: '0x163D876AF3949f45D934870a1783A040Cf717Bc5',
symbol: 'uni_test2',
name: 'test',
decimals: 18,
chainId: 11155111,
},
{
address: '0xac4D957b99482C0309717FDd8fA779f3FEE5c309',
symbol: 'uni_test1',
name: 'test',
decimals: 18,
chainId: 11155111,
},
{
address: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
symbol: 'ETH',
name: 'ETH',
decimals: 18,
chainId: 11155111,
},
{
address: '0x7B07164ecFaF0F0D85DFC062Bc205a4674c75Aa0',
symbol: 'WETH',
name: 'WETH',
decimals: 18,
chainId: 11155111,
},
]}
{...other}
apikey={apiKey}
/>
);
};

Primary.args = {
Expand All @@ -29,5 +79,8 @@ Primary.args = {
width: '100%',
height: '100%',
noDocumentLink: true,
routerPage: undefined,
supportAMMV2: true,
supportAMMV3: true,
// onlyChainId: 1,
};
7 changes: 4 additions & 3 deletions packages/dodoex-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dodoex/api",
"version": "3.0.0",
"version": "3.0.2",
"description": "DODO API Kit",
"source": "src/index.ts",
"types": "dist/types/index.d.ts",
Expand All @@ -20,6 +20,7 @@
"prerelease": "yarn run build",
"release": "semantic-release",
"release:local": "np --any-branch --no-cleanup --no-tests",
"release.npm-publish": "npm publish --access public",
"release.npm-publish-beta": "npm publish --tag beta"
},
"author": "",
Expand Down Expand Up @@ -52,6 +53,8 @@
]
},
"peerDependencies": {
"@dodoex/contract-request": "1.x",
"@dodoex/dodo-contract-request": "1.x",
"bignumber.js": ">=9",
"lodash": ">=4"
},
Expand All @@ -70,9 +73,7 @@
"@babel/preset-env": "^7.16.11",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.16.7",
"@ethersproject/abi": ">=5",
"@ethersproject/contracts": ">=5",
"@ethersproject/providers": ">=5",
"@graphql-codegen/cli": "^5.0.0",
"@graphql-codegen/client-preset": "^4.1.0",
"@rollup/plugin-babel": "^6.0.4",
Expand Down
15 changes: 13 additions & 2 deletions packages/dodoex-api/src/chainConfig/basicToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,18 @@ export const basicTokenMap: {
},
[ChainId.TAIKO]: {
...DEFAULT_BASIC_TOKEN,
wrappedTokenSymbol: 'WMNT',
wrappedTokenAddress: '0x78c1b0C915c4FAA5FffA6CAbf0219DA63d7f4cb8',
wrappedTokenAddress: '0xA51894664A773981C6C112C43ce576f315d5b1B6',
},
[ChainId.PLUME]: {
...DEFAULT_BASIC_TOKEN,
wrappedTokenAddress: '0x562723560131C47417dfcD6BB1A089E4D7C7943C',
},
[ChainId.NEOX]: {
...DEFAULT_BASIC_TOKEN,
symbol: 'GAS',
name: 'GAS',
showDecimals: 6,
wrappedTokenSymbol: 'WGAS10',
wrappedTokenAddress: '0xdE41591ED1f8ED1484aC2CD8ca0876428de60EfF',
},
};
4 changes: 4 additions & 0 deletions packages/dodoex-api/src/chainConfig/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ export enum ChainId {
DODO_CHAIN_TESTNET = 53457,

TAIKO = 167000,

PLUME = 98865,

NEOX = 47763,
}
29 changes: 29 additions & 0 deletions packages/dodoex-api/src/chainConfig/contractConfig.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { neox, plume } from '@dodoex/dodo-contract-request';
import { ChainId } from './chain';

const contractMap: {
Expand Down Expand Up @@ -285,6 +286,34 @@ const contractMap: {
DODO_DPP_PROXY: '0x38886EDE1Fc92886F9a11C37a1f5e75474858eaa',
DODO_MINEV3_PROXY: '0x1dFd36964e21a2eb633991f0B95b4241c20e1db3',
},
[ChainId.PLUME]: {
MULTI_CALL: plume.MulticallWithValid,
DODO_APPROVE: plume.DODOApprove,
ERC20_HELPER: plume.ERC20Helper,

ROUTE_V2_DATA_FETCH: plume.DODOV2RouteHelper,
ROUTE_V1_DATA_FETCH: plume.DODOV1PmmHelper,
CALLEE_HELPER: plume.DODOCalleeHelper,

DODO_PROXY: plume.DODOV2Proxy02,
DODO_DSP_PROXY: plume.DODODspProxyWithoutGSP,
DODO_DPP_PROXY: plume.DODODppProxy,
DODO_MINEV3_PROXY: plume.DODOMineV3Proxy,
},
[ChainId.NEOX]: {
MULTI_CALL: neox.MulticallWithValid,
DODO_APPROVE: neox.DODOApprove,
ERC20_HELPER: neox.ERC20Helper,

ROUTE_V2_DATA_FETCH: neox.DODOV2RouteHelper,
ROUTE_V1_DATA_FETCH: neox.DODOV1PmmHelper,
CALLEE_HELPER: neox.DODOCalleeHelper,

DODO_PROXY: neox.DODOV2Proxy02,
DODO_DSP_PROXY: neox.DODODspProxyWithoutGSP,
DODO_DPP_PROXY: neox.DODODppProxy,
DODO_MINEV3_PROXY: neox.DODOMineV3Proxy,
},
};

export default contractMap;
2 changes: 2 additions & 0 deletions packages/dodoex-api/src/chainConfig/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ export const platformIdMap: {
[ChainId.SEPOLIA]: 'sepolia',
[ChainId.DODO_CHAIN_TESTNET]: 'dodochain-testnet',
[ChainId.TAIKO]: 'taiko',
[ChainId.PLUME]: 'plume',
[ChainId.NEOX]: 'neox',
};
Loading

0 comments on commit 9065ac0

Please sign in to comment.