diff --git a/test/unit/src/helpers/swap_functions.rs b/test/unit/src/helpers/swap_functions.rs index 4cc4e80..882c7a8 100644 --- a/test/unit/src/helpers/swap_functions.rs +++ b/test/unit/src/helpers/swap_functions.rs @@ -1,6 +1,6 @@ use crate::helpers::nft_functions::validate_nft_owner; use crate::setup::msg::MarketAccounts; -use crate::setup::setup_infinity_pool::setup_infinity_pool; +use crate::setup::setup_infinity_swap::setup_infinity_pool; use crate::setup::setup_marketplace::setup_marketplace; use crate::setup::templates::standard_minter_template; use infinity_pool::msg::{PoolsByIdResponse, QueryMsg, TransactionType}; diff --git a/test/unit/src/setup.rs b/test/unit/src/setup.rs index be7ae25..7d5c0cf 100644 --- a/test/unit/src/setup.rs +++ b/test/unit/src/setup.rs @@ -1,6 +1,6 @@ pub mod msg; pub mod setup_accounts; pub mod setup_contracts; -pub mod setup_infinity_pool; +pub mod setup_infinity_swap; pub mod setup_marketplace; pub mod templates; diff --git a/test/unit/src/setup/setup_infinity_pool.rs b/test/unit/src/setup/setup_infinity_swap.rs similarity index 100% rename from test/unit/src/setup/setup_infinity_pool.rs rename to test/unit/src/setup/setup_infinity_swap.rs diff --git a/test/unit/src/tests/pool_tests/nft_pool_tests.rs b/test/unit/src/tests/pool_tests/nft_pool_tests.rs index dafe55c..454add9 100644 --- a/test/unit/src/tests/pool_tests/nft_pool_tests.rs +++ b/test/unit/src/tests/pool_tests/nft_pool_tests.rs @@ -4,7 +4,7 @@ use crate::helpers::nft_functions::{approve, mint}; use crate::helpers::pool_functions::create_pool; use crate::helpers::utils::assert_error; use crate::setup::setup_accounts::setup_addtl_account; -use crate::setup::setup_infinity_pool::setup_infinity_pool; +use crate::setup::setup_infinity_swap::setup_infinity_pool; use crate::setup::setup_marketplace::{setup_marketplace, LISTING_FEE}; use crate::setup::templates::standard_minter_template; use cosmwasm_std::{coins, Addr, Uint128}; diff --git a/test/unit/src/tests/pool_tests/token_pool_tests.rs b/test/unit/src/tests/pool_tests/token_pool_tests.rs index 65e04f4..7406ba3 100644 --- a/test/unit/src/tests/pool_tests/token_pool_tests.rs +++ b/test/unit/src/tests/pool_tests/token_pool_tests.rs @@ -4,7 +4,7 @@ use crate::helpers::nft_functions::{approve, mint}; use crate::helpers::pool_functions::{create_pool, deposit_tokens}; use crate::helpers::utils::assert_error; use crate::setup::setup_accounts::{setup_addtl_account, INITIAL_BALANCE}; -use crate::setup::setup_infinity_pool::setup_infinity_pool; +use crate::setup::setup_infinity_swap::setup_infinity_pool; use crate::setup::setup_marketplace::{setup_marketplace, LISTING_FEE}; use crate::setup::templates::standard_minter_template; use cosmwasm_std::{coins, Addr, Attribute, Uint128}; diff --git a/test/unit/src/tests/pool_tests/trade_pool_tests.rs b/test/unit/src/tests/pool_tests/trade_pool_tests.rs index 1c3abfa..3e3a897 100644 --- a/test/unit/src/tests/pool_tests/trade_pool_tests.rs +++ b/test/unit/src/tests/pool_tests/trade_pool_tests.rs @@ -3,7 +3,7 @@ use std::vec; use crate::helpers::nft_functions::{approve, mint}; use crate::helpers::pool_functions::create_pool; use crate::helpers::utils::assert_error; -use crate::setup::setup_infinity_pool::setup_infinity_pool; +use crate::setup::setup_infinity_swap::setup_infinity_pool; use crate::setup::setup_marketplace::{setup_marketplace, LISTING_FEE}; use crate::setup::templates::standard_minter_template; use cosmwasm_std::{coins, Addr, Uint128}; diff --git a/test/unit/src/tests/query_tests.rs b/test/unit/src/tests/query_tests.rs index 35593ae..c72ed7c 100644 --- a/test/unit/src/tests/query_tests.rs +++ b/test/unit/src/tests/query_tests.rs @@ -4,7 +4,7 @@ use crate::helpers::fixtures::{create_and_activate_pool_fixtures, create_pool_fi use crate::helpers::nft_functions::mint_and_approve_many; use crate::helpers::pool_functions::prepare_swap_pool; use crate::setup::setup_accounts::setup_addtl_account; -use crate::setup::setup_infinity_pool::setup_infinity_pool; +use crate::setup::setup_infinity_swap::setup_infinity_pool; use crate::setup::setup_marketplace::setup_marketplace; use crate::setup::templates::standard_minter_template; use cosmwasm_std::{Addr, Uint128}; diff --git a/ts/src/InfinityPool.client.ts b/ts/src/InfinityPool.client.ts deleted file mode 100644 index 64302a7..0000000 --- a/ts/src/InfinityPool.client.ts +++ /dev/null @@ -1,842 +0,0 @@ -/** -* This file was automatically generated by @cosmwasm/ts-codegen@0.24.0. -* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, -* and run the @cosmwasm/ts-codegen generate command to regenerate this file. -*/ - -import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate"; -import { Coin, StdFee } from "@cosmjs/amino"; -import { Addr, ConfigResponse, Config, ExecuteMsg, BondingCurve, Uint128, Timestamp, Uint64, NftSwap, SwapParams, PoolNftSwap, InstantiateMsg, PoolQuoteResponse, PoolQuote, Decimal, PoolType, PoolsByIdResponse, Pool, PoolsResponse, QueryMsg, QueryOptionsForUint64, QueryOptionsForString, QueryOptionsForTupleOfUint128AndUint64, TransactionType, SwapResponse, Swap, TokenPayment, NftPayment } from "./InfinityPool.types"; -export interface InfinityPoolReadOnlyInterface { - contractAddress: string; - config: () => Promise; - pools: ({ - queryOptions - }: { - queryOptions: QueryOptions_for_uint64; - }) => Promise; - poolsById: ({ - poolIds - }: { - poolIds: number[]; - }) => Promise; - poolsByOwner: ({ - owner, - queryOptions - }: { - owner: string; - queryOptions: QueryOptions_for_uint64; - }) => Promise; - poolNftTokenIds: ({ - poolId, - queryOptions - }: { - poolId: number; - queryOptions: QueryOptionsForString; - }) => Promise; - poolQuotesBuy: ({ - collection, - queryOptions - }: { - collection: string; - queryOptions: QueryOptionsForTupleOfUint128_and_uint64; - }) => Promise; - poolQuotesSell: ({ - collection, - queryOptions - }: { - collection: string; - queryOptions: QueryOptionsForTupleOfUint128_and_uint64; - }) => Promise; - simDirectSwapNftsForTokens: ({ - nftsToSwap, - poolId, - sender, - swapParams - }: { - nftsToSwap: NftSwap[]; - poolId: number; - sender: string; - swapParams: SwapParams; - }) => Promise; - simSwapNftsForTokens: ({ - collection, - nftsToSwap, - sender, - swapParams - }: { - collection: string; - nftsToSwap: NftSwap[]; - sender: string; - swapParams: SwapParams; - }) => Promise; - simDirectSwapTokensForSpecificNfts: ({ - nftsToSwapFor, - poolId, - sender, - swapParams - }: { - nftsToSwapFor: NftSwap[]; - poolId: number; - sender: string; - swapParams: SwapParams; - }) => Promise; - simSwapTokensForSpecificNfts: ({ - collection, - poolNftsToSwapFor, - sender, - swapParams - }: { - collection: string; - poolNftsToSwapFor: PoolNftSwap[]; - sender: string; - swapParams: SwapParams; - }) => Promise; - simSwapTokensForAnyNfts: ({ - collection, - maxExpectedTokenInput, - sender, - swapParams - }: { - collection: string; - maxExpectedTokenInput: Uint128[]; - sender: string; - swapParams: SwapParams; - }) => Promise; -} -export class InfinityPoolQueryClient implements InfinityPoolReadOnlyInterface { - client: CosmWasmClient; - contractAddress: string; - - constructor(client: CosmWasmClient, contractAddress: string) { - this.client = client; - this.contractAddress = contractAddress; - this.config = this.config.bind(this); - this.pools = this.pools.bind(this); - this.poolsById = this.poolsById.bind(this); - this.poolsByOwner = this.poolsByOwner.bind(this); - this.poolNftTokenIds = this.poolNftTokenIds.bind(this); - this.poolQuotesBuy = this.poolQuotesBuy.bind(this); - this.poolQuotesSell = this.poolQuotesSell.bind(this); - this.simDirectSwapNftsForTokens = this.simDirectSwapNftsForTokens.bind(this); - this.simSwapNftsForTokens = this.simSwapNftsForTokens.bind(this); - this.simDirectSwapTokensForSpecificNfts = this.simDirectSwapTokensForSpecificNfts.bind(this); - this.simSwapTokensForSpecificNfts = this.simSwapTokensForSpecificNfts.bind(this); - this.simSwapTokensForAnyNfts = this.simSwapTokensForAnyNfts.bind(this); - } - - config = async (): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - config: {} - }); - }; - pools = async ({ - queryOptions - }: { - queryOptions: QueryOptions_for_uint64; - }): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - pools: { - query_options: queryOptions - } - }); - }; - poolsById = async ({ - poolIds - }: { - poolIds: number[]; - }): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - pools_by_id: { - pool_ids: poolIds - } - }); - }; - poolsByOwner = async ({ - owner, - queryOptions - }: { - owner: string; - queryOptions: QueryOptions_for_uint64; - }): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - pools_by_owner: { - owner, - query_options: queryOptions - } - }); - }; - poolNftTokenIds = async ({ - poolId, - queryOptions - }: { - poolId: number; - queryOptions: QueryOptionsForString; - }): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - pool_nft_token_ids: { - pool_id: poolId, - query_options: queryOptions - } - }); - }; - poolQuotesBuy = async ({ - collection, - queryOptions - }: { - collection: string; - queryOptions: QueryOptionsForTupleOfUint128_and_uint64; - }): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - pool_quotes_buy: { - collection, - query_options: queryOptions - } - }); - }; - poolQuotesSell = async ({ - collection, - queryOptions - }: { - collection: string; - queryOptions: QueryOptionsForTupleOfUint128_and_uint64; - }): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - pool_quotes_sell: { - collection, - query_options: queryOptions - } - }); - }; - simDirectSwapNftsForTokens = async ({ - nftsToSwap, - poolId, - sender, - swapParams - }: { - nftsToSwap: NftSwap[]; - poolId: number; - sender: string; - swapParams: SwapParams; - }): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - sim_direct_swap_nfts_for_tokens: { - nfts_to_swap: nftsToSwap, - pool_id: poolId, - sender, - swap_params: swapParams - } - }); - }; - simSwapNftsForTokens = async ({ - collection, - nftsToSwap, - sender, - swapParams - }: { - collection: string; - nftsToSwap: NftSwap[]; - sender: string; - swapParams: SwapParams; - }): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - sim_swap_nfts_for_tokens: { - collection, - nfts_to_swap: nftsToSwap, - sender, - swap_params: swapParams - } - }); - }; - simDirectSwapTokensForSpecificNfts = async ({ - nftsToSwapFor, - poolId, - sender, - swapParams - }: { - nftsToSwapFor: NftSwap[]; - poolId: number; - sender: string; - swapParams: SwapParams; - }): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - sim_direct_swap_tokens_for_specific_nfts: { - nfts_to_swap_for: nftsToSwapFor, - pool_id: poolId, - sender, - swap_params: swapParams - } - }); - }; - simSwapTokensForSpecificNfts = async ({ - collection, - poolNftsToSwapFor, - sender, - swapParams - }: { - collection: string; - poolNftsToSwapFor: PoolNftSwap[]; - sender: string; - swapParams: SwapParams; - }): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - sim_swap_tokens_for_specific_nfts: { - collection, - pool_nfts_to_swap_for: poolNftsToSwapFor, - sender, - swap_params: swapParams - } - }); - }; - simSwapTokensForAnyNfts = async ({ - collection, - maxExpectedTokenInput, - sender, - swapParams - }: { - collection: string; - maxExpectedTokenInput: Uint128[]; - sender: string; - swapParams: SwapParams; - }): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - sim_swap_tokens_for_any_nfts: { - collection, - max_expected_token_input: maxExpectedTokenInput, - sender, - swap_params: swapParams - } - }); - }; -} -export interface InfinityPoolInterface extends InfinityPoolReadOnlyInterface { - contractAddress: string; - sender: string; - createTokenPool: ({ - assetRecipient, - bondingCurve, - collection, - delta, - findersFeeBps, - spotPrice - }: { - assetRecipient?: string; - bondingCurve: BondingCurve; - collection: string; - delta: Uint128; - findersFeeBps: number; - spotPrice: Uint128; - }, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; - createNftPool: ({ - assetRecipient, - bondingCurve, - collection, - delta, - findersFeeBps, - spotPrice - }: { - assetRecipient?: string; - bondingCurve: BondingCurve; - collection: string; - delta: Uint128; - findersFeeBps: number; - spotPrice: Uint128; - }, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; - createTradePool: ({ - assetRecipient, - bondingCurve, - collection, - delta, - findersFeeBps, - reinvestNfts, - reinvestTokens, - spotPrice, - swapFeeBps - }: { - assetRecipient?: string; - bondingCurve: BondingCurve; - collection: string; - delta: Uint128; - findersFeeBps: number; - reinvestNfts: boolean; - reinvestTokens: boolean; - spotPrice: Uint128; - swapFeeBps: number; - }, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; - depositTokens: ({ - poolId - }: { - poolId: number; - }, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; - depositNfts: ({ - collection, - nftTokenIds, - poolId - }: { - collection: string; - nftTokenIds: string[]; - poolId: number; - }, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; - withdrawTokens: ({ - amount, - assetRecipient, - poolId - }: { - amount: Uint128; - assetRecipient?: string; - poolId: number; - }, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; - withdrawAllTokens: ({ - assetRecipient, - poolId - }: { - assetRecipient?: string; - poolId: number; - }, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; - withdrawNfts: ({ - assetRecipient, - nftTokenIds, - poolId - }: { - assetRecipient?: string; - nftTokenIds: string[]; - poolId: number; - }, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; - withdrawAllNfts: ({ - assetRecipient, - poolId - }: { - assetRecipient?: string; - poolId: number; - }, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; - updatePoolConfig: ({ - assetRecipient, - delta, - findersFeeBps, - poolId, - reinvestNfts, - reinvestTokens, - spotPrice, - swapFeeBps - }: { - assetRecipient?: string; - delta?: Uint128; - findersFeeBps?: number; - poolId: number; - reinvestNfts?: boolean; - reinvestTokens?: boolean; - spotPrice?: Uint128; - swapFeeBps?: number; - }, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; - setActivePool: ({ - isActive, - poolId - }: { - isActive: boolean; - poolId: number; - }, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; - removePool: ({ - assetRecipient, - poolId - }: { - assetRecipient?: string; - poolId: number; - }, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; - directSwapNftsForTokens: ({ - nftsToSwap, - poolId, - swapParams - }: { - nftsToSwap: NftSwap[]; - poolId: number; - swapParams: SwapParams; - }, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; - swapNftsForTokens: ({ - collection, - nftsToSwap, - swapParams - }: { - collection: string; - nftsToSwap: NftSwap[]; - swapParams: SwapParams; - }, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; - directSwapTokensForSpecificNfts: ({ - nftsToSwapFor, - poolId, - swapParams - }: { - nftsToSwapFor: NftSwap[]; - poolId: number; - swapParams: SwapParams; - }, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; - swapTokensForSpecificNfts: ({ - collection, - poolNftsToSwapFor, - swapParams - }: { - collection: string; - poolNftsToSwapFor: PoolNftSwap[]; - swapParams: SwapParams; - }, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; - swapTokensForAnyNfts: ({ - collection, - maxExpectedTokenInput, - swapParams - }: { - collection: string; - maxExpectedTokenInput: Uint128[]; - swapParams: SwapParams; - }, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; -} -export class InfinityPoolClient extends InfinityPoolQueryClient implements InfinityPoolInterface { - client: SigningCosmWasmClient; - sender: string; - contractAddress: string; - - constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) { - super(client, contractAddress); - this.client = client; - this.sender = sender; - this.contractAddress = contractAddress; - this.createTokenPool = this.createTokenPool.bind(this); - this.createNftPool = this.createNftPool.bind(this); - this.createTradePool = this.createTradePool.bind(this); - this.depositTokens = this.depositTokens.bind(this); - this.depositNfts = this.depositNfts.bind(this); - this.withdrawTokens = this.withdrawTokens.bind(this); - this.withdrawAllTokens = this.withdrawAllTokens.bind(this); - this.withdrawNfts = this.withdrawNfts.bind(this); - this.withdrawAllNfts = this.withdrawAllNfts.bind(this); - this.updatePoolConfig = this.updatePoolConfig.bind(this); - this.setActivePool = this.setActivePool.bind(this); - this.removePool = this.removePool.bind(this); - this.directSwapNftsForTokens = this.directSwapNftsForTokens.bind(this); - this.swapNftsForTokens = this.swapNftsForTokens.bind(this); - this.directSwapTokensForSpecificNfts = this.directSwapTokensForSpecificNfts.bind(this); - this.swapTokensForSpecificNfts = this.swapTokensForSpecificNfts.bind(this); - this.swapTokensForAnyNfts = this.swapTokensForAnyNfts.bind(this); - } - - createTokenPool = async ({ - assetRecipient, - bondingCurve, - collection, - delta, - findersFeeBps, - spotPrice - }: { - assetRecipient?: string; - bondingCurve: BondingCurve; - collection: string; - delta: Uint128; - findersFeeBps: number; - spotPrice: Uint128; - }, fee: number | StdFee | "auto" = "auto", memo?: string, funds?: Coin[]): Promise => { - return await this.client.execute(this.sender, this.contractAddress, { - create_token_pool: { - asset_recipient: assetRecipient, - bonding_curve: bondingCurve, - collection, - delta, - finders_fee_bps: findersFeeBps, - spot_price: spotPrice - } - }, fee, memo, funds); - }; - createNftPool = async ({ - assetRecipient, - bondingCurve, - collection, - delta, - findersFeeBps, - spotPrice - }: { - assetRecipient?: string; - bondingCurve: BondingCurve; - collection: string; - delta: Uint128; - findersFeeBps: number; - spotPrice: Uint128; - }, fee: number | StdFee | "auto" = "auto", memo?: string, funds?: Coin[]): Promise => { - return await this.client.execute(this.sender, this.contractAddress, { - create_nft_pool: { - asset_recipient: assetRecipient, - bonding_curve: bondingCurve, - collection, - delta, - finders_fee_bps: findersFeeBps, - spot_price: spotPrice - } - }, fee, memo, funds); - }; - createTradePool = async ({ - assetRecipient, - bondingCurve, - collection, - delta, - findersFeeBps, - reinvestNfts, - reinvestTokens, - spotPrice, - swapFeeBps - }: { - assetRecipient?: string; - bondingCurve: BondingCurve; - collection: string; - delta: Uint128; - findersFeeBps: number; - reinvestNfts: boolean; - reinvestTokens: boolean; - spotPrice: Uint128; - swapFeeBps: number; - }, fee: number | StdFee | "auto" = "auto", memo?: string, funds?: Coin[]): Promise => { - return await this.client.execute(this.sender, this.contractAddress, { - create_trade_pool: { - asset_recipient: assetRecipient, - bonding_curve: bondingCurve, - collection, - delta, - finders_fee_bps: findersFeeBps, - reinvest_nfts: reinvestNfts, - reinvest_tokens: reinvestTokens, - spot_price: spotPrice, - swap_fee_bps: swapFeeBps - } - }, fee, memo, funds); - }; - depositTokens = async ({ - poolId - }: { - poolId: number; - }, fee: number | StdFee | "auto" = "auto", memo?: string, funds?: Coin[]): Promise => { - return await this.client.execute(this.sender, this.contractAddress, { - deposit_tokens: { - pool_id: poolId - } - }, fee, memo, funds); - }; - depositNfts = async ({ - collection, - nftTokenIds, - poolId - }: { - collection: string; - nftTokenIds: string[]; - poolId: number; - }, fee: number | StdFee | "auto" = "auto", memo?: string, funds?: Coin[]): Promise => { - return await this.client.execute(this.sender, this.contractAddress, { - deposit_nfts: { - collection, - nft_token_ids: nftTokenIds, - pool_id: poolId - } - }, fee, memo, funds); - }; - withdrawTokens = async ({ - amount, - assetRecipient, - poolId - }: { - amount: Uint128; - assetRecipient?: string; - poolId: number; - }, fee: number | StdFee | "auto" = "auto", memo?: string, funds?: Coin[]): Promise => { - return await this.client.execute(this.sender, this.contractAddress, { - withdraw_tokens: { - amount, - asset_recipient: assetRecipient, - pool_id: poolId - } - }, fee, memo, funds); - }; - withdrawAllTokens = async ({ - assetRecipient, - poolId - }: { - assetRecipient?: string; - poolId: number; - }, fee: number | StdFee | "auto" = "auto", memo?: string, funds?: Coin[]): Promise => { - return await this.client.execute(this.sender, this.contractAddress, { - withdraw_all_tokens: { - asset_recipient: assetRecipient, - pool_id: poolId - } - }, fee, memo, funds); - }; - withdrawNfts = async ({ - assetRecipient, - nftTokenIds, - poolId - }: { - assetRecipient?: string; - nftTokenIds: string[]; - poolId: number; - }, fee: number | StdFee | "auto" = "auto", memo?: string, funds?: Coin[]): Promise => { - return await this.client.execute(this.sender, this.contractAddress, { - withdraw_nfts: { - asset_recipient: assetRecipient, - nft_token_ids: nftTokenIds, - pool_id: poolId - } - }, fee, memo, funds); - }; - withdrawAllNfts = async ({ - assetRecipient, - poolId - }: { - assetRecipient?: string; - poolId: number; - }, fee: number | StdFee | "auto" = "auto", memo?: string, funds?: Coin[]): Promise => { - return await this.client.execute(this.sender, this.contractAddress, { - withdraw_all_nfts: { - asset_recipient: assetRecipient, - pool_id: poolId - } - }, fee, memo, funds); - }; - updatePoolConfig = async ({ - assetRecipient, - delta, - findersFeeBps, - poolId, - reinvestNfts, - reinvestTokens, - spotPrice, - swapFeeBps - }: { - assetRecipient?: string; - delta?: Uint128; - findersFeeBps?: number; - poolId: number; - reinvestNfts?: boolean; - reinvestTokens?: boolean; - spotPrice?: Uint128; - swapFeeBps?: number; - }, fee: number | StdFee | "auto" = "auto", memo?: string, funds?: Coin[]): Promise => { - return await this.client.execute(this.sender, this.contractAddress, { - update_pool_config: { - asset_recipient: assetRecipient, - delta, - finders_fee_bps: findersFeeBps, - pool_id: poolId, - reinvest_nfts: reinvestNfts, - reinvest_tokens: reinvestTokens, - spot_price: spotPrice, - swap_fee_bps: swapFeeBps - } - }, fee, memo, funds); - }; - setActivePool = async ({ - isActive, - poolId - }: { - isActive: boolean; - poolId: number; - }, fee: number | StdFee | "auto" = "auto", memo?: string, funds?: Coin[]): Promise => { - return await this.client.execute(this.sender, this.contractAddress, { - set_active_pool: { - is_active: isActive, - pool_id: poolId - } - }, fee, memo, funds); - }; - removePool = async ({ - assetRecipient, - poolId - }: { - assetRecipient?: string; - poolId: number; - }, fee: number | StdFee | "auto" = "auto", memo?: string, funds?: Coin[]): Promise => { - return await this.client.execute(this.sender, this.contractAddress, { - remove_pool: { - asset_recipient: assetRecipient, - pool_id: poolId - } - }, fee, memo, funds); - }; - directSwapNftsForTokens = async ({ - nftsToSwap, - poolId, - swapParams - }: { - nftsToSwap: NftSwap[]; - poolId: number; - swapParams: SwapParams; - }, fee: number | StdFee | "auto" = "auto", memo?: string, funds?: Coin[]): Promise => { - return await this.client.execute(this.sender, this.contractAddress, { - direct_swap_nfts_for_tokens: { - nfts_to_swap: nftsToSwap, - pool_id: poolId, - swap_params: swapParams - } - }, fee, memo, funds); - }; - swapNftsForTokens = async ({ - collection, - nftsToSwap, - swapParams - }: { - collection: string; - nftsToSwap: NftSwap[]; - swapParams: SwapParams; - }, fee: number | StdFee | "auto" = "auto", memo?: string, funds?: Coin[]): Promise => { - return await this.client.execute(this.sender, this.contractAddress, { - swap_nfts_for_tokens: { - collection, - nfts_to_swap: nftsToSwap, - swap_params: swapParams - } - }, fee, memo, funds); - }; - directSwapTokensForSpecificNfts = async ({ - nftsToSwapFor, - poolId, - swapParams - }: { - nftsToSwapFor: NftSwap[]; - poolId: number; - swapParams: SwapParams; - }, fee: number | StdFee | "auto" = "auto", memo?: string, funds?: Coin[]): Promise => { - return await this.client.execute(this.sender, this.contractAddress, { - direct_swap_tokens_for_specific_nfts: { - nfts_to_swap_for: nftsToSwapFor, - pool_id: poolId, - swap_params: swapParams - } - }, fee, memo, funds); - }; - swapTokensForSpecificNfts = async ({ - collection, - poolNftsToSwapFor, - swapParams - }: { - collection: string; - poolNftsToSwapFor: PoolNftSwap[]; - swapParams: SwapParams; - }, fee: number | StdFee | "auto" = "auto", memo?: string, funds?: Coin[]): Promise => { - return await this.client.execute(this.sender, this.contractAddress, { - swap_tokens_for_specific_nfts: { - collection, - pool_nfts_to_swap_for: poolNftsToSwapFor, - swap_params: swapParams - } - }, fee, memo, funds); - }; - swapTokensForAnyNfts = async ({ - collection, - maxExpectedTokenInput, - swapParams - }: { - collection: string; - maxExpectedTokenInput: Uint128[]; - swapParams: SwapParams; - }, fee: number | StdFee | "auto" = "auto", memo?: string, funds?: Coin[]): Promise => { - return await this.client.execute(this.sender, this.contractAddress, { - swap_tokens_for_any_nfts: { - collection, - max_expected_token_input: maxExpectedTokenInput, - swap_params: swapParams - } - }, fee, memo, funds); - }; -} \ No newline at end of file diff --git a/ts/src/InfinityPool.message-composer.ts b/ts/src/InfinityPool.message-composer.ts deleted file mode 100644 index 046dfcd..0000000 --- a/ts/src/InfinityPool.message-composer.ts +++ /dev/null @@ -1,675 +0,0 @@ -/** -* This file was automatically generated by @cosmwasm/ts-codegen@0.24.0. -* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, -* and run the @cosmwasm/ts-codegen generate command to regenerate this file. -*/ - -import { Coin } from "@cosmjs/amino"; -import { MsgExecuteContractEncodeObject } from "cosmwasm"; -import { MsgExecuteContract } from "cosmjs-types/cosmwasm/wasm/v1/tx"; -import { toUtf8 } from "@cosmjs/encoding"; -import { Addr, ConfigResponse, Config, ExecuteMsg, BondingCurve, Uint128, Timestamp, Uint64, NftSwap, SwapParams, PoolNftSwap, InstantiateMsg, PoolQuoteResponse, PoolQuote, Decimal, PoolType, PoolsByIdResponse, Pool, PoolsResponse, QueryMsg, QueryOptionsForUint64, QueryOptionsForString, QueryOptionsForTupleOfUint128AndUint64, TransactionType, SwapResponse, Swap, TokenPayment, NftPayment } from "./InfinityPool.types"; -export interface InfinityPoolMessage { - contractAddress: string; - sender: string; - createTokenPool: ({ - assetRecipient, - bondingCurve, - collection, - delta, - findersFeeBps, - spotPrice - }: { - assetRecipient?: string; - bondingCurve: BondingCurve; - collection: string; - delta: Uint128; - findersFeeBps: number; - spotPrice: Uint128; - }, funds?: Coin[]) => MsgExecuteContractEncodeObject; - createNftPool: ({ - assetRecipient, - bondingCurve, - collection, - delta, - findersFeeBps, - spotPrice - }: { - assetRecipient?: string; - bondingCurve: BondingCurve; - collection: string; - delta: Uint128; - findersFeeBps: number; - spotPrice: Uint128; - }, funds?: Coin[]) => MsgExecuteContractEncodeObject; - createTradePool: ({ - assetRecipient, - bondingCurve, - collection, - delta, - findersFeeBps, - reinvestNfts, - reinvestTokens, - spotPrice, - swapFeeBps - }: { - assetRecipient?: string; - bondingCurve: BondingCurve; - collection: string; - delta: Uint128; - findersFeeBps: number; - reinvestNfts: boolean; - reinvestTokens: boolean; - spotPrice: Uint128; - swapFeeBps: number; - }, funds?: Coin[]) => MsgExecuteContractEncodeObject; - depositTokens: ({ - poolId - }: { - poolId: number; - }, funds?: Coin[]) => MsgExecuteContractEncodeObject; - depositNfts: ({ - collection, - nftTokenIds, - poolId - }: { - collection: string; - nftTokenIds: string[]; - poolId: number; - }, funds?: Coin[]) => MsgExecuteContractEncodeObject; - withdrawTokens: ({ - amount, - assetRecipient, - poolId - }: { - amount: Uint128; - assetRecipient?: string; - poolId: number; - }, funds?: Coin[]) => MsgExecuteContractEncodeObject; - withdrawAllTokens: ({ - assetRecipient, - poolId - }: { - assetRecipient?: string; - poolId: number; - }, funds?: Coin[]) => MsgExecuteContractEncodeObject; - withdrawNfts: ({ - assetRecipient, - nftTokenIds, - poolId - }: { - assetRecipient?: string; - nftTokenIds: string[]; - poolId: number; - }, funds?: Coin[]) => MsgExecuteContractEncodeObject; - withdrawAllNfts: ({ - assetRecipient, - poolId - }: { - assetRecipient?: string; - poolId: number; - }, funds?: Coin[]) => MsgExecuteContractEncodeObject; - updatePoolConfig: ({ - assetRecipient, - delta, - findersFeeBps, - poolId, - reinvestNfts, - reinvestTokens, - spotPrice, - swapFeeBps - }: { - assetRecipient?: string; - delta?: Uint128; - findersFeeBps?: number; - poolId: number; - reinvestNfts?: boolean; - reinvestTokens?: boolean; - spotPrice?: Uint128; - swapFeeBps?: number; - }, funds?: Coin[]) => MsgExecuteContractEncodeObject; - setActivePool: ({ - isActive, - poolId - }: { - isActive: boolean; - poolId: number; - }, funds?: Coin[]) => MsgExecuteContractEncodeObject; - removePool: ({ - assetRecipient, - poolId - }: { - assetRecipient?: string; - poolId: number; - }, funds?: Coin[]) => MsgExecuteContractEncodeObject; - directSwapNftsForTokens: ({ - nftsToSwap, - poolId, - swapParams - }: { - nftsToSwap: NftSwap[]; - poolId: number; - swapParams: SwapParams; - }, funds?: Coin[]) => MsgExecuteContractEncodeObject; - swapNftsForTokens: ({ - collection, - nftsToSwap, - swapParams - }: { - collection: string; - nftsToSwap: NftSwap[]; - swapParams: SwapParams; - }, funds?: Coin[]) => MsgExecuteContractEncodeObject; - directSwapTokensForSpecificNfts: ({ - nftsToSwapFor, - poolId, - swapParams - }: { - nftsToSwapFor: NftSwap[]; - poolId: number; - swapParams: SwapParams; - }, funds?: Coin[]) => MsgExecuteContractEncodeObject; - swapTokensForSpecificNfts: ({ - collection, - poolNftsToSwapFor, - swapParams - }: { - collection: string; - poolNftsToSwapFor: PoolNftSwap[]; - swapParams: SwapParams; - }, funds?: Coin[]) => MsgExecuteContractEncodeObject; - swapTokensForAnyNfts: ({ - collection, - maxExpectedTokenInput, - swapParams - }: { - collection: string; - maxExpectedTokenInput: Uint128[]; - swapParams: SwapParams; - }, funds?: Coin[]) => MsgExecuteContractEncodeObject; -} -export class InfinityPoolMessageComposer implements InfinityPoolMessage { - sender: string; - contractAddress: string; - - constructor(sender: string, contractAddress: string) { - this.sender = sender; - this.contractAddress = contractAddress; - this.createTokenPool = this.createTokenPool.bind(this); - this.createNftPool = this.createNftPool.bind(this); - this.createTradePool = this.createTradePool.bind(this); - this.depositTokens = this.depositTokens.bind(this); - this.depositNfts = this.depositNfts.bind(this); - this.withdrawTokens = this.withdrawTokens.bind(this); - this.withdrawAllTokens = this.withdrawAllTokens.bind(this); - this.withdrawNfts = this.withdrawNfts.bind(this); - this.withdrawAllNfts = this.withdrawAllNfts.bind(this); - this.updatePoolConfig = this.updatePoolConfig.bind(this); - this.setActivePool = this.setActivePool.bind(this); - this.removePool = this.removePool.bind(this); - this.directSwapNftsForTokens = this.directSwapNftsForTokens.bind(this); - this.swapNftsForTokens = this.swapNftsForTokens.bind(this); - this.directSwapTokensForSpecificNfts = this.directSwapTokensForSpecificNfts.bind(this); - this.swapTokensForSpecificNfts = this.swapTokensForSpecificNfts.bind(this); - this.swapTokensForAnyNfts = this.swapTokensForAnyNfts.bind(this); - } - - createTokenPool = ({ - assetRecipient, - bondingCurve, - collection, - delta, - findersFeeBps, - spotPrice - }: { - assetRecipient?: string; - bondingCurve: BondingCurve; - collection: string; - delta: Uint128; - findersFeeBps: number; - spotPrice: Uint128; - }, funds?: Coin[]): MsgExecuteContractEncodeObject => { - return { - typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", - value: MsgExecuteContract.fromPartial({ - sender: this.sender, - contract: this.contractAddress, - msg: toUtf8(JSON.stringify({ - create_token_pool: { - asset_recipient: assetRecipient, - bonding_curve: bondingCurve, - collection, - delta, - finders_fee_bps: findersFeeBps, - spot_price: spotPrice - } - })), - funds - }) - }; - }; - createNftPool = ({ - assetRecipient, - bondingCurve, - collection, - delta, - findersFeeBps, - spotPrice - }: { - assetRecipient?: string; - bondingCurve: BondingCurve; - collection: string; - delta: Uint128; - findersFeeBps: number; - spotPrice: Uint128; - }, funds?: Coin[]): MsgExecuteContractEncodeObject => { - return { - typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", - value: MsgExecuteContract.fromPartial({ - sender: this.sender, - contract: this.contractAddress, - msg: toUtf8(JSON.stringify({ - create_nft_pool: { - asset_recipient: assetRecipient, - bonding_curve: bondingCurve, - collection, - delta, - finders_fee_bps: findersFeeBps, - spot_price: spotPrice - } - })), - funds - }) - }; - }; - createTradePool = ({ - assetRecipient, - bondingCurve, - collection, - delta, - findersFeeBps, - reinvestNfts, - reinvestTokens, - spotPrice, - swapFeeBps - }: { - assetRecipient?: string; - bondingCurve: BondingCurve; - collection: string; - delta: Uint128; - findersFeeBps: number; - reinvestNfts: boolean; - reinvestTokens: boolean; - spotPrice: Uint128; - swapFeeBps: number; - }, funds?: Coin[]): MsgExecuteContractEncodeObject => { - return { - typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", - value: MsgExecuteContract.fromPartial({ - sender: this.sender, - contract: this.contractAddress, - msg: toUtf8(JSON.stringify({ - create_trade_pool: { - asset_recipient: assetRecipient, - bonding_curve: bondingCurve, - collection, - delta, - finders_fee_bps: findersFeeBps, - reinvest_nfts: reinvestNfts, - reinvest_tokens: reinvestTokens, - spot_price: spotPrice, - swap_fee_bps: swapFeeBps - } - })), - funds - }) - }; - }; - depositTokens = ({ - poolId - }: { - poolId: number; - }, funds?: Coin[]): MsgExecuteContractEncodeObject => { - return { - typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", - value: MsgExecuteContract.fromPartial({ - sender: this.sender, - contract: this.contractAddress, - msg: toUtf8(JSON.stringify({ - deposit_tokens: { - pool_id: poolId - } - })), - funds - }) - }; - }; - depositNfts = ({ - collection, - nftTokenIds, - poolId - }: { - collection: string; - nftTokenIds: string[]; - poolId: number; - }, funds?: Coin[]): MsgExecuteContractEncodeObject => { - return { - typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", - value: MsgExecuteContract.fromPartial({ - sender: this.sender, - contract: this.contractAddress, - msg: toUtf8(JSON.stringify({ - deposit_nfts: { - collection, - nft_token_ids: nftTokenIds, - pool_id: poolId - } - })), - funds - }) - }; - }; - withdrawTokens = ({ - amount, - assetRecipient, - poolId - }: { - amount: Uint128; - assetRecipient?: string; - poolId: number; - }, funds?: Coin[]): MsgExecuteContractEncodeObject => { - return { - typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", - value: MsgExecuteContract.fromPartial({ - sender: this.sender, - contract: this.contractAddress, - msg: toUtf8(JSON.stringify({ - withdraw_tokens: { - amount, - asset_recipient: assetRecipient, - pool_id: poolId - } - })), - funds - }) - }; - }; - withdrawAllTokens = ({ - assetRecipient, - poolId - }: { - assetRecipient?: string; - poolId: number; - }, funds?: Coin[]): MsgExecuteContractEncodeObject => { - return { - typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", - value: MsgExecuteContract.fromPartial({ - sender: this.sender, - contract: this.contractAddress, - msg: toUtf8(JSON.stringify({ - withdraw_all_tokens: { - asset_recipient: assetRecipient, - pool_id: poolId - } - })), - funds - }) - }; - }; - withdrawNfts = ({ - assetRecipient, - nftTokenIds, - poolId - }: { - assetRecipient?: string; - nftTokenIds: string[]; - poolId: number; - }, funds?: Coin[]): MsgExecuteContractEncodeObject => { - return { - typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", - value: MsgExecuteContract.fromPartial({ - sender: this.sender, - contract: this.contractAddress, - msg: toUtf8(JSON.stringify({ - withdraw_nfts: { - asset_recipient: assetRecipient, - nft_token_ids: nftTokenIds, - pool_id: poolId - } - })), - funds - }) - }; - }; - withdrawAllNfts = ({ - assetRecipient, - poolId - }: { - assetRecipient?: string; - poolId: number; - }, funds?: Coin[]): MsgExecuteContractEncodeObject => { - return { - typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", - value: MsgExecuteContract.fromPartial({ - sender: this.sender, - contract: this.contractAddress, - msg: toUtf8(JSON.stringify({ - withdraw_all_nfts: { - asset_recipient: assetRecipient, - pool_id: poolId - } - })), - funds - }) - }; - }; - updatePoolConfig = ({ - assetRecipient, - delta, - findersFeeBps, - poolId, - reinvestNfts, - reinvestTokens, - spotPrice, - swapFeeBps - }: { - assetRecipient?: string; - delta?: Uint128; - findersFeeBps?: number; - poolId: number; - reinvestNfts?: boolean; - reinvestTokens?: boolean; - spotPrice?: Uint128; - swapFeeBps?: number; - }, funds?: Coin[]): MsgExecuteContractEncodeObject => { - return { - typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", - value: MsgExecuteContract.fromPartial({ - sender: this.sender, - contract: this.contractAddress, - msg: toUtf8(JSON.stringify({ - update_pool_config: { - asset_recipient: assetRecipient, - delta, - finders_fee_bps: findersFeeBps, - pool_id: poolId, - reinvest_nfts: reinvestNfts, - reinvest_tokens: reinvestTokens, - spot_price: spotPrice, - swap_fee_bps: swapFeeBps - } - })), - funds - }) - }; - }; - setActivePool = ({ - isActive, - poolId - }: { - isActive: boolean; - poolId: number; - }, funds?: Coin[]): MsgExecuteContractEncodeObject => { - return { - typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", - value: MsgExecuteContract.fromPartial({ - sender: this.sender, - contract: this.contractAddress, - msg: toUtf8(JSON.stringify({ - set_active_pool: { - is_active: isActive, - pool_id: poolId - } - })), - funds - }) - }; - }; - removePool = ({ - assetRecipient, - poolId - }: { - assetRecipient?: string; - poolId: number; - }, funds?: Coin[]): MsgExecuteContractEncodeObject => { - return { - typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", - value: MsgExecuteContract.fromPartial({ - sender: this.sender, - contract: this.contractAddress, - msg: toUtf8(JSON.stringify({ - remove_pool: { - asset_recipient: assetRecipient, - pool_id: poolId - } - })), - funds - }) - }; - }; - directSwapNftsForTokens = ({ - nftsToSwap, - poolId, - swapParams - }: { - nftsToSwap: NftSwap[]; - poolId: number; - swapParams: SwapParams; - }, funds?: Coin[]): MsgExecuteContractEncodeObject => { - return { - typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", - value: MsgExecuteContract.fromPartial({ - sender: this.sender, - contract: this.contractAddress, - msg: toUtf8(JSON.stringify({ - direct_swap_nfts_for_tokens: { - nfts_to_swap: nftsToSwap, - pool_id: poolId, - swap_params: swapParams - } - })), - funds - }) - }; - }; - swapNftsForTokens = ({ - collection, - nftsToSwap, - swapParams - }: { - collection: string; - nftsToSwap: NftSwap[]; - swapParams: SwapParams; - }, funds?: Coin[]): MsgExecuteContractEncodeObject => { - return { - typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", - value: MsgExecuteContract.fromPartial({ - sender: this.sender, - contract: this.contractAddress, - msg: toUtf8(JSON.stringify({ - swap_nfts_for_tokens: { - collection, - nfts_to_swap: nftsToSwap, - swap_params: swapParams - } - })), - funds - }) - }; - }; - directSwapTokensForSpecificNfts = ({ - nftsToSwapFor, - poolId, - swapParams - }: { - nftsToSwapFor: NftSwap[]; - poolId: number; - swapParams: SwapParams; - }, funds?: Coin[]): MsgExecuteContractEncodeObject => { - return { - typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", - value: MsgExecuteContract.fromPartial({ - sender: this.sender, - contract: this.contractAddress, - msg: toUtf8(JSON.stringify({ - direct_swap_tokens_for_specific_nfts: { - nfts_to_swap_for: nftsToSwapFor, - pool_id: poolId, - swap_params: swapParams - } - })), - funds - }) - }; - }; - swapTokensForSpecificNfts = ({ - collection, - poolNftsToSwapFor, - swapParams - }: { - collection: string; - poolNftsToSwapFor: PoolNftSwap[]; - swapParams: SwapParams; - }, funds?: Coin[]): MsgExecuteContractEncodeObject => { - return { - typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", - value: MsgExecuteContract.fromPartial({ - sender: this.sender, - contract: this.contractAddress, - msg: toUtf8(JSON.stringify({ - swap_tokens_for_specific_nfts: { - collection, - pool_nfts_to_swap_for: poolNftsToSwapFor, - swap_params: swapParams - } - })), - funds - }) - }; - }; - swapTokensForAnyNfts = ({ - collection, - maxExpectedTokenInput, - swapParams - }: { - collection: string; - maxExpectedTokenInput: Uint128[]; - swapParams: SwapParams; - }, funds?: Coin[]): MsgExecuteContractEncodeObject => { - return { - typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", - value: MsgExecuteContract.fromPartial({ - sender: this.sender, - contract: this.contractAddress, - msg: toUtf8(JSON.stringify({ - swap_tokens_for_any_nfts: { - collection, - max_expected_token_input: maxExpectedTokenInput, - swap_params: swapParams - } - })), - funds - }) - }; - }; -} \ No newline at end of file diff --git a/ts/src/InfinitySwap.client.ts b/ts/src/InfinitySwap.client.ts new file mode 100644 index 0000000..0c8b2d4 --- /dev/null +++ b/ts/src/InfinitySwap.client.ts @@ -0,0 +1,1170 @@ +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.24.0. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { + CosmWasmClient, + SigningCosmWasmClient, + ExecuteResult +} from "@cosmjs/cosmwasm-stargate" +import { Coin, StdFee } from "@cosmjs/amino" +import { + Addr, + ConfigResponse, + Config, + ExecuteMsg, + BondingCurve, + Uint128, + Timestamp, + Uint64, + NftSwap, + SwapParams, + PoolNftSwap, + InstantiateMsg, + PoolQuoteResponse, + PoolQuote, + Decimal, + PoolType, + PoolsByIdResponse, + Pool, + PoolsResponse, + QueryMsg, + QueryOptionsForUint64, + QueryOptionsForString, + QueryOptionsForTupleOfUint128AndUint64, + TransactionType, + SwapResponse, + Swap, + TokenPayment, + NftPayment +} from "./InfinitySwap.types" +export interface InfinityPoolReadOnlyInterface { + contractAddress: string + config: () => Promise + pools: ({ + queryOptions + }: { + queryOptions: QueryOptions_for_uint64 + }) => Promise + poolsById: ({ poolIds }: { poolIds: number[] }) => Promise + poolsByOwner: ({ + owner, + queryOptions + }: { + owner: string + queryOptions: QueryOptions_for_uint64 + }) => Promise + poolNftTokenIds: ({ + poolId, + queryOptions + }: { + poolId: number + queryOptions: QueryOptionsForString + }) => Promise + poolQuotesBuy: ({ + collection, + queryOptions + }: { + collection: string + queryOptions: QueryOptionsForTupleOfUint128_and_uint64 + }) => Promise + poolQuotesSell: ({ + collection, + queryOptions + }: { + collection: string + queryOptions: QueryOptionsForTupleOfUint128_and_uint64 + }) => Promise + simDirectSwapNftsForTokens: ({ + nftsToSwap, + poolId, + sender, + swapParams + }: { + nftsToSwap: NftSwap[] + poolId: number + sender: string + swapParams: SwapParams + }) => Promise + simSwapNftsForTokens: ({ + collection, + nftsToSwap, + sender, + swapParams + }: { + collection: string + nftsToSwap: NftSwap[] + sender: string + swapParams: SwapParams + }) => Promise + simDirectSwapTokensForSpecificNfts: ({ + nftsToSwapFor, + poolId, + sender, + swapParams + }: { + nftsToSwapFor: NftSwap[] + poolId: number + sender: string + swapParams: SwapParams + }) => Promise + simSwapTokensForSpecificNfts: ({ + collection, + poolNftsToSwapFor, + sender, + swapParams + }: { + collection: string + poolNftsToSwapFor: PoolNftSwap[] + sender: string + swapParams: SwapParams + }) => Promise + simSwapTokensForAnyNfts: ({ + collection, + maxExpectedTokenInput, + sender, + swapParams + }: { + collection: string + maxExpectedTokenInput: Uint128[] + sender: string + swapParams: SwapParams + }) => Promise +} +export class InfinityPoolQueryClient implements InfinityPoolReadOnlyInterface { + client: CosmWasmClient + contractAddress: string + + constructor(client: CosmWasmClient, contractAddress: string) { + this.client = client + this.contractAddress = contractAddress + this.config = this.config.bind(this) + this.pools = this.pools.bind(this) + this.poolsById = this.poolsById.bind(this) + this.poolsByOwner = this.poolsByOwner.bind(this) + this.poolNftTokenIds = this.poolNftTokenIds.bind(this) + this.poolQuotesBuy = this.poolQuotesBuy.bind(this) + this.poolQuotesSell = this.poolQuotesSell.bind(this) + this.simDirectSwapNftsForTokens = this.simDirectSwapNftsForTokens.bind(this) + this.simSwapNftsForTokens = this.simSwapNftsForTokens.bind(this) + this.simDirectSwapTokensForSpecificNfts = + this.simDirectSwapTokensForSpecificNfts.bind(this) + this.simSwapTokensForSpecificNfts = + this.simSwapTokensForSpecificNfts.bind(this) + this.simSwapTokensForAnyNfts = this.simSwapTokensForAnyNfts.bind(this) + } + + config = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + config: {} + }) + } + pools = async ({ + queryOptions + }: { + queryOptions: QueryOptions_for_uint64 + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + pools: { + query_options: queryOptions + } + }) + } + poolsById = async ({ + poolIds + }: { + poolIds: number[] + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + pools_by_id: { + pool_ids: poolIds + } + }) + } + poolsByOwner = async ({ + owner, + queryOptions + }: { + owner: string + queryOptions: QueryOptions_for_uint64 + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + pools_by_owner: { + owner, + query_options: queryOptions + } + }) + } + poolNftTokenIds = async ({ + poolId, + queryOptions + }: { + poolId: number + queryOptions: QueryOptionsForString + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + pool_nft_token_ids: { + pool_id: poolId, + query_options: queryOptions + } + }) + } + poolQuotesBuy = async ({ + collection, + queryOptions + }: { + collection: string + queryOptions: QueryOptionsForTupleOfUint128_and_uint64 + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + pool_quotes_buy: { + collection, + query_options: queryOptions + } + }) + } + poolQuotesSell = async ({ + collection, + queryOptions + }: { + collection: string + queryOptions: QueryOptionsForTupleOfUint128_and_uint64 + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + pool_quotes_sell: { + collection, + query_options: queryOptions + } + }) + } + simDirectSwapNftsForTokens = async ({ + nftsToSwap, + poolId, + sender, + swapParams + }: { + nftsToSwap: NftSwap[] + poolId: number + sender: string + swapParams: SwapParams + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + sim_direct_swap_nfts_for_tokens: { + nfts_to_swap: nftsToSwap, + pool_id: poolId, + sender, + swap_params: swapParams + } + }) + } + simSwapNftsForTokens = async ({ + collection, + nftsToSwap, + sender, + swapParams + }: { + collection: string + nftsToSwap: NftSwap[] + sender: string + swapParams: SwapParams + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + sim_swap_nfts_for_tokens: { + collection, + nfts_to_swap: nftsToSwap, + sender, + swap_params: swapParams + } + }) + } + simDirectSwapTokensForSpecificNfts = async ({ + nftsToSwapFor, + poolId, + sender, + swapParams + }: { + nftsToSwapFor: NftSwap[] + poolId: number + sender: string + swapParams: SwapParams + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + sim_direct_swap_tokens_for_specific_nfts: { + nfts_to_swap_for: nftsToSwapFor, + pool_id: poolId, + sender, + swap_params: swapParams + } + }) + } + simSwapTokensForSpecificNfts = async ({ + collection, + poolNftsToSwapFor, + sender, + swapParams + }: { + collection: string + poolNftsToSwapFor: PoolNftSwap[] + sender: string + swapParams: SwapParams + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + sim_swap_tokens_for_specific_nfts: { + collection, + pool_nfts_to_swap_for: poolNftsToSwapFor, + sender, + swap_params: swapParams + } + }) + } + simSwapTokensForAnyNfts = async ({ + collection, + maxExpectedTokenInput, + sender, + swapParams + }: { + collection: string + maxExpectedTokenInput: Uint128[] + sender: string + swapParams: SwapParams + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + sim_swap_tokens_for_any_nfts: { + collection, + max_expected_token_input: maxExpectedTokenInput, + sender, + swap_params: swapParams + } + }) + } +} +export interface InfinityPoolInterface extends InfinityPoolReadOnlyInterface { + contractAddress: string + sender: string + createTokenPool: ( + { + assetRecipient, + bondingCurve, + collection, + delta, + findersFeeBps, + spotPrice + }: { + assetRecipient?: string + bondingCurve: BondingCurve + collection: string + delta: Uint128 + findersFeeBps: number + spotPrice: Uint128 + }, + fee?: number | StdFee | "auto", + memo?: string, + funds?: Coin[] + ) => Promise + createNftPool: ( + { + assetRecipient, + bondingCurve, + collection, + delta, + findersFeeBps, + spotPrice + }: { + assetRecipient?: string + bondingCurve: BondingCurve + collection: string + delta: Uint128 + findersFeeBps: number + spotPrice: Uint128 + }, + fee?: number | StdFee | "auto", + memo?: string, + funds?: Coin[] + ) => Promise + createTradePool: ( + { + assetRecipient, + bondingCurve, + collection, + delta, + findersFeeBps, + reinvestNfts, + reinvestTokens, + spotPrice, + swapFeeBps + }: { + assetRecipient?: string + bondingCurve: BondingCurve + collection: string + delta: Uint128 + findersFeeBps: number + reinvestNfts: boolean + reinvestTokens: boolean + spotPrice: Uint128 + swapFeeBps: number + }, + fee?: number | StdFee | "auto", + memo?: string, + funds?: Coin[] + ) => Promise + depositTokens: ( + { + poolId + }: { + poolId: number + }, + fee?: number | StdFee | "auto", + memo?: string, + funds?: Coin[] + ) => Promise + depositNfts: ( + { + collection, + nftTokenIds, + poolId + }: { + collection: string + nftTokenIds: string[] + poolId: number + }, + fee?: number | StdFee | "auto", + memo?: string, + funds?: Coin[] + ) => Promise + withdrawTokens: ( + { + amount, + assetRecipient, + poolId + }: { + amount: Uint128 + assetRecipient?: string + poolId: number + }, + fee?: number | StdFee | "auto", + memo?: string, + funds?: Coin[] + ) => Promise + withdrawAllTokens: ( + { + assetRecipient, + poolId + }: { + assetRecipient?: string + poolId: number + }, + fee?: number | StdFee | "auto", + memo?: string, + funds?: Coin[] + ) => Promise + withdrawNfts: ( + { + assetRecipient, + nftTokenIds, + poolId + }: { + assetRecipient?: string + nftTokenIds: string[] + poolId: number + }, + fee?: number | StdFee | "auto", + memo?: string, + funds?: Coin[] + ) => Promise + withdrawAllNfts: ( + { + assetRecipient, + poolId + }: { + assetRecipient?: string + poolId: number + }, + fee?: number | StdFee | "auto", + memo?: string, + funds?: Coin[] + ) => Promise + updatePoolConfig: ( + { + assetRecipient, + delta, + findersFeeBps, + poolId, + reinvestNfts, + reinvestTokens, + spotPrice, + swapFeeBps + }: { + assetRecipient?: string + delta?: Uint128 + findersFeeBps?: number + poolId: number + reinvestNfts?: boolean + reinvestTokens?: boolean + spotPrice?: Uint128 + swapFeeBps?: number + }, + fee?: number | StdFee | "auto", + memo?: string, + funds?: Coin[] + ) => Promise + setActivePool: ( + { + isActive, + poolId + }: { + isActive: boolean + poolId: number + }, + fee?: number | StdFee | "auto", + memo?: string, + funds?: Coin[] + ) => Promise + removePool: ( + { + assetRecipient, + poolId + }: { + assetRecipient?: string + poolId: number + }, + fee?: number | StdFee | "auto", + memo?: string, + funds?: Coin[] + ) => Promise + directSwapNftsForTokens: ( + { + nftsToSwap, + poolId, + swapParams + }: { + nftsToSwap: NftSwap[] + poolId: number + swapParams: SwapParams + }, + fee?: number | StdFee | "auto", + memo?: string, + funds?: Coin[] + ) => Promise + swapNftsForTokens: ( + { + collection, + nftsToSwap, + swapParams + }: { + collection: string + nftsToSwap: NftSwap[] + swapParams: SwapParams + }, + fee?: number | StdFee | "auto", + memo?: string, + funds?: Coin[] + ) => Promise + directSwapTokensForSpecificNfts: ( + { + nftsToSwapFor, + poolId, + swapParams + }: { + nftsToSwapFor: NftSwap[] + poolId: number + swapParams: SwapParams + }, + fee?: number | StdFee | "auto", + memo?: string, + funds?: Coin[] + ) => Promise + swapTokensForSpecificNfts: ( + { + collection, + poolNftsToSwapFor, + swapParams + }: { + collection: string + poolNftsToSwapFor: PoolNftSwap[] + swapParams: SwapParams + }, + fee?: number | StdFee | "auto", + memo?: string, + funds?: Coin[] + ) => Promise + swapTokensForAnyNfts: ( + { + collection, + maxExpectedTokenInput, + swapParams + }: { + collection: string + maxExpectedTokenInput: Uint128[] + swapParams: SwapParams + }, + fee?: number | StdFee | "auto", + memo?: string, + funds?: Coin[] + ) => Promise +} +export class InfinityPoolClient + extends InfinityPoolQueryClient + implements InfinityPoolInterface +{ + client: SigningCosmWasmClient + sender: string + contractAddress: string + + constructor( + client: SigningCosmWasmClient, + sender: string, + contractAddress: string + ) { + super(client, contractAddress) + this.client = client + this.sender = sender + this.contractAddress = contractAddress + this.createTokenPool = this.createTokenPool.bind(this) + this.createNftPool = this.createNftPool.bind(this) + this.createTradePool = this.createTradePool.bind(this) + this.depositTokens = this.depositTokens.bind(this) + this.depositNfts = this.depositNfts.bind(this) + this.withdrawTokens = this.withdrawTokens.bind(this) + this.withdrawAllTokens = this.withdrawAllTokens.bind(this) + this.withdrawNfts = this.withdrawNfts.bind(this) + this.withdrawAllNfts = this.withdrawAllNfts.bind(this) + this.updatePoolConfig = this.updatePoolConfig.bind(this) + this.setActivePool = this.setActivePool.bind(this) + this.removePool = this.removePool.bind(this) + this.directSwapNftsForTokens = this.directSwapNftsForTokens.bind(this) + this.swapNftsForTokens = this.swapNftsForTokens.bind(this) + this.directSwapTokensForSpecificNfts = + this.directSwapTokensForSpecificNfts.bind(this) + this.swapTokensForSpecificNfts = this.swapTokensForSpecificNfts.bind(this) + this.swapTokensForAnyNfts = this.swapTokensForAnyNfts.bind(this) + } + + createTokenPool = async ( + { + assetRecipient, + bondingCurve, + collection, + delta, + findersFeeBps, + spotPrice + }: { + assetRecipient?: string + bondingCurve: BondingCurve + collection: string + delta: Uint128 + findersFeeBps: number + spotPrice: Uint128 + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + funds?: Coin[] + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + create_token_pool: { + asset_recipient: assetRecipient, + bonding_curve: bondingCurve, + collection, + delta, + finders_fee_bps: findersFeeBps, + spot_price: spotPrice + } + }, + fee, + memo, + funds + ) + } + createNftPool = async ( + { + assetRecipient, + bondingCurve, + collection, + delta, + findersFeeBps, + spotPrice + }: { + assetRecipient?: string + bondingCurve: BondingCurve + collection: string + delta: Uint128 + findersFeeBps: number + spotPrice: Uint128 + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + funds?: Coin[] + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + create_nft_pool: { + asset_recipient: assetRecipient, + bonding_curve: bondingCurve, + collection, + delta, + finders_fee_bps: findersFeeBps, + spot_price: spotPrice + } + }, + fee, + memo, + funds + ) + } + createTradePool = async ( + { + assetRecipient, + bondingCurve, + collection, + delta, + findersFeeBps, + reinvestNfts, + reinvestTokens, + spotPrice, + swapFeeBps + }: { + assetRecipient?: string + bondingCurve: BondingCurve + collection: string + delta: Uint128 + findersFeeBps: number + reinvestNfts: boolean + reinvestTokens: boolean + spotPrice: Uint128 + swapFeeBps: number + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + funds?: Coin[] + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + create_trade_pool: { + asset_recipient: assetRecipient, + bonding_curve: bondingCurve, + collection, + delta, + finders_fee_bps: findersFeeBps, + reinvest_nfts: reinvestNfts, + reinvest_tokens: reinvestTokens, + spot_price: spotPrice, + swap_fee_bps: swapFeeBps + } + }, + fee, + memo, + funds + ) + } + depositTokens = async ( + { + poolId + }: { + poolId: number + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + funds?: Coin[] + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + deposit_tokens: { + pool_id: poolId + } + }, + fee, + memo, + funds + ) + } + depositNfts = async ( + { + collection, + nftTokenIds, + poolId + }: { + collection: string + nftTokenIds: string[] + poolId: number + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + funds?: Coin[] + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + deposit_nfts: { + collection, + nft_token_ids: nftTokenIds, + pool_id: poolId + } + }, + fee, + memo, + funds + ) + } + withdrawTokens = async ( + { + amount, + assetRecipient, + poolId + }: { + amount: Uint128 + assetRecipient?: string + poolId: number + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + funds?: Coin[] + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + withdraw_tokens: { + amount, + asset_recipient: assetRecipient, + pool_id: poolId + } + }, + fee, + memo, + funds + ) + } + withdrawAllTokens = async ( + { + assetRecipient, + poolId + }: { + assetRecipient?: string + poolId: number + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + funds?: Coin[] + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + withdraw_all_tokens: { + asset_recipient: assetRecipient, + pool_id: poolId + } + }, + fee, + memo, + funds + ) + } + withdrawNfts = async ( + { + assetRecipient, + nftTokenIds, + poolId + }: { + assetRecipient?: string + nftTokenIds: string[] + poolId: number + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + funds?: Coin[] + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + withdraw_nfts: { + asset_recipient: assetRecipient, + nft_token_ids: nftTokenIds, + pool_id: poolId + } + }, + fee, + memo, + funds + ) + } + withdrawAllNfts = async ( + { + assetRecipient, + poolId + }: { + assetRecipient?: string + poolId: number + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + funds?: Coin[] + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + withdraw_all_nfts: { + asset_recipient: assetRecipient, + pool_id: poolId + } + }, + fee, + memo, + funds + ) + } + updatePoolConfig = async ( + { + assetRecipient, + delta, + findersFeeBps, + poolId, + reinvestNfts, + reinvestTokens, + spotPrice, + swapFeeBps + }: { + assetRecipient?: string + delta?: Uint128 + findersFeeBps?: number + poolId: number + reinvestNfts?: boolean + reinvestTokens?: boolean + spotPrice?: Uint128 + swapFeeBps?: number + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + funds?: Coin[] + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + update_pool_config: { + asset_recipient: assetRecipient, + delta, + finders_fee_bps: findersFeeBps, + pool_id: poolId, + reinvest_nfts: reinvestNfts, + reinvest_tokens: reinvestTokens, + spot_price: spotPrice, + swap_fee_bps: swapFeeBps + } + }, + fee, + memo, + funds + ) + } + setActivePool = async ( + { + isActive, + poolId + }: { + isActive: boolean + poolId: number + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + funds?: Coin[] + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + set_active_pool: { + is_active: isActive, + pool_id: poolId + } + }, + fee, + memo, + funds + ) + } + removePool = async ( + { + assetRecipient, + poolId + }: { + assetRecipient?: string + poolId: number + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + funds?: Coin[] + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + remove_pool: { + asset_recipient: assetRecipient, + pool_id: poolId + } + }, + fee, + memo, + funds + ) + } + directSwapNftsForTokens = async ( + { + nftsToSwap, + poolId, + swapParams + }: { + nftsToSwap: NftSwap[] + poolId: number + swapParams: SwapParams + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + funds?: Coin[] + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + direct_swap_nfts_for_tokens: { + nfts_to_swap: nftsToSwap, + pool_id: poolId, + swap_params: swapParams + } + }, + fee, + memo, + funds + ) + } + swapNftsForTokens = async ( + { + collection, + nftsToSwap, + swapParams + }: { + collection: string + nftsToSwap: NftSwap[] + swapParams: SwapParams + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + funds?: Coin[] + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + swap_nfts_for_tokens: { + collection, + nfts_to_swap: nftsToSwap, + swap_params: swapParams + } + }, + fee, + memo, + funds + ) + } + directSwapTokensForSpecificNfts = async ( + { + nftsToSwapFor, + poolId, + swapParams + }: { + nftsToSwapFor: NftSwap[] + poolId: number + swapParams: SwapParams + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + funds?: Coin[] + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + direct_swap_tokens_for_specific_nfts: { + nfts_to_swap_for: nftsToSwapFor, + pool_id: poolId, + swap_params: swapParams + } + }, + fee, + memo, + funds + ) + } + swapTokensForSpecificNfts = async ( + { + collection, + poolNftsToSwapFor, + swapParams + }: { + collection: string + poolNftsToSwapFor: PoolNftSwap[] + swapParams: SwapParams + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + funds?: Coin[] + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + swap_tokens_for_specific_nfts: { + collection, + pool_nfts_to_swap_for: poolNftsToSwapFor, + swap_params: swapParams + } + }, + fee, + memo, + funds + ) + } + swapTokensForAnyNfts = async ( + { + collection, + maxExpectedTokenInput, + swapParams + }: { + collection: string + maxExpectedTokenInput: Uint128[] + swapParams: SwapParams + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + funds?: Coin[] + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + swap_tokens_for_any_nfts: { + collection, + max_expected_token_input: maxExpectedTokenInput, + swap_params: swapParams + } + }, + fee, + memo, + funds + ) + } +} diff --git a/ts/src/InfinitySwap.message-composer.ts b/ts/src/InfinitySwap.message-composer.ts new file mode 100644 index 0000000..c033093 --- /dev/null +++ b/ts/src/InfinitySwap.message-composer.ts @@ -0,0 +1,841 @@ +/** + * This file was automatically generated by @cosmwasm/ts-codegen@0.24.0. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { Coin } from "@cosmjs/amino" +import { MsgExecuteContractEncodeObject } from "cosmwasm" +import { MsgExecuteContract } from "cosmjs-types/cosmwasm/wasm/v1/tx" +import { toUtf8 } from "@cosmjs/encoding" +import { + Addr, + ConfigResponse, + Config, + ExecuteMsg, + BondingCurve, + Uint128, + Timestamp, + Uint64, + NftSwap, + SwapParams, + PoolNftSwap, + InstantiateMsg, + PoolQuoteResponse, + PoolQuote, + Decimal, + PoolType, + PoolsByIdResponse, + Pool, + PoolsResponse, + QueryMsg, + QueryOptionsForUint64, + QueryOptionsForString, + QueryOptionsForTupleOfUint128AndUint64, + TransactionType, + SwapResponse, + Swap, + TokenPayment, + NftPayment +} from "./InfinitySwap.types" +export interface InfinityPoolMessage { + contractAddress: string + sender: string + createTokenPool: ( + { + assetRecipient, + bondingCurve, + collection, + delta, + findersFeeBps, + spotPrice + }: { + assetRecipient?: string + bondingCurve: BondingCurve + collection: string + delta: Uint128 + findersFeeBps: number + spotPrice: Uint128 + }, + funds?: Coin[] + ) => MsgExecuteContractEncodeObject + createNftPool: ( + { + assetRecipient, + bondingCurve, + collection, + delta, + findersFeeBps, + spotPrice + }: { + assetRecipient?: string + bondingCurve: BondingCurve + collection: string + delta: Uint128 + findersFeeBps: number + spotPrice: Uint128 + }, + funds?: Coin[] + ) => MsgExecuteContractEncodeObject + createTradePool: ( + { + assetRecipient, + bondingCurve, + collection, + delta, + findersFeeBps, + reinvestNfts, + reinvestTokens, + spotPrice, + swapFeeBps + }: { + assetRecipient?: string + bondingCurve: BondingCurve + collection: string + delta: Uint128 + findersFeeBps: number + reinvestNfts: boolean + reinvestTokens: boolean + spotPrice: Uint128 + swapFeeBps: number + }, + funds?: Coin[] + ) => MsgExecuteContractEncodeObject + depositTokens: ( + { + poolId + }: { + poolId: number + }, + funds?: Coin[] + ) => MsgExecuteContractEncodeObject + depositNfts: ( + { + collection, + nftTokenIds, + poolId + }: { + collection: string + nftTokenIds: string[] + poolId: number + }, + funds?: Coin[] + ) => MsgExecuteContractEncodeObject + withdrawTokens: ( + { + amount, + assetRecipient, + poolId + }: { + amount: Uint128 + assetRecipient?: string + poolId: number + }, + funds?: Coin[] + ) => MsgExecuteContractEncodeObject + withdrawAllTokens: ( + { + assetRecipient, + poolId + }: { + assetRecipient?: string + poolId: number + }, + funds?: Coin[] + ) => MsgExecuteContractEncodeObject + withdrawNfts: ( + { + assetRecipient, + nftTokenIds, + poolId + }: { + assetRecipient?: string + nftTokenIds: string[] + poolId: number + }, + funds?: Coin[] + ) => MsgExecuteContractEncodeObject + withdrawAllNfts: ( + { + assetRecipient, + poolId + }: { + assetRecipient?: string + poolId: number + }, + funds?: Coin[] + ) => MsgExecuteContractEncodeObject + updatePoolConfig: ( + { + assetRecipient, + delta, + findersFeeBps, + poolId, + reinvestNfts, + reinvestTokens, + spotPrice, + swapFeeBps + }: { + assetRecipient?: string + delta?: Uint128 + findersFeeBps?: number + poolId: number + reinvestNfts?: boolean + reinvestTokens?: boolean + spotPrice?: Uint128 + swapFeeBps?: number + }, + funds?: Coin[] + ) => MsgExecuteContractEncodeObject + setActivePool: ( + { + isActive, + poolId + }: { + isActive: boolean + poolId: number + }, + funds?: Coin[] + ) => MsgExecuteContractEncodeObject + removePool: ( + { + assetRecipient, + poolId + }: { + assetRecipient?: string + poolId: number + }, + funds?: Coin[] + ) => MsgExecuteContractEncodeObject + directSwapNftsForTokens: ( + { + nftsToSwap, + poolId, + swapParams + }: { + nftsToSwap: NftSwap[] + poolId: number + swapParams: SwapParams + }, + funds?: Coin[] + ) => MsgExecuteContractEncodeObject + swapNftsForTokens: ( + { + collection, + nftsToSwap, + swapParams + }: { + collection: string + nftsToSwap: NftSwap[] + swapParams: SwapParams + }, + funds?: Coin[] + ) => MsgExecuteContractEncodeObject + directSwapTokensForSpecificNfts: ( + { + nftsToSwapFor, + poolId, + swapParams + }: { + nftsToSwapFor: NftSwap[] + poolId: number + swapParams: SwapParams + }, + funds?: Coin[] + ) => MsgExecuteContractEncodeObject + swapTokensForSpecificNfts: ( + { + collection, + poolNftsToSwapFor, + swapParams + }: { + collection: string + poolNftsToSwapFor: PoolNftSwap[] + swapParams: SwapParams + }, + funds?: Coin[] + ) => MsgExecuteContractEncodeObject + swapTokensForAnyNfts: ( + { + collection, + maxExpectedTokenInput, + swapParams + }: { + collection: string + maxExpectedTokenInput: Uint128[] + swapParams: SwapParams + }, + funds?: Coin[] + ) => MsgExecuteContractEncodeObject +} +export class InfinityPoolMessageComposer implements InfinityPoolMessage { + sender: string + contractAddress: string + + constructor(sender: string, contractAddress: string) { + this.sender = sender + this.contractAddress = contractAddress + this.createTokenPool = this.createTokenPool.bind(this) + this.createNftPool = this.createNftPool.bind(this) + this.createTradePool = this.createTradePool.bind(this) + this.depositTokens = this.depositTokens.bind(this) + this.depositNfts = this.depositNfts.bind(this) + this.withdrawTokens = this.withdrawTokens.bind(this) + this.withdrawAllTokens = this.withdrawAllTokens.bind(this) + this.withdrawNfts = this.withdrawNfts.bind(this) + this.withdrawAllNfts = this.withdrawAllNfts.bind(this) + this.updatePoolConfig = this.updatePoolConfig.bind(this) + this.setActivePool = this.setActivePool.bind(this) + this.removePool = this.removePool.bind(this) + this.directSwapNftsForTokens = this.directSwapNftsForTokens.bind(this) + this.swapNftsForTokens = this.swapNftsForTokens.bind(this) + this.directSwapTokensForSpecificNfts = + this.directSwapTokensForSpecificNfts.bind(this) + this.swapTokensForSpecificNfts = this.swapTokensForSpecificNfts.bind(this) + this.swapTokensForAnyNfts = this.swapTokensForAnyNfts.bind(this) + } + + createTokenPool = ( + { + assetRecipient, + bondingCurve, + collection, + delta, + findersFeeBps, + spotPrice + }: { + assetRecipient?: string + bondingCurve: BondingCurve + collection: string + delta: Uint128 + findersFeeBps: number + spotPrice: Uint128 + }, + funds?: Coin[] + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + create_token_pool: { + asset_recipient: assetRecipient, + bonding_curve: bondingCurve, + collection, + delta, + finders_fee_bps: findersFeeBps, + spot_price: spotPrice + } + }) + ), + funds + }) + } + } + createNftPool = ( + { + assetRecipient, + bondingCurve, + collection, + delta, + findersFeeBps, + spotPrice + }: { + assetRecipient?: string + bondingCurve: BondingCurve + collection: string + delta: Uint128 + findersFeeBps: number + spotPrice: Uint128 + }, + funds?: Coin[] + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + create_nft_pool: { + asset_recipient: assetRecipient, + bonding_curve: bondingCurve, + collection, + delta, + finders_fee_bps: findersFeeBps, + spot_price: spotPrice + } + }) + ), + funds + }) + } + } + createTradePool = ( + { + assetRecipient, + bondingCurve, + collection, + delta, + findersFeeBps, + reinvestNfts, + reinvestTokens, + spotPrice, + swapFeeBps + }: { + assetRecipient?: string + bondingCurve: BondingCurve + collection: string + delta: Uint128 + findersFeeBps: number + reinvestNfts: boolean + reinvestTokens: boolean + spotPrice: Uint128 + swapFeeBps: number + }, + funds?: Coin[] + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + create_trade_pool: { + asset_recipient: assetRecipient, + bonding_curve: bondingCurve, + collection, + delta, + finders_fee_bps: findersFeeBps, + reinvest_nfts: reinvestNfts, + reinvest_tokens: reinvestTokens, + spot_price: spotPrice, + swap_fee_bps: swapFeeBps + } + }) + ), + funds + }) + } + } + depositTokens = ( + { + poolId + }: { + poolId: number + }, + funds?: Coin[] + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + deposit_tokens: { + pool_id: poolId + } + }) + ), + funds + }) + } + } + depositNfts = ( + { + collection, + nftTokenIds, + poolId + }: { + collection: string + nftTokenIds: string[] + poolId: number + }, + funds?: Coin[] + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + deposit_nfts: { + collection, + nft_token_ids: nftTokenIds, + pool_id: poolId + } + }) + ), + funds + }) + } + } + withdrawTokens = ( + { + amount, + assetRecipient, + poolId + }: { + amount: Uint128 + assetRecipient?: string + poolId: number + }, + funds?: Coin[] + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + withdraw_tokens: { + amount, + asset_recipient: assetRecipient, + pool_id: poolId + } + }) + ), + funds + }) + } + } + withdrawAllTokens = ( + { + assetRecipient, + poolId + }: { + assetRecipient?: string + poolId: number + }, + funds?: Coin[] + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + withdraw_all_tokens: { + asset_recipient: assetRecipient, + pool_id: poolId + } + }) + ), + funds + }) + } + } + withdrawNfts = ( + { + assetRecipient, + nftTokenIds, + poolId + }: { + assetRecipient?: string + nftTokenIds: string[] + poolId: number + }, + funds?: Coin[] + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + withdraw_nfts: { + asset_recipient: assetRecipient, + nft_token_ids: nftTokenIds, + pool_id: poolId + } + }) + ), + funds + }) + } + } + withdrawAllNfts = ( + { + assetRecipient, + poolId + }: { + assetRecipient?: string + poolId: number + }, + funds?: Coin[] + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + withdraw_all_nfts: { + asset_recipient: assetRecipient, + pool_id: poolId + } + }) + ), + funds + }) + } + } + updatePoolConfig = ( + { + assetRecipient, + delta, + findersFeeBps, + poolId, + reinvestNfts, + reinvestTokens, + spotPrice, + swapFeeBps + }: { + assetRecipient?: string + delta?: Uint128 + findersFeeBps?: number + poolId: number + reinvestNfts?: boolean + reinvestTokens?: boolean + spotPrice?: Uint128 + swapFeeBps?: number + }, + funds?: Coin[] + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + update_pool_config: { + asset_recipient: assetRecipient, + delta, + finders_fee_bps: findersFeeBps, + pool_id: poolId, + reinvest_nfts: reinvestNfts, + reinvest_tokens: reinvestTokens, + spot_price: spotPrice, + swap_fee_bps: swapFeeBps + } + }) + ), + funds + }) + } + } + setActivePool = ( + { + isActive, + poolId + }: { + isActive: boolean + poolId: number + }, + funds?: Coin[] + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + set_active_pool: { + is_active: isActive, + pool_id: poolId + } + }) + ), + funds + }) + } + } + removePool = ( + { + assetRecipient, + poolId + }: { + assetRecipient?: string + poolId: number + }, + funds?: Coin[] + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + remove_pool: { + asset_recipient: assetRecipient, + pool_id: poolId + } + }) + ), + funds + }) + } + } + directSwapNftsForTokens = ( + { + nftsToSwap, + poolId, + swapParams + }: { + nftsToSwap: NftSwap[] + poolId: number + swapParams: SwapParams + }, + funds?: Coin[] + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + direct_swap_nfts_for_tokens: { + nfts_to_swap: nftsToSwap, + pool_id: poolId, + swap_params: swapParams + } + }) + ), + funds + }) + } + } + swapNftsForTokens = ( + { + collection, + nftsToSwap, + swapParams + }: { + collection: string + nftsToSwap: NftSwap[] + swapParams: SwapParams + }, + funds?: Coin[] + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + swap_nfts_for_tokens: { + collection, + nfts_to_swap: nftsToSwap, + swap_params: swapParams + } + }) + ), + funds + }) + } + } + directSwapTokensForSpecificNfts = ( + { + nftsToSwapFor, + poolId, + swapParams + }: { + nftsToSwapFor: NftSwap[] + poolId: number + swapParams: SwapParams + }, + funds?: Coin[] + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + direct_swap_tokens_for_specific_nfts: { + nfts_to_swap_for: nftsToSwapFor, + pool_id: poolId, + swap_params: swapParams + } + }) + ), + funds + }) + } + } + swapTokensForSpecificNfts = ( + { + collection, + poolNftsToSwapFor, + swapParams + }: { + collection: string + poolNftsToSwapFor: PoolNftSwap[] + swapParams: SwapParams + }, + funds?: Coin[] + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + swap_tokens_for_specific_nfts: { + collection, + pool_nfts_to_swap_for: poolNftsToSwapFor, + swap_params: swapParams + } + }) + ), + funds + }) + } + } + swapTokensForAnyNfts = ( + { + collection, + maxExpectedTokenInput, + swapParams + }: { + collection: string + maxExpectedTokenInput: Uint128[] + swapParams: SwapParams + }, + funds?: Coin[] + ): MsgExecuteContractEncodeObject => { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", + value: MsgExecuteContract.fromPartial({ + sender: this.sender, + contract: this.contractAddress, + msg: toUtf8( + JSON.stringify({ + swap_tokens_for_any_nfts: { + collection, + max_expected_token_input: maxExpectedTokenInput, + swap_params: swapParams + } + }) + ), + funds + }) + } + } +} diff --git a/ts/src/InfinityPool.types.ts b/ts/src/InfinitySwap.types.ts similarity index 100% rename from ts/src/InfinityPool.types.ts rename to ts/src/InfinitySwap.types.ts