Open armaniferrante opened 3 years ago
I think this is pretty important to do since it adds unnecessary boilerplate when composing with the dex, since the standard tooling for creating nonce (e.g., Pubkey.findProgramAddress
) doesn't work and so one has to create their own nonce generation function, e.g.,
async function getVaultOwnerAndNonce(market) {
const nonce = new BN(0);
while (true) {
try {
const vaultOwner = await PublicKey.createProgramAddress(
[market.publicKey.toBuffer(), nonce.toArrayLike(Buffer, "le", 8)],
dexProgramId
);
return [vaultOwner, nonce];
} catch (e) {
nonce.iaddn(1);
}
}
}
A
u64
used for the nonce/bump seed, rather than au8
. This is inconsistent with the rest of the solana tooling, creating confusion when integrating with the dex. See https://github.com/project-serum/serum-dex/blob/master/dex/src/state.rs#L1154.