mirror of
https://github.com/logos-co/staking.git
synced 2025-01-09 10:22:18 +00:00
formulas
This commit is contained in:
parent
d23afa676a
commit
2e1ec2b7a1
11
.gitignore
vendored
Normal file
11
.gitignore
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
node_modules
|
||||||
|
.env
|
||||||
|
coverage
|
||||||
|
coverage.json
|
||||||
|
typechain
|
||||||
|
typechain-types
|
||||||
|
|
||||||
|
# Hardhat files
|
||||||
|
cache
|
||||||
|
artifacts
|
||||||
|
|
73
contracts/Staking.sol
Normal file
73
contracts/Staking.sol
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
// SPDX-License-Identifier: UNLICENSED
|
||||||
|
pragma solidity ^0.8.9;
|
||||||
|
|
||||||
|
contract Staking {
|
||||||
|
|
||||||
|
uint256 stake;
|
||||||
|
uint256 max_boost;
|
||||||
|
uint256 lockup;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @notice Calculates the maximum multiplier points an account can have
|
||||||
|
function max_mp() public view returns(uint256){
|
||||||
|
return stake * (max_boost + lockup + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @notice Create multiplier points for an account
|
||||||
|
function mint_mp() public {
|
||||||
|
/**
|
||||||
|
factor = params['NUM_PERIODS_IN_YEAR']
|
||||||
|
mp_apy = (params["MP_APY"]/100.)/factor
|
||||||
|
|
||||||
|
# prev_state already accounts for partial state updates,
|
||||||
|
# in case other policies were applied before this one.
|
||||||
|
staked_tokens = prev_state['staked_tokens']
|
||||||
|
mps = prev_state['staked_mps']
|
||||||
|
max_staked_mps = prev_state['max_staked_mps']
|
||||||
|
active = prev_state['active']
|
||||||
|
|
||||||
|
delta_mps = active * np.minimum(
|
||||||
|
staked_tokens * mp_apy, max_staked_mps - mps
|
||||||
|
)
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @notice Create initial multiplier points for locked stake
|
||||||
|
function inital_mp() public {
|
||||||
|
/**
|
||||||
|
return np.where(lockup>0, stake * (lockup + 1), 0.)
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @notice Distribute rewards
|
||||||
|
function distribute_rewards() public {
|
||||||
|
/**
|
||||||
|
factor = params['NUM_PERIODS_IN_YEAR']
|
||||||
|
stake_apy = (params['CUMULATIVE_STAKE_APY']/100.)/factor
|
||||||
|
|
||||||
|
# prev_state already accounts for partial state updates,
|
||||||
|
# in case other policies were applied before this one.
|
||||||
|
staked = prev_state['staked_tokens']
|
||||||
|
mps = prev_state['staked_mps']
|
||||||
|
rewards = prev_state['rewards_emissions']
|
||||||
|
active = prev_state['active']
|
||||||
|
|
||||||
|
if stake_apy > 0.:
|
||||||
|
delta_rewards_tokens = stake_apy * active * (staked + mps)
|
||||||
|
|
||||||
|
else:
|
||||||
|
cs = ((staked + mps) * active).sum()
|
||||||
|
|
||||||
|
if cs > 0.:
|
||||||
|
delta_rewards_tokens = rewards * active * (staked + mps) / cs
|
||||||
|
|
||||||
|
else:
|
||||||
|
delta_rewards_tokens = np.zeros_like(prev_state['staked_tokens'])
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
6
hardhat.config.js
Normal file
6
hardhat.config.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
require("@nomicfoundation/hardhat-toolbox");
|
||||||
|
|
||||||
|
/** @type import('hardhat/config').HardhatUserConfig */
|
||||||
|
module.exports = {
|
||||||
|
solidity: "0.8.18",
|
||||||
|
};
|
4389
package-lock.json
generated
Normal file
4389
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
227
package.json
Normal file
227
package.json
Normal file
@ -0,0 +1,227 @@
|
|||||||
|
{
|
||||||
|
"devDependencies": {
|
||||||
|
"hardhat": "^2.14.0"
|
||||||
|
},
|
||||||
|
"name": "staking",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"main": "index.js",
|
||||||
|
"dependencies": {
|
||||||
|
"abort-controller": "^3.0.0",
|
||||||
|
"abstract-level": "^1.0.3",
|
||||||
|
"adm-zip": "^0.4.16",
|
||||||
|
"aes-js": "^3.0.0",
|
||||||
|
"agent-base": "^6.0.2",
|
||||||
|
"aggregate-error": "^3.1.0",
|
||||||
|
"ansi-colors": "^4.1.3",
|
||||||
|
"ansi-escapes": "^4.3.2",
|
||||||
|
"ansi-regex": "^5.0.1",
|
||||||
|
"ansi-styles": "^3.2.1",
|
||||||
|
"anymatch": "^3.1.3",
|
||||||
|
"argparse": "^2.0.1",
|
||||||
|
"balanced-match": "^1.0.2",
|
||||||
|
"base-x": "^3.0.9",
|
||||||
|
"base64-js": "^1.5.1",
|
||||||
|
"bech32": "^1.1.4",
|
||||||
|
"bigint-crypto-utils": "^3.2.2",
|
||||||
|
"binary-extensions": "^2.2.0",
|
||||||
|
"blakejs": "^1.2.1",
|
||||||
|
"bn.js": "^5.2.1",
|
||||||
|
"brace-expansion": "^1.1.11",
|
||||||
|
"braces": "^3.0.2",
|
||||||
|
"brorand": "^1.1.0",
|
||||||
|
"browser-level": "^1.0.1",
|
||||||
|
"browser-stdout": "^1.3.1",
|
||||||
|
"browserify-aes": "^1.2.0",
|
||||||
|
"bs58": "^4.0.1",
|
||||||
|
"bs58check": "^2.1.2",
|
||||||
|
"buffer": "^6.0.3",
|
||||||
|
"buffer-from": "^1.1.2",
|
||||||
|
"buffer-xor": "^1.0.3",
|
||||||
|
"busboy": "^1.6.0",
|
||||||
|
"bytes": "^3.1.2",
|
||||||
|
"call-bind": "^1.0.2",
|
||||||
|
"camelcase": "^6.3.0",
|
||||||
|
"case": "^1.6.3",
|
||||||
|
"catering": "^2.1.1",
|
||||||
|
"chalk": "^2.4.2",
|
||||||
|
"chokidar": "^3.5.3",
|
||||||
|
"ci-info": "^2.0.0",
|
||||||
|
"cipher-base": "^1.0.4",
|
||||||
|
"classic-level": "^1.3.0",
|
||||||
|
"clean-stack": "^2.2.0",
|
||||||
|
"cliui": "^7.0.4",
|
||||||
|
"color-convert": "^1.9.3",
|
||||||
|
"color-name": "^1.1.3",
|
||||||
|
"command-exists": "^1.2.9",
|
||||||
|
"commander": "^3.0.2",
|
||||||
|
"concat-map": "^0.0.1",
|
||||||
|
"cookie": "^0.4.2",
|
||||||
|
"crc-32": "^1.2.2",
|
||||||
|
"create-hash": "^1.2.0",
|
||||||
|
"create-hmac": "^1.1.7",
|
||||||
|
"debug": "^4.3.4",
|
||||||
|
"decamelize": "^4.0.0",
|
||||||
|
"depd": "^2.0.0",
|
||||||
|
"diff": "^5.0.0",
|
||||||
|
"elliptic": "^6.5.4",
|
||||||
|
"emoji-regex": "^8.0.0",
|
||||||
|
"enquirer": "^2.3.6",
|
||||||
|
"env-paths": "^2.2.1",
|
||||||
|
"escalade": "^3.1.1",
|
||||||
|
"escape-string-regexp": "^1.0.5",
|
||||||
|
"ethereum-cryptography": "^1.2.0",
|
||||||
|
"ethereumjs-abi": "^0.6.8",
|
||||||
|
"ethereumjs-util": "^6.2.1",
|
||||||
|
"ethers": "^5.7.2",
|
||||||
|
"ethjs-util": "^0.1.6",
|
||||||
|
"event-target-shim": "^5.0.1",
|
||||||
|
"evp_bytestokey": "^1.0.3",
|
||||||
|
"fill-range": "^7.0.1",
|
||||||
|
"find-up": "^2.1.0",
|
||||||
|
"flat": "^5.0.2",
|
||||||
|
"follow-redirects": "^1.15.2",
|
||||||
|
"fp-ts": "^1.19.3",
|
||||||
|
"fs-extra": "^7.0.1",
|
||||||
|
"fs.realpath": "^1.0.0",
|
||||||
|
"function-bind": "^1.1.1",
|
||||||
|
"functional-red-black-tree": "^1.0.1",
|
||||||
|
"get-caller-file": "^2.0.5",
|
||||||
|
"get-intrinsic": "^1.2.1",
|
||||||
|
"glob": "^7.2.0",
|
||||||
|
"glob-parent": "^5.1.2",
|
||||||
|
"graceful-fs": "^4.2.11",
|
||||||
|
"has": "^1.0.3",
|
||||||
|
"has-flag": "^3.0.0",
|
||||||
|
"has-proto": "^1.0.1",
|
||||||
|
"has-symbols": "^1.0.3",
|
||||||
|
"hash-base": "^3.1.0",
|
||||||
|
"hash.js": "^1.1.7",
|
||||||
|
"he": "^1.2.0",
|
||||||
|
"hmac-drbg": "^1.0.1",
|
||||||
|
"http-errors": "^2.0.0",
|
||||||
|
"https-proxy-agent": "^5.0.1",
|
||||||
|
"iconv-lite": "^0.4.24",
|
||||||
|
"ieee754": "^1.2.1",
|
||||||
|
"immutable": "^4.3.0",
|
||||||
|
"indent-string": "^4.0.0",
|
||||||
|
"inflight": "^1.0.6",
|
||||||
|
"inherits": "^2.0.4",
|
||||||
|
"io-ts": "^1.10.4",
|
||||||
|
"is-binary-path": "^2.1.0",
|
||||||
|
"is-buffer": "^2.0.5",
|
||||||
|
"is-extglob": "^2.1.1",
|
||||||
|
"is-fullwidth-code-point": "^3.0.0",
|
||||||
|
"is-glob": "^4.0.3",
|
||||||
|
"is-hex-prefixed": "^1.0.0",
|
||||||
|
"is-number": "^7.0.0",
|
||||||
|
"is-plain-obj": "^2.1.0",
|
||||||
|
"is-unicode-supported": "^0.1.0",
|
||||||
|
"js-sdsl": "^4.4.0",
|
||||||
|
"js-sha3": "^0.8.0",
|
||||||
|
"js-yaml": "^4.1.0",
|
||||||
|
"jsonfile": "^4.0.0",
|
||||||
|
"keccak": "^3.0.3",
|
||||||
|
"klaw": "^1.3.1",
|
||||||
|
"level": "^8.0.0",
|
||||||
|
"level-supports": "^4.0.1",
|
||||||
|
"level-transcoder": "^1.0.1",
|
||||||
|
"locate-path": "^2.0.0",
|
||||||
|
"lodash": "^4.17.21",
|
||||||
|
"log-symbols": "^4.1.0",
|
||||||
|
"lru-cache": "^5.1.1",
|
||||||
|
"lru_map": "^0.3.3",
|
||||||
|
"mcl-wasm": "^0.7.9",
|
||||||
|
"md5.js": "^1.3.5",
|
||||||
|
"memory-level": "^1.0.0",
|
||||||
|
"memorystream": "^0.3.1",
|
||||||
|
"minimalistic-assert": "^1.0.1",
|
||||||
|
"minimalistic-crypto-utils": "^1.0.1",
|
||||||
|
"minimatch": "^3.1.2",
|
||||||
|
"mnemonist": "^0.38.5",
|
||||||
|
"module-error": "^1.0.2",
|
||||||
|
"ms": "^2.1.2",
|
||||||
|
"nanoid": "^3.3.3",
|
||||||
|
"napi-macros": "^2.2.2",
|
||||||
|
"node-addon-api": "^2.0.2",
|
||||||
|
"node-gyp-build": "^4.6.0",
|
||||||
|
"normalize-path": "^3.0.0",
|
||||||
|
"object-inspect": "^1.12.3",
|
||||||
|
"obliterator": "^2.0.4",
|
||||||
|
"once": "^1.4.0",
|
||||||
|
"os-tmpdir": "^1.0.2",
|
||||||
|
"p-limit": "^1.3.0",
|
||||||
|
"p-locate": "^2.0.0",
|
||||||
|
"p-map": "^4.0.0",
|
||||||
|
"p-try": "^1.0.0",
|
||||||
|
"path-exists": "^3.0.0",
|
||||||
|
"path-is-absolute": "^1.0.1",
|
||||||
|
"path-parse": "^1.0.7",
|
||||||
|
"pbkdf2": "^3.1.2",
|
||||||
|
"picomatch": "^2.3.1",
|
||||||
|
"qs": "^6.11.1",
|
||||||
|
"queue-microtask": "^1.2.3",
|
||||||
|
"randombytes": "^2.1.0",
|
||||||
|
"raw-body": "^2.5.2",
|
||||||
|
"readable-stream": "^3.6.2",
|
||||||
|
"readdirp": "^3.6.0",
|
||||||
|
"require-directory": "^2.1.1",
|
||||||
|
"require-from-string": "^2.0.2",
|
||||||
|
"resolve": "^1.17.0",
|
||||||
|
"rimraf": "^2.7.1",
|
||||||
|
"ripemd160": "^2.0.2",
|
||||||
|
"rlp": "^2.2.7",
|
||||||
|
"run-parallel-limit": "^1.1.0",
|
||||||
|
"rustbn.js": "^0.2.0",
|
||||||
|
"safe-buffer": "^5.1.2",
|
||||||
|
"safer-buffer": "^2.1.2",
|
||||||
|
"scrypt-js": "^3.0.1",
|
||||||
|
"secp256k1": "^4.0.3",
|
||||||
|
"semver": "^6.3.0",
|
||||||
|
"serialize-javascript": "^6.0.0",
|
||||||
|
"setimmediate": "^1.0.5",
|
||||||
|
"setprototypeof": "^1.2.0",
|
||||||
|
"sha.js": "^2.4.11",
|
||||||
|
"side-channel": "^1.0.4",
|
||||||
|
"solc": "^0.7.3",
|
||||||
|
"source-map": "^0.6.1",
|
||||||
|
"source-map-support": "^0.5.21",
|
||||||
|
"stacktrace-parser": "^0.1.10",
|
||||||
|
"statuses": "^2.0.1",
|
||||||
|
"streamsearch": "^1.1.0",
|
||||||
|
"string-width": "^4.2.3",
|
||||||
|
"string_decoder": "^1.3.0",
|
||||||
|
"strip-ansi": "^6.0.1",
|
||||||
|
"strip-hex-prefix": "^1.0.0",
|
||||||
|
"strip-json-comments": "^3.1.1",
|
||||||
|
"supports-color": "^5.5.0",
|
||||||
|
"tmp": "^0.0.33",
|
||||||
|
"to-regex-range": "^5.0.1",
|
||||||
|
"toidentifier": "^1.0.1",
|
||||||
|
"tslib": "^1.14.1",
|
||||||
|
"tsort": "^0.0.1",
|
||||||
|
"tweetnacl": "^1.0.3",
|
||||||
|
"tweetnacl-util": "^0.15.1",
|
||||||
|
"type-fest": "^0.21.3",
|
||||||
|
"undici": "^5.22.1",
|
||||||
|
"universalify": "^0.1.2",
|
||||||
|
"unpipe": "^1.0.0",
|
||||||
|
"util-deprecate": "^1.0.2",
|
||||||
|
"uuid": "^8.3.2",
|
||||||
|
"workerpool": "^6.2.1",
|
||||||
|
"wrap-ansi": "^7.0.0",
|
||||||
|
"wrappy": "^1.0.2",
|
||||||
|
"ws": "^7.5.9",
|
||||||
|
"y18n": "^5.0.8",
|
||||||
|
"yallist": "^3.1.1",
|
||||||
|
"yargs": "^16.2.0",
|
||||||
|
"yargs-parser": "^20.2.4",
|
||||||
|
"yargs-unparser": "^2.0.0",
|
||||||
|
"yocto-queue": "^0.1.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "mocha"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"description": ""
|
||||||
|
}
|
32
scripts/deploy.js
Normal file
32
scripts/deploy.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// We require the Hardhat Runtime Environment explicitly here. This is optional
|
||||||
|
// but useful for running the script in a standalone fashion through `node <script>`.
|
||||||
|
//
|
||||||
|
// You can also run a script with `npx hardhat run <script>`. If you do that, Hardhat
|
||||||
|
// will compile your contracts, add the Hardhat Runtime Environment's members to the
|
||||||
|
// global scope, and execute the script.
|
||||||
|
const hre = require("hardhat");
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const currentTimestampInSeconds = Math.round(Date.now() / 1000);
|
||||||
|
const unlockTime = currentTimestampInSeconds + 60;
|
||||||
|
|
||||||
|
const lockedAmount = hre.ethers.utils.parseEther("0.001");
|
||||||
|
|
||||||
|
const Lock = await hre.ethers.getContractFactory("Lock");
|
||||||
|
const lock = await Lock.deploy(unlockTime, { value: lockedAmount });
|
||||||
|
|
||||||
|
await lock.deployed();
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`Lock with ${ethers.utils.formatEther(
|
||||||
|
lockedAmount
|
||||||
|
)}ETH and unlock timestamp ${unlockTime} deployed to ${lock.address}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// We recommend this pattern to be able to use async/await everywhere
|
||||||
|
// and properly handle errors.
|
||||||
|
main().catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
process.exitCode = 1;
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user