From 75b4066313b7490415791e116d44b2fd606647e1 Mon Sep 17 00:00:00 2001 From: quangkeu95 Date: Wed, 10 Jan 2024 15:10:58 +0700 Subject: [PATCH] fix: Rebase main --- ts-client/pnpm-lock.yaml | 104 +++++++++--------- ts-client/src/amm/tests/pool.test.ts | 20 ++-- ts-client/src/amm/tests/utils/pool.ts | 4 +- .../src/amm/types/PoolCreatedSimulation.ts | 4 + ts-client/src/amm/types/index.ts | 1 + 5 files changed, 70 insertions(+), 63 deletions(-) create mode 100644 ts-client/src/amm/types/PoolCreatedSimulation.ts diff --git a/ts-client/pnpm-lock.yaml b/ts-client/pnpm-lock.yaml index 8654f0f6..a4048277 100644 --- a/ts-client/pnpm-lock.yaml +++ b/ts-client/pnpm-lock.yaml @@ -133,7 +133,7 @@ packages: '@babel/generator': 7.23.6 '@babel/helper-compilation-targets': 7.23.6 '@babel/helper-module-transforms': 7.23.3(@babel/core@7.23.7) - '@babel/helpers': 7.23.7 + '@babel/helpers': 7.23.8 '@babel/parser': 7.23.6 '@babel/template': 7.22.15 '@babel/traverse': 7.23.7 @@ -243,8 +243,8 @@ packages: engines: {node: '>=6.9.0'} dev: true - /@babel/helpers@7.23.7: - resolution: {integrity: sha512-6AMnjCoC8wjqBzDHkuqpa7jAKwvMo4dC+lr/TFBz+ucfulO1XMpDnwWPGBNwClOKZ8h6xn5N81W/R5OrcKtCbQ==} + /@babel/helpers@7.23.8: + resolution: {integrity: sha512-KDqYz4PiOWvDFrdHLPhKtCThtIcKVy6avWD2oG4GEvyQ+XDZwHD4YQd+H2vNMnq2rkdxsDkU82T+Vk8U/WXHRQ==} engines: {node: '>=6.9.0'} dependencies: '@babel/template': 7.22.15 @@ -390,8 +390,8 @@ packages: '@babel/helper-plugin-utils': 7.22.5 dev: true - /@babel/runtime@7.23.7: - resolution: {integrity: sha512-w06OXVOFso7LcbzMiDGt+3X7Rh7Ho8MmgPoWU3rarH+8upf+wSU/grlGbWzQyr3DkdN6ZeuMFjpdwW0Q+HxobA==} + /@babel/runtime@7.23.8: + resolution: {integrity: sha512-Y7KbAP984rn1VGMbGqKmBLio9V7y5Je9GvU4rQPCPinCyNfUcToxIXl06d59URp/F3LwinvODxab5N/G6qggkw==} engines: {node: '>=6.9.0'} dependencies: regenerator-runtime: 0.14.1 @@ -586,7 +586,7 @@ packages: engines: {node: ^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0} dependencies: '@jest/types': 28.1.3 - '@types/node': 20.10.6 + '@types/node': 20.10.8 chalk: 4.1.2 jest-message-util: 28.1.3 jest-util: 28.1.3 @@ -607,14 +607,14 @@ packages: '@jest/test-result': 28.1.3 '@jest/transform': 28.1.3 '@jest/types': 28.1.3 - '@types/node': 20.10.6 + '@types/node': 20.10.8 ansi-escapes: 4.3.2 chalk: 4.1.2 ci-info: 3.9.0 exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 28.1.3 - jest-config: 28.1.3(@types/node@20.10.6) + jest-config: 28.1.3(@types/node@20.10.8) jest-haste-map: 28.1.3 jest-message-util: 28.1.3 jest-regex-util: 28.0.2 @@ -642,7 +642,7 @@ packages: dependencies: '@jest/fake-timers': 28.1.3 '@jest/types': 28.1.3 - '@types/node': 20.10.6 + '@types/node': 20.10.8 jest-mock: 28.1.3 dev: true @@ -669,7 +669,7 @@ packages: dependencies: '@jest/types': 28.1.3 '@sinonjs/fake-timers': 9.1.2 - '@types/node': 20.10.6 + '@types/node': 20.10.8 jest-message-util: 28.1.3 jest-mock: 28.1.3 jest-util: 28.1.3 @@ -701,7 +701,7 @@ packages: '@jest/transform': 28.1.3 '@jest/types': 28.1.3 '@jridgewell/trace-mapping': 0.3.20 - '@types/node': 20.10.6 + '@types/node': 20.10.8 chalk: 4.1.2 collect-v8-coverage: 1.0.2 exit: 0.1.2 @@ -790,7 +790,7 @@ packages: '@jest/schemas': 28.1.3 '@types/istanbul-lib-coverage': 2.0.6 '@types/istanbul-reports': 3.0.4 - '@types/node': 20.10.6 + '@types/node': 20.10.8 '@types/yargs': 17.0.32 chalk: 4.1.2 dev: true @@ -1756,7 +1756,7 @@ packages: resolution: {integrity: sha512-LZmYCKcPQDtJgecvWOgT/cnoIQPWjdH+QVyzPcFvyDUiT0DiRjZaam4aqNUyvchLFhzgunv3d9xOoyE34ofdoQ==} engines: {node: '>= 10'} dependencies: - '@babel/runtime': 7.23.7 + '@babel/runtime': 7.23.8 '@solana/web3.js': 1.88.0 bn.js: 5.2.1 buffer: 6.0.3 @@ -1783,11 +1783,11 @@ packages: - utf-8-validate dev: false - /@solana/spl-token@0.3.10(@solana/web3.js@1.88.0)(fastestsmallesttextencoderdecoder@1.0.22): - resolution: {integrity: sha512-YFCtV8yC64Ef2w2HKOSNYwcsMt70e/GLMZYkZbdD6tYOlp4NnjUkY1EYxtIbVhsm3LSXoJV43u5chnMni+gr7w==} + /@solana/spl-token@0.3.11(@solana/web3.js@1.88.0)(fastestsmallesttextencoderdecoder@1.0.22): + resolution: {integrity: sha512-bvohO3rIMSVL24Pb+I4EYTJ6cL82eFpInEXD/I8K8upOGjpqHsKUoAempR/RnUlI1qSFNyFlWJfu6MNUgfbCQQ==} engines: {node: '>=16'} peerDependencies: - '@solana/web3.js': ^1.87.6 + '@solana/web3.js': ^1.88.0 dependencies: '@solana/buffer-layout': 4.0.0 '@solana/buffer-layout-utils': 0.2.0 @@ -1849,7 +1849,7 @@ packages: resolution: {integrity: sha512-RyaHMR2jGmaesnYP045VLeBGfR/gAW3cvZHzMFGg7bkO+WOYOYp1nEllf0/la4U4qsYGKCsO9eEevR5fhHiVHg==} engines: {node: '>=12.20.0'} dependencies: - '@babel/runtime': 7.23.7 + '@babel/runtime': 7.23.8 '@noble/ed25519': 1.7.3 '@noble/hashes': 1.3.3 '@noble/secp256k1': 1.7.1 @@ -1874,7 +1874,7 @@ packages: resolution: {integrity: sha512-xMoCk0y/GpiQhHbRjMcrd5NpmkwhAA0c01id7lrr6nhNdz6Uc/CywPdBeZw3Qz6BVZ/qlUoerpKPWeiXqMUjwA==} engines: {node: '>=12.20.0'} dependencies: - '@babel/runtime': 7.23.7 + '@babel/runtime': 7.23.8 '@noble/ed25519': 1.7.3 '@noble/hashes': 1.3.3 '@noble/secp256k1': 1.7.1 @@ -1899,7 +1899,7 @@ packages: /@solana/web3.js@1.88.0: resolution: {integrity: sha512-E4BdfB0HZpb66OPFhIzPApNE2tG75Mc6XKIoeymUkx/IV+USSYuxDX29sjgE/KGNYxggrOf4YuYnRMI6UiPL8w==} dependencies: - '@babel/runtime': 7.23.7 + '@babel/runtime': 7.23.8 '@noble/curves': 1.3.0 '@noble/hashes': 1.3.3 '@solana/buffer-layout': 4.0.1 @@ -1951,7 +1951,7 @@ packages: dependencies: '@coral-xyz/anchor': 0.28.0 '@coral-xyz/borsh': 0.28.0(@solana/web3.js@1.88.0) - '@solana/spl-token': 0.3.10(@solana/web3.js@1.88.0)(fastestsmallesttextencoderdecoder@1.0.22) + '@solana/spl-token': 0.3.11(@solana/web3.js@1.88.0)(fastestsmallesttextencoderdecoder@1.0.22) '@solana/web3.js': 1.88.0 '@switchboard-xyz/common': 2.3.15 cron-validator: 1.3.1 @@ -2043,7 +2043,7 @@ packages: /@types/bn.js@5.1.5: resolution: {integrity: sha512-V46N0zwKRF5Q00AZ6hWtN0T8gGmDUaUzLWQvHFo5yThtVwK/VCenFY3wXVbOvNfajEpsTfQM4IN9k/d6gUVX3A==} dependencies: - '@types/node': 20.10.6 + '@types/node': 20.10.8 dev: true /@types/chai@4.3.11: @@ -2059,7 +2059,7 @@ packages: /@types/graceful-fs@4.1.9: resolution: {integrity: sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==} dependencies: - '@types/node': 20.10.6 + '@types/node': 20.10.8 dev: true /@types/invariant@2.2.37: @@ -2107,8 +2107,8 @@ packages: resolution: {integrity: sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==} dev: false - /@types/node@20.10.6: - resolution: {integrity: sha512-Vac8H+NlRNNlAmDfGUP7b5h/KA+AtWIzuXy0E6OyP8f1tCLYAtPvKRRDJjAPqhpCb0t6U2j7/xqAuLEebW2kiw==} + /@types/node@20.10.8: + resolution: {integrity: sha512-f8nQs3cLxbAFc00vEU59yf9UyGUftkPaLGfvbVOIDdx2i1b8epBqj2aNGyP19fiyXWvlmZ7qC1XLjAzw/OKIeA==} dependencies: undici-types: 5.26.5 @@ -2497,8 +2497,8 @@ packages: engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true dependencies: - caniuse-lite: 1.0.30001574 - electron-to-chromium: 1.4.623 + caniuse-lite: 1.0.30001576 + electron-to-chromium: 1.4.626 node-releases: 2.0.14 update-browserslist-db: 1.0.13(browserslist@4.22.2) dev: true @@ -2555,7 +2555,7 @@ packages: engines: {node: '>=6.14.2'} requiresBuild: true dependencies: - node-gyp-build: 4.7.1 + node-gyp-build: 4.8.0 dev: false /call-bind@1.0.5: @@ -2579,8 +2579,8 @@ packages: resolution: {integrity: sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==} engines: {node: '>=10'} - /caniuse-lite@1.0.30001574: - resolution: {integrity: sha512-BtYEK4r/iHt/txm81KBudCUcTy7t+s9emrIaHqjYurQ10x71zJ5VQ9x1dYPcz/b+pKSp4y/v1xSI67A+LzpNyg==} + /caniuse-lite@1.0.30001576: + resolution: {integrity: sha512-ff5BdakGe2P3SQsMsiqmt1Lc8221NR1VzHj5jXN5vBny9A6fpze94HiVV/n7XRosOlsShJcvMv5mdnpjOGCEgg==} dev: true /case-anything@2.1.13: @@ -2910,8 +2910,8 @@ packages: resolution: {integrity: sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==} dev: false - /electron-to-chromium@1.4.623: - resolution: {integrity: sha512-lKoz10iCYlP1WtRYdh5MvocQPWVRoI7ysp6qf18bmeBgR8abE6+I2CsfyNKztRDZvhdWc+krKT6wS7Neg8sw3A==} + /electron-to-chromium@1.4.626: + resolution: {integrity: sha512-f7/be56VjRRQk+Ric6PmIrEtPcIqsn3tElyAu9Sh6egha2VLJ82qwkcOdcnT06W+Pb6RUulV1ckzrGbKzVcTHg==} dev: true /emittery@0.10.2: @@ -3555,7 +3555,7 @@ packages: '@jest/expect': 28.1.3 '@jest/test-result': 28.1.3 '@jest/types': 28.1.3 - '@types/node': 20.10.6 + '@types/node': 20.10.8 chalk: 4.1.2 co: 4.6.0 dedent: 0.7.0 @@ -3591,7 +3591,7 @@ packages: exit: 0.1.2 graceful-fs: 4.2.11 import-local: 3.1.0 - jest-config: 28.1.3(@types/node@20.10.6) + jest-config: 28.1.3(@types/node@20.10.8) jest-util: 28.1.3 jest-validate: 28.1.3 prompts: 2.4.2 @@ -3602,7 +3602,7 @@ packages: - ts-node dev: true - /jest-config@28.1.3(@types/node@20.10.6): + /jest-config@28.1.3(@types/node@20.10.8): resolution: {integrity: sha512-MG3INjByJ0J4AsNBm7T3hsuxKQqFIiRo/AUqb1q9LRKI5UU6Aar9JHbr9Ivn1TVwfUD9KirRoM/T6u8XlcQPHQ==} engines: {node: ^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0} peerDependencies: @@ -3617,7 +3617,7 @@ packages: '@babel/core': 7.23.7 '@jest/test-sequencer': 28.1.3 '@jest/types': 28.1.3 - '@types/node': 20.10.6 + '@types/node': 20.10.8 babel-jest: 28.1.3(@babel/core@7.23.7) chalk: 4.1.2 ci-info: 3.9.0 @@ -3686,7 +3686,7 @@ packages: '@jest/environment': 28.1.3 '@jest/fake-timers': 28.1.3 '@jest/types': 28.1.3 - '@types/node': 20.10.6 + '@types/node': 20.10.8 jest-mock: 28.1.3 jest-util: 28.1.3 dev: true @@ -3707,7 +3707,7 @@ packages: dependencies: '@jest/types': 28.1.3 '@types/graceful-fs': 4.1.9 - '@types/node': 20.10.6 + '@types/node': 20.10.8 anymatch: 3.1.3 fb-watchman: 2.0.2 graceful-fs: 4.2.11 @@ -3768,7 +3768,7 @@ packages: engines: {node: ^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0} dependencies: '@jest/types': 28.1.3 - '@types/node': 20.10.6 + '@types/node': 20.10.8 dev: true /jest-pnp-resolver@1.2.3(jest-resolve@28.1.3): @@ -3822,7 +3822,7 @@ packages: '@jest/test-result': 28.1.3 '@jest/transform': 28.1.3 '@jest/types': 28.1.3 - '@types/node': 20.10.6 + '@types/node': 20.10.8 chalk: 4.1.2 emittery: 0.10.2 graceful-fs: 4.2.11 @@ -3908,7 +3908,7 @@ packages: engines: {node: ^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0} dependencies: '@jest/types': 28.1.3 - '@types/node': 20.10.6 + '@types/node': 20.10.8 chalk: 4.1.2 ci-info: 3.9.0 graceful-fs: 4.2.11 @@ -3933,7 +3933,7 @@ packages: dependencies: '@jest/test-result': 28.1.3 '@jest/types': 28.1.3 - '@types/node': 20.10.6 + '@types/node': 20.10.8 ansi-escapes: 4.3.2 chalk: 4.1.2 emittery: 0.10.2 @@ -3945,7 +3945,7 @@ packages: resolution: {integrity: sha512-CqRA220YV/6jCo8VWvAt1KKx6eek1VIHMPeLEbpcfSfkEeWyBNppynM/o6q+Wmw+sOhos2ml34wZbSX3G13//g==} engines: {node: ^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0} dependencies: - '@types/node': 20.10.6 + '@types/node': 20.10.8 merge-stream: 2.0.0 supports-color: 8.1.1 dev: true @@ -4316,8 +4316,8 @@ packages: whatwg-url: 5.0.0 dev: false - /node-gyp-build@4.7.1: - resolution: {integrity: sha512-wTSrZ+8lsRRa3I3H8Xr65dLWSgCvY2l4AOnaeKdPA9TB/WYMPaTcrzf3rXvFoVvjKNVnu0CcWSx54qq9GKRUYg==} + /node-gyp-build@4.8.0: + resolution: {integrity: sha512-u6fs2AEUljNho3EYTJNBfImO5QTo/J/1Etd+NVdCj7qWKUSN/bSLkZwhDv7I+w/MSC6qJ4cknepkAYykDdK8og==} hasBin: true requiresBuild: true dev: false @@ -4504,7 +4504,7 @@ packages: pump: 3.0.0 readable-stream: 4.5.2 secure-json-parse: 2.7.0 - sonic-boom: 3.7.0 + sonic-boom: 3.8.0 strip-json-comments: 3.1.1 dev: true @@ -4525,7 +4525,7 @@ packages: quick-format-unescaped: 4.0.4 real-require: 0.2.0 safe-stable-stringify: 2.4.3 - sonic-boom: 3.7.0 + sonic-boom: 3.8.0 thread-stream: 2.4.1 dev: true @@ -4607,7 +4607,7 @@ packages: '@protobufjs/pool': 1.1.0 '@protobufjs/utf8': 1.1.0 '@types/long': 4.0.2 - '@types/node': 20.10.6 + '@types/node': 20.10.8 long: 4.0.0 dev: false @@ -4626,7 +4626,7 @@ packages: '@protobufjs/path': 1.1.2 '@protobufjs/pool': 1.1.0 '@protobufjs/utf8': 1.1.0 - '@types/node': 20.10.6 + '@types/node': 20.10.8 long: 5.2.3 dev: false @@ -4779,7 +4779,7 @@ packages: /rpc-websockets@7.9.0: resolution: {integrity: sha512-DwKewQz1IUA5wfLvgM8wDpPRcr+nWSxuFxx5CbrI2z/MyyZ4nXLM86TvIA+cI1ZAdqC8JIBR1mZR55dzaLU+Hw==} dependencies: - '@babel/runtime': 7.23.7 + '@babel/runtime': 7.23.8 eventemitter3: 4.0.7 uuid: 8.3.2 ws: 8.16.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) @@ -4872,8 +4872,8 @@ packages: tslib: 2.6.2 dev: false - /sonic-boom@3.7.0: - resolution: {integrity: sha512-IudtNvSqA/ObjN97tfgNmOKyDOs4dNcg4cUUsHDebqsgb8wGBBwb31LIgShNO8fye0dFI52X1+tFoKKI6Rq1Gg==} + /sonic-boom@3.8.0: + resolution: {integrity: sha512-ybz6OYOUjoQQCQ/i4LU8kaToD8ACtYP+Cj5qd2AO36bwbdewxWJ3ArmJ2cr6AvxlL2o0PqnCcPGUgkILbfkaCA==} dependencies: atomic-sleep: 1.0.0 dev: true @@ -5268,7 +5268,7 @@ packages: engines: {node: '>=6.14.2'} requiresBuild: true dependencies: - node-gyp-build: 4.7.1 + node-gyp-build: 4.8.0 dev: false /util@0.12.5: diff --git a/ts-client/src/amm/tests/pool.test.ts b/ts-client/src/amm/tests/pool.test.ts index 8c3a8e3e..ba082212 100644 --- a/ts-client/src/amm/tests/pool.test.ts +++ b/ts-client/src/amm/tests/pool.test.ts @@ -114,7 +114,11 @@ describe('Pool', () => { console.log(accountInfo); await pool.updateState(); - const { swapOutAmount, minSwapOutAmount } = pool.getSwapQuote(wsolTokenMint.publicKey, inAmountLamport, DEFAULT_SLIPPAGE); + const { swapOutAmount, minSwapOutAmount } = pool.getSwapQuote( + wsolTokenMint.publicKey, + inAmountLamport, + DEFAULT_SLIPPAGE, + ); console.log(`SwapOutAmount = `, swapOutAmount.toString()); }); @@ -123,23 +127,21 @@ describe('Pool', () => { console.log(accountInfo); await pool.updateState(); - const { swapOutAmount, minSwapOutAmount } = pool.getSwapQuote(wsolTokenMint.publicKey, inAmountLamport, DEFAULT_SLIPPAGE); + const { swapOutAmount, minSwapOutAmount } = pool.getSwapQuote( + wsolTokenMint.publicKey, + inAmountLamport, + DEFAULT_SLIPPAGE, + ); console.log(`SwapOutAmount = `, swapOutAmount.toString()); }); - const { swapOutAmount, minSwapOutAmount } = pool.getSwapQuote( wsolTokenMint.publicKey, inAmountLamport, DEFAULT_SLIPPAGE, ); - const swapTx = await pool.swap( - mockWallet.publicKey, - wsolTokenMint.publicKey, - inAmountLamport, - minSwapOutAmount, - ); + const swapTx = await pool.swap(mockWallet.publicKey, wsolTokenMint.publicKey, inAmountLamport, minSwapOutAmount); try { const swapResult = await sendAndConfirmTransaction(provider.connection, swapTx, [mockWallet.payer]); diff --git a/ts-client/src/amm/tests/utils/pool.ts b/ts-client/src/amm/tests/utils/pool.ts index fb15b134..eb2ebea7 100644 --- a/ts-client/src/amm/tests/utils/pool.ts +++ b/ts-client/src/amm/tests/utils/pool.ts @@ -6,7 +6,7 @@ import { SystemProgram, SYSVAR_RENT_PUBKEY, } from '@solana/web3.js'; -import { AmmProgram, CurveType, VaultProgram } from '../../types'; +import { AmmProgram, CurveType, PoolCreatedSimulation, VaultProgram } from '../../types'; import { BN, Program } from '@coral-xyz/anchor'; import { encodeCurveType, getFirstKey, getSecondKey, getTradeFeeBpsBuffer } from '../../utils'; import { ASSOCIATED_TOKEN_PROGRAM_ID, Token, TOKEN_PROGRAM_ID } from '@solana/spl-token'; @@ -40,7 +40,7 @@ export const simulateInitializePermissionlessPoolWithFeeTier = async ( bDepositAmount, tradeFeeBps, ); - let simulation = await instruction.simulate(); + let simulation: PoolCreatedSimulation = await instruction.simulate(); let event = simulation.events[0].data; expect(event.pool.toBase58()).to.equal(pool.toBase58()); diff --git a/ts-client/src/amm/types/PoolCreatedSimulation.ts b/ts-client/src/amm/types/PoolCreatedSimulation.ts new file mode 100644 index 00000000..e693ede9 --- /dev/null +++ b/ts-client/src/amm/types/PoolCreatedSimulation.ts @@ -0,0 +1,4 @@ +import { Amm } from '../idl'; +import { SimulateResponse } from '@coral-xyz/anchor/dist/cjs/program/namespace/simulate'; + +export type PoolCreatedSimulation = Omit, ''>; diff --git a/ts-client/src/amm/types/index.ts b/ts-client/src/amm/types/index.ts index 882212fe..2fa18f5e 100644 --- a/ts-client/src/amm/types/index.ts +++ b/ts-client/src/amm/types/index.ts @@ -22,6 +22,7 @@ export * from './Depeg'; export * from './TokenMultiplier'; export * from './PoolFees'; export * from './PoolType'; +export * from './PoolCreatedSimulation'; /** Programs */ export type AmmProgram = Program;