Hierarchy

  • default

Constructors

Properties

program: Program<BalancerAmm>

Methods

  • Add liquidity to the pool. It supports full and sided liquidity deposit.

    Parameters

    • opts: {
          amounts: BN[];
          poolAddress: Address;
          sendAndConfirm?: boolean;
      }

      Input:

      • amounts: BN[]

        Amounts to deposit

      • poolAddress: Address

        Pool address

      • Optional sendAndConfirm?: boolean

        (true) Send and confirm the transaction.

    Returns Promise<{
        tx: Transaction;
        txId: string;
    }>

  • Cancel a pool in case it's not started yet.

    Parameters

    • opts: {
          poolAddress: Address;
          sendAndConfirm?: boolean;
      }

      Input:

      • poolAddress: Address

        Pool address

      • Optional sendAndConfirm?: boolean

        (true) Send and confirm the transaction.

    Returns Promise<{
        tx: Transaction;
        txId: string;
    }>

  • Derive treasurer address of a pool by pool address.

    Parameters

    • poolAddress: Address

      Pool address.

    Returns string

    Treasurer address that holds the token treasuries of the pool.

  • Finalize a pool.

    Parameters

    • opts: {
          poolAddress: Address;
          sendAndConfirm?: boolean;
      }

      Input:

      • poolAddress: Address

        Pool address

      • Optional sendAndConfirm?: boolean

        (true) Send and confirm the transaction.

    Returns Promise<{
        tx: Transaction;
        txId: string;
    }>

  • Freeze a pool.

    Parameters

    • opts: {
          poolAddress: Address;
          sendAndConfirm?: boolean;
      }

      Input:

      • poolAddress: Address

        Pool address

      • Optional sendAndConfirm?: boolean

        (true) Send and confirm the transaction.

    Returns Promise<{
        tx: Transaction;
        txId: string;
    }>

  • Get all pool data.

    Returns Promise<ProgramAccount<DecodeStruct<{
        fields: [{
            name: "authority";
            type: "publicKey";
        }, {
            name: "fee";
            type: "u64";
        }, {
            name: "tax";
            type: "u64";
        }, {
            name: "state";
            type: {
                defined: "PoolState";
            };
        }, {
            name: "mintLpt";
            type: "publicKey";
        }, {
            name: "taxman";
            type: "publicKey";
        }, {
            name: "mints";
            type: {
                vec: "publicKey";
            };
        }, {
            name: "actions";
            type: {
                vec: {
                    defined: "MintActionState";
                };
            };
        }];
        kind: "struct";
    }, DecodedHelper<[{
        docs: ["", "Pool state", ""];
        name: "PoolState";
        type: {
            kind: "enum";
            variants: [{
                name: "Uninitialized";
            }, {
                name: "Initialized";
            }, {
                name: "Frozen";
            }, {
                name: "Deleted";
            }, {
                name: "Initializing";
            }];
        };
    }, {
        docs: ["", "Mint state", ""];
        name: "MintActionState";
        type: {
            kind: "enum";
            variants: [{
                name: "Active";
            }, {
                name: "BidOnly";
            }, {
                name: "AskOnly";
            }, {
                name: "Paused";
            }];
        };
    }], EmptyDefined>>>[]>

    All pool readable data.

  • Get pool data.

    Parameters

    • poolAddress: Address

      Pool address.

    Returns Promise<DecodeStruct<{
        fields: [{
            name: "authority";
            type: "publicKey";
        }, {
            name: "fee";
            type: "u64";
        }, {
            name: "tax";
            type: "u64";
        }, {
            name: "state";
            type: {
                defined: "PoolState";
            };
        }, {
            name: "mintLpt";
            type: "publicKey";
        }, {
            name: "taxman";
            type: "publicKey";
        }, {
            name: "mints";
            type: {
                vec: "publicKey";
            };
        }, {
            name: "actions";
            type: {
                vec: {
                    defined: "MintActionState";
                };
            };
        }];
        kind: "struct";
    }, DecodedHelper<[{
        docs: ["", "Pool state", ""];
        name: "PoolState";
        type: {
            kind: "enum";
            variants: [{
                name: "Uninitialized";
            }, {
                name: "Initialized";
            }, {
                name: "Frozen";
            }, {
                name: "Deleted";
            }, {
                name: "Initializing";
            }];
        };
    }, {
        docs: ["", "Mint state", ""];
        name: "MintActionState";
        type: {
            kind: "enum";
            variants: [{
                name: "Active";
            }, {
                name: "BidOnly";
            }, {
                name: "AskOnly";
            }, {
                name: "Paused";
            }];
        };
    }], EmptyDefined>>>

    Pool readable data.

  • Initialize joins to add liquidity for each mint to the pool. After joinning all tokens, the pool will change its state from Uninitialized to Initialized.

    Parameters

    • opts: {
          amount: BN;
          mint: Address;
          poolAddress: Address;
          sendAndConfirm?: boolean;
      }

      Input:

      • amount: BN

        Amount of tokens.

      • mint: Address

        Token address will be add liquidity.

      • poolAddress: Address

        The pool address will be add liquidity.

      • Optional sendAndConfirm?: boolean

        (true) Send and confirm the transaction.

    Returns Promise<{
        tx: Transaction;
        txId: string;
    }>

  • Initialize a Pool. This pool will generate with mintsConfigs. Maximum number of tokens in pool = 8 After the init, the authority needs to call initializeJoin to add liquidity and activate the pool.

    Parameters

    • opts: {
          fee: BN;
          mintLpt?: Keypair;
          mintsConfigs: MintConfigs[];
          pool?: Keypair;
          sendAndConfirm?: boolean;
          tax: BN;
          taxman: Address;
      }

      Input:

      • fee: BN

        The fee of swap.

      • Optional mintLpt?: Keypair

        The LP token keypair.

      • mintsConfigs: MintConfigs[]

        List mint config of pool (pk, treasury, weight, action status).

      • Optional pool?: Keypair

        The pool keypair.

      • Optional sendAndConfirm?: boolean

        (true) Send and confirm the transaction.

      • tax: BN

        The tax (platform fee) of swap.

      • taxman: Address

        The taxman address.

    Returns Promise<{
        poolAddress: string;
        tx: Transaction;
        txId: string;
    }>

  • Parse pool buffer data.

    Parameters

    • data: Buffer

      Pool buffer data.

    Returns DecodeStruct<{
        fields: [{
            name: "authority";
            type: "publicKey";
        }, {
            name: "fee";
            type: "u64";
        }, {
            name: "tax";
            type: "u64";
        }, {
            name: "state";
            type: {
                defined: "PoolState";
            };
        }, {
            name: "mintLpt";
            type: "publicKey";
        }, {
            name: "taxman";
            type: "publicKey";
        }, {
            name: "mints";
            type: {
                vec: "publicKey";
            };
        }, {
            name: "actions";
            type: {
                vec: {
                    defined: "MintActionState";
                };
            };
        }];
        kind: "struct";
    }, DecodedHelper<[{
        docs: ["", "Pool state", ""];
        name: "PoolState";
        type: {
            kind: "enum";
            variants: [{
                name: "Uninitialized";
            }, {
                name: "Initialized";
            }, {
                name: "Frozen";
            }, {
                name: "Deleted";
            }, {
                name: "Initializing";
            }];
        };
    }, {
        docs: ["", "Mint state", ""];
        name: "MintActionState";
        type: {
            kind: "enum";
            variants: [{
                name: "Active";
            }, {
                name: "BidOnly";
            }, {
                name: "AskOnly";
            }, {
                name: "Paused";
            }];
        };
    }], EmptyDefined>>

    Pool readable data.

  • Remove liquidity.

    Parameters

    • opts: {
          amount: BN;
          poolAddress: Address;
          sendAndConfirm?: boolean;
      }

      Input:

      • amount: BN

        Amount of LP tokens

      • poolAddress: Address

        Pool address

      • Optional sendAndConfirm?: boolean

        (true) Send and confirm the transaction.

    Returns Promise<{
        tx: Transaction;
        txId: string;
    }>

  • Swap multiple hops in once.

    Parameters

    • opts: {
          bidAmount: BN;
          limit: BN;
          routes: {
              askMint: Address;
              bidMint: Address;
              pool: Address;
          }[];
          sendAndConfirm?: boolean;
      }

      Input:

      • bidAmount: BN

        Bid amount

      • limit: BN

        The bottom limit is to prevent slippage rate.

      • routes: {
            askMint: Address;
            bidMint: Address;
            pool: Address;
        }[]

        The route specification

      • Optional sendAndConfirm?: boolean

        (true) Send and confirm the transaction.

    Returns Promise<{
        tx: Transaction;
        txId: string;
    }>

  • Swap tokens. This function is to swap on a signle hop. If you intent to swap multiple hops, you route instead.

    Parameters

    • opts: {
          askMint: Address;
          bidAmount: BN;
          bidMint: Address;
          limit: BN;
          poolAddress: Address;
          referralAddresses?: Address[];
          sendAndConfirm?: boolean;
      }

      Input:

      • askMint: Address

        Ask token address

      • bidAmount: BN

        Bid Amount

      • bidMint: Address

        Bid token address

      • limit: BN

        The bottom limit. It prevents large slippage rate.

      • poolAddress: Address

        Pool address

      • Optional referralAddresses?: Address[]

        The list of referral addresses.

      • Optional sendAndConfirm?: boolean

        (true) Send and confirm the transaction.

    Returns Promise<{
        tx: Transaction;
        txId: string;
    }>

  • Thaw a pool.

    Parameters

    • opts: {
          poolAddress: Address;
          sendAndConfirm?: boolean;
      }

      Input:

      • poolAddress: Address

        Pool address

      • Optional sendAndConfirm?: boolean

        (true) Send and confirm the transaction.

    Returns Promise<{
        tx: Transaction;
        txId: string;
    }>

  • Transfer pool ownership.

    Parameters

    • opts: {
          newOwner: Address;
          poolAddress: Address;
          sendAndConfirm?: boolean;
      }

      Input:

      • newOwner: Address

        New owner address

      • poolAddress: Address

        Pool address

      • Optional sendAndConfirm?: boolean

        (true) Send and confirm the transaction.

    Returns Promise<{
        tx: Transaction;
        txId: string;
    }>

  • Unwatch a watcher by the watch id

    Parameters

    • watchId: number

    Returns Promise<void>

  • Update token actions in a pool.

    Parameters

    • opts: {
          actions: DecodeEnum<{
              kind: "enum";
              variants: [{
                  name: "Active";
              }, {
                  name: "BidOnly";
              }, {
                  name: "AskOnly";
              }, {
                  name: "Paused";
              }];
          }, EmptyDefined>[];
          poolAddress: Address;
          sendAndConfirm?: boolean;
      }

      Input:

      • actions: DecodeEnum<{
            kind: "enum";
            variants: [{
                name: "Active";
            }, {
                name: "BidOnly";
            }, {
                name: "AskOnly";
            }, {
                name: "Paused";
            }];
        }, EmptyDefined>[]

        Token actions

      • poolAddress: Address

        Pool address

      • Optional sendAndConfirm?: boolean

        (true) Send and confirm the transaction.

    Returns Promise<{
        tx: Transaction;
        txId: string;
    }>

  • Update pool fee & tax

    Parameters

    • opts: {
          fee: BN;
          poolAddress: Address;
          sendAndConfirm?: boolean;
          tax: BN;
      }

      Input:

      • fee: BN

        New fee

      • poolAddress: Address

        Pool address

      • Optional sendAndConfirm?: boolean

        (true) Send and confirm the transaction.

      • tax: BN

        New tax

    Returns Promise<{
        tx: Transaction;
        txId: string;
    }>

  • Update token weights in a pool.

    Parameters

    • opts: {
          poolAddress: Address;
          sendAndConfirm?: boolean;
          weights: BN[];
      }

      Input:

      • poolAddress: Address

        Pool address

      • Optional sendAndConfirm?: boolean

        (true) Send and confirm the transaction.

      • weights: BN[]

        Token weights

    Returns Promise<{
        tx: Transaction;
        txId: string;
    }>

  • Watch account changes

    Parameters

    • callback: ((error, data) => void)

      Callback function

        • (error, data): void
        • Parameters

          • error: null | string
          • data: null | Omit<BalancerAccountChangeInfo, "data"> & {
                data: DecodeStruct<{
                    fields: [{
                        name: "authority";
                        type: "publicKey";
                    }, {
                        name: "fee";
                        type: "u64";
                    }, {
                        name: "tax";
                        type: "u64";
                    }, {
                        name: "state";
                        type: {
                            defined: "PoolState";
                        };
                    }, {
                        name: "mintLpt";
                        type: "publicKey";
                    }, {
                        name: "taxman";
                        type: "publicKey";
                    }, {
                        name: "mints";
                        type: {
                            vec: "publicKey";
                        };
                    }, {
                        name: "actions";
                        type: {
                            vec: {
                                defined: "MintActionState";
                            };
                        };
                    }];
                    kind: "struct";
                }, DecodedHelper<[{
                    docs: ["", "Pool state", ""];
                    name: "PoolState";
                    type: {
                        kind: "enum";
                        variants: [{
                            name: "Uninitialized";
                        }, {
                            name: "Initialized";
                        }, {
                            name: "Frozen";
                        }, {
                            name: "Deleted";
                        }, {
                            name: "Initializing";
                        }];
                    };
                }, {
                    docs: ["", "Mint state", ""];
                    name: "MintActionState";
                    type: {
                        kind: "enum";
                        variants: [{
                            name: "Active";
                        }, {
                            name: "BidOnly";
                        }, {
                            name: "AskOnly";
                        }, {
                            name: "Paused";
                        }];
                    };
                }], EmptyDefined>>;
            }

          Returns void

    • Optional filters: GetProgramAccountsFilter[]

      Event filters

    Returns number

    Watch id

Generated using TypeDoc