Update BigStake
This commit is contained in:
1 parent
f37326855e
commit
74296bb16a
4 files changed
+309
-257
No files matched your search
@@ -381,7 +381,7 @@
|
||||
"type": "uint256[]"
|
||||
}
|
||||
],
|
||||
"name": "batchCreateUserStakes",
|
||||
"name": "batchUpdateUserStakes",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
@@ -495,6 +495,19 @@
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "user",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "clearVesting",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
@@ -1870,69 +1883,6 @@
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "user",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "vestingIndex",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "bonus",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "lockedUntil",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "usdAmount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "lastClaimed",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "createdAt",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "claimedAmount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "claimedBonus",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "updateVesting",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
@@ -2181,8 +2131,8 @@
|
||||
"type": "function"
|
||||
}
|
||||
],
|
||||
"bytecode": "0x60806040523480156200001157600080fd5b506200001c62000022565b620000d6565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff1615620000735760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b0390811614620000d35780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b6162d480620000e66000396000f3fe608060405234801561001057600080fd5b506004361061045e5760003560e01c80637e6d99261161024c578063bd84477d11610146578063d532bdfe116100c3578063ef5d9ae811610087578063ef5d9ae814610c9c578063f2bb563014610cbc578063fe2f50d014610ccf578063fee6018c14610cd8578063ffecf51614610ceb57600080fd5b8063d532bdfe14610c3a578063da1b436414610c4d578063e88f8e6614610c6d578063eacdc5ff14610c80578063eb44e0a314610c8957600080fd5b8063c6b61e4c1161010a578063c6b61e4c14610b3b578063c7b530b014610bab578063cc573a9114610bcb578063ce13d09014610c07578063cfcf331914610c1a57600080fd5b8063bd84477d14610a64578063bed9757e14610acc578063c0c07d1714610aed578063c267660314610b00578063c32d3ae214610b0857600080fd5b8063953d16bf116101d4578063aaf4b04d11610198578063aaf4b04d146109eb578063ac97b417146109fe578063b6c3dc4c14610a11578063b92a349f14610a31578063bc0bc6ba14610a4457600080fd5b8063953d16bf1461093957806396fd111a1461094c5780639cb6f5561461096c5780639f3a676c1461097f578063a0d46758146109cb57600080fd5b806382b756811161021b57806382b75681146108ca57806384e8520a146108dd578063853e0df2146108fd5780638939d787146109105780638f82818f1461091957600080fd5b80637e6d99261461087357806380259e691461089c57806380ca0ecf146108af5780638129fc1c146108c257600080fd5b806341e23c2a1161035d578063592d1dd1116102e55780636ef569a5116102a95780636ef569a5146108045780637065cb481461080d57806375060a0b146108205780637a0c6dc0146108405780637bc221ac1461086057600080fd5b8063592d1dd11461079f57806361d1080b146107bf57806362cd6a09146107c757806363624c83146107de57806367a74ddc146107f157600080fd5b80634a61f1e51161032c5780634a61f1e51461071e57806351e624721461073e57806351f6cf2f14610751578063549e61d314610779578063581162271461078c57600080fd5b806341e23c2a1461064b57806343a32f891461065e57806343c7c011146106d9578063441a4175146106ec57600080fd5b8063173825d9116103eb5780632e46fed8116103af5780632e46fed8146105c15780633ba8396e146105ea5780633c92f98d1461060d5780633e4bc6bc1461062f5780633f35e7221461063857600080fd5b8063173825d91461056c5780631764303d1461057f5780631aefa2d1146105925780631eb9e53e146105a55780632ded58aa146105b857600080fd5b8063092c761011610432578063092c7610146105065780630a84096a146105265780630a910a6d146105395780630c7d63861461054257806313baee5b1461054c57600080fd5b8062159da6146104635780630137451814610489578063022914a7146104ca5780630519da32146104fd575b600080fd5b610476610471366004615930565b610cfe565b6040519081526020015b60405180910390f35b6104b2610497366004615930565b6004602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610480565b6104ed6104d8366004615930565b60006020819052908152604090205460ff1681565b6040519015158152602001610480565b61047660075481565b610476610514366004615930565b60066020526000908152604090205481565b610476610534366004615952565b610d98565b61047660125481565b61054a610ed0565b005b61047661055a366004615930565b600c6020526000908152604090205481565b61054a61057a366004615930565b6110cf565b61054a61058d3660046159c0565b6111c0565b61054a6105a0366004615a01565b61142b565b6104766105b3366004615930565b61145f565b61047660115481565b6104766105cf366004615930565b6001600160a01b03166000908152601c602052604090205490565b6104ed6105f8366004615930565b60016020526000908152604090205460ff1681565b61062061061b3660046159c0565b6114a3565b60405161048093929190615a55565b610476601d5481565b61054a610646366004615952565b611691565b61054a610659366004615a8b565b611718565b6106aa61066c366004615952565b60146020908152600092835260408084209091529082529020805460018201546002830154600390930154919290916001600160a01b039091169084565b604051610480949392919093845260208401929092526001600160a01b03166040830152606082015260800190565b61054a6106e7366004615930565b611a22565b6106ff6106fa366004615a01565b611dab565b604080516001600160a01b039093168352602083019190915201610480565b61047661072c366004615930565b60186020526000908152604090205481565b61054a61074c366004615a01565b611de3565b61076461075f366004615952565b611e17565b60408051928352602083019190915201610480565b61054a610787366004615b17565b611e53565b61054a61079a366004615b82565b6121be565b6104766107ad366004615930565b60056020526000908152604090205481565b601b54610476565b6107cf612495565b60405161048093929190615ba4565b61054a6107ec366004615c6d565b6126e8565b61054a6107ff366004615ceb565b6128d6565b61047660165481565b61054a61081b366004615930565b612933565b61047661082e366004615930565b600a6020526000908152604090205481565b61085361084e366004615930565b612a05565b6040516104809190615d1e565b61047661086e366004615930565b612aec565b610476610881366004615930565b6001600160a01b031660009081526017602052604090205490565b61054a6108aa366004615a01565b612ccf565b6104766108bd366004615952565b612d03565b61054a612e0f565b61054a6108d836600461Line truncated
|
||||
"deployedBytecode": "0x608060405234801561001057600080fd5b506004361061045e5760003560e01c80637e6d99261161024c578063bd84477d11610146578063d532bdfe116100c3578063ef5d9ae811610087578063ef5d9ae814610c9c578063f2bb563014610cbc578063fe2f50d014610ccf578063fee6018c14610cd8578063ffecf51614610ceb57600080fd5b8063d532bdfe14610c3a578063da1b436414610c4d578063e88f8e6614610c6d578063eacdc5ff14610c80578063eb44e0a314610c8957600080fd5b8063c6b61e4c1161010a578063c6b61e4c14610b3b578063c7b530b014610bab578063cc573a9114610bcb578063ce13d09014610c07578063cfcf331914610c1a57600080fd5b8063bd84477d14610a64578063bed9757e14610acc578063c0c07d1714610aed578063c267660314610b00578063c32d3ae214610b0857600080fd5b8063953d16bf116101d4578063aaf4b04d11610198578063aaf4b04d146109eb578063ac97b417146109fe578063b6c3dc4c14610a11578063b92a349f14610a31578063bc0bc6ba14610a4457600080fd5b8063953d16bf1461093957806396fd111a1461094c5780639cb6f5561461096c5780639f3a676c1461097f578063a0d46758146109cb57600080fd5b806382b756811161021b57806382b75681146108ca57806384e8520a146108dd578063853e0df2146108fd5780638939d787146109105780638f82818f1461091957600080fd5b80637e6d99261461087357806380259e691461089c57806380ca0ecf146108af5780638129fc1c146108c257600080fd5b806341e23c2a1161035d578063592d1dd1116102e55780636ef569a5116102a95780636ef569a5146108045780637065cb481461080d57806375060a0b146108205780637a0c6dc0146108405780637bc221ac1461086057600080fd5b8063592d1dd11461079f57806361d1080b146107bf57806362cd6a09146107c757806363624c83146107de57806367a74ddc146107f157600080fd5b80634a61f1e51161032c5780634a61f1e51461071e57806351e624721461073e57806351f6cf2f14610751578063549e61d314610779578063581162271461078c57600080fd5b806341e23c2a1461064b57806343a32f891461065e57806343c7c011146106d9578063441a4175146106ec57600080fd5b8063173825d9116103eb5780632e46fed8116103af5780632e46fed8146105c15780633ba8396e146105ea5780633c92f98d1461060d5780633e4bc6bc1461062f5780633f35e7221461063857600080fd5b8063173825d91461056c5780631764303d1461057f5780631aefa2d1146105925780631eb9e53e146105a55780632ded58aa146105b857600080fd5b8063092c761011610432578063092c7610146105065780630a84096a146105265780630a910a6d146105395780630c7d63861461054257806313baee5b1461054c57600080fd5b8062159da6146104635780630137451814610489578063022914a7146104ca5780630519da32146104fd575b600080fd5b610476610471366004615930565b610cfe565b6040519081526020015b60405180910390f35b6104b2610497366004615930565b6004602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610480565b6104ed6104d8366004615930565b60006020819052908152604090205460ff1681565b6040519015158152602001610480565b61047660075481565b610476610514366004615930565b60066020526000908152604090205481565b610476610534366004615952565b610d98565b61047660125481565b61054a610ed0565b005b61047661055a366004615930565b600c6020526000908152604090205481565b61054a61057a366004615930565b6110cf565b61054a61058d3660046159c0565b6111c0565b61054a6105a0366004615a01565b61142b565b6104766105b3366004615930565b61145f565b61047660115481565b6104766105cf366004615930565b6001600160a01b03166000908152601c602052604090205490565b6104ed6105f8366004615930565b60016020526000908152604090205460ff1681565b61062061061b3660046159c0565b6114a3565b60405161048093929190615a55565b610476601d5481565b61054a610646366004615952565b611691565b61054a610659366004615a8b565b611718565b6106aa61066c366004615952565b60146020908152600092835260408084209091529082529020805460018201546002830154600390930154919290916001600160a01b039091169084565b604051610480949392919093845260208401929092526001600160a01b03166040830152606082015260800190565b61054a6106e7366004615930565b611a22565b6106ff6106fa366004615a01565b611dab565b604080516001600160a01b039093168352602083019190915201610480565b61047661072c366004615930565b60186020526000908152604090205481565b61054a61074c366004615a01565b611de3565b61076461075f366004615952565b611e17565b60408051928352602083019190915201610480565b61054a610787366004615b17565b611e53565b61054a61079a366004615b82565b6121be565b6104766107ad366004615930565b60056020526000908152604090205481565b601b54610476565b6107cf612495565b60405161048093929190615ba4565b61054a6107ec366004615c6d565b6126e8565b61054a6107ff366004615ceb565b6128d6565b61047660165481565b61054a61081b366004615930565b612933565b61047661082e366004615930565b600a6020526000908152604090205481565b61085361084e366004615930565b612a05565b6040516104809190615d1e565b61047661086e366004615930565b612aec565b610476610881366004615930565b6001600160a01b031660009081526017602052604090205490565b61054a6108aa366004615a01565b612ccf565b6104766108bd366004615952565b612d03565b61054a612e0f565b61054a6108d8366004615a01565b612ff2565b6104766108eb366004615930565b600d6020526000908152604090205481565b61054a61090b366004615a01565b613084565b61047660135481565b610476610927366004615930565b60176020526000908152604090205481565b61054a610947366004615a01565b613120565b61095f61095a366004615b82565b613427565b6040516104809190615dcc565b61054a61097a366004615a01565b6135f7565b61099261098d366004615a01565b6138e8565b6040805196875260208701959095529385019290925260608401526001600160a01b0390Line truncated
|
||||
"bytecode": "0x60806040523480156200001157600080fd5b506200001c62000022565b620000d6565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff1615620000735760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b0390811614620000d35780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b615ce180620000e66000396000f3fe608060405234801561001057600080fd5b506004361061036e5760003560e01c8062159da6146103735780630137451814610399578063022914a7146103cf5780630519da3214610402578063092c76101461040b5780630a84096a1461042b5780630a910a6d1461043e5780630c7d63861461044757806313baee5b14610451578063173825d9146104715780631764303d146104845780631aefa2d1146104975780631eb9e53e146104aa5780632ded58aa146104bd5780632e46fed8146104c65780633ba8396e146104ef5780633c92f98d146105125780633e4bc6bc146105345780633f35e7221461053d57806343a32f891461055057806343c7c011146105cb578063441a4175146105de57806348ea286d146105ff5780634a61f1e51461061257806351e624721461063257806351f6cf2f146106455780635811622714610666578063592d1dd11461067957806361d1080b1461069957806362cd6a09146106a157806363624c83146106b857806367a74ddc146106cb5780636ef569a5146106de5780637065cb48146106e757806375060a0b146106fa5780637a0c6dc01461071a5780637bc221ac1461073a5780637e6d99261461074d57806380259e691461077657806380ca0ecf146107895780638129fc1c1461079c57806382b75681146107a457806384e8520a146107b7578063853e0df2146107d75780638939d787146107ea5780638f82818f146107f3578063953d16bf1461081357806396fd111a146108265780639cb6f556146108465780639f3a676c14610859578063a0d46758146108a5578063aaf4b04d146108c5578063ac97b417146108d8578063b6c3dc4c146108eb578063b92a349f1461090b578063bc0bc6ba1461091e578063bd84477d1461093e578063bed9757e146109a6578063c0c07d17146109c7578063c2676603146109da578063c32d3ae2146109e2578063c6b61e4c14610a15578063c7b530b014610a85578063cc573a9114610aa5578063ce13d09014610ae1578063cfcf331914610af4578063d532bdfe14610b14578063d72f23b614610b27578063da1b436414610b3a578063e88f8e6614610b5a578063eacdc5ff14610b6d578063eb44e0a314610b76578063ef5d9ae814610b89578063f2bb563014610ba9578063fe2f50d014610bbc578063fee6018c14610bc5578063ffecf51614610bd8575b600080fd5b610386610381366004615264565b610beb565b6040519081526020015b60405180910390f35b6103c26103a7366004615264565b6004602052600090815260409020546001600160a01b031681565b6040516103909190615286565b6103f26103dd366004615264565b60006020819052908152604090205460ff1681565b6040519015158152602001610390565b61038660075481565b610386610419366004615264565b60066020526000908152604090205481565b61038661043936600461529a565b610c85565b61038660125481565b61044f610dbd565b005b61038661045f366004615264565b600c6020526000908152604090205481565b61044f61047f366004615264565b610f83565b61044f610492366004615308565b611074565b61044f6104a5366004615349565b6112b2565b6103866104b8366004615264565b6112e6565b61038660115481565b6103866104d4366004615264565b6001600160a01b03166000908152601c602052604090205490565b6103f26104fd366004615264565b60016020526000908152604090205460ff1681565b610525610520366004615308565b61132a565b6040516103909392919061539d565b610386601d5481565b61044f61054b36600461529a565b61151b565b61059c61055e36600461529a565b60146020908152600092835260408084209091529082529020805460018201546002830154600390930154919290916001600160a01b039091169084565b604051610390949392919093845260208401929092526001600160a01b03166040830152606082015260800190565b61044f6105d9366004615264565b611590565b6105f16105ec366004615349565b6118fe565b6040516103909291906153d3565b61044f61060d366004615264565b611936565b610386610620366004615264565b60186020526000908152604090205481565b61044f610640366004615349565b611ac2565b61065861065336600461529a565b611af6565b6040516103909291906153ec565b61044f6106743660046153fa565b611b32565b610386610687366004615264565b60056020526000908152604090205481565b601b54610386565b6106a9611d9c565b60405161039093929190615448565b61044f6106c63660046154ea565b611fc3565b61044f6106d9366004615568565b6121b1565b61038660165481565b61044f6106f5366004615264565b61220e565b610386610708366004615264565b600a6020526000908152604090205481565b61072d610728366004615264565b6122e0565b604051610390919061559b565b610386610748366004615264565b6123c7565b61038661075b366004615264565b6001600160a01b031660009081526017602052604090205490565b61044f610784366004615349565b61259b565b61038661079736600461529a565b6125cf565b61044f6126db565b61044f6107b2366004615349565b6128be565b6103866107c5366004615264565b600d6020526000908152604090205481565b61044f6107e5366004615349565b612950565b61038660135481565b610386610801366004615264565b60176020526000908152604090205481565b61044f610821366004615349565b6129ce565b6108396108343660046153fa565b612cbc565b6040516103909190615683565b61044f610854366004615349565b612e5b565b61086c610867366004615349565b6130ea565b6040805196875260208701959095529385019290925260608401526001600160a01b0390811660808401521660a082015260c001610390565b6108b86108b336600461529a565b61313d565b60405161039091906156d1565b61044f6108d3366004615349565b61Line truncated
|
||||
"deployedBytecode": "0x608060405234801561001057600080fd5b506004361061036e5760003560e01c8062159da6146103735780630137451814610399578063022914a7146103cf5780630519da3214610402578063092c76101461040b5780630a84096a1461042b5780630a910a6d1461043e5780630c7d63861461044757806313baee5b14610451578063173825d9146104715780631764303d146104845780631aefa2d1146104975780631eb9e53e146104aa5780632ded58aa146104bd5780632e46fed8146104c65780633ba8396e146104ef5780633c92f98d146105125780633e4bc6bc146105345780633f35e7221461053d57806343a32f891461055057806343c7c011146105cb578063441a4175146105de57806348ea286d146105ff5780634a61f1e51461061257806351e624721461063257806351f6cf2f146106455780635811622714610666578063592d1dd11461067957806361d1080b1461069957806362cd6a09146106a157806363624c83146106b857806367a74ddc146106cb5780636ef569a5146106de5780637065cb48146106e757806375060a0b146106fa5780637a0c6dc01461071a5780637bc221ac1461073a5780637e6d99261461074d57806380259e691461077657806380ca0ecf146107895780638129fc1c1461079c57806382b75681146107a457806384e8520a146107b7578063853e0df2146107d75780638939d787146107ea5780638f82818f146107f3578063953d16bf1461081357806396fd111a146108265780639cb6f556146108465780639f3a676c14610859578063a0d46758146108a5578063aaf4b04d146108c5578063ac97b417146108d8578063b6c3dc4c146108eb578063b92a349f1461090b578063bc0bc6ba1461091e578063bd84477d1461093e578063bed9757e146109a6578063c0c07d17146109c7578063c2676603146109da578063c32d3ae2146109e2578063c6b61e4c14610a15578063c7b530b014610a85578063cc573a9114610aa5578063ce13d09014610ae1578063cfcf331914610af4578063d532bdfe14610b14578063d72f23b614610b27578063da1b436414610b3a578063e88f8e6614610b5a578063eacdc5ff14610b6d578063eb44e0a314610b76578063ef5d9ae814610b89578063f2bb563014610ba9578063fe2f50d014610bbc578063fee6018c14610bc5578063ffecf51614610bd8575b600080fd5b610386610381366004615264565b610beb565b6040519081526020015b60405180910390f35b6103c26103a7366004615264565b6004602052600090815260409020546001600160a01b031681565b6040516103909190615286565b6103f26103dd366004615264565b60006020819052908152604090205460ff1681565b6040519015158152602001610390565b61038660075481565b610386610419366004615264565b60066020526000908152604090205481565b61038661043936600461529a565b610c85565b61038660125481565b61044f610dbd565b005b61038661045f366004615264565b600c6020526000908152604090205481565b61044f61047f366004615264565b610f83565b61044f610492366004615308565b611074565b61044f6104a5366004615349565b6112b2565b6103866104b8366004615264565b6112e6565b61038660115481565b6103866104d4366004615264565b6001600160a01b03166000908152601c602052604090205490565b6103f26104fd366004615264565b60016020526000908152604090205460ff1681565b610525610520366004615308565b61132a565b6040516103909392919061539d565b610386601d5481565b61044f61054b36600461529a565b61151b565b61059c61055e36600461529a565b60146020908152600092835260408084209091529082529020805460018201546002830154600390930154919290916001600160a01b039091169084565b604051610390949392919093845260208401929092526001600160a01b03166040830152606082015260800190565b61044f6105d9366004615264565b611590565b6105f16105ec366004615349565b6118fe565b6040516103909291906153d3565b61044f61060d366004615264565b611936565b610386610620366004615264565b60186020526000908152604090205481565b61044f610640366004615349565b611ac2565b61065861065336600461529a565b611af6565b6040516103909291906153ec565b61044f6106743660046153fa565b611b32565b610386610687366004615264565b60056020526000908152604090205481565b601b54610386565b6106a9611d9c565b60405161039093929190615448565b61044f6106c63660046154ea565b611fc3565b61044f6106d9366004615568565b6121b1565b61038660165481565b61044f6106f5366004615264565b61220e565b610386610708366004615264565b600a6020526000908152604090205481565b61072d610728366004615264565b6122e0565b604051610390919061559b565b610386610748366004615264565b6123c7565b61038661075b366004615264565b6001600160a01b031660009081526017602052604090205490565b61044f610784366004615349565b61259b565b61038661079736600461529a565b6125cf565b61044f6126db565b61044f6107b2366004615349565b6128be565b6103866107c5366004615264565b600d6020526000908152604090205481565b61044f6107e5366004615349565b612950565b61038660135481565b610386610801366004615264565b60176020526000908152604090205481565b61044f610821366004615349565b6129ce565b6108396108343660046153fa565b612cbc565b6040516103909190615683565b61044f610854366004615349565b612e5b565b61086c610867366004615349565b6130ea565b6040805196875260208701959095529385019290925260608401526001600160a01b0390811660808401521660a082015260c001610390565b6108b86108b336600461529a565b61313d565b60405161039091906156d1565b61044f6108d3366004615349565b6131a1565b61044f6108e6366004615349565b613227565b6108fe6108f936600461529a565b613619565b604051610390919061570b565b61044f610919366004615719565b61372b565b61093161092c366004615349565b6138cc565b604051610390919061574c565b61095161094c36600461529a565b613970565b604080519a8b5260208b0199909952978901969096526060880194909452608087019290925260a086015260c08501526001600160a01b031660e0840152151561010083015261012082015261014001610390565b6109b96109b436600461529a565b6139Line truncated
|
||||
"linkReferences": {},
|
||||
"deployedLinkReferences": {}
|
||||
}
|
||||
@@ -208,6 +208,16 @@ contract CunaFinanceBase is Initializable, ReentrancyGuardUpgradeable {
|
||||
emit FundsWithdrawn(msg.sender, BASE_TOKEN, _amount);
|
||||
}
|
||||
|
||||
/// @notice Admin function to adjust withdraw liabilities (for fixing decimal conversion issues)
|
||||
/// @param token The token address to adjust
|
||||
/// @param newAmount The new liability amount (should be in token's native decimals)
|
||||
function adjustWithdrawLiability(address token, uint256 newAmount) external onlyOwner {
|
||||
uint256 oldAmount = withdrawLiabilities[token];
|
||||
withdrawLiabilities[token] = newAmount;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function setPriceOracle(address _token, address _oracle) external onlyOwner {
|
||||
priceOracles[_token] = _oracle;
|
||||
}
|
||||
@@ -357,6 +367,54 @@ contract CunaFinanceBase is Initializable, ReentrancyGuardUpgradeable {
|
||||
currentEpochId++;
|
||||
}
|
||||
|
||||
/// @notice Re-enter/update the most recent epoch with new values and recalculated unlock percentage
|
||||
/// @param estDaysRemaining Estimated days remaining for the protocol
|
||||
/// @param currentTreasuryTvl Current treasury total value locked
|
||||
/// @param _paybackPercent Percentage multiplier for unlock calculation (scaled by 10000)
|
||||
/// @param _currentLiability Current total liability amount
|
||||
function reenterEpoch(uint256 estDaysRemaining, uint256 currentTreasuryTvl, uint256 _paybackPercent, uint256 _currentLiability) external onlyOwner {
|
||||
require(currentEpochId > 0, "No epochs to update");
|
||||
|
||||
uint256 epochId = currentEpochId - 1; // Most recent epoch
|
||||
|
||||
uint256 unlockPercentage = 0;
|
||||
// Calculate current ratio
|
||||
if (_currentLiability > 0) {
|
||||
uint256 currentRatio = (currentTreasuryTvl * 10000) / _currentLiability;
|
||||
|
||||
if (epochId > 0) {
|
||||
// Calculate unlock percentage BEFORE updating highest ratio
|
||||
unlockPercentage = calculateUnlockPercentage(currentRatio, _paybackPercent);
|
||||
}
|
||||
|
||||
// Update highest ratio AFTER calculating unlock percentage
|
||||
if (currentRatio > highestRatio) {
|
||||
highestRatio = currentRatio;
|
||||
}
|
||||
}
|
||||
|
||||
// Check that unlock percentage doesn't exceed maximum
|
||||
require(unlockPercentage <= maxUnlockPercentage, "Unlock percentage high");
|
||||
|
||||
// Update the existing epoch entry
|
||||
epochs[epochId] = Epoch({
|
||||
estDaysRemaining: estDaysRemaining,
|
||||
currentTreasuryTvl: currentTreasuryTvl,
|
||||
totalLiability: _currentLiability,
|
||||
paybackPercent: _paybackPercent,
|
||||
unlockPercentage: unlockPercentage,
|
||||
timestamp: block.timestamp
|
||||
});
|
||||
|
||||
emit EpochEnded(epochId, currentTreasuryTvl, unlockPercentage, _paybackPercent);
|
||||
}
|
||||
|
||||
/// @notice Set a manual currentEpochId
|
||||
/// @param epochId The epoch ID to set as the currentEpochId
|
||||
function setEpochId(uint256 epochId) external onlyOwner {
|
||||
currentEpochId = epochId;
|
||||
}
|
||||
|
||||
/// @notice Calculate total unclaimed funds for a user across all epochs since last claim
|
||||
function calculateUnclaimedFunds(address user) public view returns (uint256 totalUnclaimed) {
|
||||
uint256 remainingStake = getNetStake(user);
|
||||
@@ -452,8 +510,8 @@ contract CunaFinanceBase is Initializable, ReentrancyGuardUpgradeable {
|
||||
transferAmount = amount / 1e12; // Convert from 18 decimals to 6 decimals
|
||||
}
|
||||
|
||||
// Decrement withdraw liabilities for all tokens (using original 18-decimal amount)
|
||||
withdrawLiabilities[token] -= amount;
|
||||
// Decrement withdraw liabilities (using correct decimal precision)
|
||||
withdrawLiabilities[token] -= transferAmount;
|
||||
|
||||
// Transfer tokens to user based on the specified token (using converted amount)
|
||||
IERC20(token).safeTransfer(msg.sender, transferAmount);
|
||||
@@ -507,35 +565,35 @@ contract CunaFinanceBase is Initializable, ReentrancyGuardUpgradeable {
|
||||
|
||||
// Bot Functions for Staking Management
|
||||
|
||||
/// @notice Create a withdraw stake for a user (for admin/migration purposes)
|
||||
/// @dev Only to be used by bots for manual withdraw stake creation
|
||||
/// @param user The user address to create the withdraw stake for
|
||||
/// @param amount The amount for the withdraw stake
|
||||
/// @param unlockTime The unlock timestamp for the withdraw stake
|
||||
/// @param token The token address for the withdraw stake
|
||||
/// @param isVesting Whether this is a vesting-related stake (adds 1e6 to stakeId)
|
||||
function createWithdrawStakeForUser(address user, uint256 amount, uint256 unlockTime, address token, bool isVesting) external onlyBot {
|
||||
require(user != address(0), "Invalid user address");
|
||||
require(amount > 0, "Invalid amount");
|
||||
require(token != address(0), "Invalid token address");
|
||||
// /// @notice Create a withdraw stake for a user (for admin/migration purposes)
|
||||
// /// @dev Only to be used by bots for manual withdraw stake creation
|
||||
// /// @param user The user address to create the withdraw stake for
|
||||
// /// @param amount The amount for the withdraw stake
|
||||
// /// @param unlockTime The unlock timestamp for the withdraw stake
|
||||
// /// @param token The token address for the withdraw stake
|
||||
// /// @param isVesting Whether this is a vesting-related stake (adds 1e6 to stakeId)
|
||||
// function createWithdrawStakeForUser(address user, uint256 amount, uint256 unlockTime, address token, bool isVesting) external onlyBot {
|
||||
// require(user != address(0), "Invalid user address");
|
||||
// require(amount > 0, "Invalid amount");
|
||||
// require(token != address(0), "Invalid token address");
|
||||
|
||||
// Generate unique stakeId
|
||||
stakeIdCounter++;
|
||||
uint256 finalStakeId = isVesting ? stakeIdCounter + 1e6 : stakeIdCounter;
|
||||
// // Generate unique stakeId
|
||||
// stakeIdCounter++;
|
||||
// uint256 finalStakeId = isVesting ? stakeIdCounter + 1e6 : stakeIdCounter;
|
||||
|
||||
// Create the withdraw stake
|
||||
withdrawStakes[user].push(WithdrawStake({
|
||||
stakeId: finalStakeId,
|
||||
amount: amount,
|
||||
unlockTime: unlockTime,
|
||||
token: token
|
||||
}));
|
||||
// // Create the withdraw stake
|
||||
// withdrawStakes[user].push(WithdrawStake({
|
||||
// stakeId: finalStakeId,
|
||||
// amount: amount,
|
||||
// unlockTime: unlockTime,
|
||||
// token: token
|
||||
// }));
|
||||
|
||||
// Increment withdraw liabilities for this token
|
||||
withdrawLiabilities[token] += amount;
|
||||
// // Increment withdraw liabilities for this token
|
||||
// withdrawLiabilities[token] += amount;
|
||||
|
||||
emit StakeWithdrawn(user, amount, finalStakeId);
|
||||
}
|
||||
// emit StakeWithdrawn(user, amount, finalStakeId);
|
||||
// }
|
||||
|
||||
/// @notice Batch create stakes for multiple users (efficient for migration)
|
||||
/// @dev Only to be used by bots for initial setup
|
||||
@@ -1201,8 +1259,8 @@ contract CunaFinanceBase is Initializable, ReentrancyGuardUpgradeable {
|
||||
|
||||
// Only update liabilities and emit event if something was actually claimed
|
||||
if (totalBonusClaimed > 0) {
|
||||
// Increment withdraw liabilities for BASE_TOKEN
|
||||
withdrawLiabilities[BASE_TOKEN] += totalBonusClaimed;
|
||||
// Increment withdraw liabilities for BASE_TOKEN (convert from 18 decimals to 6 decimals)
|
||||
withdrawLiabilities[BASE_TOKEN] += totalBonusClaimed / 1e12;
|
||||
emit BonusClaimed(msg.sender, totalBonusClaimed);
|
||||
}
|
||||
}
|
||||
@@ -1321,7 +1379,7 @@ contract CunaFinanceBase 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 1000; // Updated value to trigger upgrade detection
|
||||
return 1002; // Added adjustWithdrawLiability admin function
|
||||
}
|
||||
|
||||
}
|
||||
@@ -530,11 +530,39 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
|
||||
emit StakeWithdrawn(user, amount, finalStakeId);
|
||||
}
|
||||
|
||||
/// @notice Batch create stakes for multiple users (efficient for migration)
|
||||
/// @dev Only to be used by bots for initial setup
|
||||
// /// @notice Batch create stakes for multiple users
|
||||
// /// @dev Only to be used by bots for initial setup
|
||||
// /// @param users Array of user addresses
|
||||
// /// @param amounts Array of stake amounts (must match users length)
|
||||
// function batchCreateUserStakes(address[] calldata users, uint256[] calldata amounts) external onlyBot {
|
||||
// require(users.length == amounts.length, "Array length mismatch");
|
||||
// require(users.length > 0, "Empty arrays");
|
||||
|
||||
// for (uint256 i = 0; i < users.length; i++) {
|
||||
// require(users[i] != address(0), "Invalid address");
|
||||
// require(amounts[i] > 0, "Invalid amount");
|
||||
|
||||
// // Update totalBigStakes directly (subtract old, add new)
|
||||
// totalBigStakes = totalBigStakes - userBigStake[users[i]] + amounts[i];
|
||||
|
||||
// // Set original stake
|
||||
// userOriginalStake[users[i]] = amounts[i];
|
||||
|
||||
// // Set last claimed epoch to current epoch
|
||||
// userLastClaimedEpoch[users[i]] = currentEpochId;
|
||||
|
||||
// // Set user's big stake
|
||||
// userBigStake[users[i]] = amounts[i];
|
||||
|
||||
// emit StakeCreated(users[i], amounts[i]);
|
||||
// }
|
||||
// }
|
||||
|
||||
/// @notice Batch add to stakes for multiple users
|
||||
/// @dev Only to be used by bots for edits
|
||||
/// @param users Array of user addresses
|
||||
/// @param amounts Array of stake amounts (must match users length)
|
||||
function batchCreateUserStakes(address[] calldata users, uint256[] calldata amounts) external onlyBot {
|
||||
/// @param amounts Array of stake amounts to ADD to a users bigStake
|
||||
function batchUpdateUserStakes(address[] calldata users, uint256[] calldata amounts) external onlyBot {
|
||||
require(users.length == amounts.length, "Array length mismatch");
|
||||
require(users.length > 0, "Empty arrays");
|
||||
|
||||
@@ -542,19 +570,18 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
|
||||
require(users[i] != address(0), "Invalid address");
|
||||
require(amounts[i] > 0, "Invalid amount");
|
||||
|
||||
// Update totalBigStakes directly (subtract old, add new)
|
||||
totalBigStakes = totalBigStakes - userBigStake[users[i]] + amounts[i];
|
||||
// Update totalBigStakes directly (add new)
|
||||
totalBigStakes = totalBigStakes + amounts[i];
|
||||
|
||||
// Set original stake
|
||||
userOriginalStake[users[i]] = amounts[i];
|
||||
// Add to original stake
|
||||
userOriginalStake[users[i]] += amounts[i];
|
||||
|
||||
// Set last claimed epoch to current epoch
|
||||
userLastClaimedEpoch[users[i]] = currentEpochId;
|
||||
// userLastClaimedEpoch[users[i]] = currentEpochId; DONT Update
|
||||
|
||||
// Set user's big stake
|
||||
userBigStake[users[i]] = amounts[i];
|
||||
// Increment user's big stake
|
||||
userBigStake[users[i]] += amounts[i];
|
||||
|
||||
emit StakeCreated(users[i], amounts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -795,30 +822,30 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
|
||||
}
|
||||
|
||||
// Bot Functions for Emergency Management
|
||||
/// @notice This function will end and clear a user's vestings.
|
||||
/// @dev Only to be used by bots in emergencies
|
||||
/// @param user The user whose vestings will be ended and 0'd
|
||||
// function clearVesting(address user) external onlyBot {
|
||||
// for (uint256 i = 0; i < vestings[user].length; ++i) {
|
||||
// Vesting storage vesting = vestings[user][i];
|
||||
// @notice This function will end and clear a user's vestings.
|
||||
// @dev Only to be used by bots in emergencies
|
||||
// @param user The user whose vestings will be ended and 0'd
|
||||
function clearVesting(address user) external onlyBot {
|
||||
for (uint256 i = 0; i < vestings[user].length; ++i) {
|
||||
Vesting storage vesting = vestings[user][i];
|
||||
|
||||
// // Decrement accounting variables before clearing
|
||||
// if (!vesting.complete) {
|
||||
// if (dollarsVested[user] >= vesting.usdAmount) {
|
||||
// dollarsVested[user] -= vesting.usdAmount;
|
||||
// }
|
||||
// if (vestedTotal[vesting.token] >= vesting.amount) {
|
||||
// vestedTotal[vesting.token] -= vesting.amount;
|
||||
// }
|
||||
// }
|
||||
// Decrement accounting variables before clearing
|
||||
if (!vesting.complete) {
|
||||
if (dollarsVested[user] >= vesting.usdAmount) {
|
||||
dollarsVested[user] -= vesting.usdAmount;
|
||||
}
|
||||
if (vestedTotal[vesting.token] >= vesting.amount) {
|
||||
vestedTotal[vesting.token] -= vesting.amount;
|
||||
}
|
||||
}
|
||||
|
||||
// vesting.amount = 0;
|
||||
// vesting.bonus = 0;
|
||||
// vesting.claimedAmount = 0;
|
||||
// vesting.claimedBonus = 0;
|
||||
// vesting.complete = true;
|
||||
// }
|
||||
// }
|
||||
vesting.amount = 0;
|
||||
vesting.bonus = 0;
|
||||
vesting.claimedAmount = 0;
|
||||
vesting.claimedBonus = 0;
|
||||
vesting.complete = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// @notice Creates a vesting for a given user
|
||||
/// @dev Only to be used by bots for manual vesting creation
|
||||
@@ -846,45 +873,45 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
|
||||
vestedTotal[token] += amount - claimedAmount;
|
||||
}
|
||||
|
||||
/// @notice Update an existing vesting at a specific index
|
||||
/// @dev Only updates existing vestings. Fails if the index doesn't exist.
|
||||
/// @param user The user address to update vesting for
|
||||
/// @param vestingIndex The index of the existing vesting to update
|
||||
/// @param amount The vesting amount
|
||||
/// @param bonus The bonus amount
|
||||
/// @param lockedUntil The lock timestamp
|
||||
/// @param token The token address
|
||||
/// @param usdAmount The USD value
|
||||
/// @param lastClaimed The last claimed timestamp
|
||||
/// @param createdAt The creation timestamp
|
||||
/// @param claimedAmount The already claimed amount
|
||||
/// @param claimedBonus The already claimed bonus
|
||||
function updateVesting(address user, uint256 vestingIndex, uint256 amount, uint256 bonus, uint256 lockedUntil, address token, uint256 usdAmount, uint256 lastClaimed, uint256 createdAt, uint256 claimedAmount, uint256 claimedBonus) public onlyBot {
|
||||
require(vestingIndex < vestings[user].length, "Vesting index does not exist");
|
||||
// /// @notice Update an existing vesting at a specific index
|
||||
// /// @dev Only updates existing vestings. Fails if the index doesn't exist.
|
||||
// /// @param user The user address to update vesting for
|
||||
// /// @param vestingIndex The index of the existing vesting to update
|
||||
// /// @param amount The vesting amount
|
||||
// /// @param bonus The bonus amount
|
||||
// /// @param lockedUntil The lock timestamp
|
||||
// /// @param token The token address
|
||||
// /// @param usdAmount The USD value
|
||||
// /// @param lastClaimed The last claimed timestamp
|
||||
// /// @param createdAt The creation timestamp
|
||||
// /// @param claimedAmount The already claimed amount
|
||||
// /// @param claimedBonus The already claimed bonus
|
||||
// function updateVesting(address user, uint256 vestingIndex, uint256 amount, uint256 bonus, uint256 lockedUntil, address token, uint256 usdAmount, uint256 lastClaimed, uint256 createdAt, uint256 claimedAmount, uint256 claimedBonus) public onlyBot {
|
||||
// require(vestingIndex < vestings[user].length, "Vesting index does not exist");
|
||||
|
||||
// Subtract old values from totals first
|
||||
Vesting storage oldVesting = vestings[user][vestingIndex];
|
||||
dollarsVested[user] -= oldVesting.usdAmount;
|
||||
vestedTotal[oldVesting.token] -= (oldVesting.amount - oldVesting.claimedAmount);
|
||||
// // Subtract old values from totals first
|
||||
// Vesting storage oldVesting = vestings[user][vestingIndex];
|
||||
// dollarsVested[user] -= oldVesting.usdAmount;
|
||||
// vestedTotal[oldVesting.token] -= (oldVesting.amount - oldVesting.claimedAmount);
|
||||
|
||||
// Update the vesting at the specified index
|
||||
vestings[user][vestingIndex] = Vesting({
|
||||
amount: amount,
|
||||
bonus: bonus,
|
||||
lockedUntil: lockedUntil,
|
||||
claimedAmount: claimedAmount,
|
||||
claimedBonus: claimedBonus,
|
||||
lastClaimed: lastClaimed,
|
||||
createdAt: createdAt,
|
||||
token: token,
|
||||
complete: false,
|
||||
usdAmount: usdAmount
|
||||
});
|
||||
// // Update the vesting at the specified index
|
||||
// vestings[user][vestingIndex] = Vesting({
|
||||
// amount: amount,
|
||||
// bonus: bonus,
|
||||
// lockedUntil: lockedUntil,
|
||||
// claimedAmount: claimedAmount,
|
||||
// claimedBonus: claimedBonus,
|
||||
// lastClaimed: lastClaimed,
|
||||
// createdAt: createdAt,
|
||||
// token: token,
|
||||
// complete: false,
|
||||
// usdAmount: usdAmount
|
||||
// });
|
||||
|
||||
// Add new values to totals
|
||||
dollarsVested[user] += usdAmount;
|
||||
vestedTotal[token] += amount - claimedAmount;
|
||||
}
|
||||
// // Add new values to totals
|
||||
// dollarsVested[user] += usdAmount;
|
||||
// vestedTotal[token] += amount - claimedAmount;
|
||||
// }
|
||||
|
||||
// /// @notice Migrates all vestings from an old address to a new address
|
||||
// /// @dev Only to be used by bots for account migrations
|
||||
@@ -1314,7 +1341,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 999; // Different value from bsc_paca to distinguish contracts
|
||||
return 1001; // Different value from bsc_paca to distinguish contracts
|
||||
}
|
||||
|
||||
}
|
||||
+107
-90
@@ -208,44 +208,52 @@ contract CunaFinanceSonic is Initializable, ReentrancyGuardUpgradeable {
|
||||
emit FundsWithdrawn(msg.sender, SONIC_TOKEN, _amount);
|
||||
}
|
||||
|
||||
/// @notice Admin function to adjust withdraw liabilities (for fixing decimal conversion issues)
|
||||
/// @param token The token address to adjust
|
||||
/// @param newAmount The new liability amount (should be in token's native decimals)
|
||||
function adjustWithdrawLiability(address token, uint256 newAmount) external onlyOwner {
|
||||
withdrawLiabilities[token] = newAmount;
|
||||
|
||||
}
|
||||
|
||||
function setPriceOracle(address _token, address _oracle) external onlyOwner {
|
||||
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
|
||||
@@ -357,6 +365,48 @@ contract CunaFinanceSonic is Initializable, ReentrancyGuardUpgradeable {
|
||||
currentEpochId++;
|
||||
}
|
||||
|
||||
/// @notice Re-enter/update the most recent epoch with new values and recalculated unlock percentage
|
||||
/// @param estDaysRemaining Estimated days remaining for the protocol
|
||||
/// @param currentTreasuryTvl Current treasury total value locked
|
||||
/// @param _paybackPercent Percentage multiplier for unlock calculation (scaled by 10000)
|
||||
/// @param _currentLiability Current total liability amount
|
||||
function reenterEpoch(uint256 estDaysRemaining, uint256 currentTreasuryTvl, uint256 _paybackPercent, uint256 _currentLiability) external onlyOwner {
|
||||
require(currentEpochId > 0, "No epochs to update");
|
||||
|
||||
uint256 epochId = currentEpochId - 1; // Most recent epoch
|
||||
|
||||
uint256 unlockPercentage = 0;
|
||||
// Calculate current ratio
|
||||
if (_currentLiability > 0) {
|
||||
uint256 currentRatio = (currentTreasuryTvl * 10000) / _currentLiability;
|
||||
|
||||
if (epochId > 0) {
|
||||
// Calculate unlock percentage BEFORE updating highest ratio
|
||||
unlockPercentage = calculateUnlockPercentage(currentRatio, _paybackPercent);
|
||||
}
|
||||
|
||||
// Update highest ratio AFTER calculating unlock percentage
|
||||
if (currentRatio > highestRatio) {
|
||||
highestRatio = currentRatio;
|
||||
}
|
||||
}
|
||||
|
||||
// Check that unlock percentage doesn't exceed maximum
|
||||
require(unlockPercentage <= maxUnlockPercentage, "Unlock percentage high");
|
||||
|
||||
// Update the existing epoch entry
|
||||
epochs[epochId] = Epoch({
|
||||
estDaysRemaining: estDaysRemaining,
|
||||
currentTreasuryTvl: currentTreasuryTvl,
|
||||
totalLiability: _currentLiability,
|
||||
paybackPercent: _paybackPercent,
|
||||
unlockPercentage: unlockPercentage,
|
||||
timestamp: block.timestamp
|
||||
});
|
||||
|
||||
emit EpochEnded(epochId, currentTreasuryTvl, unlockPercentage, _paybackPercent);
|
||||
}
|
||||
|
||||
/// @notice Calculate total unclaimed funds for a user across all epochs since last claim
|
||||
function calculateUnclaimedFunds(address user) public view returns (uint256 totalUnclaimed) {
|
||||
uint256 remainingStake = getNetStake(user);
|
||||
@@ -452,8 +502,8 @@ contract CunaFinanceSonic is Initializable, ReentrancyGuardUpgradeable {
|
||||
transferAmount = amount / 1e12; // Convert from 18 decimals to 6 decimals
|
||||
}
|
||||
|
||||
// Decrement withdraw liabilities for all tokens (using original 18-decimal amount)
|
||||
withdrawLiabilities[token] -= amount;
|
||||
// Decrement withdraw liabilities (using correct decimal precision)
|
||||
withdrawLiabilities[token] -= transferAmount;
|
||||
|
||||
// Transfer tokens to user based on the specified token (using converted amount)
|
||||
IERC20(token).safeTransfer(msg.sender, transferAmount);
|
||||
@@ -507,35 +557,35 @@ contract CunaFinanceSonic is Initializable, ReentrancyGuardUpgradeable {
|
||||
|
||||
// Bot Functions for Staking Management
|
||||
|
||||
/// @notice Create a withdraw stake for a user (for admin/migration purposes)
|
||||
/// @dev Only to be used by bots for manual withdraw stake creation
|
||||
/// @param user The user address to create the withdraw stake for
|
||||
/// @param amount The amount for the withdraw stake
|
||||
/// @param unlockTime The unlock timestamp for the withdraw stake
|
||||
/// @param token The token address for the withdraw stake
|
||||
/// @param isVesting Whether this is a vesting-related stake (adds 1e6 to stakeId)
|
||||
function createWithdrawStakeForUser(address user, uint256 amount, uint256 unlockTime, address token, bool isVesting) external onlyBot {
|
||||
require(user != address(0), "Invalid user address");
|
||||
require(amount > 0, "Invalid amount");
|
||||
require(token != address(0), "Invalid token address");
|
||||
// /// @notice Create a withdraw stake for a user (for admin/migration purposes)
|
||||
// /// @dev Only to be used by bots for manual withdraw stake creation
|
||||
// /// @param user The user address to create the withdraw stake for
|
||||
// /// @param amount The amount for the withdraw stake
|
||||
// /// @param unlockTime The unlock timestamp for the withdraw stake
|
||||
// /// @param token The token address for the withdraw stake
|
||||
// /// @param isVesting Whether this is a vesting-related stake (adds 1e6 to stakeId)
|
||||
// function createWithdrawStakeForUser(address user, uint256 amount, uint256 unlockTime, address token, bool isVesting) external onlyBot {
|
||||
// require(user != address(0), "Invalid user address");
|
||||
// require(amount > 0, "Invalid amount");
|
||||
// require(token != address(0), "Invalid token address");
|
||||
|
||||
// Generate unique stakeId
|
||||
stakeIdCounter++;
|
||||
uint256 finalStakeId = isVesting ? stakeIdCounter + 1e6 : stakeIdCounter;
|
||||
// // Generate unique stakeId
|
||||
// stakeIdCounter++;
|
||||
// uint256 finalStakeId = isVesting ? stakeIdCounter + 1e6 : stakeIdCounter;
|
||||
|
||||
// Create the withdraw stake
|
||||
withdrawStakes[user].push(WithdrawStake({
|
||||
stakeId: finalStakeId,
|
||||
amount: amount,
|
||||
unlockTime: unlockTime,
|
||||
token: token
|
||||
}));
|
||||
// // Create the withdraw stake
|
||||
// withdrawStakes[user].push(WithdrawStake({
|
||||
// stakeId: finalStakeId,
|
||||
// amount: amount,
|
||||
// unlockTime: unlockTime,
|
||||
// token: token
|
||||
// }));
|
||||
|
||||
// Increment withdraw liabilities for this token
|
||||
withdrawLiabilities[token] += amount;
|
||||
// // Increment withdraw liabilities for this token
|
||||
// withdrawLiabilities[token] += amount;
|
||||
|
||||
emit StakeWithdrawn(user, amount, finalStakeId);
|
||||
}
|
||||
// emit StakeWithdrawn(user, amount, finalStakeId);
|
||||
// }
|
||||
|
||||
/// @notice Batch create stakes for multiple users (efficient for migration)
|
||||
/// @dev Only to be used by bots for initial setup
|
||||
@@ -1201,8 +1251,8 @@ contract CunaFinanceSonic is Initializable, ReentrancyGuardUpgradeable {
|
||||
|
||||
// Only update liabilities and emit event if something was actually claimed
|
||||
if (totalBonusClaimed > 0) {
|
||||
// Increment withdraw liabilities for SONIC_TOKEN
|
||||
withdrawLiabilities[SONIC_TOKEN] += totalBonusClaimed;
|
||||
// Increment withdraw liabilities for SONIC_TOKEN (convert from 18 decimals to 6 decimals)
|
||||
withdrawLiabilities[SONIC_TOKEN] += totalBonusClaimed / 1e12;
|
||||
emit BonusClaimed(msg.sender, totalBonusClaimed);
|
||||
}
|
||||
}
|
||||
@@ -1284,44 +1334,11 @@ contract CunaFinanceSonic is Initializable, ReentrancyGuardUpgradeable {
|
||||
return totalClaimed[user];
|
||||
}
|
||||
|
||||
// /// @notice Search marketplace history for stakes where address was seller or buyer
|
||||
// /// @param targetAddress The address to search for as seller or buyer
|
||||
// /// @return Array of MarketplaceHistory structs where address was involved
|
||||
// function searchMarketplaceHistory(address targetAddress) external view returns (MarketplaceHistory[] memory) {
|
||||
// require(targetAddress != address(0), "Invalid address");
|
||||
|
||||
// // Count matches first to size the result array properly
|
||||
// uint256 matchCount = 0;
|
||||
// for (uint256 i = 0; i < marketplaceHistory.length; i++) {
|
||||
// if (marketplaceHistory[i].seller == targetAddress || marketplaceHistory[i].buyer == targetAddress) {
|
||||
// matchCount++;
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Return empty array if no matches
|
||||
// if (matchCount == 0) {
|
||||
// return new MarketplaceHistory[](0);
|
||||
// }
|
||||
|
||||
// // Create result array with exact size needed
|
||||
// MarketplaceHistory[] memory result = new MarketplaceHistory[](matchCount);
|
||||
// uint256 resultIndex = 0;
|
||||
|
||||
// // Populate result array
|
||||
// for (uint256 i = 0; i < marketplaceHistory.length; i++) {
|
||||
// if (marketplaceHistory[i].seller == targetAddress || marketplaceHistory[i].buyer == targetAddress) {
|
||||
// result[resultIndex] = marketplaceHistory[i];
|
||||
// resultIndex++;
|
||||
// }
|
||||
// }
|
||||
|
||||
// return result;
|
||||
// }
|
||||
|
||||
/// @notice Test function for upgrade verification
|
||||
/// @return Returns a constant value to verify upgrade worked
|
||||
function testUpgradeFunction() external pure returns (uint256) {
|
||||
return 999; // Different value from bsc_paca to distinguish contracts
|
||||
return 1002; // Added adjustWithdrawLiability admin function
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user