Comments (1)
Here is a simplified demo:
const Nimiq = require('@nimiq/core');
const balance = Nimiq.Policy.coinsToLunas(1500);
const start = 1000;
const stepBlocks = 100;
const stepAmount = Nimiq.Policy.coinsToLunas(100);
const totalAmount = Nimiq.Policy.coinsToLunas(1000);
const contract = new Nimiq.VestingContract(balance, Nimiq.Address.NULL, start, stepBlocks, stepAmount, totalAmount);
for (let block = 0; block <= 2000; block += 100) {
const minCap = contract.getMinCap(block);
const available = Math.max(0, balance - minCap);
console.log(`#${block}: min cap: ${Nimiq.Policy.lunasToCoins(minCap)}, available: ${Nimiq.Policy.lunasToCoins(available)}`);
}
and the result:
#0: min cap: 2000, available: 0
#100: min cap: 1900, available: 0
#200: min cap: 1800, available: 0
#300: min cap: 1700, available: 0
#400: min cap: 1600, available: 0
#500: min cap: 1500, available: 0
#600: min cap: 1400, available: 100
#700: min cap: 1300, available: 200
#800: min cap: 1200, available: 300
#900: min cap: 1100, available: 400
#1000: min cap: 1000, available: 500
#1100: min cap: 900, available: 600
#1200: min cap: 800, available: 700
#1300: min cap: 700, available: 800
#1400: min cap: 600, available: 900
#1500: min cap: 500, available: 1000
#1600: min cap: 400, available: 1100
#1700: min cap: 300, available: 1200
#1800: min cap: 200, available: 1300
#1900: min cap: 100, available: 1400
#2000: min cap: 0, available: 1500
in other words, getMinCap counts negative steps too.
Here is the contract from the testnet:
https://test.nimiq.watch/#NQ50+NE4C+8X7C+HFA5+7F58+DVPC+VC6C+UVEH+GE47
from core-js.
Related Issues (20)
- RPC method getRawTransactionInfo always returns inMempool: false
- minning by php script. HOT 2
- Metrics server without HTTPS
- Provide the loader as modern es6 module HOT 2
- Client transaction history returns knownTxs above the limit HOT 3
- Mempool.getTransactions() might scan entire mempool
- core-js won't build with Node 14 HOT 1
- ipv6 ws address parse wrong HOT 1
- Different number of confirmations returned by getTransactionByHash and getTransactionReceipt HOT 5
- Deno support HOT 1
- Add recurring payments (subscription)
- refactor dockerfiles HOT 1
- DEB package includes dev dependencies HOT 1
- github repo missing tag `v1.5.8` HOT 1
- looking for example HOT 2
- Apple M1 support HOT 13
- Building on node js 18 / Ubuntu 22.04 gives an error HOT 2
- Replace node-deb with standard deb creation tools
- Unable to build core-js using Node v22.1.0 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core-js.