diff --git a/scripts/StateJsonConvert/Makefile b/scripts/StateJsonConvert/Makefile new file mode 100644 index 000000000..59b6ea9c1 --- /dev/null +++ b/scripts/StateJsonConvert/Makefile @@ -0,0 +1,3 @@ +convert.exe : ScillaStateJsonConvert.cpp + g++ -o convert.exe ScillaStateJsonConvert.cpp -ljsoncpp -lboost_program_options + diff --git a/scripts/StateJsonConvert/README.md b/scripts/StateJsonConvert/README.md new file mode 100644 index 000000000..bc534fa0f --- /dev/null +++ b/scripts/StateJsonConvert/README.md @@ -0,0 +1,61 @@ +# Convert State JSON from Zilliqa API Format to Scilla Format + +The [Zilliqa API]((https://dev.zilliqa.com/docs/apis/api-contract-get-smartcontract-state)) +to fetch the state of a contract produces a JSON in the format + +``` +{ + "_balance": "0", + "admins": { + "0xdfa89866ae86632b36361d53b76c1373448c28fa": { + "argtypes": [], + "arguments": [], + "constructor": "True" + } + } +} +``` + +This program converts it into a format that Scilla understands. Since +there is some loss of information in the API output (the type of a field, +for example), this program also requires the `-contractinfo` output of +scilla-checker as an additional input to find this missing information. +The init JSON of the contract must be provided as input to `scilla-checker` +(via the `-init` option) so that names are disambiguated correctly in the +output contract info JSON of `scilla-checker`. + +The output JSON for the above snippet would look something like this + +``` +[ + { + "vname" : "_balance" + "type" : "Uint128", + "value" : "0" + }, + { + "vname" : "admins", + "type" : "Map ByStr20 Bool", + "value" : [ + { + "key" : "0xdfa89866ae86632b36361d53b76c1373448c28fa", + "val" : { + "argtypes": [], + "arguments": [], + "constructor": "True" + } + } + ] + } +] +``` + +## Build +Install `libjsoncpp-dev`and `libboost-program-options-dev` system packages. +The command `make` in this directory should now succeed in building the +executable `convert.exe`. + +## Use +Using the example inputs provided in `tests`, here's how the tool can be used: + +```./convert.exe -s tests/ZilSwap/state.json -c tests/ZilSwap/contractinfo.json``` diff --git a/scripts/StateJsonConvert/ScillaStateJsonConvert.cpp b/scripts/StateJsonConvert/ScillaStateJsonConvert.cpp new file mode 100644 index 000000000..3f5c7b480 --- /dev/null +++ b/scripts/StateJsonConvert/ScillaStateJsonConvert.cpp @@ -0,0 +1,163 @@ +#include +#include +#include +#include +#include +#include + +#include + +namespace po = boost::program_options; + +void exitMsg(const std::string &Msg) { + std::cerr << Msg; + exit(EXIT_FAILURE); +} + +void parseCLIArgs(int argc, char *argv[], po::variables_map &VM) { + auto UsageString = + "Usage: " + std::string(argv[0]) + + " -c contract_info.json -s state.json" + "\nSupported options"; + po::options_description Desc(UsageString); + + // clang-format off + Desc.add_options() + ("state,s", po::value(), "Specify the JSON to use as initial state") + ("contract-info,c", po::value(), "Specify the contract info JSON from checker") + ("help,h", "Print help message") + ("version,v", "Print version") + ; + // clang-format on + + try { + po::store(po::command_line_parser(argc, argv).options(Desc).run(), VM); + po::notify(VM); + } catch (std::exception &e) { + std::cerr << e.what() << "\n"; + std::cerr << Desc << "\n"; + exit(EXIT_FAILURE); + } + + if (VM.count("help")) { + std::cerr << Desc << "\n"; + exit(EXIT_SUCCESS); + } + + // Ensure that an input file is provided. + if (!VM.count("state") || !VM.count("contract-info")) { + std::cerr << "Missing mandatory command line arguments\n" << Desc << "\n"; + exit(EXIT_FAILURE); + } +} + +std::string readFile(const std::string &Filename) { + std::ifstream IfsFile(Filename); + std::string FileStr((std::istreambuf_iterator(IfsFile)), + (std::istreambuf_iterator())); + return FileStr; +} + +Json::Value parseJSONString(const std::string &JS) { + Json::Value Ret; + Json::CharReaderBuilder ReadBuilder; + std::unique_ptr Reader(ReadBuilder.newCharReader()); + std::string Error; + try { + Reader->parse(JS.c_str(), JS.c_str() + JS.length(), &Ret, &Error); + } catch (const std::exception &e) { + exitMsg(std::string(e.what()) + ": " + Error); + } + + return Ret; +} + +Json::Value parseJSONFile(const std::string &Filename) { + + return parseJSONString(readFile(Filename)); +} + +Json::Value convertValue(const Json::Value &IJ, int Depth) { + if (Depth == 0) { + return IJ; + } + + if (IJ.isNull()) { + return Json::arrayValue; + } + + if (!IJ.isObject()) { + exitMsg("Expected JSON object at depth " + std::to_string(Depth)); + } + + Json::Value OJ = Json::arrayValue; + for (Json::Value::const_iterator Itr = IJ.begin(); + Itr != IJ.end(); Itr++) + { + Json::Value J = Json::objectValue; + J["key"] = Itr.name(); + J["val"] = convertValue(*Itr, Depth - 1); + OJ.append(J); + } + + return OJ; +} + +int main(int argc, char *argv[]) +{ + po::variables_map VM; + parseCLIArgs(argc, argv, VM); + + // Process the contract info JSON first. + std::string ContrInfoFilename = VM["contract-info"].as(); + Json::Value ContrInfoJ = parseJSONFile(ContrInfoFilename); + + Json::Value &Fields = ContrInfoJ["contract_info"]["fields"]; + if (Fields.isNull()) { + exitMsg("fields not found in " + ContrInfoFilename); + } + + std::unordered_map DepthMap; + std::unordered_map TypeMap; + DepthMap["_balance"] = 0; + TypeMap["_balance"] = "Uint128"; + + for (const auto &Field : Fields) { + if (!Field["vname"].isString() || !Field["type"].isString() + || !Field["depth"].isInt()) + { + exitMsg("Incorrect field entry.\n" + Field.toStyledString()); + } + TypeMap[Field["vname"].asString()] = Field["type"].asString(); + DepthMap[Field["vname"].asString()] = Field["depth"].asInt(); + } + + std::string InputStateFilename = VM["state"].as(); + Json::Value InputState = parseJSONFile(InputStateFilename); + + Json::Value OutputState = Json::arrayValue; + if (!InputState.isObject()) { + exitMsg("Expected input state to be a JSON object"); + } + + for (Json::Value::const_iterator Itr = InputState.begin(); + Itr != InputState.end(); Itr++) + { + const std::string &VName = Itr.name(); + const Json::Value &ValJ = *Itr; + const auto &Type = TypeMap.find(VName); + const auto &Depth = DepthMap.find(VName); + if (Type == TypeMap.end() || Depth == DepthMap.end()) { + exitMsg("Not found: type or depth for " + VName); + } + Json::Value OJ; + OJ["vname"] = VName; + OJ["type"] = Type->second; + OJ["value"] = convertValue(ValJ, Depth->second); + OutputState.append(OJ); + } + + std::cout << OutputState.toStyledString(); + + return 0; +} diff --git a/scripts/StateJsonConvert/tests/ZilSwap/contractinfo.json b/scripts/StateJsonConvert/tests/ZilSwap/contractinfo.json new file mode 100644 index 000000000..31785a989 --- /dev/null +++ b/scripts/StateJsonConvert/tests/ZilSwap/contractinfo.json @@ -0,0 +1,346 @@ +{ + "contract_info": { + "scilla_major_version": "0", + "vname": "ZilSwap", + "params": [ + { "vname": "initial_owner", "type": "ByStr20" }, + { "vname": "initial_fee", "type": "Uint256" } + ], + "fields": [ + { + "vname": "pools", + "type": "Map (ByStr20) (zilswap.Pool)", + "depth": 1 + }, + { + "vname": "balances", + "type": "Map (ByStr20) (Map (ByStr20) (Uint128))", + "depth": 2 + }, + { + "vname": "total_contributions", + "type": "Map (ByStr20) (Uint128)", + "depth": 1 + }, + { "vname": "output_after_fee", "type": "Uint256", "depth": 0 }, + { "vname": "owner", "type": "ByStr20", "depth": 0 }, + { "vname": "pending_owner", "type": "ByStr20", "depth": 0 } + ], + "transitions": [ + { + "vname": "RecipientAcceptTransferFrom", + "params": [ + { "vname": "initiator", "type": "ByStr20" }, + { "vname": "sender", "type": "ByStr20" }, + { "vname": "recipient", "type": "ByStr20" }, + { "vname": "amount", "type": "Uint128" } + ] + }, + { + "vname": "TransferFromSuccessCallBack", + "params": [ + { "vname": "initiator", "type": "ByStr20" }, + { "vname": "sender", "type": "ByStr20" }, + { "vname": "recipient", "type": "ByStr20" }, + { "vname": "amount", "type": "Uint128" } + ] + }, + { + "vname": "TransferSuccessCallBack", + "params": [ + { "vname": "sender", "type": "ByStr20" }, + { "vname": "recipient", "type": "ByStr20" }, + { "vname": "amount", "type": "Uint128" } + ] + }, + { + "vname": "SetFee", + "params": [ { "vname": "new_fee", "type": "Uint256" } ] + }, + { + "vname": "TransferOwnership", + "params": [ { "vname": "new_owner", "type": "ByStr20" } ] + }, + { "vname": "AcceptPendingOwnership", "params": [] }, + { + "vname": "AddLiquidity", + "params": [ + { "vname": "token_address", "type": "ByStr20" }, + { "vname": "min_contribution_amount", "type": "Uint128" }, + { "vname": "max_token_amount", "type": "Uint128" }, + { "vname": "deadline_block", "type": "BNum" } + ] + }, + { + "vname": "RemoveLiquidity", + "params": [ + { "vname": "token_address", "type": "ByStr20" }, + { "vname": "contribution_amount", "type": "Uint128" }, + { "vname": "min_zil_amount", "type": "Uint128" }, + { "vname": "min_token_amount", "type": "Uint128" }, + { "vname": "deadline_block", "type": "BNum" } + ] + }, + { + "vname": "SwapExactZILForTokens", + "params": [ + { "vname": "token_address", "type": "ByStr20" }, + { "vname": "min_token_amount", "type": "Uint128" }, + { "vname": "deadline_block", "type": "BNum" }, + { "vname": "recipient_address", "type": "ByStr20" } + ] + }, + { + "vname": "SwapExactTokensForZIL", + "params": [ + { "vname": "token_address", "type": "ByStr20" }, + { "vname": "token_amount", "type": "Uint128" }, + { "vname": "min_zil_amount", "type": "Uint128" }, + { "vname": "deadline_block", "type": "BNum" }, + { "vname": "recipient_address", "type": "ByStr20" } + ] + }, + { + "vname": "SwapZILForExactTokens", + "params": [ + { "vname": "token_address", "type": "ByStr20" }, + { "vname": "token_amount", "type": "Uint128" }, + { "vname": "deadline_block", "type": "BNum" }, + { "vname": "recipient_address", "type": "ByStr20" } + ] + }, + { + "vname": "SwapTokensForExactZIL", + "params": [ + { "vname": "token_address", "type": "ByStr20" }, + { "vname": "max_token_amount", "type": "Uint128" }, + { "vname": "zil_amount", "type": "Uint128" }, + { "vname": "deadline_block", "type": "BNum" }, + { "vname": "recipient_address", "type": "ByStr20" } + ] + }, + { + "vname": "SwapExactTokensForTokens", + "params": [ + { "vname": "token0_address", "type": "ByStr20" }, + { "vname": "token1_address", "type": "ByStr20" }, + { "vname": "token0_amount", "type": "Uint128" }, + { "vname": "min_token1_amount", "type": "Uint128" }, + { "vname": "deadline_block", "type": "BNum" }, + { "vname": "recipient_address", "type": "ByStr20" } + ] + }, + { + "vname": "SwapTokensForExactTokens", + "params": [ + { "vname": "token0_address", "type": "ByStr20" }, + { "vname": "token1_address", "type": "ByStr20" }, + { "vname": "max_token0_amount", "type": "Uint128" }, + { "vname": "token1_amount", "type": "Uint128" }, + { "vname": "deadline_block", "type": "BNum" }, + { "vname": "recipient_address", "type": "ByStr20" } + ] + } + ], + "procedures": [ + { + "vname": "ThrowIfExpired", + "params": [ { "vname": "deadline_block", "type": "BNum" } ] + }, + { + "vname": "ThrowIfZero", + "params": [ { "vname": "number", "type": "Uint128" } ] + }, + { + "vname": "ThrowIfZil", + "params": [ { "vname": "address", "type": "ByStr20" } ] + }, + { "vname": "ThrowUnlessSenderIsOwner", "params": [] }, + { + "vname": "Send", + "params": [ + { "vname": "coins", "type": "zilswap.Coins" }, + { "vname": "to_address", "type": "ByStr20" } + ] + }, + { + "vname": "Receive", + "params": [ { "vname": "coins", "type": "zilswap.Coins" } ] + }, + { + "vname": "DoSwap", + "params": [ + { "vname": "pool", "type": "zilswap.Pool" }, + { "vname": "token_address", "type": "ByStr20" }, + { "vname": "input", "type": "zilswap.Coins" }, + { "vname": "output", "type": "zilswap.Coins" }, + { "vname": "input_from", "type": "ByStr20" }, + { "vname": "output_to", "type": "ByStr20" } + ] + }, + { + "vname": "DoSwapTwice", + "params": [ + { "vname": "pool0", "type": "zilswap.Pool" }, + { "vname": "token0_address", "type": "ByStr20" }, + { "vname": "pool1", "type": "zilswap.Pool" }, + { "vname": "token1_address", "type": "ByStr20" }, + { "vname": "input_amount", "type": "Uint128" }, + { "vname": "intermediate_amount", "type": "Uint128" }, + { "vname": "output_amount", "type": "Uint128" }, + { "vname": "recipient_address", "type": "ByStr20" } + ] + }, + { + "vname": "SwapUsingZIL", + "params": [ + { "vname": "token_address", "type": "ByStr20" }, + { "vname": "direction", "type": "zilswap.SwapDirection" }, + { "vname": "exact_side", "type": "zilswap.ExactSide" }, + { "vname": "exact_amount", "type": "Uint128" }, + { "vname": "limit_amount", "type": "Uint128" }, + { "vname": "deadline_block", "type": "BNum" }, + { "vname": "recipient_address", "type": "ByStr20" } + ] + } + ], + "events": [ + { + "vname": "Burn", + "params": [ + { "vname": "pool", "type": "ByStr20" }, + { "vname": "address", "type": "ByStr20" }, + { "vname": "amount", "type": "Uint128" } + ] + }, + { + "vname": "Mint", + "params": [ + { "vname": "pool", "type": "ByStr20" }, + { "vname": "address", "type": "ByStr20" }, + { "vname": "amount", "type": "Uint128" } + ] + }, + { + "vname": "PoolCreated", + "params": [ { "vname": "pool", "type": "ByStr20" } ] + }, + { + "vname": "Swap", + "params": [ + { "vname": "pool", "type": "ByStr20" }, + { "vname": "address", "type": "ByStr20" }, + { "vname": "input", "type": "zilswap.Coins" }, + { "vname": "output", "type": "zilswap.Coins" } + ] + } + ], + "ADTs": [ + { + "tname": "zilswap.Pool", + "tparams": [], + "tmap": [ + { "cname": "zilswap.Pool", "argtypes": [ "Uint128", "Uint128" ] } + ] + }, + { + "tname": "zilswap.Denom", + "tparams": [], + "tmap": [ + { "cname": "zilswap.Zil", "argtypes": [] }, + { "cname": "zilswap.Token", "argtypes": [ "ByStr20" ] } + ] + }, + { + "tname": "zilswap.ResultOrError", + "tparams": [], + "tmap": [ + { + "cname": "zilswap.Result", + "argtypes": [ "zilswap.Pool", "Uint128" ] + }, + { "cname": "zilswap.Error", "argtypes": [ "String" ] } + ] + }, + { + "tname": "Option", + "tparams": [ "'A" ], + "tmap": [ + { "cname": "Some", "argtypes": [ "'A" ] }, + { "cname": "None", "argtypes": [] } + ] + }, + { + "tname": "zilswap.Coins", + "tparams": [], + "tmap": [ + { + "cname": "zilswap.Coins", + "argtypes": [ "zilswap.Denom", "Uint128" ] + } + ] + }, + { + "tname": "Bool", + "tparams": [], + "tmap": [ + { "cname": "True", "argtypes": [] }, + { "cname": "False", "argtypes": [] } + ] + }, + { + "tname": "Nat", + "tparams": [], + "tmap": [ + { "cname": "Zero", "argtypes": [] }, + { "cname": "Succ", "argtypes": [ "Nat" ] } + ] + }, + { + "tname": "List", + "tparams": [ "'A" ], + "tmap": [ + { "cname": "Cons", "argtypes": [ "'A", "List ('A)" ] }, + { "cname": "Nil", "argtypes": [] } + ] + }, + { + "tname": "Pair", + "tparams": [ "'A", "'B" ], + "tmap": [ { "cname": "Pair", "argtypes": [ "'A", "'B" ] } ] + }, + { + "tname": "zilswap.ExactSide", + "tparams": [], + "tmap": [ + { "cname": "zilswap.ExactInput", "argtypes": [] }, + { "cname": "zilswap.ExactOutput", "argtypes": [] } + ] + }, + { + "tname": "zilswap.Swap", + "tparams": [], + "tmap": [ + { + "cname": "zilswap.Swap", + "argtypes": [ + "Option (zilswap.Pool)", "zilswap.SwapDirection", + "zilswap.ExactSide", "Uint128", "Option (Uint128)", "Uint256" + ] + } + ] + }, + { + "tname": "zilswap.SwapDirection", + "tparams": [], + "tmap": [ + { "cname": "zilswap.ZilToToken", "argtypes": [] }, + { "cname": "zilswap.TokenToZil", "argtypes": [] } + ] + } + ] + }, + "warnings": [], + "gas_remaining": "9941" +} + diff --git a/scripts/StateJsonConvert/tests/ZilSwap/state.json b/scripts/StateJsonConvert/tests/ZilSwap/state.json new file mode 100644 index 000000000..735570642 --- /dev/null +++ b/scripts/StateJsonConvert/tests/ZilSwap/state.json @@ -0,0 +1,613 @@ +{ + "_balance": "3378169646881212360", + "balances": { + "0x04333e1536851fac5fc19b454c496a94a76c0785": { + "0x6019739427a69d6ffcec3c91d95e1ba9931dd1d6": "104989299528215", + "0x9c8d42eae7c38cd1e98ba64f1d360dbcb782f3fe": "142857142857142", + "0xf9364c4938aad201d2d2994d6234dc2ef568f0d9": "0" + }, + "0x1126ad89e6c4c025e77599f84ae52f68f52e97fd": { + "0x8609c42d101d7df6bfded70ea37e7c1771f53e37": "1000000000000000" + }, + "0x157d6c470489146c8f52dcda5d5ca28f9de9eee2": { + "0x334b9ed8ba59ed3e7236f4351a1bfbb6f1fdb3cc": "100000000000000" + }, + "0x16fabe5796ee8e8bad7565a9752da91bac30e838": { + "0x2155370fd82ab06eb2cde93ff770df5c955482e7": "0", + "0x4741230c8de3f489fca4d443ed5208a7e605b91b": "9545629862584076", + "0x5213b6f99e36aa8e2e020534fcad917286188dcd": "0", + "0x5271b17f150fa9029efaa0e85c9880444f508bc7": "11899525813458670", + "0xa38a8ca7f45d0bc86416c5335d736ab4ee63bab7": "812919674578336", + "0xaf1fcb9b52e3cd61ad05fdf2e915c70c7ac22fbc": "0", + "0xd84183a493b248162da741f6d8d8dbf34d1d7a53": "0", + "0xddbe574c7e2357d676eab7731aeb86c91add9131": "4252373558028219", + "0xf9364c4938aad201d2d2994d6234dc2ef568f0d9": "0" + }, + "0x184cbc0e7e4fbdb6bffc92ac54df141d595502bc": { + "0xaf1fcb9b52e3cd61ad05fdf2e915c70c7ac22fbc": "1000000000000000000" + }, + "0x249fed366b69281319147fda271d3226e67e4fea": { + "0xbbe53f0aab8df9d4a43d723fc372f5b0ef4e8026": "1000000000000000" + }, + "0x380b9174ddfa9ca437cf1e7070b0207e6e87298b": { + "0x0ba87f4374f7d9fe3ddf75b11439506b491a779a": "1000000000000000" + }, + "0x4026aa3f10cafc94e43354827f66e2917c10bfb6": { + "0x0f2d6a11703b5f57afab1aafbc820a3d3c5a3801": "4000000000000000" + }, + "0x59b2061d956df73524622d84325d3ebd3cbab2a4": { + "0xe754dbcfe4b6ccb9f3bc6ec0d8f25cd77eb9ebe0": "100000000000000000" + }, + "0x59f21a39ad97beee06b63f81c58fcbb0f9ae8829": { + "0x5f571af99e8fa1d41406548373b4d3ac8d087bb0": "1000000000000000" + }, + "0x6978852e940a54f2971178468dd0cb37f38464a5": { + "0xa1c56e7235a76d0d95ddbe6a5eaf780840c88e9f": "4000000000000000" + }, + "0x6af7c76bbaecb87c508ffef726eebe4ca274051b": { + "0x29f49ad465210c9b71ef082e23f16b8d69a68715": "2466195731283061" + }, + "0x6e8894131c29177311f1f5ecb886f88c93ebe869": { + "0x0d04a3dafcecc89745fd29e5b5bc154e2007759e": "2745699991210632", + "0x0f2d6a11703b5f57afab1aafbc820a3d3c5a3801": "20750446022667892", + "0x10a045fbc035f0bb3c724df5133c49a1d1d68887": "325356530306972", + "0x1e17a49df0f5fd6e3c4ed154ee43d1311e522cdd": "0", + "0x29f49ad465210c9b71ef082e23f16b8d69a68715": "9713848886628", + "0x2b1f5ca96e455c9d138c19b65575ac7bdab2ab4f": "49972634998195416", + "0x38c7c6f14c635a1a707fa6d4b96353b23ae74a17": "0", + "0x4776f50024464df5aa4588e4827dcf031c2b95f1": "58283153019271192", + "0x5213b6f99e36aa8e2e020534fcad917286188dcd": "0", + "0x52572b707d32f7be48b5cc014ab3fcb47b3fabef": "802721903926777", + "0x5271b17f150fa9029efaa0e85c9880444f508bc7": "48943052226429406", + "0x540954659308661a3f4b6f1cf66f50c10f9f2732": "38696477651323744", + "0x57b1ad5f5eb4597610b23e737c8949728b27e3b8": "44108626801296419", + "0x5c7330591a4406a5e05d7610ab78142a72e7855f": "0", + "0x69cfef1fb8476b1d71bf2a06e08faba1d1e737d5": "49524858114586087", + "0x8433179285b051087b2753e054a213335a51956e": "0", + "0xa9e038877bc41043e95baadb667f65c6a189b4e9": "1416749791923367", + "0xbf074d87dde49857d2a54e6f470059e1113bb6cf": "966396288912305", + "0xd7a1a1d2f9dd1c141a19bc78ac3e0490c796f67b": "118921252606778652", + "0xd84183a493b248162da741f6d8d8dbf34d1d7a53": "0", + "0xe754dbcfe4b6ccb9f3bc6ec0d8f25cd77eb9ebe0": "218768046622352584", + "0xfd346f18222558fa4b5606f3a9b703dcde48b637": "200373118843578367" + }, + "0x6f0b1fbda199dc4abfda28fa2eaa299599b3e8f2": { + "0x2b1f5ca96e455c9d138c19b65575ac7bdab2ab4f": "26364647884653", + "0x6e54f8db8b876803ab55259e14d157e0326b2db4": "5209486808507237", + "0x9883d795ae4525682d073ac90a7b0b57d06107dc": "437135076829420", + "0xa38ca7a4522eb46fe1f714ab27c52996168e6100": "186155941245623" + }, + "0x787ddb1f929c955eb3af1fb16e4c2cdb5aee1335": { + "0x2db2318f897d8d05f5df75c9ecec7a015f18339e": "4500000000000000", + "0x30d07583a1526ed7f3a66831a8cbf4520b42c40e": "4500000000000000", + "0x3fa174518eb8e0a274bb1ea4d07809db313d7d5d": "4500000000000000", + "0x9cc0548c6408bd2704968c21b69095af195d2005": "4500000000000000", + "0xa1a68c3b58f5cd313a32adf63b3fdc03de96ad59": "0", + "0xf0bb189e49be8bbe89ea5f3e13ed70b94954ca21": "4500000000000000", + "0xf96e561905b1efb4211ee904f5fb7dcb9b3ff087": "4500000000000000" + }, + "0x7b949726966b80c93542233531f9bd53542d4514": { + "0x018e3d58344e70b6bf6ee7835368589e46ce63cb": "1483311116524909", + "0x09e5eb6fa29c1e6915863f5c927a4faf84b00c03": "14550978017885968", + "0x1ad3ec139d80fd0204991c692fcad67ca4fb05e8": "12302738243904921", + "0x1bf047fa5d1629671bd96d08b04f4f39f176a291": "37152179586752798", + "0x2c512124ec5d8f23a90fc8a85b7fb7a4601556e8": "10176016085352845", + "0x2dc191f45748459d56dfbd70b4d649691daa8566": "1587037685875860", + "0x38c7c6f14c635a1a707fa6d4b96353b23ae74a17": "2257148517850275", + "0x42a2d1358ab8e4f3c8452931b100befde785c5a5": "8161290944532557", + "0x5213b6f99e36aa8e2e020534fcad917286188dcd": "0", + "0x550a88f78104df09163fdde2a5c1ff9323873e76": "2333739829025922", + "0x58c3b5f22444eaa15ba4bd9f26b0b088c77aa3cb": "0", + "0x5a223536dd3bd1223252fcea90083093843484b9": "126475860476007", + "0x6019739427a69d6ffcec3c91d95e1ba9931dd1d6": "0", + "0x60d522a021ebaeac7ff4d2dc4075a2b5d82aadbe": "0", + "0x6cb4c1b8cb07fb509a007811e8d96d33ae647aad": "272242084547806", + "0x6d74aa0540e8a3e99d3c435f1cdaf4c99826caa5": "0", + "0x6fc74177501058a733c0257009fb31f2a28cd658": "0", + "0x731743779595497f4f90558353f60d2a1768a038": "26691913223253801", + "0x737d85026c5dbf045199364d65b4b3d5d76e3f98": "8730447614966739", + "0x7627c6b1136c2c80d747d3a9c0a061b830fd88c8": "0", + "0x7a3e0a5e1164b369bb2856fa7101dbd637401927": "49850000000004", + "0x829aeca8f62f9af5059888b70170908254c8b842": "2534159823552206", + "0x82cf6677cbceda48423a39a50df56596a1558ee9": "0", + "0x86bc43f27f8013915091aac414556b8e663fd5b2": "19873902712707542", + "0x91ed0e9c0e10ce04ff9393e163864785f09f22ea": "442605556712795", + "0x99945e2a664f99b519fbda12fd7cdc749dcacbdc": "596455777780013", + "0x9af4b8562efd8b5aff0333ea7b011309bfe507e4": "0", + "0x9c8d42eae7c38cd1e98ba64f1d360dbcb782f3fe": "16515647281278366", + "0x9e80c04c7f909c89d8c7349070a3667593963774": "16240092414752937", + "0x9eb60f541d5796d213985c28ac5c5cd91b7f7f5b": "2910235655", + "0xa04b1ed55ad4fad388ffa8e77db9667ec31a1db2": "7377012034823129", + "0xa1500564b29c24c3a8e78888e9f455005425c602": "0", + "0xa5ea8c20accd370b114a1b057b41e06c842e335b": "3643964208570574", + "0xae66a2a32ccc05d0469391bed53f4d8433ad3cea": "0", + "0xaf1fcb9b52e3cd61ad05fdf2e915c70c7ac22fbc": "0", + "0xb06bf0de864c332844bc39ed72f1be91061466cc": "2512173258544896", + "0xb15862814724fca758a5949cecdf88685aed3c79": "0", + "0xb4af71dc2838735f4ce15de6c0c1429ffd889648": "7807440172649849", + "0xb78e9ccbc89fc9856b31325f5f02a00376fe3617": "5167647791593971", + "0xc6adfc3be1fd0ccf9bdb452628d7752518d74782": "0", + "0xc886ba014fbd17e0c27ee2848d755553eb178ac2": "0", + "0xca737b18c97e76fe49a2a78464d847719afc3c03": "0", + "0xcd7001f165855697d9a3e7bd9d2a239a7287ce75": "66843561239241", + "0xd13727db633447b65cfd45ea8afdc4f9a1283b26": "18788277558981195", + "0xd77939ecfe878324dc040c571cb91749b32fc332": "0", + "0xdb2647d32ec37776419bd03eab674fa1eff9509e": "12545928615845787", + "0xe085a334b8a5dbb8b70cc251579ac5a51cc27fc6": "5306753264952505", + "0xe0c34d3701660f700e557c8bae405f127f1ab7c5": "6762186680277555", + "0xe2a5139daabcd9a29791a239cf744ec13d72b344": "607406267097961", + "0xe32afa2b82a0b3315b6eecc1c57fa4e5d7c4e6a5": "73751536315964", + "0xe3c148d380eb8ba88a56680515b276a5dd16f733": "0", + "0xe829dea9947993eae6b0ef89cdf044126634aeea": "374951385105854", + "0xe84162d3f94c2928f94c47513a12d39b9b61b17f": "0", + "0xea753330764a646e3fe85c293b588a514ad13211": "2474897695645024", + "0xec0481e15c604d589b35354bae3fa6e7fd578d67": "682133803129745", + "0xed3bb799f2d82427028cff221116c16d02c7fb98": "3477552382986145", + "0xeef7062c3a3eb66e92ac1111f1f700acec5b6412": "4459132436589390", + "0xef8401f7ef1472dcea8b868689d276ba352dda10": "215937647391260643", + "0xefdd39075b3700c0ee58debfda15f2f1d1f5e68b": "923153993234696", + "0xf9364c4938aad201d2d2994d6234dc2ef568f0d9": "0", + "0xf93f818584e61c0a2d3a9661088fb91db4f97a51": "3382679813395594" + }, + "0x7f4a28aabde4cca04b5529eacb64b1449b317e7f": { + "0x038c3fd30aeab37e9e1b545b965f306dad614ae7": "2818794917805395", + "0x0d04a3dafcecc89745fd29e5b5bc154e2007759e": "1326967739103156", + "0x1084af5aea5c1055a7fb183ae9483faccb88232e": "194515769156893", + "0x10a045fbc035f0bb3c724df5133c49a1d1d68887": "273028341268267", + "0x20d3f9fd24029712ae9e204c04944aded6219a02": "261294047642448", + "0x2155370fd82ab06eb2cde93ff770df5c955482e7": "0", + "0x2b1f5ca96e455c9d138c19b65575ac7bdab2ab4f": "2034223658658906", + "0x42a2d1358ab8e4f3c8452931b100befde785c5a5": "9999998401333", + "0x4adfb0d61e05c56ed426298e7e3137fcf48321e4": "511742330895265", + "0x5213b6f99e36aa8e2e020534fcad917286188dcd": "0", + "0x57b1ad5f5eb4597610b23e737c8949728b27e3b8": "10905209140587740", + "0x58c3b5f22444eaa15ba4bd9f26b0b088c77aa3cb": "5940707203098645", + "0x7627c6b1136c2c80d747d3a9c0a061b830fd88c8": "370810706590994", + "0x7d2f29159cc1a80813b78eb3f2a637247f60d16c": "363118448456704", + "0x8433179285b051087b2753e054a213335a51956e": "0", + "0x95fb835dde45b19f7de9a23df61b75b1816a7d11": "545452", + "0x9c8d42eae7c38cd1e98ba64f1d360dbcb782f3fe": "665784738665466", + "0xa2b6e23fb69f0cd3812c11c110ac2f4a77cf6371": "0", + "0xa6dc70c6dc15ec49d7f5900ab3f1663e764afbb6": "0", + "0xae66a2a32ccc05d0469391bed53f4d8433ad3cea": "603744563032064", + "0xaf1fcb9b52e3cd61ad05fdf2e915c70c7ac22fbc": "536226652541857", + "0xbf074d87dde49857d2a54e6f470059e1113bb6cf": "0", + "0xc886ba014fbd17e0c27ee2848d755553eb178ac2": "0", + "0xc8acd26c46510ea701761de5f1ce678f9b03953f": "0", + "0xd2a9e7c4dda724e4b01fa6b92096153ee2f91073": "1617854688857262", + "0xd7a1a1d2f9dd1c141a19bc78ac3e0490c796f67b": "1618980362554784", + "0xd7c46a49a0bb0d867581af4c8d23a0c613a42497": "348271487893987", + "0xd8247844f84a2c0d01ca3f10731ac3cee7b0466e": "286997084524120", + "0xddbe574c7e2357d676eab7731aeb86c91add9131": "534489344569216", + "0xe754dbcfe4b6ccb9f3bc6ec0d8f25cd77eb9ebe0": "75000000000000000", + "0xe829dea9947993eae6b0ef89cdf044126634aeea": "44069581816768", + "0xfd346f18222558fa4b5606f3a9b703dcde48b637": "845877492784956", + "0xfef2107b3cdee1192302db472a88b09d55df033b": "1479191278181211" + }, + "0x80f0bf187e87fb85d860c439e18ebfc78c733f34": { + "0xa71806c35c6c9811f3cb3ed163fd12527bbc9604": "2000000000000000" + }, + "0x998052aee4d2427f03a0d36b4af82a40020e4263": { + "0x8ff83c69d5cf6b3f959a37d4359c8d99172b32da": "1000000000000000" + }, + "0xa116bf61c41b2163402b28801386430c5d3881aa": { + "0x8609c42d101d7df6bfded70ea37e7c1771f53e37": "1000000000000000" + }, + "0xa8a1372c45f4863f3b609aed202d68e21dba91f3": { + "0xe754dbcfe4b6ccb9f3bc6ec0d8f25cd77eb9ebe0": "100000000000000000" + }, + "0xaa65cd1c5547e4778a32475df0d56fa48fc432d1": { + "0xe754dbcfe4b6ccb9f3bc6ec0d8f25cd77eb9ebe0": "10000000000000" + }, + "0xab3e353fa92b595f57007c1c82725eded8b9a501": { + "0x6a02f55beb557f7cedffaf039738b986b7c7c1a7": "1000000000000000" + }, + "0xac868041134e743ffb9cb0f5be4b4ddf8a3d5574": { + "0xabb8d2f6c894ff409fa9b616ab50e3fa9f124c10": "1024000000000000" + }, + "0xacb721d989c095c64a24d16dfd23b08d738e2552": { + "0x42fc70115d78bd40a99677c29ab5cf4cf4689ebc": "908637015289277", + "0x54077035047d7924a3b82ddb2a8d2e01c72b8c91": "2999800039992001", + "0x6019739427a69d6ffcec3c91d95e1ba9931dd1d6": "5874405", + "0x669a98df7cccb6c24032897a896cbc9b1100d496": "1089242838130551", + "0x866c263e2b67db79cc3ed984ff64cb3382b8c9c9": "0", + "0xb4aa006664879c8ad91f27729344b5238673dc31": "3000000000000000", + "0xbccc7c3707f4e8c671ff300a2298ea5670f50cbe": "1817274030578554" + }, + "0xb2f66571a0c7bd9001fb6ca67b01ac749250504c": { + "0x10a045fbc035f0bb3c724df5133c49a1d1d68887": "1918081117273714", + "0x2b1f5ca96e455c9d138c19b65575ac7bdab2ab4f": "14845996570778170", + "0x4776f50024464df5aa4588e4827dcf031c2b95f1": "55839625186595060", + "0x57b1ad5f5eb4597610b23e737c8949728b27e3b8": "11786236713243829", + "0xd7a1a1d2f9dd1c141a19bc78ac3e0490c796f67b": "3873589792347351", + "0xd8247844f84a2c0d01ca3f10731ac3cee7b0466e": "10123907305787156", + "0xfa70c67ff84fe96a538cbd842cf02b0e45634a2c": "2509634951041601", + "0xfd346f18222558fa4b5606f3a9b703dcde48b637": "1936794896173675" + }, + "0xb583ea6151fbf79ec9bdfbda0cc6deb2eb826596": { + "0x0d04a3dafcecc89745fd29e5b5bc154e2007759e": "1000000000000000" + }, + "0xbdc328deeb2693c9f374c1c49ab9ac016bec1548": { + "0x8ee48ac8a59363bbf547a1ce5b6c54368e1cd176": "1000000000000000" + }, + "0xc1fc10f809d226deed8765a9645edc95d6731251": { + "0x0d04a3dafcecc89745fd29e5b5bc154e2007759e": "5000000000000000" + }, + "0xc36a9c64524bfaed02b2e5e767529d5d2e4d90b8": { + "0xaf1fcb9b52e3cd61ad05fdf2e915c70c7ac22fbc": "1000000000000000000" + }, + "0xc53cddce79993553511accc2ed99674710826981": { + "0xc742ea49c811c4bf4af09fbb3a063b2922e8f90b": "1000000000000000" + }, + "0xd8cbcdb38f89a0b0edbe6f5d3d8b6667d11bcc48": { + "0x8ac017de01df58309aced98d189045d9063c41ca": "1000000000000000" + }, + "0xdf21a29a43f2f4bfc1a1fd32db103c43f078e367": { + "0x07a3660d477efa32cb42064b6200a64c46b75283": "1500000000000000" + }, + "0xe2143caee4b4ff160f3917034046612d160d8905": { + "0x0d04a3dafcecc89745fd29e5b5bc154e2007759e": "3000000000000000" + }, + "0xe69c5be4f7c939ab4e5d7cc0237ab0c3930e7873": { + "0xabb8d2f6c894ff409fa9b616ab50e3fa9f124c10": "4096000000000000" + }, + "0xec2784b5101a496c3fbe97ed5a5687400e62b6a2": { + "0x8609c42d101d7df6bfded70ea37e7c1771f53e37": "1000000000000000" + }, + "0xf4c8e1f2ba2d296dbd7c8059c60c367b4fc3f707": { + "0x334b9ed8ba59ed3e7236f4351a1bfbb6f1fdb3cc": "9000000000000000" + }, + "0xfd8a0d57c599d05304f778926a6a916a9fe3696b": { + "0xafebfe83dc5b07b26842791dff4f64254a1d34fb": "24000000000000000" + } + }, + "output_after_fee": "9970", + "owner": "0xe754dbcfe4b6ccb9f3bc6ec0d8f25cd77eb9ebe0", + "pending_owner": "0x0000000000000000000000000000000000000000", + "pools": { + "0x04333e1536851fac5fc19b454c496a94a76c0785": { + "argtypes": [], + "arguments": [ + "49675598946055611", + "20659" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0x1126ad89e6c4c025e77599f84ae52f68f52e97fd": { + "argtypes": [], + "arguments": [ + "2400000000000000", + "41754604848" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0x157d6c470489146c8f52dcda5d5ca28f9de9eee2": { + "argtypes": [], + "arguments": [ + "3878822737827215", + "261519" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0x16fabe5796ee8e8bad7565a9752da91bac30e838": { + "argtypes": [], + "arguments": [ + "12058523104392675", + "12467428235553376" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0x184cbc0e7e4fbdb6bffc92ac54df141d595502bc": { + "argtypes": [], + "arguments": [ + "1000000000000000000", + "1000000000000000000" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0x249fed366b69281319147fda271d3226e67e4fea": { + "argtypes": [], + "arguments": [ + "998009968123562", + "50100000000" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0x380b9174ddfa9ca437cf1e7070b0207e6e87298b": { + "argtypes": [], + "arguments": [ + "2083453493618367", + "48075112669003505258" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0x4026aa3f10cafc94e43354827f66e2917c10bfb6": { + "argtypes": [], + "arguments": [ + "4000000000000000", + "8001" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0x59b2061d956df73524622d84325d3ebd3cbab2a4": { + "argtypes": [], + "arguments": [ + "100000000000000000", + "500000000" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0x59f21a39ad97beee06b63f81c58fcbb0f9ae8829": { + "argtypes": [], + "arguments": [ + "1000000000000000", + "9000000" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0x6978852e940a54f2971178468dd0cb37f38464a5": { + "argtypes": [], + "arguments": [ + "4000000000000000", + "2126008811" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0x6af7c76bbaecb87c508ffef726eebe4ca274051b": { + "argtypes": [], + "arguments": [ + "2314908709273171", + "736317883493173369010" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0x6e8894131c29177311f1f5ecb886f88c93ebe869": { + "argtypes": [], + "arguments": [ + "79032254869050463", + "101082147558456" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0x6f0b1fbda199dc4abfda28fa2eaa299599b3e8f2": { + "argtypes": [], + "arguments": [ + "45114419444989626", + "388667575514408447056767354137851" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0x787ddb1f929c955eb3af1fb16e4c2cdb5aee1335": { + "argtypes": [], + "arguments": [ + "21397747521284410", + "3435837041" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0x7b949726966b80c93542233531f9bd53542d4514": { + "argtypes": [], + "arguments": [ + "182036588937548486", + "134848565730451969" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0x7f4a28aabde4cca04b5529eacb64b1449b317e7f": { + "argtypes": [], + "arguments": [ + "682065336135944082", + "1778791914" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0x80f0bf187e87fb85d860c439e18ebfc78c733f34": { + "argtypes": [], + "arguments": [ + "148560817085182", + "2700000000001" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0x998052aee4d2427f03a0d36b4af82a40020e4263": { + "argtypes": [], + "arguments": [ + "1038017475578450", + "713043511417" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0xa116bf61c41b2163402b28801386430c5d3881aa": { + "argtypes": [], + "arguments": [ + "1400000000000000", + "71489848442" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0xa8a1372c45f4863f3b609aed202d68e21dba91f3": { + "argtypes": [], + "arguments": [ + "100000000000000000", + "500000000000000000000" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0xaa65cd1c5547e4778a32475df0d56fa48fc432d1": { + "argtypes": [], + "arguments": [ + "320960740479494", + "1562506123" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0xab3e353fa92b595f57007c1c82725eded8b9a501": { + "argtypes": [], + "arguments": [ + "1500000000000000", + "16016017" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0xac868041134e743ffb9cb0f5be4b4ddf8a3d5574": { + "argtypes": [], + "arguments": [ + "3256769731462492", + "3238311" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0xacb721d989c095c64a24d16dfd23b08d738e2552": { + "argtypes": [], + "arguments": [ + "11811842501144489", + "81600055444" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0xb2f66571a0c7bd9001fb6ca67b01ac749250504c": { + "argtypes": [], + "arguments": [ + "6912503188094435", + "107217532188469" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0xb583ea6151fbf79ec9bdfbda0cc6deb2eb826596": { + "argtypes": [], + "arguments": [ + "1000000000000000", + "2400000000000000" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0xbdc328deeb2693c9f374c1c49ab9ac016bec1548": { + "argtypes": [], + "arguments": [ + "6000000000000000", + "8354218881" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0xc1fc10f809d226deed8765a9645edc95d6731251": { + "argtypes": [], + "arguments": [ + "4960844468017643", + "2419000000000000000" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0xc36a9c64524bfaed02b2e5e767529d5d2e4d90b8": { + "argtypes": [], + "arguments": [ + "1000000000000000000", + "1000000000000" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0xc53cddce79993553511accc2ed99674710826981": { + "argtypes": [], + "arguments": [ + "122590083143898", + "41183285615" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0xd8cbcdb38f89a0b0edbe6f5d3d8b6667d11bcc48": { + "argtypes": [], + "arguments": [ + "1000000000000000", + "4900000000" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0xdf21a29a43f2f4bfc1a1fd32db103c43f078e367": { + "argtypes": [], + "arguments": [ + "1491577274995497", + "492777518416263945734578899223" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0xe2143caee4b4ff160f3917034046612d160d8905": { + "argtypes": [], + "arguments": [ + "3000000000000000", + "240000000000000" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0xe69c5be4f7c939ab4e5d7cc0237ab0c3930e7873": { + "argtypes": [], + "arguments": [ + "5353649219212462", + "980001" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0xec2784b5101a496c3fbe97ed5a5687400e62b6a2": { + "argtypes": [], + "arguments": [ + "1000000000000000", + "100000000000000" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0xf4c8e1f2ba2d296dbd7c8059c60c367b4fc3f707": { + "argtypes": [], + "arguments": [ + "10796667513890650", + "83726115" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + }, + "0xfd8a0d57c599d05304f778926a6a916a9fe3696b": { + "argtypes": [], + "arguments": [ + "25000000000000000", + "230427651319" + ], + "constructor": "0x1a62dd9c84b0c8948cb51fc664ba143e7a34985c.Pool" + } + }, + "total_contributions": { + "0x04333e1536851fac5fc19b454c496a94a76c0785": "247846442385357", + "0x1126ad89e6c4c025e77599f84ae52f68f52e97fd": "1000000000000000", + "0x157d6c470489146c8f52dcda5d5ca28f9de9eee2": "100000000000000", + "0x16fabe5796ee8e8bad7565a9752da91bac30e838": "26510448908649301", + "0x184cbc0e7e4fbdb6bffc92ac54df141d595502bc": "1000000000000000000", + "0x249fed366b69281319147fda271d3226e67e4fea": "1000000000000000", + "0x380b9174ddfa9ca437cf1e7070b0207e6e87298b": "1000000000000000", + "0x4026aa3f10cafc94e43354827f66e2917c10bfb6": "4000000000000000", + "0x59b2061d956df73524622d84325d3ebd3cbab2a4": "100000000000000000", + "0x59f21a39ad97beee06b63f81c58fcbb0f9ae8829": "1000000000000000", + "0x6978852e940a54f2971178468dd0cb37f38464a5": "4000000000000000", + "0x6af7c76bbaecb87c508ffef726eebe4ca274051b": "2466195731283061", + "0x6e8894131c29177311f1f5ecb886f88c93ebe869": "854608305261646440", + "0x6f0b1fbda199dc4abfda28fa2eaa299599b3e8f2": "5859142474466933", + "0x787ddb1f929c955eb3af1fb16e4c2cdb5aee1335": "27000000000000000", + "0x7b949726966b80c93542233531f9bd53542d4514": "484449769140209644", + "0x7f4a28aabde4cca04b5529eacb64b1449b317e7f": "108591899577632889", + "0x80f0bf187e87fb85d860c439e18ebfc78c733f34": "2000000000000000", + "0x998052aee4d2427f03a0d36b4af82a40020e4263": "1000000000000000", + "0xa116bf61c41b2163402b28801386430c5d3881aa": "1000000000000000", + "0xa8a1372c45f4863f3b609aed202d68e21dba91f3": "100000000000000000", + "0xaa65cd1c5547e4778a32475df0d56fa48fc432d1": "10000000000000", + "0xab3e353fa92b595f57007c1c82725eded8b9a501": "1000000000000000", + "0xac868041134e743ffb9cb0f5be4b4ddf8a3d5574": "1024000000000000", + "0xacb721d989c095c64a24d16dfd23b08d738e2552": "9814953929864788", + "0xb2f66571a0c7bd9001fb6ca67b01ac749250504c": "102833866533240556", + "0xb583ea6151fbf79ec9bdfbda0cc6deb2eb826596": "1000000000000000", + "0xbdc328deeb2693c9f374c1c49ab9ac016bec1548": "1000000000000000", + "0xc1fc10f809d226deed8765a9645edc95d6731251": "5000000000000000", + "0xc36a9c64524bfaed02b2e5e767529d5d2e4d90b8": "1000000000000000000", + "0xc53cddce79993553511accc2ed99674710826981": "1000000000000000", + "0xd8cbcdb38f89a0b0edbe6f5d3d8b6667d11bcc48": "1000000000000000", + "0xdf21a29a43f2f4bfc1a1fd32db103c43f078e367": "1500000000000000", + "0xe2143caee4b4ff160f3917034046612d160d8905": "3000000000000000", + "0xe69c5be4f7c939ab4e5d7cc0237ab0c3930e7873": "4096000000000000", + "0xec2784b5101a496c3fbe97ed5a5687400e62b6a2": "1000000000000000", + "0xf4c8e1f2ba2d296dbd7c8059c60c367b4fc3f707": "9000000000000000", + "0xfd8a0d57c599d05304f778926a6a916a9fe3696b": "24000000000000000" + } +} diff --git a/scripts/StateJsonConvert/tests/ZilSwap/zilswap.scilla b/scripts/StateJsonConvert/tests/ZilSwap/zilswap.scilla new file mode 100644 index 000000000..5983b291a --- /dev/null +++ b/scripts/StateJsonConvert/tests/ZilSwap/zilswap.scilla @@ -0,0 +1 @@ +scilla_version 0 import BoolUtils IntUtils library ZilSwap type Denom = | Zil | Token of ByStr20 type Coins = | Coins of Denom Uint128 type Pool = | Pool of Uint128 Uint128 type SwapDirection = | ZilToToken | TokenToZil type ExactSide = | ExactInput | ExactOutput type Swap = | Swap of (Option Pool) SwapDirection ExactSide Uint128 (Option Uint128) Uint256 type ResultOrError = | Result of Pool Uint128 | Error of String let zero = Uint128 0 let one = Uint128 1 let min_liquidity = Uint128 100 let fee_denom = Uint256 10000 let zil_address = 0x0000000000000000000000000000000000000000 let zil = Zil let oneMsg : Message -> List Message = fun (msg : Message) => let nil_msg = Nil {Message} in Cons {Message} msg nil_msg let grow : Uint128 -> Uint256 = fun (var : Uint128) => let maybe_big = builtin to_uint256 var in match maybe_big with | Some big => big | None => Uint256 0 end let frac : Uint128 -> Uint128 -> Uint128 -> Option Uint128 = fun (d : Uint128) => fun (x : Uint128) => fun (y : Uint128) => let big_x = grow x in let big_y = grow y in let big_d = grow d in let d_times_y = builtin mul big_d big_y in let d_times_y_over_x = builtin div d_times_y big_x in builtin to_uint128 d_times_y_over_x let outputFor : Uint128 -> Uint128 -> Uint128 -> Uint256 -> Option Uint128 = fun (input_amount_u128 : Uint128) => fun (input_reserve_u128 : Uint128) => fun (output_reserve_u128 : Uint128) => fun (after_fee : Uint256) => let input_amount = grow input_amount_u128 in let input_reserve = grow input_reserve_u128 in let output_reserve = grow output_reserve_u128 in let input_amount_after_fee = builtin mul input_amount after_fee in let numerator = builtin mul input_amount_after_fee output_reserve in let denominator = let d1 = builtin mul input_reserve fee_denom in builtin add d1 input_amount_after_fee in let result = builtin div numerator denominator in builtin to_uint128 result let inputFor : Uint128 -> Uint128 -> Uint128 -> Uint256 -> Option Uint128 = fun (output_amount_u128 : Uint128) => fun (input_reserve_u128 : Uint128) => fun (output_reserve_u128 : Uint128) => fun (after_fee : Uint256) => let output_amount = grow output_amount_u128 in let input_reserve = grow input_reserve_u128 in let output_reserve = grow output_reserve_u128 in let numerator = let n1 = builtin mul input_reserve output_amount in builtin mul n1 fee_denom in let denominator = let d1 = builtin sub output_reserve output_amount in builtin mul d1 after_fee in let result = builtin div numerator denominator in builtin to_uint128 result let amountFor : Pool -> SwapDirection -> ExactSide -> Uint128 -> Uint256 -> Option Uint128 = fun (pool : Pool) => fun (direction : SwapDirection) => fun (exact_side : ExactSide) => fun (exact_amount : Uint128) => fun (after_fee : Uint256) => match pool with | Pool zil_reserve token_reserve => let calc = fun (exact: ExactSide) => match exact with | ExactInput => outputFor | ExactOutput => inputFor end in match direction with | ZilToToken => calc exact_side exact_amount zil_reserve token_reserve after_fee | TokenToZil => calc exact_side exact_amount token_reserve zil_reserve after_fee end end let withinLimits : Uint128 -> Option Uint128 -> ExactSide -> Bool = fun (result_amount : Uint128) => fun (maybe_limit_amount : Option Uint128) => fun (exact_side : ExactSide) => match maybe_limit_amount with | None => True | Some limit_amount => match exact_side with | ExactInput => uint128_ge result_amount limit_amount | ExactOutput => uint128_ge limit_amount result_amount end end let resultFor : Swap -> ResultOrError = fun (swap : Swap) => match swap with | Swap maybe_pool direction exact_side exact_amount maybe_limit_amount after_fee => match maybe_pool with | None => let e = "MissingPool" in Error e | Some pool => let maybe_amount = amountFor pool direction exact_side exact_amount after_fee in match maybe_amount with | None => let e = "IntegerOverflow" in Error e | Some amount => let within_limits = withinLimits amount maybe_limit_amount exact_side in match within_limits with | False => let e = "RequestedRatesCannotBeFulfilled" in Error e | True => Result pool amount end end end end let poolEmpty : Pool -> Bool = fun (p : Pool) => match p with | Pool x y => let x_empty = builtin lt x one in let y_empty = builtin lt y one in orb x_empty y_empty end contract ZilSwap ( initial_owner : ByStr20, initial_fee : Uint256 ) with uint256_le initial_fee fee_denom => field pools : Map ByStr20 Pool = Emp ByStr20 Pool field balances : Map ByStr20 (Map ByStr20 Uint128) = Emp ByStr20 (Map ByStr20 Uint128) field total_contributions : Map ByStr20 Uint128 = Emp ByStr20 Uint128 field output_after_fee : Uint256 = builtin sub fee_denom initial_fee field owner : ByStr20 = initial_owner field pending_owner : ByStr20 = zil_address procedure ThrowIfExpired(deadline_block: BNum) current_block <- & BLOCKNUMBER; is_not_expired = builtin blt current_block deadline_block; match is_not_expired with | True => | False => e = { _exception : "TransactionExpired" }; throw e end end procedure ThrowIfZero(number: Uint128) gt_zero = uint128_gt number zero; match gt_zero with | True => | False => e = { _exception : "InvalidParameter" }; throw e end end procedure ThrowIfZil(address : ByStr20) is_zil = builtin eq address zil_address; match is_zil with | False => | True => e = { _exception : "InvalidParameter" }; throw e end end procedure ThrowUnlessSenderIsOwner() current_owner <- owner; is_owner = builtin eq _sender current_owner; match is_owner with | False => | True => e = { _exception : "InvalidSender" }; throw e end end procedure Send(coins : Coins, to_address : ByStr20) match coins with | Coins denom amount => match denom with | Zil => msg = { _tag : "AddFunds"; _recipient: to_address; _amount: amount }; msgs = oneMsg msg; send msgs | Token token => msg_to_token = { _tag : "Transfer"; _recipient: token; _amount: zero; to: to_address; amount: amount }; msgs = oneMsg msg_to_token; send msgs end end end procedure Receive(coins : Coins) match coins with | Coins denom amount => match denom with | Zil => needs_refund = uint128_gt _amount amount; accept; match needs_refund with | True => refund = let refund_amount = builtin sub _amount amount in Coins zil refund_amount; Send refund _sender | False => end | Token token => msg_to_token = { _tag : "TransferFrom"; _recipient: token; _amount: zero; from: _sender; to: _this_address; amount: amount }; msgs = oneMsg msg_to_token; send msgs end end end procedure DoSwap( pool : Pool, token_address : ByStr20, input : Coins, output : Coins, input_from : ByStr20, output_to : ByStr20 ) match pool with | Pool x y => match input with | Coins input_denom input_amount => match output with | Coins output_denom output_amount => match input_denom with | Zil => new_pool = let new_x = builtin add x input_amount in let new_y = builtin sub y output_amount in Pool new_x new_y; pools[token_address] := new_pool | Token t => new_pool = let new_x = builtin sub x output_amount in let new_y = builtin add y input_amount in Pool new_x new_y; pools[token_address] := new_pool end end end; sending_from_self = builtin eq input_from _this_address; match sending_from_self with | True => | False => Receive input end; sending_to_self = builtin eq output_to _this_address; match sending_to_self with | True => | False => Send output output_to end; e = { _eventname: "Swap"; pool: token_address; address: _sender; input: input; output: output }; event e end end procedure DoSwapTwice( pool0 : Pool, token0_address : ByStr20, pool1 : Pool, token1_address : ByStr20, input_amount : Uint128, intermediate_amount : Uint128, output_amount : Uint128, recipient_address : ByStr20 ) input = let token0 = Token token0_address in Coins token0 input_amount; intermediate = Coins zil intermediate_amount; output = let token1 = Token token1_address in Coins token1 output_amount; DoSwap pool0 token0_address input intermediate _sender _this_address ; DoSwap pool1 token1_address intermediate output _this_address recipient_address end procedure SwapUsingZIL( token_address : ByStr20, direction : SwapDirection, exact_side : ExactSide, exact_amount : Uint128, limit_amount : Uint128, deadline_block : BNum, recipient_address : ByStr20 ) ThrowIfExpired deadline_block; ThrowIfZero exact_amount; ThrowIfZero limit_amount; after_fee <- output_after_fee; maybe_pool <- pools[token_address]; result = let option_limit_amount = Some {Uint128} limit_amount in let swap = Swap maybe_pool direction exact_side exact_amount option_limit_amount after_fee in resultFor swap; match result with | Error msg => e = { _exception : msg }; throw e | Result pool calculated_amount => token = Token token_address; match exact_side with | ExactInput => match direction with | ZilToToken => input = Coins zil exact_amount; output = Coins token calculated_amount; DoSwap pool token_address input output _sender recipient_address | TokenToZil => input = Coins token exact_amount; output = Coins zil calculated_amount; DoSwap pool token_address input output _sender recipient_address end | ExactOutput => match direction with | ZilToToken => input = Coins zil calculated_amount; output = Coins token exact_amount; DoSwap pool token_address input output _sender recipient_address | TokenToZil => input = Coins token calculated_amount; output = Coins zil exact_amount; DoSwap pool token_address input output _sender recipient_address end end end end transition RecipientAcceptTransferFrom( initiator : ByStr20, sender : ByStr20, recipient : ByStr20, amount : Uint128 ) is_valid_transfer_to_self = let self_triggered = builtin eq initiator _this_address in let is_transfer_to_self = builtin eq recipient _this_address in andb self_triggered is_transfer_to_self; match is_valid_transfer_to_self with | False => e = { _exception : "InvalidInvocation" }; throw e | True => end end transition TransferFromSuccessCallBack( initiator : ByStr20, sender : ByStr20, recipient : ByStr20, amount : Uint128 ) end transition TransferSuccessCallBack( sender : ByStr20, recipient : ByStr20, amount : Uint128 ) end transition SetFee( new_fee : Uint256 ) ThrowUnlessSenderIsOwner; is_valid_fee = uint256_le new_fee fee_denom; match is_valid_fee with | False => e = { _exception : "InvalidParameter" }; throw e | True => new_output_after_fee = builtin sub fee_denom new_fee; output_after_fee := new_output_after_fee end end transition TransferOwnership( new_owner : ByStr20 ) ThrowUnlessSenderIsOwner; pending_owner := new_owner end transition AcceptPendingOwnership() new_owner <- pending_owner; sender_is_pending_owner = builtin eq _sender new_owner; match sender_is_pending_owner with | False => e = { _exception : "InvalidSender" }; throw e | True => owner := new_owner; pending_owner := zil_address end end transition AddLiquidity( token_address : ByStr20, min_contribution_amount : Uint128, max_token_amount : Uint128, deadline_block : BNum ) ThrowIfExpired deadline_block; ThrowIfZil token_address; ThrowIfZero _amount; ThrowIfZero max_token_amount; token = Token token_address; zils_in = Coins zil _amount; Receive zils_in; maybe_pool <- pools[token_address]; match maybe_pool with | None => min_zil_contributed = uint128_ge _amount min_liquidity; match min_zil_contributed with | False => e = { _exception : "InvalidParameter" }; throw e | True => tokens_in = Coins token max_token_amount; Receive tokens_in; new_pool = Pool _amount max_token_amount; pools[token_address] := new_pool; e1 = { _eventname: "PoolCreated"; pool: token_address }; event e1; balances[token_address][_sender] := _amount; total_contributions[token_address] := _amount; e2 = { _eventname: "Mint"; pool: token_address; address: _sender; amount: _amount }; event e2 end | Some pool => match pool with | Pool x y => maybe_result = frac _amount x y; match maybe_result with | None => e = { _exception : "IntegerOverflow" }; throw e | Some result => delta_y = builtin add result one; maybe_total_contribution <- total_contributions[token_address]; match maybe_total_contribution with | None => e = { _exception : "MissingContributions" }; throw e | Some total_contribution => maybe_new_contribution = frac _amount x total_contribution; match maybe_new_contribution with | None => e = { _exception : "IntegerOverflow" }; throw e | Some new_contribution => within_limits = let token_lte_max = uint128_le delta_y max_token_amount in let contribution_gte_max = uint128_ge new_contribution min_contribution_amount in andb token_lte_max contribution_gte_max; match within_limits with | False => e = { _exception : "RequestedRatesCannotBeFulfilled" ; delta_y: delta_y }; throw e | True => tokens_in = Coins token delta_y; Receive tokens_in; new_pool = let new_x = builtin add x _amount in let new_y = builtin add y delta_y in Pool new_x new_y; pools[token_address] := new_pool; existing_balance <- balances[token_address][_sender]; match existing_balance with | Some b => new_balance = builtin add b new_contribution; balances[token_address][_sender] := new_balance | None => balances[token_address][_sender] := new_contribution end; new_total_contribution = builtin add total_contribution new_contribution; total_contributions[token_address] := new_total_contribution; e = { _eventname: "Mint"; pool: token_address; address: _sender; amount: new_contribution }; event e end end end end end end end transition RemoveLiquidity( token_address : ByStr20, contribution_amount : Uint128, min_zil_amount : Uint128, min_token_amount : Uint128, deadline_block : BNum ) ThrowIfExpired deadline_block; ThrowIfZero contribution_amount; ThrowIfZero min_zil_amount; ThrowIfZero min_token_amount; token = Token token_address; maybe_total_contribution <- total_contributions[token_address]; match maybe_total_contribution with | None => e = { _exception : "MissingPool" }; throw e | Some total_contribution => ThrowIfZero total_contribution; maybe_pool <- pools[token_address]; match maybe_pool with | None => e = { _exception : "MissingPool" }; throw e | Some pool => match pool with | Pool x y => maybe_zil_amount = frac contribution_amount total_contribution x; maybe_token_amount = frac contribution_amount total_contribution y; match maybe_zil_amount with | None => e = { _exception : "IntegerOverflow" }; throw e | Some zil_amount => match maybe_token_amount with | None => e = { _exception : "IntegerOverflow" }; throw e | Some token_amount => within_limits = let zil_ok = uint128_ge zil_amount min_zil_amount in let token_ok = uint128_ge token_amount min_token_amount in andb zil_ok token_ok; match within_limits with | False => e = { _exception : "RequestedRatesCannotBeFulfilled" }; throw e | True => existing_balance <- balances[token_address][_sender]; match existing_balance with | None => e = { _exception : "MissingBalance" }; throw e | Some b => new_pool = let new_x = builtin sub x zil_amount in let new_y = builtin sub y token_amount in Pool new_x new_y; is_pool_now_empty = poolEmpty new_pool; match is_pool_now_empty with | True => delete pools[token_address]; delete balances[token_address]; delete total_contributions[token_address] | False => pools[token_address] := new_pool; new_balance = builtin sub b contribution_amount; balances[token_address][_sender] := new_balance; new_total_contribution = builtin sub total_contribution contribution_amount; total_contributions[token_address] := new_total_contribution end; zils_out = Coins zil zil_amount; tokens_out = Coins token token_amount; Send zils_out _sender; Send tokens_out _sender; e = { _eventname: "Burn"; pool: token_address; address: _sender; amount: contribution_amount }; event e end end end end end end end end transition SwapExactZILForTokens( token_address : ByStr20, min_token_amount : Uint128, deadline_block : BNum, recipient_address : ByStr20 ) direction = ZilToToken; exact_side = ExactInput; exact_amount = _amount; limit_amount = min_token_amount; SwapUsingZIL token_address direction exact_side exact_amount limit_amount deadline_block recipient_address end transition SwapExactTokensForZIL( token_address : ByStr20, token_amount : Uint128, min_zil_amount : Uint128, deadline_block : BNum, recipient_address : ByStr20 ) direction = TokenToZil; exact_side = ExactInput; exact_amount = token_amount; limit_amount = min_zil_amount; SwapUsingZIL token_address direction exact_side exact_amount limit_amount deadline_block recipient_address end transition SwapZILForExactTokens( token_address : ByStr20, token_amount : Uint128, deadline_block : BNum, recipient_address : ByStr20 ) direction = ZilToToken; exact_side = ExactOutput; exact_amount = token_amount; limit_amount = _amount; SwapUsingZIL token_address direction exact_side exact_amount limit_amount deadline_block recipient_address end transition SwapTokensForExactZIL( token_address : ByStr20, max_token_amount : Uint128, zil_amount : Uint128, deadline_block : BNum, recipient_address : ByStr20 ) direction = TokenToZil; exact_side = ExactOutput; exact_amount = zil_amount; limit_amount = max_token_amount; SwapUsingZIL token_address direction exact_side exact_amount limit_amount deadline_block recipient_address end transition SwapExactTokensForTokens( token0_address : ByStr20, token1_address : ByStr20, token0_amount : Uint128, min_token1_amount : Uint128, deadline_block : BNum, recipient_address : ByStr20 ) ThrowIfExpired deadline_block; ThrowIfZero token0_amount; ThrowIfZero min_token1_amount; after_fee <- output_after_fee; maybe_pool0 <- pools[token0_address]; result0 = let direction = TokenToZil in let exact_side = ExactInput in let limit_amount = None {Uint128} in let swap = Swap maybe_pool0 direction exact_side token0_amount limit_amount after_fee in resultFor swap; match result0 with | Error msg => e = { _exception : msg }; throw e | Result pool0 zil_intermediate_amount => maybe_pool1 <- pools[token1_address]; result1 = let direction = ZilToToken in let exact_side = ExactInput in let limit_amount = Some {Uint128} min_token1_amount in let swap = Swap maybe_pool1 direction exact_side zil_intermediate_amount limit_amount after_fee in resultFor swap; match result1 with | Error msg => e = { _exception : msg }; throw e | Result pool1 output_amount => DoSwapTwice pool0 token0_address pool1 token1_address token0_amount zil_intermediate_amount output_amount recipient_address end end end transition SwapTokensForExactTokens( token0_address : ByStr20, token1_address : ByStr20, max_token0_amount : Uint128, token1_amount : Uint128, deadline_block : BNum, recipient_address : ByStr20 ) ThrowIfExpired deadline_block; ThrowIfZero max_token0_amount; ThrowIfZero token1_amount; after_fee <- output_after_fee; maybe_pool1 <- pools[token1_address]; result1 = let direction = ZilToToken in let exact_side = ExactOutput in let limit_amount = None {Uint128} in let swap = Swap maybe_pool1 direction exact_side token1_amount limit_amount after_fee in resultFor swap; match result1 with | Error msg => e = { _exception : msg }; throw e | Result pool1 zil_intermediate_amount => maybe_pool0 <- pools[token0_address]; result0 = let direction = TokenToZil in let exact_side = ExactOutput in let limit_amount = Some {Uint128} max_token0_amount in let swap = Swap maybe_pool0 direction exact_side zil_intermediate_amount limit_amount after_fee in resultFor swap; match result0 with | Error msg => e = { _exception : msg }; throw e | Result pool0 input_amount => DoSwapTwice pool0 token0_address pool1 token1_address input_amount zil_intermediate_amount token1_amount recipient_address end end end