From 9eb48cd6551ee842323d4fd7e900f14a69afb1ff Mon Sep 17 00:00:00 2001 From: Igor Yalovoy Date: Tue, 18 Feb 2025 21:22:46 -0600 Subject: [PATCH] Updated auction allocations and clear-auction.js to implement a uniform-price auction aiming to raise a specified total USDC amount, added verification for allocations, and adjusted scripts for setting auction root. --- script/data/auction/allocations.txt | 321 +++++++++++++++++++++++++++- utils/auction/clear-auction.js | 225 +++++++++++++------ utils/auction/scripts.md | 2 + 3 files changed, 483 insertions(+), 65 deletions(-) diff --git a/script/data/auction/allocations.txt b/script/data/auction/allocations.txt index df6ae965..fdf8874b 100644 --- a/script/data/auction/allocations.txt +++ b/script/data/auction/allocations.txt @@ -378,4 +378,323 @@ 0xd5724050fA47d3E54dAd4b94e024B2E618F8159A 83950999950000000000 1679019999 0 0xd6957C35fD61C6705bbDbd7b6fC6B55dD6219CeA 37197850000000000000 743957000 0 0xdAa4dABEC8626C537F59a6073bD35FB0A1290350 99999999950000000000 1999999999 0 -0xdF2120120a77591353EB24c25E6d78Fa64ef2965 323781998350000000000 6475639967 794360033 +0xdF2120120a77591353EB24c25E6d78Fa64ef2965 363500000000000000000 7270000000 0 +0xdeB6d1D8B199Ce89C520100BA2bE493eE45Ba41c 119897500000000000000 2397950000 0 +0xdf7D9A5E684960260F115f39406e5eEFa7F7470a 994253999950000000000 19885079999 0 +0xe04c374F68Af851b1f9F9d2be151F094856161F6 27536000000000000000 550720000 0 +0xe0b29E9E1DeeCbEc789500241b55d2A5d446D455 38050000000000000000 761000000 0 +0xe56bbB2D1A3C77dBfEca02361e154F5a6df4D874 1526079999950000000000 30521599999 0 +0xe70D804197627c7C6c495be5F0bC0fACfa98606E 232658500000000000000 4653170000 0 +0xe6A855049273b25179DD35F1795B7BcE6898b9f3 26552999950000000000 531059999 0 +0xe8c92c988a2D920442ED238534033A7Bac284916 100018000000000000000 2000360000 0 +0xe9D3DbC477146576Cf29De89d1b75850Cd466B84 15066999950000000000 301339999 0 +0xe9b7d7Eb95629ba852c99E2203D36cdB08a0CAE5 25000000000000000000 500000000 0 +0xeA5Adbf0806C1c883B213790367709EE4a286537 58298999950000000000 1165979999 0 +0xeDf0d1bC81109709C69d2192b7Be642B00779ABC 315045999950000000000 6300919999 0 +0xeeEcb749d7481dd0d4C5807754Ee4ef7f3c6a6FB 12586499950000000000 251729999 0 +0xeead23E83AC9139ec420b1083467fa05EDE5616E 22499999950000000000 449999999 0 +0xf0c8be994bd2E31c583f1C44B720Fea6FD2614dC 50344999950000000000 1006899999 0 +0xf2386063289ef5366B7D05EAffe61e985aF6f010 374199999950000000000 7483999999 0 +0xf3f819B1Fe0d627ddCFB1BB9660B02F1A531006c 25110499950000000000 502209999 0 +0xf419AfF873B6256517acfad6D885fC6a2E1437f2 20000000000000000000 400000000 0 +0xf60222db3f9930093bDf574B23d0Dd59fF3E6997 24999999950000000000 499999999 0 +0xfB80dFD3fd53A65cc24b7671f8FBB4b907Df8D55 35538000000000000000 710760000 0 +0xfD088c45926a4759d706570EC694c1D30677862E 155499999950000000000 3109999999 0 +0xfDa6c44F8dDA87Cde9F75c916F387314873a0F1F 27049999950000000000 540999999 0 +0xfa919faA87D6920deE261FcD5eDf398351548C36 25199999950000000000 503999999 0 +0x55845AccEdEF1FD494CD6c307f8660b35ED3131b 15000000000000000000 300000000 0 +0x7D42148aaF944F973861294926F76aE2005aE01A 30292999950000000000 605859999 0 +0x7c36b55E3b260A89ab5Dda6096ae0175658412cb 25010000000000000000 500200000 0 +0xE3923ddEBfa124500Dc463735930cE25bFBB5628 15249999950000000000 304999999 0 +0xda6f319fDaC0b5cddB33F65d41767B200Cb1702e 90040000000000000000 1800800000 0 +0x1d43b76e1B9B6C8E8694909462eF283C600CA856 58999999950000000000 1179999999 0 +0x45cba3b9b5662D8E86f90cFd69F36823147ecA45 25302000000000000000 506040000 0 +0x4f335ec576FC8e7b0072F695693AC65782Bdc9DB 37576499950000000000 751529999 0 +0x93d6fBe57B6C21865a42F143B5bc146BcE26b736 50049999950000000000 1000999999 0 +0xd07b776302e0e65a060B6caBb1d5dB224cab7Ce6 252000000000000000000 5040000000 0 +0x3057eDE4416B594741f6efd5Fb9C5b5BF6E993Cb 90243499950000000000 1804869999 0 +0x37D076027EEB4A464AFb1fbCF54605F5589Cf7bB 40000000000000000000 800000000 0 +0x4AF56fD53ECdE6D1B7E6E171213a06E2969aFEb2 54999999950000000000 1099999999 0 +0x684c741B595ED00799bfC8CD2Bc912f8e81B96a4 256112000000000000000 5122240000 0 +0x7bEe324303475E8e8B9ab76659eEd2b81897Af64 30050000000000000000 601000000 0 +0xF4c5d74d36356d114e4C245b7Ec1a88faAD77d3C 26009499950000000000 520189999 0 +0x1B7610d912384Be798859CE9511034f32e8eA141 66259499950000000000 1325189999 0 +0x2DE10B4199a1cBC8587117c8776160B16bb31E49 152656499950000000000 3053129999 0 +0x33e8c8CF11Bc0807a3e8f0776c62D661372F4026 24775499950000000000 495509999 0 +0x64DbbCdc891B91A022ca7e5F35F8D5A0B84ABECd 37948999950000000000 758979999 0 +0xD2808024a1b5539c11B006A1B6eC6450A1CCeA6b 25433000000000000000 508660000 0 +0xf623c87ca0Ce95316EBB33e2139Ff9D33954B4d4 12749999950000000000 254999999 0 +0x06046Aa07Be829b6a941F32F21408a0FC0A9A64e 300002999950000000000 6000059999 0 +0x0958e9253Ca69a3CAe91FcaCaA896326f9Bf0DF7 50000999950000000000 1000019999 0 +0x0D170edc622a15d310F3ef97Cab2DC6A6C09D00b 49999999900000000000 999999998 0 +0x0dA62fE23CE0b03548ECcd977d0C741b663393da 12575500000000000000 251510000 0 +0x1696C867e6D8F06Fec3cdb8ce596767917ED85C1 49149999950000000000 982999999 0 +0x25Ce5AD43e016b77cCa2061B3457CEE87be1e8A7 25026500000000000000 500530000 0 +0x2a459d76D7Eeb299D939E17a295D6016F53b8f93 37499999950000000000 749999999 0 +0x3001535F4fe775c59D5AC8428ba08e2049ed45Eb 29999999900000000000 599999998 0 +0x3C6386e7ED61c5e0AFCA304CC8a6eD0F349F7EEF 500000000000000000000 10000000000 0 +0x42dA8cA85e4E178aF48E7518978cBAEB1fBd0d87 100999999950000000000 2019999999 0 +0x45511Fce841b6D4Ee3c8F97355a4c37f0412E24c 15168999950000000000 303379999 0 +0x46915d0edFb2b0cA6164e645A4abAe5c317F57B4 150003000000000000000 3000060000 0 +0x555a3E5599304d26ad85E4Cf50615001F2Cf0d31 12733500000000000000 254670000 0 +0x565792089b634be6e021e6CD494896b55e3DC03B 49999999950000000000 999999999 0 +0x7760363384dCc4Df92843C5aB764c94B2679b08C 22565000000000000000 451300000 0 +0x7e6071bb0E16B1FB28e1957b861B26117E56cC3F 49999999950000000000 999999999 0 +0x862b09C531158d54742e4B0598D9bA395e4866aB 24999999950000000000 499999999 0 +0x91398A10e4fC6aB59Ce3998dEe667438270FEFD9 24999999950000000000 499999999 0 +0x94f439C33fAF9D6Bb6720FD6963D383d2F428969 25069999950000000000 501399999 0 +0x974E38164B58f344098E865E981d8a33697FFB32 12500000000000000000 250000000 0 +0xB5ee0d379BeDDd0DB5Dc6bC76EF36B2B33cf23e9 55869500000000000000 1117390000 0 +0xB97A9d24C93a74163E4ddca8fbb4b01490Ffb4B3 15042999950000000000 300859999 0 +0xD939c6f7B8F2e830111Aa61a591EE94A0FB7f1c6 14999999950000000000 299999999 0 +0xE795628Fc899b91b771F276df498d91CE7995720 74999999950000000000 1499999999 0 +0xF95A86005BC440Ea63e1C57E5428A30bF2C67FB6 17499999950000000000 349999999 0 +0xFFE364B44Ace10f005ec8cd07b78De8904aca0F1 26499999950000000000 529999999 0 +0xa7b3e903d6EA855eAF3e2706FD69De4BAb31dfe6 25442999950000000000 508859999 0 +0xd39004cE657e2Ec0175f9ea24Ef2fcFFfFc9D889 70499999950000000000 1409999999 0 +0xd53a9846A502BaD2863F1DC51D568858C775dF64 25000000000000000000 500000000 0 +0xd99Fb6981dE228f7BcF794f8c4D064c41caf4D76 61941500000000000000 1238830000 0 +0xdb8337a527312dB10411250e7fA8636c95449cdB 25294999950000000000 505899999 0 +0xf1e7c3dcCbBB3B1413E6D0dEB68B1B89acA551e6 49999999950000000000 999999999 0 +0x470Bb9F01dC93C73e51a01ef3aE4554Cec49bdBB 29908499950000000000 598169999 0 +0x9f10BF1Bfc3A5430885afbf4D6463A4f36738E95 25049999950000000000 500999999 0 +0xE8277F8bc6B4D0eF0615Cb14688388FE92aB5523 46000000000000000000 920000000 0 +0xdFE8c67e6907F8Fd929d46EeD3B86f2141179B83 29600000000000000000 592000000 0 +0x467a3E952a3d3C2F73169Cc0446F2ed833cc5C33 49999999950000000000 999999999 0 +0x63c4b9aa708fA4DCA9b09E74CfE36608520E0a99 24048000000000000000 480960000 0 +0x827dCd4CfC651e4a658B58a5Ce7545Dd76A3aD96 15150000000000000000 303000000 0 +0x8749aB07aefED63E3e415865D8bF7E6B78D87b5A 24999999950000000000 499999999 0 +0x98D008f7bf597C288133F913f5c0285fbD30D20C 52499999950000000000 1049999999 0 +0xF57119364538b345eabF07c54bdfdB64Bd99c9e3 59999999900000000000 1199999998 0 +0x49EB4A31Cdec5Ede4EA7675bF3964daD248ec3B2 12542999950000000000 250859999 0 +0x559620cdE492d431bf2Aa81bB7113fD1590b422C 264400000000000000000 5288000000 0 +0x6A27aEa4ab969875e175Ad7100e0CdDa5324F36E 50000000000000000000 1000000000 0 +0x7A04605FC8ad994B21957DA7a8846F88cB18CaEd 50290000000000000000 1005800000 0 +0x8842Cc427D8b5227DA65d16939c5128905C5f40d 14949999950000000000 298999999 0 +0xF31a21FE9a0f58516b260d8f23b1102eca6d814C 25002499950000000000 500049999 0 +0xF50611b2D37879c61efEd12B98247b6D938493b0 15049999950000000000 300999999 0 +0xbbbd3bFC02e7Ca1D75fD91f7421AEC142c9B9005 25999999950000000000 519999999 0 +0x04e78Fb382d025D61E34290162D3Bbe4457aC299 12500000000000000000 250000000 0 +0x1173e535DAAAceaD5745D1f5f19C64723427e1DC 29345999950000000000 586919999 0 +0x1bB1207A5dd6D55026C65344820e3764301bB3F9 59999999950000000000 1199999999 0 +0x2526FeACD8dAc4B56aA670EaF6a2CD0f44Dd14D2 25100000000000000000 502000000 0 +0x364482A404171B8135DF6E3FA6AfDcAd973E9661 125000000000000000000 2500000000 0 +0x4babe97B39018eF602f894D825dB7Dc0101ec6B8 512500000000000000000 10250000000 0 +0x50Fb487E36C769066bCBE3612bA3F82fCB73b94F 39999999950000000000 799999999 0 +0x5A197c816aEea9E33f0736Ced248FA2f7cD64Ff7 49949999950000000000 998999999 0 +0x670201f07724bB4b9a5b8aE118e58EAEcfD9F503 25091999950000000000 501839999 0 +0x69B624370c13C275747f829284EA2e3c13930b90 21499999950000000000 429999999 0 +0x6B2aF11899cAb936e22d8c80c17B8d594CF8EaAf 35039999950000000000 700799999 0 +0x876428C8Bb2F8F34beDCC25712e97765501de118 50140500000000000000 1002810000 0 +0xB56ba08e1d21A6424787dA793126CD3A9272A34E 43499999950000000000 869999999 0 +0xD60EbDb4913486fBe596793380BD44b297f25D44 199999999950000000000 3999999999 0 +0xd42750D5025D74bd49f87F18b9B636e8542B61cA 20127999950000000000 402559999 0 +0xe2a5F2cc9eab18895aDa4866206fb6bfA560681d 204521000000000000000 4090420000 0 +0x01df689F929b1F3e97fF84128bFE298bE35bB6ac 15835002050000000000 316700041 733299958 +0x03E14EeC725AB3e44344d0fA57b40E7faf04D419 0 0 1000000000 +0x03b6cE61c75f274DF3686AE4b65EF60B381E4C99 0 0 299290000 +0x06a0e040129320292BcB7ACd91fE734Ffb040c45 0 0 252000000 +0x08D1f66A9Fc2CFd268626De82C8658DA1Bf68A1b 0 0 500999999 +0x096a72d48B591b0AFeC441124E555f2D1BE126b3 0 0 999999999 +0x09f69f942eDfAFe2F549C64d2d993D26BFd66B7a 0 0 499999999 +0x0D8C40Ab2F2a67DF76892Ec15A368dE297f5A6d7 0 0 2000000000 +0x0d4E7aD7b0d1A798db7026123539B2Da28df339E 0 0 259999999 +0x0d8636bd068Fe6Aee2B3ea20e98255ADD33Ec208 0 0 511499999 +0x11080d692e63490D29E0dFC3f81100E51F3230f3 0 0 260000000 +0x115649E42fF931Ee0ED50672F9f99891bAAb01e3 0 0 503670000 +0x13bFaA14b1769f1D674a3021426CfA5Ed7FDB1eA 0 0 500000000 +0x15e58f8Bd1827B1f05D89AeC8cdB7330Fcb35dA8 0 0 500000000 +0x15b5d066056C747BBf8d6c2e18c006fC9A06Bb88 0 0 1599999999 +0x18c845d1AA7A07A1a4b4dEd3A076ADAaE12C240B 0 0 497999999 +0x197254C61fF522e8758F4Ef6a266961DecAF75e8 0 0 255840000 +0x19B771C6Fa986DCfD9d04384bB57eE6eD173806e 0 0 263439999 +0x19d71c73e8c153bbDe0EF4A5343DFa56D0133238 0 0 277610000 +0x1A0DfD49a2057BFe99eC322C04dF31fC75D16F10 0 0 250750000 +0x19ec1A77A161a6D7B3a0f4dE4Aa5660Ea44213e1 0 0 349999999 +0x1BaD097161f1Ca04854b93EfF27cb6b0677A3f57 0 0 600459999 +0x1CE4E6a259D9514EA61652a2D93e3cCB89303372 0 0 502130000 +0x1FE3Fb2b0c065525Ac861A3d22331996285Ab2A2 0 0 5001000000 +0x2481e8DA1315dcaaD122c4b1cb988EB236370014 0 0 250999999 +0x26Edf3bB1877951a715a1B72a04fFA985620ECea 0 0 300959999 +0x27a271b2A0C4Dd653D417c0d53a9a8661A0dc2F6 0 0 999999999 +0x28fD136f5F3f45Ea20CFe0d7FEFEF8BEA2276cf0 0 0 500000000 +0x2B77aFc4b79ED9e7b4C51623E79bF6bDC2712568 0 0 549999999 +0x2aA937FB3547b8Eb867F1a32e4Aa66Cc45997020 0 0 1341110000 +0x2aF0AcE73a238Fb7A63475fFEf6d6F7C44148ACb 0 0 254000000 +0x2b9798745734E81C3060871045F8c7a3c8Eb2caB 0 0 262160000 +0x31334C8A318231B5128b22B1C11eE5cB460ab1Ed 0 0 253000000 +0x31F93EA423cf2E59bc96c06d4b131a8cc9FA9eC4 0 0 300500000 +0x34bd5c28D3dF07532b2467611C2F91d19fa2FB62 0 0 502960000 +0x35D6505323F8657BbfA70dAc710Bd21eC71F94E9 0 0 499499999 +0x36B7D28e14354104F18C08aaE1d963c3758c4980 0 0 4302999999 +0x37C6B8503551a925C43683008E8F849Fa178BAC7 0 0 2449000000 +0x3Ac55670858a6f05815b70D415daFB382c93a90c 0 0 1999999999 +0x43578b59F18e76eaB6ffC57f679a966747d80076 0 0 262970000 +0x4409eAe77d69c2893BeF98B226144a376389922B 0 0 708499999 +0x440a73C76E032D8154246a0D7403AAA9E438DB8b 0 0 600000000 +0x446AA060DFCaa895f166A9E84c43d955a9886a0d 0 0 499999999 +0x4723e2907E42088dEA70a013A0b37b0ef3AAbB0B 0 0 2001240000 +0x475aaD6032F8c8FDaB4a1d1433A36ffD110E82D2 0 0 685410000 +0x4CB6bdD49372E998b1DbFaB47ad78Bfa9d15CaD1 0 0 499999999 +0x4bFef19230d7fE1A1D6A1c3AA72B48841c95c234 0 0 300000000 +0x505aF8517199781Bf0421Db0C086aebA332e2cFa 0 0 2000000000 +0x54875bd23B33f46b7502420730b102539bb905F2 0 0 999999999 +0x553f1B3a739fc3c1E3ce66d7Bbd317c275F0aeFE 0 0 4999999999 +0x567F86E6ca46dFc0CC024B6ddAb1CB66807C1653 0 0 549090000 +0x59a5a652727B37a81e53DA8c224228Bd08Ce8291 0 0 259550000 +0x5A53676B3268920fC110e7d0010C8a97E827716B 0 0 701540000 +0x5A17B52E3cFFff670F12de430b65abf55650F64e 0 0 6000000000 +0x5d540f8d004AbFE6f728247d062857FF7d9f477c 0 0 252000000 +0x5cEB11AA039384404ed70224A6312Cb101f10Eb8 0 0 2815999999 +0x61d85A78269f538DAB42a8C63F90e809D8E2AF58 0 0 3500000000 +0x644011F52f5cc3d5eB4079F81ECd9C9A48e9D473 0 0 1000999999 +0x64c934daB3298af65aD59B9804A329390ce32f0C 0 0 499999999 +0x65C9dEdB4A730F7FC428Ff4eE1aADE9A487BdD3C 0 0 999999999 +0x66b91b7Cd979eF8f541e00EA0Db1e2b27aA5c0db 0 0 500799999 +0x675b303136df42E45886D5EC80A10790E026a8b0 0 0 500799999 +0x67Ac347Ebe4b8126F5F40150e072a19ef628127e 0 0 699800000 +0x681567fC4e68d03fe94D3816B65AD8c08d2625ba 0 0 900999999 +0x695Ea479622639C61dD7474E39D70E847561CD22 0 0 546390000 +0x6BD452D6cb262DD10c5772C8f3e7E4766Fabf151 0 0 649999999 +0x707d9ef3ef7a6417A9640637CF3DB2C5ea0710C3 0 0 460320000 +0x7117579455C472D42Fb3a14c43aa5B0b8E0cF591 0 0 255070000 +0x723F39De7B33140539c49C80664E8E1dfda8d958 0 0 257409999 +0x7305a87B5cDC9fDF632aD435F660D65028dDb575 0 0 2024060000 +0x80bed4FF87B188961338e2817Bd3B02B1Ff5682b 0 0 1017399999 +0x824742Bf0F62e6e843b375F9da8ee64C22b7a22A 0 0 449999999 +0x856EF9bbaf269583DE7B64A762Ef63dE120b50A8 0 0 749999999 +0x8A34d74E45f0e4936Ac2970eF750Aa5ea809606C 0 0 600000000 +0x8E5E242c4DbeFD97f9aCfa00117B101587969061 0 0 554900000 +0x8E72bCAAafba328b17d3167b32E9049C3c946fCc 0 0 1039800000 +0x8F057B714F256430a96808121597E204a306DcB1 0 0 252779999 +0x8aE0d0F59db2594a3A7565fe7dc565e963e5F621 0 0 400000000 +0x8cC6535DE8E3E2fb8ce27d3ADE08c85Eb1A04ACe 0 0 547449999 +0x8dAB2343B1f380081637ebA1470b21B02413A6D0 0 0 500300000 +0x8f42Fbc3827540d94E77F2CADb01026Bc5CD6729 0 0 1999999998 +0x905402A70824CDB2F4EC09Fb2E2104baccF1Ac7e 0 0 299999999 +0x9284b53e264CABfb861BB665b8094f1dadf40A3d 0 0 4850999999 +0x9294469a3B69592d0EF894204cA80B510052E8B5 0 0 430529999 +0x93B36B6cc8c2da184F4eB04A9aE9AA2D570C853f 0 0 999999999 +0x97A8296339A76189282c18196c13BaCda465149A 0 0 500909999 +0x98493160CF7dC30b1F3751Cbc256C7325F00dC27 0 0 812000000 +0x9Bf99aB3acE46581979Cf282Ae803acC4d142390 0 0 2249999999 +0xA1DB7FFe85ED54EBf3D5754fFB97818E7E204F1f 0 0 950000000 +0xA20E11dBF21a524fEb2Aa769a59f16ECF188D624 0 0 1032720000 +0xA811c306557370B90Cf92F207d94ab43D0FaF013 0 0 999999999 +0xAbd5629AA0DA8475147e25ED5D103dF0c3e90A01 0 0 251679999 +0xB0d7741F5AcfCB4eEA78820C789D237640A4e586 0 0 499999999 +0xAf22b71C2b2C15B5837ac3Cc2Bc3f51235250Dce 0 0 253379999 +0xBAB6Ec471efb4A44349C90C7E7C6369cb01Ab718 0 0 600999999 +0xBE74161AcF4Df78B69dd2B14A2eDd0d17C9965CB 0 0 1029999999 +0xC93628E7776Eb37c56c916437A8E46256a23fEdB 0 0 255839999 +0xCab8B5F289Bf3422Fa923d8585FB6723B301Cf74 0 0 1503950000 +0xD25C7117Eb04337DbC84c06522A70A35B8cC30CE 0 0 501720000 +0xD307CBFd889f119d4F6b6b6bfcCBCd9FB43bF609 0 0 404000000 +0xD76b72F9D71680275681CaC012E76224B91C7C57 0 0 252000000 +0xD8d40db6aEC1076BA046dEa44ed6428cEc5f99d3 0 0 254869999 +0xDD07DF7bB27259231f4b57C970c72380D7389eA6 0 0 250000000 +0xDb7b25763AE63d5C1d45eA11657F8df7D8AE9bca 0 0 702520000 +0xDb9c71c464FF6943C52c1456753E9B3143afb84c 0 0 503920000 +0xE07dAE62455571d11E88ba83C2Bc934e8cd9BD51 0 0 996999998 +0xEf21f8c5AC1FA7bc0cF9431b721Fc2CA6a9fEDC2 0 0 255380000 +0xF59E3C0692f9200Ef0d1ecBC22fb0677b086A62B 0 0 800000000 +0xF9A666C16a05b35a9FD7D55B63A061Bd04CEa98e 0 0 650999999 +0xFa4a38B74c258Ab7469bf04AB41bA25910491F6F 0 0 499999999 +0xFbc42e3f8F2a06697b42580B19812e7bf64C42Db 0 0 1499999999 +0xFd5f160513373636d38F0237F44C1cE6A9a4d47a 0 0 259999999 +0xa005EaEDD5e8fA6bF9e86d37fdd92B0c759e9d44 0 0 304500000 +0xFdB3a148993974ED5156EC653477F7334D605845 0 0 1334999999 +0xFff4012Cfbc3C3261D396786fa084EE4b8c44408 0 0 500000000 +0xa5a600b404729cC8E7efC3978754a0F9AD19b3a7 0 0 299999999 +0xa76Ede6A137b7Ea7685B9F60343cB6177D8852dd 0 0 4001999999 +0xa774db1862ef77779bef0dbFadfF3217f70C83dC 0 0 502739999 +0xaB2109EFf3f2EfA143d12Dd6d3bb1D297584f07a 0 0 250859999 +0xadcCB8c2A895733A9d84c998fF271E8fEf25E74E 0 0 1997860000 +0xb0543cf8dEa187913ab21b3568323F3Fe43c6C24 0 0 365899999 +0xb17f6F305B2CFeA5FA9bC96cdB5e4f6F6C605112 0 0 499999999 +0xbE80C915750f2917062E559f64167770f2C1Ca67 0 0 1000850000 +0xbaBdCC559106497D2eeB65C5F888bca41881E35c 0 0 304899999 +0xbd18e1b69D817f0794a4fcdd03a23Dc13c3e6Feb 0 0 2000000000 +0xc1C5c94472920C09a50837A48d17E8fd5BB55c11 0 0 251860000 +0xc307b05992A71a9EA2CF20D6fe9EB4Cad7d10CB2 0 0 1350180000 +0xc67c25a0002EF8Bd0F38c03867378A22E18D03Ae 0 0 2704999999 +0xc8bdCb91b52A759B956557836BC5ba30d70309d2 0 0 270349999 +0xcE0b73D3822D39d5bea46a8B9e2dC0775B3c5207 0 0 500829999 +0xcaFF3ce1b139B46913ba3bc3237F59318747a304 0 0 2850000000 +0xce2dF4650232E55C3e1F46e3Cbc2588638Ddc600 0 0 312000000 +0xd35450970A8c5CB0061b4737Fa0abEe4d3C74594 0 0 499999999 +0xdA62542F06f97636244cD606FdA80906D5A6985A 0 0 308860000 +0xdF8137779Ff2C50D51cc27c86102edE6F314a376 0 0 502210000 +0xe4B69B086d3f1EcC9d93B32E1D10E5e91D2590B7 0 0 301840000 +0xe5015b6380E8F0b8Eea39D9292eFd33686eBBc9A 0 0 1201979999 +0xe9C5672042415dfF356e2aE7c7bD135DfA61B635 0 0 519999999 +0xeA0c4a7F4921b37869fc251960CFf46a14a47818 0 0 251919999 +0xeafb5424C9D326d4bc9e98ab6EF57fF10D458225 0 0 299289999 +0xeb7855eAc6f0269607B4745F173ce356d6007366 0 0 1000000000 +0xf0480894025Af29f86EBe3719D5b9417ea1E1676 0 0 1036829999 +0xf5AC2de82A6b9409f47B76De83b6D82cc7389b5E 0 0 555000000 +0xf9d38548C1b5de3126eDb75A14a8Bdf9e456B6c8 0 0 400860000 +0xfa1d290118763499b78707D16025031A0dD81BcE 0 0 250159999 +0x1F06d04cf57f8DeFFe6F63BBe58555C1cf0524f4 0 0 1000000000 +0x9529302B5959DD705c423F23D15a38AB161e591b 0 0 260499999 +0xeC1837AD8c812a7FC5bcFf613553D95C6056B080 0 0 1252830000 +0x2800d7F931A1C12a7cf5b1F7B9AE497D63Dd1559 0 0 500000000 +0x2DFa70A9Cd184673a7e506948e0A4C6E6653FC19 0 0 251859999 +0x437493d7Cb4B6cD20fe502399B9ad7bCbb9a83FE 0 0 4255000000 +0x74C5eBb4a3fC3B685d212d977F429941F262b27c 0 0 1440239999 +0x89dbd4Bb60F58C7cfc0900b445cD4A9D7A27a723 0 0 500000000 +0xB89c948e193F405067c6E380d2aA59387C28421F 0 0 1000000000 +0xc59fd15734ef41Cf04B0194092D6e536a13F8D0e 0 0 389999999 +0xdF3A35392563C546234C50EdF42f759736B13118 0 0 450000000 +0x1E300b80069E967576eD9946ab47f649d715FeB4 0 0 250859999 +0x65FF0a5Fc2398e3F9107246438C4b3F8281b2921 0 0 500190000 +0xF1B95C863819b29D48128bCB77839E6EC91c1952 0 0 503059999 +0xa4CfCBC5807b56519fA62D9de0161c8c65AD9A2a 0 0 349999999 +0xa868906a05951Fde74f5E1fB3670690B79Bd5FB8 0 0 2045999999 +0xc47771Ab0E37e8874a5F8458F206AcE18c51d7e2 0 0 1200000000 +0xdc98BC2d9DaaAa7b81c176971728F1Aeb9DA7a93 0 0 1001860000 +0x10395EFB8bA5cc40F9571483b95bAd48D8BCa253 0 0 299810000 +0x1bc292751D36d45901aDA1a49046A1852246a06C 0 0 261640000 +0x217C2280F2c32E8528f4F72e0BE603b5958ae22b 0 0 252999999 +0x2b4b858dA41aBa21C7D6ca60f1ACa02Cf2f48b31 0 0 499999999 +0x6E0A786F717fD84e864D83B084E06b4b66fa44C6 0 0 599899999 +0x7085e5a8601C36d2DF41De27DD8927497309d46f 0 0 5000000000 +0x8d2736A3bDbDaD7aa72fe0776805d3cf46834DC6 0 0 2039999999 +0xDb586C31be3531C19496d3dB3Ba781151E307670 0 0 381549999 +0xE3343d959B5a2c3Dcd94a50cD71135A3e9fEFc5F 0 0 500000000 +0xb83912AecDE1e2B86423d44072923483088a42fC 0 0 250000000 +0xbeAb395F191f35AC7D4A87Cc134F5f4E40005a6C 0 0 256950000 +0xf249017c645E7a8fE443A24109D1B5e0eC13D270 0 0 1622000000 +0x4524075c8fE1c716E3D06AFEAB95C169D7820032 0 0 428539999 +0x61f41fbbC871822898Aa252bf61930D608511C5E 0 0 999999999 +0x60AfeF4741749Ee320F5ba638570D7b1F17C8C83 0 0 999999999 +0x6fbEB648BbD08F59A225B034026F73Dff9DaD1C6 0 0 420759999 +0xB2a2D60D045159640F37bE41A8B8f6146E4bC4dC 0 0 999999999 +0xCe74f266B0D27087cec036CAbbC5B72d06FFb126 0 0 597999999 +0x031C75Ea14291317078C6156d45370A6e5871c49 0 0 502259999 +0x71029EF9E92b3e7d6E5EE15Dc374a704b97fcFd5 0 0 251830000 +0xf85052eCab627f39D17054cF1CfD8829Ec2d4238 0 0 299999999 +0x084413343A39Ced088977a1d906DcD63DeB2437C 0 0 501930000 +0x15497D32676589101C557bC0aA59615DEB07a16e 0 0 671049999 +0x1ad327e031D1Ec46476A6211Cb5e0c072AE51a6D 0 0 790359999 +0x2D266A0f7D3a8Ddea6D538919F6Df11cA8916Fb5 0 0 250999999 +0x2bdDD5d899534A958fbeE7a819D05A12F1d340d9 0 0 502010000 +0x2eC95b6d40882b1C8d06D03D88f89024e9c2e21e 0 0 522000000 +0x319E6a37BdbD30be7e9190B655D787DEf2D85309 0 0 300000000 +0x32Fcc094D5C1D4EC55f18aca3f7D773D6B1E6E4d 0 0 1399999999 +0x4105960055885de4898a90f6970Bf0928643D5C6 0 0 449999999 +0x4493c6B2C5025Ce0875a28C8d03b3A0F01F49D59 0 0 1000000000 +0x4d16291C1b676F505ee5B79DCb955D8Ba73ba8C8 0 0 300329999 +0x60A0A0977242d2514BFA9696EE346308d077AB38 0 0 499859999 +0x6C03a3A6a49C6e7262759aC20774Fa1446883A32 0 0 549999999 +0x74046392a33a6aCeD83C1b37E69FDb155e567ff9 0 0 49999999999 +0x87E220E6fcD80Cabf2A9E1Dc4940dE06AFcc5492 0 0 300059999 +0x9429cA4A4965C5598443B0E5eff87cE38ded86E1 0 0 992999999 +0x9D9b4E1444ad31Ae65B31117F5d1389d03BEa543 0 0 254569999 +0xA79F52AfbD8A4b1289924a9d4293d46b875187A5 0 0 500029999 +0xB1fCf1587A45319FaF2718209FdFbE07eea8eD27 0 0 1204999999 +0xCb097b5771fE96ab5c01a58bBA54A99dB7E05F10 0 0 509999999 +0xE695607378b109a18672B2d5375aF3cB48103D7c 0 0 2598550000 +0xdaDe6eFA8F9b2bbA407714Ed1b966Cf324912511 0 0 259000000 +0xe3C71ED9c02F32343b2bD25942E6578166FF9103 0 0 355009999 +0xf4C1822B9bcBF87E94C9b015781A5ADC61F99aFd 0 0 1000899999 diff --git a/utils/auction/clear-auction.js b/utils/auction/clear-auction.js index 2db8ac3e..2b5c5c8b 100644 --- a/utils/auction/clear-auction.js +++ b/utils/auction/clear-auction.js @@ -1,35 +1,31 @@ const fs = require('fs'); const path = require('path'); -const USDC_SCALE = 1_000_000n; // 1 USDC = 1e6 +const USDC_SCALE = 1_000_000n; // 1 USDC = 1e6 +const TOKEN_SCALE = 1_000_000_000_000_000_000n; // 1 TOKEN = 1e18 /** - * Runs a uniform-price auction using BigInt with: - * - USDC in 6 decimals (1 USDC = 1e6) - * - Tokens in 18 decimals (1 TOKEN = 1e18) + * Runs a uniform-price auction aiming to raise a specified total USDC amount. * * @param {Object[]} bids - * @param {string} bids[].address - Ethereum address. - * @param {bigint} bids[].usdcAmount - USDC in 1e6 units. - * @param {bigint} bids[].maxPrice - Max price in USDC’s 1e6 format. - * @param {bigint} bids[].priority - Priority for tie-breaks. - * @param {bigint} totalTokens - Total tokens to sell in 1e18 units. + * @param {string} bids[].address - Ethereum address. + * @param {bigint} bids[].usdcAmount - USDC in 1e6 units. + * @param {bigint} bids[].maxPrice - Max price in USDC’s 1e6 format (6 decimals). + * @param {bigint} bids[].priority - Priority for tie-breaks. + * @param {bigint} totalUSDCRequired - Total USDC (in 1e6) to be raised by the auction. * * @returns {{ * finalPrice: bigint, // Price per token in 1e6 USDC units (6 decimals) * allocations: { * [address: string]: { * tokens: bigint, // Tokens allocated (18 decimals) - * usedUSDC: bigint, // USDC used (6 decimals) + * usedUSDC: bigint, // USDC actually used (6 decimals) * refundedUSDC: bigint // USDC refunded (6 decimals) * } * } * }} */ -function runAuction(bids, totalTokens) { - // Constants for scaling - const TOKEN_SCALE = 1_000_000_000_000_000_000n; // 1 TOKEN = 1e18 - +function runAuction(bids, totalUSDCRequired) { // 1) Sort bids by maxPrice (desc), then priority (desc) bids.sort((a, b) => { if (b.maxPrice === a.maxPrice) { @@ -38,22 +34,29 @@ function runAuction(bids, totalTokens) { return Number(b.maxPrice - a.maxPrice); }); - // 2) Determine the clearing price - let tokensAccumulated = 0n; + // 2) Find the clearing price by accumulating USDC until totalUSDCRequired is reached + let cumulativeUSDC = 0n; let finalPrice = 0n; - for (const bid of bids) { - // tokensDemanded = (usdcAmount * TOKEN_SCALE) / maxPrice - const tokensDemanded = (bid.usdcAmount * TOKEN_SCALE) / bid.maxPrice; + // We'll track the index of the "clearing bidder" and how much USDC we used from them + let clearingIndex = -1; + let partialUsedFromClearingBidder = 0n; + + for (let i = 0; i < bids.length; i++) { + const bid = bids[i]; - tokensAccumulated += tokensDemanded; - if (tokensAccumulated >= totalTokens) { + // If adding the full bid.usdcAmount crosses the required threshold + if (cumulativeUSDC + bid.usdcAmount >= totalUSDCRequired) { finalPrice = bid.maxPrice; + partialUsedFromClearingBidder = totalUSDCRequired - cumulativeUSDC; // can be full or partial + clearingIndex = i; break; + } else { + cumulativeUSDC += bid.usdcAmount; } } - // If finalPrice is 0, not enough demand to sell all tokens => "not successful" + // 3) If finalPrice is 0 => not enough demand => everyone refunded if (finalPrice === 0n) { const allocations = {}; for (const bid of bids) { @@ -66,13 +69,15 @@ function runAuction(bids, totalTokens) { return { finalPrice, allocations }; } - // 3) Allocate tokens - let tokensLeft = totalTokens; + // 4) We know the finalPrice and exactly how much we used from the clearing bidder const allocations = {}; + let usdcUsedSoFar = 0n; - for (const bid of bids) { - // If user bid below finalPrice => no tokens - if (bid.maxPrice < finalPrice) { + for (let i = 0; i < bids.length; i++) { + const bid = bids[i]; + + // If we've passed the clearing index, or the bidder's maxPrice < finalPrice => no allocation + if (i > clearingIndex || bid.maxPrice < finalPrice) { allocations[bid.address] = { tokens: 0n, usedUSDC: 0n, @@ -81,51 +86,120 @@ function runAuction(bids, totalTokens) { continue; } - // tokensWanted = (usdcAmount * TOKEN_SCALE) / finalPrice - let tokensWanted = (bid.usdcAmount * TOKEN_SCALE) / finalPrice; - if (tokensWanted > tokensLeft) { - tokensWanted = tokensLeft; - } + // If this is before the clearing bidder => full usage + if (i < clearingIndex) { + const usedUSDC = bid.usdcAmount; + const tokens = (usedUSDC * TOKEN_SCALE) / finalPrice; - // usedUSDC = (tokensAllocated * finalPrice) / TOKEN_SCALE - let usedUSDC = (tokensWanted * finalPrice) / TOKEN_SCALE; + let refundedUSDC = bid.usdcAmount - usedUSDC; + if (refundedUSDC < 2n) { + refundedUSDC = 0n; + } - // Refund leftover USDC. Clamp to 0 if negative or 1. - let refundedUSDC = bid.usdcAmount - usedUSDC; - if (refundedUSDC < 2n) { - refundedUSDC = 0n; + allocations[bid.address] = { + tokens, + usedUSDC, + refundedUSDC + }; + usdcUsedSoFar += usedUSDC; } + // If this is exactly the clearing bidder => partial usage + else if (i === clearingIndex) { + const usedUSDC = partialUsedFromClearingBidder; + const tokens = (usedUSDC * TOKEN_SCALE) / finalPrice; - allocations[bid.address] = { - tokens: tokensWanted, - usedUSDC, - refundedUSDC - }; + let refundedUSDC = bid.usdcAmount - usedUSDC; + if (refundedUSDC < 2n) { + refundedUSDC = 0n; + } - tokensLeft -= tokensWanted; - if (tokensLeft <= 0n) { - break; + allocations[bid.address] = { + tokens, + usedUSDC, + refundedUSDC + }; + usdcUsedSoFar += usedUSDC; } } - // If the loop broke early, ensure leftover bidders get 0 tokens - if (tokensLeft > 0n) { - for (const bid of bids) { - if (!allocations[bid.address]) { - allocations[bid.address] = { - tokens: 0n, - usedUSDC: 0n, - refundedUSDC: bid.usdcAmount - }; + return { finalPrice, allocations }; +} + +/** + * Verifies that the allocations are consistent with the bids and finalPrice: + * 1. For each bidder, usedUSDC + refundedUSDC == bid.usdcAmount + * 2. If finalPrice > 0, tokens == (usedUSDC * 1e18) / finalPrice + * 3. Sum(usedUSDC) + Sum(refundedUSDC) across all bidders == sum of all bids' usdcAmount + * + * Throws an Error if any check fails, otherwise logs success. + * + * @param {Object[]} bids + * @param {bigint} bids[].usdcAmount + * @param {string} bids[].address + * @param {bigint} finalPrice + * @param {Object} allocations + */ +function verifyAllocations(bids, finalPrice, allocations) { + let totalUsedUSDC = 0n; + let totalRefundedUSDC = 0n; + let totalTokens = 0n; + let originalTotalUSDC = 0n; + + for (const bid of bids) { + originalTotalUSDC += bid.usdcAmount; + + const { tokens = 0n, usedUSDC = 0n, refundedUSDC = 0n } = + allocations[bid.address] || {}; + + // Check that usedUSDC + refundedUSDC == original bid + if (usedUSDC + refundedUSDC !== bid.usdcAmount) { + throw new Error( + `Allocation mismatch for ${bid.address}: usedUSDC + refundedUSDC != bid.usdcAmount` + ); + } + + // Check token calculation if finalPrice > 0 + if (finalPrice > 0n) { + const expectedTokens = (usedUSDC * TOKEN_SCALE) / finalPrice; + if (tokens !== expectedTokens) { + throw new Error( + `Allocation mismatch for ${bid.address}: tokens (${tokens}) != expectedTokens (${expectedTokens})` + ); + } + } else { + // If finalPrice is zero, tokens must be zero + if (tokens !== 0n) { + throw new Error( + `Allocation mismatch for ${bid.address}: finalPrice=0 => tokens should be 0` + ); } } + + // Tally for global checks + totalUsedUSDC += usedUSDC; + totalRefundedUSDC += refundedUSDC; + totalTokens += tokens; } - return { finalPrice, allocations }; + // Check global USDC usage + if (totalUsedUSDC + totalRefundedUSDC !== originalTotalUSDC) { + throw new Error( + `Global USDC mismatch: (used + refunded) = ${ + totalUsedUSDC + totalRefundedUSDC + }, expected ${originalTotalUSDC}` + ); + } + + console.log(`verifyAllocations:`); + console.log(` ✓ All per-bidder checks passed`); + console.log(` ✓ Global USDC usage matches`); + console.log(` Total tokens allocated: ${(totalTokens / TOKEN_SCALE).toString()}`); + console.log(` Total USDC used: ${(totalUsedUSDC / USDC_SCALE).toString()}`); + console.log(` Total USDC refunded: ${(totalRefundedUSDC / USDC_SCALE).toString()}`); } // ---------------------------------------------------------------------- -// Read input file (address amount maxPrice priority) => BigInt +// Read bids from a file (address amount maxPrice priority) // ---------------------------------------------------------------------- function readBidsFromFile(filePath) { const content = fs.readFileSync(filePath, 'utf-8'); @@ -135,7 +209,9 @@ function readBidsFromFile(filePath) { for (const line of lines) { if (!line.trim()) continue; // skip empty lines - const [address, amountStr, maxPriceStr, priorityStr] = line.trim().split(/\s+/); + const [address, amountStr, maxPriceStr, priorityStr] = line + .trim() + .split(/\s+/); if (!address || !amountStr || !maxPriceStr || !priorityStr) { continue; // skip malformed lines } @@ -168,19 +244,40 @@ function writeOutputToFile(filePath, finalPrice, allocations) { // ---------------------------------------------------------------------- function main() { const inputFilePath = path.join(__dirname, '../../script/data/auction/bids.txt'); - const outputFilePath = path.join(__dirname, '../../script/data/auction/allocations.txt'); + const outputFilePath = path.join( + __dirname, + '../../script/data/auction/allocations.txt' + ); + // Read bids const bids = readBidsFromFile(inputFilePath); - // If we want to sell 1,000 tokens, in 18-decimal: - // 1000 tokens * 1e18 = 1e21 - const totalTokens = 40_000n * 1_000_000_000_000_000_000n; // 1000 * 1e18 = 1e21 + // Suppose we want to raise exactly 100,000 USDC. + // 100,000 USDC => 100,000 * 1e6 = 100_000n * 1_000_000n + const totalUSDCRequired = 1000_000n * USDC_SCALE; - const { finalPrice, allocations } = runAuction(bids, totalTokens); + // Run the auction + const { finalPrice, allocations } = runAuction(bids, totalUSDCRequired); + // Write the results to disk writeOutputToFile(outputFilePath, finalPrice, allocations); - console.log(`Auction complete. Final Price: $${(finalPrice/USDC_SCALE).toString()}.00. Results written to ${outputFilePath}`); + // Verify the allocations + try { + verifyAllocations(bids, finalPrice, allocations); + } catch (err) { + console.error(`Allocation verification failed: ${err.message}`); + process.exit(1); + } + + // Log + const finalPriceFloat = Number(finalPrice) / Number(USDC_SCALE); + console.log( + `Auction complete. Final Price: ~$${finalPriceFloat.toFixed( + 2 + )} USDC/token.` + ); + console.log(`Results written to ${outputFilePath}`); } // Execute if called directly (e.g. `node auction-bigint.js`) diff --git a/utils/auction/scripts.md b/utils/auction/scripts.md index 2aa84b26..bcdcac61 100644 --- a/utils/auction/scripts.md +++ b/utils/auction/scripts.md @@ -5,3 +5,5 @@ node utils/auction/clear-auction.js node utils/auction/build-merkle-proof.mjs + +ROOT=0x7dfe5c2d9e5871561b754e68eefb9015be76484d7b935fa34f6cba51f6b2c9b9 forge script script/actions/set-auction-root.s.sol --rpc-url kinto -vvvv --gas-estimate-multiplier 3000 --skip-simulation