Skip to content

Commit

Permalink
microcredit upgrade on mainnet
Browse files Browse the repository at this point in the history
  • Loading branch information
dumedco committed Nov 17, 2023
1 parent 2e771e2 commit f4800bd
Show file tree
Hide file tree
Showing 13 changed files with 2,620 additions and 596 deletions.
194 changes: 114 additions & 80 deletions .openzeppelin/celo-alfajores.json

Large diffs are not rendered by default.

29 changes: 25 additions & 4 deletions contracts/microcredit/MicrocreditImplementation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,29 @@ contract MicrocreditImplementation is
uint256 _dailyInterest,
uint256 _claimDeadline
) external override onlyManagers {
_addLoan(_tokenAddress, _userAddress, _amount, _period, _dailyInterest, _claimDeadline);
_addLoan(_userAddress, _tokenAddress, _amount, _period, _dailyInterest, _claimDeadline);
}

/**
* @notice Adds a loan
*
* @param _userAddress address of the user
* @param _amount amount of the loan
* @param _period period of the loan
* @param _dailyInterest daily interest of the loan
* @param _claimDeadline claim deadline of the loan
*/
function addLoan(
address _userAddress,
uint256 _amount,
uint256 _period,
uint256 _dailyInterest,
uint256 _claimDeadline
) external override onlyManagers {
_addLoan(_userAddress, address(cUSD), _amount, _period, _dailyInterest, _claimDeadline);
}


/**
* @notice Adds multiples loans
*
Expand Down Expand Up @@ -717,8 +737,8 @@ contract MicrocreditImplementation is
}

function _addLoan(
address _tokenAddress,
address _userAddress,
address _tokenAddress,
uint256 _amount,
uint256 _period,
uint256 _dailyInterest,
Expand Down Expand Up @@ -908,11 +928,12 @@ contract MicrocreditImplementation is
);
}

function initV2() external onlyOwner {
function initV2(uint256 _from, uint256 _to) external onlyOwner {
uint256 _userId;
uint256 _loanId;

for (_userId = 0; _userId < _usersLength; _userId++) {
_to = _to < _usersLength ? _to : _usersLength;
for (_userId = _from; _userId < _to; _userId++) {
for (_loanId = 0; _loanId < _users[_userId].loansLength; _loanId++) {
_users[_userId].loans[_loanId].tokenAddress = address(cUSD);
_users[_userId].loans[_loanId].tokenAmountBorrowed = _users[_userId].loans[_loanId].amountBorrowed;
Expand Down
7 changes: 7 additions & 0 deletions contracts/microcredit/interfaces/IMicrocredit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ interface IMicrocredit {
uint256 dailyInterest,
uint256 claimDeadline
) external;
function addLoan(
address userAddress,
uint256 amount,
uint256 period,
uint256 dailyInterest,
uint256 claimDeadline
) external;
function addLoans(
address[] calldata userAddresses,
address[] calldata tokenAddresses,
Expand Down
54 changes: 54 additions & 0 deletions deploy/prod/helpers/ambassadors.replaceEntityAccount.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { deployments, ethers } from "hardhat";
import { createProposal, toEther } from "../../../test/utils/helpers";
import * as ethersTypes from "ethers";
import {getExchangePathProd} from "../../../test/utils/uniswap";

const { deploy } = deployments;
let deployer: SignerWithAddress;

// mainnet
const governanceDelegatorAddress = "0x8f8BB984e652Cb8D0aa7C9D6712Ec2020EB1BAb4";
const ambassadorsAddress = "0x25f58d8C2522dC7E0C53cF8163C837De2415Ba51";
const newOldAddress = "0x266f8E061AD13dDF79Cb662FF633Ddb6dd40725d";
const newEntityAddress = "0xd3762200407133f7dDd5FE6073300fea3CaC948a";

// // //alfajores
// const governanceDelegatorAddress = "0x5c27e2600a3eDEF53DE0Ec32F01efCF145419eDF";
// const ambassadorsAddress = "0xF7f1675e5A6fa5D2dd4F3b534a59B5B6Ef866221";
// const newEntityAddress = "0x1FfceAF524aB1a882a1FD5E17ba650F33A969094";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const accounts: SignerWithAddress[] = await ethers.getSigners();
deployer = accounts[0];

await createCallProposal();
};

async function createCallProposal() {
console.log("Creating new proposal");

await createProposal(
governanceDelegatorAddress,
deployer,
[
ambassadorsAddress,
],
[0],
[
"replaceEntityAccount(address,address)"
],
[
["address","address"]
],
[
[newOldAddress, newEntityAddress]
],
'Ambassadors - replaceEntityAccount'
);
}

export default func;
func.tags = ["Ambassadors_replaceEntityAccount"];
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ const donationMinerProxyAddress = "0x09Cdc8f50994F63103bc165B139631A6ad18EF49";
const proxyAdminAddress = "0x79f9ca5f1A01e1768b9C24AD37FF63A0199E3Fe5";
const recurringCronAddress = "0x8903B83B6e1B1379f41a9cc82080Be10E1c8E6d3";


let GovernanceProxy: ethersTypes.Contract;

let newDonationMinerImplementationAddress: string;


Expand All @@ -35,11 +32,6 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const accounts: SignerWithAddress[] = await ethers.getSigners();
deployer = accounts[0];

GovernanceProxy = await ethers.getContractAt(
"PACTDelegate",
governanceDelegatorAddress
);

await deployNewDonationMinerImplementation();
await createCallProposal();
};
Expand All @@ -59,7 +51,7 @@ async function createCallProposal() {
console.log("Creating new proposal");

await createProposal(
GovernanceProxy,
governanceDelegatorAddress,
deployer,
[
proxyAdminAddress,
Expand Down
208 changes: 104 additions & 104 deletions deployments/alfajores/MicrocreditImplementation.json

Large diffs are not rendered by default.

532 changes: 532 additions & 0 deletions deployments/alfajores/solcInputs/e8151c3a25592c6ef1927bad91d3e2de.json

Large diffs are not rendered by default.

Loading

0 comments on commit f4800bd

Please sign in to comment.