OKC Swap

CertiKFiles named in the report

CertiK reviewed OKX (OKC Swap) on 13 Dec 2022: 9 findings, 0 critical; 2 acknowledged, 7 open.

No open critical findings
Open the reportOpen OKX’s security record

Report hosted on skynet.certik.com.

Trustblock does not review code.

Findings9

Statuses are the security firm’s own, from its report.

SeverityOpenAcknowledgedFixed
Critical000
High010
Medium010
Low700
HighCentralization Related RisksAcknowledged

In the contract `StakingRewards`, the role `rewardsDistribution` has authority over the functions shown in the diagram below. Any compromise to the `rewardsDistribution` account may allow the hacker to take advantage of this authority and change the amount of rewards or the reward duration. ![](https://accelerator-tasks-prod.acc.corp.certik.com/009df8265b654454a8173f122fa7002e/diagrams/centralization_StakingRewards-StakingRewards-rewardsDistribution.svg) In the contract `StakingRewardsFactory`, the role `_owner` has authority over the functions shown in the diagram below. Any compromise to the `_owner` account may allow the hacker to take advantage of this authority and change the amount of rewards or the reward duration for staking contracts. ![](https://accelerator-tasks-prod.acc.corp.certik.com/009df8265b654454a8173f122fa7002e/diagrams/centralization_StakingRewardsFactory-StakingRewardsFactory-_owner.svg) In the contract `OKCSwapFactory`, the role `feeToSetter` has authority over the functions shown in the diagram below. Any compromise to the `feeToSetter` account may allow the hacker to take advantage of this authority and change the amount of liquidity fees as well as change the fee recipient. ![](https://accelerator-tasks-prod.acc.corp.certik.com/009df8265b654454a8173f122fa7002e/diagrams/centralization_OKCSwapFactory-OKCSwapFactory-feeToSetter.svg) In the contract `OKCSwapPair` the role `factory` has authority over the functions shown in the diagram below. Any compromise to the `factory` account may allow the hacker to take advantage of this authority and initialize the incorrect tokens for the pair. ![](https://accelerator-tasks-prod.acc.corp.certik.com/009df8265b654454a8173f122fa7002e/diagrams/centralization_OKCSwapPair-OKCSwapPair-factory.svg)

MediumIncompatibility with Deflationary TokensAcknowledged

When transferring deflationary ERC20 tokens, the input amount may not be equal to the received amount due to the charged transaction fee. For example, if a user sends 100 deflationary tokens (with a 10% transaction fee), only 90 tokens actually arrived to the contract. However, a failure to discount such fees may allow the same user to withdraw 100 tokens from the contract, which causes the contract to lose 10 tokens in such a transaction. Reference: https://thoreum-finance.medium.com/what-exploit-happened-today-for-gocerberus-and-garuda-also-for-lokum-ybear-piggy-caramelswap-3943ee23a39f ```solidity=90 stakingToken.safeTransferFrom(msg.sender, address(this), amount); ``` - Transferring tokens by `amount`. ```solidity=85 _balances[msg.sender] = _balances[msg.sender].add(amount); ``` - The `amount` is used for bookkeeping purposes without compensating for potential transfer fees. --- ```solidity=98 stakingToken.safeTransferFrom(msg.sender, address(this), amount); ``` - Transferring tokens by `amount`. ```solidity=97 _balances[msg.sender] = _balances[msg.sender].add(amount); ``` - The `amount` is used for bookkeeping purposes without compensating for potential transfer fees. --- ```solidity=45 require( rewardsToken.transfer(stakingRewards, rewardAmount), 'StakingRewardsFactory::notifyRewardAmount: transfer failed' ); ``` - Transferring tokens by `rewardAmount`. ```solidity=49 StakingRewards(stakingRewards).notifyRewardAmount(rewardAmount,rewardsDuration); ``` - The `rewardAmount` is used for bookkeeping purposes without compensating for potential transfer fees. ### Proof of Concept The following unit test created using `forge` demonstrates the issue by performing the following: 1. A deflationary ERC20 token is created where when transferring tokens, only 90% of the inputted amount is transferred 2. The test mints 100 tokens to the contract and the contract stakes 100 tokens 3. The staking balance is compared with ERC20 balance of the staking contract 4. The test fails as expected as the staking balance is 100 while the ERC20 balance is 90 ```solidity pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "forge-std/Test.sol"; import {mockERC20} from "../src/mocks/mockERC20.sol"; import {mockWETH} from "../src/mocks/mockWETH.sol"; import {StakingRewards} from "../src/farm/StakingRewards.sol"; contract DeflationaryERC20 is mockERC20 { function _transfer(address sender, address recipient, uint256 amount) internal override { amount = amount * 9 / 10; super._transfer(sender, recipient, amount); } } contract StakingRewardsTest is Test { StakingRewards public stakingRewards; DeflationaryERC20 public mockToken; mockWETH public WETH; function setUp() public { mockToken = new DeflationaryERC20(); WETH = new mockWETH(); stakingRewards = new StakingRewards(address(mockToken), address(WETH)); } function testStakeDeflationary() public { mockToken.mint(address(this), 100); mockToken.approve(address(stakingRewards), 100); stakingRewards.stake(100); uint256 balance = stakingRewards.balanceOf(address(this)); uint256 actualBalance = mockToken.balanceOf(address(stakingRewards)); assertFalse(actualBalance == balance); } } ```

Contracts in scope

No deployed address is recorded for this audit.

The report names a repository or files. Open the report to see its scope.

Repository and files the report names (23)

  • contracts/libraries/OKCSwapOracleLibrary.sol
  • contracts/pair/OKCSwapFactory.sol
  • contracts/interfaces/IOKCSwapCallee.sol
  • contracts/interfaces/IOKCSwapRouter01.sol
  • contracts/libraries/UQ112x112.sol
  • contracts/libraries/RewardsDistributionRecipient.sol
  • contracts/interfaces/IWOKT.sol
  • contracts/pair/OKCSwapPair.sol
  • contracts/libraries/SafeMath.sol
  • contracts/interfaces/IOKCSwapPair.sol
  • contracts/farm/TimeLock.sol
  • contracts/farm/StakingRewardsFactory.sol
  • contracts/libraries/TransferHelper.sol
  • contracts/interfaces/IOKCSwapFactory.sol
  • contracts/libraries/Math.sol
  • contracts/interfaces/IERC20.sol
  • contracts/libraries/OKCSwapLibrary.sol
  • contracts/farm/StakingRewards.sol
  • contracts/interfaces/IOKCSwapERC20.sol
  • contracts/router/OKCSwapRouter02.sol
  • contracts/interfaces/IStakingRewards.sol
  • contracts/pair/OKCSwapERC20.sol
  • contracts/interfaces/IOKCSwapRouter02.sol

Part of OKX’s security record

OKX
Audits5 audits by 1 firmLast audit May 2024, by CertiK.
Critical findingsNo open critical findingsAcross the 5 reports, 1 critical finding was reported. It is marked fixed by the firm that reported it.
IncidentIncident 12 Dec 2023Source: De.Fi incident database.
Open OKX’s security record

Security firm

CertiK

1,044 projects reviewed · 1,375 reports · latest May 2025

See CertiK’s audits

Something wrong on this page? A missing report, a wrong date, a finding that was fixed since. Tell us and we check it against its source.

Tell us