diff --git a/ts-client/package.json b/ts-client/package.json index 9e314148..4acf7e12 100644 --- a/ts-client/package.json +++ b/ts-client/package.json @@ -1,6 +1,6 @@ { "name": "@mercurial-finance/dynamic-amm-sdk", - "version": "0.4.12", + "version": "0.4.13", "description": "Mercurial Vaults SDK is a typescript library that allows you to interact with Mercurial v2's AMM.", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", diff --git a/ts-client/src/amm/index.ts b/ts-client/src/amm/index.ts index 857fcc21..0bc7d6bf 100644 --- a/ts-client/src/amm/index.ts +++ b/ts-client/src/amm/index.ts @@ -149,7 +149,6 @@ export default class AmmImpl implements AmmImplementation { public poolInfo: PoolInformation, public vaultA: VaultImpl, public vaultB: VaultImpl, - private accountsBufferMap: Map, private accountsInfo: AccountsInfo, private swapCurve: SwapCurve, private depegAccounts: Map>, @@ -456,7 +455,6 @@ export default class AmmImpl implements AmmImplementation { poolInfo, vaultA, vaultB, - accountsBufferMap, accountsInfo, swapCurve, depegAccounts, @@ -590,7 +588,6 @@ export default class AmmImpl implements AmmImplementation { poolInfo, vaultA, vaultB, - accountsBufferMap, accountsInfo, swapCurve, depegAccounts, @@ -661,7 +658,17 @@ export default class AmmImpl implements AmmImplementation { this.vaultB.refreshVaultState(), ]); - const accountsInfoMap = deserializeAccountsBuffer(this.accountsBufferMap); + const accountsBufferMap = await getAccountsBuffer(this.program.provider.connection, [ + { pubkey: this.vaultA.vaultState.tokenVault, type: AccountType.VAULT_A_RESERVE }, + { pubkey: this.vaultB.vaultState.tokenVault, type: AccountType.VAULT_B_RESERVE }, + { pubkey: this.vaultA.vaultState.lpMint, type: AccountType.VAULT_A_LP }, + { pubkey: this.vaultB.vaultState.lpMint, type: AccountType.VAULT_B_LP }, + { pubkey: poolState.aVaultLp, type: AccountType.POOL_VAULT_A_LP }, + { pubkey: poolState.bVaultLp, type: AccountType.POOL_VAULT_B_LP }, + { pubkey: poolState.lpMint, type: AccountType.POOL_LP_MINT }, + { pubkey: SYSVAR_CLOCK_PUBKEY, type: AccountType.SYSVAR_CLOCK }, + ]); + const accountsInfoMap = deserializeAccountsBuffer(accountsBufferMap); const currentTime = accountsInfoMap.get(SYSVAR_CLOCK_PUBKEY.toBase58()) as BN; const poolVaultALp = accountsInfoMap.get(poolState.aVaultLp.toBase58()) as BN; @@ -696,6 +703,9 @@ export default class AmmImpl implements AmmImplementation { }; this.accountsInfo = accountsInfo; + const depegAccounts = await getDepegAccounts(this.program.provider.connection, [poolState]); + this.depegAccounts = depegAccounts; + if (this.isStablePool) { // update swap curve const { amp, depeg, tokenMultiplier } = poolState.curveType['stable'];