πͺPermissionless Vaults
Instantiating a CPMM Vault
import { NETWORK } from '@injectivelabs/networks'
import { MsgBroadcaster } from "@injectivelabs/wallet-ts"
import {
Coin,
toUtf8,
toBase64,
IndexerGrpcMitoApi,
ChainGrpcTokenFactoryApi,
MsgExecuteContractCompat,
} from "@injectivelabs/sdk-ts";
export const msgBroadcastClient = new MsgBroadcaster({
walletStrategy /* instantiated wallet strategy */,
network: NETWORK.Devnet,
});
// Devnet configuration
const CPMM_CONTRACT_CODE = 5;
const MITO_MASTER_CONTRACT_ADDRESS = "inj1wug8sewp6cedgkmrmvhl3lf3tulagm9h5uhctd";
// Mainnet configuration
// const CPMM_CONTRACT_CODE = 540;
// const MITO_MASTER_CONTRACT_ADDRESS = "inj1vcqkkvqs7prqu70dpddfj7kqeqfdz5gg662qs3";
const funds = [
{
denom: 'inj',
amount: '70000000000000000000' // 70 INJ
},
{
denom: 'factory/creatorAddress/subDenom',
amount: '2100000000' // 2100 of the custom token
}
];
const senderWalletAddress = 'inj...';
const marketId = '0x....';
const feeBps = 100; // 1%
const baseDecimals = 6;
const quoteDecimals = 18;
export const instantiateCPMMVault = async () => {
const msgs = MsgExecuteContractCompat.fromJSON({
contractAddress: MITO_MASTER_CONTRACT_ADDRESS,
funds,
exec: {
action: 'register_vault',
msg: {
is_subscribing_with_funds: true,
registration_mode: {
permissionless: {
whitelisted_vault_code_id: CPMM_CONTRACT_CODE,
},
},
instantiate_vault_msg: {
Amm: {
owner: senderWalletAddress,
master_address: MITO_MASTER_CONTRACT_ADDRESS,
notional_value_cap: '100000000000000000000000', // 100,000 INJ
market_id: marketId,
pricing_strategy: {
SmoothingPricingWithRelativePriceRange: {
bid_range: '0.8',
ask_range: '0.8',
},
},
max_invariant_sensitivity_bps: '5',
max_price_sensitivity_bps: '5',
fee_bps: 100,
order_type: 'Vanilla',
config_owner: senderWalletAddress,
base_decimals: baseDecimals,
quote_decimals: quoteDecimals,
},
},
},
},
sender: senderWalletAddress,
});
await msgBroadcastClient.broadcastV2({
address: senderWalletAddress,
msgs,
});
};
Querying Vaults
Querying Vault Creation Fee
Last updated