Highest Ratio Change

This commit is contained in:
sascha3333 committed 2025-09-27 23:40:28 +02:00
1 parent c329181447
commit f6e338e287
2 files changed
+76 -83

No files matched your search

@@ -1388,6 +1388,19 @@
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{
"inputs": [],
"name": "highestRatio",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{ {
"inputs": [], "inputs": [],
"name": "initialize", "name": "initialize",
@@ -1580,57 +1593,6 @@
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{
"inputs": [
{
"internalType": "address",
"name": "targetAddress",
"type": "address"
}
],
"name": "searchMarketplaceHistory",
"outputs": [
{
"components": [
{
"internalType": "uint256",
"name": "listTime",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "saleTime",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "origValue",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "saleValue",
"type": "uint256"
},
{
"internalType": "address",
"name": "seller",
"type": "address"
},
{
"internalType": "address",
"name": "buyer",
"type": "address"
}
],
"internalType": "struct CunaFinanceBsc.MarketplaceHistory[]",
"name": "",
"type": "tuple[]"
}
],
"stateMutability": "view",
"type": "function"
},
{ {
"inputs": [ "inputs": [
{ {
@@ -1853,6 +1815,19 @@
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{
"inputs": [
{
"internalType": "uint256",
"name": "_highestRatio",
"type": "uint256"
}
],
"name": "updateHighestRatio",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{ {
"inputs": [ "inputs": [
{ {
@@ -2171,8 +2146,8 @@
"type": "function" "type": "function"
} }
], ],
"bytecode": "0x60806040523480156200001157600080fd5b506200001c62000022565b620000d6565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff1615620000735760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b0390811614620000d35780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b615fc280620000e66000396000f3fe608060405234801561001057600080fd5b50600436106103635760003560e01c8062159da614610368578063013745181461038e578063022914a7146103c45780630519da32146103f7578063092c7610146104005780630a84096a146104205780630a910a6d146104335780630c7d63861461043c57806313baee5b14610446578063173825d9146104665780631764303d146104795780631aefa2d11461048c5780631eb9e53e1461049f5780632ded58aa146104b25780632e46fed8146104bb5780633ba8396e146104e45780633c92f98d146105075780633f35e7221461052957806343a32f891461053c57806343c7c011146105b7578063441a4175146105ca5780634a61f1e5146105eb57806351e624721461060b57806351f6cf2f1461061e578063549e61d31461063f5780635811622714610652578063592d1dd11461066557806361d1080b1461068557806362cd6a091461068d57806367a74ddc146106a45780636ef569a5146106b75780637065cb48146106c057806374d1c8e3146106d357806375060a0b146106e65780637a0c6dc0146107065780637bc221ac146107265780637e6d99261461073957806380ca0ecf146107625780638129fc1c1461077557806382b756811461077d57806384e8520a14610790578063853e0df2146107b05780638939d787146107c35780638f82818f146107cc5780639437e32e146107ec578063953d16bf146107ff57806396fd111a146108125780639cb6f556146108325780639f3a676c14610845578063a0d4675814610891578063aaf4b04d146108b1578063ac97b417146108c4578063b6c3dc4c146108d7578063b92a349f146108f7578063bc0bc6ba1461090a578063bd84477d1461092a578063bed9757e14610992578063c0c07d17146109b3578063c2676603146109c6578063c32d3ae2146109ce578063c6b61e4c14610a01578063c7b530b014610a71578063cc573a9114610a91578063ce13d09014610acd578063ce3432c314610ae0578063cfcf331914610b00578063d532bdfe14610b13578063da1b436414610b26578063e88f8e6614610b46578063eacdc5ff14610b59578063eb44e0a314610b62578063ef5d9ae814610b75578063f2bb563014610b95578063fe2f50d014610ba8578063fee6018c14610bb1578063ffecf51614610bc4575b600080fd5b61037b610376366004615500565b610bd7565b6040519081526020015b60405180910390f35b6103b761039c366004615500565b6004602052600090815260409020546001600160a01b031681565b6040516103859190615522565b6103e76103d2366004615500565b60006020819052908152604090205460ff1681565b6040519015158152602001610385565b61037b60075481565b61037b61040e366004615500565b60066020526000908152604090205481565b61037b61042e366004615536565b610c71565b61037b60125481565b610444610da9565b005b61037b610454366004615500565b600c6020526000908152604090205481565b610444610474366004615500565b610f6f565b6104446104873660046155a4565b611060565b61044461049a3660046155e5565b61129e565b61037b6104ad366004615500565b6112d2565b61037b60115481565b61037b6104c9366004615500565b6001600160a01b03166000908152601c602052604090205490565b6103e76104f2366004615500565b60016020526000908152604090205460ff1681565b61051a6105153660046155a4565b611316565b60405161038593929190615639565b610444610537366004615536565b611507565b61058861054a366004615536565b60146020908152600092835260408084209091529082529020805460018201546002830154600390930154919290916001600160a01b039091169084565b604051610385949392919093845260208401929092526001600160a01b03166040830152606082015260800190565b6104446105c5366004615500565b61157c565b6105dd6105d83660046155e5565b6118ea565b60405161038592919061566f565b61037b6105f9366004615500565b60186020526000908152604090205481565b6104446106193660046155e5565b611922565b61063161062c366004615536565b611956565b604051610385929190615688565b61044461064d366004615696565b611992565b610444610660366004615701565b611cff565b61037b610673366004615500565b60056020526000908152604090205481565b601b5461037b565b610695611f69565b6040516103859392919061574f565b6104446106b23660046157f1565b612190565b61037b60165481565b6104446106ce366004615500565b6121ed565b6104446106e1366004615824565b6122bf565b61037b6106f4366004615500565b600a6020526000908152604090205481565b610719610714366004615500565b6124a2565b604051610385919061588f565b61037b610734366004615500565b612589565b61037b610747366004615500565b6001600160a01b031660009081526017602052604090205490565b61037b610770366004615536565b61275d565b610444612869565b61044461078b3660046155e5565b612a91565b61037b61079e366004615500565b600d6020526000908152604090205481565b6104446107be3660046155e5565b612b23565b61037b60135481565b61037b6107da366004615500565b60176020526000908152604090205481565b6104446107fa36600461593d565b612ba1565b61044461080d3660046155e5565b612be8565b610825610820366004615701565b612ed6565b60405161038591906159cf565b6104446108403660046155e5565b613075565b6108586108533660046155e5565b613304565b6040805196875260208701959095529385019290925260608401526001600160a01b0390811660808401521660a082015260c001610385565b6108a461089f366004615536565b613357565b6040516103859190615a1d565b6104446108bf3660046155e5565b6133bb565b6104446108d23660046155e5565b6134Line truncated "bytecode": "0x60806040523480156200001157600080fd5b506200001c62000022565b620000d6565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff1615620000735760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b0390811614620000d35780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b615d8480620000e66000396000f3fe608060405234801561001057600080fd5b506004361061036e5760003560e01c8062159da6146103735780630137451814610399578063022914a7146103cf5780630519da3214610402578063092c76101461040b5780630a84096a1461042b5780630a910a6d1461043e5780630c7d63861461044757806313baee5b14610451578063173825d9146104715780631764303d146104845780631aefa2d1146104975780631eb9e53e146104aa5780632ded58aa146104bd5780632e46fed8146104c65780633ba8396e146104ef5780633c92f98d146105125780633e4bc6bc146105345780633f35e7221461053d57806343a32f891461055057806343c7c011146105cb578063441a4175146105de5780634a61f1e5146105ff57806351e624721461061f57806351f6cf2f14610632578063549e61d3146106535780635811622714610666578063592d1dd11461067957806361d1080b1461069957806362cd6a09146106a157806367a74ddc146106b85780636ef569a5146106cb5780637065cb48146106d457806374d1c8e3146106e757806375060a0b146106fa5780637a0c6dc01461071a5780637bc221ac1461073a5780637e6d99261461074d57806380259e691461077657806380ca0ecf146107895780638129fc1c1461079c57806382b75681146107a457806384e8520a146107b7578063853e0df2146107d75780638939d787146107ea5780638f82818f146107f35780639437e32e14610813578063953d16bf1461082657806396fd111a146108395780639cb6f556146108595780639f3a676c1461086c578063a0d46758146108b8578063aaf4b04d146108d8578063ac97b417146108eb578063b6c3dc4c146108fe578063b92a349f1461091e578063bc0bc6ba14610931578063bd84477d14610951578063bed9757e146109b9578063c0c07d17146109da578063c2676603146109ed578063c32d3ae2146109f5578063c6b61e4c14610a28578063c7b530b014610a98578063cc573a9114610ab8578063ce13d09014610af4578063cfcf331914610b07578063d532bdfe14610b27578063da1b436414610b3a578063e88f8e6614610b5a578063eacdc5ff14610b6d578063eb44e0a314610b76578063ef5d9ae814610b89578063f2bb563014610ba9578063fe2f50d014610bbc578063fee6018c14610bc5578063ffecf51614610bd8575b600080fd5b6103866103813660046152c2565b610beb565b6040519081526020015b60405180910390f35b6103c26103a73660046152c2565b6004602052600090815260409020546001600160a01b031681565b60405161039091906152e4565b6103f26103dd3660046152c2565b60006020819052908152604090205460ff1681565b6040519015158152602001610390565b61038660075481565b6103866104193660046152c2565b60066020526000908152604090205481565b6103866104393660046152f8565b610c85565b61038660125481565b61044f610dbd565b005b61038661045f3660046152c2565b600c6020526000908152604090205481565b61044f61047f3660046152c2565b610f83565b61044f610492366004615366565b611074565b61044f6104a53660046153a7565b6112b2565b6103866104b83660046152c2565b6112e6565b61038660115481565b6103866104d43660046152c2565b6001600160a01b03166000908152601c602052604090205490565b6103f26104fd3660046152c2565b60016020526000908152604090205460ff1681565b610525610520366004615366565b61132a565b604051610390939291906153fb565b610386601d5481565b61044f61054b3660046152f8565b61151b565b61059c61055e3660046152f8565b60146020908152600092835260408084209091529082529020805460018201546002830154600390930154919290916001600160a01b039091169084565b604051610390949392919093845260208401929092526001600160a01b03166040830152606082015260800190565b61044f6105d93660046152c2565b611590565b6105f16105ec3660046153a7565b6118fe565b604051610390929190615431565b61038661060d3660046152c2565b60186020526000908152604090205481565b61044f61062d3660046153a7565b611936565b6106456106403660046152f8565b61196a565b60405161039092919061544a565b61044f610661366004615458565b6119a6565b61044f6106743660046154c3565b611d13565b6103866106873660046152c2565b60056020526000908152604090205481565b601b54610386565b6106a9611f7d565b60405161039093929190615511565b61044f6106c63660046155b3565b6121a4565b61038660165481565b61044f6106e23660046152c2565b612201565b61044f6106f53660046155e6565b6122d3565b6103866107083660046152c2565b600a6020526000908152604090205481565b61072d6107283660046152c2565b6124b6565b6040516103909190615651565b6103866107483660046152c2565b61259d565b61038661075b3660046152c2565b6001600160a01b031660009081526017602052604090205490565b61044f6107843660046153a7565b612771565b6103866107973660046152f8565b6127a5565b61044f6128b1565b61044f6107b23660046153a7565b612ad9565b6103866107c53660046152c2565b600d6020526000908152604090205481565b61044f6107e53660046153a7565b612b6b565b61038660135481565b6103866108013660046152c2565b60176020526000908152604090205481565b61044f6108213660046156ff565b612be9565b61044f6108343660046153a7565b612c30565b61084c6108473660046154c3565b612f1e565b6040516103909190615791565b61044f6108673660046153a7565b6130bd565b61087f61087a3660046153a7565b61334c565b6040805196875260208701959095529385019290925260608401526001600160a01b0390811660808401521660a082015260c001610390565b6108cb6108c63660046152f8565b61339f565b604051610390919061Line truncated
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106103635760003560e01c8062159da614610368578063013745181461038e578063022914a7146103c45780630519da32146103f7578063092c7610146104005780630a84096a146104205780630a910a6d146104335780630c7d63861461043c57806313baee5b14610446578063173825d9146104665780631764303d146104795780631aefa2d11461048c5780631eb9e53e1461049f5780632ded58aa146104b25780632e46fed8146104bb5780633ba8396e146104e45780633c92f98d146105075780633f35e7221461052957806343a32f891461053c57806343c7c011146105b7578063441a4175146105ca5780634a61f1e5146105eb57806351e624721461060b57806351f6cf2f1461061e578063549e61d31461063f5780635811622714610652578063592d1dd11461066557806361d1080b1461068557806362cd6a091461068d57806367a74ddc146106a45780636ef569a5146106b75780637065cb48146106c057806374d1c8e3146106d357806375060a0b146106e65780637a0c6dc0146107065780637bc221ac146107265780637e6d99261461073957806380ca0ecf146107625780638129fc1c1461077557806382b756811461077d57806384e8520a14610790578063853e0df2146107b05780638939d787146107c35780638f82818f146107cc5780639437e32e146107ec578063953d16bf146107ff57806396fd111a146108125780639cb6f556146108325780639f3a676c14610845578063a0d4675814610891578063aaf4b04d146108b1578063ac97b417146108c4578063b6c3dc4c146108d7578063b92a349f146108f7578063bc0bc6ba1461090a578063bd84477d1461092a578063bed9757e14610992578063c0c07d17146109b3578063c2676603146109c6578063c32d3ae2146109ce578063c6b61e4c14610a01578063c7b530b014610a71578063cc573a9114610a91578063ce13d09014610acd578063ce3432c314610ae0578063cfcf331914610b00578063d532bdfe14610b13578063da1b436414610b26578063e88f8e6614610b46578063eacdc5ff14610b59578063eb44e0a314610b62578063ef5d9ae814610b75578063f2bb563014610b95578063fe2f50d014610ba8578063fee6018c14610bb1578063ffecf51614610bc4575b600080fd5b61037b610376366004615500565b610bd7565b6040519081526020015b60405180910390f35b6103b761039c366004615500565b6004602052600090815260409020546001600160a01b031681565b6040516103859190615522565b6103e76103d2366004615500565b60006020819052908152604090205460ff1681565b6040519015158152602001610385565b61037b60075481565b61037b61040e366004615500565b60066020526000908152604090205481565b61037b61042e366004615536565b610c71565b61037b60125481565b610444610da9565b005b61037b610454366004615500565b600c6020526000908152604090205481565b610444610474366004615500565b610f6f565b6104446104873660046155a4565b611060565b61044461049a3660046155e5565b61129e565b61037b6104ad366004615500565b6112d2565b61037b60115481565b61037b6104c9366004615500565b6001600160a01b03166000908152601c602052604090205490565b6103e76104f2366004615500565b60016020526000908152604090205460ff1681565b61051a6105153660046155a4565b611316565b60405161038593929190615639565b610444610537366004615536565b611507565b61058861054a366004615536565b60146020908152600092835260408084209091529082529020805460018201546002830154600390930154919290916001600160a01b039091169084565b604051610385949392919093845260208401929092526001600160a01b03166040830152606082015260800190565b6104446105c5366004615500565b61157c565b6105dd6105d83660046155e5565b6118ea565b60405161038592919061566f565b61037b6105f9366004615500565b60186020526000908152604090205481565b6104446106193660046155e5565b611922565b61063161062c366004615536565b611956565b604051610385929190615688565b61044461064d366004615696565b611992565b610444610660366004615701565b611cff565b61037b610673366004615500565b60056020526000908152604090205481565b601b5461037b565b610695611f69565b6040516103859392919061574f565b6104446106b23660046157f1565b612190565b61037b60165481565b6104446106ce366004615500565b6121ed565b6104446106e1366004615824565b6122bf565b61037b6106f4366004615500565b600a6020526000908152604090205481565b610719610714366004615500565b6124a2565b604051610385919061588f565b61037b610734366004615500565b612589565b61037b610747366004615500565b6001600160a01b031660009081526017602052604090205490565b61037b610770366004615536565b61275d565b610444612869565b61044461078b3660046155e5565b612a91565b61037b61079e366004615500565b600d6020526000908152604090205481565b6104446107be3660046155e5565b612b23565b61037b60135481565b61037b6107da366004615500565b60176020526000908152604090205481565b6104446107fa36600461593d565b612ba1565b61044461080d3660046155e5565b612be8565b610825610820366004615701565b612ed6565b60405161038591906159cf565b6104446108403660046155e5565b613075565b6108586108533660046155e5565b613304565b6040805196875260208701959095529385019290925260608401526001600160a01b0390811660808401521660a082015260c001610385565b6108a461089f366004615536565b613357565b6040516103859190615a1d565b6104446108bf3660046155e5565b6133bb565b6104446108d23660046155e5565b613441565b6108ea6108e5366004615536565b613833565b6040516103859190615a57565b610444610905366004615a65565b613945565b61091d6109183660046155e5565b613ae6565b6040516103859190615a98565b61093d610938366004615536565b613b8a565b604080519a8b5260208b0199909952978901969096526060880194909452608087019290925260a086015260c08501526001600160a01b031660e0840152151561010083015261012082015261014001610385565b6109a56109a0366004615536565b613c08565b604051610385929190615aa6565b610444Line truncated "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061036e5760003560e01c8062159da6146103735780630137451814610399578063022914a7146103cf5780630519da3214610402578063092c76101461040b5780630a84096a1461042b5780630a910a6d1461043e5780630c7d63861461044757806313baee5b14610451578063173825d9146104715780631764303d146104845780631aefa2d1146104975780631eb9e53e146104aa5780632ded58aa146104bd5780632e46fed8146104c65780633ba8396e146104ef5780633c92f98d146105125780633e4bc6bc146105345780633f35e7221461053d57806343a32f891461055057806343c7c011146105cb578063441a4175146105de5780634a61f1e5146105ff57806351e624721461061f57806351f6cf2f14610632578063549e61d3146106535780635811622714610666578063592d1dd11461067957806361d1080b1461069957806362cd6a09146106a157806367a74ddc146106b85780636ef569a5146106cb5780637065cb48146106d457806374d1c8e3146106e757806375060a0b146106fa5780637a0c6dc01461071a5780637bc221ac1461073a5780637e6d99261461074d57806380259e691461077657806380ca0ecf146107895780638129fc1c1461079c57806382b75681146107a457806384e8520a146107b7578063853e0df2146107d75780638939d787146107ea5780638f82818f146107f35780639437e32e14610813578063953d16bf1461082657806396fd111a146108395780639cb6f556146108595780639f3a676c1461086c578063a0d46758146108b8578063aaf4b04d146108d8578063ac97b417146108eb578063b6c3dc4c146108fe578063b92a349f1461091e578063bc0bc6ba14610931578063bd84477d14610951578063bed9757e146109b9578063c0c07d17146109da578063c2676603146109ed578063c32d3ae2146109f5578063c6b61e4c14610a28578063c7b530b014610a98578063cc573a9114610ab8578063ce13d09014610af4578063cfcf331914610b07578063d532bdfe14610b27578063da1b436414610b3a578063e88f8e6614610b5a578063eacdc5ff14610b6d578063eb44e0a314610b76578063ef5d9ae814610b89578063f2bb563014610ba9578063fe2f50d014610bbc578063fee6018c14610bc5578063ffecf51614610bd8575b600080fd5b6103866103813660046152c2565b610beb565b6040519081526020015b60405180910390f35b6103c26103a73660046152c2565b6004602052600090815260409020546001600160a01b031681565b60405161039091906152e4565b6103f26103dd3660046152c2565b60006020819052908152604090205460ff1681565b6040519015158152602001610390565b61038660075481565b6103866104193660046152c2565b60066020526000908152604090205481565b6103866104393660046152f8565b610c85565b61038660125481565b61044f610dbd565b005b61038661045f3660046152c2565b600c6020526000908152604090205481565b61044f61047f3660046152c2565b610f83565b61044f610492366004615366565b611074565b61044f6104a53660046153a7565b6112b2565b6103866104b83660046152c2565b6112e6565b61038660115481565b6103866104d43660046152c2565b6001600160a01b03166000908152601c602052604090205490565b6103f26104fd3660046152c2565b60016020526000908152604090205460ff1681565b610525610520366004615366565b61132a565b604051610390939291906153fb565b610386601d5481565b61044f61054b3660046152f8565b61151b565b61059c61055e3660046152f8565b60146020908152600092835260408084209091529082529020805460018201546002830154600390930154919290916001600160a01b039091169084565b604051610390949392919093845260208401929092526001600160a01b03166040830152606082015260800190565b61044f6105d93660046152c2565b611590565b6105f16105ec3660046153a7565b6118fe565b604051610390929190615431565b61038661060d3660046152c2565b60186020526000908152604090205481565b61044f61062d3660046153a7565b611936565b6106456106403660046152f8565b61196a565b60405161039092919061544a565b61044f610661366004615458565b6119a6565b61044f6106743660046154c3565b611d13565b6103866106873660046152c2565b60056020526000908152604090205481565b601b54610386565b6106a9611f7d565b60405161039093929190615511565b61044f6106c63660046155b3565b6121a4565b61038660165481565b61044f6106e23660046152c2565b612201565b61044f6106f53660046155e6565b6122d3565b6103866107083660046152c2565b600a6020526000908152604090205481565b61072d6107283660046152c2565b6124b6565b6040516103909190615651565b6103866107483660046152c2565b61259d565b61038661075b3660046152c2565b6001600160a01b031660009081526017602052604090205490565b61044f6107843660046153a7565b612771565b6103866107973660046152f8565b6127a5565b61044f6128b1565b61044f6107b23660046153a7565b612ad9565b6103866107c53660046152c2565b600d6020526000908152604090205481565b61044f6107e53660046153a7565b612b6b565b61038660135481565b6103866108013660046152c2565b60176020526000908152604090205481565b61044f6108213660046156ff565b612be9565b61044f6108343660046153a7565b612c30565b61084c6108473660046154c3565b612f1e565b6040516103909190615791565b61044f6108673660046153a7565b6130bd565b61087f61087a3660046153a7565b61334c565b6040805196875260208701959095529385019290925260608401526001600160a01b0390811660808401521660a082015260c001610390565b6108cb6108c63660046152f8565b61339f565b60405161039091906157df565b61044f6108e63660046153a7565b613403565b61044f6108f93660046153a7565b613489565b61091161090c3660046152f8565b61387b565b6040516103909190615819565b61044f61092c366004615827565b61398d565b61094461093f3660046153a7565b613b2e565b604051610390919061585a565b61096461095f3660046152f8565b613bd2565b604080519a8b5260208b0199909952978901969096526060880194909452608087019290925260a086015260c08501526001600160a01b031660e08401521515610100830152610120820152610140016103Line truncated
"linkReferences": {}, "linkReferences": {},
"deployedLinkReferences": {} "deployedLinkReferences": {}
} }
+48 -30
View File
@@ -114,6 +114,7 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
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
uint256 public highestRatio; // Track the highest TVL/liability ratio ever achieved (scaled by 10000)
// Events // Events
event VestingClaimed(address indexed user, uint256 amount, uint256 bonus); event VestingClaimed(address indexed user, uint256 amount, uint256 bonus);
@@ -196,6 +197,10 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
maxUnlockPercentage = _maxPercentage; maxUnlockPercentage = _maxPercentage;
} }
function updateHighestRatio(uint256 _highestRatio) external onlyOwner {
highestRatio = _highestRatio;
}
function withdrawFromVestingPool(address _token, uint256 _amount) external onlyOwner { function withdrawFromVestingPool(address _token, uint256 _amount) external onlyOwner {
IERC20(_token).safeTransfer(msg.sender, _amount); IERC20(_token).safeTransfer(msg.sender, _amount);
emit FundsWithdrawn(msg.sender, _token, _amount); emit FundsWithdrawn(msg.sender, _token, _amount);
@@ -305,7 +310,7 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
uint256 lastTvl, uint256 lastTvl,
uint256 lastLiability, uint256 lastLiability,
uint256 paybackPercent uint256 paybackPercent
) internal pure returns (uint256) { ) internal view returns (uint256) {
if (lastLiability == 0 || currentLiability == 0) { if (lastLiability == 0 || currentLiability == 0) {
return 0; // Safety check return 0; // Safety check
@@ -315,6 +320,11 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
uint256 currentRatio = (currentTvl * 10000) / currentLiability; uint256 currentRatio = (currentTvl * 10000) / currentLiability;
uint256 lastRatio = (lastTvl * 10000) / lastLiability; uint256 lastRatio = (lastTvl * 10000) / lastLiability;
// Check if current ratio is below the highest ratio ever achieved
if (currentRatio < highestRatio) {
return 0; // No unlock if we're below historical high
}
if (currentRatio <= lastRatio) { if (currentRatio <= lastRatio) {
return 0; // No unlock if ratio didn't improve return 0; // No unlock if ratio didn't improve
} }
@@ -333,6 +343,14 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
function endEpoch(uint256 estDaysRemaining, uint256 currentTreasuryTvl, uint256 _paybackPercent, uint256 _currentLiability) external onlyOwner { function endEpoch(uint256 estDaysRemaining, uint256 currentTreasuryTvl, uint256 _paybackPercent, uint256 _currentLiability) external onlyOwner {
uint256 unlockPercentage = 0; uint256 unlockPercentage = 0;
// Calculate current ratio and update highest ratio if necessary
if (_currentLiability > 0) {
uint256 currentRatio = (currentTreasuryTvl * 10000) / _currentLiability;
if (currentRatio > highestRatio) {
highestRatio = currentRatio;
}
}
if (currentEpochId > 0) { if (currentEpochId > 0) {
// Get previous epoch data // Get previous epoch data
Epoch storage lastEpoch = epochs[currentEpochId - 1]; Epoch storage lastEpoch = epochs[currentEpochId - 1];
@@ -353,7 +371,7 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
epochs[currentEpochId] = Epoch({ epochs[currentEpochId] = Epoch({
estDaysRemaining: estDaysRemaining, estDaysRemaining: estDaysRemaining,
currentTreasuryTvl: currentTreasuryTvl, currentTreasuryTvl: currentTreasuryTvl,
totalLiability: totalBigStakes, totalLiability: _currentLiability,
paybackPercent: _paybackPercent, paybackPercent: _paybackPercent,
unlockPercentage: unlockPercentage, unlockPercentage: unlockPercentage,
timestamp: block.timestamp timestamp: block.timestamp
@@ -1241,39 +1259,39 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
return totalClaimed[user]; return totalClaimed[user];
} }
/// @notice Search marketplace history for stakes where address was seller or buyer // /// @notice Search marketplace history for stakes where address was seller or buyer
/// @param targetAddress The address to search for as seller or buyer // /// @param targetAddress The address to search for as seller or buyer
/// @return Array of MarketplaceHistory structs where address was involved // /// @return Array of MarketplaceHistory structs where address was involved
function searchMarketplaceHistory(address targetAddress) external view returns (MarketplaceHistory[] memory) { // function searchMarketplaceHistory(address targetAddress) external view returns (MarketplaceHistory[] memory) {
require(targetAddress != address(0), "Invalid address"); // require(targetAddress != address(0), "Invalid address");
// Count matches first to size the result array properly // // Count matches first to size the result array properly
uint256 matchCount = 0; // uint256 matchCount = 0;
for (uint256 i = 0; i < marketplaceHistory.length; i++) { // for (uint256 i = 0; i < marketplaceHistory.length; i++) {
if (marketplaceHistory[i].seller == targetAddress || marketplaceHistory[i].buyer == targetAddress) { // if (marketplaceHistory[i].seller == targetAddress || marketplaceHistory[i].buyer == targetAddress) {
matchCount++; // matchCount++;
} // }
} // }
// Return empty array if no matches // // Return empty array if no matches
if (matchCount == 0) { // if (matchCount == 0) {
return new MarketplaceHistory[](0); // return new MarketplaceHistory[](0);
} // }
// Create result array with exact size needed // // Create result array with exact size needed
MarketplaceHistory[] memory result = new MarketplaceHistory[](matchCount); // MarketplaceHistory[] memory result = new MarketplaceHistory[](matchCount);
uint256 resultIndex = 0; // uint256 resultIndex = 0;
// Populate result array // // Populate result array
for (uint256 i = 0; i < marketplaceHistory.length; i++) { // for (uint256 i = 0; i < marketplaceHistory.length; i++) {
if (marketplaceHistory[i].seller == targetAddress || marketplaceHistory[i].buyer == targetAddress) { // if (marketplaceHistory[i].seller == targetAddress || marketplaceHistory[i].buyer == targetAddress) {
result[resultIndex] = marketplaceHistory[i]; // result[resultIndex] = marketplaceHistory[i];
resultIndex++; // resultIndex++;
} // }
} // }
return result; // return result;
} // }
/// @notice Test function for upgrade verification /// @notice Test function for upgrade verification
/// @return Returns a constant value to verify upgrade worked /// @return Returns a constant value to verify upgrade worked