Skip to content

Commit b9162bd

Browse files
committed
fix: Add check for zero value in tokenFallback
1 parent 43bab7e commit b9162bd

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

network-owned-liquidity/src/main/java/icon/inflation/score/nol/Errors.java

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
public class Errors {
55
public static final String TOKEN_FALLBACK_DATA_EMPTY = "Token Fallback: Data can't be empty";
6+
public static final String TOKEN_FALLBACK_ZERO_VALUE = "Token Fallback: Value can't be zero";
67
public static final String IRC31_METHOD_NOT_FOUND = "IRC31: method not found";
78
public static final String ORDER_LIMIT_REACHED = "Order is above configured limit";
89
public static final String LP_OVER_SLIPPAGE_LIMIT = "The price of the liquidity pool is to far off the oracle price of supplied assets";

network-owned-liquidity/src/main/java/icon/inflation/score/nol/NetworkOwnedLiquidity.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class NetworkOwnedLiquidity implements INetworkOwnedLiquidity {
4444

4545
public static final BigInteger DEFAULT_ORDER_PERIOD = BLOCKS_IN_A_MONTH;
4646
public static final BigInteger DEFAULT_SWAP_REWARDS = BigInteger.valueOf(100); // 1%
47-
public static final BigInteger DEFAULT_LP_SLIPPAGE = BigInteger.valueOf(200); // 2%
47+
public static final BigInteger DEFAULT_LP_SLIPPAGE = BigInteger.valueOf(100); // 1%
4848

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

232233
JsonObject json = Json.parse(unpackedData).asObject();

0 commit comments

Comments
 (0)