xiongzhu 2 yıl önce
ebeveyn
işleme
022db46e03

+ 2 - 0
src/task/enums/task-type.enum.ts

@@ -13,5 +13,7 @@ export enum TaskType {
     removeLiquidity = 'removeLiquidity',
     addLiquiditySyncSwap = 'addLiquiditySyncSwap',
     removeLiquiditySyncSwap = 'removeLiquiditySyncSwap',
+    addLiquidityMute = 'addLiquidityMute',
+    removeLiquidityMute = 'removeLiquidityMute',
     mint = 'mint'
 }

+ 15 - 0
src/task/task.service.ts

@@ -256,6 +256,21 @@ export class TaskService implements OnModuleInit {
                         case TaskType.removeLiquiditySyncSwap:
                             web3Result = await this.web3Service.removeLiquiditySyncSwap(accountId)
                             break
+                        case TaskType.addLiquidityMute:
+                            web3Result = await this.web3Service.addLiquidityMute(
+                                accountId,
+                                taskItem.amountType === 'amount'
+                                    ? randomAmount(taskItem.amount.min, taskItem.amount.max)
+                                    : randomBalancePercent(
+                                          await this.accountsService.getZkBalance(account),
+                                          taskItem.percent.min,
+                                          taskItem.percent.max
+                                      )
+                            )
+                            break
+                        case TaskType.removeLiquidityMute:
+                            web3Result = await this.web3Service.removeLiquidityMute(accountId)
+                            break
                         case TaskType.mint:
                             web3Result = await this.web3Service.mint(accountId)
                             break

+ 2 - 8
src/web3/abi/index.ts

@@ -4,11 +4,5 @@ import SyncSwapPoolFactoryAbi from './SyncSwapClassicPoolFactory.json'
 import SyncSwapPoolAbi from './SyncSwapClassicPool.json'
 import SyncSwapRouterAbi from './SyncSwapRouter.json'
 import muteRouterAbi from './muteRouterAbi.json'
-export {
-    erc20,
-    mintSquareAbi,
-    SyncSwapPoolFactoryAbi,
-    SyncSwapPoolAbi,
-    SyncSwapRouterAbi,
-    muteRouterAbi
-}
+import mutePairAbi from './mutePairAbi.json'
+export { erc20, mintSquareAbi, SyncSwapPoolFactoryAbi, SyncSwapPoolAbi, SyncSwapRouterAbi, muteRouterAbi, mutePairAbi }

+ 1364 - 0
src/web3/abi/mutePairAbi.json

@@ -0,0 +1,1364 @@
+[
+    {
+        "inputs": [],
+        "stateMutability": "nonpayable",
+        "type": "constructor"
+    },
+    {
+        "anonymous": false,
+        "inputs": [
+            {
+                "indexed": true,
+                "internalType": "address",
+                "name": "owner",
+                "type": "address"
+            },
+            {
+                "indexed": true,
+                "internalType": "address",
+                "name": "spender",
+                "type": "address"
+            },
+            {
+                "indexed": false,
+                "internalType": "uint256",
+                "name": "value",
+                "type": "uint256"
+            }
+        ],
+        "name": "Approval",
+        "type": "event"
+    },
+    {
+        "anonymous": false,
+        "inputs": [
+            {
+                "indexed": true,
+                "internalType": "address",
+                "name": "sender",
+                "type": "address"
+            },
+            {
+                "indexed": false,
+                "internalType": "uint256",
+                "name": "amount0",
+                "type": "uint256"
+            },
+            {
+                "indexed": false,
+                "internalType": "uint256",
+                "name": "amount1",
+                "type": "uint256"
+            },
+            {
+                "indexed": true,
+                "internalType": "address",
+                "name": "to",
+                "type": "address"
+            }
+        ],
+        "name": "Burn",
+        "type": "event"
+    },
+    {
+        "anonymous": false,
+        "inputs": [
+            {
+                "indexed": false,
+                "internalType": "uint256",
+                "name": "pairFee",
+                "type": "uint256"
+            },
+            {
+                "indexed": false,
+                "internalType": "uint256",
+                "name": "liqFee",
+                "type": "uint256"
+            }
+        ],
+        "name": "ChangeFee",
+        "type": "event"
+    },
+    {
+        "anonymous": false,
+        "inputs": [
+            {
+                "indexed": true,
+                "internalType": "address",
+                "name": "sender",
+                "type": "address"
+            },
+            {
+                "indexed": true,
+                "internalType": "address",
+                "name": "recipient",
+                "type": "address"
+            },
+            {
+                "indexed": false,
+                "internalType": "uint256",
+                "name": "amount0",
+                "type": "uint256"
+            },
+            {
+                "indexed": false,
+                "internalType": "uint256",
+                "name": "amount1",
+                "type": "uint256"
+            }
+        ],
+        "name": "Claim",
+        "type": "event"
+    },
+    {
+        "anonymous": false,
+        "inputs": [
+            {
+                "indexed": true,
+                "internalType": "address",
+                "name": "delegator",
+                "type": "address"
+            },
+            {
+                "indexed": true,
+                "internalType": "address",
+                "name": "fromDelegate",
+                "type": "address"
+            },
+            {
+                "indexed": true,
+                "internalType": "address",
+                "name": "toDelegate",
+                "type": "address"
+            }
+        ],
+        "name": "DelegateChanged",
+        "type": "event"
+    },
+    {
+        "anonymous": false,
+        "inputs": [
+            {
+                "indexed": true,
+                "internalType": "address",
+                "name": "delegate",
+                "type": "address"
+            },
+            {
+                "indexed": false,
+                "internalType": "uint256",
+                "name": "previousBalance",
+                "type": "uint256"
+            },
+            {
+                "indexed": false,
+                "internalType": "uint256",
+                "name": "newBalance",
+                "type": "uint256"
+            }
+        ],
+        "name": "DelegateVotesChanged",
+        "type": "event"
+    },
+    {
+        "anonymous": false,
+        "inputs": [
+            {
+                "indexed": true,
+                "internalType": "address",
+                "name": "sender",
+                "type": "address"
+            },
+            {
+                "indexed": false,
+                "internalType": "uint256",
+                "name": "amount0",
+                "type": "uint256"
+            },
+            {
+                "indexed": false,
+                "internalType": "uint256",
+                "name": "amount1",
+                "type": "uint256"
+            },
+            {
+                "indexed": false,
+                "internalType": "uint256",
+                "name": "pAmount0",
+                "type": "uint256"
+            },
+            {
+                "indexed": false,
+                "internalType": "uint256",
+                "name": "pAmount1",
+                "type": "uint256"
+            }
+        ],
+        "name": "Fees",
+        "type": "event"
+    },
+    {
+        "anonymous": false,
+        "inputs": [
+            {
+                "indexed": true,
+                "internalType": "address",
+                "name": "sender",
+                "type": "address"
+            },
+            {
+                "indexed": false,
+                "internalType": "uint256",
+                "name": "amount0",
+                "type": "uint256"
+            },
+            {
+                "indexed": false,
+                "internalType": "uint256",
+                "name": "amount1",
+                "type": "uint256"
+            }
+        ],
+        "name": "Mint",
+        "type": "event"
+    },
+    {
+        "anonymous": false,
+        "inputs": [
+            {
+                "indexed": true,
+                "internalType": "address",
+                "name": "sender",
+                "type": "address"
+            },
+            {
+                "indexed": false,
+                "internalType": "uint256",
+                "name": "amount0In",
+                "type": "uint256"
+            },
+            {
+                "indexed": false,
+                "internalType": "uint256",
+                "name": "amount1In",
+                "type": "uint256"
+            },
+            {
+                "indexed": false,
+                "internalType": "uint256",
+                "name": "amount0Out",
+                "type": "uint256"
+            },
+            {
+                "indexed": false,
+                "internalType": "uint256",
+                "name": "amount1Out",
+                "type": "uint256"
+            },
+            {
+                "indexed": true,
+                "internalType": "address",
+                "name": "to",
+                "type": "address"
+            }
+        ],
+        "name": "Swap",
+        "type": "event"
+    },
+    {
+        "anonymous": false,
+        "inputs": [
+            {
+                "indexed": false,
+                "internalType": "uint256",
+                "name": "reserve0",
+                "type": "uint256"
+            },
+            {
+                "indexed": false,
+                "internalType": "uint256",
+                "name": "reserve1",
+                "type": "uint256"
+            }
+        ],
+        "name": "Sync",
+        "type": "event"
+    },
+    {
+        "anonymous": false,
+        "inputs": [
+            {
+                "indexed": true,
+                "internalType": "address",
+                "name": "from",
+                "type": "address"
+            },
+            {
+                "indexed": true,
+                "internalType": "address",
+                "name": "to",
+                "type": "address"
+            },
+            {
+                "indexed": false,
+                "internalType": "uint256",
+                "name": "value",
+                "type": "uint256"
+            }
+        ],
+        "name": "Transfer",
+        "type": "event"
+    },
+    {
+        "stateMutability": "payable",
+        "type": "fallback"
+    },
+    {
+        "inputs": [],
+        "name": "DOMAIN_SEPARATOR",
+        "outputs": [
+            {
+                "internalType": "bytes32",
+                "name": "",
+                "type": "bytes32"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "MINIMUM_LIQUIDITY",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "",
+                "type": "address"
+            },
+            {
+                "internalType": "address",
+                "name": "",
+                "type": "address"
+            }
+        ],
+        "name": "allowance",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "spender",
+                "type": "address"
+            },
+            {
+                "internalType": "uint256",
+                "name": "value",
+                "type": "uint256"
+            }
+        ],
+        "name": "approve",
+        "outputs": [
+            {
+                "internalType": "bool",
+                "name": "",
+                "type": "bool"
+            }
+        ],
+        "stateMutability": "nonpayable",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "",
+                "type": "address"
+            }
+        ],
+        "name": "balanceOf",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "to",
+                "type": "address"
+            }
+        ],
+        "name": "burn",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "amount0",
+                "type": "uint256"
+            },
+            {
+                "internalType": "uint256",
+                "name": "amount1",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "nonpayable",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "uint256",
+                "name": "_fee",
+                "type": "uint256"
+            }
+        ],
+        "name": "changeFeeType",
+        "outputs": [],
+        "stateMutability": "nonpayable",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "",
+                "type": "address"
+            },
+            {
+                "internalType": "uint32",
+                "name": "",
+                "type": "uint32"
+            }
+        ],
+        "name": "checkpoints",
+        "outputs": [
+            {
+                "internalType": "uint32",
+                "name": "fromBlock",
+                "type": "uint32"
+            },
+            {
+                "internalType": "uint256",
+                "name": "votes",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "claimFees",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "claimed0",
+                "type": "uint256"
+            },
+            {
+                "internalType": "uint256",
+                "name": "claimed1",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "nonpayable",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "",
+                "type": "address"
+            }
+        ],
+        "name": "claimable0",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "",
+                "type": "address"
+            }
+        ],
+        "name": "claimable1",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "tokenIn",
+                "type": "address"
+            },
+            {
+                "internalType": "uint256",
+                "name": "amountIn",
+                "type": "uint256"
+            }
+        ],
+        "name": "current",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "amountOut",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "currentCumulativePrices",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "reserve0Cumulative",
+                "type": "uint256"
+            },
+            {
+                "internalType": "uint256",
+                "name": "reserve1Cumulative",
+                "type": "uint256"
+            },
+            {
+                "internalType": "uint256",
+                "name": "blockTimestamp",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "decimals",
+        "outputs": [
+            {
+                "internalType": "uint8",
+                "name": "",
+                "type": "uint8"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "delegatee",
+                "type": "address"
+            }
+        ],
+        "name": "delegate",
+        "outputs": [],
+        "stateMutability": "nonpayable",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "delegator",
+                "type": "address"
+            }
+        ],
+        "name": "delegates",
+        "outputs": [
+            {
+                "internalType": "address",
+                "name": "",
+                "type": "address"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "factory",
+        "outputs": [
+            {
+                "internalType": "address",
+                "name": "",
+                "type": "address"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "fees",
+        "outputs": [
+            {
+                "internalType": "address",
+                "name": "",
+                "type": "address"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "uint256",
+                "name": "amountIn",
+                "type": "uint256"
+            },
+            {
+                "internalType": "address",
+                "name": "tokenIn",
+                "type": "address"
+            }
+        ],
+        "name": "getAmountOut",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "account",
+                "type": "address"
+            }
+        ],
+        "name": "getCurrentVotes",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "account",
+                "type": "address"
+            },
+            {
+                "internalType": "uint256",
+                "name": "blockNumber",
+                "type": "uint256"
+            }
+        ],
+        "name": "getPriorVotes",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "getReserves",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "_reserve0",
+                "type": "uint256"
+            },
+            {
+                "internalType": "uint256",
+                "name": "_reserve1",
+                "type": "uint256"
+            },
+            {
+                "internalType": "uint256",
+                "name": "_blockTimestampLast",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "index0",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "index1",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "_token0",
+                "type": "address"
+            },
+            {
+                "internalType": "address",
+                "name": "_token1",
+                "type": "address"
+            },
+            {
+                "internalType": "uint256",
+                "name": "_fee",
+                "type": "uint256"
+            },
+            {
+                "internalType": "bool",
+                "name": "_stable",
+                "type": "bool"
+            }
+        ],
+        "name": "initialize",
+        "outputs": [],
+        "stateMutability": "nonpayable",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "lastObservation",
+        "outputs": [
+            {
+                "components": [
+                    {
+                        "internalType": "uint256",
+                        "name": "timestamp",
+                        "type": "uint256"
+                    },
+                    {
+                        "internalType": "uint256",
+                        "name": "reserve0Cumulative",
+                        "type": "uint256"
+                    },
+                    {
+                        "internalType": "uint256",
+                        "name": "reserve1Cumulative",
+                        "type": "uint256"
+                    }
+                ],
+                "internalType": "struct MuteSwitchPairDynamic.Observation",
+                "name": "",
+                "type": "tuple"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "metadata",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "dec0",
+                "type": "uint256"
+            },
+            {
+                "internalType": "uint256",
+                "name": "dec1",
+                "type": "uint256"
+            },
+            {
+                "internalType": "uint256",
+                "name": "r0",
+                "type": "uint256"
+            },
+            {
+                "internalType": "uint256",
+                "name": "r1",
+                "type": "uint256"
+            },
+            {
+                "internalType": "bool",
+                "name": "st",
+                "type": "bool"
+            },
+            {
+                "internalType": "address",
+                "name": "t0",
+                "type": "address"
+            },
+            {
+                "internalType": "address",
+                "name": "t1",
+                "type": "address"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "to",
+                "type": "address"
+            }
+        ],
+        "name": "mint",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "liquidity",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "nonpayable",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "name",
+        "outputs": [
+            {
+                "internalType": "string",
+                "name": "",
+                "type": "string"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "",
+                "type": "address"
+            }
+        ],
+        "name": "nonces",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "",
+                "type": "address"
+            }
+        ],
+        "name": "numCheckpoints",
+        "outputs": [
+            {
+                "internalType": "uint32",
+                "name": "",
+                "type": "uint32"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "observationLength",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "uint256",
+                "name": "",
+                "type": "uint256"
+            }
+        ],
+        "name": "observations",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "timestamp",
+                "type": "uint256"
+            },
+            {
+                "internalType": "uint256",
+                "name": "reserve0Cumulative",
+                "type": "uint256"
+            },
+            {
+                "internalType": "uint256",
+                "name": "reserve1Cumulative",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "pairFee",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "owner",
+                "type": "address"
+            },
+            {
+                "internalType": "address",
+                "name": "spender",
+                "type": "address"
+            },
+            {
+                "internalType": "uint256",
+                "name": "value",
+                "type": "uint256"
+            },
+            {
+                "internalType": "uint256",
+                "name": "deadline",
+                "type": "uint256"
+            },
+            {
+                "internalType": "bytes",
+                "name": "sig",
+                "type": "bytes"
+            }
+        ],
+        "name": "permit",
+        "outputs": [],
+        "stateMutability": "nonpayable",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "tokenIn",
+                "type": "address"
+            },
+            {
+                "internalType": "uint256",
+                "name": "amountIn",
+                "type": "uint256"
+            },
+            {
+                "internalType": "uint256",
+                "name": "points",
+                "type": "uint256"
+            }
+        ],
+        "name": "prices",
+        "outputs": [
+            {
+                "internalType": "uint256[]",
+                "name": "",
+                "type": "uint256[]"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "tokenIn",
+                "type": "address"
+            },
+            {
+                "internalType": "uint256",
+                "name": "amountIn",
+                "type": "uint256"
+            },
+            {
+                "internalType": "uint256",
+                "name": "granularity",
+                "type": "uint256"
+            }
+        ],
+        "name": "quote",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "amountOut",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "reserve0CumulativeLast",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "reserve1CumulativeLast",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "tokenIn",
+                "type": "address"
+            },
+            {
+                "internalType": "uint256",
+                "name": "amountIn",
+                "type": "uint256"
+            },
+            {
+                "internalType": "uint256",
+                "name": "points",
+                "type": "uint256"
+            },
+            {
+                "internalType": "uint256",
+                "name": "window",
+                "type": "uint256"
+            }
+        ],
+        "name": "sample",
+        "outputs": [
+            {
+                "internalType": "uint256[]",
+                "name": "",
+                "type": "uint256[]"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "to",
+                "type": "address"
+            }
+        ],
+        "name": "skim",
+        "outputs": [],
+        "stateMutability": "nonpayable",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "stable",
+        "outputs": [
+            {
+                "internalType": "bool",
+                "name": "",
+                "type": "bool"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "",
+                "type": "address"
+            }
+        ],
+        "name": "supplyIndex0",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "",
+                "type": "address"
+            }
+        ],
+        "name": "supplyIndex1",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "uint256",
+                "name": "amount0Out",
+                "type": "uint256"
+            },
+            {
+                "internalType": "uint256",
+                "name": "amount1Out",
+                "type": "uint256"
+            },
+            {
+                "internalType": "address",
+                "name": "to",
+                "type": "address"
+            },
+            {
+                "internalType": "bytes",
+                "name": "data",
+                "type": "bytes"
+            }
+        ],
+        "name": "swap",
+        "outputs": [],
+        "stateMutability": "nonpayable",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "symbol",
+        "outputs": [
+            {
+                "internalType": "string",
+                "name": "",
+                "type": "string"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "sync",
+        "outputs": [],
+        "stateMutability": "nonpayable",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "token0",
+        "outputs": [
+            {
+                "internalType": "address",
+                "name": "",
+                "type": "address"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "token1",
+        "outputs": [
+            {
+                "internalType": "address",
+                "name": "",
+                "type": "address"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "tokens",
+        "outputs": [
+            {
+                "internalType": "address",
+                "name": "",
+                "type": "address"
+            },
+            {
+                "internalType": "address",
+                "name": "",
+                "type": "address"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "totalSupply",
+        "outputs": [
+            {
+                "internalType": "uint256",
+                "name": "",
+                "type": "uint256"
+            }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "to",
+                "type": "address"
+            },
+            {
+                "internalType": "uint256",
+                "name": "value",
+                "type": "uint256"
+            }
+        ],
+        "name": "transfer",
+        "outputs": [
+            {
+                "internalType": "bool",
+                "name": "",
+                "type": "bool"
+            }
+        ],
+        "stateMutability": "nonpayable",
+        "type": "function"
+    },
+    {
+        "inputs": [
+            {
+                "internalType": "address",
+                "name": "from",
+                "type": "address"
+            },
+            {
+                "internalType": "address",
+                "name": "to",
+                "type": "address"
+            },
+            {
+                "internalType": "uint256",
+                "name": "value",
+                "type": "uint256"
+            }
+        ],
+        "name": "transferFrom",
+        "outputs": [
+            {
+                "internalType": "bool",
+                "name": "",
+                "type": "bool"
+            }
+        ],
+        "stateMutability": "nonpayable",
+        "type": "function"
+    }
+]

+ 128 - 30
src/web3/web3.service.ts

@@ -44,7 +44,15 @@ import { FileService } from 'src/file/file.service'
 import axios from 'axios'
 import * as randomString from 'randomstring'
 import { Account } from '../accounts/entities/account.entity'
-import { erc20, mintSquareAbi, SyncSwapPoolFactoryAbi, SyncSwapPoolAbi, SyncSwapRouterAbi, muteRouterAbi } from './abi'
+import {
+    erc20,
+    mintSquareAbi,
+    SyncSwapPoolFactoryAbi,
+    SyncSwapPoolAbi,
+    SyncSwapRouterAbi,
+    muteRouterAbi,
+    mutePairAbi
+} from './abi'
 
 @Injectable()
 export class Web3Service {
@@ -329,47 +337,50 @@ export class Web3Service {
         return new Web3Result(account.address, tx.hash, config, true)
     }
 
-    async removeLiquiditySyncSwap(accountId) {
+    async addLiquidityMute(accountId, amount) {
         const account = await this.accountService.findById(accountId)
         const config = web3Config[account.network]
         const provider = new Provider(config.zksyncRpcUrl)
         const zkWallet = new Wallet(account.privateKey).connect(provider)
         const web3 = new Web3(new Web3.providers.HttpProvider(config.zksyncRpcUrl))
 
-        const poolFactory = new web3.eth.Contract(SyncSwapPoolFactoryAbi, config.syncSwapPoolFactoryAddress)
+        const muteRouter = new web3.eth.Contract(muteRouterAbi, config.muteRouterAddress)
+        const wethAddress = await muteRouter.methods.WETH().call()
         // @ts-ignore
-        const poolAddress = await poolFactory.methods.getPool(config.syncSwapWethAddress, config.zkUsdcAddress).call()
-        Logger.log(`poolAddress: ${poolAddress}`, 'removeLiquiditySyncSwap')
+        const pairInfo = await muteRouter.methods.getPairInfo([wethAddress, config.zkUsdcAddress], false).call()
 
-        const pool = new web3.eth.Contract(SyncSwapPoolAbi, poolAddress as unknown as string)
-        // @ts-ignore
-        const liquidity = await pool.methods.balanceOf(zkWallet.address).call()
-        Logger.log(`liquidity: ${liquidity}`, 'removeLiquiditySyncSwap')
+        const amountA = ethers.utils.parseEther(amount)
+        const amountB = ethers.BigNumber.from(
+            // @ts-ignore
+            await muteRouter.methods.quote(amountA.toBigInt(), pairInfo.reserveA, pairInfo.reserveB).call()
+        )
+        Logger.log(
+            `amountA: ${ethers.utils.formatUnits(amountA, 18)}, amountB: ${ethers.utils.formatUnits(amountB, 6)}`,
+            'addLiquidityMute'
+        )
 
-        const router = new web3.eth.Contract(SyncSwapRouterAbi, config.syncSwapRouterAddress)
-        const burnLiquiditySingle = router.methods.burnLiquiditySingle(
+        const addLiquidity = await muteRouter.methods.addLiquidityETH(
             // @ts-ignore
-            poolAddress,
-            liquidity,
-            ethers.utils.defaultAbiCoder.encode(
-                ['uint256', 'uint256', 'uint8'],
-                [ethers.constants.AddressZero, zkWallet.address, '0']
-            ),
-            '0',
-            ethers.constants.AddressZero,
-            '0x'
+            config.zkUsdcAddress,
+            amountB.toBigInt(),
+            amountB.mul('985').div(1000).toBigInt(),
+            amountA.mul('985').div(1000).toBigInt(),
+            zkWallet.address,
+            Math.floor(new Date().getTime() / 1000 + 60 * 30) + '',
+            0,
+            false
         )
-        const gasLimit = await burnLiquiditySingle.estimateGas({
-            from: zkWallet.address
-        })
+        const gasLimit = await addLiquidity.estimateGas({ from: zkWallet.address, value: amountA.toHexString() })
         const tx = await zkWallet.sendTransaction({
-            to: config.syncSwapRouterAddress,
-            data: burnLiquiditySingle.encodeABI(),
-            gasLimit
+            to: config.muteRouterAddress,
+            data: addLiquidity.encodeABI(),
+            value: amountA.toHexString(),
+            gasLimit: gasLimit
         })
-        Logger.log(`transaction sent: ${tx.hash}`, 'removeLiquiditySyncSwap')
-        account.removeLiuidityNum = (account.removeLiuidityNum || 0) + 1
-        account.lastRemoveLiuidity = new Date()
+
+        Logger.log(`transaction sent: ${tx.hash}`, 'addLiquidityMute')
+        account.addLiuidityNum = (account.addLiuidityNum || 0) + 1
+        account.lastAddLiuidity = new Date()
         await this.accountService.save([account])
         return new Web3Result(account.address, tx.hash, config, true)
     }
@@ -439,13 +450,100 @@ export class Web3Service {
             data: decLiquidityCalling.encodeABI(),
             gasLimit
         })
-        console.log('decLiquidityCalling tx: ', JSON.stringify(tx0, null, 4))
+        Logger.log(`transaction sent: ${tx0.hash}`, 'removeLiquidity')
         account.removeLiuidityNum = (account.removeLiuidityNum || 0) + 1
         account.lastRemoveLiuidity = new Date()
         await this.accountService.save([account])
         return new Web3Result(account.address, tx0.hash, web3Config[account.network], true)
     }
 
+    async removeLiquiditySyncSwap(accountId) {
+        const account = await this.accountService.findById(accountId)
+        const config = web3Config[account.network]
+        const provider = new Provider(config.zksyncRpcUrl)
+        const zkWallet = new Wallet(account.privateKey).connect(provider)
+        const web3 = new Web3(new Web3.providers.HttpProvider(config.zksyncRpcUrl))
+
+        const poolFactory = new web3.eth.Contract(SyncSwapPoolFactoryAbi, config.syncSwapPoolFactoryAddress)
+        // @ts-ignore
+        const poolAddress = await poolFactory.methods.getPool(config.syncSwapWethAddress, config.zkUsdcAddress).call()
+        Logger.log(`poolAddress: ${poolAddress}`, 'removeLiquiditySyncSwap')
+
+        const pool = new web3.eth.Contract(SyncSwapPoolAbi, poolAddress as unknown as string)
+        // @ts-ignore
+        const liquidity = await pool.methods.balanceOf(zkWallet.address).call()
+        Logger.log(`liquidity: ${liquidity}`, 'removeLiquiditySyncSwap')
+
+        const router = new web3.eth.Contract(SyncSwapRouterAbi, config.syncSwapRouterAddress)
+        const burnLiquiditySingle = router.methods.burnLiquiditySingle(
+            // @ts-ignore
+            poolAddress,
+            liquidity,
+            ethers.utils.defaultAbiCoder.encode(
+                ['uint256', 'uint256', 'uint8'],
+                [ethers.constants.AddressZero, zkWallet.address, '0']
+            ),
+            '0',
+            ethers.constants.AddressZero,
+            '0x'
+        )
+        const gasLimit = await burnLiquiditySingle.estimateGas({
+            from: zkWallet.address
+        })
+        const tx = await zkWallet.sendTransaction({
+            to: config.syncSwapRouterAddress,
+            data: burnLiquiditySingle.encodeABI(),
+            gasLimit
+        })
+        Logger.log(`transaction sent: ${tx.hash}`, 'removeLiquiditySyncSwap')
+        account.removeLiuidityNum = (account.removeLiuidityNum || 0) + 1
+        account.lastRemoveLiuidity = new Date()
+        await this.accountService.save([account])
+        return new Web3Result(account.address, tx.hash, config, true)
+    }
+
+    async removeLiquidityMute(accountId) {
+        const account = await this.accountService.findById(accountId)
+        const config = web3Config[account.network]
+        const provider = new Provider(config.zksyncRpcUrl)
+        const zkWallet = new Wallet(account.privateKey).connect(provider)
+        const web3 = new Web3(new Web3.providers.HttpProvider(config.zksyncRpcUrl))
+
+        const muteRouter = new web3.eth.Contract(muteRouterAbi, config.muteRouterAddress)
+        const wethAddress = await muteRouter.methods.WETH().call()
+        // @ts-ignore
+        const pairInfo = await muteRouter.methods.getPairInfo([wethAddress, config.zkUsdcAddress], false).call()
+        const pair = new web3.eth.Contract(mutePairAbi, (pairInfo as unknown as any).pair)
+        // @ts-ignore
+        const liquidity = await pair.methods.balanceOf(zkWallet.address).call()
+        Logger.log(`liquidity: ${liquidity}`, 'removeLiquidityMute')
+
+        await this.approve((pairInfo as unknown as any).pair, config.muteRouterAddress, zkWallet, account.network)
+
+        const removeLiquidity = await muteRouter.methods.removeLiquidityETHSupportingFeeOnTransferTokens(
+            // @ts-ignore
+            config.zkUsdcAddress,
+            ethers.BigNumber.from(liquidity).toHexString(),
+            1,
+            1,
+            zkWallet.address,
+            Math.floor(new Date().getTime() / 1000 + 60 * 30) + '',
+            false
+        )
+        const gasLimit = await removeLiquidity.estimateGas({ from: zkWallet.address })
+        const tx = await zkWallet.sendTransaction({
+            to: config.muteRouterAddress,
+            data: removeLiquidity.encodeABI(),
+            gasLimit: gasLimit
+        })
+
+        Logger.log(`transaction sent: ${tx.hash}`, 'removeLiquidityMute')
+        account.removeLiuidityNum = (account.removeLiuidityNum || 0) + 1
+        account.lastRemoveLiuidity = new Date()
+        await this.accountService.save([account])
+        return new Web3Result(account.address, tx.hash, config, true)
+    }
+
     async allowance(tokenAddress, spender, wallet: Wallet, network: Network): Promise<number> {
         const web3 = new Web3(new Web3.providers.HttpProvider(web3Config[network].zksyncRpcUrl))
         const tokenAContract = new web3.eth.Contract(erc20, tokenAddress)