diff --git a/Swap/flamingo-contract-swap/FlamingoSwapFactory/FlamingoSwapFactoryContract.Admin.cs b/Swap/flamingo-contract-swap/FlamingoSwapFactory/FlamingoSwapFactoryContract.Admin.cs index f2173c1..f8057ac 100644 --- a/Swap/flamingo-contract-swap/FlamingoSwapFactory/FlamingoSwapFactoryContract.Admin.cs +++ b/Swap/flamingo-contract-swap/FlamingoSwapFactory/FlamingoSwapFactoryContract.Admin.cs @@ -52,6 +52,7 @@ public static byte[] Upgrade(byte[] newScript, byte[] paramList, byte returnType Assert(Runtime.CheckWitness(GetAdmin()), "upgrade: CheckWitness failed!"); byte[] newContractHash = Hash160(newScript); + Assert(Blockchain.GetContract(newContractHash).Serialize().Equals(new byte[] { 0x00, 0x00 }), "upgrade: The contract already exists"); Contract newContract = Contract.Migrate(newScript, paramList, returnType, cps, name, version, author, email, description); Runtime.Notify("upgrade", ExecutionEngine.ExecutingScriptHash, newContractHash); diff --git a/Swap/flamingo-contract-swap/FlamingoSwapPair/FlamingoSwapPairContract.Admin.cs b/Swap/flamingo-contract-swap/FlamingoSwapPair/FlamingoSwapPairContract.Admin.cs index 339961d..ee98b01 100644 --- a/Swap/flamingo-contract-swap/FlamingoSwapPair/FlamingoSwapPairContract.Admin.cs +++ b/Swap/flamingo-contract-swap/FlamingoSwapPair/FlamingoSwapPairContract.Admin.cs @@ -61,6 +61,7 @@ public static byte[] Upgrade(byte[] newScript, byte[] paramList, byte returnType var me = ExecutionEngine.ExecutingScriptHash; byte[] newContractHash = Hash160(newScript); + Assert(Blockchain.GetContract(newContractHash).Serialize().Equals(new byte[] { 0x00, 0x00 }), "upgrade: The contract already exists"); var r = ReservePair; SafeTransfer(Token0, me, newContractHash, r.Reserve0); diff --git a/Swap/flamingo-contract-swap/FlamingoSwapPair/FlamingoSwapPairContract.Nep5.cs b/Swap/flamingo-contract-swap/FlamingoSwapPair/FlamingoSwapPairContract.Nep5.cs index bbbb718..ce90787 100644 --- a/Swap/flamingo-contract-swap/FlamingoSwapPair/FlamingoSwapPairContract.Nep5.cs +++ b/Swap/flamingo-contract-swap/FlamingoSwapPair/FlamingoSwapPairContract.Nep5.cs @@ -25,8 +25,6 @@ partial class FlamingoSwapPairContract [DisplayName("name")] public static string Name() => "Exchange Pair"; //name of the token - [DisplayName("symbol")] - public static string Symbol() => "Temp-AB"; //symbol of the token [DisplayName("supportedStandards")] @@ -70,7 +68,7 @@ private static bool Transfer(byte[] from, byte[] to, BigInteger amount, byte[] c { //Check parameters Assert(from.Length == 20 && to.Length == 20, "The parameters from and to SHOULD be 20-byte addresses."); - Assert(amount > 0, "The parameter amount MUST be greater than 0."); + Assert(amount >= 0, "The parameter amount MUST be greater than 0."); if (!Runtime.CheckWitness(from) && from.AsBigInteger() != callscript.AsBigInteger()) return false; @@ -81,6 +79,7 @@ private static bool Transfer(byte[] from, byte[] to, BigInteger amount, byte[] c if (from == to) return true; + //Reduce payer balances if (fromAmount == amount) asset.Delete(from); diff --git a/Swap/flamingo-contract-swap/FlamingoSwapPair/FlamingoSwapPairContract.cs b/Swap/flamingo-contract-swap/FlamingoSwapPair/FlamingoSwapPairContract.cs index baca445..43f417b 100644 --- a/Swap/flamingo-contract-swap/FlamingoSwapPair/FlamingoSwapPairContract.cs +++ b/Swap/flamingo-contract-swap/FlamingoSwapPair/FlamingoSwapPairContract.cs @@ -30,6 +30,10 @@ partial class FlamingoSwapPairContract : SmartContract /// static readonly byte[] Token1 = "cbad1e6082cb71f336939934f21e5929a5c6d7ff".HexToBytes(); + + [DisplayName("symbol")] + public static string Symbol() => "E-AB"; //symbol of the token + #endregion @@ -45,6 +49,9 @@ partial class FlamingoSwapPairContract : SmartContract ///// //static readonly byte[] Token1 = "7c76490fc79a8a47068b904e83d78c0292590fd4".HexToBytes(); + //[DisplayName("symbol")] + //public static string Symbol() => "E-BC"; //symbol of the token + #endregion diff --git a/Swap/flamingo-contract-swap/FlamingoSwapRouter/FlamingoSwapRouterContract.Admin.cs b/Swap/flamingo-contract-swap/FlamingoSwapRouter/FlamingoSwapRouterContract.Admin.cs index ef0bbcc..4216144 100644 --- a/Swap/flamingo-contract-swap/FlamingoSwapRouter/FlamingoSwapRouterContract.Admin.cs +++ b/Swap/flamingo-contract-swap/FlamingoSwapRouter/FlamingoSwapRouterContract.Admin.cs @@ -54,6 +54,7 @@ public static byte[] Upgrade(byte[] newScript, byte[] paramList, byte returnType Assert(Runtime.CheckWitness(GetAdmin()), "upgrade: CheckWitness failed!"); byte[] newContractHash = Hash160(newScript); + Assert(Blockchain.GetContract(newContractHash).Serialize().Equals(new byte[] { 0x00, 0x00 }), "upgrade: The contract already exists"); Contract newContract = Contract.Migrate(newScript, paramList, returnType, cps, name, version, author, email, description); Runtime.Notify("upgrade", ExecutionEngine.ExecutingScriptHash, newContractHash); diff --git a/Swap/flamingo-contract-swap/FlamingoSwapRouter/FlamingoSwapRouterContract.cs b/Swap/flamingo-contract-swap/FlamingoSwapRouter/FlamingoSwapRouterContract.cs index 9c6bb25..00d9a49 100644 --- a/Swap/flamingo-contract-swap/FlamingoSwapRouter/FlamingoSwapRouterContract.cs +++ b/Swap/flamingo-contract-swap/FlamingoSwapRouter/FlamingoSwapRouterContract.cs @@ -114,6 +114,7 @@ public static BigInteger[] AddLiquidity(byte[] sender, byte[] tokenA, byte[] tok { //B超出期望最大值,按照 TokenB 期望最大值计算 TokenA 的注入量 var estimatedA = Quote(amountBDesired, reserveB, reserveA); + Assert(estimatedA <= amountADesired, "Excess A Amount"); Assert(estimatedA >= amountAMin, "Insufficient A Amount"); amountA = estimatedA; amountB = amountBDesired;