open-index/open-npm huggingface dataset:
npm package: @hysteaks-js/ethers-sdk
Description: Typechain ethers-v6 SDK for Hysteaks contracts.
Latest version: 1.0.0

# @hysteaks-js/ethers-sdk

Auto generated TypeChain ethers.js v6 SDK for interacting with deployed contracts.

## Example Usage

### Batch Send - Native

```ts
import { HysteaksBatchSend__factory } from '@hysteaks-js/ethers-sdk';

const provider = new ethers.JsonRpcProvider('<HYCHAIN_RPC_URL>');

const batchSendContract = HysteaksBatchSend__factory.connect(
  '<BATCH_SEND_CONTRACT_ADDRESS>',
  provider,
);

const owner = new ethers.Wallet('<OWNER_PRIVATE_KEY>', provider);

const recipients = ['<RECIPIENT_1_ADDRESS>', '<RECIPIENT_2_ADDRESS>'];
const amounts = [ethers.parseEther('100'), ethers.parseEther('200')];

// The total amount is the sum of all the amounts to send plus the fee if the owner is not fee exempt

const totalAmount = amounts.reduce((a, b) => a + b, 0n);

const isFeeExempt = await batchSendContract.isFeeExempt(owner.address);

if (!isFeeExempt) {
  const fee = await batchSendContract.calculateFee(totalAmount);
  totalAmount += fee;
}

// Submit the transaction

batchSendContract.connect(owner).sendNativeBatch(recipients, amounts, {
  value: totalAmount,
});
```

### Batch Send - ERC20

```ts
import { HysteaksBatchSend__factory } from '@hysteaks-js/ethers-sdk';

const provider = new ethers.JsonRpcProvider('<HYCHAIN_RPC_URL>');

const batchSendContract = HysteaksBatchSend__factory.connect(
  '<BATCH_SEND_CONTRACT_ADDRESS>',
  provider,
);

const owner = new ethers.Wallet('<OWNER_PRIVATE_KEY>', provider);

// The token address is the address of the ERC20 token to send

const tokenAddress = '<TOKEN_ADDRESS>';

// NOTE: The owner must approve the batch send contract to spend the tokens on their behalf

// ... code to approve the batch send contract to spend the tokens on behalf of the owner ...

const recipients = ['<RECIPIENT_1_ADDRESS>', '<RECIPIENT_2_ADDRESS>'];
const amounts = [ethers.parseEther('100'), ethers.parseEther('200')];

// The total amount is the sum of all the amounts to send plus the fee if the owner is not fee exempt

const totalAmount = amounts.reduce((a, b) => a + b, 0n);

const isFeeExempt = await batchSendContract.isFeeExempt(owner.address);

if (!isFeeExempt) {
  const fee = await batchSendContract.calculateFee(totalAmount);
  totalAmount += fee;
}

// Submit the transaction

batchSendContract.connect(owner).sendERC20Batch(tokenAddress, recipients, amounts);
```
npm package: @hysteaks-js/reward-helpers
Description: Helper functions for performing reward calculations off-chain.
Latest version: 1.0.0

# Reward Helpers

This package contains helper functions for calculating reward distributions off chain.

## Installation

```bash
npm install @hysteaks-js/reward-helpers
```

## Usage

```typescript
import { even } from '@hysteaks-js/reward-helpers';

const amount = 100n;
const recipientCount = 5;
const result = even(amount, recipientCount);

console.log(result);
// [20n, 20n, 20n, 20n, 20n]
```

```typescript
import { weightedAmount } from '@hysteaks-js/reward-helpers';

const amount = 100n;
const weights = [1n, 2n, 3n, 4n];
const result = weightedAmount(amount, weights);
console.log(result);
// [10n, 20n, 30n, 40n]
```