0.0.53 • Published 2 years ago

cremav2-sdk v0.0.53

Weekly downloads
-
License
AGPL-3.0
Repository
-
Last release
2 years ago

LICENSE crema language

What is Crema-SDK-V2

CLMM means concentrated liquidity market maker, it's crema sdk for new swap protocal. Crema is a open-source concentrated liquidity market maker on the Solana BlockChain . The new version of crema increases the capital efficiency of decentralized exchanges.

This repository contains the typescript sdk(@cremafinance/crema-sdk-v2), which help you interact with a deployed program.

Community

You can join these groups and chats to discuss and ask clmm-sdk-v2 related questions:

How to use Crema-SDK-V2?

Installation

yarn add @cremafinance/crema-sdk-v2

Test

You can use yarn test to test crema instructions in ./test/instructions.

Use case:

We will show you the pseudocode example, specific method of application you can read ./integration/jupiter/example or ./tests/instructions/xx.test.ts

Pseudocode Example

    // swap quote structa
    // import type { SwapQuote, SwapQuoteParam } from "@cremafinance/crema-sdk-v2/quote/public/swap";
    type SwapQuote = {
        estimatedAmountIn: u64;
        estimatedAmountOut: u64;
        estimatedEndSqrtPrice: BN;
        estimatedFeeAmount: u64;
        isExceed: boolean;
        aToB: boolean;
        byAmountIn: boolean;
        amount: BN;
    };

    const ix = sdk.ctx.program.instruction.swapWithPartner(
        aToB,           // weather change token_a for token_b
        byAmountIn,     // weather amount of fixed input 
        amount,         // the amount of token
        amountLimit,    // calculate by simulate swap quote result and slippage
        sqrtPriceLimit, // max or min sqrt price limit(depend on aToB)
        {
          accounts: {
            clmmConfig,
            clmmpool,
            tokenA,
            tokenB,
            accountA,
            accountB,
            tokenAVault,
            tokenBVault,
            tickArrayMap, // get this account by getTickArrayMapPDA(...).publicKey
            owner,
            partner,      // partner of integration
            partnerAtaA,  // partner's associated token account of token_a
            partnerAtaB,  // partner's associated token account of token_b
            tokenProgram: TOKEN_PROGRAM_ID,
          },
          // Get tick arrays address by createTickArrayRange first, then get theirs account data by fetcher,getTickData().
          remainingAccounts, 
        }
      );

Structure

|____integration
| |____jupiter
|____src
| |____cli
| |____errors
| |____idls
| | |____clmmpool.json
| | |____clmmpool.ts
| |____impl
| |____math
| |____network
| |____quotes
| | |____swap
| | |____public
| |____types
| |____utils
| |____clmmpool-client.ts
| |____context.ts
| |____index.ts
| |____ix.ts
|____test
| |____instructions
| |____utils
|____package.json
|____README.md

Folder Details

  • intergation: the sdk interface of the dex intergation, such as jupiter.
  • src: the main content of crema sdk v2.
    • cli: The cli to develop complete applications.
    • error: The error type in crema program.
    • idls: Definition Language–IDL–specification.
    • impl: The functions implemented for frontbank.
    • math: All math arithmetic funcitions.
    • network: All functions about get some information from solana newwork.
    • quotes: Some functions about swap and increase/decrease liquidity.
    • types: All type definition about program.
    • utils: All helpful utils.
    • context: The functions of clmmpool context.
    • ix.ts: All instruction definition interfaces.
  • test: the test case of crema instruction.
    • instructions: Some test case of crema instructions.
    • utils: Some utils function used to test.
  • package.json
  • README.md

License

Crema-SDK-V2 is under the Apache 2.0 license. See the LICENSE file for details.

0.0.53

2 years ago

0.0.52

2 years ago

0.0.51

2 years ago

0.0.50

2 years ago

0.0.49

2 years ago

0.0.48

2 years ago

0.0.47

2 years ago

0.0.46

2 years ago

0.0.45

2 years ago

0.0.44

2 years ago

0.0.43

2 years ago

0.0.42

2 years ago

0.0.41

2 years ago

0.0.40

2 years ago

0.0.39

2 years ago

0.0.38

2 years ago

0.0.37

2 years ago

0.0.36

2 years ago

0.0.35

2 years ago

0.0.34

2 years ago

0.0.33

2 years ago

0.0.32

2 years ago

0.0.31

2 years ago

0.0.30

2 years ago

0.0.29

2 years ago

0.0.28

2 years ago

0.0.27

2 years ago

0.0.26

2 years ago

0.0.25

2 years ago

0.0.24

2 years ago

0.0.23

2 years ago

0.0.22

2 years ago

0.0.21

2 years ago

0.0.20

2 years ago

0.0.19

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago