Skip to content

Commit

Permalink
feat: add AMMV3 slippage protection and update related components
Browse files Browse the repository at this point in the history
  • Loading branch information
yrjkqq committed Dec 5, 2024
1 parent 9a0696a commit 876a206
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 93 deletions.
4 changes: 2 additions & 2 deletions packages/dodoex-widgets/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dodoex/widgets",
"version": "3.0.1-taiko.11",
"version": "3.0.1-taiko.12",
"description": "DODO Widgets",
"source": "src/index.tsx",
"types": "dist/types/index.d.ts",
Expand Down Expand Up @@ -154,4 +154,4 @@
"ts-jest": "^29.0.1",
"typescript": "^5.6.3"
}
}
}
1 change: 1 addition & 0 deletions packages/dodoex-widgets/src/constants/pool.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const AUTO_SWAP_SLIPPAGE_PROTECTION = 'auto';
export const AUTO_LIQUIDITY_SLIPPAGE_PROTECTION = '0.1';
export const AUTO_AMM_V2_LIQUIDITY_SLIPPAGE_PROTECTION = '0.5';
export const AUTO_AMM_V3_LIQUIDITY_SLIPPAGE_PROTECTION = '0.5';

/**
* slippage protection
Expand Down
64 changes: 32 additions & 32 deletions packages/dodoex-widgets/src/locales/en-US.po
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ msgstr "{0} pending"

#: src/widgets/PoolWidget/PoolList/AddLiquidity.tsx:446
#: src/widgets/PoolWidget/PoolList/MyCreated.tsx:342
#: src/widgets/PoolWidget/PoolList/MyLiquidity.tsx:706
#: src/widgets/PoolWidget/PoolList/MyLiquidity.tsx:710
msgid "Removing"
msgstr "Removing"

Expand Down Expand Up @@ -141,7 +141,7 @@ msgstr "Unstaking"

#: src/widgets/PoolWidget/PoolList/AddLiquidity.tsx:449
#: src/widgets/PoolWidget/PoolList/MyCreated.tsx:345
#: src/widgets/PoolWidget/PoolList/MyLiquidity.tsx:709
#: src/widgets/PoolWidget/PoolList/MyLiquidity.tsx:713
msgid "Adding"
msgstr "Adding"

Expand Down Expand Up @@ -177,7 +177,7 @@ msgstr "Select Pool"
msgid "he slippage coefficient needs to be greater than or equal to 0, and less than or equal to 1."
msgstr "he slippage coefficient needs to be greater than or equal to 0, and less than or equal to 1."

#: src/widgets/PoolWidget/AMMV3/AMMV3PositionManage.tsx:536
#: src/widgets/PoolWidget/AMMV3/AMMV3PositionManage.tsx:537
#: src/widgets/PoolWidget/AMMV3/components/ReviewModal.tsx:59
msgid "Selected Range"
msgstr "Selected Range"
Expand Down Expand Up @@ -241,11 +241,11 @@ msgstr "Creation Time"
msgid "The current network is inconsistent with the wallet - please switch in wallet"
msgstr "The current network is inconsistent with the wallet - please switch in wallet"

#: src/widgets/PoolWidget/AMMV3/AddLiquidityV3.tsx:395
#: src/widgets/PoolWidget/AMMV3/AddLiquidityV3.tsx:396
msgid "Set price range"
msgstr "Set price range"

#: src/widgets/PoolWidget/AMMV3/AddLiquidityV3.tsx:411
#: src/widgets/PoolWidget/AMMV3/AddLiquidityV3.tsx:412
msgid "Full range"
msgstr "Full range"

Expand Down Expand Up @@ -471,7 +471,7 @@ msgstr "Yes, I am sure"
msgid "Add liquidity to obtain LP tokens for mining"
msgstr "Add liquidity to obtain LP tokens for mining"

#: src/widgets/PoolWidget/AMMV3/AMMV3PositionManage.tsx:560
#: src/widgets/PoolWidget/AMMV3/AMMV3PositionManage.tsx:561
msgid "Add more liquidity"
msgstr "Add more liquidity"

Expand Down Expand Up @@ -538,7 +538,7 @@ msgstr "Done"
msgid "Results in a relatively fixed price."
msgstr "Results in a relatively fixed price."

#: src/widgets/PoolWidget/AMMV3/AddLiquidityV3.tsx:520
#: src/widgets/PoolWidget/AMMV3/AddLiquidityV3.tsx:521
#: src/widgets/PoolWidget/AMMV3/components/PositionSelectedRangePreview.tsx:213
#: src/widgets/PoolWidget/AMMV3/components/PositionViewCard.tsx:233
msgid "Current price"
Expand Down Expand Up @@ -582,12 +582,12 @@ msgid "Add Initial Liquidity"
msgstr "Add Initial Liquidity"

#: src/widgets/PoolWidget/AMMV2Create/index.tsx:202
#: src/widgets/PoolWidget/AMMV3/AddLiquidityV3.tsx:251
#: src/widgets/PoolWidget/AMMV3/AddLiquidityV3.tsx:330
#: src/widgets/PoolWidget/AMMV3/AMMV3PositionManage.tsx:302
#: src/widgets/PoolWidget/AMMV3/AMMV3PositionManage.tsx:369
#: src/widgets/PoolWidget/AMMV3/AMMV3PositionManage.tsx:419
#: src/widgets/PoolWidget/AMMV3/AMMV3PositionManage.tsx:478
#: src/widgets/PoolWidget/AMMV3/AddLiquidityV3.tsx:252
#: src/widgets/PoolWidget/AMMV3/AddLiquidityV3.tsx:331
#: src/widgets/PoolWidget/AMMV3/AMMV3PositionManage.tsx:303
#: src/widgets/PoolWidget/AMMV3/AMMV3PositionManage.tsx:370
#: src/widgets/PoolWidget/AMMV3/AMMV3PositionManage.tsx:420
#: src/widgets/PoolWidget/AMMV3/AMMV3PositionManage.tsx:479
#: src/widgets/PoolWidget/AMMV3/components/ReviewModal.tsx:36
#: src/widgets/PoolWidget/hooks/useAMMV2AddLiquidity.ts:120
msgid "Add liquidity"
Expand Down Expand Up @@ -806,7 +806,7 @@ msgstr "End release time before adjustment"
#: src/widgets/MiningWidget/MiningList/operate-area/StakeButton.tsx:105
#: src/widgets/MiningWidget/OperateArea/index.tsx:72
#: src/widgets/MiningWidget/OperateArea/StakeButton.tsx:80
#: src/widgets/PoolWidget/AMMV3/AMMV3PositionManage.tsx:448
#: src/widgets/PoolWidget/AMMV3/AMMV3PositionManage.tsx:449
msgid "Stake"
msgstr "Stake"

Expand All @@ -820,15 +820,15 @@ msgstr "Price discrepancy {lqAndDodoCompareText} between liquidity pool and the
msgid "Fetching best price..."
msgstr "Fetching best price..."

#: src/widgets/PoolWidget/AMMV3/AddLiquidityV3.tsx:464
#: src/widgets/PoolWidget/AMMV3/AddLiquidityV3.tsx:465
msgid "Invalid range selected. The min price must be lower than the max price."
msgstr "Invalid range selected. The min price must be lower than the max price."

#: src/widgets/PoolWidget/PoolDetail/components/MoreDetail/LiquidityProvidersTable.tsx:91
msgid "Liquidity Provider"
msgstr "Liquidity Provider"

#: src/widgets/PoolWidget/AMMV3/AMMV3PositionManage.tsx:790
#: src/widgets/PoolWidget/AMMV3/AMMV3PositionManage.tsx:793
msgid "*Collecting fees will withdraw currently available fees for you."
msgstr "*Collecting fees will withdraw currently available fees for you."

Expand Down Expand Up @@ -929,7 +929,7 @@ msgid "The pegged exchange rate refers to the exchange rate between two token as
msgstr "The pegged exchange rate refers to the exchange rate between two token assets where one's value is pegged/fixed by the other. For example, the pegged exchange rate between the US Dollar and USDT is 1."

#: src/widgets/PoolWidget/AMMV2Create/index.tsx:271
#: src/widgets/PoolWidget/AMMV3/AddLiquidityV3.tsx:561
#: src/widgets/PoolWidget/AMMV3/AddLiquidityV3.tsx:562
msgid "Deposit amounts"
msgstr "Deposit amounts"

Expand Down Expand Up @@ -995,7 +995,7 @@ msgstr "No LP pools match your criteria"
#: src/widgets/PoolWidget/PoolList/AddLiquidity.tsx:217
#: src/widgets/PoolWidget/PoolList/AddLiquidity.tsx:554
#: src/widgets/PoolWidget/PoolList/MyLiquidity.tsx:257
#: src/widgets/PoolWidget/PoolList/MyLiquidity.tsx:809
#: src/widgets/PoolWidget/PoolList/MyLiquidity.tsx:813
msgid "Fee rate"
msgstr "Fee rate"

Expand All @@ -1011,7 +1011,7 @@ msgstr "Add Liquidity"
#: src/widgets/MiningWidget/MiningList/operate-area/UnstakeButton.tsx:85
#: src/widgets/MiningWidget/OperateArea/index.tsx:73
#: src/widgets/MiningWidget/OperateArea/UnstakeButton.tsx:70
#: src/widgets/PoolWidget/AMMV3/AMMV3PositionManage.tsx:449
#: src/widgets/PoolWidget/AMMV3/AMMV3PositionManage.tsx:450
msgid "Unstake"
msgstr "Unstake"

Expand Down Expand Up @@ -1191,7 +1191,7 @@ msgstr "Start Time"
#: src/widgets/PoolWidget/PoolList/AddLiquidity.tsx:173
#: src/widgets/PoolWidget/PoolList/AddLiquidity.tsx:604
#: src/widgets/PoolWidget/PoolList/MyLiquidity.tsx:213
#: src/widgets/PoolWidget/PoolList/MyLiquidity.tsx:863
#: src/widgets/PoolWidget/PoolList/MyLiquidity.tsx:867
#: src/widgets/PoolWidget/PoolOperate/hooks/usePoolOrMiningTabs.ts:20
msgid "Mining"
msgstr "Mining"
Expand Down Expand Up @@ -1331,7 +1331,7 @@ msgstr "Your position will be 100% composed of {0} at this price"
msgid "When adding rewards, the number of rewards for a single block may be adjusted"
msgstr "When adding rewards, the number of rewards for a single block may be adjusted"

#: src/widgets/PoolWidget/AMMV3/AddLiquidityV3.tsx:489
#: src/widgets/PoolWidget/AMMV3/AddLiquidityV3.tsx:490
msgid "This pool must be initialized before you can add liquidity. To initialize, select a starting price for the pool. Then, enter your liquidity price range and deposit amount. Gas fees will be higher than usual due to the initialization transaction."
msgstr "This pool must be initialized before you can add liquidity. To initialize, select a starting price for the pool. Then, enter your liquidity price range and deposit amount. Gas fees will be higher than usual due to the initialization transaction."

Expand Down Expand Up @@ -1488,11 +1488,11 @@ msgstr "Minutes"
msgid "Off"
msgstr "Off"

#: src/widgets/PoolWidget/AMMV3/AddLiquidityV3.tsx:459
#: src/widgets/PoolWidget/AMMV3/AddLiquidityV3.tsx:460
msgid "Your position will not earn fees or be used in trades until the market price moves into your range."
msgstr "Your position will not earn fees or be used in trades until the market price moves into your range."

#: src/widgets/PoolWidget/AMMV3/AddLiquidityV3.tsx:522
#: src/widgets/PoolWidget/AMMV3/AddLiquidityV3.tsx:523
msgid "per"
msgstr "per"

Expand Down Expand Up @@ -1744,7 +1744,7 @@ msgstr "Select Pool Version"
#: src/widgets/MiningWidget/MiningDetail/MiningInfo.tsx:465
#: src/widgets/MiningWidget/MiningList/operate-area/index.tsx:204
#: src/widgets/MiningWidget/OperateArea/index.tsx:74
#: src/widgets/PoolWidget/AMMV3/AMMV3PositionManage.tsx:450
#: src/widgets/PoolWidget/AMMV3/AMMV3PositionManage.tsx:451
msgid "Claim"
msgstr "Claim"

Expand Down Expand Up @@ -1850,7 +1850,7 @@ msgstr "Once created, the price cannot be changed. This option applies to assets

#: src/components/Swap/components/SettingsDialog/index.tsx:50
#: src/widgets/PoolWidget/AMMV2Create/Setting.tsx:100
#: src/widgets/PoolWidget/PoolOperate/components/SlippageSetting.tsx:115
#: src/widgets/PoolWidget/PoolOperate/components/SlippageSetting.tsx:122
msgid "Slippage Tolerance"
msgstr "Slippage Tolerance"

Expand All @@ -1876,7 +1876,7 @@ msgstr "My Staked"
#: src/widgets/PoolWidget/PoolList/AddLiquidity.tsx:676
#: src/widgets/PoolWidget/PoolList/MyCreated.tsx:268
#: src/widgets/PoolWidget/PoolList/MyCreated.tsx:562
#: src/widgets/PoolWidget/PoolList/MyLiquidity.tsx:1100
#: src/widgets/PoolWidget/PoolList/MyLiquidity.tsx:1104
#: src/widgets/PoolWidget/PoolOperate/AddPoolOperate.tsx:106
#: src/widgets/PoolWidget/PoolOperate/hooks/usePoolOperateTabs.ts:15
msgid "Add"
Expand Down Expand Up @@ -1928,7 +1928,7 @@ msgid "Low"
msgstr "Low"

#: src/widgets/PoolWidget/AMMV2Create/index.tsx:220
#: src/widgets/PoolWidget/AMMV3/AddLiquidityV3.tsx:366
#: src/widgets/PoolWidget/AMMV3/AddLiquidityV3.tsx:367
msgid "Select pair"
msgstr "Select pair"

Expand All @@ -1950,7 +1950,7 @@ msgstr "Do not select non-standard ERC20 tokens as this may lead to unknown erro
msgid "Create Pool"
msgstr "Create Pool"

#: src/widgets/PoolWidget/PoolList/MyLiquidity.tsx:702
#: src/widgets/PoolWidget/PoolList/MyLiquidity.tsx:701
msgid "Managing"
msgstr "Managing"

Expand Down Expand Up @@ -2115,7 +2115,7 @@ msgstr "Initial Price Alert"
#: src/widgets/PoolWidget/PoolList/MyCreated.tsx:253
#: src/widgets/PoolWidget/PoolList/MyCreated.tsx:550
#: src/widgets/PoolWidget/PoolList/MyLiquidity.tsx:543
#: src/widgets/PoolWidget/PoolList/MyLiquidity.tsx:1088
#: src/widgets/PoolWidget/PoolList/MyLiquidity.tsx:1092
#: src/widgets/PoolWidget/PoolOperate/hooks/usePoolOperateTabs.ts:16
#: src/widgets/PoolWidget/PoolOperate/RemovePoolOperate.tsx:228
msgid "Remove"
Expand All @@ -2142,7 +2142,7 @@ msgstr "SafeERC20: low-level call failed. Please contact the DODO team."
msgid "Pool Creation Confirmation"
msgstr "Pool Creation Confirmation"

#: src/widgets/PoolWidget/AMMV3/AMMV3PositionManage.tsx:765
#: src/widgets/PoolWidget/AMMV3/AMMV3PositionManage.tsx:768
msgid "Claim fees"
msgstr "Claim fees"

Expand Down Expand Up @@ -2221,7 +2221,7 @@ msgid "This trading pair does not have enough historical data and has used the d
msgstr "This trading pair does not have enough historical data and has used the default dynamic slippage."

#: src/widgets/PoolWidget/AMMV3/components/PositionViewCard.tsx:248
#: src/widgets/PoolWidget/PoolList/MyLiquidity.tsx:1100
#: src/widgets/PoolWidget/PoolList/MyLiquidity.tsx:1104
msgid "Manage"
msgstr "Manage"

Expand Down Expand Up @@ -2331,7 +2331,7 @@ msgstr "Claim Rewards"
msgid "My Pools (PMM)"
msgstr "My Pools (PMM)"

#: src/widgets/PoolWidget/AMMV3/AddLiquidityV3.tsx:478
#: src/widgets/PoolWidget/AMMV3/AddLiquidityV3.tsx:479
msgid "Starting price"
msgstr "Starting price"

Expand Down
Loading

0 comments on commit 876a206

Please sign in to comment.