Multiple claims + usdc tracking in withdrawliabilities

This commit is contained in:
sascha3333 committed 2025-09-15 14:07:43 +02:00
1 parent 4f8f062f35
commit 8e0b6a58bd
2 files changed
+152 -125

No files matched your search

@@ -323,31 +323,6 @@
"name": "VestingClaimed", "name": "VestingClaimed",
"type": "event" "type": "event"
}, },
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "bonus",
"type": "uint256"
}
],
"name": "VestingCreated",
"type": "event"
},
{ {
"inputs": [ "inputs": [
{ {
@@ -490,9 +465,9 @@
{ {
"inputs": [ "inputs": [
{ {
"internalType": "uint256", "internalType": "uint256[]",
"name": "_vestingIndex", "name": "_vestingIndices",
"type": "uint256" "type": "uint256[]"
} }
], ],
"name": "claimBonus", "name": "claimBonus",
@@ -520,19 +495,6 @@
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{
"inputs": [
{
"internalType": "address",
"name": "user",
"type": "address"
}
],
"name": "clearVesting",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{ {
"inputs": [ "inputs": [
{ {
@@ -717,6 +679,11 @@
"name": "totalLiability", "name": "totalLiability",
"type": "uint256" "type": "uint256"
}, },
{
"internalType": "uint256",
"name": "paybackPercent",
"type": "uint256"
},
{ {
"internalType": "uint256", "internalType": "uint256",
"name": "unlockPercentage", "name": "unlockPercentage",
@@ -844,6 +811,11 @@
"name": "totalLiability", "name": "totalLiability",
"type": "uint256" "type": "uint256"
}, },
{
"internalType": "uint256",
"name": "paybackPercent",
"type": "uint256"
},
{ {
"internalType": "uint256", "internalType": "uint256",
"name": "unlockPercentage", "name": "unlockPercentage",
@@ -895,6 +867,11 @@
"name": "totalLiability", "name": "totalLiability",
"type": "uint256" "type": "uint256"
}, },
{
"internalType": "uint256",
"name": "paybackPercent",
"type": "uint256"
},
{ {
"internalType": "uint256", "internalType": "uint256",
"name": "unlockPercentage", "name": "unlockPercentage",
@@ -1514,6 +1491,25 @@
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "pendingSellStakes",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{ {
"inputs": [ "inputs": [
{ {
@@ -2033,6 +2029,25 @@
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "withdrawLiabilities",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{ {
"inputs": [ "inputs": [
{ {
@@ -2084,29 +2099,10 @@
], ],
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "withdrawVestingLiabilities",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
} }
], ],
"bytecode": "0x60806040523480156200001157600080fd5b506200001c62000022565b620000d6565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff1615620000735760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b0390811614620000d35780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b615f6c80620000e66000396000f3fe608060405234801561001057600080fd5b50600436106104325760003560e01c80638129fc1c11610236578063c26766031161013b578063d9193025116100c3578063ef5d9ae811610087578063ef5d9ae814610c0e578063f109208f14610c2e578063f2bb563014610c41578063fe2f50d014610c54578063ffecf51614610c5d57600080fd5b8063d919302514610bac578063da1b436414610bbf578063e88f8e6614610bdf578063eacdc5ff14610bf2578063eb44e0a314610bfb57600080fd5b8063cc573a911161010a578063cc573a9114610b17578063ce13d09014610b53578063ce3432c314610b66578063cfcf331914610b86578063d532bdfe14610b9957600080fd5b8063c267660314610a5c578063c32d3ae214610a64578063c6b61e4c14610a92578063c7b530b014610af757600080fd5b80639f3a676c116101be578063b6c3dc4c1161018d578063b6c3dc4c14610980578063b92a349f146109a0578063bc0bc6ba146109b3578063bd84477d146109d3578063bed9757e14610a3b57600080fd5b80639f3a676c146108ee578063a0d467581461093a578063aaf4b04d1461095a578063ac97b4171461096d57600080fd5b80638f82818f116102055780638f82818f146108755780639437e32e14610895578063953d16bf146108a857806396fd111a146108bb5780639cb6f556146108db57600080fd5b80638129fc1c14610827578063853e0df21461082f57806387b4b105146108425780638851ec0f1461086257600080fd5b806343c7c0111161033c57806362cd6a09116102c457806374d1c8e31161029357806374d1c8e3146107a55780637a0c6dc0146107b85780637bc221ac146107d85780637e6d9926146107eb57806380ca0ecf1461081457600080fd5b806362cd6a091461075f57806367a74ddc146107765780636ef569a5146107895780637065cb481461079257600080fd5b806351f6cf2f1161030b57806351f6cf2f146106e9578063549e61d3146107115780635811622714610724578063592d1dd11461073757806361d1080b1461075757600080fd5b806343c7c0111461067e578063441a41751461069157806348ea286d146106c357806351e62472146106d657600080fd5b8063173825d9116103bf5780632e46fed81161038e5780632e46fed8146105825780633ba8396e146105ab5780633c92f98d146105ce5780633f35e722146105f057806343a32f891461060357600080fd5b8063173825d9146105405780631aefa2d1146105535780631eb9e53e146105665780632ded58aa1461057957600080fd5b8063092c761011610406578063092c7610146104da5780630a84096a146104fa5780630a910a6d1461050d5780630c7d63861461051657806313baee5b1461052057600080fd5b8062159da614610437578063013745181461045d578063022914a71461049e5780630519da32146104d1575b600080fd5b61044a610445366004615689565b610c70565b6040519081526020015b60405180910390f35b61048661046b366004615689565b6004602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610454565b6104c16104ac366004615689565b60006020819052908152604090205460ff1681565b6040519015158152602001610454565b61044a60075481565b61044a6104e8366004615689565b60066020526000908152604090205481565b61044a6105083660046156ab565b610d06565b61044a60115481565b61051e610e3e565b005b61044a61052e366004615689565b600c6020526000908152604090205481565b61051e61054e366004615689565b610fff565b61051e6105613660046156d5565b6110f0565b61044a610574366004615689565b611124565b61044a60105481565b61044a610590366004615689565b6001600160a01b031660009081526019602052604090205490565b6104c16105b9366004615689565b60016020526000908152604090205460ff1681565b6105e16105dc366004615732565b61115b565b604051610454939291906157ae565b61051e6105fe3660046156ab565b611349565b61064f6106113660046156ab565b60126020908152600092835260408084209091529082529020805460018201546002830154600390930154919290916001600160a01b039091169084565b604051610454949392919093845260208401929092526001600160a01b03166040830152606082015260800190565b61051e61068c366004615689565b6113d0565b6106a461069f3660046156d5565b611759565b604080516001600160a01b039093168352602083019190915201610454565b61051e6106d1366004615689565b611791565b61051e6106e43660046156d5565b611921565b6106fc6106f73660046156ab565b611955565b60408051928352602083019190915201610454565b61051e61071f3660046157e4565b611991565b61051e61073236600461584f565b611c5a565b61044a610745366004615689565b60056020526000908152604090205481565b60185461044a565b610767611f4a565b60405161045493929190615871565b61051e61078436600461593a565b61219d565b61044a60145481565b61051e6107a0366004615689565b6121fa565b61051e6107b336600461596d565b6122cc565b6107cb6107c6366004615689565b6124af565b60405161045491906159d8565b61044a6107e6366004615689565b612596565b61044a6107f9366004615689565b6001600160a01b031660009081526015602052604090205490565b61044a6108223660046156ab565b612779565b61051e612885565b61051e61083d3660046156d5565b612aaa565b61044a610850366004615689565b600a6020526000908152604090205481565b61051e610870366004615a86565b612b46565b61044a610883366004615689565b60156020526000908152604090205481565b61051e6108a3366004615ab2565b612c79565b61051e6108b63660046156d5565b612cc0565b6108ce6108c936600461584f565b612faa565b604051610454Line truncated "bytecode": "0x60806040523480156200001157600080fd5b506200001c62000022565b620000d6565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff1615620000735760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b0390811614620000d35780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b615f7880620000e66000396000f3fe608060405234801561001057600080fd5b50600436106104325760003560e01c80637e6d992611610236578063bed9757e1161013b578063d532bdfe116100c3578063ef5d9ae811610087578063ef5d9ae814610c26578063f109208f14610c46578063f2bb563014610c59578063fe2f50d014610c6c578063ffecf51614610c7557600080fd5b8063d532bdfe14610bc4578063da1b436414610bd7578063e88f8e6614610bf7578063eacdc5ff14610c0a578063eb44e0a314610c1357600080fd5b8063c7b530b01161010a578063c7b530b014610b22578063cc573a9114610b42578063ce13d09014610b7e578063ce3432c314610b91578063cfcf331914610bb157600080fd5b8063bed9757e14610a5b578063c267660314610a7c578063c32d3ae214610a84578063c6b61e4c14610ab257600080fd5b80639cb6f556116101be578063ac97b4171161018d578063ac97b4171461098d578063b6c3dc4c146109a0578063b92a349f146109c0578063bc0bc6ba146109d3578063bd84477d146109f357600080fd5b80639cb6f556146108fb5780639f3a676c1461090e578063a0d467581461095a578063aaf4b04d1461097a57600080fd5b80638851ec0f116102055780638851ec0f146108825780638f82818f146108955780639437e32e146108b5578063953d16bf146108c857806396fd111a146108db57600080fd5b80637e6d99261461082b57806380ca0ecf146108545780638129fc1c14610867578063853e0df21461086f57600080fd5b806343a32f891161033c57806361d1080b116102c45780637065cb48116102935780637065cb48146107b257806374d1c8e3146107c557806375060a0b146107d85780637a0c6dc0146107f85780637bc221ac1461081857600080fd5b806361d1080b1461077757806362cd6a091461077f57806367a74ddc146107965780636ef569a5146107a957600080fd5b806351e624721161030b57806351e62472146106f657806351f6cf2f14610709578063549e61d3146107315780635811622714610744578063592d1dd11461075757600080fd5b806343a32f891461061657806343c7c01114610691578063441a4175146106a45780634a61f1e5146106d657600080fd5b8063173825d9116103bf5780632ded58aa1161038e5780632ded58aa1461058c5780632e46fed8146105955780633ba8396e146105be5780633c92f98d146105e15780633f35e7221461060357600080fd5b8063173825d9146105405780631764303d146105535780631aefa2d1146105665780631eb9e53e1461057957600080fd5b8063092c761011610406578063092c7610146104da5780630a84096a146104fa5780630a910a6d1461050d5780630c7d63861461051657806313baee5b1461052057600080fd5b8062159da614610437578063013745181461045d578063022914a71461049e5780630519da32146104d1575b600080fd5b61044a610445366004615681565b610c88565b6040519081526020015b60405180910390f35b61048661046b366004615681565b6004602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610454565b6104c16104ac366004615681565b60006020819052908152604090205460ff1681565b6040519015158152602001610454565b61044a60075481565b61044a6104e8366004615681565b60066020526000908152604090205481565b61044a6105083660046156a3565b610d1e565b61044a60115481565b61051e610e56565b005b61044a61052e366004615681565b600c6020526000908152604090205481565b61051e61054e366004615681565b611055565b61051e610561366004615711565b611146565b61051e610574366004615752565b6113b1565b61044a610587366004615681565b6113e5565b61044a60105481565b61044a6105a3366004615681565b6001600160a01b03166000908152601a602052604090205490565b6104c16105cc366004615681565b60016020526000908152604090205460ff1681565b6105f46105ef366004615711565b611452565b604051610454939291906157a6565b61051e6106113660046156a3565b611640565b6106626106243660046156a3565b60126020908152600092835260408084209091529082529020805460018201546002830154600390930154919290916001600160a01b039091169084565b604051610454949392919093845260208401929092526001600160a01b03166040830152606082015260800190565b61051e61069f366004615681565b6116c7565b6106b76106b2366004615752565b611a50565b604080516001600160a01b039093168352602083019190915201610454565b61044a6106e4366004615681565b60166020526000908152604090205481565b61051e610704366004615752565b611a88565b61071c6107173660046156a3565b611abc565b60408051928352602083019190915201610454565b61051e61073f3660046157dc565b611af8565b61051e610752366004615847565b611dc1565b61044a610765366004615681565b60056020526000908152604090205481565b60195461044a565b610787612098565b60405161045493929190615869565b61051e6107a4366004615932565b6122eb565b61044a60145481565b61051e6107c0366004615681565b612348565b61051e6107d3366004615965565b61241a565b61044a6107e6366004615681565b600a6020526000908152604090205481565b61080b610806366004615681565b6125fd565b60405161045491906159d0565b61044a610826366004615681565b6126e4565b61044a610839366004615681565b6001600160a01b031660009081526015602052604090205490565b61044a6108623660046156a3565b6128c7565b61051e6129d3565b61051e61087d366004615752565b612bf8565b61051e610890366004615a7e565b612c94565b61044a6108a3366004615681565b60156020526000908152604090205481565b61051e6108c3366004615aaa565b612dd5565b61051e6108d6366004615752Line truncated
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106104325760003560e01c80638129fc1c11610236578063c26766031161013b578063d9193025116100c3578063ef5d9ae811610087578063ef5d9ae814610c0e578063f109208f14610c2e578063f2bb563014610c41578063fe2f50d014610c54578063ffecf51614610c5d57600080fd5b8063d919302514610bac578063da1b436414610bbf578063e88f8e6614610bdf578063eacdc5ff14610bf2578063eb44e0a314610bfb57600080fd5b8063cc573a911161010a578063cc573a9114610b17578063ce13d09014610b53578063ce3432c314610b66578063cfcf331914610b86578063d532bdfe14610b9957600080fd5b8063c267660314610a5c578063c32d3ae214610a64578063c6b61e4c14610a92578063c7b530b014610af757600080fd5b80639f3a676c116101be578063b6c3dc4c1161018d578063b6c3dc4c14610980578063b92a349f146109a0578063bc0bc6ba146109b3578063bd84477d146109d3578063bed9757e14610a3b57600080fd5b80639f3a676c146108ee578063a0d467581461093a578063aaf4b04d1461095a578063ac97b4171461096d57600080fd5b80638f82818f116102055780638f82818f146108755780639437e32e14610895578063953d16bf146108a857806396fd111a146108bb5780639cb6f556146108db57600080fd5b80638129fc1c14610827578063853e0df21461082f57806387b4b105146108425780638851ec0f1461086257600080fd5b806343c7c0111161033c57806362cd6a09116102c457806374d1c8e31161029357806374d1c8e3146107a55780637a0c6dc0146107b85780637bc221ac146107d85780637e6d9926146107eb57806380ca0ecf1461081457600080fd5b806362cd6a091461075f57806367a74ddc146107765780636ef569a5146107895780637065cb481461079257600080fd5b806351f6cf2f1161030b57806351f6cf2f146106e9578063549e61d3146107115780635811622714610724578063592d1dd11461073757806361d1080b1461075757600080fd5b806343c7c0111461067e578063441a41751461069157806348ea286d146106c357806351e62472146106d657600080fd5b8063173825d9116103bf5780632e46fed81161038e5780632e46fed8146105825780633ba8396e146105ab5780633c92f98d146105ce5780633f35e722146105f057806343a32f891461060357600080fd5b8063173825d9146105405780631aefa2d1146105535780631eb9e53e146105665780632ded58aa1461057957600080fd5b8063092c761011610406578063092c7610146104da5780630a84096a146104fa5780630a910a6d1461050d5780630c7d63861461051657806313baee5b1461052057600080fd5b8062159da614610437578063013745181461045d578063022914a71461049e5780630519da32146104d1575b600080fd5b61044a610445366004615689565b610c70565b6040519081526020015b60405180910390f35b61048661046b366004615689565b6004602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610454565b6104c16104ac366004615689565b60006020819052908152604090205460ff1681565b6040519015158152602001610454565b61044a60075481565b61044a6104e8366004615689565b60066020526000908152604090205481565b61044a6105083660046156ab565b610d06565b61044a60115481565b61051e610e3e565b005b61044a61052e366004615689565b600c6020526000908152604090205481565b61051e61054e366004615689565b610fff565b61051e6105613660046156d5565b6110f0565b61044a610574366004615689565b611124565b61044a60105481565b61044a610590366004615689565b6001600160a01b031660009081526019602052604090205490565b6104c16105b9366004615689565b60016020526000908152604090205460ff1681565b6105e16105dc366004615732565b61115b565b604051610454939291906157ae565b61051e6105fe3660046156ab565b611349565b61064f6106113660046156ab565b60126020908152600092835260408084209091529082529020805460018201546002830154600390930154919290916001600160a01b039091169084565b604051610454949392919093845260208401929092526001600160a01b03166040830152606082015260800190565b61051e61068c366004615689565b6113d0565b6106a461069f3660046156d5565b611759565b604080516001600160a01b039093168352602083019190915201610454565b61051e6106d1366004615689565b611791565b61051e6106e43660046156d5565b611921565b6106fc6106f73660046156ab565b611955565b60408051928352602083019190915201610454565b61051e61071f3660046157e4565b611991565b61051e61073236600461584f565b611c5a565b61044a610745366004615689565b60056020526000908152604090205481565b60185461044a565b610767611f4a565b60405161045493929190615871565b61051e61078436600461593a565b61219d565b61044a60145481565b61051e6107a0366004615689565b6121fa565b61051e6107b336600461596d565b6122cc565b6107cb6107c6366004615689565b6124af565b60405161045491906159d8565b61044a6107e6366004615689565b612596565b61044a6107f9366004615689565b6001600160a01b031660009081526015602052604090205490565b61044a6108223660046156ab565b612779565b61051e612885565b61051e61083d3660046156d5565b612aaa565b61044a610850366004615689565b600a6020526000908152604090205481565b61051e610870366004615a86565b612b46565b61044a610883366004615689565b60156020526000908152604090205481565b61051e6108a3366004615ab2565b612c79565b61051e6108b63660046156d5565b612cc0565b6108ce6108c936600461584f565b612faa565b6040516104549190615b0a565b61051e6108e93660046156d5565b613169565b6109016108fc3660046156d5565b61341c565b6040805196875260208701959095529385019290925260608401526001600160a01b0390811660808401521660a082015260c001610454565b61094d6109483660046156ab565b61346f565b6040516104549190615b83565b61051e6109683660046156d5565b6134ff565b61051e61097b3660046156d5565b613585565b61099361098e3660046156ab565b613994565b6040516104549190615bb7565b61051e6109ae366004615beb565b613ac8565b6109c6Line truncated "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106104325760003560e01c80637e6d992611610236578063bed9757e1161013b578063d532bdfe116100c3578063ef5d9ae811610087578063ef5d9ae814610c26578063f109208f14610c46578063f2bb563014610c59578063fe2f50d014610c6c578063ffecf51614610c7557600080fd5b8063d532bdfe14610bc4578063da1b436414610bd7578063e88f8e6614610bf7578063eacdc5ff14610c0a578063eb44e0a314610c1357600080fd5b8063c7b530b01161010a578063c7b530b014610b22578063cc573a9114610b42578063ce13d09014610b7e578063ce3432c314610b91578063cfcf331914610bb157600080fd5b8063bed9757e14610a5b578063c267660314610a7c578063c32d3ae214610a84578063c6b61e4c14610ab257600080fd5b80639cb6f556116101be578063ac97b4171161018d578063ac97b4171461098d578063b6c3dc4c146109a0578063b92a349f146109c0578063bc0bc6ba146109d3578063bd84477d146109f357600080fd5b80639cb6f556146108fb5780639f3a676c1461090e578063a0d467581461095a578063aaf4b04d1461097a57600080fd5b80638851ec0f116102055780638851ec0f146108825780638f82818f146108955780639437e32e146108b5578063953d16bf146108c857806396fd111a146108db57600080fd5b80637e6d99261461082b57806380ca0ecf146108545780638129fc1c14610867578063853e0df21461086f57600080fd5b806343a32f891161033c57806361d1080b116102c45780637065cb48116102935780637065cb48146107b257806374d1c8e3146107c557806375060a0b146107d85780637a0c6dc0146107f85780637bc221ac1461081857600080fd5b806361d1080b1461077757806362cd6a091461077f57806367a74ddc146107965780636ef569a5146107a957600080fd5b806351e624721161030b57806351e62472146106f657806351f6cf2f14610709578063549e61d3146107315780635811622714610744578063592d1dd11461075757600080fd5b806343a32f891461061657806343c7c01114610691578063441a4175146106a45780634a61f1e5146106d657600080fd5b8063173825d9116103bf5780632ded58aa1161038e5780632ded58aa1461058c5780632e46fed8146105955780633ba8396e146105be5780633c92f98d146105e15780633f35e7221461060357600080fd5b8063173825d9146105405780631764303d146105535780631aefa2d1146105665780631eb9e53e1461057957600080fd5b8063092c761011610406578063092c7610146104da5780630a84096a146104fa5780630a910a6d1461050d5780630c7d63861461051657806313baee5b1461052057600080fd5b8062159da614610437578063013745181461045d578063022914a71461049e5780630519da32146104d1575b600080fd5b61044a610445366004615681565b610c88565b6040519081526020015b60405180910390f35b61048661046b366004615681565b6004602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610454565b6104c16104ac366004615681565b60006020819052908152604090205460ff1681565b6040519015158152602001610454565b61044a60075481565b61044a6104e8366004615681565b60066020526000908152604090205481565b61044a6105083660046156a3565b610d1e565b61044a60115481565b61051e610e56565b005b61044a61052e366004615681565b600c6020526000908152604090205481565b61051e61054e366004615681565b611055565b61051e610561366004615711565b611146565b61051e610574366004615752565b6113b1565b61044a610587366004615681565b6113e5565b61044a60105481565b61044a6105a3366004615681565b6001600160a01b03166000908152601a602052604090205490565b6104c16105cc366004615681565b60016020526000908152604090205460ff1681565b6105f46105ef366004615711565b611452565b604051610454939291906157a6565b61051e6106113660046156a3565b611640565b6106626106243660046156a3565b60126020908152600092835260408084209091529082529020805460018201546002830154600390930154919290916001600160a01b039091169084565b604051610454949392919093845260208401929092526001600160a01b03166040830152606082015260800190565b61051e61069f366004615681565b6116c7565b6106b76106b2366004615752565b611a50565b604080516001600160a01b039093168352602083019190915201610454565b61044a6106e4366004615681565b60166020526000908152604090205481565b61051e610704366004615752565b611a88565b61071c6107173660046156a3565b611abc565b60408051928352602083019190915201610454565b61051e61073f3660046157dc565b611af8565b61051e610752366004615847565b611dc1565b61044a610765366004615681565b60056020526000908152604090205481565b60195461044a565b610787612098565b60405161045493929190615869565b61051e6107a4366004615932565b6122eb565b61044a60145481565b61051e6107c0366004615681565b612348565b61051e6107d3366004615965565b61241a565b61044a6107e6366004615681565b600a6020526000908152604090205481565b61080b610806366004615681565b6125fd565b60405161045491906159d0565b61044a610826366004615681565b6126e4565b61044a610839366004615681565b6001600160a01b031660009081526015602052604090205490565b61044a6108623660046156a3565b6128c7565b61051e6129d3565b61051e61087d366004615752565b612bf8565b61051e610890366004615a7e565b612c94565b61044a6108a3366004615681565b60156020526000908152604090205481565b61051e6108c3366004615aaa565b612dd5565b61051e6108d6366004615752565b612e1c565b6108ee6108e9366004615847565b613122565b6040516104549190615b02565b61051e610909366004615752565b6132f2565b61092161091c366004615752565b6135e3565b6040805196875260208701959095529385019290925260608401526001600160a01b0390811660808401521660a082015260c001610454565b61096d6109683660046156a3565b613636565b6040516104549190615b85565b61051e610988366004615752565b6136c6565b61051e61099b366004615752565b61374c565b6109b36109ae3660046156a3565b613b5a565b604051Line truncated
"linkReferences": {}, "linkReferences": {},
"deployedLinkReferences": {} "deployedLinkReferences": {}
} }
+94 -63
View File
@@ -1,6 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
@@ -41,6 +40,7 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
uint256 estDaysRemaining; uint256 estDaysRemaining;
uint256 currentTreasuryTvl; uint256 currentTreasuryTvl;
uint256 totalLiability; // Snapshot of totalBigStakes at epoch end uint256 totalLiability; // Snapshot of totalBigStakes at epoch end
uint256 paybackPercent; // Payback percentage used for this epoch (scaled by 10000)
uint256 unlockPercentage; // Calculated unlock percentage (scaled by 10000) uint256 unlockPercentage; // Calculated unlock percentage (scaled by 10000)
uint256 timestamp; // When this epoch ended uint256 timestamp; // When this epoch ended
} }
@@ -90,8 +90,8 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
uint256 private stakeIdCounter; uint256 private stakeIdCounter;
uint256 private vestingStakeIdCounter; uint256 private vestingStakeIdCounter;
// Track total withdraw vesting liabilities by token address // Track total withdraw liabilities by token address (all tokens including BSC_TOKEN)
mapping(address => uint256) public withdrawVestingLiabilities; mapping(address => uint256) public withdrawLiabilities;
// Epoch-based staking variables // Epoch-based staking variables
mapping(uint256 => Epoch) public epochs; mapping(uint256 => Epoch) public epochs;
@@ -107,13 +107,13 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
uint256 public marketplaceMin; // Minimum value for listings (in USD, e.g., 25 * 1e18 = $25) uint256 public marketplaceMin; // Minimum value for listings (in USD, e.g., 25 * 1e18 = $25)
uint256 public cancellationFee; // Fee percentage for cancelling listings (e.g., 500 = 5%) uint256 public cancellationFee; // Fee percentage for cancelling listings (e.g., 500 = 5%)
mapping(address => uint256) public marketplace_sales; // Track total sales per user mapping(address => uint256) public marketplace_sales; // Track total sales per user
mapping(address => uint256) public pendingSellStakes; // Track total value of pending sell stakes per user
SellStakeKey[] public sellStakeKeys; // Array for iteration over active sell stakes SellStakeKey[] public sellStakeKeys; // Array for iteration over active sell stakes
mapping(address => mapping(uint256 => uint256)) private sellStakeKeyIndex; // Track position in keys array mapping(address => mapping(uint256 => uint256)) private sellStakeKeyIndex; // Track position in keys array
MarketplaceHistory[] public marketplaceHistory; // Complete history of all transactions MarketplaceHistory[] public marketplaceHistory; // Complete history of all transactions
mapping(address => uint256) public totalClaimed; // Track total amount claimed and sent to withdrawStakes per user mapping(address => uint256) public totalClaimed; // Track total amount claimed and sent to withdrawStakes per user
// Events // Events
event VestingCreated(address indexed user, uint256 amount, uint256 bonus);
event VestingClaimed(address indexed user, uint256 amount, uint256 bonus); event VestingClaimed(address indexed user, uint256 amount, uint256 bonus);
event BonusClaimed(address indexed user, uint256 bonus); event BonusClaimed(address indexed user, uint256 bonus);
event UnlockScheduleSet(address indexed token); event UnlockScheduleSet(address indexed token);
@@ -343,6 +343,7 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
estDaysRemaining: estDaysRemaining, estDaysRemaining: estDaysRemaining,
currentTreasuryTvl: currentTreasuryTvl, currentTreasuryTvl: currentTreasuryTvl,
totalLiability: totalBigStakes, totalLiability: totalBigStakes,
paybackPercent: _paybackPercent,
unlockPercentage: unlockPercentage, unlockPercentage: unlockPercentage,
timestamp: block.timestamp timestamp: block.timestamp
}); });
@@ -366,11 +367,13 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
return totalUnclaimed; return totalUnclaimed;
} }
/// @notice Get user's net stake (big stake minus unclaimed funds) /// @notice Get user's net stake (big stake minus unclaimed funds minus pending sell stakes)
function getNetStake(address user) public view returns (uint256) { function getNetStake(address user) public view returns (uint256) {
uint256 bigStake = userBigStake[user]; uint256 bigStake = userBigStake[user];
uint256 unclaimed = calculateUnclaimedFunds(user); uint256 unclaimed = calculateUnclaimedFunds(user);
return bigStake - unclaimed; uint256 pending = pendingSellStakes[user];
uint256 committed = unclaimed + pending;
return bigStake > committed ? bigStake - committed : 0;
} }
/// @notice Get comprehensive user stake information /// @notice Get comprehensive user stake information
@@ -411,6 +414,9 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
token: BSC_TOKEN token: BSC_TOKEN
})); }));
// Increment withdraw liabilities for BSC_TOKEN
withdrawLiabilities[BSC_TOKEN] += unclaimedAmount;
emit FundsClaimed(msg.sender, unclaimedAmount); emit FundsClaimed(msg.sender, unclaimedAmount);
} }
@@ -433,10 +439,8 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
address token = stake.token; address token = stake.token;
stake.amount = 0; // Mark as withdrawn stake.amount = 0; // Mark as withdrawn
// Decrement withdraw vesting liabilities for non-BSC tokens // Decrement withdraw liabilities for all tokens
if (token != BSC_TOKEN) { withdrawLiabilities[token] -= amount;
withdrawVestingLiabilities[token] -= amount;
}
// Transfer tokens to user based on the specified token // Transfer tokens to user based on the specified token
IERC20(token).safeTransfer(msg.sender, amount); IERC20(token).safeTransfer(msg.sender, amount);
@@ -482,6 +486,9 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
token: BSC_TOKEN token: BSC_TOKEN
})); }));
// Increment withdraw liabilities for BSC_TOKEN
withdrawLiabilities[BSC_TOKEN] += payoutAmount;
emit FundsClaimed(msg.sender, payoutAmount); emit FundsClaimed(msg.sender, payoutAmount);
} }
@@ -622,9 +629,8 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
stakeIdCounter++; stakeIdCounter++;
uint256 stakeId = stakeIdCounter; uint256 stakeId = stakeIdCounter;
// Deduct value from user's big stake immediately // Add to pending sell stakes tracking (don't touch actual bigStake until sale/cancel)
userBigStake[msg.sender] -= value; pendingSellStakes[msg.sender] += value;
totalBigStakes -= value;
// Create the sellStake entry // Create the sellStake entry
sellStakes[msg.sender][stakeId] = SellStake({ sellStakes[msg.sender][stakeId] = SellStake({
@@ -653,14 +659,16 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
uint256 value = sellStakeEntry.value; uint256 value = sellStakeEntry.value;
// Calculate cancellation fee // Calculate cancellation fee and apply directly to userBigStake
uint256 fee = (value * cancellationFee) / 10000; uint256 fee = (value * cancellationFee) / 10000;
uint256 valueAfterFee = value - fee;
// Restore value minus fee to user's big stake // Remove from pending and apply fee directly to bigStake
userBigStake[msg.sender] += valueAfterFee; pendingSellStakes[msg.sender] -= value;
totalBigStakes += valueAfterFee; if (fee > 0) {
// Note: fee reduces total liability (not added back to totalBigStakes) userBigStake[msg.sender] -= fee;
totalBigStakes -= fee;
}
// Note: fee reduces total liability permanently
// Emit fee event // Emit fee event
if (fee > 0) { if (fee > 0) {
@@ -720,10 +728,12 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
// Transfer payment from buyer to seller (direct transfer) // Transfer payment from buyer to seller (direct transfer)
IERC20(BSC_TOKEN).safeTransferFrom(msg.sender, seller, salePrice); IERC20(BSC_TOKEN).safeTransferFrom(msg.sender, seller, salePrice);
// Add buyerStake to buyer's big stake (value - protocol share) // Transfer stakes: remove from seller, add to buyer (minus protocol share)
userBigStake[seller] -= value;
userBigStake[msg.sender] += buyerStake; userBigStake[msg.sender] += buyerStake;
totalBigStakes += buyerStake; pendingSellStakes[seller] -= value;
// Note: protocolShare reduces total liability (not added back to totalBigStakes) // Note: totalBigStakes decreases by protocolShare (value - buyerStake)
totalBigStakes -= (value - buyerStake);
// Track marketplace sales for seller // Track marketplace sales for seller
marketplace_sales[seller] += salePrice; marketplace_sales[seller] += salePrice;
@@ -759,27 +769,27 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
/// @notice This function will end and clear a user's vestings. /// @notice This function will end and clear a user's vestings.
/// @dev Only to be used by bots in emergencies /// @dev Only to be used by bots in emergencies
/// @param user The user whose vestings will be ended and 0'd /// @param user The user whose vestings will be ended and 0'd
function clearVesting(address user) external onlyBot { // function clearVesting(address user) external onlyBot {
for (uint256 i = 0; i < vestings[user].length; ++i) { // for (uint256 i = 0; i < vestings[user].length; ++i) {
Vesting storage vesting = vestings[user][i]; // Vesting storage vesting = vestings[user][i];
// Decrement accounting variables before clearing // // Decrement accounting variables before clearing
if (!vesting.complete) { // if (!vesting.complete) {
if (dollarsVested[user] >= vesting.usdAmount) { // if (dollarsVested[user] >= vesting.usdAmount) {
dollarsVested[user] -= vesting.usdAmount; // dollarsVested[user] -= vesting.usdAmount;
} // }
if (vestedTotal[vesting.token] >= vesting.amount) { // if (vestedTotal[vesting.token] >= vesting.amount) {
vestedTotal[vesting.token] -= vesting.amount; // vestedTotal[vesting.token] -= vesting.amount;
} // }
} // }
vesting.amount = 0; // vesting.amount = 0;
vesting.bonus = 0; // vesting.bonus = 0;
vesting.claimedAmount = 0; // vesting.claimedAmount = 0;
vesting.claimedBonus = 0; // vesting.claimedBonus = 0;
vesting.complete = true; // vesting.complete = true;
} // }
} // }
/// @notice Creates a vesting for a given user /// @notice Creates a vesting for a given user
/// @dev Only to be used by bots for manual vesting creation /// @dev Only to be used by bots for manual vesting creation
@@ -1025,8 +1035,8 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
token: vesting.token token: vesting.token
})); }));
// Increment withdraw vesting liabilities for this token // Increment withdraw liabilities for this token
withdrawVestingLiabilities[vesting.token] += amountToClaim; withdrawLiabilities[vesting.token] += amountToClaim;
emit VestingClaimed(msg.sender, amountToClaim, 0); emit VestingClaimed(msg.sender, amountToClaim, 0);
} }
@@ -1073,35 +1083,56 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
token: _token token: _token
})); }));
// Increment withdraw vesting liabilities for this token // Increment withdraw liabilities for this token
withdrawVestingLiabilities[_token] += totalReward; withdrawLiabilities[_token] += totalReward;
emit VestingClaimed(msg.sender, totalReward, 0); emit VestingClaimed(msg.sender, totalReward, 0);
} }
/// @notice Claim unlocked bonus tokens from a specific vesting /// @notice Claim unlocked bonus tokens from multiple vestings
/// @param _vestingIndex The index of the vesting to claim bonus from /// @param _vestingIndices Array of vesting indices to claim bonus from
function claimBonus(uint256 _vestingIndex) external nonReentrant { function claimBonus(uint256[] calldata _vestingIndices) external nonReentrant {
require(_vestingIndex < vestings[msg.sender].length, "Invalid vesting index"); uint256 totalBonusClaimed = 0;
Vesting storage vesting = vestings[msg.sender][_vestingIndex]; for (uint256 i = 0; i < _vestingIndices.length; i++) {
uint256 maxBonus = getUnlockedVestingBonus(msg.sender, _vestingIndex); uint256 _vestingIndex = _vestingIndices[i];
require(maxBonus >= vesting.claimedBonus, "Invalid claim amount"); // Skip invalid vesting indices
uint256 bonusToClaim = maxBonus - vesting.claimedBonus; if (_vestingIndex >= vestings[msg.sender].length) {
require(bonusToClaim > 0, "Nothing to claim"); continue;
}
vesting.claimedBonus += bonusToClaim; Vesting storage vesting = vestings[msg.sender][_vestingIndex];
uint256 maxBonus = getUnlockedVestingBonus(msg.sender, _vestingIndex);
// Create withdrawable stake with unlock delay (add 1e6 to distinguish from normal stakes) // Skip if invalid claim amount or nothing to claim
withdrawStakes[msg.sender].push(WithdrawStake({ if (maxBonus < vesting.claimedBonus) {
stakeId: _vestingIndex + 1e6, continue;
amount: bonusToClaim, }
unlockTime: block.timestamp + unlockDelay,
token: BSC_TOKEN
}));
emit BonusClaimed(msg.sender, bonusToClaim); uint256 bonusToClaim = maxBonus - vesting.claimedBonus;
if (bonusToClaim == 0) {
continue;
}
vesting.claimedBonus += bonusToClaim;
totalBonusClaimed += bonusToClaim;
// Create withdrawable stake with unlock delay (add 1e6 to distinguish from normal stakes)
withdrawStakes[msg.sender].push(WithdrawStake({
stakeId: _vestingIndex + 1e6,
amount: bonusToClaim,
unlockTime: block.timestamp + unlockDelay,
token: BSC_TOKEN
}));
}
// Only update liabilities and emit event if something was actually claimed
if (totalBonusClaimed > 0) {
// Increment withdraw liabilities for BSC_TOKEN
withdrawLiabilities[BSC_TOKEN] += totalBonusClaimed;
emit BonusClaimed(msg.sender, totalBonusClaimed);
}
} }