open-index/open-npm huggingface dataset:
npm package: @lifinity/sdk-v2
Description: lifinity sdk v2
Latest version: 2.0.3

# lifinity-sdk-v2

## Installation
```bash
yarn install @lifinity/sdk-v2
```

## Usage
- Get pools
```typescript
import { getPools, LIFINITY_PROGRAM_ID } from '@lifinity/sdk-v2';

const connection: Connection = new Connection("https://api.mainnet-beta.solana.com");
const pools = await getPools(connection);

console.log("pools =", pools);
```

- Get swap amount
```typescript
import { Connection, PublicKey } from '@solana/web3.js';
import { getAmountOut, LIFINITY_PROGRAM_ID } from '@lifinity/sdk-v2';

const connection: Connection = new Connection("https://api.mainnet-beta.solana.com");
const fromMint: PublicKey = new PublicKey("---Mint address of the input token---");
const toMint: PublicKey = new PublicKey("---Mint address of the output token---");
const amountIn: number = 1; // Input amount
const slippage: number = 1; // Slippage (%)

const pool = await getPool(connection, fromMint, toMint);
const ammData = await getAmm(connection, pool.ammPubkey);

const res = await getAmountOut(connection, ammData, amountIn, fromMint, slippage);

console.log("amountIn: number =", res.amountIn);
console.log("amountOut: number =", res.amountOut);
console.log("amountOutWithSlippage: number =", res.amountOutWithSlippage);
console.log("priceImpact: number =", res.priceImpact);
console.log("fee: number =", res.fee);
console.log("feePercent: number =", res.feePercent);
```

- Get swap instruction
```typescript
import { Connection, PublicKey } from '@solana/web3.js';
import { getSwapInstruction } from '@lifinity/sdk-v2'

const connection: Connection = new Connection("https://api.mainnet-beta.solana.com");
const ownerAccount: PublicKey = new PublicKey("---User's Solana address---")
const fromMint: PublicKey = new PublicKey("---Mint address of the input token---");
const toMint: PublicKey = new PublicKey("---Mint address of the output token---");
const amountIn: number = 1; // Input amount
const minimumOut: number = 100; // Output amount
const fromUserAccount: PublicKey = new PublicKey("---User's input token account---");
const toUserAccount: PublicKey = new PublicKey("---User's output token account---");

const pool = await getPool(connection, fromMint, toMint);
const ammData = await getAmm(connection, pool.ammPubkey);

const swapInstruction = await getSwapInstruction(connection, ownerAccount, amountIn, minimumOut, ammData, fromMint, toMint, fromUserAccount, toUserAccount);

console.log("swapInstruction: TransactionInstruction =", swapInstruction);
```

Copyright © 2022 LIFINITY FOUNDATION All Rights Reserved.
npm package: @lifinity/sdk-v2-eclipse
Description: lifinity sdk v2 eclipse
Latest version: 0.1.9

# lifinity-sdk-v2

## Installation
```bash
yarn install @lifinity/sdk-v2
```

## Usage
- Get pools
```typescript
import { getPools, LIFINITY_ECLIPSE_PROGRAM_ID } from '@lifinity/sdk-v2';

const connection: Connection = new Connection("https://api.mainnet-beta.solana.com");
const pools = await getPools(connection);

console.log("pools =", pools);
```

- Get swap amount
```typescript
import { Connection, PublicKey } from '@solana/web3.js';
import { getAmountOut, LIFINITY_ECLIPSE_PROGRAM_ID } from '@lifinity/sdk-v2';

const connection: Connection = new Connection("https://api.mainnet-beta.solana.com");
const fromMint: PublicKey = new PublicKey("---Mint address of the input token---");
const toMint: PublicKey = new PublicKey("---Mint address of the output token---");
const amountIn: number = 1; // Input amount
const slippage: number = 1; // Slippage (%)

const pool = await getPool(connection, fromMint, toMint);
const ammData = await getAmm(connection, pool.ammPubkey);

const res = await getAmountOut(connection, ammData, amountIn, fromMint, slippage);

console.log("amountIn: number =", res.amountIn);
console.log("amountOut: number =", res.amountOut);
console.log("amountOutWithSlippage: number =", res.amountOutWithSlippage);
console.log("priceImpact: number =", res.priceImpact);
console.log("fee: number =", res.fee);
console.log("feePercent: number =", res.feePercent);
```

