diff --git a/README.md b/README.md index 3ea976f..2ccd453 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,28 @@ **Repository for P2Pix EVM contracts to be imported by the project.** +## SM Dependency Tree + +```rs +./contracts/ +├── DataTypes.sol +├── EventAndErrors.sol +├── lib +│ ├── auth +│ │ └── Owned.sol +│ ├── mock +│ │ └── mockToken.sol +│ ├── tokens +│ │ └── ERC20.sol +│ └── utils +│ ├── Counters.sol +│ ├── ReentrancyGuard.sol +│ └── SafeTransferLib.sol +└── p2pix.sol +``` +## Callgraph +![Callgraph](docs/callgraph.svg) + ## Usage ### Pre Requisites diff --git a/artifacts/contracts/DataTypes.sol/DataTypes.dbg.json b/artifacts/contracts/DataTypes.sol/DataTypes.dbg.json index 7e60a1d..b770d30 100644 --- a/artifacts/contracts/DataTypes.sol/DataTypes.dbg.json +++ b/artifacts/contracts/DataTypes.sol/DataTypes.dbg.json @@ -1,4 +1,4 @@ { "_format": "hh-sol-dbg-1", - "buildInfo": "../../build-info/6c9bcd31e56d59a208be7520d57707e6.json" + "buildInfo": "../../build-info/0d20d1f12753266e5824cbfb8a85b2b2.json" } diff --git a/artifacts/contracts/EventAndErrors.sol/EventAndErrors.dbg.json b/artifacts/contracts/EventAndErrors.sol/EventAndErrors.dbg.json index 7e60a1d..b770d30 100644 --- a/artifacts/contracts/EventAndErrors.sol/EventAndErrors.dbg.json +++ b/artifacts/contracts/EventAndErrors.sol/EventAndErrors.dbg.json @@ -1,4 +1,4 @@ { "_format": "hh-sol-dbg-1", - "buildInfo": "../../build-info/6c9bcd31e56d59a208be7520d57707e6.json" + "buildInfo": "../../build-info/0d20d1f12753266e5824cbfb8a85b2b2.json" } diff --git a/artifacts/contracts/EventAndErrors.sol/EventAndErrors.json b/artifacts/contracts/EventAndErrors.sol/EventAndErrors.json index e83bc5f..1cfa90a 100644 --- a/artifacts/contracts/EventAndErrors.sol/EventAndErrors.json +++ b/artifacts/contracts/EventAndErrors.sol/EventAndErrors.json @@ -69,12 +69,6 @@ "name": "token", "type": "address" }, - { - "indexed": false, - "internalType": "uint256", - "name": "premium", - "type": "uint256" - }, { "indexed": false, "internalType": "uint256", @@ -129,6 +123,25 @@ "name": "DepositWithdrawn", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "FundsWithdrawn", + "type": "event" + }, { "anonymous": false, "inputs": [ @@ -197,25 +210,6 @@ ], "name": "LockReturned", "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "PremiumsWithdrawn", - "type": "event" } ], "bytecode": "0x", diff --git a/artifacts/contracts/lib/auth/Owned.sol/Owned.dbg.json b/artifacts/contracts/lib/auth/Owned.sol/Owned.dbg.json index 1ee4b84..335e277 100644 --- a/artifacts/contracts/lib/auth/Owned.sol/Owned.dbg.json +++ b/artifacts/contracts/lib/auth/Owned.sol/Owned.dbg.json @@ -1,4 +1,4 @@ { "_format": "hh-sol-dbg-1", - "buildInfo": "../../../../build-info/6c9bcd31e56d59a208be7520d57707e6.json" + "buildInfo": "../../../../build-info/0d20d1f12753266e5824cbfb8a85b2b2.json" } diff --git a/artifacts/contracts/lib/mock/mockToken.sol/MockToken.dbg.json b/artifacts/contracts/lib/mock/mockToken.sol/MockToken.dbg.json index 1ee4b84..335e277 100644 --- a/artifacts/contracts/lib/mock/mockToken.sol/MockToken.dbg.json +++ b/artifacts/contracts/lib/mock/mockToken.sol/MockToken.dbg.json @@ -1,4 +1,4 @@ { "_format": "hh-sol-dbg-1", - "buildInfo": "../../../../build-info/6c9bcd31e56d59a208be7520d57707e6.json" + "buildInfo": "../../../../build-info/0d20d1f12753266e5824cbfb8a85b2b2.json" } diff --git a/artifacts/contracts/lib/tokens/ERC20.sol/ERC20.dbg.json b/artifacts/contracts/lib/tokens/ERC20.sol/ERC20.dbg.json index 1ee4b84..335e277 100644 --- a/artifacts/contracts/lib/tokens/ERC20.sol/ERC20.dbg.json +++ b/artifacts/contracts/lib/tokens/ERC20.sol/ERC20.dbg.json @@ -1,4 +1,4 @@ { "_format": "hh-sol-dbg-1", - "buildInfo": "../../../../build-info/6c9bcd31e56d59a208be7520d57707e6.json" + "buildInfo": "../../../../build-info/0d20d1f12753266e5824cbfb8a85b2b2.json" } diff --git a/artifacts/contracts/lib/utils/Counters.sol/Counters.dbg.json b/artifacts/contracts/lib/utils/Counters.sol/Counters.dbg.json index 1ee4b84..335e277 100644 --- a/artifacts/contracts/lib/utils/Counters.sol/Counters.dbg.json +++ b/artifacts/contracts/lib/utils/Counters.sol/Counters.dbg.json @@ -1,4 +1,4 @@ { "_format": "hh-sol-dbg-1", - "buildInfo": "../../../../build-info/6c9bcd31e56d59a208be7520d57707e6.json" + "buildInfo": "../../../../build-info/0d20d1f12753266e5824cbfb8a85b2b2.json" } diff --git a/artifacts/contracts/lib/utils/ReentrancyGuard.sol/ReentrancyGuard.dbg.json b/artifacts/contracts/lib/utils/ReentrancyGuard.sol/ReentrancyGuard.dbg.json index 1ee4b84..335e277 100644 --- a/artifacts/contracts/lib/utils/ReentrancyGuard.sol/ReentrancyGuard.dbg.json +++ b/artifacts/contracts/lib/utils/ReentrancyGuard.sol/ReentrancyGuard.dbg.json @@ -1,4 +1,4 @@ { "_format": "hh-sol-dbg-1", - "buildInfo": "../../../../build-info/6c9bcd31e56d59a208be7520d57707e6.json" + "buildInfo": "../../../../build-info/0d20d1f12753266e5824cbfb8a85b2b2.json" } diff --git a/artifacts/contracts/lib/utils/SafeTransferLib.sol/SafeTransferLib.dbg.json b/artifacts/contracts/lib/utils/SafeTransferLib.sol/SafeTransferLib.dbg.json index 1ee4b84..335e277 100644 --- a/artifacts/contracts/lib/utils/SafeTransferLib.sol/SafeTransferLib.dbg.json +++ b/artifacts/contracts/lib/utils/SafeTransferLib.sol/SafeTransferLib.dbg.json @@ -1,4 +1,4 @@ { "_format": "hh-sol-dbg-1", - "buildInfo": "../../../../build-info/6c9bcd31e56d59a208be7520d57707e6.json" + "buildInfo": "../../../../build-info/0d20d1f12753266e5824cbfb8a85b2b2.json" } diff --git a/artifacts/contracts/p2pix.sol/P2PIX.dbg.json b/artifacts/contracts/p2pix.sol/P2PIX.dbg.json index 7e60a1d..b770d30 100644 --- a/artifacts/contracts/p2pix.sol/P2PIX.dbg.json +++ b/artifacts/contracts/p2pix.sol/P2PIX.dbg.json @@ -1,4 +1,4 @@ { "_format": "hh-sol-dbg-1", - "buildInfo": "../../build-info/6c9bcd31e56d59a208be7520d57707e6.json" + "buildInfo": "../../build-info/0d20d1f12753266e5824cbfb8a85b2b2.json" } diff --git a/artifacts/contracts/p2pix.sol/P2PIX.json b/artifacts/contracts/p2pix.sol/P2PIX.json index 04d915b..34e712f 100644 --- a/artifacts/contracts/p2pix.sol/P2PIX.json +++ b/artifacts/contracts/p2pix.sol/P2PIX.json @@ -90,12 +90,6 @@ "name": "token", "type": "address" }, - { - "indexed": false, - "internalType": "uint256", - "name": "premium", - "type": "uint256" - }, { "indexed": false, "internalType": "uint256", @@ -150,6 +144,25 @@ "name": "DepositWithdrawn", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "FundsWithdrawn", + "type": "event" + }, { "anonymous": false, "inputs": [ @@ -238,25 +251,6 @@ "name": "OwnerUpdated", "type": "event" }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "PremiumsWithdrawn", - "type": "event" - }, { "inputs": [ { @@ -306,17 +300,17 @@ "inputs": [ { "internalType": "address", - "name": "token", + "name": "_token", "type": "address" }, { "internalType": "uint256", - "name": "amount", + "name": "_amount", "type": "uint256" }, { "internalType": "string", - "name": "pixTarget", + "name": "_pixTarget", "type": "string" } ], @@ -328,7 +322,7 @@ "type": "uint256" } ], - "stateMutability": "payable", + "stateMutability": "nonpayable", "type": "function" }, { @@ -403,11 +397,6 @@ "name": "remaining", "type": "uint256" }, - { - "internalType": "uint256", - "name": "premium", - "type": "uint256" - }, { "internalType": "string", "name": "pixTarget", @@ -587,14 +576,18 @@ }, { "inputs": [], - "name": "withdrawPremiums", + "name": "withdrawBalance", "outputs": [], "stateMutability": "nonpayable", "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" } ], - "bytecode": "0x60806040526001805560405162001806380380620018068339810160408190526200002a9162000123565b600080546001600160a01b031916339081178255604051909182917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d76908290a350600382905580516000905b80821015620000d6576000620000ae8484815181106200009a576200009a62000203565b6020026020010151620000e060201b60201c565b6000908152600460205260409020805460ff1916600190811790915592909201915062000076565b5050505062000219565b600c1b611000600160ac1b031690565b634e487b7160e01b600052604160045260246000fd5b80516001600160a01b03811681146200011e57600080fd5b919050565b600080604083850312156200013757600080fd5b8251602080850151919350906001600160401b03808211156200015957600080fd5b818601915086601f8301126200016e57600080fd5b815181811115620001835762000183620000f0565b8060051b604051601f19603f83011681018181108582111715620001ab57620001ab620000f0565b604052918252848201925083810185019189831115620001ca57600080fd5b938501935b82851015620001f357620001e38562000106565b84529385019392850192620001cf565b8096505050505050509250929050565b634e487b7160e01b600052603260045260246000fd5b6115dd80620002296000396000f3fe6080604052600436106100e85760003560e01c80636193cdfb1161008a5780638e2a3d36116100595780638e2a3d36146102f55780639872dbfe1461032757806398a268711461033d578063bfe07da61461037d57600080fd5b80636193cdfb1461026857806372fada5c1461027d5780638da5cb5b1461029d5780638e2749d6146102d557600080fd5b80632dfdf0b5116100c65780632dfdf0b5146101d857806336317972146101ef5780634b2ae9801461020f5780634e1389ed1461024857600080fd5b806303aaf306146100ed57806313af40351461012057806316d7224014610142575b600080fd5b3480156100f957600080fd5b5061010d6101083660046111e7565b610390565b6040519081526020015b60405180910390f35b34801561012c57600080fd5b5061014061013b366004611269565b61053a565b005b34801561014e57600080fd5b5061019f61015d366004611284565b60066020526000908152604090208054600182015460028301546003840154600485015460059095015493949293919290916001600160a01b03918216911686565b6040805196875260208701959095529385019290925260608401526001600160a01b0390811660808401521660a082015260c001610117565b3480156101e457600080fd5b5060025461010d9081565b3480156101fb57600080fd5b5061014061020a36600461129d565b6105e0565b34801561021b57600080fd5b5061010d61022a366004611269565b600c1b750ffffffffffffffffffffffffffffffffffffffff0001690565b34801561025457600080fd5b506101406102633660046112e9565b6106a0565b34801561027457600080fd5b50610140610962565b34801561028957600080fd5b50610140610298366004611284565b6109f2565b3480156102a957600080fd5b506000546102bd906001600160a01b031681565b6040516001600160a01b039091168152602001610117565b3480156102e157600080fd5b506101406102f036600461133c565b610a7a565b34801561030157600080fd5b50610315610310366004611284565b610b76565b6040516101179695949392919061137e565b34801561033357600080fd5b5061010d60035481565b34801561034957600080fd5b5061036d610358366004611284565b60046020526000908152604090205460ff1681565b6040519015158152602001610117565b61010d61038b36600461140c565b610c46565b600061039a610e00565b6103a48383610a7a565b60008881526005602052604090206004810154600160a01b900460ff166103de57604051635972996f60e11b815260040160405180910390fd5b8054851115610400576040516308aeed0f60e21b815260040160405180910390fd5b61040b89868a610e2b565b915060006040518060c001604052808b81526020018881526020018781526020016003544361043a91906114a9565b81526001600160a01b03808c166020808401919091528b82166040938401526000878152600682528381208551815591850151600183015592840151600282015560608401516003820155608084015160048201805491841673ffffffffffffffffffffffffffffffffffffffff1992831617905560a085015160059092018054929093169116179055835491925087918491906104d99084906114c1565b9091555050604080518b81526020810188905284916001600160a01b038c16917f2a28b2ae47b0bd4b104e7cd29b1dfa72846af8c4cfdc009da2ae29db68cb67ea910160405180910390a3505061052f60018055565b979650505050505050565b6000546001600160a01b031633146105885760405162461bcd60e51b815260206004820152600c60248201526b15539055551213d49256915160a21b60448201526064015b60405180910390fd5b6000805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081178255604051909133917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d769190a350565b6105e8610e00565b6105f183610eaf565b6105fb8282610a7a565b60008381526005602052604090206004810154600160a01b900460ff1615156001141561062b5761062b846109f2565b600481015481546000835560038301546001600160a01b03928316926106549184911683610eec565b604080518781526020810183905233917f7719804546c0185709e60c90d164447ff251a5ba29af0216faa921350f6bebf7910160405180910390a250505061069b60018055565b505050565b6106a8610e00565b6000858152600660205260409020600381015443108015906106cc57506002810154155b156106ea576040516331da482760e11b815260040160405180910390fd5b80546000908152600560209081526040808320600280860154925191949361071893918601928b9101611513565b60405160208183030381529060405280519060200120905060008160405160200161076f91907f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c810191909152603c0190565b60408051601f1981840301815291815281516020928301206000858152600790935291205490915060ff161515600114156107bd57604051637a48537560e11b815260040160405180910390fd5b6040805160008082526020820180845284905260ff881692820192909252606081018990526080810188905261083f9060019060a0016020604051602081039080840390855afa158015610815573d6000803e3d6000fd5b5050604051601f190151600c1b750ffffffffffffffffffffffffffffffffffffffff00016919050565b60008181526004602052604090205490915060ff1661087157604051632057875960e21b815260040160405180910390fd5b6004840154600186015460028701546001600160a01b0390921691600091610898916114c1565b60006002890181905560038901819055868152600760205260409020805460ff1916600117905560048801549091506108dc9083906001600160a01b031683610eec565b60018701541561090757600587015460018801546109079184916001600160a01b0390911690610eec565b60048701546040518d81526001600160a01b03909116907f5e420822d2f7281fdc4b763c62c8b7874bf22108a35efe93144d79296aacc67d9060200160405180910390a25050505050505061095b60018055565b5050505050565b6000546001600160a01b031633146109ab5760405162461bcd60e51b815260206004820152600c60248201526b15539055551213d49256915160a21b604482015260640161057f565b476109b63382610f78565b60408051338152602081018390527fbf0d92faf65e256806eefa1a0d281d4873cc3c80d1ed25b8ae6f7cc66fc918ef910160405180910390a150565b6109fb81610eaf565b6000818152600560209081526040918290206004810180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690556003015491518381526001600160a01b03909216917fb4d98b272597e828d9b172c0d44390d5b267040e918088eac8a0a0fadcb81c70910160405180910390a250565b6000815b80821015610b5a57600060066000868686818110610a9e57610a9e6115ba565b9050602002013581526020019081526020016000209050610abe81610fd3565b6002810154815460009081526005602052604081208054909190610ae39084906114a9565b90915550506000600282015560048101546001600160a01b03167f67e089478e21dd12c98e69331c4152f6c9b2038b91e0f28268ffa01558c0b4ff868686818110610b3057610b306115ba565b90506020020135604051610b4691815260200190565b60405180910390a282600101925050610a7e565b80821015610b705763dfb035c96000526004601cfd5b50505050565b60056020526000908152604090208054600182015460028301805492939192610b9e906114d8565b80601f0160208091040260200160405190810160405280929190818152602001828054610bca906114d8565b8015610c175780601f10610bec57610100808354040283529160200191610c17565b820191906000526020600020905b815481529060010190602001808311610bfa57829003601f168201915b50505050600383015460049093015491926001600160a01b03908116929081169150600160a01b900460ff1686565b6000610c50611006565b9050600085905060006040518060c0016040528087815260200134815260200186868080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050908252503360208201526001600160a01b038916604082015260016060909101529050610cd0610e00565b60008381526005602090815260409182902083518155818401516001820155918301518051849392610d099260028501929101906110e6565b50606082015160038201805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392831617905560808301516004909201805460a090940151929091167fffffffffffffffffffffff00000000000000000000000000000000000000000090931692909217600160a01b91151591909102179055600280546001019055610d9c82333089611056565b610da560018055565b604080518481526001600160a01b0389166020820152348183015260608101889052905133917fe0cfbec12278e314697ee34bb7a1ba4d704e84c438680672f7c1175f287e5910919081900360800190a25050949350505050565b60015460021415610e245760405163558a1e0360e11b815260040160405180910390fd5b6002600155565b6040805160208101859052908101839052606082811b6bffffffffffffffffffffffff19169082015260009060740160405160208183030381529060405280519060200120905043600660008381526020019081526020016000206003015410610ea85760405163d0404f8560e01b815260040160405180910390fd5b9392505050565b6000818152600560205260409020600301546001600160a01b03163314610ee9576040516342e8fb9360e11b815260040160405180910390fd5b50565b600060405163a9059cbb60e01b6000528360045282602452602060006044600080895af13d15601f3d1160016000511416171691506000606052806040525080610b705760405162461bcd60e51b815260206004820152600f60248201527f5452414e534645525f4641494c45440000000000000000000000000000000000604482015260640161057f565b600080600080600085875af190508061069b5760405162461bcd60e51b815260206004820152601360248201527f4554485f5452414e534645525f4641494c454400000000000000000000000000604482015260640161057f565b438160030154101580610fe857506002810154155b15610ee95760405163d0404f8560e01b815260040160405180910390fd5b600061101160025490565b600081815260056020526040902060040154909150600160a01b900460ff161515600114156110535760405163c44bd76560e01b815260040160405180910390fd5b90565b60006040516323b872dd60e01b6000528460045283602452826044526020600060646000808a5af13d15601f3d116001600051141617169150600060605280604052508061095b5760405162461bcd60e51b815260206004820152601460248201527f5452414e534645525f46524f4d5f4641494c4544000000000000000000000000604482015260640161057f565b8280546110f2906114d8565b90600052602060002090601f016020900481019282611114576000855561115a565b82601f1061112d57805160ff191683800117855561115a565b8280016001018555821561115a579182015b8281111561115a57825182559160200191906001019061113f565b5061116692915061116a565b5090565b5b80821115611166576000815560010161116b565b80356001600160a01b038116811461119657600080fd5b919050565b60008083601f8401126111ad57600080fd5b50813567ffffffffffffffff8111156111c557600080fd5b6020830191508360208260051b85010111156111e057600080fd5b9250929050565b600080600080600080600060c0888a03121561120257600080fd5b873596506112126020890161117f565b95506112206040890161117f565b9450606088013593506080880135925060a088013567ffffffffffffffff81111561124a57600080fd5b6112568a828b0161119b565b989b979a50959850939692959293505050565b60006020828403121561127b57600080fd5b610ea88261117f565b60006020828403121561129657600080fd5b5035919050565b6000806000604084860312156112b257600080fd5b83359250602084013567ffffffffffffffff8111156112d057600080fd5b6112dc8682870161119b565b9497909650939450505050565b600080600080600060a0868803121561130157600080fd5b85359450602086013593506040860135925060608601359150608086013560ff8116811461132e57600080fd5b809150509295509295909350565b6000806020838503121561134f57600080fd5b823567ffffffffffffffff81111561136657600080fd5b6113728582860161119b565b90969095509350505050565b86815260006020878184015260c0604084015286518060c085015260005b818110156113b85788810183015185820160e00152820161139c565b818111156113ca57600060e083870101525b50601f01601f1916830160e00191506113f0905060608301866001600160a01b03169052565b6001600160a01b038416608083015282151560a083015261052f565b6000806000806060858703121561142257600080fd5b61142b8561117f565b935060208501359250604085013567ffffffffffffffff8082111561144f57600080fd5b818701915087601f83011261146357600080fd5b81358181111561147257600080fd5b88602082850101111561148457600080fd5b95989497505060200194505050565b634e487b7160e01b600052601160045260246000fd5b600082198211156114bc576114bc611493565b500190565b6000828210156114d3576114d3611493565b500390565b600181811c908216806114ec57607f821691505b6020821081141561150d57634e487b7160e01b600052602260045260246000fd5b50919050565b600080855481600182811c91508083168061152f57607f831692505b602080841082141561154f57634e487b7160e01b86526022600452602486fd5b8180156115635760018114611574576115a1565b60ff198616895284890196506115a1565b60008c81526020902060005b868110156115995781548b820152908501908301611580565b505084890196505b5098855250505050938401929092525050604001919050565b634e487b7160e01b600052603260045260246000fdfea164736f6c6343000809000a", - "deployedBytecode": "0x6080604052600436106100e85760003560e01c80636193cdfb1161008a5780638e2a3d36116100595780638e2a3d36146102f55780639872dbfe1461032757806398a268711461033d578063bfe07da61461037d57600080fd5b80636193cdfb1461026857806372fada5c1461027d5780638da5cb5b1461029d5780638e2749d6146102d557600080fd5b80632dfdf0b5116100c65780632dfdf0b5146101d857806336317972146101ef5780634b2ae9801461020f5780634e1389ed1461024857600080fd5b806303aaf306146100ed57806313af40351461012057806316d7224014610142575b600080fd5b3480156100f957600080fd5b5061010d6101083660046111e7565b610390565b6040519081526020015b60405180910390f35b34801561012c57600080fd5b5061014061013b366004611269565b61053a565b005b34801561014e57600080fd5b5061019f61015d366004611284565b60066020526000908152604090208054600182015460028301546003840154600485015460059095015493949293919290916001600160a01b03918216911686565b6040805196875260208701959095529385019290925260608401526001600160a01b0390811660808401521660a082015260c001610117565b3480156101e457600080fd5b5060025461010d9081565b3480156101fb57600080fd5b5061014061020a36600461129d565b6105e0565b34801561021b57600080fd5b5061010d61022a366004611269565b600c1b750ffffffffffffffffffffffffffffffffffffffff0001690565b34801561025457600080fd5b506101406102633660046112e9565b6106a0565b34801561027457600080fd5b50610140610962565b34801561028957600080fd5b50610140610298366004611284565b6109f2565b3480156102a957600080fd5b506000546102bd906001600160a01b031681565b6040516001600160a01b039091168152602001610117565b3480156102e157600080fd5b506101406102f036600461133c565b610a7a565b34801561030157600080fd5b50610315610310366004611284565b610b76565b6040516101179695949392919061137e565b34801561033357600080fd5b5061010d60035481565b34801561034957600080fd5b5061036d610358366004611284565b60046020526000908152604090205460ff1681565b6040519015158152602001610117565b61010d61038b36600461140c565b610c46565b600061039a610e00565b6103a48383610a7a565b60008881526005602052604090206004810154600160a01b900460ff166103de57604051635972996f60e11b815260040160405180910390fd5b8054851115610400576040516308aeed0f60e21b815260040160405180910390fd5b61040b89868a610e2b565b915060006040518060c001604052808b81526020018881526020018781526020016003544361043a91906114a9565b81526001600160a01b03808c166020808401919091528b82166040938401526000878152600682528381208551815591850151600183015592840151600282015560608401516003820155608084015160048201805491841673ffffffffffffffffffffffffffffffffffffffff1992831617905560a085015160059092018054929093169116179055835491925087918491906104d99084906114c1565b9091555050604080518b81526020810188905284916001600160a01b038c16917f2a28b2ae47b0bd4b104e7cd29b1dfa72846af8c4cfdc009da2ae29db68cb67ea910160405180910390a3505061052f60018055565b979650505050505050565b6000546001600160a01b031633146105885760405162461bcd60e51b815260206004820152600c60248201526b15539055551213d49256915160a21b60448201526064015b60405180910390fd5b6000805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081178255604051909133917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d769190a350565b6105e8610e00565b6105f183610eaf565b6105fb8282610a7a565b60008381526005602052604090206004810154600160a01b900460ff1615156001141561062b5761062b846109f2565b600481015481546000835560038301546001600160a01b03928316926106549184911683610eec565b604080518781526020810183905233917f7719804546c0185709e60c90d164447ff251a5ba29af0216faa921350f6bebf7910160405180910390a250505061069b60018055565b505050565b6106a8610e00565b6000858152600660205260409020600381015443108015906106cc57506002810154155b156106ea576040516331da482760e11b815260040160405180910390fd5b80546000908152600560209081526040808320600280860154925191949361071893918601928b9101611513565b60405160208183030381529060405280519060200120905060008160405160200161076f91907f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c810191909152603c0190565b60408051601f1981840301815291815281516020928301206000858152600790935291205490915060ff161515600114156107bd57604051637a48537560e11b815260040160405180910390fd5b6040805160008082526020820180845284905260ff881692820192909252606081018990526080810188905261083f9060019060a0016020604051602081039080840390855afa158015610815573d6000803e3d6000fd5b5050604051601f190151600c1b750ffffffffffffffffffffffffffffffffffffffff00016919050565b60008181526004602052604090205490915060ff1661087157604051632057875960e21b815260040160405180910390fd5b6004840154600186015460028701546001600160a01b0390921691600091610898916114c1565b60006002890181905560038901819055868152600760205260409020805460ff1916600117905560048801549091506108dc9083906001600160a01b031683610eec565b60018701541561090757600587015460018801546109079184916001600160a01b0390911690610eec565b60048701546040518d81526001600160a01b03909116907f5e420822d2f7281fdc4b763c62c8b7874bf22108a35efe93144d79296aacc67d9060200160405180910390a25050505050505061095b60018055565b5050505050565b6000546001600160a01b031633146109ab5760405162461bcd60e51b815260206004820152600c60248201526b15539055551213d49256915160a21b604482015260640161057f565b476109b63382610f78565b60408051338152602081018390527fbf0d92faf65e256806eefa1a0d281d4873cc3c80d1ed25b8ae6f7cc66fc918ef910160405180910390a150565b6109fb81610eaf565b6000818152600560209081526040918290206004810180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690556003015491518381526001600160a01b03909216917fb4d98b272597e828d9b172c0d44390d5b267040e918088eac8a0a0fadcb81c70910160405180910390a250565b6000815b80821015610b5a57600060066000868686818110610a9e57610a9e6115ba565b9050602002013581526020019081526020016000209050610abe81610fd3565b6002810154815460009081526005602052604081208054909190610ae39084906114a9565b90915550506000600282015560048101546001600160a01b03167f67e089478e21dd12c98e69331c4152f6c9b2038b91e0f28268ffa01558c0b4ff868686818110610b3057610b306115ba565b90506020020135604051610b4691815260200190565b60405180910390a282600101925050610a7e565b80821015610b705763dfb035c96000526004601cfd5b50505050565b60056020526000908152604090208054600182015460028301805492939192610b9e906114d8565b80601f0160208091040260200160405190810160405280929190818152602001828054610bca906114d8565b8015610c175780601f10610bec57610100808354040283529160200191610c17565b820191906000526020600020905b815481529060010190602001808311610bfa57829003601f168201915b50505050600383015460049093015491926001600160a01b03908116929081169150600160a01b900460ff1686565b6000610c50611006565b9050600085905060006040518060c0016040528087815260200134815260200186868080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050908252503360208201526001600160a01b038916604082015260016060909101529050610cd0610e00565b60008381526005602090815260409182902083518155818401516001820155918301518051849392610d099260028501929101906110e6565b50606082015160038201805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392831617905560808301516004909201805460a090940151929091167fffffffffffffffffffffff00000000000000000000000000000000000000000090931692909217600160a01b91151591909102179055600280546001019055610d9c82333089611056565b610da560018055565b604080518481526001600160a01b0389166020820152348183015260608101889052905133917fe0cfbec12278e314697ee34bb7a1ba4d704e84c438680672f7c1175f287e5910919081900360800190a25050949350505050565b60015460021415610e245760405163558a1e0360e11b815260040160405180910390fd5b6002600155565b6040805160208101859052908101839052606082811b6bffffffffffffffffffffffff19169082015260009060740160405160208183030381529060405280519060200120905043600660008381526020019081526020016000206003015410610ea85760405163d0404f8560e01b815260040160405180910390fd5b9392505050565b6000818152600560205260409020600301546001600160a01b03163314610ee9576040516342e8fb9360e11b815260040160405180910390fd5b50565b600060405163a9059cbb60e01b6000528360045282602452602060006044600080895af13d15601f3d1160016000511416171691506000606052806040525080610b705760405162461bcd60e51b815260206004820152600f60248201527f5452414e534645525f4641494c45440000000000000000000000000000000000604482015260640161057f565b600080600080600085875af190508061069b5760405162461bcd60e51b815260206004820152601360248201527f4554485f5452414e534645525f4641494c454400000000000000000000000000604482015260640161057f565b438160030154101580610fe857506002810154155b15610ee95760405163d0404f8560e01b815260040160405180910390fd5b600061101160025490565b600081815260056020526040902060040154909150600160a01b900460ff161515600114156110535760405163c44bd76560e01b815260040160405180910390fd5b90565b60006040516323b872dd60e01b6000528460045283602452826044526020600060646000808a5af13d15601f3d116001600051141617169150600060605280604052508061095b5760405162461bcd60e51b815260206004820152601460248201527f5452414e534645525f46524f4d5f4641494c4544000000000000000000000000604482015260640161057f565b8280546110f2906114d8565b90600052602060002090601f016020900481019282611114576000855561115a565b82601f1061112d57805160ff191683800117855561115a565b8280016001018555821561115a579182015b8281111561115a57825182559160200191906001019061113f565b5061116692915061116a565b5090565b5b80821115611166576000815560010161116b565b80356001600160a01b038116811461119657600080fd5b919050565b60008083601f8401126111ad57600080fd5b50813567ffffffffffffffff8111156111c557600080fd5b6020830191508360208260051b85010111156111e057600080fd5b9250929050565b600080600080600080600060c0888a03121561120257600080fd5b873596506112126020890161117f565b95506112206040890161117f565b9450606088013593506080880135925060a088013567ffffffffffffffff81111561124a57600080fd5b6112568a828b0161119b565b989b979a50959850939692959293505050565b60006020828403121561127b57600080fd5b610ea88261117f565b60006020828403121561129657600080fd5b5035919050565b6000806000604084860312156112b257600080fd5b83359250602084013567ffffffffffffffff8111156112d057600080fd5b6112dc8682870161119b565b9497909650939450505050565b600080600080600060a0868803121561130157600080fd5b85359450602086013593506040860135925060608601359150608086013560ff8116811461132e57600080fd5b809150509295509295909350565b6000806020838503121561134f57600080fd5b823567ffffffffffffffff81111561136657600080fd5b6113728582860161119b565b90969095509350505050565b86815260006020878184015260c0604084015286518060c085015260005b818110156113b85788810183015185820160e00152820161139c565b818111156113ca57600060e083870101525b50601f01601f1916830160e00191506113f0905060608301866001600160a01b03169052565b6001600160a01b038416608083015282151560a083015261052f565b6000806000806060858703121561142257600080fd5b61142b8561117f565b935060208501359250604085013567ffffffffffffffff8082111561144f57600080fd5b818701915087601f83011261146357600080fd5b81358181111561147257600080fd5b88602082850101111561148457600080fd5b95989497505060200194505050565b634e487b7160e01b600052601160045260246000fd5b600082198211156114bc576114bc611493565b500190565b6000828210156114d3576114d3611493565b500390565b600181811c908216806114ec57607f821691505b6020821081141561150d57634e487b7160e01b600052602260045260246000fd5b50919050565b600080855481600182811c91508083168061152f57607f831692505b602080841082141561154f57634e487b7160e01b86526022600452602486fd5b8180156115635760018114611574576115a1565b60ff198616895284890196506115a1565b60008c81526020902060005b868110156115995781548b820152908501908301611580565b505084890196505b5098855250505050938401929092525050604001919050565b634e487b7160e01b600052603260045260246000fdfea164736f6c6343000809000a", + "bytecode": "0x60806040526001805560405162001807380380620018078339810160408190526200002a9162000123565b600080546001600160a01b031916339081178255604051909182917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d76908290a350600382905580516000905b80821015620000d6576000620000ae8484815181106200009a576200009a62000203565b6020026020010151620000e060201b60201c565b6000908152600460205260409020805460ff1916600190811790915592909201915062000076565b5050505062000219565b600c1b611000600160ac1b031690565b634e487b7160e01b600052604160045260246000fd5b80516001600160a01b03811681146200011e57600080fd5b919050565b600080604083850312156200013757600080fd5b8251602080850151919350906001600160401b03808211156200015957600080fd5b818601915086601f8301126200016e57600080fd5b815181811115620001835762000183620000f0565b8060051b604051601f19603f83011681018181108582111715620001ab57620001ab620000f0565b604052918252848201925083810185019189831115620001ca57600080fd5b938501935b82851015620001f357620001e38562000106565b84529385019392850192620001cf565b8096505050505050509250929050565b634e487b7160e01b600052603260045260246000fd5b6115de80620002296000396000f3fe6080604052600436106100ec5760003560e01c80635fd8c7101161008a5780638e2a3d36116100595780638e2a3d36146103005780639872dbfe1461033157806398a2687114610347578063bfe07da61461038757600080fd5b80635fd8c7101461027357806372fada5c146102885780638da5cb5b146102a85780638e2749d6146102e057600080fd5b80632dfdf0b5116100c65780632dfdf0b5146101e357806336317972146101fa5780634b2ae9801461021a5780634e1389ed1461025357600080fd5b806303aaf306146100f857806313af40351461012b57806316d722401461014d57600080fd5b366100f357005b600080fd5b34801561010457600080fd5b506101186101133660046111e9565b6103a7565b6040519081526020015b60405180910390f35b34801561013757600080fd5b5061014b61014636600461126b565b610551565b005b34801561015957600080fd5b506101aa610168366004611286565b60066020526000908152604090208054600182015460028301546003840154600485015460059095015493949293919290916001600160a01b03918216911686565b6040805196875260208701959095529385019290925260608401526001600160a01b0390811660808401521660a082015260c001610122565b3480156101ef57600080fd5b506002546101189081565b34801561020657600080fd5b5061014b61021536600461129f565b6105f7565b34801561022657600080fd5b5061011861023536600461126b565b600c1b750ffffffffffffffffffffffffffffffffffffffff0001690565b34801561025f57600080fd5b5061014b61026e3660046112eb565b6106b7565b34801561027f57600080fd5b5061014b61097a565b34801561029457600080fd5b5061014b6102a3366004611286565b610a0a565b3480156102b457600080fd5b506000546102c8906001600160a01b031681565b6040516001600160a01b039091168152602001610122565b3480156102ec57600080fd5b5061014b6102fb36600461133e565b610a92565b34801561030c57600080fd5b5061032061031b366004611286565b610b8e565b604051610122959493929190611380565b34801561033d57600080fd5b5061011860035481565b34801561035357600080fd5b50610377610362366004611286565b60046020526000908152604090205460ff1681565b6040519015158152602001610122565b34801561039357600080fd5b506101186103a236600461140d565b610c58565b60006103b1610e02565b6103bb8383610a92565b60008881526005602052604090206003810154600160a01b900460ff166103f557604051635972996f60e11b815260040160405180910390fd5b8054851115610417576040516308aeed0f60e21b815260040160405180910390fd5b61042289868a610e2d565b915060006040518060c001604052808b81526020018881526020018781526020016003544361045191906114aa565b81526001600160a01b03808c166020808401919091528b82166040938401526000878152600682528381208551815591850151600183015592840151600282015560608401516003820155608084015160048201805491841673ffffffffffffffffffffffffffffffffffffffff1992831617905560a085015160059092018054929093169116179055835491925087918491906104f09084906114c2565b9091555050604080518b81526020810188905284916001600160a01b038c16917f2a28b2ae47b0bd4b104e7cd29b1dfa72846af8c4cfdc009da2ae29db68cb67ea910160405180910390a3505061054660018055565b979650505050505050565b6000546001600160a01b0316331461059f5760405162461bcd60e51b815260206004820152600c60248201526b15539055551213d49256915160a21b60448201526064015b60405180910390fd5b6000805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081178255604051909133917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d769190a350565b6105ff610e02565b61060883610eb1565b6106128282610a92565b60008381526005602052604090206003810154600160a01b900460ff161515600114156106425761064284610a0a565b600381015481546000835560028301546001600160a01b039283169261066b9184911683610eee565b604080518781526020810183905233917f7719804546c0185709e60c90d164447ff251a5ba29af0216faa921350f6bebf7910160405180910390a25050506106b260018055565b505050565b6106bf610e02565b60008581526006602052604090206003810154431015806106e257506002810154155b15610700576040516331da482760e11b815260040160405180910390fd5b805460009081526005602090815260408083206002850154915190939261073092600186019290918b9101611514565b60405160208183030381529060405280519060200120905060008160405160200161078791907f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c810191909152603c0190565b60408051601f1981840301815291815281516020928301206000858152600790935291205490915060ff161515600114156107d557604051637a48537560e11b815260040160405180910390fd5b6040805160008082526020820180845284905260ff88169282019290925260608101899052608081018890526108579060019060a0016020604051602081039080840390855afa15801561082d573d6000803e3d6000fd5b5050604051601f190151600c1b750ffffffffffffffffffffffffffffffffffffffff00016919050565b60008181526004602052604090205490915060ff1661088957604051632057875960e21b815260040160405180910390fd5b6003840154600186015460028701546001600160a01b03909216916000916108b0916114c2565b60006002890181905560038901819055868152600760205260409020805460ff1916600117905560048801549091506108f49083906001600160a01b031683610eee565b60018701541561091f576005870154600188015461091f9184916001600160a01b0390911690610eee565b60048701546040518d81526001600160a01b03909116907f5e420822d2f7281fdc4b763c62c8b7874bf22108a35efe93144d79296aacc67d9060200160405180910390a25050505050505061097360018055565b5050505050565b6000546001600160a01b031633146109c35760405162461bcd60e51b815260206004820152600c60248201526b15539055551213d49256915160a21b6044820152606401610596565b476109ce3382610f7a565b60408051338152602081018390527feaff4b37086828766ad3268786972c0cd24259d4c87a80f9d3963a3c3d999b0d910160405180910390a150565b610a1381610eb1565b6000818152600560209081526040918290206003810180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690556002015491518381526001600160a01b03909216917fb4d98b272597e828d9b172c0d44390d5b267040e918088eac8a0a0fadcb81c70910160405180910390a250565b6000815b80821015610b7257600060066000868686818110610ab657610ab66115bb565b9050602002013581526020019081526020016000209050610ad681610fd5565b6002810154815460009081526005602052604081208054909190610afb9084906114aa565b90915550506000600282015560048101546001600160a01b03167f67e089478e21dd12c98e69331c4152f6c9b2038b91e0f28268ffa01558c0b4ff868686818110610b4857610b486115bb565b90506020020135604051610b5e91815260200190565b60405180910390a282600101925050610a96565b80821015610b885763dfb035c96000526004601cfd5b50505050565b60056020526000908152604090208054600182018054919291610bb0906114d9565b80601f0160208091040260200160405190810160405280929190818152602001828054610bdc906114d9565b8015610c295780601f10610bfe57610100808354040283529160200191610c29565b820191906000526020600020905b815481529060010190602001808311610c0c57829003601f168201915b50505050600283015460039093015491926001600160a01b03908116929081169150600160a01b900460ff1685565b6000610c62611008565b9050600085905060006040518060a0016040528087815260200186868080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050908252503360208201526001600160a01b038916604082015260016060909101529050610cdc610e02565b6000838152600560209081526040909120825181558183015180518493610d0a9260018501929101906110e8565b506040820151600280830180546001600160a01b0393841673ffffffffffffffffffffffffffffffffffffffff199091161790556060840151600390930180546080909501511515600160a01b027fffffffffffffffffffffff000000000000000000000000000000000000000000909516939092169290921792909217909155610d989080546001019055565b610da482333089611058565b610dad60018055565b604080518481526001600160a01b038916602082015290810187905233907f25ac57b911b0f66b64c294827f539545fbc3ddd002cafab117776274f3241e4c9060600160405180910390a25050949350505050565b60015460021415610e265760405163558a1e0360e11b815260040160405180910390fd5b6002600155565b6040805160208101859052908101839052606082811b6bffffffffffffffffffffffff19169082015260009060740160405160208183030381529060405280519060200120905043600660008381526020019081526020016000206003015410610eaa5760405163d0404f8560e01b815260040160405180910390fd5b9392505050565b6000818152600560205260409020600201546001600160a01b03163314610eeb576040516342e8fb9360e11b815260040160405180910390fd5b50565b600060405163a9059cbb60e01b6000528360045282602452602060006044600080895af13d15601f3d1160016000511416171691506000606052806040525080610b885760405162461bcd60e51b815260206004820152600f60248201527f5452414e534645525f4641494c454400000000000000000000000000000000006044820152606401610596565b600080600080600085875af19050806106b25760405162461bcd60e51b815260206004820152601360248201527f4554485f5452414e534645525f4641494c4544000000000000000000000000006044820152606401610596565b438160030154101580610fea57506002810154155b15610eeb5760405163d0404f8560e01b815260040160405180910390fd5b600061101360025490565b600081815260056020526040902060030154909150600160a01b900460ff161515600114156110555760405163c44bd76560e01b815260040160405180910390fd5b90565b60006040516323b872dd60e01b6000528460045283602452826044526020600060646000808a5af13d15601f3d11600160005114161716915060006060528060405250806109735760405162461bcd60e51b815260206004820152601460248201527f5452414e534645525f46524f4d5f4641494c45440000000000000000000000006044820152606401610596565b8280546110f4906114d9565b90600052602060002090601f016020900481019282611116576000855561115c565b82601f1061112f57805160ff191683800117855561115c565b8280016001018555821561115c579182015b8281111561115c578251825591602001919060010190611141565b5061116892915061116c565b5090565b5b80821115611168576000815560010161116d565b80356001600160a01b038116811461119857600080fd5b919050565b60008083601f8401126111af57600080fd5b50813567ffffffffffffffff8111156111c757600080fd5b6020830191508360208260051b85010111156111e257600080fd5b9250929050565b600080600080600080600060c0888a03121561120457600080fd5b8735965061121460208901611181565b955061122260408901611181565b9450606088013593506080880135925060a088013567ffffffffffffffff81111561124c57600080fd5b6112588a828b0161119d565b989b979a50959850939692959293505050565b60006020828403121561127d57600080fd5b610eaa82611181565b60006020828403121561129857600080fd5b5035919050565b6000806000604084860312156112b457600080fd5b83359250602084013567ffffffffffffffff8111156112d257600080fd5b6112de8682870161119d565b9497909650939450505050565b600080600080600060a0868803121561130357600080fd5b85359450602086013593506040860135925060608601359150608086013560ff8116811461133057600080fd5b809150509295509295909350565b6000806020838503121561135157600080fd5b823567ffffffffffffffff81111561136857600080fd5b6113748582860161119d565b90969095509350505050565b8581526000602060a08184015286518060a085015260005b818110156113b45788810183015185820160c001528201611398565b818111156113c657600060c083870101525b50601f01601f1916830160c00191506113ec905060408301866001600160a01b03169052565b6001600160a01b038416606083015282151560808301529695505050505050565b6000806000806060858703121561142357600080fd5b61142c85611181565b935060208501359250604085013567ffffffffffffffff8082111561145057600080fd5b818701915087601f83011261146457600080fd5b81358181111561147357600080fd5b88602082850101111561148557600080fd5b95989497505060200194505050565b634e487b7160e01b600052601160045260246000fd5b600082198211156114bd576114bd611494565b500190565b6000828210156114d4576114d4611494565b500390565b600181811c908216806114ed57607f821691505b6020821081141561150e57634e487b7160e01b600052602260045260246000fd5b50919050565b600080855481600182811c91508083168061153057607f831692505b602080841082141561155057634e487b7160e01b86526022600452602486fd5b8180156115645760018114611575576115a2565b60ff198616895284890196506115a2565b60008c81526020902060005b8681101561159a5781548b820152908501908301611581565b505084890196505b5098855250505050938401929092525050604001919050565b634e487b7160e01b600052603260045260246000fdfea164736f6c6343000809000a", + "deployedBytecode": "0x6080604052600436106100ec5760003560e01c80635fd8c7101161008a5780638e2a3d36116100595780638e2a3d36146103005780639872dbfe1461033157806398a2687114610347578063bfe07da61461038757600080fd5b80635fd8c7101461027357806372fada5c146102885780638da5cb5b146102a85780638e2749d6146102e057600080fd5b80632dfdf0b5116100c65780632dfdf0b5146101e357806336317972146101fa5780634b2ae9801461021a5780634e1389ed1461025357600080fd5b806303aaf306146100f857806313af40351461012b57806316d722401461014d57600080fd5b366100f357005b600080fd5b34801561010457600080fd5b506101186101133660046111e9565b6103a7565b6040519081526020015b60405180910390f35b34801561013757600080fd5b5061014b61014636600461126b565b610551565b005b34801561015957600080fd5b506101aa610168366004611286565b60066020526000908152604090208054600182015460028301546003840154600485015460059095015493949293919290916001600160a01b03918216911686565b6040805196875260208701959095529385019290925260608401526001600160a01b0390811660808401521660a082015260c001610122565b3480156101ef57600080fd5b506002546101189081565b34801561020657600080fd5b5061014b61021536600461129f565b6105f7565b34801561022657600080fd5b5061011861023536600461126b565b600c1b750ffffffffffffffffffffffffffffffffffffffff0001690565b34801561025f57600080fd5b5061014b61026e3660046112eb565b6106b7565b34801561027f57600080fd5b5061014b61097a565b34801561029457600080fd5b5061014b6102a3366004611286565b610a0a565b3480156102b457600080fd5b506000546102c8906001600160a01b031681565b6040516001600160a01b039091168152602001610122565b3480156102ec57600080fd5b5061014b6102fb36600461133e565b610a92565b34801561030c57600080fd5b5061032061031b366004611286565b610b8e565b604051610122959493929190611380565b34801561033d57600080fd5b5061011860035481565b34801561035357600080fd5b50610377610362366004611286565b60046020526000908152604090205460ff1681565b6040519015158152602001610122565b34801561039357600080fd5b506101186103a236600461140d565b610c58565b60006103b1610e02565b6103bb8383610a92565b60008881526005602052604090206003810154600160a01b900460ff166103f557604051635972996f60e11b815260040160405180910390fd5b8054851115610417576040516308aeed0f60e21b815260040160405180910390fd5b61042289868a610e2d565b915060006040518060c001604052808b81526020018881526020018781526020016003544361045191906114aa565b81526001600160a01b03808c166020808401919091528b82166040938401526000878152600682528381208551815591850151600183015592840151600282015560608401516003820155608084015160048201805491841673ffffffffffffffffffffffffffffffffffffffff1992831617905560a085015160059092018054929093169116179055835491925087918491906104f09084906114c2565b9091555050604080518b81526020810188905284916001600160a01b038c16917f2a28b2ae47b0bd4b104e7cd29b1dfa72846af8c4cfdc009da2ae29db68cb67ea910160405180910390a3505061054660018055565b979650505050505050565b6000546001600160a01b0316331461059f5760405162461bcd60e51b815260206004820152600c60248201526b15539055551213d49256915160a21b60448201526064015b60405180910390fd5b6000805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081178255604051909133917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d769190a350565b6105ff610e02565b61060883610eb1565b6106128282610a92565b60008381526005602052604090206003810154600160a01b900460ff161515600114156106425761064284610a0a565b600381015481546000835560028301546001600160a01b039283169261066b9184911683610eee565b604080518781526020810183905233917f7719804546c0185709e60c90d164447ff251a5ba29af0216faa921350f6bebf7910160405180910390a25050506106b260018055565b505050565b6106bf610e02565b60008581526006602052604090206003810154431015806106e257506002810154155b15610700576040516331da482760e11b815260040160405180910390fd5b805460009081526005602090815260408083206002850154915190939261073092600186019290918b9101611514565b60405160208183030381529060405280519060200120905060008160405160200161078791907f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c810191909152603c0190565b60408051601f1981840301815291815281516020928301206000858152600790935291205490915060ff161515600114156107d557604051637a48537560e11b815260040160405180910390fd5b6040805160008082526020820180845284905260ff88169282019290925260608101899052608081018890526108579060019060a0016020604051602081039080840390855afa15801561082d573d6000803e3d6000fd5b5050604051601f190151600c1b750ffffffffffffffffffffffffffffffffffffffff00016919050565b60008181526004602052604090205490915060ff1661088957604051632057875960e21b815260040160405180910390fd5b6003840154600186015460028701546001600160a01b03909216916000916108b0916114c2565b60006002890181905560038901819055868152600760205260409020805460ff1916600117905560048801549091506108f49083906001600160a01b031683610eee565b60018701541561091f576005870154600188015461091f9184916001600160a01b0390911690610eee565b60048701546040518d81526001600160a01b03909116907f5e420822d2f7281fdc4b763c62c8b7874bf22108a35efe93144d79296aacc67d9060200160405180910390a25050505050505061097360018055565b5050505050565b6000546001600160a01b031633146109c35760405162461bcd60e51b815260206004820152600c60248201526b15539055551213d49256915160a21b6044820152606401610596565b476109ce3382610f7a565b60408051338152602081018390527feaff4b37086828766ad3268786972c0cd24259d4c87a80f9d3963a3c3d999b0d910160405180910390a150565b610a1381610eb1565b6000818152600560209081526040918290206003810180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690556002015491518381526001600160a01b03909216917fb4d98b272597e828d9b172c0d44390d5b267040e918088eac8a0a0fadcb81c70910160405180910390a250565b6000815b80821015610b7257600060066000868686818110610ab657610ab66115bb565b9050602002013581526020019081526020016000209050610ad681610fd5565b6002810154815460009081526005602052604081208054909190610afb9084906114aa565b90915550506000600282015560048101546001600160a01b03167f67e089478e21dd12c98e69331c4152f6c9b2038b91e0f28268ffa01558c0b4ff868686818110610b4857610b486115bb565b90506020020135604051610b5e91815260200190565b60405180910390a282600101925050610a96565b80821015610b885763dfb035c96000526004601cfd5b50505050565b60056020526000908152604090208054600182018054919291610bb0906114d9565b80601f0160208091040260200160405190810160405280929190818152602001828054610bdc906114d9565b8015610c295780601f10610bfe57610100808354040283529160200191610c29565b820191906000526020600020905b815481529060010190602001808311610c0c57829003601f168201915b50505050600283015460039093015491926001600160a01b03908116929081169150600160a01b900460ff1685565b6000610c62611008565b9050600085905060006040518060a0016040528087815260200186868080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050908252503360208201526001600160a01b038916604082015260016060909101529050610cdc610e02565b6000838152600560209081526040909120825181558183015180518493610d0a9260018501929101906110e8565b506040820151600280830180546001600160a01b0393841673ffffffffffffffffffffffffffffffffffffffff199091161790556060840151600390930180546080909501511515600160a01b027fffffffffffffffffffffff000000000000000000000000000000000000000000909516939092169290921792909217909155610d989080546001019055565b610da482333089611058565b610dad60018055565b604080518481526001600160a01b038916602082015290810187905233907f25ac57b911b0f66b64c294827f539545fbc3ddd002cafab117776274f3241e4c9060600160405180910390a25050949350505050565b60015460021415610e265760405163558a1e0360e11b815260040160405180910390fd5b6002600155565b6040805160208101859052908101839052606082811b6bffffffffffffffffffffffff19169082015260009060740160405160208183030381529060405280519060200120905043600660008381526020019081526020016000206003015410610eaa5760405163d0404f8560e01b815260040160405180910390fd5b9392505050565b6000818152600560205260409020600201546001600160a01b03163314610eeb576040516342e8fb9360e11b815260040160405180910390fd5b50565b600060405163a9059cbb60e01b6000528360045282602452602060006044600080895af13d15601f3d1160016000511416171691506000606052806040525080610b885760405162461bcd60e51b815260206004820152600f60248201527f5452414e534645525f4641494c454400000000000000000000000000000000006044820152606401610596565b600080600080600085875af19050806106b25760405162461bcd60e51b815260206004820152601360248201527f4554485f5452414e534645525f4641494c4544000000000000000000000000006044820152606401610596565b438160030154101580610fea57506002810154155b15610eeb5760405163d0404f8560e01b815260040160405180910390fd5b600061101360025490565b600081815260056020526040902060030154909150600160a01b900460ff161515600114156110555760405163c44bd76560e01b815260040160405180910390fd5b90565b60006040516323b872dd60e01b6000528460045283602452826044526020600060646000808a5af13d15601f3d11600160005114161716915060006060528060405250806109735760405162461bcd60e51b815260206004820152601460248201527f5452414e534645525f46524f4d5f4641494c45440000000000000000000000006044820152606401610596565b8280546110f4906114d9565b90600052602060002090601f016020900481019282611116576000855561115c565b82601f1061112f57805160ff191683800117855561115c565b8280016001018555821561115c579182015b8281111561115c578251825591602001919060010190611141565b5061116892915061116c565b5090565b5b80821115611168576000815560010161116d565b80356001600160a01b038116811461119857600080fd5b919050565b60008083601f8401126111af57600080fd5b50813567ffffffffffffffff8111156111c757600080fd5b6020830191508360208260051b85010111156111e257600080fd5b9250929050565b600080600080600080600060c0888a03121561120457600080fd5b8735965061121460208901611181565b955061122260408901611181565b9450606088013593506080880135925060a088013567ffffffffffffffff81111561124c57600080fd5b6112588a828b0161119d565b989b979a50959850939692959293505050565b60006020828403121561127d57600080fd5b610eaa82611181565b60006020828403121561129857600080fd5b5035919050565b6000806000604084860312156112b457600080fd5b83359250602084013567ffffffffffffffff8111156112d257600080fd5b6112de8682870161119d565b9497909650939450505050565b600080600080600060a0868803121561130357600080fd5b85359450602086013593506040860135925060608601359150608086013560ff8116811461133057600080fd5b809150509295509295909350565b6000806020838503121561135157600080fd5b823567ffffffffffffffff81111561136857600080fd5b6113748582860161119d565b90969095509350505050565b8581526000602060a08184015286518060a085015260005b818110156113b45788810183015185820160c001528201611398565b818111156113c657600060c083870101525b50601f01601f1916830160c00191506113ec905060408301866001600160a01b03169052565b6001600160a01b038416606083015282151560808301529695505050505050565b6000806000806060858703121561142357600080fd5b61142c85611181565b935060208501359250604085013567ffffffffffffffff8082111561145057600080fd5b818701915087601f83011261146457600080fd5b81358181111561147357600080fd5b88602082850101111561148557600080fd5b95989497505060200194505050565b634e487b7160e01b600052601160045260246000fd5b600082198211156114bd576114bd611494565b500190565b6000828210156114d4576114d4611494565b500390565b600181811c908216806114ed57607f821691505b6020821081141561150e57634e487b7160e01b600052602260045260246000fd5b50919050565b600080855481600182811c91508083168061153057607f831692505b602080841082141561155057634e487b7160e01b86526022600452602486fd5b8180156115645760018114611575576115a2565b60ff198616895284890196506115a2565b60008c81526020902060005b8681101561159a5781548b820152908501908301611581565b505084890196505b5098855250505050938401929092525050604001919050565b634e487b7160e01b600052603260045260246000fdfea164736f6c6343000809000a", "linkReferences": {}, "deployedLinkReferences": {} } diff --git a/contracts/DataTypes.sol b/contracts/DataTypes.sol index 1add8ba..5204eca 100644 --- a/contracts/DataTypes.sol +++ b/contracts/DataTypes.sol @@ -5,8 +5,6 @@ library DataTypes { struct Deposit { /// @dev Remaining tokens available. uint256 remaining; - /// @dev Premium paid in ETH for priority. - uint256 premium; /// @dev The PIX account for the seller receive transactions. string pixTarget; address seller; @@ -24,7 +22,7 @@ library DataTypes { uint256 amount; /// @dev If not paid at this block will be expired. uint256 expirationBlock; - /// @dev Where goes the tokens when validated. + /// @dev Where the tokens are sent the when order gets validated. address targetAddress; /// @dev Relayer address that facilitated this transaction. address relayerAddress; diff --git a/contracts/EventAndErrors.sol b/contracts/EventAndErrors.sol index 5810826..b46d4a7 100644 --- a/contracts/EventAndErrors.sol +++ b/contracts/EventAndErrors.sol @@ -9,7 +9,6 @@ interface EventAndErrors { address indexed seller, uint256 depositID, address token, - uint256 premium, uint256 amount ); event DepositClosed( @@ -35,7 +34,7 @@ interface EventAndErrors { address indexed buyer, bytes32 lockId ); - event PremiumsWithdrawn( + event FundsWithdrawn( address owner, uint256 amount ); @@ -49,6 +48,7 @@ interface EventAndErrors { /// @dev 0x85d1f726 error OnlySeller(); /// @dev Lock not expired or already released. + /// @dev Another lock with same ID is not expired yet. /// @dev 0xd0404f85 error NotExpired(); /// @dev Loop bounds have overflowed. @@ -63,7 +63,7 @@ interface EventAndErrors { /// @dev Lock already released or returned. /// @dev 0x63b4904e error AlreadyReleased(); - /// @dev Transaction already used to unlock payment + /// @dev Transaction already used to unlock payment. /// @dev 0xf490a6ea error TxAlreadyUsed(); /// @dev Signer is not a valid signer. diff --git a/contracts/lib/utils/Counters.sol b/contracts/lib/utils/Counters.sol index a3f8751..8039093 100644 --- a/contracts/lib/utils/Counters.sol +++ b/contracts/lib/utils/Counters.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: AGPL-3.0-only +// SPDX-License-Identifier: MIT pragma solidity >=0.8.4; diff --git a/contracts/p2pix.sol b/contracts/p2pix.sol index 19eb99d..42a1e57 100644 --- a/contracts/p2pix.sol +++ b/contracts/p2pix.sol @@ -66,26 +66,30 @@ contract P2PIX is /// ███ Public FX ██████████████████████████████████████████████████████████ - // Vendedor precisa mandar token para o smart contract + chave PIX destino. Retorna um DepositID. + /// @notice Creates a deposit order based on a seller's + /// offer of an amount of ERC20 tokens. + /// @dev Seller needs to send his tokens to the P2PIX smart contract. + /// @param _pixTarget Pix key destination provided by the offer's seller. + /// @return depositID The `uint256` return value provided + /// as the deposit identifier. + /// @dev Function sighash: 0xbfe07da6. function deposit( - address token, - uint256 amount, - string calldata pixTarget + address _token, + uint256 _amount, + string calldata _pixTarget ) public - payable returns (uint256 depositID) { (depositID) = _encodeDepositID(); - ERC20 t = ERC20(token); + ERC20 t = ERC20(_token); DT.Deposit memory d = DT.Deposit({ - remaining: amount, - premium: msg.value, - pixTarget: pixTarget, + remaining: _amount, + pixTarget: _pixTarget, seller: msg.sender, - token: token, + token: _token, valid: true }); @@ -98,7 +102,7 @@ contract P2PIX is t, msg.sender, address(this), - amount + _amount ); clearReentrancyGuard(); @@ -106,14 +110,16 @@ contract P2PIX is emit DepositAdded( msg.sender, depositID, - token, - msg.value, - amount + _token, + _amount ); } - // Vendedor pode invalidar da ordem de venda impedindo novos - // locks na mesma (isso não afeta nenhum lock que esteja ativo). + /// @notice Enables seller to invalidate future + /// locks made to his/her token offering order. + /// @dev This function does not affect any ongoing active locks. + /// @dev Function sighash: 0x72fada5c. + function cancelDeposit( uint256 depositID ) public { @@ -125,12 +131,20 @@ contract P2PIX is ); } - // Relayer interaje adicionando um “lock” na ordem de venda. - // O lock precisa incluir address do comprador + address do relayer + reembolso/premio relayer + valor. - // **Só poder ter um lock em aberto para cada (ordem de venda, valor)**. - // Só pode fazer lock de ordens que não estão invalidadas(Passo 5). - // Essa etapa pode ser feita pelo vendedor conjuntamente com a parte 1. - // Retorna um LockID. + /// @notice Public method designed to lock an remaining amount of + /// the deposit order of a seller. + /// @dev This method can be performed by either an order's seller, + /// relayer, or buyer. + /// @dev There can only exist a lock per each `_amount` partitioned + /// from the total `remaining` value. + /// @dev Locks can only be performed in valid orders. + /// @param _targetAddress The address of the buyer of a `_depositID`. + /// @param _relayerAddress The relayer's address. + /// @param _relayerPremium The refund/premium owed to a relayer. + /// @param expiredLocks An array of `bytes32` identifiers to be + /// provided so to unexpire locks using this transaction gas push. + /// @return lockID The `bytes32` value returned as the lock identifier. + /// @dev Function sighash: 0x03aaf306. function lock( uint256 _depositID, address _targetAddress, @@ -180,9 +194,11 @@ contract P2PIX is ); } - // Relayer interage com o smart contract, colocando no calldata o comprovante do PIX realizado. - // Smart contract valida o comprovante, manda os tokens para o endereço do pagador, - // e reembolsa o custo do gás para o endereço do relayer especificado na parte (2). + /// @notice Lock release method that liquidate lock + // orders and distributes relayer fees. + /// @dev This method can be called by either an + /// order's seller, relayer, or buyer. + /// @dev Function sighash: 0x4e1389ed. function release( bytes32 lockID, uint256 pixTimestamp, @@ -193,12 +209,13 @@ contract P2PIX is public nonReentrant { - // TODO **Prevenir que um Pix não relacionado ao APP seja usado pois tem o mesmo destino + /// @todo Prevent a PIX non-related to the app from + /// getting targeted, due to both sharing the same destination. DT.Lock storage l = mapLocks[lockID]; if( - l.expirationBlock <= block.number - && l.amount <= 0 + l.expirationBlock <= block.number || + l.amount <= 0 ) revert AlreadyReleased(); @@ -243,7 +260,7 @@ contract P2PIX is l.expirationBlock = 0; usedTransactions[message] = true; - SafeTransferLib.safeTransfer( + SafeTransferLib.safeTransfer( t, l.targetAddress, totalAmount @@ -264,7 +281,10 @@ contract P2PIX is } - // Unlock expired locks + /// @notice Unlocks expired locks. + /// @dev Triggered in the callgraph by both `lock` and `withdraw` functions. + /// @dev This method can also have any public actor as its `tx.origin`. + /// @dev Function sighash: 0x8e2749d6. function unlockExpired( bytes32[] calldata lockIDs ) public { @@ -307,7 +327,10 @@ contract P2PIX is } } - // Após os locks expirarem, vendedor pode interagir c/ o contrato e recuperar os tokens de um depósito específico. + /// @notice Seller's expired deposit fund sweeper. + /// @dev A seller may use this method to recover + /// tokens from expired deposits. + /// @dev Function sighash: 0x36317972. function withdraw( uint256 depositID, bytes32[] calldata expiredLocks @@ -347,22 +370,29 @@ contract P2PIX is /// ███ Owner Only █████████████████████████████████████████████████████████ - // O dono do contrato pode sacar os premiums pagos - function withdrawPremiums() external onlyOwner { + /// @dev Contract's balance withdraw method. + /// @dev Function sighash: 0x5fd8c710. + function withdrawBalance() external onlyOwner { uint256 balance = address(this).balance; SafeTransferLib.safeTransferETH( msg.sender, balance ); - emit PremiumsWithdrawn( + emit FundsWithdrawn( msg.sender, balance ); } /// ███ Helper FX ██████████████████████████████████████████████████████████ + + // solhint-disable-next-line no-empty-blocks + receive() external payable {} + /// @notice Access control private view method that + /// performs auth check on an deposit's seller. + /// @dev Function sighash: 0x4125a4d9. function _onlySeller(uint256 _depositID) private view @@ -374,6 +404,10 @@ contract P2PIX is OnlySeller(); } + /// @notice Private view auxiliar logic that reverts + /// on a not expired lock passed as argument of the function. + /// @dev Called exclusively by the `unlockExpired` method. + /// @dev Function sighash: 0x74e2a0bb. function _notExpired(DT.Lock storage _l) private view @@ -385,31 +419,35 @@ contract P2PIX is _l.amount <= 0 ) revert NotExpired(); - - // Custom Error Yul Impl - // assembly { - // if iszero(iszero( - // or( - // or( - // lt(number(), sload(add(_l.slot, 3))), - // eq(sload(add(_l.slot, 3)), number()) - // ), - // iszero(sload(add(_l.slot, 2))) - // ))) - // { - // mstore(0x00, 0xd0404f85) - // revert(0x1c, 0x04) - // } - // } +/* + // Custom Error Yul Impl + assembly { + if iszero(iszero( + or( + or( + lt(number(), sload(add(_l.slot, 3))), + eq(sload(add(_l.slot, 3)), number()) + ), + iszero(sload(add(_l.slot, 2))) + ))) + { + mstore(0x00, 0xd0404f85) + revert(0x1c, 0x04) + } + } - // Require Error Solidity Impl - // require( - // _l.expirationBlock < block.number && - // _l.amount > 0, - // "P2PIX: Lock not expired or already released" - // ); + // Require Error Solidity Impl + require( + _l.expirationBlock < block.number && + _l.amount > 0, + "P2PIX: Lock not expired or already released" + ); +*/ } + /// @notice Internal view auxiliar logic that returns a new valid `_depositID`. + /// @dev It reverts on an already valid counter (`uint256`) value. + /// @dev Function sighash: 0xdb51d697. function _encodeDepositID() internal view @@ -423,6 +461,12 @@ contract P2PIX is DepositAlreadyExists(); } + /// @notice Private view auxiliar logic that encodes/returns + /// the `bytes32` identifier of an lock. + /// @dev reverts on a not expired lock with the same ID passed + /// as argument of the function. + /// @dev Called exclusively by the `lock` method. + /// @dev Function sighash: 0x3fc5fb52. function _encodeLockID( uint256 _depositID, uint256 _amount, @@ -441,6 +485,9 @@ contract P2PIX is NotExpired(); } + /// @notice Public method that handles `address` + /// to `uint256` safe type casting. + /// @dev Function sighash: 0x4b2ae980. function _castAddrToKey(address _addr) public pure diff --git a/docs/DataTypes.md b/docs/DataTypes.md new file mode 100644 index 0000000..59667df --- /dev/null +++ b/docs/DataTypes.md @@ -0,0 +1,12 @@ +# DataTypes + + + + + + + + + + + diff --git a/docs/EventAndErrors.md b/docs/EventAndErrors.md new file mode 100644 index 0000000..ab038ae --- /dev/null +++ b/docs/EventAndErrors.md @@ -0,0 +1,241 @@ +# EventAndErrors + + + + + + + + + + +## Events + +### DepositAdded + +```solidity +event DepositAdded(address indexed seller, uint256 depositID, address token, uint256 amount) +``` + +███ Events ████████████████████████████████████████████████████████████ + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| seller `indexed` | address | undefined | +| depositID | uint256 | undefined | +| token | address | undefined | +| amount | uint256 | undefined | + +### DepositClosed + +```solidity +event DepositClosed(address indexed seller, uint256 depositID) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| seller `indexed` | address | undefined | +| depositID | uint256 | undefined | + +### DepositWithdrawn + +```solidity +event DepositWithdrawn(address indexed seller, uint256 depositID, uint256 amount) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| seller `indexed` | address | undefined | +| depositID | uint256 | undefined | +| amount | uint256 | undefined | + +### FundsWithdrawn + +```solidity +event FundsWithdrawn(address owner, uint256 amount) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | +| amount | uint256 | undefined | + +### LockAdded + +```solidity +event LockAdded(address indexed buyer, bytes32 indexed lockID, uint256 depositID, uint256 amount) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| buyer `indexed` | address | undefined | +| lockID `indexed` | bytes32 | undefined | +| depositID | uint256 | undefined | +| amount | uint256 | undefined | + +### LockReleased + +```solidity +event LockReleased(address indexed buyer, bytes32 lockId) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| buyer `indexed` | address | undefined | +| lockId | bytes32 | undefined | + +### LockReturned + +```solidity +event LockReturned(address indexed buyer, bytes32 lockId) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| buyer `indexed` | address | undefined | +| lockId | bytes32 | undefined | + + + +## Errors + +### AlreadyReleased + +```solidity +error AlreadyReleased() +``` + + + +*Lock already released or returned.0x63b4904e* + + +### DepositAlreadyExists + +```solidity +error DepositAlreadyExists() +``` + + + +*Deposit already exist and it is still valid.0xc44bd765* + + +### InvalidDeposit + +```solidity +error InvalidDeposit() +``` + + + +*Deposit not valid anymore.0xb2e532de* + + +### InvalidSigner + +```solidity +error InvalidSigner() +``` + + + +*Signer is not a valid signer.0x815e1d64* + + +### LoopOverflow + +```solidity +error LoopOverflow() +``` + + + +*Loop bounds have overflowed.0xdfb035c9* + + +### NotEnoughTokens + +```solidity +error NotEnoughTokens() +``` + + + +*Not enough token remaining on deposit.0x22bbb43c* + + +### NotExpired + +```solidity +error NotExpired() +``` + + + +*Lock not expired or already released.Another lock with same ID is not expired yet.0xd0404f85* + + +### OnlySeller + +```solidity +error OnlySeller() +``` + + + +*Only seller could call this function.0x85d1f726* + + +### TxAlreadyUsed + +```solidity +error TxAlreadyUsed() +``` + + + +*Transaction already used to unlock payment.0xf490a6ea* + + + diff --git a/docs/P2PIX.md b/docs/P2PIX.md new file mode 100644 index 0000000..a8599d2 --- /dev/null +++ b/docs/P2PIX.md @@ -0,0 +1,567 @@ +# P2PIX + + + + + + + + + +## Methods + +### _castAddrToKey + +```solidity +function _castAddrToKey(address _addr) external pure returns (uint256 _key) +``` + +Public method that handles `address` to `uint256` safe type casting. + +*Function sighash: 0x4b2ae980.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _addr | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _key | uint256 | undefined | + +### cancelDeposit + +```solidity +function cancelDeposit(uint256 depositID) external nonpayable +``` + +Enables seller to invalidate future locks made to his/her token offering order. + +*This function does not affect any ongoing active locks.Function sighash: 0x72fada5c.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| depositID | uint256 | undefined | + +### defaultLockBlocks + +```solidity +function defaultLockBlocks() external view returns (uint256) +``` + + + +*Default blocks that lock will hold tokens.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### deposit + +```solidity +function deposit(address _token, uint256 _amount, string _pixTarget) external nonpayable returns (uint256 depositID) +``` + +Creates a deposit order based on a seller's offer of an amount of ERC20 tokens. + +*Seller needs to send his tokens to the P2PIX smart contract.Function sighash: 0xbfe07da6.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _token | address | undefined | +| _amount | uint256 | undefined | +| _pixTarget | string | Pix key destination provided by the offer's seller. | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| depositID | uint256 | The `uint256` return value provided as the deposit identifier. | + +### depositCount + +```solidity +function depositCount() external view returns (uint256 _val) +``` + +███ Storage ████████████████████████████████████████████████████████████ + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _val | uint256 | undefined | + +### lock + +```solidity +function lock(uint256 _depositID, address _targetAddress, address _relayerAddress, uint256 _relayerPremium, uint256 _amount, bytes32[] expiredLocks) external nonpayable returns (bytes32 lockID) +``` + +Public method designed to lock an remaining amount of the deposit order of a seller. + +*This method can be performed by either an order's seller, relayer, or buyer.There can only exist a lock per each `_amount` partitioned from the total `remaining` value.Locks can only be performed in valid orders.Function sighash: 0x03aaf306.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _depositID | uint256 | undefined | +| _targetAddress | address | The address of the buyer of a `_depositID`. | +| _relayerAddress | address | The relayer's address. | +| _relayerPremium | uint256 | The refund/premium owed to a relayer. | +| _amount | uint256 | undefined | +| expiredLocks | bytes32[] | An array of `bytes32` identifiers to be provided so to unexpire locks using this transaction gas push. | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| lockID | bytes32 | The `bytes32` value returned as the lock identifier. | + +### mapDeposits + +```solidity +function mapDeposits(uint256) external view returns (uint256 remaining, string pixTarget, address seller, address token, bool valid) +``` + + + +*Seller list of deposits* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| remaining | uint256 | undefined | +| pixTarget | string | undefined | +| seller | address | undefined | +| token | address | undefined | +| valid | bool | undefined | + +### mapLocks + +```solidity +function mapLocks(bytes32) external view returns (uint256 depositID, uint256 relayerPremium, uint256 amount, uint256 expirationBlock, address targetAddress, address relayerAddress) +``` + + + +*List of Locks.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | bytes32 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| depositID | uint256 | undefined | +| relayerPremium | uint256 | undefined | +| amount | uint256 | undefined | +| expirationBlock | uint256 | undefined | +| targetAddress | address | undefined | +| relayerAddress | address | undefined | + +### owner + +```solidity +function owner() external view returns (address) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +### release + +```solidity +function release(bytes32 lockID, uint256 pixTimestamp, bytes32 r, bytes32 s, uint8 v) external nonpayable +``` + + + +*This method can be called by either an order's seller, relayer, or buyer.Function sighash: 0x4e1389ed.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| lockID | bytes32 | undefined | +| pixTimestamp | uint256 | undefined | +| r | bytes32 | undefined | +| s | bytes32 | undefined | +| v | uint8 | undefined | + +### setOwner + +```solidity +function setOwner(address newOwner) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newOwner | address | undefined | + +### unlockExpired + +```solidity +function unlockExpired(bytes32[] lockIDs) external nonpayable +``` + +Unlocks expired locks. + +*Triggered in the callgraph by both `lock` and `withdraw` functions.This method can also have any public actor as its `tx.origin`.Function sighash: 0x8e2749d6.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| lockIDs | bytes32[] | undefined | + +### validBacenSigners + +```solidity +function validBacenSigners(uint256) external view returns (bool) +``` + + + +*List of valid Bacen signature addresses* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### withdraw + +```solidity +function withdraw(uint256 depositID, bytes32[] expiredLocks) external nonpayable +``` + +Seller's expired deposit fund sweeper. + +*A seller may use this method to recover tokens from expired deposits.Function sighash: 0x36317972.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| depositID | uint256 | undefined | +| expiredLocks | bytes32[] | undefined | + +### withdrawBalance + +```solidity +function withdrawBalance() external nonpayable +``` + + + +*Contract's balance withdraw method. Function sighash: 0x5fd8c710.* + + + + +## Events + +### DepositAdded + +```solidity +event DepositAdded(address indexed seller, uint256 depositID, address token, uint256 amount) +``` + +███ Events ████████████████████████████████████████████████████████████ + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| seller `indexed` | address | undefined | +| depositID | uint256 | undefined | +| token | address | undefined | +| amount | uint256 | undefined | + +### DepositClosed + +```solidity +event DepositClosed(address indexed seller, uint256 depositID) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| seller `indexed` | address | undefined | +| depositID | uint256 | undefined | + +### DepositWithdrawn + +```solidity +event DepositWithdrawn(address indexed seller, uint256 depositID, uint256 amount) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| seller `indexed` | address | undefined | +| depositID | uint256 | undefined | +| amount | uint256 | undefined | + +### FundsWithdrawn + +```solidity +event FundsWithdrawn(address owner, uint256 amount) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | +| amount | uint256 | undefined | + +### LockAdded + +```solidity +event LockAdded(address indexed buyer, bytes32 indexed lockID, uint256 depositID, uint256 amount) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| buyer `indexed` | address | undefined | +| lockID `indexed` | bytes32 | undefined | +| depositID | uint256 | undefined | +| amount | uint256 | undefined | + +### LockReleased + +```solidity +event LockReleased(address indexed buyer, bytes32 lockId) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| buyer `indexed` | address | undefined | +| lockId | bytes32 | undefined | + +### LockReturned + +```solidity +event LockReturned(address indexed buyer, bytes32 lockId) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| buyer `indexed` | address | undefined | +| lockId | bytes32 | undefined | + +### OwnerUpdated + +```solidity +event OwnerUpdated(address indexed user, address indexed newOwner) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| user `indexed` | address | undefined | +| newOwner `indexed` | address | undefined | + + + +## Errors + +### AlreadyReleased + +```solidity +error AlreadyReleased() +``` + + + +*Lock already released or returned.0x63b4904e* + + +### DepositAlreadyExists + +```solidity +error DepositAlreadyExists() +``` + + + +*Deposit already exist and it is still valid.0xc44bd765* + + +### InvalidDeposit + +```solidity +error InvalidDeposit() +``` + + + +*Deposit not valid anymore.0xb2e532de* + + +### InvalidSigner + +```solidity +error InvalidSigner() +``` + + + +*Signer is not a valid signer.0x815e1d64* + + +### LoopOverflow + +```solidity +error LoopOverflow() +``` + + + +*Loop bounds have overflowed.0xdfb035c9* + + +### NotEnoughTokens + +```solidity +error NotEnoughTokens() +``` + + + +*Not enough token remaining on deposit.0x22bbb43c* + + +### NotExpired + +```solidity +error NotExpired() +``` + + + +*Lock not expired or already released.Another lock with same ID is not expired yet.0xd0404f85* + + +### OnlySeller + +```solidity +error OnlySeller() +``` + + + +*Only seller could call this function.0x85d1f726* + + +### Reentrancy + +```solidity +error Reentrancy() +``` + + + + + + +### TxAlreadyUsed + +```solidity +error TxAlreadyUsed() +``` + + + +*Transaction already used to unlock payment.0xf490a6ea* + + + diff --git a/docs/callgraph.svg b/docs/callgraph.svg new file mode 100644 index 0000000..4d9c66f --- /dev/null +++ b/docs/callgraph.svg @@ -0,0 +1,537 @@ + + + + + + + + +P2PIX + + + + +DT + + + + +Counters.Counter + + + + +SafeTransferLib + + + + +Legend + + + + + +<Constructor> + + + + + +_castAddrToKey + + + + + + + + + + + +deposit + + + + + +_encodeDepositID + + + + + + + + + + + +ERC20 + + + + + + + + + + + +setReentrancyGuard + + + + + + + + + + + +clearReentrancyGuard + + + + + + + + + + + +DepositAdded + + + + + + + + + + + +Deposit + + + + + + + + + + + +increment + + + + + + + + + + + +safeTransferFrom + + + + + + + + + + + +cancelDeposit + + + + + +_onlySeller + + + + + + + + + + + +DepositClosed + + + + + + + + + + + +lock + + + + + +unlockExpired + + + + + + + + + + + +_encodeLockID + + + + + + + + + + + +InvalidDeposit + + + + + + + + + + + +NotEnoughTokens + + + + + + + + + + + +LockAdded + + + + + + + + + + + +Lock + + + + + + + + + + + +release + + + + + + + + + + + + + + + + + +AlreadyReleased + + + + + + + + + + + +TxAlreadyUsed + + + + + + + + + + + +InvalidSigner + + + + + + + + + + + +LockReleased + + + + + + + + + + + +safeTransfer + + + + + + + + + + + + + + + + + +_notExpired + + + + + + + + + + + +LockReturned + + + + + + + + + + + +withdraw + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +DepositWithdrawn + + + + + + + + + + + + + + + + + +withdrawBalance + + + + + +FundsWithdrawn + + + + + + + + + + + +safeTransferETH + + + + + + + + + + + +<Receive Ether> + + + + + +OnlySeller + + + + + + + + + + + +NotExpired + + + + + + + + + + + +DepositAlreadyExists + + + + + + + + + + + +current + + + + + + + + + + + + + + + + + +Internal Call +External Call +Defined Contract +Undefined Contract + + + + + +    +    + +    + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/lib/auth/Owned.md b/docs/lib/auth/Owned.md new file mode 100644 index 0000000..0629a7a --- /dev/null +++ b/docs/lib/auth/Owned.md @@ -0,0 +1,68 @@ +# Owned + +*Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/auth/Owned.sol)* + + + +Simple single owner authorization mixin. + + + +## Methods + +### owner + +```solidity +function owner() external view returns (address) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +### setOwner + +```solidity +function setOwner(address newOwner) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newOwner | address | undefined | + + + +## Events + +### OwnerUpdated + +```solidity +event OwnerUpdated(address indexed user, address indexed newOwner) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| user `indexed` | address | undefined | +| newOwner `indexed` | address | undefined | + + + diff --git a/docs/lib/mock/MockToken.md b/docs/lib/mock/MockToken.md new file mode 100644 index 0000000..7bc0c2e --- /dev/null +++ b/docs/lib/mock/MockToken.md @@ -0,0 +1,298 @@ +# MockToken + + + + + + + + + +## Methods + +### DOMAIN_SEPARATOR + +```solidity +function DOMAIN_SEPARATOR() external view returns (bytes32) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bytes32 | undefined | + +### allowance + +```solidity +function allowance(address, address) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | +| _1 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### approve + +```solidity +function approve(address spender, uint256 amount) external nonpayable returns (bool) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| spender | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### balanceOf + +```solidity +function balanceOf(address) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### decimals + +```solidity +function decimals() external view returns (uint8) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint8 | undefined | + +### name + +```solidity +function name() external view returns (string) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined | + +### nonces + +```solidity +function nonces(address) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### permit + +```solidity +function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | +| spender | address | undefined | +| value | uint256 | undefined | +| deadline | uint256 | undefined | +| v | uint8 | undefined | +| r | bytes32 | undefined | +| s | bytes32 | undefined | + +### symbol + +```solidity +function symbol() external view returns (string) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined | + +### totalSupply + +```solidity +function totalSupply() external view returns (uint256) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### transfer + +```solidity +function transfer(address to, uint256 amount) external nonpayable returns (bool) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| to | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### transferFrom + +```solidity +function transferFrom(address from, address to, uint256 amount) external nonpayable returns (bool) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from | address | undefined | +| to | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + + + +## Events + +### Approval + +```solidity +event Approval(address indexed owner, address indexed spender, uint256 amount) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner `indexed` | address | undefined | +| spender `indexed` | address | undefined | +| amount | uint256 | undefined | + +### Transfer + +```solidity +event Transfer(address indexed from, address indexed to, uint256 amount) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from `indexed` | address | undefined | +| to `indexed` | address | undefined | +| amount | uint256 | undefined | + + + diff --git a/docs/lib/tokens/ERC20.md b/docs/lib/tokens/ERC20.md new file mode 100644 index 0000000..9ead6a7 --- /dev/null +++ b/docs/lib/tokens/ERC20.md @@ -0,0 +1,298 @@ +# ERC20 + +*Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol)Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)* + + + +Modern and gas efficient ERC20 + EIP-2612 implementation. + +*Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.* + +## Methods + +### DOMAIN_SEPARATOR + +```solidity +function DOMAIN_SEPARATOR() external view returns (bytes32) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bytes32 | undefined | + +### allowance + +```solidity +function allowance(address, address) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | +| _1 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### approve + +```solidity +function approve(address spender, uint256 amount) external nonpayable returns (bool) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| spender | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### balanceOf + +```solidity +function balanceOf(address) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### decimals + +```solidity +function decimals() external view returns (uint8) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint8 | undefined | + +### name + +```solidity +function name() external view returns (string) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined | + +### nonces + +```solidity +function nonces(address) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### permit + +```solidity +function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | +| spender | address | undefined | +| value | uint256 | undefined | +| deadline | uint256 | undefined | +| v | uint8 | undefined | +| r | bytes32 | undefined | +| s | bytes32 | undefined | + +### symbol + +```solidity +function symbol() external view returns (string) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined | + +### totalSupply + +```solidity +function totalSupply() external view returns (uint256) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### transfer + +```solidity +function transfer(address to, uint256 amount) external nonpayable returns (bool) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| to | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### transferFrom + +```solidity +function transferFrom(address from, address to, uint256 amount) external nonpayable returns (bool) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from | address | undefined | +| to | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + + + +## Events + +### Approval + +```solidity +event Approval(address indexed owner, address indexed spender, uint256 amount) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner `indexed` | address | undefined | +| spender `indexed` | address | undefined | +| amount | uint256 | undefined | + +### Transfer + +```solidity +event Transfer(address indexed from, address indexed to, uint256 amount) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from `indexed` | address | undefined | +| to `indexed` | address | undefined | +| amount | uint256 | undefined | + + + diff --git a/docs/lib/utils/Counters.md b/docs/lib/utils/Counters.md new file mode 100644 index 0000000..30ca393 --- /dev/null +++ b/docs/lib/utils/Counters.md @@ -0,0 +1,26 @@ +# Counters + +*buf0t9Modified from OpenZeppelin Contracts (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Counters.sol)* + +> Counters + +Provides counters that can only be incremented, decrementedor reset. + +*Include with `using Counters for Counters.Counter;`* + + + +## Errors + +### DecOverflow + +```solidity +error DecOverflow() +``` + + + +*0xce3a3d37* + + + diff --git a/docs/lib/utils/ReentrancyGuard.md b/docs/lib/utils/ReentrancyGuard.md new file mode 100644 index 0000000..9143e78 --- /dev/null +++ b/docs/lib/utils/ReentrancyGuard.md @@ -0,0 +1,26 @@ +# ReentrancyGuard + +*z0r0z.ethModified from Seaport (https://github.com/ProjectOpenSea/seaport/blob/main/contracts/lib/ReentrancyGuard.sol)Modified from Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/ReentrancyGuard.sol)* + + + +Reentrancy protection for smart contracts. + + + + + +## Errors + +### Reentrancy + +```solidity +error Reentrancy() +``` + + + + + + + diff --git a/docs/lib/utils/SafeTransferLib.md b/docs/lib/utils/SafeTransferLib.md new file mode 100644 index 0000000..464d256 --- /dev/null +++ b/docs/lib/utils/SafeTransferLib.md @@ -0,0 +1,12 @@ +# SafeTransferLib + +*Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol)* + + + +Safe ETH and ERC20 transfer library that gracefully handles missing return values. + +*Caution! This library won't check that a token has code, responsibility is delegated to the caller.* + + + diff --git a/src/types/EventAndErrors.ts b/src/types/EventAndErrors.ts index 24b5a79..7edec0c 100644 --- a/src/types/EventAndErrors.ts +++ b/src/types/EventAndErrors.ts @@ -16,33 +16,32 @@ export interface EventAndErrorsInterface extends utils.Interface { functions: {}; events: { - "DepositAdded(address,uint256,address,uint256,uint256)": EventFragment; + "DepositAdded(address,uint256,address,uint256)": EventFragment; "DepositClosed(address,uint256)": EventFragment; "DepositWithdrawn(address,uint256,uint256)": EventFragment; + "FundsWithdrawn(address,uint256)": EventFragment; "LockAdded(address,bytes32,uint256,uint256)": EventFragment; "LockReleased(address,bytes32)": EventFragment; "LockReturned(address,bytes32)": EventFragment; - "PremiumsWithdrawn(address,uint256)": EventFragment; }; getEvent(nameOrSignatureOrTopic: "DepositAdded"): EventFragment; getEvent(nameOrSignatureOrTopic: "DepositClosed"): EventFragment; getEvent(nameOrSignatureOrTopic: "DepositWithdrawn"): EventFragment; + getEvent(nameOrSignatureOrTopic: "FundsWithdrawn"): EventFragment; getEvent(nameOrSignatureOrTopic: "LockAdded"): EventFragment; getEvent(nameOrSignatureOrTopic: "LockReleased"): EventFragment; getEvent(nameOrSignatureOrTopic: "LockReturned"): EventFragment; - getEvent(nameOrSignatureOrTopic: "PremiumsWithdrawn"): EventFragment; } export interface DepositAddedEventObject { seller: string; depositID: BigNumber; token: string; - premium: BigNumber; amount: BigNumber; } export type DepositAddedEvent = TypedEvent< - [string, BigNumber, string, BigNumber, BigNumber], + [string, BigNumber, string, BigNumber], DepositAddedEventObject >; @@ -72,6 +71,17 @@ export type DepositWithdrawnEvent = TypedEvent< export type DepositWithdrawnEventFilter = TypedEventFilter; +export interface FundsWithdrawnEventObject { + owner: string; + amount: BigNumber; +} +export type FundsWithdrawnEvent = TypedEvent< + [string, BigNumber], + FundsWithdrawnEventObject +>; + +export type FundsWithdrawnEventFilter = TypedEventFilter; + export interface LockAddedEventObject { buyer: string; lockID: string; @@ -107,18 +117,6 @@ export type LockReturnedEvent = TypedEvent< export type LockReturnedEventFilter = TypedEventFilter; -export interface PremiumsWithdrawnEventObject { - owner: string; - amount: BigNumber; -} -export type PremiumsWithdrawnEvent = TypedEvent< - [string, BigNumber], - PremiumsWithdrawnEventObject ->; - -export type PremiumsWithdrawnEventFilter = - TypedEventFilter; - export interface EventAndErrors extends BaseContract { connect(signerOrProvider: Signer | Provider | string): this; attach(addressOrName: string): this; @@ -150,18 +148,16 @@ export interface EventAndErrors extends BaseContract { callStatic: {}; filters: { - "DepositAdded(address,uint256,address,uint256,uint256)"( + "DepositAdded(address,uint256,address,uint256)"( seller?: PromiseOrValue | null, depositID?: null, token?: null, - premium?: null, amount?: null ): DepositAddedEventFilter; DepositAdded( seller?: PromiseOrValue | null, depositID?: null, token?: null, - premium?: null, amount?: null ): DepositAddedEventFilter; @@ -185,6 +181,12 @@ export interface EventAndErrors extends BaseContract { amount?: null ): DepositWithdrawnEventFilter; + "FundsWithdrawn(address,uint256)"( + owner?: null, + amount?: null + ): FundsWithdrawnEventFilter; + FundsWithdrawn(owner?: null, amount?: null): FundsWithdrawnEventFilter; + "LockAdded(address,bytes32,uint256,uint256)"( buyer?: PromiseOrValue | null, lockID?: PromiseOrValue | null, @@ -215,15 +217,6 @@ export interface EventAndErrors extends BaseContract { buyer?: PromiseOrValue | null, lockId?: null ): LockReturnedEventFilter; - - "PremiumsWithdrawn(address,uint256)"( - owner?: null, - amount?: null - ): PremiumsWithdrawnEventFilter; - PremiumsWithdrawn( - owner?: null, - amount?: null - ): PremiumsWithdrawnEventFilter; }; estimateGas: {}; diff --git a/src/types/factories/EventAndErrors__factory.ts b/src/types/factories/EventAndErrors__factory.ts index 31943e7..1e330dc 100644 --- a/src/types/factories/EventAndErrors__factory.ts +++ b/src/types/factories/EventAndErrors__factory.ts @@ -76,12 +76,6 @@ const _abi = [ name: "token", type: "address", }, - { - indexed: false, - internalType: "uint256", - name: "premium", - type: "uint256", - }, { indexed: false, internalType: "uint256", @@ -136,6 +130,25 @@ const _abi = [ name: "DepositWithdrawn", type: "event", }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "owner", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "FundsWithdrawn", + type: "event", + }, { anonymous: false, inputs: [ @@ -205,25 +218,6 @@ const _abi = [ name: "LockReturned", type: "event", }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "address", - name: "owner", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "amount", - type: "uint256", - }, - ], - name: "PremiumsWithdrawn", - type: "event", - }, ]; export class EventAndErrors__factory { diff --git a/src/types/factories/p2pix.sol/P2PIX__factory.ts b/src/types/factories/p2pix.sol/P2PIX__factory.ts index b43b139..92c9233 100644 --- a/src/types/factories/p2pix.sol/P2PIX__factory.ts +++ b/src/types/factories/p2pix.sol/P2PIX__factory.ts @@ -101,12 +101,6 @@ const _abi = [ name: "token", type: "address", }, - { - indexed: false, - internalType: "uint256", - name: "premium", - type: "uint256", - }, { indexed: false, internalType: "uint256", @@ -161,6 +155,25 @@ const _abi = [ name: "DepositWithdrawn", type: "event", }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "owner", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "FundsWithdrawn", + type: "event", + }, { anonymous: false, inputs: [ @@ -249,25 +262,6 @@ const _abi = [ name: "OwnerUpdated", type: "event", }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "address", - name: "owner", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "amount", - type: "uint256", - }, - ], - name: "PremiumsWithdrawn", - type: "event", - }, { inputs: [ { @@ -317,17 +311,17 @@ const _abi = [ inputs: [ { internalType: "address", - name: "token", + name: "_token", type: "address", }, { internalType: "uint256", - name: "amount", + name: "_amount", type: "uint256", }, { internalType: "string", - name: "pixTarget", + name: "_pixTarget", type: "string", }, ], @@ -339,7 +333,7 @@ const _abi = [ type: "uint256", }, ], - stateMutability: "payable", + stateMutability: "nonpayable", type: "function", }, { @@ -414,11 +408,6 @@ const _abi = [ name: "remaining", type: "uint256", }, - { - internalType: "uint256", - name: "premium", - type: "uint256", - }, { internalType: "string", name: "pixTarget", @@ -598,15 +587,19 @@ const _abi = [ }, { inputs: [], - name: "withdrawPremiums", + name: "withdrawBalance", outputs: [], stateMutability: "nonpayable", type: "function", }, + { + stateMutability: "payable", + type: "receive", + }, ]; const _bytecode = - "0x60806040526001805560405162001806380380620018068339810160408190526200002a9162000123565b600080546001600160a01b031916339081178255604051909182917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d76908290a350600382905580516000905b80821015620000d6576000620000ae8484815181106200009a576200009a62000203565b6020026020010151620000e060201b60201c565b6000908152600460205260409020805460ff1916600190811790915592909201915062000076565b5050505062000219565b600c1b611000600160ac1b031690565b634e487b7160e01b600052604160045260246000fd5b80516001600160a01b03811681146200011e57600080fd5b919050565b600080604083850312156200013757600080fd5b8251602080850151919350906001600160401b03808211156200015957600080fd5b818601915086601f8301126200016e57600080fd5b815181811115620001835762000183620000f0565b8060051b604051601f19603f83011681018181108582111715620001ab57620001ab620000f0565b604052918252848201925083810185019189831115620001ca57600080fd5b938501935b82851015620001f357620001e38562000106565b84529385019392850192620001cf565b8096505050505050509250929050565b634e487b7160e01b600052603260045260246000fd5b6115dd80620002296000396000f3fe6080604052600436106100e85760003560e01c80636193cdfb1161008a5780638e2a3d36116100595780638e2a3d36146102f55780639872dbfe1461032757806398a268711461033d578063bfe07da61461037d57600080fd5b80636193cdfb1461026857806372fada5c1461027d5780638da5cb5b1461029d5780638e2749d6146102d557600080fd5b80632dfdf0b5116100c65780632dfdf0b5146101d857806336317972146101ef5780634b2ae9801461020f5780634e1389ed1461024857600080fd5b806303aaf306146100ed57806313af40351461012057806316d7224014610142575b600080fd5b3480156100f957600080fd5b5061010d6101083660046111e7565b610390565b6040519081526020015b60405180910390f35b34801561012c57600080fd5b5061014061013b366004611269565b61053a565b005b34801561014e57600080fd5b5061019f61015d366004611284565b60066020526000908152604090208054600182015460028301546003840154600485015460059095015493949293919290916001600160a01b03918216911686565b6040805196875260208701959095529385019290925260608401526001600160a01b0390811660808401521660a082015260c001610117565b3480156101e457600080fd5b5060025461010d9081565b3480156101fb57600080fd5b5061014061020a36600461129d565b6105e0565b34801561021b57600080fd5b5061010d61022a366004611269565b600c1b750ffffffffffffffffffffffffffffffffffffffff0001690565b34801561025457600080fd5b506101406102633660046112e9565b6106a0565b34801561027457600080fd5b50610140610962565b34801561028957600080fd5b50610140610298366004611284565b6109f2565b3480156102a957600080fd5b506000546102bd906001600160a01b031681565b6040516001600160a01b039091168152602001610117565b3480156102e157600080fd5b506101406102f036600461133c565b610a7a565b34801561030157600080fd5b50610315610310366004611284565b610b76565b6040516101179695949392919061137e565b34801561033357600080fd5b5061010d60035481565b34801561034957600080fd5b5061036d610358366004611284565b60046020526000908152604090205460ff1681565b6040519015158152602001610117565b61010d61038b36600461140c565b610c46565b600061039a610e00565b6103a48383610a7a565b60008881526005602052604090206004810154600160a01b900460ff166103de57604051635972996f60e11b815260040160405180910390fd5b8054851115610400576040516308aeed0f60e21b815260040160405180910390fd5b61040b89868a610e2b565b915060006040518060c001604052808b81526020018881526020018781526020016003544361043a91906114a9565b81526001600160a01b03808c166020808401919091528b82166040938401526000878152600682528381208551815591850151600183015592840151600282015560608401516003820155608084015160048201805491841673ffffffffffffffffffffffffffffffffffffffff1992831617905560a085015160059092018054929093169116179055835491925087918491906104d99084906114c1565b9091555050604080518b81526020810188905284916001600160a01b038c16917f2a28b2ae47b0bd4b104e7cd29b1dfa72846af8c4cfdc009da2ae29db68cb67ea910160405180910390a3505061052f60018055565b979650505050505050565b6000546001600160a01b031633146105885760405162461bcd60e51b815260206004820152600c60248201526b15539055551213d49256915160a21b60448201526064015b60405180910390fd5b6000805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081178255604051909133917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d769190a350565b6105e8610e00565b6105f183610eaf565b6105fb8282610a7a565b60008381526005602052604090206004810154600160a01b900460ff1615156001141561062b5761062b846109f2565b600481015481546000835560038301546001600160a01b03928316926106549184911683610eec565b604080518781526020810183905233917f7719804546c0185709e60c90d164447ff251a5ba29af0216faa921350f6bebf7910160405180910390a250505061069b60018055565b505050565b6106a8610e00565b6000858152600660205260409020600381015443108015906106cc57506002810154155b156106ea576040516331da482760e11b815260040160405180910390fd5b80546000908152600560209081526040808320600280860154925191949361071893918601928b9101611513565b60405160208183030381529060405280519060200120905060008160405160200161076f91907f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c810191909152603c0190565b60408051601f1981840301815291815281516020928301206000858152600790935291205490915060ff161515600114156107bd57604051637a48537560e11b815260040160405180910390fd5b6040805160008082526020820180845284905260ff881692820192909252606081018990526080810188905261083f9060019060a0016020604051602081039080840390855afa158015610815573d6000803e3d6000fd5b5050604051601f190151600c1b750ffffffffffffffffffffffffffffffffffffffff00016919050565b60008181526004602052604090205490915060ff1661087157604051632057875960e21b815260040160405180910390fd5b6004840154600186015460028701546001600160a01b0390921691600091610898916114c1565b60006002890181905560038901819055868152600760205260409020805460ff1916600117905560048801549091506108dc9083906001600160a01b031683610eec565b60018701541561090757600587015460018801546109079184916001600160a01b0390911690610eec565b60048701546040518d81526001600160a01b03909116907f5e420822d2f7281fdc4b763c62c8b7874bf22108a35efe93144d79296aacc67d9060200160405180910390a25050505050505061095b60018055565b5050505050565b6000546001600160a01b031633146109ab5760405162461bcd60e51b815260206004820152600c60248201526b15539055551213d49256915160a21b604482015260640161057f565b476109b63382610f78565b60408051338152602081018390527fbf0d92faf65e256806eefa1a0d281d4873cc3c80d1ed25b8ae6f7cc66fc918ef910160405180910390a150565b6109fb81610eaf565b6000818152600560209081526040918290206004810180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690556003015491518381526001600160a01b03909216917fb4d98b272597e828d9b172c0d44390d5b267040e918088eac8a0a0fadcb81c70910160405180910390a250565b6000815b80821015610b5a57600060066000868686818110610a9e57610a9e6115ba565b9050602002013581526020019081526020016000209050610abe81610fd3565b6002810154815460009081526005602052604081208054909190610ae39084906114a9565b90915550506000600282015560048101546001600160a01b03167f67e089478e21dd12c98e69331c4152f6c9b2038b91e0f28268ffa01558c0b4ff868686818110610b3057610b306115ba565b90506020020135604051610b4691815260200190565b60405180910390a282600101925050610a7e565b80821015610b705763dfb035c96000526004601cfd5b50505050565b60056020526000908152604090208054600182015460028301805492939192610b9e906114d8565b80601f0160208091040260200160405190810160405280929190818152602001828054610bca906114d8565b8015610c175780601f10610bec57610100808354040283529160200191610c17565b820191906000526020600020905b815481529060010190602001808311610bfa57829003601f168201915b50505050600383015460049093015491926001600160a01b03908116929081169150600160a01b900460ff1686565b6000610c50611006565b9050600085905060006040518060c0016040528087815260200134815260200186868080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050908252503360208201526001600160a01b038916604082015260016060909101529050610cd0610e00565b60008381526005602090815260409182902083518155818401516001820155918301518051849392610d099260028501929101906110e6565b50606082015160038201805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392831617905560808301516004909201805460a090940151929091167fffffffffffffffffffffff00000000000000000000000000000000000000000090931692909217600160a01b91151591909102179055600280546001019055610d9c82333089611056565b610da560018055565b604080518481526001600160a01b0389166020820152348183015260608101889052905133917fe0cfbec12278e314697ee34bb7a1ba4d704e84c438680672f7c1175f287e5910919081900360800190a25050949350505050565b60015460021415610e245760405163558a1e0360e11b815260040160405180910390fd5b6002600155565b6040805160208101859052908101839052606082811b6bffffffffffffffffffffffff19169082015260009060740160405160208183030381529060405280519060200120905043600660008381526020019081526020016000206003015410610ea85760405163d0404f8560e01b815260040160405180910390fd5b9392505050565b6000818152600560205260409020600301546001600160a01b03163314610ee9576040516342e8fb9360e11b815260040160405180910390fd5b50565b600060405163a9059cbb60e01b6000528360045282602452602060006044600080895af13d15601f3d1160016000511416171691506000606052806040525080610b705760405162461bcd60e51b815260206004820152600f60248201527f5452414e534645525f4641494c45440000000000000000000000000000000000604482015260640161057f565b600080600080600085875af190508061069b5760405162461bcd60e51b815260206004820152601360248201527f4554485f5452414e534645525f4641494c454400000000000000000000000000604482015260640161057f565b438160030154101580610fe857506002810154155b15610ee95760405163d0404f8560e01b815260040160405180910390fd5b600061101160025490565b600081815260056020526040902060040154909150600160a01b900460ff161515600114156110535760405163c44bd76560e01b815260040160405180910390fd5b90565b60006040516323b872dd60e01b6000528460045283602452826044526020600060646000808a5af13d15601f3d116001600051141617169150600060605280604052508061095b5760405162461bcd60e51b815260206004820152601460248201527f5452414e534645525f46524f4d5f4641494c4544000000000000000000000000604482015260640161057f565b8280546110f2906114d8565b90600052602060002090601f016020900481019282611114576000855561115a565b82601f1061112d57805160ff191683800117855561115a565b8280016001018555821561115a579182015b8281111561115a57825182559160200191906001019061113f565b5061116692915061116a565b5090565b5b80821115611166576000815560010161116b565b80356001600160a01b038116811461119657600080fd5b919050565b60008083601f8401126111ad57600080fd5b50813567ffffffffffffffff8111156111c557600080fd5b6020830191508360208260051b85010111156111e057600080fd5b9250929050565b600080600080600080600060c0888a03121561120257600080fd5b873596506112126020890161117f565b95506112206040890161117f565b9450606088013593506080880135925060a088013567ffffffffffffffff81111561124a57600080fd5b6112568a828b0161119b565b989b979a50959850939692959293505050565b60006020828403121561127b57600080fd5b610ea88261117f565b60006020828403121561129657600080fd5b5035919050565b6000806000604084860312156112b257600080fd5b83359250602084013567ffffffffffffffff8111156112d057600080fd5b6112dc8682870161119b565b9497909650939450505050565b600080600080600060a0868803121561130157600080fd5b85359450602086013593506040860135925060608601359150608086013560ff8116811461132e57600080fd5b809150509295509295909350565b6000806020838503121561134f57600080fd5b823567ffffffffffffffff81111561136657600080fd5b6113728582860161119b565b90969095509350505050565b86815260006020878184015260c0604084015286518060c085015260005b818110156113b85788810183015185820160e00152820161139c565b818111156113ca57600060e083870101525b50601f01601f1916830160e00191506113f0905060608301866001600160a01b03169052565b6001600160a01b038416608083015282151560a083015261052f565b6000806000806060858703121561142257600080fd5b61142b8561117f565b935060208501359250604085013567ffffffffffffffff8082111561144f57600080fd5b818701915087601f83011261146357600080fd5b81358181111561147257600080fd5b88602082850101111561148457600080fd5b95989497505060200194505050565b634e487b7160e01b600052601160045260246000fd5b600082198211156114bc576114bc611493565b500190565b6000828210156114d3576114d3611493565b500390565b600181811c908216806114ec57607f821691505b6020821081141561150d57634e487b7160e01b600052602260045260246000fd5b50919050565b600080855481600182811c91508083168061152f57607f831692505b602080841082141561154f57634e487b7160e01b86526022600452602486fd5b8180156115635760018114611574576115a1565b60ff198616895284890196506115a1565b60008c81526020902060005b868110156115995781548b820152908501908301611580565b505084890196505b5098855250505050938401929092525050604001919050565b634e487b7160e01b600052603260045260246000fdfea164736f6c6343000809000a"; + "0x60806040526001805560405162001807380380620018078339810160408190526200002a9162000123565b600080546001600160a01b031916339081178255604051909182917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d76908290a350600382905580516000905b80821015620000d6576000620000ae8484815181106200009a576200009a62000203565b6020026020010151620000e060201b60201c565b6000908152600460205260409020805460ff1916600190811790915592909201915062000076565b5050505062000219565b600c1b611000600160ac1b031690565b634e487b7160e01b600052604160045260246000fd5b80516001600160a01b03811681146200011e57600080fd5b919050565b600080604083850312156200013757600080fd5b8251602080850151919350906001600160401b03808211156200015957600080fd5b818601915086601f8301126200016e57600080fd5b815181811115620001835762000183620000f0565b8060051b604051601f19603f83011681018181108582111715620001ab57620001ab620000f0565b604052918252848201925083810185019189831115620001ca57600080fd5b938501935b82851015620001f357620001e38562000106565b84529385019392850192620001cf565b8096505050505050509250929050565b634e487b7160e01b600052603260045260246000fd5b6115de80620002296000396000f3fe6080604052600436106100ec5760003560e01c80635fd8c7101161008a5780638e2a3d36116100595780638e2a3d36146103005780639872dbfe1461033157806398a2687114610347578063bfe07da61461038757600080fd5b80635fd8c7101461027357806372fada5c146102885780638da5cb5b146102a85780638e2749d6146102e057600080fd5b80632dfdf0b5116100c65780632dfdf0b5146101e357806336317972146101fa5780634b2ae9801461021a5780634e1389ed1461025357600080fd5b806303aaf306146100f857806313af40351461012b57806316d722401461014d57600080fd5b366100f357005b600080fd5b34801561010457600080fd5b506101186101133660046111e9565b6103a7565b6040519081526020015b60405180910390f35b34801561013757600080fd5b5061014b61014636600461126b565b610551565b005b34801561015957600080fd5b506101aa610168366004611286565b60066020526000908152604090208054600182015460028301546003840154600485015460059095015493949293919290916001600160a01b03918216911686565b6040805196875260208701959095529385019290925260608401526001600160a01b0390811660808401521660a082015260c001610122565b3480156101ef57600080fd5b506002546101189081565b34801561020657600080fd5b5061014b61021536600461129f565b6105f7565b34801561022657600080fd5b5061011861023536600461126b565b600c1b750ffffffffffffffffffffffffffffffffffffffff0001690565b34801561025f57600080fd5b5061014b61026e3660046112eb565b6106b7565b34801561027f57600080fd5b5061014b61097a565b34801561029457600080fd5b5061014b6102a3366004611286565b610a0a565b3480156102b457600080fd5b506000546102c8906001600160a01b031681565b6040516001600160a01b039091168152602001610122565b3480156102ec57600080fd5b5061014b6102fb36600461133e565b610a92565b34801561030c57600080fd5b5061032061031b366004611286565b610b8e565b604051610122959493929190611380565b34801561033d57600080fd5b5061011860035481565b34801561035357600080fd5b50610377610362366004611286565b60046020526000908152604090205460ff1681565b6040519015158152602001610122565b34801561039357600080fd5b506101186103a236600461140d565b610c58565b60006103b1610e02565b6103bb8383610a92565b60008881526005602052604090206003810154600160a01b900460ff166103f557604051635972996f60e11b815260040160405180910390fd5b8054851115610417576040516308aeed0f60e21b815260040160405180910390fd5b61042289868a610e2d565b915060006040518060c001604052808b81526020018881526020018781526020016003544361045191906114aa565b81526001600160a01b03808c166020808401919091528b82166040938401526000878152600682528381208551815591850151600183015592840151600282015560608401516003820155608084015160048201805491841673ffffffffffffffffffffffffffffffffffffffff1992831617905560a085015160059092018054929093169116179055835491925087918491906104f09084906114c2565b9091555050604080518b81526020810188905284916001600160a01b038c16917f2a28b2ae47b0bd4b104e7cd29b1dfa72846af8c4cfdc009da2ae29db68cb67ea910160405180910390a3505061054660018055565b979650505050505050565b6000546001600160a01b0316331461059f5760405162461bcd60e51b815260206004820152600c60248201526b15539055551213d49256915160a21b60448201526064015b60405180910390fd5b6000805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081178255604051909133917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d769190a350565b6105ff610e02565b61060883610eb1565b6106128282610a92565b60008381526005602052604090206003810154600160a01b900460ff161515600114156106425761064284610a0a565b600381015481546000835560028301546001600160a01b039283169261066b9184911683610eee565b604080518781526020810183905233917f7719804546c0185709e60c90d164447ff251a5ba29af0216faa921350f6bebf7910160405180910390a25050506106b260018055565b505050565b6106bf610e02565b60008581526006602052604090206003810154431015806106e257506002810154155b15610700576040516331da482760e11b815260040160405180910390fd5b805460009081526005602090815260408083206002850154915190939261073092600186019290918b9101611514565b60405160208183030381529060405280519060200120905060008160405160200161078791907f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c810191909152603c0190565b60408051601f1981840301815291815281516020928301206000858152600790935291205490915060ff161515600114156107d557604051637a48537560e11b815260040160405180910390fd5b6040805160008082526020820180845284905260ff88169282019290925260608101899052608081018890526108579060019060a0016020604051602081039080840390855afa15801561082d573d6000803e3d6000fd5b5050604051601f190151600c1b750ffffffffffffffffffffffffffffffffffffffff00016919050565b60008181526004602052604090205490915060ff1661088957604051632057875960e21b815260040160405180910390fd5b6003840154600186015460028701546001600160a01b03909216916000916108b0916114c2565b60006002890181905560038901819055868152600760205260409020805460ff1916600117905560048801549091506108f49083906001600160a01b031683610eee565b60018701541561091f576005870154600188015461091f9184916001600160a01b0390911690610eee565b60048701546040518d81526001600160a01b03909116907f5e420822d2f7281fdc4b763c62c8b7874bf22108a35efe93144d79296aacc67d9060200160405180910390a25050505050505061097360018055565b5050505050565b6000546001600160a01b031633146109c35760405162461bcd60e51b815260206004820152600c60248201526b15539055551213d49256915160a21b6044820152606401610596565b476109ce3382610f7a565b60408051338152602081018390527feaff4b37086828766ad3268786972c0cd24259d4c87a80f9d3963a3c3d999b0d910160405180910390a150565b610a1381610eb1565b6000818152600560209081526040918290206003810180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690556002015491518381526001600160a01b03909216917fb4d98b272597e828d9b172c0d44390d5b267040e918088eac8a0a0fadcb81c70910160405180910390a250565b6000815b80821015610b7257600060066000868686818110610ab657610ab66115bb565b9050602002013581526020019081526020016000209050610ad681610fd5565b6002810154815460009081526005602052604081208054909190610afb9084906114aa565b90915550506000600282015560048101546001600160a01b03167f67e089478e21dd12c98e69331c4152f6c9b2038b91e0f28268ffa01558c0b4ff868686818110610b4857610b486115bb565b90506020020135604051610b5e91815260200190565b60405180910390a282600101925050610a96565b80821015610b885763dfb035c96000526004601cfd5b50505050565b60056020526000908152604090208054600182018054919291610bb0906114d9565b80601f0160208091040260200160405190810160405280929190818152602001828054610bdc906114d9565b8015610c295780601f10610bfe57610100808354040283529160200191610c29565b820191906000526020600020905b815481529060010190602001808311610c0c57829003601f168201915b50505050600283015460039093015491926001600160a01b03908116929081169150600160a01b900460ff1685565b6000610c62611008565b9050600085905060006040518060a0016040528087815260200186868080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050908252503360208201526001600160a01b038916604082015260016060909101529050610cdc610e02565b6000838152600560209081526040909120825181558183015180518493610d0a9260018501929101906110e8565b506040820151600280830180546001600160a01b0393841673ffffffffffffffffffffffffffffffffffffffff199091161790556060840151600390930180546080909501511515600160a01b027fffffffffffffffffffffff000000000000000000000000000000000000000000909516939092169290921792909217909155610d989080546001019055565b610da482333089611058565b610dad60018055565b604080518481526001600160a01b038916602082015290810187905233907f25ac57b911b0f66b64c294827f539545fbc3ddd002cafab117776274f3241e4c9060600160405180910390a25050949350505050565b60015460021415610e265760405163558a1e0360e11b815260040160405180910390fd5b6002600155565b6040805160208101859052908101839052606082811b6bffffffffffffffffffffffff19169082015260009060740160405160208183030381529060405280519060200120905043600660008381526020019081526020016000206003015410610eaa5760405163d0404f8560e01b815260040160405180910390fd5b9392505050565b6000818152600560205260409020600201546001600160a01b03163314610eeb576040516342e8fb9360e11b815260040160405180910390fd5b50565b600060405163a9059cbb60e01b6000528360045282602452602060006044600080895af13d15601f3d1160016000511416171691506000606052806040525080610b885760405162461bcd60e51b815260206004820152600f60248201527f5452414e534645525f4641494c454400000000000000000000000000000000006044820152606401610596565b600080600080600085875af19050806106b25760405162461bcd60e51b815260206004820152601360248201527f4554485f5452414e534645525f4641494c4544000000000000000000000000006044820152606401610596565b438160030154101580610fea57506002810154155b15610eeb5760405163d0404f8560e01b815260040160405180910390fd5b600061101360025490565b600081815260056020526040902060030154909150600160a01b900460ff161515600114156110555760405163c44bd76560e01b815260040160405180910390fd5b90565b60006040516323b872dd60e01b6000528460045283602452826044526020600060646000808a5af13d15601f3d11600160005114161716915060006060528060405250806109735760405162461bcd60e51b815260206004820152601460248201527f5452414e534645525f46524f4d5f4641494c45440000000000000000000000006044820152606401610596565b8280546110f4906114d9565b90600052602060002090601f016020900481019282611116576000855561115c565b82601f1061112f57805160ff191683800117855561115c565b8280016001018555821561115c579182015b8281111561115c578251825591602001919060010190611141565b5061116892915061116c565b5090565b5b80821115611168576000815560010161116d565b80356001600160a01b038116811461119857600080fd5b919050565b60008083601f8401126111af57600080fd5b50813567ffffffffffffffff8111156111c757600080fd5b6020830191508360208260051b85010111156111e257600080fd5b9250929050565b600080600080600080600060c0888a03121561120457600080fd5b8735965061121460208901611181565b955061122260408901611181565b9450606088013593506080880135925060a088013567ffffffffffffffff81111561124c57600080fd5b6112588a828b0161119d565b989b979a50959850939692959293505050565b60006020828403121561127d57600080fd5b610eaa82611181565b60006020828403121561129857600080fd5b5035919050565b6000806000604084860312156112b457600080fd5b83359250602084013567ffffffffffffffff8111156112d257600080fd5b6112de8682870161119d565b9497909650939450505050565b600080600080600060a0868803121561130357600080fd5b85359450602086013593506040860135925060608601359150608086013560ff8116811461133057600080fd5b809150509295509295909350565b6000806020838503121561135157600080fd5b823567ffffffffffffffff81111561136857600080fd5b6113748582860161119d565b90969095509350505050565b8581526000602060a08184015286518060a085015260005b818110156113b45788810183015185820160c001528201611398565b818111156113c657600060c083870101525b50601f01601f1916830160c00191506113ec905060408301866001600160a01b03169052565b6001600160a01b038416606083015282151560808301529695505050505050565b6000806000806060858703121561142357600080fd5b61142c85611181565b935060208501359250604085013567ffffffffffffffff8082111561145057600080fd5b818701915087601f83011261146457600080fd5b81358181111561147357600080fd5b88602082850101111561148557600080fd5b95989497505060200194505050565b634e487b7160e01b600052601160045260246000fd5b600082198211156114bd576114bd611494565b500190565b6000828210156114d4576114d4611494565b500390565b600181811c908216806114ed57607f821691505b6020821081141561150e57634e487b7160e01b600052602260045260246000fd5b50919050565b600080855481600182811c91508083168061153057607f831692505b602080841082141561155057634e487b7160e01b86526022600452602486fd5b8180156115645760018114611575576115a2565b60ff198616895284890196506115a2565b60008c81526020902060005b8681101561159a5781548b820152908501908301611581565b505084890196505b5098855250505050938401929092525050604001919050565b634e487b7160e01b600052603260045260246000fdfea164736f6c6343000809000a"; type P2PIXConstructorParams = | [signer?: Signer] diff --git a/src/types/p2pix.sol/P2PIX.ts b/src/types/p2pix.sol/P2PIX.ts index fb44a2e..2312b66 100644 --- a/src/types/p2pix.sol/P2PIX.ts +++ b/src/types/p2pix.sol/P2PIX.ts @@ -9,7 +9,6 @@ import type { CallOverrides, ContractTransaction, Overrides, - PayableOverrides, PopulatedTransaction, Signer, utils, @@ -44,7 +43,7 @@ export interface P2PIXInterface extends utils.Interface { "unlockExpired(bytes32[])": FunctionFragment; "validBacenSigners(uint256)": FunctionFragment; "withdraw(uint256,bytes32[])": FunctionFragment; - "withdrawPremiums()": FunctionFragment; + "withdrawBalance()": FunctionFragment; }; getFunction( @@ -63,7 +62,7 @@ export interface P2PIXInterface extends utils.Interface { | "unlockExpired" | "validBacenSigners" | "withdraw" - | "withdrawPremiums" + | "withdrawBalance" ): FunctionFragment; encodeFunctionData( @@ -137,7 +136,7 @@ export interface P2PIXInterface extends utils.Interface { values: [PromiseOrValue, PromiseOrValue[]] ): string; encodeFunctionData( - functionFragment: "withdrawPremiums", + functionFragment: "withdrawBalance", values?: undefined ): string; @@ -177,40 +176,39 @@ export interface P2PIXInterface extends utils.Interface { ): Result; decodeFunctionResult(functionFragment: "withdraw", data: BytesLike): Result; decodeFunctionResult( - functionFragment: "withdrawPremiums", + functionFragment: "withdrawBalance", data: BytesLike ): Result; events: { - "DepositAdded(address,uint256,address,uint256,uint256)": EventFragment; + "DepositAdded(address,uint256,address,uint256)": EventFragment; "DepositClosed(address,uint256)": EventFragment; "DepositWithdrawn(address,uint256,uint256)": EventFragment; + "FundsWithdrawn(address,uint256)": EventFragment; "LockAdded(address,bytes32,uint256,uint256)": EventFragment; "LockReleased(address,bytes32)": EventFragment; "LockReturned(address,bytes32)": EventFragment; "OwnerUpdated(address,address)": EventFragment; - "PremiumsWithdrawn(address,uint256)": EventFragment; }; getEvent(nameOrSignatureOrTopic: "DepositAdded"): EventFragment; getEvent(nameOrSignatureOrTopic: "DepositClosed"): EventFragment; getEvent(nameOrSignatureOrTopic: "DepositWithdrawn"): EventFragment; + getEvent(nameOrSignatureOrTopic: "FundsWithdrawn"): EventFragment; getEvent(nameOrSignatureOrTopic: "LockAdded"): EventFragment; getEvent(nameOrSignatureOrTopic: "LockReleased"): EventFragment; getEvent(nameOrSignatureOrTopic: "LockReturned"): EventFragment; getEvent(nameOrSignatureOrTopic: "OwnerUpdated"): EventFragment; - getEvent(nameOrSignatureOrTopic: "PremiumsWithdrawn"): EventFragment; } export interface DepositAddedEventObject { seller: string; depositID: BigNumber; token: string; - premium: BigNumber; amount: BigNumber; } export type DepositAddedEvent = TypedEvent< - [string, BigNumber, string, BigNumber, BigNumber], + [string, BigNumber, string, BigNumber], DepositAddedEventObject >; @@ -240,6 +238,17 @@ export type DepositWithdrawnEvent = TypedEvent< export type DepositWithdrawnEventFilter = TypedEventFilter; +export interface FundsWithdrawnEventObject { + owner: string; + amount: BigNumber; +} +export type FundsWithdrawnEvent = TypedEvent< + [string, BigNumber], + FundsWithdrawnEventObject +>; + +export type FundsWithdrawnEventFilter = TypedEventFilter; + export interface LockAddedEventObject { buyer: string; lockID: string; @@ -286,18 +295,6 @@ export type OwnerUpdatedEvent = TypedEvent< export type OwnerUpdatedEventFilter = TypedEventFilter; -export interface PremiumsWithdrawnEventObject { - owner: string; - amount: BigNumber; -} -export type PremiumsWithdrawnEvent = TypedEvent< - [string, BigNumber], - PremiumsWithdrawnEventObject ->; - -export type PremiumsWithdrawnEventFilter = - TypedEventFilter; - export interface P2PIX extends BaseContract { connect(signerOrProvider: Signer | Provider | string): this; attach(addressOrName: string): this; @@ -338,10 +335,10 @@ export interface P2PIX extends BaseContract { defaultLockBlocks(overrides?: CallOverrides): Promise<[BigNumber]>; deposit( - token: PromiseOrValue, - amount: PromiseOrValue, - pixTarget: PromiseOrValue, - overrides?: PayableOverrides & { from?: PromiseOrValue } + _token: PromiseOrValue, + _amount: PromiseOrValue, + _pixTarget: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } ): Promise; depositCount( @@ -362,9 +359,8 @@ export interface P2PIX extends BaseContract { arg0: PromiseOrValue, overrides?: CallOverrides ): Promise< - [BigNumber, BigNumber, string, string, string, boolean] & { + [BigNumber, string, string, string, boolean] & { remaining: BigNumber; - premium: BigNumber; pixTarget: string; seller: string; token: string; @@ -418,7 +414,7 @@ export interface P2PIX extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - withdrawPremiums( + withdrawBalance( overrides?: Overrides & { from?: PromiseOrValue } ): Promise; }; @@ -436,10 +432,10 @@ export interface P2PIX extends BaseContract { defaultLockBlocks(overrides?: CallOverrides): Promise; deposit( - token: PromiseOrValue, - amount: PromiseOrValue, - pixTarget: PromiseOrValue, - overrides?: PayableOverrides & { from?: PromiseOrValue } + _token: PromiseOrValue, + _amount: PromiseOrValue, + _pixTarget: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } ): Promise; depositCount(overrides?: CallOverrides): Promise; @@ -458,9 +454,8 @@ export interface P2PIX extends BaseContract { arg0: PromiseOrValue, overrides?: CallOverrides ): Promise< - [BigNumber, BigNumber, string, string, string, boolean] & { + [BigNumber, string, string, string, boolean] & { remaining: BigNumber; - premium: BigNumber; pixTarget: string; seller: string; token: string; @@ -514,7 +509,7 @@ export interface P2PIX extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - withdrawPremiums( + withdrawBalance( overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -532,9 +527,9 @@ export interface P2PIX extends BaseContract { defaultLockBlocks(overrides?: CallOverrides): Promise; deposit( - token: PromiseOrValue, - amount: PromiseOrValue, - pixTarget: PromiseOrValue, + _token: PromiseOrValue, + _amount: PromiseOrValue, + _pixTarget: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -554,9 +549,8 @@ export interface P2PIX extends BaseContract { arg0: PromiseOrValue, overrides?: CallOverrides ): Promise< - [BigNumber, BigNumber, string, string, string, boolean] & { + [BigNumber, string, string, string, boolean] & { remaining: BigNumber; - premium: BigNumber; pixTarget: string; seller: string; token: string; @@ -610,22 +604,20 @@ export interface P2PIX extends BaseContract { overrides?: CallOverrides ): Promise; - withdrawPremiums(overrides?: CallOverrides): Promise; + withdrawBalance(overrides?: CallOverrides): Promise; }; filters: { - "DepositAdded(address,uint256,address,uint256,uint256)"( + "DepositAdded(address,uint256,address,uint256)"( seller?: PromiseOrValue | null, depositID?: null, token?: null, - premium?: null, amount?: null ): DepositAddedEventFilter; DepositAdded( seller?: PromiseOrValue | null, depositID?: null, token?: null, - premium?: null, amount?: null ): DepositAddedEventFilter; @@ -649,6 +641,12 @@ export interface P2PIX extends BaseContract { amount?: null ): DepositWithdrawnEventFilter; + "FundsWithdrawn(address,uint256)"( + owner?: null, + amount?: null + ): FundsWithdrawnEventFilter; + FundsWithdrawn(owner?: null, amount?: null): FundsWithdrawnEventFilter; + "LockAdded(address,bytes32,uint256,uint256)"( buyer?: PromiseOrValue | null, lockID?: PromiseOrValue | null, @@ -688,15 +686,6 @@ export interface P2PIX extends BaseContract { user?: PromiseOrValue | null, newOwner?: PromiseOrValue | null ): OwnerUpdatedEventFilter; - - "PremiumsWithdrawn(address,uint256)"( - owner?: null, - amount?: null - ): PremiumsWithdrawnEventFilter; - PremiumsWithdrawn( - owner?: null, - amount?: null - ): PremiumsWithdrawnEventFilter; }; estimateGas: { @@ -713,10 +702,10 @@ export interface P2PIX extends BaseContract { defaultLockBlocks(overrides?: CallOverrides): Promise; deposit( - token: PromiseOrValue, - amount: PromiseOrValue, - pixTarget: PromiseOrValue, - overrides?: PayableOverrides & { from?: PromiseOrValue } + _token: PromiseOrValue, + _amount: PromiseOrValue, + _pixTarget: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } ): Promise; depositCount(overrides?: CallOverrides): Promise; @@ -773,7 +762,7 @@ export interface P2PIX extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - withdrawPremiums( + withdrawBalance( overrides?: Overrides & { from?: PromiseOrValue } ): Promise; }; @@ -792,10 +781,10 @@ export interface P2PIX extends BaseContract { defaultLockBlocks(overrides?: CallOverrides): Promise; deposit( - token: PromiseOrValue, - amount: PromiseOrValue, - pixTarget: PromiseOrValue, - overrides?: PayableOverrides & { from?: PromiseOrValue } + _token: PromiseOrValue, + _amount: PromiseOrValue, + _pixTarget: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } ): Promise; depositCount(overrides?: CallOverrides): Promise; @@ -852,7 +841,7 @@ export interface P2PIX extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - withdrawPremiums( + withdrawBalance( overrides?: Overrides & { from?: PromiseOrValue } ): Promise; }; diff --git a/test/1-deposit.test.ts b/test/1-deposit.test.ts index 2001eca..5fde07a 100644 --- a/test/1-deposit.test.ts +++ b/test/1-deposit.test.ts @@ -65,7 +65,7 @@ describe("P2PIX deposit test", () => { erc20.address, ethers.utils.parseEther("1000"), "SELLER PIX KEY", - { value: ethers.utils.parseEther("0.1") }, + // { value: ethers.utils.parseEther("0.1") }, ); await expect(transaction) .to.emit(p2pix, "DepositAdded") @@ -73,7 +73,7 @@ describe("P2PIX deposit test", () => { owner.address, 0, erc20.address, - ethers.utils.parseEther("0.1"), + // ethers.utils.parseEther("0.1"), ethers.utils.parseEther("1000"), ); }); @@ -83,7 +83,7 @@ describe("P2PIX deposit test", () => { erc20.address, ethers.utils.parseEther("1000"), "SELLER PIX KEY", - { value: ethers.utils.parseEther("0.1") }, + // { value: ethers.utils.parseEther("0.1") }, ); await expect(transaction) .to.emit(p2pix, "DepositAdded") @@ -91,7 +91,7 @@ describe("P2PIX deposit test", () => { owner.address, 1, erc20.address, - ethers.utils.parseEther("0.1"), + // ethers.utils.parseEther("0.1"), ethers.utils.parseEther("1000"), ); }); diff --git a/test/2-lock-release.test.ts b/test/2-lock-release.test.ts index a484feb..e18d259 100644 --- a/test/2-lock-release.test.ts +++ b/test/2-lock-release.test.ts @@ -70,7 +70,7 @@ describe("P2PIX deposit test", () => { erc20.address, ethers.utils.parseEther("1000"), "SELLER PIX KEY", - { value: ethers.utils.parseEther("0.1") }, + // { value: ethers.utils.parseEther("0.1") }, ); await expect(transaction) .to.emit(p2pix, "DepositAdded") @@ -78,7 +78,7 @@ describe("P2PIX deposit test", () => { owner.address, 0, erc20.address, - ethers.utils.parseEther("0.1"), + // ethers.utils.parseEther("0.1"), ethers.utils.parseEther("1000"), ); console.log(