# Wrote a payouts NPM package for the notebooks

**URL:** <https://discourse.sourcecred.io/t/wrote-a-payouts-npm-package-for-the-notebooks/273>\
**Category:** Didathing\
**Created:** [October 6, 2019, 4:58pm UTC](https://discourse.sourcecred.io/t/wrote-a-payouts-npm-package-for-the-notebooks/273 "2019-10-06T16:58:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Beanow](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sourcecred.io/beanow/32/98_2.png) [@Beanow](https://discourse.sourcecred.io/u/Beanow)\
**Post date:** [October 6, 2019, 4:58pm UTC](https://discourse.sourcecred.io/t/wrote-a-payouts-npm-package-for-the-notebooks/273/1 "2019-10-06T16:58:50Z")

</div>

> [@CredSperiment Week 2 Payouts](https://discourse.sourcecred.io/t/credsperiment-week-2-payouts/240/3):
>
> > Time to publish the code from this notebook into a package and `require('@sourcecred/payouts')` next?
> 
> Want to take a stab at this? 🙂

Said stab is starting to look pretty usable.

I’ve created a new repo [GitHub - sourcecred/payouts: Tooling to generate payout data from SourceCred.](https://github.com/sourcecred/payouts)

Which is published to NPM as [@sourcecred/payouts - npm](https://www.npmjs.com/package/@sourcecred/payouts)

And I’ve refactored the week2 payouts notebook to use it:

> **[SourceCred: CredSperiment Week 2 (@sourcecred/payouts based)](https://observablehq.com/@beanow/sourcecred-credsperiment-week-2-sourcecred-payouts-based)**
>
> To get a sense of why we need new ways to share rewards in open-source communities, and an overview of SourceCred and the CredSperiment you can check out this talk by @decentralion: Discussing these results! Please share your thoughts on the thread...

There are some discrepancies between it and [the original](https://observablehq.com/@decentralion/sourcecred-credsperiment-week-2):

- In the **Fast Payouts** table, the “% cred” column was incorrect in the original.  
`{name: "% cred", fn: (a) => fastPayout.get(a) / totalFastPayout, format: percentFormat}`  
This `fastPayout` and `totalFastPayout` represent mana, not cred.
- In the **Slow Payouts** table, the “Target total payout” column had a rounding issue.  
The original used `Math.round()` when _displaying_ and used the sum of _unrounded values_ for the total. The new version uses `Math.floor()` for each user, and uses the sum of _rounded values_ for the total.

---

<div class="post-metadata">

**Author:** ![Beanow](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sourcecred.io/beanow/32/98_2.png) [@Beanow](https://discourse.sourcecred.io/u/Beanow)\
**Post date:** [October 6, 2019, 5:14pm UTC](https://discourse.sourcecred.io/t/wrote-a-payouts-npm-package-for-the-notebooks/273/2 "2019-10-06T17:14:39Z")

</div>

Also, a request to include this repository in our instance.

> <https://github.com/sourcecred/cred/pull/1>

---

<div class="post-metadata">

**Author:** ![decentralion](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sourcecred.io/decentralion/32/7_2.png) [@decentralion](https://discourse.sourcecred.io/u/decentralion)\
**Post date:** [October 7, 2019, 4:00am UTC](https://discourse.sourcecred.io/t/wrote-a-payouts-npm-package-for-the-notebooks/273/3 "2019-10-07T04:00:39Z")

</div>

Thanks @Beanow! I’ll use it for the next canonical grain distribution.
