This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity 0.8.7; | |
import {Test, console2} from "forge-std/Test.sol"; | |
import {Curves} from "contracts/Curves.sol"; | |
import {CurvesERC20Factory} from "contracts/CurvesERC20Factory.sol"; | |
import {FeeSplitter} from "contracts/FeeSplitter.sol"; | |
contract CurvesTest is Test { | |
Curves curves; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// run this script in a nodejs environment | |
let {privateKey, publicKey} = crypto.generateKeyPairSync("rsa", {modulusLength: 512}) | |
publickKey = publicKey.export({type: "pkcs1", format: "pem"}) | |
privateKey = privateKey.export({type: "pkcs1", format: "pem"}) | |
// publicKey value | |
// '-----BEGIN RSA PUBLIC KEY-----\n' + | |
// 'MEgCQQC5GmUc8KaG8LuRYu0KmuAuMkqX8hEhjEXeWaXZpg6rz8CTLsKK1JaTnrqk\n' + | |
// 'G9jVrJExmZ+jqXk7Ll5awzDRbV/HAgMBAAE=\n' + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const bs58 = require('bs58'); | |
const axios = require("axios"); | |
const triggerUrl = "https://api.trongrid.io/wallet/triggerconstantcontract"; | |
const energyUnitUrl = "https://api.trongrid.io/wallet/getenergyprices"; | |
// amount should not include decimals | |
// sender and receiver should be in base58 | |
async function getFee(sender, receiver, amount) { | |
const decimals = 10**6; //USDT decimals |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//nodejs | |
const axios = require('axios') | |
async function getCurrentGasPrices() { | |
let response = await axios.get('https://bscgas.info/gas') | |
let prices = { | |
slow: response.data.slow, | |
standard: response.data.standard, | |
fast: response.data.fast, | |
instant: response.data.instant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function claimRewards(address _lpToken) public override { | |
updatePool(_lpToken); | |
Pool memory pool = pools[_lpToken]; | |
Miner storage miner = miners[_lpToken][msg.sender]; | |
BonusToken memory bonusToken = bonusTokens[_lpToken]; | |
_claimCoverRewards(pool, miner); | |
_claimBonus(bonusToken, miner); | |
// update writeoff to match current acc rewards & bonus per token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function deposit(address _lpToken, uint256 _amount) external override { | |
require(block.timestamp >= START_TIME , "Blacksmith: not started"); | |
require(_amount > 0, "Blacksmith: amount is 0"); | |
Pool memory pool = pools[_lpToken]; | |
require(pool.lastUpdatedAt > 0, "Blacksmith: pool does not exists"); | |
require(IERC20(_lpToken).balanceOf(msg.sender) >= _amount, "Blacksmith: insufficient balance"); | |
updatePool(_lpToken); | |
Miner storage miner = miners[_lpToken][msg.sender]; | |
BonusToken memory bonusToken = bonusTokens[_lpToken]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Pool { | |
uint256 weight; // the allocation weight for pool | |
uint256 accRewardsPerToken; // accumulated COVER to the lastUpdated Time | |
uint256 lastUpdatedAt; // last accumulated rewards update timestamp | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body> | |
<head> | |
Just testing gists | |
</head> | |
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Miner { | |
uint256 amount; | |
uint256 rewardWriteoff; // the amount of COVER tokens to write off when calculate rewards from last update | |
uint256 bonusWriteoff; // the amount of bonus tokens to write off when calculate rewards from last update | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let gucci = “Gucci”; | |
let versace = “Versace”; | |
//We shall swap the values of versace and gucci variables | |
//Pre-ES6 | |
let temp = gucci; | |
gucci = versace; | |
versace = gucci; | |
console.log(versace, “is better than”, gucci); | |
//Output: Gucci is better than Versace. |
NewerOlder