Buyout SellStakes

This commit is contained in:
sascha3333 committed 2025-10-22 02:45:03 +02:00
1 parent 8178311084
commit 7ce2927464
3 files changed
+200 -72

No files matched your search

@@ -490,6 +490,30 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "contractOwnedSellStakes",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
@@ -1630,6 +1654,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "sellStakePremiumPercent",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
@@ -1687,29 +1724,6 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_token",
"type": "address"
},
{
"internalType": "uint256",
"name": "_lockTime",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_percentagePerStep",
"type": "uint256"
}
],
"name": "setUnlockScheduleByPercentage",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "testUpgradeFunction",
@@ -1880,6 +1894,19 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_newPremium",
"type": "uint256"
}
],
"name": "updateSellStakePremiumPercent",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
@@ -2141,8 +2168,8 @@
"type": "function"
}
],
"bytecode": "0x60806040523480156200001157600080fd5b506200001c62000022565b620000d6565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff1615620000735760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b0390811614620000d35780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b615bac80620000e66000396000f3fe608060405234801561001057600080fd5b506004361061036e5760003560e01c8062159da6146103735780630137451814610399578063022914a7146103cf5780630519da3214610402578063092c76101461040b5780630a84096a1461042b5780630a910a6d1461043e5780630c7d63861461044757806313baee5b14610451578063173825d9146104715780631764303d146104845780631aefa2d1146104975780631eb9e53e146104aa5780632ded58aa146104bd5780632e46fed8146104c65780633ba8396e146104ef5780633c92f98d146105125780633e4bc6bc146105345780633f35e7221461053d57806343a32f891461055057806343c7c011146105cb578063441a4175146105de57806348ea286d146105ff5780634a61f1e51461061257806351e624721461063257806351f6cf2f146106455780635811622714610666578063592d1dd11461067957806361d1080b1461069957806362cd6a09146106a157806363624c83146106b857806367a74ddc146106cb5780636ef569a5146106de5780637065cb48146106e757806375060a0b146106fa5780637a0c6dc01461071a5780637bc221ac1461073a5780637e6d99261461074d5780637ee612551461077657806380259e691461078957806380ca0ecf1461079c5780638129fc1c146107af57806382b75681146107b757806384e8520a146107ca578063853e0df2146107ea5780638939d787146107fd5780638f82818f14610806578063953d16bf1461082657806396fd111a146108395780639cb6f556146108595780639f3a676c1461086c578063a0d46758146108b8578063aaf4b04d146108d8578063ac97b417146108eb578063b6c3dc4c146108fe578063b92a349f1461091e578063bc0bc6ba14610931578063bd84477d14610951578063bed9757e146109b9578063c0c07d17146109da578063c2676603146109ed578063c32d3ae2146109f5578063c6b61e4c14610a28578063c7b530b014610a98578063cc573a9114610ab8578063ce13d09014610af4578063cfcf331914610b07578063d532bdfe14610b27578063da1b436414610b3a578063e88f8e6614610b5a578063eacdc5ff14610b6d578063eb44e0a314610b76578063ef5d9ae814610b89578063f2bb563014610ba9578063fe2f50d014610bbc578063fee6018c14610bc5578063ffecf51614610bd8575b600080fd5b610386610381366004615134565b610beb565b6040519081526020015b60405180910390f35b6103c26103a7366004615134565b6004602052600090815260409020546001600160a01b031681565b6040516103909190615156565b6103f26103dd366004615134565b60006020819052908152604090205460ff1681565b6040519015158152602001610390565b61038660075481565b610386610419366004615134565b60066020526000908152604090205481565b61038661043936600461516a565b610c85565b61038660125481565b61044f610dbd565b005b61038661045f366004615134565b600c6020526000908152604090205481565b61044f61047f366004615134565b610f83565b61044f6104923660046151d8565b611074565b61044f6104a5366004615219565b6112b2565b6103866104b8366004615134565b6112e6565b61038660115481565b6103866104d4366004615134565b6001600160a01b03166000908152601c602052604090205490565b6103f26104fd366004615134565b60016020526000908152604090205460ff1681565b6105256105203660046151d8565b61132a565b6040516103909392919061526d565b610386601d5481565b61044f61054b36600461516a565b61151b565b61059c61055e36600461516a565b60146020908152600092835260408084209091529082529020805460018201546002830154600390930154919290916001600160a01b039091169084565b604051610390949392919093845260208401929092526001600160a01b03166040830152606082015260800190565b61044f6105d9366004615134565b611590565b6105f16105ec366004615219565b6118fe565b6040516103909291906152a3565b61044f61060d366004615134565b611936565b610386610620366004615134565b60186020526000908152604090205481565b61044f610640366004615219565b611ac2565b61065861065336600461516a565b611af6565b6040516103909291906152bc565b61044f6106743660046152ca565b611b32565b610386610687366004615134565b60056020526000908152604090205481565b601b54610386565b6106a9611d9c565b60405161039093929190615318565b61044f6106c63660046153ba565b611fc3565b61044f6106d9366004615438565b6121b1565b61038660165481565b61044f6106f5366004615134565b61220e565b610386610708366004615134565b600a6020526000908152604090205481565b61072d610728366004615134565b6122e0565b604051610390919061546b565b610386610748366004615134565b6123c7565b61038661075b366004615134565b6001600160a01b031660009081526017602052604090205490565b61044f610784366004615519565b61259b565b61044f610797366004615219565b612725565b6103866107aa36600461516a565b612759565b61044f612865565b61044f6107c5366004615219565b612a48565b6103866107d8366004615134565b600d6020526000908152604090205481565b61044f6107f8366004615219565b612ada565b61038660135481565b610386610814366004615134565b60176020526000908152604090205481565b61044f610834366004615219565b612b58565b61084c6108473660046152ca565b612e3a565b6040516103909190615585565b61044f610867366004615219565b612fd9565b61087f61087a366004615219565b613268565b6040805196875260208701959095529385019290925260608401526001600160a01b0390811660808401521660a082015260c001610390565b6108cb6108c636600461516a565b6132bb565b604051610390919061Line truncated
"deployedBytecode": "0x608060405234801561001057600080fd5b506004361061036e5760003560e01c8062159da6146103735780630137451814610399578063022914a7146103cf5780630519da3214610402578063092c76101461040b5780630a84096a1461042b5780630a910a6d1461043e5780630c7d63861461044757806313baee5b14610451578063173825d9146104715780631764303d146104845780631aefa2d1146104975780631eb9e53e146104aa5780632ded58aa146104bd5780632e46fed8146104c65780633ba8396e146104ef5780633c92f98d146105125780633e4bc6bc146105345780633f35e7221461053d57806343a32f891461055057806343c7c011146105cb578063441a4175146105de57806348ea286d146105ff5780634a61f1e51461061257806351e624721461063257806351f6cf2f146106455780635811622714610666578063592d1dd11461067957806361d1080b1461069957806362cd6a09146106a157806363624c83146106b857806367a74ddc146106cb5780636ef569a5146106de5780637065cb48146106e757806375060a0b146106fa5780637a0c6dc01461071a5780637bc221ac1461073a5780637e6d99261461074d5780637ee612551461077657806380259e691461078957806380ca0ecf1461079c5780638129fc1c146107af57806382b75681146107b757806384e8520a146107ca578063853e0df2146107ea5780638939d787146107fd5780638f82818f14610806578063953d16bf1461082657806396fd111a146108395780639cb6f556146108595780639f3a676c1461086c578063a0d46758146108b8578063aaf4b04d146108d8578063ac97b417146108eb578063b6c3dc4c146108fe578063b92a349f1461091e578063bc0bc6ba14610931578063bd84477d14610951578063bed9757e146109b9578063c0c07d17146109da578063c2676603146109ed578063c32d3ae2146109f5578063c6b61e4c14610a28578063c7b530b014610a98578063cc573a9114610ab8578063ce13d09014610af4578063cfcf331914610b07578063d532bdfe14610b27578063da1b436414610b3a578063e88f8e6614610b5a578063eacdc5ff14610b6d578063eb44e0a314610b76578063ef5d9ae814610b89578063f2bb563014610ba9578063fe2f50d014610bbc578063fee6018c14610bc5578063ffecf51614610bd8575b600080fd5b610386610381366004615134565b610beb565b6040519081526020015b60405180910390f35b6103c26103a7366004615134565b6004602052600090815260409020546001600160a01b031681565b6040516103909190615156565b6103f26103dd366004615134565b60006020819052908152604090205460ff1681565b6040519015158152602001610390565b61038660075481565b610386610419366004615134565b60066020526000908152604090205481565b61038661043936600461516a565b610c85565b61038660125481565b61044f610dbd565b005b61038661045f366004615134565b600c6020526000908152604090205481565b61044f61047f366004615134565b610f83565b61044f6104923660046151d8565b611074565b61044f6104a5366004615219565b6112b2565b6103866104b8366004615134565b6112e6565b61038660115481565b6103866104d4366004615134565b6001600160a01b03166000908152601c602052604090205490565b6103f26104fd366004615134565b60016020526000908152604090205460ff1681565b6105256105203660046151d8565b61132a565b6040516103909392919061526d565b610386601d5481565b61044f61054b36600461516a565b61151b565b61059c61055e36600461516a565b60146020908152600092835260408084209091529082529020805460018201546002830154600390930154919290916001600160a01b039091169084565b604051610390949392919093845260208401929092526001600160a01b03166040830152606082015260800190565b61044f6105d9366004615134565b611590565b6105f16105ec366004615219565b6118fe565b6040516103909291906152a3565b61044f61060d366004615134565b611936565b610386610620366004615134565b60186020526000908152604090205481565b61044f610640366004615219565b611ac2565b61065861065336600461516a565b611af6565b6040516103909291906152bc565b61044f6106743660046152ca565b611b32565b610386610687366004615134565b60056020526000908152604090205481565b601b54610386565b6106a9611d9c565b60405161039093929190615318565b61044f6106c63660046153ba565b611fc3565b61044f6106d9366004615438565b6121b1565b61038660165481565b61044f6106f5366004615134565b61220e565b610386610708366004615134565b600a6020526000908152604090205481565b61072d610728366004615134565b6122e0565b604051610390919061546b565b610386610748366004615134565b6123c7565b61038661075b366004615134565b6001600160a01b031660009081526017602052604090205490565b61044f610784366004615519565b61259b565b61044f610797366004615219565b612725565b6103866107aa36600461516a565b612759565b61044f612865565b61044f6107c5366004615219565b612a48565b6103866107d8366004615134565b600d6020526000908152604090205481565b61044f6107f8366004615219565b612ada565b61038660135481565b610386610814366004615134565b60176020526000908152604090205481565b61044f610834366004615219565b612b58565b61084c6108473660046152ca565b612e3a565b6040516103909190615585565b61044f610867366004615219565b612fd9565b61087f61087a366004615219565b613268565b6040805196875260208701959095529385019290925260608401526001600160a01b0390811660808401521660a082015260c001610390565b6108cb6108c636600461516a565b6132bb565b60405161039091906155d3565b61044f6108e6366004615219565b61331f565b61044f6108f9366004615219565b6133a5565b61091161090c36600461516a565b613797565b604051610390919061560d565b61044f61092c36600461561b565b6138a9565b61094461093f366004615219565b613a4a565b604051610390919061564e565b61096461095f36600461516a565b613aee565b604080519a8b5260208b0199909952978901969096526060880194909452608087019290925260a086015260c08501526001600160a01b031660e08401521515610100830152610120820152610140016103Line truncated
"bytecode": "0x60806040523480156200001157600080fd5b506200001c62000022565b620000d6565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff1615620000735760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b0390811614620000d35780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b615ec580620000e66000396000f3fe608060405234801561001057600080fd5b50600436106103845760003560e01c8062159da61461038957806301374518146103af578063022914a7146103e55780630519da3214610418578063092c7610146104215780630a84096a146104415780630a910a6d146104545780630c7d63861461045d57806313baee5b14610467578063173825d9146104875780631764303d1461049a5780631aefa2d1146104ad5780631eb9e53e146104c05780632ded58aa146104d35780632e46fed8146104dc5780633ba8396e146105055780633c92f98d146105285780633e4bc6bc1461054a5780633f35e7221461055357806343a32f891461056657806343c7c011146105e1578063441a4175146105f457806348ea286d146106155780634a61f1e51461062857806351e624721461064857806351f6cf2f1461065b578063581162271461067c578063592d1dd11461068f57806361d1080b146106af57806362cd6a09146106b757806363624c83146106ce57806367a74ddc146106e15780636ef569a5146106f45780637065cb48146106fd57806375060a0b146107105780637a0c6dc0146107305780637bc221ac146107505780637e6d9926146107635780637ee612551461078c57806380259e691461079f57806380ca0ecf146107b25780638129fc1c146107c557806382b75681146107cd57806384e8520a146107e0578063853e0df2146108005780638939d787146108135780638f82818f1461081c578063953d16bf1461083c57806396fd111a1461084f5780639cb6f5561461086f5780639f3a676c14610882578063a0d46758146108ce578063aaf4b04d146108ee578063ac97b41714610901578063af8ee6be14610914578063b6c3dc4c1461093f578063bc0bc6ba1461095f578063bd84477d1461097f578063bed9757e146109e7578063c0c07d1714610a08578063c267660314610a1b578063c32d3ae214610a23578063c6b61e4c14610a56578063c7b530b014610ac6578063ca6c627c14610ae6578063cc573a9114610aef578063ce13d09014610b2b578063cfcf331914610b3e578063d532bdfe14610b5e578063da1b436414610b71578063dfe3cc7c14610b91578063e88f8e6614610ba4578063eacdc5ff14610bb7578063eb44e0a314610bc0578063ef5d9ae814610bd3578063f2bb563014610bf3578063fe2f50d014610c06578063fee6018c14610c0f578063ffecf51614610c22575b600080fd5b61039c61039736600461544f565b610c35565b6040519081526020015b60405180910390f35b6103d86103bd36600461544f565b6004602052600090815260409020546001600160a01b031681565b6040516103a69190615471565b6104086103f336600461544f565b60006020819052908152604090205460ff1681565b60405190151581526020016103a6565b61039c60075481565b61039c61042f36600461544f565b60066020526000908152604090205481565b61039c61044f366004615485565b610ccf565b61039c60125481565b610465610e07565b005b61039c61047536600461544f565b600c6020526000908152604090205481565b61046561049536600461544f565b610fcd565b6104656104a83660046154f3565b6110be565b6104656104bb366004615534565b6112fc565b61039c6104ce36600461544f565b611330565b61039c60115481565b61039c6104ea36600461544f565b6001600160a01b03166000908152601c602052604090205490565b61040861051336600461544f565b60016020526000908152604090205460ff1681565b61053b6105363660046154f3565b611374565b6040516103a693929190615588565b61039c601d5481565b610465610561366004615485565b611565565b6105b2610574366004615485565b60146020908152600092835260408084209091529082529020805460018201546002830154600390930154919290916001600160a01b039091169084565b6040516103a6949392919093845260208401929092526001600160a01b03166040830152606082015260800190565b6104656105ef36600461544f565b6115da565b610607610602366004615534565b611948565b6040516103a69291906155be565b61046561062336600461544f565b611980565b61039c61063636600461544f565b60186020526000908152604090205481565b610465610656366004615534565b611b0c565b61066e610669366004615485565b611b40565b6040516103a69291906155d7565b61046561068a3660046155e5565b611b7c565b61039c61069d36600461544f565b60056020526000908152604090205481565b601b5461039c565b6106bf611dc2565b6040516103a693929190615633565b6104656106dc3660046156d5565b611fe9565b6104656106ef366004615753565b6121d7565b61039c60165481565b61046561070b36600461544f565b612234565b61039c61071e36600461544f565b600a6020526000908152604090205481565b61074361073e36600461544f565b612306565b6040516103a69190615786565b61039c61075e36600461544f565b6123ed565b61039c61077136600461544f565b6001600160a01b031660009081526017602052604090205490565b61046561079a366004615834565b6125c1565b6104656107ad366004615534565b61274b565b61039c6107c0366004615485565b61277f565b61046561288b565b6104656107db366004615534565b612a74565b61039c6107ee36600461544f565b600d6020526000908152604090205481565b61046561080e366004615534565b612b06565b61039c60135481565b61039c61082a36600461544f565b60176020526000908152604090205481565b61046561084a366004615534565b612b84565b61086261085d3660046155e5565b612e54565b6040516103a691906158a0565b61046561087d366004615534565b612ff3565b610895610890366004615534565b613434565b6040805196875260208701959095529385019290925260608401526001600160a01b0390811660808401521660a082015260c0016103a6565b6108e16108dcLine truncated
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106103845760003560e01c8062159da61461038957806301374518146103af578063022914a7146103e55780630519da3214610418578063092c7610146104215780630a84096a146104415780630a910a6d146104545780630c7d63861461045d57806313baee5b14610467578063173825d9146104875780631764303d1461049a5780631aefa2d1146104ad5780631eb9e53e146104c05780632ded58aa146104d35780632e46fed8146104dc5780633ba8396e146105055780633c92f98d146105285780633e4bc6bc1461054a5780633f35e7221461055357806343a32f891461056657806343c7c011146105e1578063441a4175146105f457806348ea286d146106155780634a61f1e51461062857806351e624721461064857806351f6cf2f1461065b578063581162271461067c578063592d1dd11461068f57806361d1080b146106af57806362cd6a09146106b757806363624c83146106ce57806367a74ddc146106e15780636ef569a5146106f45780637065cb48146106fd57806375060a0b146107105780637a0c6dc0146107305780637bc221ac146107505780637e6d9926146107635780637ee612551461078c57806380259e691461079f57806380ca0ecf146107b25780638129fc1c146107c557806382b75681146107cd57806384e8520a146107e0578063853e0df2146108005780638939d787146108135780638f82818f1461081c578063953d16bf1461083c57806396fd111a1461084f5780639cb6f5561461086f5780639f3a676c14610882578063a0d46758146108ce578063aaf4b04d146108ee578063ac97b41714610901578063af8ee6be14610914578063b6c3dc4c1461093f578063bc0bc6ba1461095f578063bd84477d1461097f578063bed9757e146109e7578063c0c07d1714610a08578063c267660314610a1b578063c32d3ae214610a23578063c6b61e4c14610a56578063c7b530b014610ac6578063ca6c627c14610ae6578063cc573a9114610aef578063ce13d09014610b2b578063cfcf331914610b3e578063d532bdfe14610b5e578063da1b436414610b71578063dfe3cc7c14610b91578063e88f8e6614610ba4578063eacdc5ff14610bb7578063eb44e0a314610bc0578063ef5d9ae814610bd3578063f2bb563014610bf3578063fe2f50d014610c06578063fee6018c14610c0f578063ffecf51614610c22575b600080fd5b61039c61039736600461544f565b610c35565b6040519081526020015b60405180910390f35b6103d86103bd36600461544f565b6004602052600090815260409020546001600160a01b031681565b6040516103a69190615471565b6104086103f336600461544f565b60006020819052908152604090205460ff1681565b60405190151581526020016103a6565b61039c60075481565b61039c61042f36600461544f565b60066020526000908152604090205481565b61039c61044f366004615485565b610ccf565b61039c60125481565b610465610e07565b005b61039c61047536600461544f565b600c6020526000908152604090205481565b61046561049536600461544f565b610fcd565b6104656104a83660046154f3565b6110be565b6104656104bb366004615534565b6112fc565b61039c6104ce36600461544f565b611330565b61039c60115481565b61039c6104ea36600461544f565b6001600160a01b03166000908152601c602052604090205490565b61040861051336600461544f565b60016020526000908152604090205460ff1681565b61053b6105363660046154f3565b611374565b6040516103a693929190615588565b61039c601d5481565b610465610561366004615485565b611565565b6105b2610574366004615485565b60146020908152600092835260408084209091529082529020805460018201546002830154600390930154919290916001600160a01b039091169084565b6040516103a6949392919093845260208401929092526001600160a01b03166040830152606082015260800190565b6104656105ef36600461544f565b6115da565b610607610602366004615534565b611948565b6040516103a69291906155be565b61046561062336600461544f565b611980565b61039c61063636600461544f565b60186020526000908152604090205481565b610465610656366004615534565b611b0c565b61066e610669366004615485565b611b40565b6040516103a69291906155d7565b61046561068a3660046155e5565b611b7c565b61039c61069d36600461544f565b60056020526000908152604090205481565b601b5461039c565b6106bf611dc2565b6040516103a693929190615633565b6104656106dc3660046156d5565b611fe9565b6104656106ef366004615753565b6121d7565b61039c60165481565b61046561070b36600461544f565b612234565b61039c61071e36600461544f565b600a6020526000908152604090205481565b61074361073e36600461544f565b612306565b6040516103a69190615786565b61039c61075e36600461544f565b6123ed565b61039c61077136600461544f565b6001600160a01b031660009081526017602052604090205490565b61046561079a366004615834565b6125c1565b6104656107ad366004615534565b61274b565b61039c6107c0366004615485565b61277f565b61046561288b565b6104656107db366004615534565b612a74565b61039c6107ee36600461544f565b600d6020526000908152604090205481565b61046561080e366004615534565b612b06565b61039c60135481565b61039c61082a36600461544f565b60176020526000908152604090205481565b61046561084a366004615534565b612b84565b61086261085d3660046155e5565b612e54565b6040516103a691906158a0565b61046561087d366004615534565b612ff3565b610895610890366004615534565b613434565b6040805196875260208701959095529385019290925260608401526001600160a01b0390811660808401521660a082015260c0016103a6565b6108e16108dc366004615485565b613487565b6040516103a691906158ee565b6104656108fc366004615534565b6134eb565b61046561090f366004615534565b613571565b61039c610922366004615485565b601e60209081526000928352604080842090915290825290205481565b61095261094d366004615485565b613963565b6040516103a69190615928565b61097261096d366004615534565b613a75565b6040516103a69190615936565b61099261098d366004615485565b613b19565b604080519a8b5260208b0199909952978901969096526060880194909452608087019290Line truncated
"linkReferences": {},
"deployedLinkReferences": {}
}
+101 -33
View File
@@ -115,6 +115,8 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
MarketplaceHistory[] public marketplaceHistory; // Complete history of all transactions
mapping(address => uint256) public totalClaimed; // Track total amount claimed and sent to withdrawStakes per user
uint256 public highestRatio; // Track the highest TVL/liability ratio ever achieved (scaled by 10000)
mapping(address => mapping(uint256 => uint256)) public contractOwnedSellStakes; // Track contract-owned sellStakes linked to user withdrawStake IDs
uint256 public sellStakePremiumPercent; // Premium percentage for contract-owned sellStakes (e.g., 1000 = 10%)
// Events
event VestingClaimed(address indexed user, uint256 amount, uint256 bonus);
@@ -163,6 +165,7 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
unlockDelay = 60 * 60 * 72;
maxUnlockPercentage = 100; // 1% maximum unlock per epoch
sellStakePremiumPercent = 1000; // 10% premium for contract-owned sellStakes
}
// Ownership Management
@@ -212,40 +215,40 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
priceOracles[_token] = _oracle;
}
/// @notice Set unlock schedule for a token using percentage-based steps
/// @param _token The token address to set the schedule for
/// @param _lockTime The initial lock time in seconds
/// @param _percentagePerStep The percentage to unlock at each step (scaled by 10000)
function setUnlockScheduleByPercentage(address _token, uint256 _lockTime, uint256 _percentagePerStep) external onlyOwner {
require(_token != address(0), "Invalid token address");
require(_percentagePerStep > 0 && _percentagePerStep <= 10000, "Invalid percentage");
// /// @notice Set unlock schedule for a token using percentage-based steps
// /// @param _token The token address to set the schedule for
// /// @param _lockTime The initial lock time in seconds
// /// @param _percentagePerStep The percentage to unlock at each step (scaled by 10000)
// function setUnlockScheduleByPercentage(address _token, uint256 _lockTime, uint256 _percentagePerStep) external onlyOwner {
// require(_token != address(0), "Invalid token address");
// require(_percentagePerStep > 0 && _percentagePerStep <= 10000, "Invalid percentage");
// Clear existing schedule
delete unlockSchedules[_token];
// // Clear existing schedule
// delete unlockSchedules[_token];
uint256 totalPercentage = 0;
uint256 timeOffset = _lockTime;
// uint256 totalPercentage = 0;
// uint256 timeOffset = _lockTime;
// Create unlock steps until we reach 100%
while (totalPercentage < 10000) {
uint256 stepPercentage = _percentagePerStep;
// // Create unlock steps until we reach 100%
// while (totalPercentage < 10000) {
// uint256 stepPercentage = _percentagePerStep;
// Adjust last step to exactly reach 100%
if (totalPercentage + stepPercentage > 10000) {
stepPercentage = 10000 - totalPercentage;
}
// // Adjust last step to exactly reach 100%
// if (totalPercentage + stepPercentage > 10000) {
// stepPercentage = 10000 - totalPercentage;
// }
unlockSchedules[_token].push(UnlockStep({
timeOffset: timeOffset,
percentage: stepPercentage
}));
// unlockSchedules[_token].push(UnlockStep({
// timeOffset: timeOffset,
// percentage: stepPercentage
// }));
totalPercentage += stepPercentage;
timeOffset += _lockTime; // Each step adds the same time interval
}
// totalPercentage += stepPercentage;
// timeOffset += _lockTime; // Each step adds the same time interval
// }
emit UnlockScheduleSet(_token);
}
// emit UnlockScheduleSet(_token);
// }
// /// @notice Set custom unlock schedule for a token with specific steps
// /// @param _token The token address to set the schedule for
@@ -297,6 +300,13 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
instantBuyoutPercent = _newPercent;
}
/// @notice Update contract-owned sellStake premium percentage
/// @param _newPremium The premium percentage (scaled by 10000), ex: 1000 = 10%
function updateSellStakePremiumPercent(uint256 _newPremium) external onlyOwner {
require(_newPremium <= 5000, "Premium cannot exceed 50%");
sellStakePremiumPercent = _newPremium;
}
// Epoch-based Staking Functions
/// @notice Internal function to calculate unlock percentage based on ratio improvement vs historical high
@@ -441,6 +451,33 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
if (stake.stakeId == stakeId && stake.amount > 0) {
require(block.timestamp >= stake.unlockTime, "Stake locked");
// Check if there's a contract-owned sellStake linked to this withdrawStake
uint256 contractSellStakeId = contractOwnedSellStakes[msg.sender][stakeId];
if (contractSellStakeId > 0) {
SellStake storage contractSellStake = sellStakes[address(this)][contractSellStakeId];
if (contractSellStake.value > 0) {
uint256 sellValue = contractSellStake.value;
// Cancel the contract-owned sellStake (no fee)
pendingSellStakes[address(this)] -= sellValue;
delete sellStakes[address(this)][contractSellStakeId];
// Remove from keys array using swap-and-pop
uint256 keyIndex = sellStakeKeyIndex[address(this)][contractSellStakeId];
uint256 lastKeyIndex = sellStakeKeys.length - 1;
if (keyIndex != lastKeyIndex) {
SellStakeKey memory lastKey = sellStakeKeys[lastKeyIndex];
sellStakeKeys[keyIndex] = lastKey;
sellStakeKeyIndex[lastKey.seller][lastKey.stakeId] = keyIndex;
}
sellStakeKeys.pop();
delete sellStakeKeyIndex[address(this)][contractSellStakeId];
emit StakeSaleCancelled(address(this), contractSellStakeId);
}
delete contractOwnedSellStakes[msg.sender][stakeId];
}
uint256 amount = stake.amount;
address token = stake.token;
stake.amount = 0; // Mark as withdrawn
@@ -485,8 +522,9 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
// Create withdrawable stake with unlock delay (like claimUnlockedFunds)
stakeIdCounter++;
uint256 withdrawStakeId = stakeIdCounter;
withdrawStakes[msg.sender].push(WithdrawStake({
stakeId: stakeIdCounter,
stakeId: withdrawStakeId,
amount: payoutAmount,
unlockTime: block.timestamp + unlockDelay,
token: BSC_TOKEN
@@ -495,6 +533,29 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
// Increment withdraw liabilities for BSC_TOKEN
withdrawLiabilities[BSC_TOKEN] += payoutAmount;
// Create contract-owned sellStake at premium price
uint256 sellStakePrice = (payoutAmount * (10000 + sellStakePremiumPercent)) / 10000;
stakeIdCounter++;
uint256 sellStakeId = stakeIdCounter;
sellStakes[address(this)][sellStakeId] = SellStake({
value: amount, // Original amount - what buyer receives in stake
salePrice: sellStakePrice, // Premium price buyer pays
seller: address(this),
listTime: block.timestamp
});
pendingSellStakes[address(this)] += amount;
contractOwnedSellStakes[msg.sender][withdrawStakeId] = sellStakeId; // Link withdrawStake ID to sellStake ID
// Add to iteration keys
sellStakeKeys.push(SellStakeKey({
seller: address(this),
stakeId: sellStakeId
}));
sellStakeKeyIndex[address(this)][sellStakeId] = sellStakeKeys.length - 1;
emit StakeUpForSale(address(this), sellStakePrice, sellStakeId);
emit FundsClaimed(msg.sender, payoutAmount);
}
@@ -822,10 +883,17 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
userLastClaimedEpoch[msg.sender] = currentEpochId;
}
// Transfer stakes: remove from seller, add to buyer (minus protocol share)
userBigStake[seller] -= value;
userBigStake[msg.sender] += buyerStake;
pendingSellStakes[seller] -= value;
// Transfer stakes: handle contract seller differently
if (seller == address(this)) {
// Contract is seller - only add to buyer, don't deduct from contract
userBigStake[msg.sender] += buyerStake;
pendingSellStakes[address(this)] -= value;
} else {
// Normal seller flow - remove from seller, add to buyer (minus protocol share)
userBigStake[seller] -= value;
userBigStake[msg.sender] += buyerStake;
pendingSellStakes[seller] -= value;
}
// Increment buyer's original stake tracking (marketplace purchases count as original stake)
userOriginalStake[msg.sender] += buyerStake;
@@ -1383,7 +1451,7 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
/// @notice Test function for upgrade verification
/// @return Returns a constant value to verify upgrade worked
function testUpgradeFunction() external pure returns (uint256) {
return 1001; // Different value from bsc_paca to distinguish contracts
return 1003; // Different value from bsc_paca to distinguish contracts
}
}
+47 -14
View File
@@ -33,42 +33,75 @@ module.exports = {
url: "http://127.0.0.1:8545",
},
bscTestnet: {
url: "https://virtual.binance.eu.rpc.tenderly.co/77a9a30c-44ca-45e0-ae2a-9b5ddb41d20e",
url: "https://virtual.binance.eu.rpc.tenderly.co/fbd4f88f-4e4c-4894-a197-2272e3b3d197",
chainId: 1337,
accounts: env.PRIVATE_KEY ? [env.PRIVATE_KEY] : [],
},
anvil: {
url: "https://rpc.tacopancake.com",
url: "https://virtual.binance.eu.rpc.tenderly.co/7c672a28-191d-4bb0-9af8-5ae1e4464c5d",
chainId: 1337,
accounts: [
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", // Default Anvil account 0
accounts: env.PRIVATE_KEY ? [env.PRIVATE_KEY] : [
// "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", // Default Anvil account 0
],
allowUnlimitedContractSize: true,
},
buildbear: {
url: "https://rpc.buildbear.io/stale-bucky-0f42044d",
url: "https://rpc.buildbear.io/interim-warlock-36006e5c",
chainId: 31337,
accounts: env.PRIVATE_KEY ? [env.PRIVATE_KEY] : [],
},
basefork: {
url: "https://rpc.buildbear.io/yodelling-wong-30e77094",
chainId: 31337,
accounts: env.PRIVATE_KEY ? [env.PRIVATE_KEY] : [],
},
mainnet: {
url: env.MAINNET_RPC_URL || "https://bsc-dataseed1.binance.org",
chainId: 56,
accounts: env.PRIVATE_KEY ? [env.PRIVATE_KEY] : [],
},
base: {
url: env.BASE_RPC_URL || "https://base-mainnet.public.blastapi.io",
chainId: 8453,
accounts: env.PRIVATE_KEY ? [env.PRIVATE_KEY] : [],
},
sonic: {
url: env.SONIC_RPC_URL || "https://rpc.soniclabs.com",
chainId: 146,
accounts: env.PRIVATE_KEY ? [env.PRIVATE_KEY] : [],
},
},
etherscan: {
apiKey: {
bsc: env.BSCSCAN_API_KEY || "",
bscTestnet: env.BSCSCAN_API_KEY || "",
buildbear: "abc", // API key not needed for BuildBear
},
apiKey: "JRKR5T93RQTKVERUJ2NVE4T994TD66QGFH",
customChains: [
{
network: "buildbear",
chainId: 31337,
urls: {
apiURL: "https://rpc.buildbear.io/verify/etherscan/stale-bucky-0f42044d",
browserURL: "https://explorer.buildbear.io/stale-bucky-0f42044d"
apiURL: "https://rpc.buildbear.io/verify/etherscan/missing-darkphoenix-ad09c709",
browserURL: "https://explorer.buildbear.io/missing-darkphoenix-ad09c709"
}
},
{
network: "base",
chainId: 8453,
urls: {
apiURL: "https://api.basescan.org/api",
browserURL: "https://basescan.org"
}
},
{
network: "sonic",
chainId: 146,
urls: {
apiURL: "https://api.sonicscan.org/api",
browserURL: "https://sonicscan.org"
}
}
]
},
sourcify: {
enabled: true,
apiUrl: "https://rpc.buildbear.io/verify/sourcify/server/stale-bucky-0f42044d"
enabled: false,
apiUrl: "https://rpc.buildbear.io/verify/sourcify/server/missing-darkphoenix-ad09c709"
},
};