- Get swap instruction
```typescript
import { Connection, PublicKey } from '@solana/web3.js';
import { getSwapInstruction } from '@lifinity/sdk-v2'

const connection: Connection = new Connection("https://api.mainnet-beta.solana.com");
const ownerAccount: PublicKey = new PublicKey("---User's Solana address---")
const fromMint: PublicKey = new PublicKey("---Mint address of the input token---");
const toMint: PublicKey = new PublicKey("---Mint address of the output token---");
const amountIn: number = 1; // Input amount
const minimumOut: number = 100; // Output amount
const fromUserAccount: PublicKey = new PublicKey("---User's input token account---");
const toUserAccount: PublicKey = new PublicKey("---User's output token account---");

const pool = await getPool(connection, fromMint, toMint);
const ammData = await getAmm(connection, pool.ammPubkey);

const swapInstruction = await getSwapInstruction(connection, ownerAccount, amountIn, minimumOut, ammData, fromMint, toMint, fromUserAccount, toUserAccount);

console.log("swapInstruction: TransactionInstruction =", swapInstruction);
```

Copyright © 2022 LIFINITY FOUNDATION All Rights Reserved.
npm package: @liflandgaming/tslint-config
Description: tslint shared config
Author: Nikita Shatunov
Latest version: 1.0.4

# tslint-config
tslint shared config

### Usage

`npm i -S @liflandgaming/tslint-config`

Add `tslint.json` file to root of your project with following code:

```json
{
  "extends": "@liflandgaming/tslint-config"
}
```
npm package: @liflig/cdk-cloudfront-auth
Description: CDK Constructs for adding authentication for a CloudFront Distribution
Latest version: 1.10.1

# CloudFront authorization with Cognito for CDK

Easily add Cognito-based authorization to your CloudFront distribution,
to place static files behind authorization.

This is based on https://github.com/aws-samples/cloudfront-authorization-at-edge.

## Usage

```bash
bun add @liflig/cdk-cloudfront-auth
```

Deploy the Lambda@Edge functions to us-east-1:

```ts
// In a stack deployed to us-east-1.
const authLambdas = new AuthLambdas(this, "AuthLambdas", {
  regions: ["eu-west-1"], // Regions to make Lambda version params available.
})
```

Deploy the Cognito and CloudFront setup in whatever region
of your choice:

```ts
const auth = new CloudFrontAuth(this, "Auth", {
  cognitoAuthDomain: `${domain.domainName}.auth.${region}.amazoncognito.com`,
  authLambdas, // AuthLambdas from above
  userPool, // Cognito User Pool
})
const distribution = new cloudfront.Distribution(this, "Distribution", {
  defaultBehavior: auth.createProtectedBehavior(origin),
  additionalBehaviors: auth.createAuthPagesBehaviors(origin),
})
auth.updateClient("ClientUpdate", {
  signOutUrl: `https://${distribution.distributionDomainName}${auth.signOutRedirectTo}`,
  callbackUrl: `https://${distribution.distributionDomainName}${auth.callbackPath}`,
})
```

If using `CloudFrontWebDistribution` instead of `Distribution`:

```ts
const distribution = new cloudfront.CloudFrontWebDistribution(this, "Distribution", {
  originConfigs: [
    {
      behaviors: [
        ...auth.authPages,
        {
          isDefaultBehavior: true,
          lambdaFunctionAssociations: auth.authFilters,
        },
      ],
    },
  ],
})
```

## Customizing authorization

The `CloudFrontAuth` construct accepts a `requireGroupAnyOf` property
that causes access to be restricted to only users in specific groups.
npm package: @liflig/cdk-lambda-config
Description: CDK Construct for adding config.json file to a Lambda Function
Latest version: 1.7.36

# CDK Construct for adding config.json file to a Lambda Function

When using Lambda@Edge, a function cannot use environment variables.
This CDK Construct uses a Custom Resource to inject a `config.json`
file with user provided values into an existing function, and
publishes a new version that is ready to be used as part of a
CloudFront Distribution.

Inspired by similar mechanism in https://github.com/aws-samples/cloudfront-authorization-at-edge/

## Usage

```bash
npm install @liflig/cdk-lambda-config
```

Using the construct:

```ts
const originalFunction = lambda.Function.fromFunctionArn(...)
const updatedFunction = new LambdaConfig(this, "UpdatedFunction", {
  function: originalFunction,
  config: {
    Key1: "Some value",
    Nested: {
      Key2: "Other value",
    },
  },
  nonce: "1", // See TSDoc.
})
// Can now retrieve the new version:
updatedFunction.version
```

Read from within the handler:

```ts
const fs = require("fs")
const path = require("path")
const config = JSON.parse(
  fs.readFileSync(path.join(__dirname, "config.json"), "utf-8"),
)
```