Skip to content

Instantly share code, notes, and snippets.

View Rubilmax's full-sized avatar
🔥
Building the next EVM UI

Romain Milon Rubilmax

🔥
Building the next EVM UI
View GitHub Profile
@Rubilmax
Rubilmax / MorphoBorrower.js
Created August 18, 2022 16:58
Morpho Borrower Off-Chain (Javascript)
import ethers from "ethers";
const signer = new ethers.Wallet(
"PRIVATE_KEY",
new ethers.providers.JsonRpcBatchProvider("RPC_URL")
);
const signerAddress = await signer.getAddress();
const cEthAddress = "0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5";
@Rubilmax
Rubilmax / MorphoSupplier.js
Last active August 19, 2022 06:54
Morpho Supplier Off-Chain (Javascript)
import ethers from "ethers";
const signer = new ethers.Wallet(
"PRIVATE_KEY",
new ethers.providers.JsonRpcBatchProvider("RPC_URL")
);
const signerAddress = await signer.getAddress();
const cEthAddress = "0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5";
@Rubilmax
Rubilmax / MorphoRewardsTracker.sol
Created August 18, 2022 16:49
Morpho Rewards Tracker Smart Contract (Solidity)
// SPDX-License-Identifier: GNU AGPLv3
pragma solidity ^0.8.16;
import {ILens} from "@morpho-dao/morpho-core-v1/contracts/compound/interfaces/ILens.sol";
contract MorphoRewardsTracker {
address public constant CWBTC2 = 0xccF4429DB6322D5C611ee964527D42E5d685DD6a;
address public constant LENS = 0x930f1b46e1D081Ec1524efD95752bE3eCe51EF67;
@Rubilmax
Rubilmax / MorphoBorrower.sol
Created August 18, 2022 16:49
Morpho Borrower Smart Contract (Solidity)
// SPDX-License-Identifier: GNU AGPLv3
pragma solidity ^0.8.16;
import {ILens} from "@morpho-dao/morpho-core-v1/contracts/compound/interfaces/ILens.sol";
import {IMorpho} from "@morpho-dao/morpho-core-v1/contracts/compound/interfaces/IMorpho.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {CompoundMath} from "@morpho-dao/morpho-utils/src/math/CompoundMath.sol";
interface IWETH9 {
@Rubilmax
Rubilmax / MorphoSupplier.sol
Last active August 18, 2022 16:50
Morpho Supplier Smart Contract (Solidity)
// SPDX-License-Identifier: GNU AGPLv3
pragma solidity ^0.8.16;
import {ILens} from "@morpho-dao/morpho-core-v1/contracts/compound/interfaces/ILens.sol";
import {IMorpho} from "@morpho-dao/morpho-core-v1/contracts/compound/interfaces/IMorpho.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {CompoundMath} from "@morpho-dao/morpho-utils/src/math/CompoundMath.sol";
interface IWETH9 {
@Rubilmax
Rubilmax / index.js
Last active June 11, 2020 17:41
Multichat's logic
// we keep track of connections ourselves as suggested in peerjs's documentation
addConnection: function (conn) {
this.connections[conn.peer] = conn;
this.updatePeerIds();
console.log(`Connected to ${conn.peer}!`);
},
removeConnection: function (conn) {
delete this.connections[conn.peer];
this.updatePeerIds();
@Rubilmax
Rubilmax / index.js
Last active June 11, 2020 16:45
Multichat's script
const appPrefix = "secure-p2p-multichat-"; // the prefix we will preprend to usernames
const oldChats = localStorage.getItem("chats");
const chats = oldChats ? JSON.parse(oldChats) : []; // oldChats may be undefined, which throws error if passed into JSON.parse
const app = new Vue({
el: "#app",
data: {
screen: "login", // initialize at login screen
usernameInput: localStorage.getItem("username"), // to load saved username
@Rubilmax
Rubilmax / index.html
Created June 11, 2020 16:00
Multichat's screens
<div id="login" v-if="screen === 'login'">
<div class="container">
<h1>Enter your username</h1>
<div class="row">
<form v-on:submit="submitLogin">
<div class="input-field col s8">
<input :disabled="loading" id="username" type="text" v-model="usernameInput" />
<label for="username">My username</label>
</div>
@Rubilmax
Rubilmax / index.html
Last active June 11, 2020 16:01
Multichat's skeleton
<!DOCTYPE html>
<html lang="en">
<head>
<title>Serverless, secure & persistent multichat</title>
<!-- To efficiently implement sockets -->
<script src="https://unpkg.com/peerjs@1.2.0/dist/peerjs.min.js"></script>
<!-- To easily manage dynamic rendering -->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>