Skip to content

Commit

Permalink
fully repaid loans reward
Browse files Browse the repository at this point in the history
  • Loading branch information
dumedco committed Feb 28, 2024
1 parent 0042d08 commit dffbf86
Show file tree
Hide file tree
Showing 19 changed files with 4,669 additions and 8,861 deletions.
15 changes: 11 additions & 4 deletions contracts/microcredit/MicrocreditImplementation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ contract MicrocreditImplementation is
using SafeERC20Upgradeable for IERC20;
using EnumerableSet for EnumerableSet.AddressSet;

address public constant DEFAULT_LENDER_ADDRESS = 0xE6662E970CD54c154af8b9dEd54C95a69b133A5a;
uint256 public constant REWARD_MULTIPLIER = 10;

event MaintainerAdded(
address indexed maintainerAddress
);
Expand Down Expand Up @@ -644,12 +647,16 @@ contract MicrocreditImplementation is
_loan.lastComputedDate = _loan.lastComputedDate + _days * 86400;

if (_loan.lastComputedDebt == 0) {
if (address(microcreditManager) != address(0)) {
microcreditManager.addCompletedLoanToManager(_loan.managerAddress, msg.sender, _loanId);
}
// if (address(microcreditManager) != address(0)) {
// microcreditManager.addCompletedLoanToManager(_loan.managerAddress, msg.sender, _loanId);
// }

uint256 rewardAmount = (_loan.amountRepayed - _loan.amountBorrowed) * REWARD_MULTIPLIER;

if (address(donationMiner) != address(0)) {
donationMiner.donateVirtual(_loan.amountRepayed - _loan.amountBorrowed, msg.sender);
donationMiner.donateVirtual(rewardAmount, msg.sender);
donationMiner.donateVirtual(rewardAmount, _loan.managerAddress);
donationMiner.donateVirtual(rewardAmount, DEFAULT_LENDER_ADDRESS);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
deployer = accounts[0];

await deployNewDonationMinerImplementation();
await createCallProposal();
// await createCallProposal();
};

async function deployNewDonationMinerImplementation() {
console.log("Deploying new DonationMinerImplementation");
newDonationMinerImplementationAddress = (
await deploy('DonationMinerImplementation', {
await deploy('MicrocreditImplementation', {
from: deployer.address,
args: [],
log: true,
Expand Down
25 changes: 25 additions & 0 deletions deploy/prod/helpers/microcredit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
// @ts-ignore
const { deployments, ethers } = hre;
const { deploy } = deployments;

const accounts: SignerWithAddress[] = await ethers.getSigners();
const deployer = accounts[0];

await deploy(
"MicrocreditImplementation",
{
from: deployer.address,
args: [],
log: true,
// gasLimit: 13000000,
}
);
};

export default func;
func.tags = ["MicrocreditImplementation"];
20 changes: 14 additions & 6 deletions deploy/prod/helpers/transferOwnershipMethod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ let deployer: SignerWithAddress;

// mainnet
const governanceDelegatorAddress = "0x8f8BB984e652Cb8D0aa7C9D6712Ec2020EB1BAb4";
const targetAddress = "0x496F7De1420ad52659e257C7Aa3f79a995274dbc";
const target1Address = "0xFC641CE792c242EACcD545B7bee2028f187f61EC";
const target2Address = "0x1C51657af2ceBA3D5492bA0c5A17E562F7ba6593";
const newOwnerAddress = "0x0497b572842a178445fC29EbDDf6B220C40eE384";


// //alfajores
// const governanceDelegatorAddress = "0x5c27e2600a3eDEF53DE0Ec32F01efCF145419eDF";
// const targetAddress = "0x223b3b11e7eB4542178e787Ab1402f6b23261B84";
// const target1Address = "0x79f9ca5f1A01e1768b9C24AD37FF63A0199E3Fe5";
// const target2Address = "0x09Cdc8f50994F63103bc165B139631A6ad18EF49";
// const newOwnerAddress = "0x9bDD1df7e44c120C51E74E5C6FA2e0b41487De9F";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
Expand All @@ -36,17 +38,23 @@ async function createUpgradeImplementation() {
governanceDelegatorAddress,
deployer,
[
targetAddress,
target1Address,
target2Address,
],
[0],
[0, 0],
[
"transferOwnership(address)",
"transferOwnership(address)",
],
[["address"]],
[
["address"],
["address"]]
,
[
[newOwnerAddress],
[newOwnerAddress],
],
'Change contract ownership'
'Change contracts ownership'
);
}

Expand Down
1 change: 1 addition & 0 deletions deploy/test/microcredit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
await donationMiner.updateMicrocredit(microcreditContract.address);

await microcreditContract.updateDonationMiner(donationMiner.address);

await microcreditContract.updateUniswapRouter(uniswapRouterAddress);
await microcreditContract.updateUniswapQuoter(uniswapQuoterAddress);

Expand Down
320 changes: 236 additions & 84 deletions deployments/mainnet/DonationMinerImplementation.json

Large diffs are not rendered by default.

Loading

0 comments on commit dffbf86

Please sign in to comment.