Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add check for zero value in tokenFallback #9

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading