Skip to content

Commit

Permalink
Merge pull request #9 from icon-project/fix/audit-issues
Browse files Browse the repository at this point in the history
fix: Add check for zero value in tokenFallback
  • Loading branch information
AntonAndell authored Feb 16, 2024
2 parents 43bab7e + b9162bd commit a544e62
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

public class Errors {
public static final String TOKEN_FALLBACK_DATA_EMPTY = "Token Fallback: Data can't be empty";
public static final String TOKEN_FALLBACK_ZERO_VALUE = "Token Fallback: Value can't be zero";
public static final String IRC31_METHOD_NOT_FOUND = "IRC31: method not found";
public static final String ORDER_LIMIT_REACHED = "Order is above configured limit";
public static final String LP_OVER_SLIPPAGE_LIMIT = "The price of the liquidity pool is to far off the oracle price of supplied assets";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class NetworkOwnedLiquidity implements INetworkOwnedLiquidity {

public static final BigInteger DEFAULT_ORDER_PERIOD = BLOCKS_IN_A_MONTH;
public static final BigInteger DEFAULT_SWAP_REWARDS = BigInteger.valueOf(100); // 1%
public static final BigInteger DEFAULT_LP_SLIPPAGE = BigInteger.valueOf(200); // 2%
public static final BigInteger DEFAULT_LP_SLIPPAGE = BigInteger.valueOf(100); // 1%

public NetworkOwnedLiquidity(Address _balancedDex, Address _balancedOracle) {
balancedDex.set(_balancedDex);
Expand Down Expand Up @@ -227,6 +227,7 @@ public BigInteger calculateICXReward(BigInteger pid, BigInteger amount) {
public void onIRC31Received(Address _operator, Address _from, BigInteger _id, BigInteger _value, byte[] _data) {
only(getBalancedDex());
String unpackedData = new String(_data);
Context.require(_value.compareTo(BigInteger.ZERO) > 0, Errors.TOKEN_FALLBACK_ZERO_VALUE);
Context.require(!unpackedData.equals(""), Errors.TOKEN_FALLBACK_DATA_EMPTY);

JsonObject json = Json.parse(unpackedData).asObject();
Expand Down

0 comments on commit a544e62

Please sign in to comment.