-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Owner and payer #209
Comments
Hi @stasdem The correct data type for "owner" is actually Keypair. Don't use Account type since it's deprecated. Confusingly, though, if you want to pay with the owner address you will need to use its public key:
For unsettled funds, serum has two holding accounts called base token account and quote token account
Based on where the coins are coming from (settled funds = main SOL address | SPL token address; unsettled funds = quote token account | base token account), you place the public key in place as the payer, and you should be good to go. Again payer is a publicKey type, while owner is actually Keypair. Hope that helps! |
@ashpoolin are there any official docs on this? I also found this confusing. |
After playing around with this a bit more, I find myself confused. The two function calls you listed // copy this from Phantom: Settings > Export Private Key
const secretKey = process.env.WALLET_SECRET
const connection = new Connection('https://solana-api.projectserum.com');
const owner = Keypair.fromSecretKey(bs58.decode(secretKey));
const ownerPublicKey = owner.publicKey
// create associated token accounts for spl-token if they don't exist yet
const usdcMint = new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')
const usdcToken = new Token(connection, usdcMint, TOKEN_PROGRAM_ID, owner)
const ownerTokenAccount = await usdcToken.getOrCreateAssociatedAccountInfo(ownerPublicKey);
const solUsdcMarket = new PublicKey('9wFFyRfZBsuAha4YcuxcXLKwMxJR43S7fPfQLusDBzvT');
const serumAddress = new PublicKey('9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin')
const market = await Market.load(connection, solUsdcMarket, {}, serumAddress)
const base = await market.findBaseTokenAccountsForOwner(connection, ownerPublicKey, true)
const solHoldingAccount = base[0].pubkey // logged this returns my sol address
const quote = await market.findQuoteTokenAccountsForOwner(connection, ownerPublicKey, true)
const usdcHoldingAccount = quote[0].pubkey // logged, this returns my spl token address |
It's not documented, but I tried to write down my theories on the different payer accounts in a table in here (about halfway through): https://ashpoolin.github.io/how-tf-do-you-use-serum-ts-client In the case you mentioned, do you have any unsettled funds in a market? If so maybe the base and quote token accounts might be different. But currently, your base token is SOL, so it makes sense that it's just looking at your main address, and quote token USDC is pointing to the SPL token address. Please pardon my sloppy language, I'm just a blind person going by feel... Anybody who knows the answer please feel free to correct me. |
That table is very useful. And yeah, no unsettled funds, so your explanation makes sense. Would be nice if we could figure out a way to map error hex codes to the underlying causes: https://github.com/project-serum/serum-dex/blob/master/dex/src/error.rs That'd at least make debugging these sort of things easier |
This is actually related to how Solana work. Each account will have many related accounts called Link to the Solana docs: When A special case is when the token is SOL, where it just considered your main wallet address as a token account. p/s: The |
Hello your docs it's very clear, thank you. But can you tell me how to make size smaller than 1, i.e. 0.1? Because when I use decimal parts they are automatically rounded to 0. |
Hi
I want to place orders but I dont understand who are owner and payer and what I need to put in this variables.
// Placing orders
let owner = new Account('????????');
console.log(owner)
let payer = new PublicKey('????????'); // spl-token account
console.log(payer)
await market.placeOrder(connection, {
owner,
payer,
side: 'buy', // 'buy' or 'sell'
price: 14.77,
size: 1.0,
orderType: 'limit', // 'limit', 'ioc', 'postOnly'
});
I have tried to put in owner private key, mnemonic, address. It's all not working
Help me please
The text was updated successfully, but these errors were encountered: