@whetstone-research/doppler-sdk 0.0.24 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -0
- package/dist/chunk-3LTCKCJC.js +319 -0
- package/dist/chunk-3LTCKCJC.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +9 -0
- package/dist/{chunk-4XN6DQBW.js.map → chunk-PZ5AY32C.js.map} +1 -1
- package/dist/chunk-RO6R66OM.js +974 -0
- package/dist/chunk-RO6R66OM.js.map +1 -0
- package/dist/evm/index.d.ts +8533 -0
- package/dist/evm/index.js +15055 -0
- package/dist/evm/index.js.map +1 -0
- package/dist/oracle-BSvZ6pxp.d.ts +820 -0
- package/dist/pda-RVIHNLRP.js +4 -0
- package/dist/pda-RVIHNLRP.js.map +1 -0
- package/dist/solana/index.d.ts +2495 -0
- package/dist/solana/index.js +2209 -0
- package/dist/solana/index.js.map +1 -0
- package/dist/solana/react/index.d.ts +1046 -0
- package/dist/solana/react/index.js +1436 -0
- package/dist/solana/react/index.js.map +1 -0
- package/package.json +36 -20
- package/dist/DopplerSDK.d.mts +0 -106
- package/dist/DopplerSDK.d.ts +0 -106
- package/dist/DopplerSDK.js +0 -53
- package/dist/DopplerSDK.js.map +0 -1
- package/dist/DopplerSDK.mjs +0 -44
- package/dist/DopplerSDK.mjs.map +0 -1
- package/dist/abis/bytecodes/derc20.d.mts +0 -3
- package/dist/abis/bytecodes/derc20.d.ts +0 -3
- package/dist/abis/bytecodes/derc20.js +0 -9
- package/dist/abis/bytecodes/derc20.js.map +0 -1
- package/dist/abis/bytecodes/derc20.mjs +0 -3
- package/dist/abis/bytecodes/derc20.mjs.map +0 -1
- package/dist/abis/bytecodes/derc2080.d.mts +0 -3
- package/dist/abis/bytecodes/derc2080.d.ts +0 -3
- package/dist/abis/bytecodes/derc2080.js +0 -9
- package/dist/abis/bytecodes/derc2080.js.map +0 -1
- package/dist/abis/bytecodes/derc2080.mjs +0 -3
- package/dist/abis/bytecodes/derc2080.mjs.map +0 -1
- package/dist/abis/bytecodes/doppler.d.mts +0 -3
- package/dist/abis/bytecodes/doppler.d.ts +0 -3
- package/dist/abis/bytecodes/doppler.js +0 -9
- package/dist/abis/bytecodes/doppler.js.map +0 -1
- package/dist/abis/bytecodes/doppler.mjs +0 -3
- package/dist/abis/bytecodes/doppler.mjs.map +0 -1
- package/dist/abis/bytecodes/dopplerDN404.d.mts +0 -3
- package/dist/abis/bytecodes/dopplerDN404.d.ts +0 -3
- package/dist/abis/bytecodes/dopplerDN404.js +0 -9
- package/dist/abis/bytecodes/dopplerDN404.js.map +0 -1
- package/dist/abis/bytecodes/dopplerDN404.mjs +0 -3
- package/dist/abis/bytecodes/dopplerDN404.mjs.map +0 -1
- package/dist/abis/bytecodes/stateView.d.mts +0 -3
- package/dist/abis/bytecodes/stateView.d.ts +0 -3
- package/dist/abis/bytecodes/stateView.js +0 -9
- package/dist/abis/bytecodes/stateView.js.map +0 -1
- package/dist/abis/bytecodes/stateView.mjs +0 -3
- package/dist/abis/bytecodes/stateView.mjs.map +0 -1
- package/dist/abis/bytecodes.d.mts +0 -5
- package/dist/abis/bytecodes.d.ts +0 -5
- package/dist/abis/bytecodes.js +0 -33
- package/dist/abis/bytecodes.js.map +0 -1
- package/dist/abis/bytecodes.mjs +0 -8
- package/dist/abis/bytecodes.mjs.map +0 -1
- package/dist/abis/index.d.mts +0 -3871
- package/dist/abis/index.d.ts +0 -3871
- package/dist/abis/index.js +0 -130
- package/dist/abis/index.js.map +0 -1
- package/dist/abis/index.mjs +0 -9
- package/dist/abis/index.mjs.map +0 -1
- package/dist/addresses.d.mts +0 -69
- package/dist/addresses.d.ts +0 -69
- package/dist/addresses.js +0 -29
- package/dist/addresses.js.map +0 -1
- package/dist/addresses.mjs +0 -4
- package/dist/addresses.mjs.map +0 -1
- package/dist/builders/DynamicAuctionBuilder.d.mts +0 -138
- package/dist/builders/DynamicAuctionBuilder.d.ts +0 -138
- package/dist/builders/DynamicAuctionBuilder.js +0 -35
- package/dist/builders/DynamicAuctionBuilder.js.map +0 -1
- package/dist/builders/DynamicAuctionBuilder.mjs +0 -26
- package/dist/builders/DynamicAuctionBuilder.mjs.map +0 -1
- package/dist/builders/MulticurveBuilder.d.mts +0 -196
- package/dist/builders/MulticurveBuilder.d.ts +0 -196
- package/dist/builders/MulticurveBuilder.js +0 -35
- package/dist/builders/MulticurveBuilder.js.map +0 -1
- package/dist/builders/MulticurveBuilder.mjs +0 -26
- package/dist/builders/MulticurveBuilder.mjs.map +0 -1
- package/dist/builders/StaticAuctionBuilder.d.mts +0 -131
- package/dist/builders/StaticAuctionBuilder.d.ts +0 -131
- package/dist/builders/StaticAuctionBuilder.js +0 -35
- package/dist/builders/StaticAuctionBuilder.js.map +0 -1
- package/dist/builders/StaticAuctionBuilder.mjs +0 -26
- package/dist/builders/StaticAuctionBuilder.mjs.map +0 -1
- package/dist/builders/index.d.mts +0 -8
- package/dist/builders/index.d.ts +0 -8
- package/dist/builders/index.js +0 -62
- package/dist/builders/index.js.map +0 -1
- package/dist/builders/index.mjs +0 -29
- package/dist/builders/index.mjs.map +0 -1
- package/dist/builders/shared.d.mts +0 -115
- package/dist/builders/shared.d.ts +0 -115
- package/dist/builders/shared.js +0 -46
- package/dist/builders/shared.js.map +0 -1
- package/dist/builders/shared.mjs +0 -25
- package/dist/builders/shared.mjs.map +0 -1
- package/dist/chunk-25GEBO3B.mjs +0 -219
- package/dist/chunk-25GEBO3B.mjs.map +0 -1
- package/dist/chunk-2A3B3NVB.js +0 -737
- package/dist/chunk-2A3B3NVB.js.map +0 -1
- package/dist/chunk-3NMGCQJ4.mjs +0 -6
- package/dist/chunk-3NMGCQJ4.mjs.map +0 -1
- package/dist/chunk-44CYUEPG.js +0 -377
- package/dist/chunk-44CYUEPG.js.map +0 -1
- package/dist/chunk-4VWQNNNW.js +0 -233
- package/dist/chunk-4VWQNNNW.js.map +0 -1
- package/dist/chunk-4XN6DQBW.js +0 -4
- package/dist/chunk-5GQJRNFL.mjs +0 -40
- package/dist/chunk-5GQJRNFL.mjs.map +0 -1
- package/dist/chunk-5JHXBDZD.js +0 -265
- package/dist/chunk-5JHXBDZD.js.map +0 -1
- package/dist/chunk-5TQOT6CW.js +0 -8
- package/dist/chunk-5TQOT6CW.js.map +0 -1
- package/dist/chunk-65CESA3J.js +0 -46
- package/dist/chunk-65CESA3J.js.map +0 -1
- package/dist/chunk-6BQY5EPB.js +0 -144
- package/dist/chunk-6BQY5EPB.js.map +0 -1
- package/dist/chunk-6H6X3VTZ.js +0 -18
- package/dist/chunk-6H6X3VTZ.js.map +0 -1
- package/dist/chunk-7A4DBBXA.js +0 -311
- package/dist/chunk-7A4DBBXA.js.map +0 -1
- package/dist/chunk-7M57PU6V.js +0 -28
- package/dist/chunk-7M57PU6V.js.map +0 -1
- package/dist/chunk-7ZUV6WPX.mjs +0 -3
- package/dist/chunk-7ZUV6WPX.mjs.map +0 -1
- package/dist/chunk-A2CJYRRQ.js +0 -330
- package/dist/chunk-A2CJYRRQ.js.map +0 -1
- package/dist/chunk-ABT6AT7C.mjs +0 -16
- package/dist/chunk-ABT6AT7C.mjs.map +0 -1
- package/dist/chunk-BK3S6SVR.js +0 -2707
- package/dist/chunk-BK3S6SVR.js.map +0 -1
- package/dist/chunk-BQZTELUX.js +0 -45
- package/dist/chunk-BQZTELUX.js.map +0 -1
- package/dist/chunk-CFAAYL5M.mjs +0 -26
- package/dist/chunk-CFAAYL5M.mjs.map +0 -1
- package/dist/chunk-CFXXUZJY.js +0 -275
- package/dist/chunk-CFXXUZJY.js.map +0 -1
- package/dist/chunk-CWTGQAOG.mjs +0 -72
- package/dist/chunk-CWTGQAOG.mjs.map +0 -1
- package/dist/chunk-DCWF3EMP.js +0 -171
- package/dist/chunk-DCWF3EMP.js.map +0 -1
- package/dist/chunk-DOUF6NON.mjs +0 -3
- package/dist/chunk-DOUF6NON.mjs.map +0 -1
- package/dist/chunk-DQJXCZU2.mjs +0 -318
- package/dist/chunk-DQJXCZU2.mjs.map +0 -1
- package/dist/chunk-DSYPZETD.js +0 -4
- package/dist/chunk-DSYPZETD.js.map +0 -1
- package/dist/chunk-F2BYG63D.mjs +0 -145
- package/dist/chunk-F2BYG63D.mjs.map +0 -1
- package/dist/chunk-FNUBKONK.js +0 -291
- package/dist/chunk-FNUBKONK.js.map +0 -1
- package/dist/chunk-FOESYJP3.mjs +0 -3
- package/dist/chunk-FOESYJP3.mjs.map +0 -1
- package/dist/chunk-FXTGIKQG.mjs +0 -3
- package/dist/chunk-FXTGIKQG.mjs.map +0 -1
- package/dist/chunk-GSBQIVME.mjs +0 -278
- package/dist/chunk-GSBQIVME.mjs.map +0 -1
- package/dist/chunk-H3B54PFV.mjs +0 -17
- package/dist/chunk-H3B54PFV.mjs.map +0 -1
- package/dist/chunk-HJFVRV47.js +0 -120
- package/dist/chunk-HJFVRV47.js.map +0 -1
- package/dist/chunk-IIM2CSDQ.js +0 -147
- package/dist/chunk-IIM2CSDQ.js.map +0 -1
- package/dist/chunk-IUTIHSLH.mjs +0 -295
- package/dist/chunk-IUTIHSLH.mjs.map +0 -1
- package/dist/chunk-IUZ3BBQP.mjs +0 -117
- package/dist/chunk-IUZ3BBQP.mjs.map +0 -1
- package/dist/chunk-IWJOPXYN.mjs +0 -96
- package/dist/chunk-IWJOPXYN.mjs.map +0 -1
- package/dist/chunk-IX4V4UGW.mjs +0 -141
- package/dist/chunk-IX4V4UGW.mjs.map +0 -1
- package/dist/chunk-J62YDWIK.js +0 -8
- package/dist/chunk-J62YDWIK.js.map +0 -1
- package/dist/chunk-JIKAD4YL.js +0 -4
- package/dist/chunk-JIKAD4YL.js.map +0 -1
- package/dist/chunk-JLUOFAE4.mjs +0 -2531
- package/dist/chunk-JLUOFAE4.mjs.map +0 -1
- package/dist/chunk-KAZQJ24E.mjs +0 -59
- package/dist/chunk-KAZQJ24E.mjs.map +0 -1
- package/dist/chunk-KHUE77HC.js +0 -81
- package/dist/chunk-KHUE77HC.js.map +0 -1
- package/dist/chunk-KOAC3BBP.mjs +0 -11
- package/dist/chunk-KOAC3BBP.mjs.map +0 -1
- package/dist/chunk-LW3CYA27.mjs +0 -2705
- package/dist/chunk-LW3CYA27.mjs.map +0 -1
- package/dist/chunk-MEA2C5YX.js +0 -143
- package/dist/chunk-MEA2C5YX.js.map +0 -1
- package/dist/chunk-MU56HCUI.js +0 -2556
- package/dist/chunk-MU56HCUI.js.map +0 -1
- package/dist/chunk-OCIY7QEJ.mjs +0 -169
- package/dist/chunk-OCIY7QEJ.mjs.map +0 -1
- package/dist/chunk-OHA5KJ2M.mjs +0 -6
- package/dist/chunk-OHA5KJ2M.mjs.map +0 -1
- package/dist/chunk-P25HBGP5.mjs +0 -3
- package/dist/chunk-P25HBGP5.mjs.map +0 -1
- package/dist/chunk-P563HTVU.js +0 -164
- package/dist/chunk-P563HTVU.js.map +0 -1
- package/dist/chunk-P7CHGWY7.js +0 -4
- package/dist/chunk-P7CHGWY7.js.map +0 -1
- package/dist/chunk-PGYTMRP3.js +0 -277
- package/dist/chunk-PGYTMRP3.js.map +0 -1
- package/dist/chunk-QAPQGDWK.js +0 -8
- package/dist/chunk-QAPQGDWK.js.map +0 -1
- package/dist/chunk-QHBKRUBY.mjs +0 -328
- package/dist/chunk-QHBKRUBY.mjs.map +0 -1
- package/dist/chunk-QOYI7WCH.js +0 -120
- package/dist/chunk-QOYI7WCH.js.map +0 -1
- package/dist/chunk-QRTABC4Z.js +0 -8
- package/dist/chunk-QRTABC4Z.js.map +0 -1
- package/dist/chunk-QSQGLWNY.mjs +0 -3
- package/dist/chunk-QSQGLWNY.mjs.map +0 -1
- package/dist/chunk-QUBD6HUZ.mjs +0 -735
- package/dist/chunk-QUBD6HUZ.mjs.map +0 -1
- package/dist/chunk-RDTIXP6S.mjs +0 -263
- package/dist/chunk-RDTIXP6S.mjs.map +0 -1
- package/dist/chunk-RLOZWHRR.js +0 -320
- package/dist/chunk-RLOZWHRR.js.map +0 -1
- package/dist/chunk-RV64M4Q6.mjs +0 -3
- package/dist/chunk-RV64M4Q6.mjs.map +0 -1
- package/dist/chunk-SWWLOD7Q.mjs +0 -6
- package/dist/chunk-SWWLOD7Q.mjs.map +0 -1
- package/dist/chunk-T3UA4MJL.js +0 -4
- package/dist/chunk-T3UA4MJL.js.map +0 -1
- package/dist/chunk-TEWAXP5C.mjs +0 -162
- package/dist/chunk-TEWAXP5C.mjs.map +0 -1
- package/dist/chunk-THEIRDGE.mjs +0 -273
- package/dist/chunk-THEIRDGE.mjs.map +0 -1
- package/dist/chunk-U3GOWK6J.mjs +0 -6
- package/dist/chunk-U3GOWK6J.mjs.map +0 -1
- package/dist/chunk-UPVKABAV.js +0 -19
- package/dist/chunk-UPVKABAV.js.map +0 -1
- package/dist/chunk-VEIVYUYF.js +0 -4
- package/dist/chunk-VEIVYUYF.js.map +0 -1
- package/dist/chunk-VKSD3KXF.mjs +0 -275
- package/dist/chunk-VKSD3KXF.mjs.map +0 -1
- package/dist/chunk-VYSOAGRU.mjs +0 -6
- package/dist/chunk-VYSOAGRU.mjs.map +0 -1
- package/dist/chunk-WDC53TM7.mjs +0 -305
- package/dist/chunk-WDC53TM7.mjs.map +0 -1
- package/dist/chunk-WKWP42TD.mjs +0 -39
- package/dist/chunk-WKWP42TD.mjs.map +0 -1
- package/dist/chunk-WNUB3UTT.js +0 -241
- package/dist/chunk-WNUB3UTT.js.map +0 -1
- package/dist/chunk-WNWK2QMU.mjs +0 -375
- package/dist/chunk-WNWK2QMU.mjs.map +0 -1
- package/dist/chunk-WQHTNL5L.js +0 -4
- package/dist/chunk-WQHTNL5L.js.map +0 -1
- package/dist/chunk-WZF5XNBC.js +0 -297
- package/dist/chunk-WZF5XNBC.js.map +0 -1
- package/dist/chunk-X3UMAHOJ.js +0 -4
- package/dist/chunk-X3UMAHOJ.js.map +0 -1
- package/dist/chunk-XMFOZYNI.js +0 -8
- package/dist/chunk-XMFOZYNI.js.map +0 -1
- package/dist/chunk-XNMXN5SZ.mjs +0 -3
- package/dist/chunk-XNMXN5SZ.mjs.map +0 -1
- package/dist/chunk-XSJTASPK.js +0 -13
- package/dist/chunk-XSJTASPK.js.map +0 -1
- package/dist/chunk-YBK6EBA5.mjs +0 -239
- package/dist/chunk-YBK6EBA5.mjs.map +0 -1
- package/dist/chunk-YYLD3AJ7.js +0 -61
- package/dist/chunk-YYLD3AJ7.js.map +0 -1
- package/dist/chunk-ZEDJUNC6.mjs +0 -115
- package/dist/chunk-ZEDJUNC6.mjs.map +0 -1
- package/dist/constants.d.mts +0 -91
- package/dist/constants.d.ts +0 -91
- package/dist/constants.js +0 -196
- package/dist/constants.js.map +0 -1
- package/dist/constants.mjs +0 -3
- package/dist/constants.mjs.map +0 -1
- package/dist/deployments.generated.d.mts +0 -275
- package/dist/deployments.generated.d.ts +0 -275
- package/dist/deployments.generated.js +0 -12
- package/dist/deployments.generated.js.map +0 -1
- package/dist/deployments.generated.mjs +0 -3
- package/dist/deployments.generated.mjs.map +0 -1
- package/dist/entities/DopplerFactory.d.mts +0 -272
- package/dist/entities/DopplerFactory.d.ts +0 -272
- package/dist/entities/DopplerFactory.js +0 -34
- package/dist/entities/DopplerFactory.js.map +0 -1
- package/dist/entities/DopplerFactory.mjs +0 -25
- package/dist/entities/DopplerFactory.mjs.map +0 -1
- package/dist/entities/auction/DynamicAuction.d.mts +0 -72
- package/dist/entities/auction/DynamicAuction.d.ts +0 -72
- package/dist/entities/auction/DynamicAuction.js +0 -21
- package/dist/entities/auction/DynamicAuction.js.map +0 -1
- package/dist/entities/auction/DynamicAuction.mjs +0 -12
- package/dist/entities/auction/DynamicAuction.mjs.map +0 -1
- package/dist/entities/auction/MulticurvePool.d.mts +0 -78
- package/dist/entities/auction/MulticurvePool.d.ts +0 -78
- package/dist/entities/auction/MulticurvePool.js +0 -24
- package/dist/entities/auction/MulticurvePool.js.map +0 -1
- package/dist/entities/auction/MulticurvePool.mjs +0 -15
- package/dist/entities/auction/MulticurvePool.mjs.map +0 -1
- package/dist/entities/auction/RehypeDopplerHook.d.mts +0 -57
- package/dist/entities/auction/RehypeDopplerHook.d.ts +0 -57
- package/dist/entities/auction/RehypeDopplerHook.js +0 -34
- package/dist/entities/auction/RehypeDopplerHook.js.map +0 -1
- package/dist/entities/auction/RehypeDopplerHook.mjs +0 -25
- package/dist/entities/auction/RehypeDopplerHook.mjs.map +0 -1
- package/dist/entities/auction/RehypeDopplerHookMigrator.d.mts +0 -48
- package/dist/entities/auction/RehypeDopplerHookMigrator.d.ts +0 -48
- package/dist/entities/auction/RehypeDopplerHookMigrator.js +0 -34
- package/dist/entities/auction/RehypeDopplerHookMigrator.js.map +0 -1
- package/dist/entities/auction/RehypeDopplerHookMigrator.mjs +0 -25
- package/dist/entities/auction/RehypeDopplerHookMigrator.mjs.map +0 -1
- package/dist/entities/auction/StaticAuction.d.mts +0 -44
- package/dist/entities/auction/StaticAuction.d.ts +0 -44
- package/dist/entities/auction/StaticAuction.js +0 -21
- package/dist/entities/auction/StaticAuction.js.map +0 -1
- package/dist/entities/auction/StaticAuction.mjs +0 -12
- package/dist/entities/auction/StaticAuction.mjs.map +0 -1
- package/dist/entities/auction/index.d.mts +0 -9
- package/dist/entities/auction/index.d.ts +0 -9
- package/dist/entities/auction/index.js +0 -55
- package/dist/entities/auction/index.js.map +0 -1
- package/dist/entities/auction/index.mjs +0 -30
- package/dist/entities/auction/index.mjs.map +0 -1
- package/dist/entities/quoter/Quoter.d.mts +0 -150
- package/dist/entities/quoter/Quoter.d.ts +0 -150
- package/dist/entities/quoter/Quoter.js +0 -21
- package/dist/entities/quoter/Quoter.js.map +0 -1
- package/dist/entities/quoter/Quoter.mjs +0 -12
- package/dist/entities/quoter/Quoter.mjs.map +0 -1
- package/dist/entities/quoter/index.d.mts +0 -5
- package/dist/entities/quoter/index.d.ts +0 -5
- package/dist/entities/quoter/index.js +0 -22
- package/dist/entities/quoter/index.js.map +0 -1
- package/dist/entities/quoter/index.mjs +0 -13
- package/dist/entities/quoter/index.mjs.map +0 -1
- package/dist/entities/token/derc20/Derc20.d.mts +0 -102
- package/dist/entities/token/derc20/Derc20.d.ts +0 -102
- package/dist/entities/token/derc20/Derc20.js +0 -19
- package/dist/entities/token/derc20/Derc20.js.map +0 -1
- package/dist/entities/token/derc20/Derc20.mjs +0 -10
- package/dist/entities/token/derc20/Derc20.mjs.map +0 -1
- package/dist/entities/token/derc20/index.d.mts +0 -5
- package/dist/entities/token/derc20/index.d.ts +0 -5
- package/dist/entities/token/derc20/index.js +0 -20
- package/dist/entities/token/derc20/index.js.map +0 -1
- package/dist/entities/token/derc20/index.mjs +0 -11
- package/dist/entities/token/derc20/index.mjs.map +0 -1
- package/dist/entities/token/eth/Eth.d.mts +0 -54
- package/dist/entities/token/eth/Eth.d.ts +0 -54
- package/dist/entities/token/eth/Eth.js +0 -12
- package/dist/entities/token/eth/Eth.js.map +0 -1
- package/dist/entities/token/eth/Eth.mjs +0 -3
- package/dist/entities/token/eth/Eth.mjs.map +0 -1
- package/dist/entities/token/eth/index.d.mts +0 -5
- package/dist/entities/token/eth/index.d.ts +0 -5
- package/dist/entities/token/eth/index.js +0 -13
- package/dist/entities/token/eth/index.js.map +0 -1
- package/dist/entities/token/eth/index.mjs +0 -4
- package/dist/entities/token/eth/index.mjs.map +0 -1
- package/dist/entities/token/index.d.mts +0 -6
- package/dist/entities/token/index.d.ts +0 -6
- package/dist/entities/token/index.js +0 -27
- package/dist/entities/token/index.js.map +0 -1
- package/dist/entities/token/index.mjs +0 -14
- package/dist/entities/token/index.mjs.map +0 -1
- package/dist/index.d.mts +0 -39
- package/dist/index.d.ts +0 -39
- package/dist/index.js +0 -587
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -49
- package/dist/index.mjs.map +0 -1
- package/dist/types.d.mts +0 -662
- package/dist/types.d.ts +0 -662
- package/dist/types.js +0 -34
- package/dist/types.js.map +0 -1
- package/dist/types.mjs +0 -5
- package/dist/types.mjs.map +0 -1
- package/dist/utils/airlock.d.mts +0 -11
- package/dist/utils/airlock.d.ts +0 -11
- package/dist/utils/airlock.js +0 -26
- package/dist/utils/airlock.js.map +0 -1
- package/dist/utils/airlock.mjs +0 -5
- package/dist/utils/airlock.mjs.map +0 -1
- package/dist/utils/balanceDelta.d.mts +0 -10
- package/dist/utils/balanceDelta.d.ts +0 -10
- package/dist/utils/balanceDelta.js +0 -12
- package/dist/utils/balanceDelta.js.map +0 -1
- package/dist/utils/balanceDelta.mjs +0 -3
- package/dist/utils/balanceDelta.mjs.map +0 -1
- package/dist/utils/computeOptimalGamma.d.mts +0 -7
- package/dist/utils/computeOptimalGamma.d.ts +0 -7
- package/dist/utils/computeOptimalGamma.js +0 -12
- package/dist/utils/computeOptimalGamma.js.map +0 -1
- package/dist/utils/computeOptimalGamma.mjs +0 -3
- package/dist/utils/computeOptimalGamma.mjs.map +0 -1
- package/dist/utils/dopplerHookMigrator.d.mts +0 -18
- package/dist/utils/dopplerHookMigrator.d.ts +0 -18
- package/dist/utils/dopplerHookMigrator.js +0 -20
- package/dist/utils/dopplerHookMigrator.js.map +0 -1
- package/dist/utils/dopplerHookMigrator.mjs +0 -7
- package/dist/utils/dopplerHookMigrator.mjs.map +0 -1
- package/dist/utils/index.d.mts +0 -14
- package/dist/utils/index.d.ts +0 -14
- package/dist/utils/index.js +0 -197
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/index.mjs +0 -24
- package/dist/utils/index.mjs.map +0 -1
- package/dist/utils/isToken0Expected.d.mts +0 -13
- package/dist/utils/isToken0Expected.d.ts +0 -13
- package/dist/utils/isToken0Expected.js +0 -12
- package/dist/utils/isToken0Expected.js.map +0 -1
- package/dist/utils/isToken0Expected.mjs +0 -3
- package/dist/utils/isToken0Expected.mjs.map +0 -1
- package/dist/utils/marketCapHelpers.d.mts +0 -259
- package/dist/utils/marketCapHelpers.d.ts +0 -259
- package/dist/utils/marketCapHelpers.js +0 -58
- package/dist/utils/marketCapHelpers.js.map +0 -1
- package/dist/utils/marketCapHelpers.mjs +0 -5
- package/dist/utils/marketCapHelpers.mjs.map +0 -1
- package/dist/utils/poolKey.d.mts +0 -17
- package/dist/utils/poolKey.d.ts +0 -17
- package/dist/utils/poolKey.js +0 -12
- package/dist/utils/poolKey.js.map +0 -1
- package/dist/utils/poolKey.mjs +0 -3
- package/dist/utils/poolKey.mjs.map +0 -1
- package/dist/utils/priceHelpers.d.mts +0 -86
- package/dist/utils/priceHelpers.d.ts +0 -86
- package/dist/utils/priceHelpers.js +0 -41
- package/dist/utils/priceHelpers.js.map +0 -1
- package/dist/utils/priceHelpers.mjs +0 -4
- package/dist/utils/priceHelpers.mjs.map +0 -1
- package/dist/utils/tickMath.d.mts +0 -72
- package/dist/utils/tickMath.d.ts +0 -72
- package/dist/utils/tickMath.js +0 -60
- package/dist/utils/tickMath.js.map +0 -1
- package/dist/utils/tickMath.mjs +0 -3
- package/dist/utils/tickMath.mjs.map +0 -1
- package/dist/utils/tokenAddressMiner.d.mts +0 -37
- package/dist/utils/tokenAddressMiner.d.ts +0 -37
- package/dist/utils/tokenAddressMiner.js +0 -19
- package/dist/utils/tokenAddressMiner.js.map +0 -1
- package/dist/utils/tokenAddressMiner.mjs +0 -10
- package/dist/utils/tokenAddressMiner.mjs.map +0 -1
|
@@ -0,0 +1,2209 @@
|
|
|
1
|
+
import { encodeInstructionData, initializeConfigArgsCodec, initializePoolArgsCodec, initializeOracleArgsCodec, setFeesArgsCodec, setSentinelArgsCodec, setRouteArgsCodec, transferAdminArgsCodec, swapExactInArgsCodec, createPositionArgsCodec, removeLiquidityArgsCodec, collectProtocolFeesArgsCodec, oracleConsultArgsCodec, quoteToNumeraireArgsCodec, decodeAmmConfig } from '../chunk-RO6R66OM.js';
|
|
2
|
+
export { MAX_FEE_AMOUNT, calculateAccruedFees, calculateTwap, calculateTwapNumber, ceilDiv, comparePoolAndOraclePrices, computePrice0Q64, computePrice1Q64, consultTwap, createCollectFeesInstruction, decodeAmmConfig, decodeOracleState, decodePool, decodePosition, fetchAllPools, fetchOracle, fetchOraclesBatch, fetchPool, fetchPoolPositions, fetchPoolsBatch, fetchPosition, fetchPositionByParams, fetchPositionsBatch, fetchUserPositions, filterActivePositions, filterPoolsByMint, getAddLiquidityQuote, getK, getOracleAddressFromPool, getOracleAge, getOracleBufferStats, getOracleDeviation, getOracleForPool, getOracleSpotPrices, getPendingFees, getPoolAddressFromMints, getPoolByMints, getPositionAddressFromParams, getPositionValue, getRemoveLiquidityQuote, getSpotPrice0, getSpotPrice1, getSwapQuote, getSwapQuoteExactOut, getTvl, isOracleStale, isqrt, maxBigInt, minBigInt, numberToQ64, poolExists, q64Div, q64Mul, q64ToNumber, ratioToNumber, sortPoolsByReserves, sortPositionsByShares } from '../chunk-RO6R66OM.js';
|
|
3
|
+
import { SYSTEM_PROGRAM_ID, ACCOUNT_ROLE_WRITABLE, ACCOUNT_ROLE_READONLY, TOKEN_PROGRAM_ID, ACCOUNT_ROLE_WRITABLE_SIGNER, ACCOUNT_ROLE_SIGNER, PROGRAM_ID, TOKEN_METADATA_PROGRAM_ID, INSTRUCTION_DISCRIMINATORS, getConfigAddress } from '../chunk-3LTCKCJC.js';
|
|
4
|
+
export { ACCOUNT_DISCRIMINATORS, ACCOUNT_ROLE_READONLY, ACCOUNT_ROLE_SIGNER, ACCOUNT_ROLE_WRITABLE, ACCOUNT_ROLE_WRITABLE_SIGNER, ACCOUNT_VERSION, BPS_DENOM, INSTRUCTION_DISCRIMINATORS, MAX_ORACLE_OBSERVATIONS, MAX_SENTINEL_ALLOWLIST, PROGRAM_ID, Q64_ONE, SEED_AUTHORITY, SEED_CONFIG, SEED_ORACLE, SEED_POOL, SEED_POSITION, SEED_PROTOCOL_POSITION, SENTINEL_NO_CHANGE, SENTINEL_PROGRAM_ID, SF_AFTER_ADD_LIQ, SF_AFTER_REMOVE_LIQ, SF_AFTER_SWAP, SF_BEFORE_ADD_LIQ, SF_BEFORE_REMOVE_LIQ, SF_BEFORE_SWAP, SYSTEM_PROGRAM_ID, TOKEN_METADATA_PROGRAM_ID, TOKEN_PROGRAM_ID, areMintsOrdered, getConfigAddress, getLiquidityAddresses, getOracleAddress, getPoolAddress, getPoolAuthorityAddress, getPoolInitAddresses, getPositionAddress, getProtocolPositionAddress, getSwapAddresses, sortMints } from '../chunk-3LTCKCJC.js';
|
|
5
|
+
import { __export } from '../chunk-PZ5AY32C.js';
|
|
6
|
+
import { getAddressCodec, getStructCodec, getU64Codec, getU128Codec, getBooleanCodec, getU8Codec, address, transformEncoder, getStructEncoder, fixEncoderSize, getAddressEncoder, getU8Encoder, getArrayEncoder, getBytesEncoder, getStructDecoder, fixDecoderSize, getAddressDecoder, getU8Decoder, getArrayDecoder, getBytesDecoder, combineCodec, getU64Encoder, getU16Encoder, addEncoderSizePrefix, getU32Encoder, getUtf8Encoder, getU64Decoder, getU16Decoder, addDecoderSizePrefix, getU32Decoder, getUtf8Decoder, getProgramDerivedAddress, getOptionEncoder, getU128Encoder, getOptionDecoder, getU128Decoder, getBooleanEncoder, getBooleanDecoder, mergeBytes } from '@solana/kit';
|
|
7
|
+
import '@solana/program-client-core';
|
|
8
|
+
|
|
9
|
+
var addressCodec = getAddressCodec();
|
|
10
|
+
var textEncoder = new TextEncoder();
|
|
11
|
+
async function getMetadataAddress(mint) {
|
|
12
|
+
return getProgramDerivedAddress({
|
|
13
|
+
programAddress: TOKEN_METADATA_PROGRAM_ID,
|
|
14
|
+
seeds: [
|
|
15
|
+
textEncoder.encode("metadata"),
|
|
16
|
+
addressCodec.encode(TOKEN_METADATA_PROGRAM_ID),
|
|
17
|
+
addressCodec.encode(mint)
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// src/solana/core/marketCapHelpers.ts
|
|
23
|
+
function marketCapToTokenPrice(marketCapUSD, baseTotalSupply, baseDecimals) {
|
|
24
|
+
if (marketCapUSD <= 0) {
|
|
25
|
+
throw new Error("Market cap must be positive");
|
|
26
|
+
}
|
|
27
|
+
if (baseTotalSupply <= 0n) {
|
|
28
|
+
throw new Error("Token supply must be positive");
|
|
29
|
+
}
|
|
30
|
+
const supplyNum = Number(baseTotalSupply) / 10 ** baseDecimals;
|
|
31
|
+
return marketCapUSD / supplyNum;
|
|
32
|
+
}
|
|
33
|
+
function validateMarketCapParameters(marketCapUSD, baseTotalSupply, baseDecimals) {
|
|
34
|
+
const warnings = [];
|
|
35
|
+
if (marketCapUSD < 1e3) {
|
|
36
|
+
warnings.push(
|
|
37
|
+
`Market cap $${marketCapUSD.toLocaleString()} is very small. Verify this is intentional.`
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
if (marketCapUSD > 1e12) {
|
|
41
|
+
warnings.push(
|
|
42
|
+
`Market cap $${marketCapUSD.toLocaleString()} exceeds $1T. Verify this is correct.`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
const tokenPriceUSD = marketCapToTokenPrice(
|
|
46
|
+
marketCapUSD,
|
|
47
|
+
baseTotalSupply,
|
|
48
|
+
baseDecimals
|
|
49
|
+
);
|
|
50
|
+
if (tokenPriceUSD < 1e-6) {
|
|
51
|
+
warnings.push(
|
|
52
|
+
`Implied token price $${tokenPriceUSD.toExponential(2)} is very small. This may cause precision issues.`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
if (tokenPriceUSD > 1e6) {
|
|
56
|
+
warnings.push(
|
|
57
|
+
`Implied token price $${tokenPriceUSD.toLocaleString()} is very large. Verify token supply and market cap.`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
return { valid: warnings.length === 0, warnings };
|
|
61
|
+
}
|
|
62
|
+
function marketCapToCurveParams(input) {
|
|
63
|
+
const {
|
|
64
|
+
startMarketCapUSD,
|
|
65
|
+
endMarketCapUSD,
|
|
66
|
+
baseTotalSupply,
|
|
67
|
+
baseForCurve,
|
|
68
|
+
baseDecimals,
|
|
69
|
+
quoteDecimals,
|
|
70
|
+
numerairePriceUSD,
|
|
71
|
+
virtualBase
|
|
72
|
+
} = input;
|
|
73
|
+
if (startMarketCapUSD <= 0)
|
|
74
|
+
throw new Error("startMarketCapUSD must be positive");
|
|
75
|
+
if (endMarketCapUSD <= 0) throw new Error("endMarketCapUSD must be positive");
|
|
76
|
+
if (startMarketCapUSD >= endMarketCapUSD) {
|
|
77
|
+
throw new Error("startMarketCapUSD must be less than endMarketCapUSD");
|
|
78
|
+
}
|
|
79
|
+
if (baseForCurve <= 0n) throw new Error("baseForCurve must be positive");
|
|
80
|
+
if (baseForCurve > baseTotalSupply)
|
|
81
|
+
throw new Error("baseForCurve cannot exceed baseTotalSupply");
|
|
82
|
+
if (numerairePriceUSD <= 0)
|
|
83
|
+
throw new Error("numerairePriceUSD must be positive");
|
|
84
|
+
const canonicalVirtualBase = virtualBase !== void 0 && virtualBase > 0n ? virtualBase : baseForCurve;
|
|
85
|
+
return {
|
|
86
|
+
start: _marketCapToCurveParams(
|
|
87
|
+
startMarketCapUSD,
|
|
88
|
+
baseTotalSupply,
|
|
89
|
+
baseForCurve,
|
|
90
|
+
baseDecimals,
|
|
91
|
+
quoteDecimals,
|
|
92
|
+
numerairePriceUSD,
|
|
93
|
+
canonicalVirtualBase
|
|
94
|
+
),
|
|
95
|
+
end: _marketCapToCurveParams(
|
|
96
|
+
endMarketCapUSD,
|
|
97
|
+
baseTotalSupply,
|
|
98
|
+
baseForCurve,
|
|
99
|
+
baseDecimals,
|
|
100
|
+
quoteDecimals,
|
|
101
|
+
numerairePriceUSD,
|
|
102
|
+
canonicalVirtualBase
|
|
103
|
+
)
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function marketCapToSingleCurveParams(marketCapUSD, baseTotalSupply, baseForCurve, baseDecimals, quoteDecimals, numerairePriceUSD, virtualBase) {
|
|
107
|
+
if (marketCapUSD <= 0) throw new Error("marketCapUSD must be positive");
|
|
108
|
+
if (baseForCurve <= 0n) throw new Error("baseForCurve must be positive");
|
|
109
|
+
if (baseForCurve > baseTotalSupply)
|
|
110
|
+
throw new Error("baseForCurve cannot exceed baseTotalSupply");
|
|
111
|
+
if (numerairePriceUSD <= 0)
|
|
112
|
+
throw new Error("numerairePriceUSD must be positive");
|
|
113
|
+
const canonicalVirtualBase = virtualBase !== void 0 && virtualBase > 0n ? virtualBase : baseForCurve;
|
|
114
|
+
return _marketCapToCurveParams(
|
|
115
|
+
marketCapUSD,
|
|
116
|
+
baseTotalSupply,
|
|
117
|
+
baseForCurve,
|
|
118
|
+
baseDecimals,
|
|
119
|
+
quoteDecimals,
|
|
120
|
+
numerairePriceUSD,
|
|
121
|
+
canonicalVirtualBase
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
function curveParamsToMarketCap(input) {
|
|
125
|
+
const {
|
|
126
|
+
curveVirtualBase,
|
|
127
|
+
curveVirtualQuote,
|
|
128
|
+
baseReserve,
|
|
129
|
+
quoteReserve,
|
|
130
|
+
baseTotalSupply,
|
|
131
|
+
baseDecimals,
|
|
132
|
+
quoteDecimals,
|
|
133
|
+
numerairePriceUSD
|
|
134
|
+
} = input;
|
|
135
|
+
if (curveVirtualBase <= 0n)
|
|
136
|
+
throw new Error("curveVirtualBase must be positive");
|
|
137
|
+
if (curveVirtualQuote <= 0n)
|
|
138
|
+
throw new Error("curveVirtualQuote must be positive");
|
|
139
|
+
if (baseReserve < 0n) throw new Error("baseReserve must be non-negative");
|
|
140
|
+
if (quoteReserve < 0n) throw new Error("quoteReserve must be non-negative");
|
|
141
|
+
const spotPriceUSD = _spotPriceUSD(
|
|
142
|
+
curveVirtualBase,
|
|
143
|
+
curveVirtualQuote,
|
|
144
|
+
baseReserve,
|
|
145
|
+
quoteReserve,
|
|
146
|
+
baseDecimals,
|
|
147
|
+
quoteDecimals,
|
|
148
|
+
numerairePriceUSD
|
|
149
|
+
);
|
|
150
|
+
const supplyHuman = Number(baseTotalSupply) / 10 ** baseDecimals;
|
|
151
|
+
return spotPriceUSD * supplyHuman;
|
|
152
|
+
}
|
|
153
|
+
function _marketCapToCurveParams(marketCapUSD, baseTotalSupply, baseForCurve, baseDecimals, quoteDecimals, numerairePriceUSD, curveVirtualBase) {
|
|
154
|
+
const tokenPriceUSD = marketCapToTokenPrice(
|
|
155
|
+
marketCapUSD,
|
|
156
|
+
baseTotalSupply,
|
|
157
|
+
baseDecimals
|
|
158
|
+
);
|
|
159
|
+
const priceInNumeraire = tokenPriceUSD / numerairePriceUSD;
|
|
160
|
+
const decimalScale = 10 ** (quoteDecimals - baseDecimals);
|
|
161
|
+
const rawPriceQuotePerBase = priceInNumeraire * decimalScale;
|
|
162
|
+
const effectiveDenominator = baseForCurve + curveVirtualBase;
|
|
163
|
+
const PRECISION = 1000000000n;
|
|
164
|
+
const rawPriceScaled = BigInt(
|
|
165
|
+
Math.round(rawPriceQuotePerBase * Number(PRECISION))
|
|
166
|
+
);
|
|
167
|
+
const curveVirtualQuote = effectiveDenominator * rawPriceScaled / PRECISION;
|
|
168
|
+
if (curveVirtualQuote <= 0n) {
|
|
169
|
+
throw new Error(
|
|
170
|
+
`Computed curveVirtualQuote is zero or negative for marketCap=$${marketCapUSD.toLocaleString()}. Try a higher market cap or larger virtualBase.`
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
return { curveVirtualBase, curveVirtualQuote };
|
|
174
|
+
}
|
|
175
|
+
function _spotPriceUSD(curveVirtualBase, curveVirtualQuote, baseReserve, quoteReserve, baseDecimals, quoteDecimals, numerairePriceUSD) {
|
|
176
|
+
const effBase = Number(baseReserve + curveVirtualBase);
|
|
177
|
+
const effQuote = Number(quoteReserve + curveVirtualQuote);
|
|
178
|
+
const rawRatio = effQuote / effBase;
|
|
179
|
+
const decimalScale = 10 ** (baseDecimals - quoteDecimals);
|
|
180
|
+
return rawRatio * decimalScale * numerairePriceUSD;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// src/solana/core/errors.ts
|
|
184
|
+
var CpmmErrorCode = /* @__PURE__ */ ((CpmmErrorCode2) => {
|
|
185
|
+
CpmmErrorCode2[CpmmErrorCode2["Unauthorized"] = 6e3] = "Unauthorized";
|
|
186
|
+
CpmmErrorCode2[CpmmErrorCode2["PoolLocked"] = 6001] = "PoolLocked";
|
|
187
|
+
CpmmErrorCode2[CpmmErrorCode2["InvalidFee"] = 6002] = "InvalidFee";
|
|
188
|
+
CpmmErrorCode2[CpmmErrorCode2["InvalidFeeSplit"] = 6003] = "InvalidFeeSplit";
|
|
189
|
+
CpmmErrorCode2[CpmmErrorCode2["InvalidDirection"] = 6004] = "InvalidDirection";
|
|
190
|
+
CpmmErrorCode2[CpmmErrorCode2["InsufficientLiquidity"] = 6005] = "InsufficientLiquidity";
|
|
191
|
+
CpmmErrorCode2[CpmmErrorCode2["SlippageExceeded"] = 6006] = "SlippageExceeded";
|
|
192
|
+
CpmmErrorCode2[CpmmErrorCode2["MathOverflow"] = 6007] = "MathOverflow";
|
|
193
|
+
CpmmErrorCode2[CpmmErrorCode2["InvalidMintOrder"] = 6008] = "InvalidMintOrder";
|
|
194
|
+
CpmmErrorCode2[CpmmErrorCode2["SameMintPair"] = 6009] = "SameMintPair";
|
|
195
|
+
CpmmErrorCode2[CpmmErrorCode2["InvalidVault"] = 6010] = "InvalidVault";
|
|
196
|
+
CpmmErrorCode2[CpmmErrorCode2["InvalidPosition"] = 6011] = "InvalidPosition";
|
|
197
|
+
CpmmErrorCode2[CpmmErrorCode2["PositionNotEmpty"] = 6012] = "PositionNotEmpty";
|
|
198
|
+
CpmmErrorCode2[CpmmErrorCode2["InvalidRoute"] = 6013] = "InvalidRoute";
|
|
199
|
+
CpmmErrorCode2[CpmmErrorCode2["NotSupportedInV0_1"] = 6014] = "NotSupportedInV0_1";
|
|
200
|
+
CpmmErrorCode2[CpmmErrorCode2["OracleNotInitialized"] = 6015] = "OracleNotInitialized";
|
|
201
|
+
CpmmErrorCode2[CpmmErrorCode2["ZeroSharesOut"] = 6016] = "ZeroSharesOut";
|
|
202
|
+
CpmmErrorCode2[CpmmErrorCode2["SentinelRejected"] = 6017] = "SentinelRejected";
|
|
203
|
+
CpmmErrorCode2[CpmmErrorCode2["SentinelCpiFailed"] = 6018] = "SentinelCpiFailed";
|
|
204
|
+
CpmmErrorCode2[CpmmErrorCode2["SentinelProgramNotProvided"] = 6019] = "SentinelProgramNotProvided";
|
|
205
|
+
CpmmErrorCode2[CpmmErrorCode2["SentinelProgramNotExecutable"] = 6020] = "SentinelProgramNotExecutable";
|
|
206
|
+
CpmmErrorCode2[CpmmErrorCode2["SentinelReturnDataMissing"] = 6021] = "SentinelReturnDataMissing";
|
|
207
|
+
CpmmErrorCode2[CpmmErrorCode2["SentinelReturnDataInvalid"] = 6022] = "SentinelReturnDataInvalid";
|
|
208
|
+
CpmmErrorCode2[CpmmErrorCode2["SentinelNotAllowlisted"] = 6023] = "SentinelNotAllowlisted";
|
|
209
|
+
CpmmErrorCode2[CpmmErrorCode2["TotalSharesZero"] = 6024] = "TotalSharesZero";
|
|
210
|
+
CpmmErrorCode2[CpmmErrorCode2["AmountZero"] = 6025] = "AmountZero";
|
|
211
|
+
CpmmErrorCode2[CpmmErrorCode2["Paused"] = 6026] = "Paused";
|
|
212
|
+
CpmmErrorCode2[CpmmErrorCode2["InvariantViolation"] = 6027] = "InvariantViolation";
|
|
213
|
+
CpmmErrorCode2[CpmmErrorCode2["InvalidMint"] = 6028] = "InvalidMint";
|
|
214
|
+
CpmmErrorCode2[CpmmErrorCode2["InvalidInput"] = 6029] = "InvalidInput";
|
|
215
|
+
CpmmErrorCode2[CpmmErrorCode2["Reentrancy"] = 6030] = "Reentrancy";
|
|
216
|
+
return CpmmErrorCode2;
|
|
217
|
+
})(CpmmErrorCode || {});
|
|
218
|
+
var CPMM_ERROR_MESSAGES = {
|
|
219
|
+
[6e3 /* Unauthorized */]: "Unauthorized: Caller lacks required authority",
|
|
220
|
+
[6001 /* PoolLocked */]: "Pool is currently locked (reentrancy protection)",
|
|
221
|
+
[6002 /* InvalidFee */]: "Invalid fee value (exceeds max or invalid range)",
|
|
222
|
+
[6003 /* InvalidFeeSplit */]: "Invalid fee split value (exceeds max or invalid range)",
|
|
223
|
+
[6004 /* InvalidDirection */]: "Invalid swap direction (must be 0 or 1)",
|
|
224
|
+
[6005 /* InsufficientLiquidity */]: "Insufficient liquidity for this operation",
|
|
225
|
+
[6006 /* SlippageExceeded */]: "Slippage exceeded: Output amount less than minimum",
|
|
226
|
+
[6007 /* MathOverflow */]: "Math operation overflowed",
|
|
227
|
+
[6008 /* InvalidMintOrder */]: "Token mints not in canonical order",
|
|
228
|
+
[6009 /* SameMintPair */]: "Cannot create pool with identical tokens",
|
|
229
|
+
[6010 /* InvalidVault */]: "Vault account is invalid or does not match",
|
|
230
|
+
[6011 /* InvalidPosition */]: "Position account is invalid or does not match",
|
|
231
|
+
[6012 /* PositionNotEmpty */]: "Cannot close position with non-zero shares or fees",
|
|
232
|
+
[6013 /* InvalidRoute */]: "Invalid route configuration",
|
|
233
|
+
[6014 /* NotSupportedInV0_1 */]: "Not supported in v0.1",
|
|
234
|
+
[6015 /* OracleNotInitialized */]: "Oracle not initialized for this pool",
|
|
235
|
+
[6016 /* ZeroSharesOut */]: "Zero shares out",
|
|
236
|
+
[6017 /* SentinelRejected */]: "Sentinel program rejected the operation",
|
|
237
|
+
[6018 /* SentinelCpiFailed */]: "Sentinel CPI call failed",
|
|
238
|
+
[6019 /* SentinelProgramNotProvided */]: "Sentinel program account not provided",
|
|
239
|
+
[6020 /* SentinelProgramNotExecutable */]: "Sentinel program account is not executable",
|
|
240
|
+
[6021 /* SentinelReturnDataMissing */]: "Sentinel return data missing or wrong program id",
|
|
241
|
+
[6022 /* SentinelReturnDataInvalid */]: "Sentinel return data invalid length or could not deserialize",
|
|
242
|
+
[6023 /* SentinelNotAllowlisted */]: "Sentinel program not in allowlist",
|
|
243
|
+
[6024 /* TotalSharesZero */]: "Pool has zero shares (no liquidity)",
|
|
244
|
+
[6025 /* AmountZero */]: "Amount cannot be zero",
|
|
245
|
+
[6026 /* Paused */]: "Pool is paused by admin",
|
|
246
|
+
[6027 /* InvariantViolation */]: "Internal invariant violation",
|
|
247
|
+
[6028 /* InvalidMint */]: "Invalid mint address",
|
|
248
|
+
[6029 /* InvalidInput */]: "Invalid input parameter",
|
|
249
|
+
[6030 /* Reentrancy */]: "Reentrancy detected"
|
|
250
|
+
};
|
|
251
|
+
var CpmmError = class extends Error {
|
|
252
|
+
constructor(code, logs) {
|
|
253
|
+
super(CPMM_ERROR_MESSAGES[code] || `Unknown CPMM error: ${code}`);
|
|
254
|
+
this.code = code;
|
|
255
|
+
this.logs = logs;
|
|
256
|
+
this.name = "CpmmError";
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Get the error code name
|
|
260
|
+
*/
|
|
261
|
+
get codeName() {
|
|
262
|
+
return CpmmErrorCode[this.code] || "Unknown";
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
function parseErrorFromLogs(logs) {
|
|
266
|
+
for (const log of logs) {
|
|
267
|
+
const anchorMatch = log.match(
|
|
268
|
+
/AnchorError.*Error Code:\s*(\w+)\.\s*Error Number:\s*(\d+)/
|
|
269
|
+
);
|
|
270
|
+
if (anchorMatch) {
|
|
271
|
+
const errorNumber = parseInt(anchorMatch[2], 10);
|
|
272
|
+
if (errorNumber >= 6e3 && errorNumber <= 6030) {
|
|
273
|
+
return new CpmmError(errorNumber, logs);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
const hexMatch = log.match(/Error Number:\s*0x([0-9a-fA-F]+)/);
|
|
277
|
+
if (hexMatch) {
|
|
278
|
+
const errorNumber = parseInt(hexMatch[1], 16);
|
|
279
|
+
if (errorNumber >= 6e3 && errorNumber <= 6030) {
|
|
280
|
+
return new CpmmError(errorNumber, logs);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
const customMatch = log.match(/Error Message:\s*(.+)/);
|
|
284
|
+
if (customMatch) {
|
|
285
|
+
const message = customMatch[1].toLowerCase();
|
|
286
|
+
for (const [code, msg] of Object.entries(CPMM_ERROR_MESSAGES)) {
|
|
287
|
+
if (msg.toLowerCase().includes(message) || message.includes(msg.toLowerCase())) {
|
|
288
|
+
return new CpmmError(parseInt(code), logs);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
function isCpmmError(code) {
|
|
296
|
+
return code >= 6e3 && code <= 6030;
|
|
297
|
+
}
|
|
298
|
+
function getErrorMessage(code) {
|
|
299
|
+
if (isCpmmError(code)) {
|
|
300
|
+
return CPMM_ERROR_MESSAGES[code];
|
|
301
|
+
}
|
|
302
|
+
return `Unknown error code: ${code}`;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// src/solana/instructions/initializeConfig.ts
|
|
306
|
+
function createInitializeConfigInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
307
|
+
const { config, payer, systemProgram = SYSTEM_PROGRAM_ID } = accounts;
|
|
308
|
+
const keys = [
|
|
309
|
+
{ address: config, role: ACCOUNT_ROLE_WRITABLE },
|
|
310
|
+
{ address: payer, role: ACCOUNT_ROLE_WRITABLE_SIGNER },
|
|
311
|
+
{ address: systemProgram, role: ACCOUNT_ROLE_READONLY }
|
|
312
|
+
];
|
|
313
|
+
const data = encodeInstructionData(
|
|
314
|
+
INSTRUCTION_DISCRIMINATORS.initializeConfig,
|
|
315
|
+
initializeConfigArgsCodec,
|
|
316
|
+
args
|
|
317
|
+
);
|
|
318
|
+
return {
|
|
319
|
+
programAddress: programId,
|
|
320
|
+
accounts: keys,
|
|
321
|
+
data
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// src/solana/instructions/initializePool.ts
|
|
326
|
+
function isTransactionSigner(value) {
|
|
327
|
+
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
328
|
+
}
|
|
329
|
+
function createSignerAccountMeta(value, role) {
|
|
330
|
+
if (isTransactionSigner(value)) {
|
|
331
|
+
return {
|
|
332
|
+
address: value.address,
|
|
333
|
+
role,
|
|
334
|
+
signer: value
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
return { address: value, role };
|
|
338
|
+
}
|
|
339
|
+
function createInitializePoolInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
340
|
+
const {
|
|
341
|
+
config,
|
|
342
|
+
pool,
|
|
343
|
+
protocolPosition,
|
|
344
|
+
authority,
|
|
345
|
+
vault0,
|
|
346
|
+
vault1,
|
|
347
|
+
token0Mint,
|
|
348
|
+
token1Mint,
|
|
349
|
+
payer,
|
|
350
|
+
tokenProgram = TOKEN_PROGRAM_ID,
|
|
351
|
+
systemProgram = SYSTEM_PROGRAM_ID,
|
|
352
|
+
rent
|
|
353
|
+
} = accounts;
|
|
354
|
+
const keys = [
|
|
355
|
+
{ address: config, role: ACCOUNT_ROLE_READONLY },
|
|
356
|
+
{ address: pool, role: ACCOUNT_ROLE_WRITABLE },
|
|
357
|
+
{ address: protocolPosition, role: ACCOUNT_ROLE_WRITABLE },
|
|
358
|
+
{ address: authority, role: ACCOUNT_ROLE_READONLY },
|
|
359
|
+
createSignerAccountMeta(vault0, ACCOUNT_ROLE_WRITABLE_SIGNER),
|
|
360
|
+
createSignerAccountMeta(vault1, ACCOUNT_ROLE_WRITABLE_SIGNER),
|
|
361
|
+
{ address: token0Mint, role: ACCOUNT_ROLE_READONLY },
|
|
362
|
+
{ address: token1Mint, role: ACCOUNT_ROLE_READONLY },
|
|
363
|
+
createSignerAccountMeta(payer, ACCOUNT_ROLE_WRITABLE_SIGNER),
|
|
364
|
+
{ address: tokenProgram, role: ACCOUNT_ROLE_READONLY },
|
|
365
|
+
{ address: systemProgram, role: ACCOUNT_ROLE_READONLY },
|
|
366
|
+
{ address: rent, role: ACCOUNT_ROLE_READONLY }
|
|
367
|
+
];
|
|
368
|
+
const data = encodeInstructionData(
|
|
369
|
+
INSTRUCTION_DISCRIMINATORS.initializePool,
|
|
370
|
+
initializePoolArgsCodec,
|
|
371
|
+
args
|
|
372
|
+
);
|
|
373
|
+
return {
|
|
374
|
+
programAddress: programId,
|
|
375
|
+
accounts: keys,
|
|
376
|
+
data
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// src/solana/instructions/initializeOracle.ts
|
|
381
|
+
function createInitializeOracleInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
382
|
+
const {
|
|
383
|
+
config,
|
|
384
|
+
pool,
|
|
385
|
+
oracle,
|
|
386
|
+
admin,
|
|
387
|
+
payer,
|
|
388
|
+
systemProgram = SYSTEM_PROGRAM_ID
|
|
389
|
+
} = accounts;
|
|
390
|
+
const keys = [
|
|
391
|
+
{ address: config, role: ACCOUNT_ROLE_READONLY },
|
|
392
|
+
{ address: pool, role: ACCOUNT_ROLE_READONLY },
|
|
393
|
+
{ address: oracle, role: ACCOUNT_ROLE_WRITABLE },
|
|
394
|
+
{ address: admin, role: ACCOUNT_ROLE_SIGNER },
|
|
395
|
+
{ address: payer, role: ACCOUNT_ROLE_WRITABLE_SIGNER },
|
|
396
|
+
{ address: systemProgram, role: ACCOUNT_ROLE_READONLY }
|
|
397
|
+
];
|
|
398
|
+
const data = encodeInstructionData(
|
|
399
|
+
INSTRUCTION_DISCRIMINATORS.initializeOracle,
|
|
400
|
+
initializeOracleArgsCodec,
|
|
401
|
+
args
|
|
402
|
+
);
|
|
403
|
+
return {
|
|
404
|
+
programAddress: programId,
|
|
405
|
+
accounts: keys,
|
|
406
|
+
data
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// src/solana/instructions/setFees.ts
|
|
411
|
+
function createSetFeesInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
412
|
+
const { config, pool, admin } = accounts;
|
|
413
|
+
const keys = [
|
|
414
|
+
{ address: config, role: ACCOUNT_ROLE_READONLY },
|
|
415
|
+
{ address: pool, role: ACCOUNT_ROLE_WRITABLE },
|
|
416
|
+
{ address: admin, role: ACCOUNT_ROLE_SIGNER }
|
|
417
|
+
];
|
|
418
|
+
const data = encodeInstructionData(
|
|
419
|
+
INSTRUCTION_DISCRIMINATORS.setFees,
|
|
420
|
+
setFeesArgsCodec,
|
|
421
|
+
args
|
|
422
|
+
);
|
|
423
|
+
return {
|
|
424
|
+
programAddress: programId,
|
|
425
|
+
accounts: keys,
|
|
426
|
+
data
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// src/solana/instructions/setSentinel.ts
|
|
431
|
+
function createSetSentinelInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
432
|
+
const { config, pool, admin } = accounts;
|
|
433
|
+
const keys = [
|
|
434
|
+
{ address: config, role: ACCOUNT_ROLE_READONLY },
|
|
435
|
+
{ address: pool, role: ACCOUNT_ROLE_WRITABLE },
|
|
436
|
+
{ address: admin, role: ACCOUNT_ROLE_SIGNER }
|
|
437
|
+
];
|
|
438
|
+
const data = encodeInstructionData(
|
|
439
|
+
INSTRUCTION_DISCRIMINATORS.setSentinel,
|
|
440
|
+
setSentinelArgsCodec,
|
|
441
|
+
args
|
|
442
|
+
);
|
|
443
|
+
return {
|
|
444
|
+
programAddress: programId,
|
|
445
|
+
accounts: keys,
|
|
446
|
+
data
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
// src/solana/instructions/setRoute.ts
|
|
451
|
+
function createSetRouteInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
452
|
+
const { config, pool, nextPool, admin } = accounts;
|
|
453
|
+
const keys = [
|
|
454
|
+
{ address: config, role: ACCOUNT_ROLE_READONLY },
|
|
455
|
+
{ address: pool, role: ACCOUNT_ROLE_WRITABLE }
|
|
456
|
+
];
|
|
457
|
+
if (nextPool) {
|
|
458
|
+
keys.push({ address: nextPool, role: ACCOUNT_ROLE_READONLY });
|
|
459
|
+
}
|
|
460
|
+
keys.push({ address: admin, role: ACCOUNT_ROLE_SIGNER });
|
|
461
|
+
const data = encodeInstructionData(
|
|
462
|
+
INSTRUCTION_DISCRIMINATORS.setRoute,
|
|
463
|
+
setRouteArgsCodec,
|
|
464
|
+
args
|
|
465
|
+
);
|
|
466
|
+
return {
|
|
467
|
+
programAddress: programId,
|
|
468
|
+
accounts: keys,
|
|
469
|
+
data
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// src/solana/instructions/pause.ts
|
|
474
|
+
function createPauseInstruction(accounts, programId = PROGRAM_ID) {
|
|
475
|
+
const { config, admin } = accounts;
|
|
476
|
+
const keys = [
|
|
477
|
+
{ address: config, role: ACCOUNT_ROLE_WRITABLE },
|
|
478
|
+
{ address: admin, role: ACCOUNT_ROLE_SIGNER }
|
|
479
|
+
];
|
|
480
|
+
const data = INSTRUCTION_DISCRIMINATORS.pause;
|
|
481
|
+
return {
|
|
482
|
+
programAddress: programId,
|
|
483
|
+
accounts: keys,
|
|
484
|
+
data
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
// src/solana/instructions/unpause.ts
|
|
489
|
+
function createUnpauseInstruction(accounts, programId = PROGRAM_ID) {
|
|
490
|
+
const { config, admin } = accounts;
|
|
491
|
+
const keys = [
|
|
492
|
+
{ address: config, role: ACCOUNT_ROLE_WRITABLE },
|
|
493
|
+
{ address: admin, role: ACCOUNT_ROLE_SIGNER }
|
|
494
|
+
];
|
|
495
|
+
const data = INSTRUCTION_DISCRIMINATORS.unpause;
|
|
496
|
+
return {
|
|
497
|
+
programAddress: programId,
|
|
498
|
+
accounts: keys,
|
|
499
|
+
data
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// src/solana/instructions/transferAdmin.ts
|
|
504
|
+
function createTransferAdminInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
505
|
+
const { config, admin } = accounts;
|
|
506
|
+
const keys = [
|
|
507
|
+
{ address: config, role: ACCOUNT_ROLE_WRITABLE },
|
|
508
|
+
{ address: admin, role: ACCOUNT_ROLE_SIGNER }
|
|
509
|
+
];
|
|
510
|
+
const data = encodeInstructionData(
|
|
511
|
+
INSTRUCTION_DISCRIMINATORS.transferAdmin,
|
|
512
|
+
transferAdminArgsCodec,
|
|
513
|
+
args
|
|
514
|
+
);
|
|
515
|
+
return {
|
|
516
|
+
programAddress: programId,
|
|
517
|
+
accounts: keys,
|
|
518
|
+
data
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// src/solana/instructions/skim.ts
|
|
523
|
+
function createSkimInstruction(accounts, programId = PROGRAM_ID) {
|
|
524
|
+
const {
|
|
525
|
+
config,
|
|
526
|
+
pool,
|
|
527
|
+
admin,
|
|
528
|
+
authority,
|
|
529
|
+
vault0,
|
|
530
|
+
vault1,
|
|
531
|
+
token0Mint,
|
|
532
|
+
token1Mint,
|
|
533
|
+
adminAta0,
|
|
534
|
+
adminAta1,
|
|
535
|
+
tokenProgram = TOKEN_PROGRAM_ID
|
|
536
|
+
} = accounts;
|
|
537
|
+
const keys = [
|
|
538
|
+
{ address: config, role: ACCOUNT_ROLE_READONLY },
|
|
539
|
+
{ address: pool, role: ACCOUNT_ROLE_READONLY },
|
|
540
|
+
{ address: admin, role: ACCOUNT_ROLE_SIGNER },
|
|
541
|
+
{ address: authority, role: ACCOUNT_ROLE_READONLY },
|
|
542
|
+
{ address: vault0, role: ACCOUNT_ROLE_WRITABLE },
|
|
543
|
+
{ address: vault1, role: ACCOUNT_ROLE_WRITABLE },
|
|
544
|
+
{ address: token0Mint, role: ACCOUNT_ROLE_READONLY },
|
|
545
|
+
{ address: token1Mint, role: ACCOUNT_ROLE_READONLY },
|
|
546
|
+
{ address: adminAta0, role: ACCOUNT_ROLE_WRITABLE },
|
|
547
|
+
{ address: adminAta1, role: ACCOUNT_ROLE_WRITABLE },
|
|
548
|
+
{ address: tokenProgram, role: ACCOUNT_ROLE_READONLY }
|
|
549
|
+
];
|
|
550
|
+
const data = INSTRUCTION_DISCRIMINATORS.skim;
|
|
551
|
+
return {
|
|
552
|
+
programAddress: programId,
|
|
553
|
+
accounts: keys,
|
|
554
|
+
data
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// src/solana/instructions/swapExactIn.ts
|
|
559
|
+
function createSwapExactInInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
560
|
+
const {
|
|
561
|
+
config,
|
|
562
|
+
pool,
|
|
563
|
+
authority,
|
|
564
|
+
vaultIn,
|
|
565
|
+
vaultOut,
|
|
566
|
+
token0Mint,
|
|
567
|
+
token1Mint,
|
|
568
|
+
userIn,
|
|
569
|
+
userOut,
|
|
570
|
+
user,
|
|
571
|
+
tokenProgram = TOKEN_PROGRAM_ID,
|
|
572
|
+
oracle,
|
|
573
|
+
remainingAccounts = []
|
|
574
|
+
} = accounts;
|
|
575
|
+
const keys = [
|
|
576
|
+
{ address: config, role: ACCOUNT_ROLE_READONLY },
|
|
577
|
+
{ address: pool, role: ACCOUNT_ROLE_WRITABLE },
|
|
578
|
+
{ address: authority, role: ACCOUNT_ROLE_READONLY },
|
|
579
|
+
{ address: vaultIn, role: ACCOUNT_ROLE_WRITABLE },
|
|
580
|
+
{ address: vaultOut, role: ACCOUNT_ROLE_WRITABLE },
|
|
581
|
+
{ address: token0Mint, role: ACCOUNT_ROLE_READONLY },
|
|
582
|
+
{ address: token1Mint, role: ACCOUNT_ROLE_READONLY },
|
|
583
|
+
{ address: userIn, role: ACCOUNT_ROLE_WRITABLE },
|
|
584
|
+
{ address: userOut, role: ACCOUNT_ROLE_WRITABLE },
|
|
585
|
+
{ address: user, role: ACCOUNT_ROLE_SIGNER },
|
|
586
|
+
{ address: tokenProgram, role: ACCOUNT_ROLE_READONLY }
|
|
587
|
+
];
|
|
588
|
+
if (oracle) {
|
|
589
|
+
keys.push({ address: oracle, role: ACCOUNT_ROLE_WRITABLE });
|
|
590
|
+
}
|
|
591
|
+
for (const account of remainingAccounts) {
|
|
592
|
+
keys.push({ address: account, role: ACCOUNT_ROLE_READONLY });
|
|
593
|
+
}
|
|
594
|
+
const data = encodeInstructionData(
|
|
595
|
+
INSTRUCTION_DISCRIMINATORS.swapExactIn,
|
|
596
|
+
swapExactInArgsCodec,
|
|
597
|
+
args
|
|
598
|
+
);
|
|
599
|
+
return {
|
|
600
|
+
programAddress: programId,
|
|
601
|
+
accounts: keys,
|
|
602
|
+
data
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
function createSwapInstruction(params) {
|
|
606
|
+
const {
|
|
607
|
+
config,
|
|
608
|
+
pool,
|
|
609
|
+
authority,
|
|
610
|
+
vault0,
|
|
611
|
+
vault1,
|
|
612
|
+
token0Mint,
|
|
613
|
+
token1Mint,
|
|
614
|
+
userToken0,
|
|
615
|
+
userToken1,
|
|
616
|
+
user,
|
|
617
|
+
amountIn,
|
|
618
|
+
minAmountOut,
|
|
619
|
+
direction,
|
|
620
|
+
oracle,
|
|
621
|
+
remainingAccounts,
|
|
622
|
+
updateOracle = false,
|
|
623
|
+
programId = PROGRAM_ID
|
|
624
|
+
} = params;
|
|
625
|
+
const [vaultIn, vaultOut] = direction === 0 ? [vault0, vault1] : [vault1, vault0];
|
|
626
|
+
const [userIn, userOut] = direction === 0 ? [userToken0, userToken1] : [userToken1, userToken0];
|
|
627
|
+
return createSwapExactInInstruction(
|
|
628
|
+
{
|
|
629
|
+
config,
|
|
630
|
+
pool,
|
|
631
|
+
authority,
|
|
632
|
+
vaultIn,
|
|
633
|
+
vaultOut,
|
|
634
|
+
token0Mint,
|
|
635
|
+
token1Mint,
|
|
636
|
+
userIn,
|
|
637
|
+
userOut,
|
|
638
|
+
user,
|
|
639
|
+
oracle,
|
|
640
|
+
remainingAccounts
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
amountIn,
|
|
644
|
+
minAmountOut,
|
|
645
|
+
direction,
|
|
646
|
+
updateOracle
|
|
647
|
+
},
|
|
648
|
+
programId
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
// src/solana/instructions/createPosition.ts
|
|
653
|
+
function createCreatePositionInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
654
|
+
const {
|
|
655
|
+
pool,
|
|
656
|
+
position,
|
|
657
|
+
owner,
|
|
658
|
+
payer,
|
|
659
|
+
systemProgram = SYSTEM_PROGRAM_ID
|
|
660
|
+
} = accounts;
|
|
661
|
+
const keys = [
|
|
662
|
+
{ address: pool, role: ACCOUNT_ROLE_READONLY },
|
|
663
|
+
{ address: position, role: ACCOUNT_ROLE_WRITABLE },
|
|
664
|
+
{ address: owner, role: ACCOUNT_ROLE_SIGNER },
|
|
665
|
+
{ address: payer, role: ACCOUNT_ROLE_WRITABLE_SIGNER },
|
|
666
|
+
{ address: systemProgram, role: ACCOUNT_ROLE_READONLY }
|
|
667
|
+
];
|
|
668
|
+
const data = encodeInstructionData(
|
|
669
|
+
INSTRUCTION_DISCRIMINATORS.createPosition,
|
|
670
|
+
createPositionArgsCodec,
|
|
671
|
+
args
|
|
672
|
+
);
|
|
673
|
+
return {
|
|
674
|
+
programAddress: programId,
|
|
675
|
+
accounts: keys,
|
|
676
|
+
data
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
// src/solana/instructions/closePosition.ts
|
|
681
|
+
function createClosePositionInstruction(accounts, programId = PROGRAM_ID) {
|
|
682
|
+
const { pool, position, owner, rentRecipient } = accounts;
|
|
683
|
+
const keys = [
|
|
684
|
+
{ address: pool, role: ACCOUNT_ROLE_READONLY },
|
|
685
|
+
{ address: position, role: ACCOUNT_ROLE_WRITABLE },
|
|
686
|
+
{ address: owner, role: ACCOUNT_ROLE_SIGNER },
|
|
687
|
+
{ address: rentRecipient, role: ACCOUNT_ROLE_WRITABLE }
|
|
688
|
+
];
|
|
689
|
+
const data = INSTRUCTION_DISCRIMINATORS.closePosition;
|
|
690
|
+
return {
|
|
691
|
+
programAddress: programId,
|
|
692
|
+
accounts: keys,
|
|
693
|
+
data
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
var addLiquidityArgsWithOracleCodec = getStructCodec([
|
|
697
|
+
["amount0Max", getU64Codec()],
|
|
698
|
+
["amount1Max", getU64Codec()],
|
|
699
|
+
["minSharesOut", getU128Codec()],
|
|
700
|
+
["updateOracle", getBooleanCodec()]
|
|
701
|
+
]);
|
|
702
|
+
function createAddLiquidityInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
703
|
+
const {
|
|
704
|
+
config,
|
|
705
|
+
pool,
|
|
706
|
+
position,
|
|
707
|
+
protocolPosition,
|
|
708
|
+
owner,
|
|
709
|
+
authority,
|
|
710
|
+
vault0,
|
|
711
|
+
vault1,
|
|
712
|
+
token0Mint,
|
|
713
|
+
token1Mint,
|
|
714
|
+
user0,
|
|
715
|
+
user1,
|
|
716
|
+
tokenProgram = TOKEN_PROGRAM_ID,
|
|
717
|
+
oracle,
|
|
718
|
+
remainingAccounts = []
|
|
719
|
+
} = accounts;
|
|
720
|
+
const keys = [
|
|
721
|
+
{ address: config, role: ACCOUNT_ROLE_READONLY },
|
|
722
|
+
{ address: pool, role: ACCOUNT_ROLE_WRITABLE },
|
|
723
|
+
{ address: position, role: ACCOUNT_ROLE_WRITABLE },
|
|
724
|
+
{ address: protocolPosition, role: ACCOUNT_ROLE_WRITABLE },
|
|
725
|
+
{ address: owner, role: ACCOUNT_ROLE_SIGNER },
|
|
726
|
+
{ address: authority, role: ACCOUNT_ROLE_READONLY },
|
|
727
|
+
{ address: vault0, role: ACCOUNT_ROLE_WRITABLE },
|
|
728
|
+
{ address: vault1, role: ACCOUNT_ROLE_WRITABLE },
|
|
729
|
+
{ address: token0Mint, role: ACCOUNT_ROLE_READONLY },
|
|
730
|
+
{ address: token1Mint, role: ACCOUNT_ROLE_READONLY },
|
|
731
|
+
{ address: user0, role: ACCOUNT_ROLE_WRITABLE },
|
|
732
|
+
{ address: user1, role: ACCOUNT_ROLE_WRITABLE },
|
|
733
|
+
{ address: tokenProgram, role: ACCOUNT_ROLE_READONLY }
|
|
734
|
+
];
|
|
735
|
+
if (oracle) {
|
|
736
|
+
keys.push({ address: oracle, role: ACCOUNT_ROLE_WRITABLE });
|
|
737
|
+
}
|
|
738
|
+
for (const account of remainingAccounts) {
|
|
739
|
+
keys.push({ address: account, role: ACCOUNT_ROLE_READONLY });
|
|
740
|
+
}
|
|
741
|
+
const data = encodeInstructionData(
|
|
742
|
+
INSTRUCTION_DISCRIMINATORS.addLiquidity,
|
|
743
|
+
addLiquidityArgsWithOracleCodec,
|
|
744
|
+
args
|
|
745
|
+
);
|
|
746
|
+
return {
|
|
747
|
+
programAddress: programId,
|
|
748
|
+
accounts: keys,
|
|
749
|
+
data
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
// src/solana/instructions/removeLiquidity.ts
|
|
754
|
+
function createRemoveLiquidityInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
755
|
+
const {
|
|
756
|
+
config,
|
|
757
|
+
pool,
|
|
758
|
+
position,
|
|
759
|
+
protocolPosition,
|
|
760
|
+
owner,
|
|
761
|
+
authority,
|
|
762
|
+
vault0,
|
|
763
|
+
vault1,
|
|
764
|
+
token0Mint,
|
|
765
|
+
token1Mint,
|
|
766
|
+
user0,
|
|
767
|
+
user1,
|
|
768
|
+
tokenProgram = TOKEN_PROGRAM_ID,
|
|
769
|
+
oracle,
|
|
770
|
+
remainingAccounts = []
|
|
771
|
+
} = accounts;
|
|
772
|
+
const keys = [
|
|
773
|
+
{ address: config, role: ACCOUNT_ROLE_READONLY },
|
|
774
|
+
{ address: pool, role: ACCOUNT_ROLE_WRITABLE },
|
|
775
|
+
{ address: position, role: ACCOUNT_ROLE_WRITABLE },
|
|
776
|
+
{ address: protocolPosition, role: ACCOUNT_ROLE_WRITABLE },
|
|
777
|
+
{ address: owner, role: ACCOUNT_ROLE_SIGNER },
|
|
778
|
+
{ address: authority, role: ACCOUNT_ROLE_READONLY },
|
|
779
|
+
{ address: vault0, role: ACCOUNT_ROLE_WRITABLE },
|
|
780
|
+
{ address: vault1, role: ACCOUNT_ROLE_WRITABLE },
|
|
781
|
+
{ address: token0Mint, role: ACCOUNT_ROLE_READONLY },
|
|
782
|
+
{ address: token1Mint, role: ACCOUNT_ROLE_READONLY },
|
|
783
|
+
{ address: user0, role: ACCOUNT_ROLE_WRITABLE },
|
|
784
|
+
{ address: user1, role: ACCOUNT_ROLE_WRITABLE },
|
|
785
|
+
{ address: tokenProgram, role: ACCOUNT_ROLE_READONLY }
|
|
786
|
+
];
|
|
787
|
+
if (oracle) {
|
|
788
|
+
keys.push({ address: oracle, role: ACCOUNT_ROLE_WRITABLE });
|
|
789
|
+
}
|
|
790
|
+
for (const account of remainingAccounts) {
|
|
791
|
+
keys.push({ address: account, role: ACCOUNT_ROLE_READONLY });
|
|
792
|
+
}
|
|
793
|
+
const data = encodeInstructionData(
|
|
794
|
+
INSTRUCTION_DISCRIMINATORS.removeLiquidity,
|
|
795
|
+
removeLiquidityArgsCodec,
|
|
796
|
+
args
|
|
797
|
+
);
|
|
798
|
+
return {
|
|
799
|
+
programAddress: programId,
|
|
800
|
+
accounts: keys,
|
|
801
|
+
data
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
// src/solana/instructions/collectProtocolFees.ts
|
|
806
|
+
function createCollectProtocolFeesInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
807
|
+
const {
|
|
808
|
+
config,
|
|
809
|
+
pool,
|
|
810
|
+
protocolPosition,
|
|
811
|
+
admin,
|
|
812
|
+
authority,
|
|
813
|
+
vault0,
|
|
814
|
+
vault1,
|
|
815
|
+
token0Mint,
|
|
816
|
+
token1Mint,
|
|
817
|
+
recipient0,
|
|
818
|
+
recipient1,
|
|
819
|
+
tokenProgram = TOKEN_PROGRAM_ID
|
|
820
|
+
} = accounts;
|
|
821
|
+
const keys = [
|
|
822
|
+
{ address: config, role: ACCOUNT_ROLE_READONLY },
|
|
823
|
+
{ address: pool, role: ACCOUNT_ROLE_WRITABLE },
|
|
824
|
+
{ address: protocolPosition, role: ACCOUNT_ROLE_WRITABLE },
|
|
825
|
+
{ address: admin, role: ACCOUNT_ROLE_SIGNER },
|
|
826
|
+
{ address: authority, role: ACCOUNT_ROLE_READONLY },
|
|
827
|
+
{ address: vault0, role: ACCOUNT_ROLE_WRITABLE },
|
|
828
|
+
{ address: vault1, role: ACCOUNT_ROLE_WRITABLE },
|
|
829
|
+
{ address: token0Mint, role: ACCOUNT_ROLE_READONLY },
|
|
830
|
+
{ address: token1Mint, role: ACCOUNT_ROLE_READONLY },
|
|
831
|
+
{ address: recipient0, role: ACCOUNT_ROLE_WRITABLE },
|
|
832
|
+
{ address: recipient1, role: ACCOUNT_ROLE_WRITABLE },
|
|
833
|
+
{ address: tokenProgram, role: ACCOUNT_ROLE_READONLY }
|
|
834
|
+
];
|
|
835
|
+
const data = encodeInstructionData(
|
|
836
|
+
INSTRUCTION_DISCRIMINATORS.collectProtocolFees,
|
|
837
|
+
collectProtocolFeesArgsCodec,
|
|
838
|
+
args
|
|
839
|
+
);
|
|
840
|
+
return {
|
|
841
|
+
programAddress: programId,
|
|
842
|
+
accounts: keys,
|
|
843
|
+
data
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
// src/solana/instructions/oracleUpdate.ts
|
|
848
|
+
function createOracleUpdateInstruction(accounts, programId = PROGRAM_ID) {
|
|
849
|
+
const { pool, oracle } = accounts;
|
|
850
|
+
const keys = [
|
|
851
|
+
{ address: pool, role: ACCOUNT_ROLE_READONLY },
|
|
852
|
+
{ address: oracle, role: ACCOUNT_ROLE_WRITABLE }
|
|
853
|
+
];
|
|
854
|
+
const data = INSTRUCTION_DISCRIMINATORS.oracleUpdate;
|
|
855
|
+
return {
|
|
856
|
+
programAddress: programId,
|
|
857
|
+
accounts: keys,
|
|
858
|
+
data
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
var oracleConsultResultCodec = getStructCodec([
|
|
862
|
+
["price0Q64", getU128Codec()],
|
|
863
|
+
["price1Q64", getU128Codec()]
|
|
864
|
+
]);
|
|
865
|
+
function decodeOracleConsultResult(data) {
|
|
866
|
+
return oracleConsultResultCodec.decode(data);
|
|
867
|
+
}
|
|
868
|
+
function createOracleConsultInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
869
|
+
const { pool, oracle } = accounts;
|
|
870
|
+
const keys = [
|
|
871
|
+
{ address: pool, role: ACCOUNT_ROLE_READONLY },
|
|
872
|
+
{ address: oracle, role: ACCOUNT_ROLE_READONLY }
|
|
873
|
+
];
|
|
874
|
+
const data = encodeInstructionData(
|
|
875
|
+
INSTRUCTION_DISCRIMINATORS.oracleConsult,
|
|
876
|
+
oracleConsultArgsCodec,
|
|
877
|
+
args
|
|
878
|
+
);
|
|
879
|
+
return {
|
|
880
|
+
programAddress: programId,
|
|
881
|
+
accounts: keys,
|
|
882
|
+
data
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
var quoteToNumeraireResultCodec = getStructCodec([
|
|
886
|
+
["amountInNumeraire", getU128Codec()],
|
|
887
|
+
["endMint", getAddressCodec()],
|
|
888
|
+
["hopsUsed", getU8Codec()]
|
|
889
|
+
]);
|
|
890
|
+
function decodeQuoteToNumeraireResult(data) {
|
|
891
|
+
return quoteToNumeraireResultCodec.decode(data);
|
|
892
|
+
}
|
|
893
|
+
function createQuoteToNumeraireInstruction(accounts, args, programId = PROGRAM_ID) {
|
|
894
|
+
const { config, startPool, remainingAccounts = [] } = accounts;
|
|
895
|
+
const keys = [
|
|
896
|
+
{ address: config, role: ACCOUNT_ROLE_READONLY },
|
|
897
|
+
{ address: startPool, role: ACCOUNT_ROLE_READONLY }
|
|
898
|
+
];
|
|
899
|
+
for (const account of remainingAccounts) {
|
|
900
|
+
keys.push({ address: account, role: ACCOUNT_ROLE_READONLY });
|
|
901
|
+
}
|
|
902
|
+
const data = encodeInstructionData(
|
|
903
|
+
INSTRUCTION_DISCRIMINATORS.quoteToNumeraire,
|
|
904
|
+
quoteToNumeraireArgsCodec,
|
|
905
|
+
args
|
|
906
|
+
);
|
|
907
|
+
return {
|
|
908
|
+
programAddress: programId,
|
|
909
|
+
accounts: keys,
|
|
910
|
+
data
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
// src/solana/client/config.ts
|
|
915
|
+
function base64ToBytes(base64) {
|
|
916
|
+
const binary = atob(base64);
|
|
917
|
+
const bytes = new Uint8Array(binary.length);
|
|
918
|
+
for (let i = 0; i < binary.length; i++) {
|
|
919
|
+
bytes[i] = binary.charCodeAt(i);
|
|
920
|
+
}
|
|
921
|
+
return bytes;
|
|
922
|
+
}
|
|
923
|
+
async function fetchConfig(rpc, programId = PROGRAM_ID, commitment) {
|
|
924
|
+
const [configAddress] = await getConfigAddress(programId);
|
|
925
|
+
const response = await rpc.getAccountInfo(configAddress, {
|
|
926
|
+
encoding: "base64",
|
|
927
|
+
commitment
|
|
928
|
+
}).send();
|
|
929
|
+
if (!response.value) {
|
|
930
|
+
return null;
|
|
931
|
+
}
|
|
932
|
+
return decodeAmmConfig(base64ToBytes(response.value.data[0]));
|
|
933
|
+
}
|
|
934
|
+
async function fetchConfigWithAddress(rpc, programId = PROGRAM_ID, commitment) {
|
|
935
|
+
const [configAddress] = await getConfigAddress(programId);
|
|
936
|
+
const account = await fetchConfig(rpc, programId, commitment);
|
|
937
|
+
if (!account) {
|
|
938
|
+
return null;
|
|
939
|
+
}
|
|
940
|
+
return { address: configAddress, account };
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
// src/solana/initializer/index.ts
|
|
944
|
+
var initializer_exports = {};
|
|
945
|
+
__export(initializer_exports, {
|
|
946
|
+
BPF_LOADER_UPGRADEABLE_PROGRAM_ID: () => BPF_LOADER_UPGRADEABLE_PROGRAM_ID,
|
|
947
|
+
CURVE_KIND_XYK: () => CURVE_KIND_XYK,
|
|
948
|
+
CURVE_PARAMS_FORMAT_XYK_V0: () => CURVE_PARAMS_FORMAT_XYK_V0,
|
|
949
|
+
DIRECTION_BUY: () => DIRECTION_BUY,
|
|
950
|
+
DIRECTION_SELL: () => DIRECTION_SELL,
|
|
951
|
+
INITIALIZER_ACCOUNT_DISCRIMINATORS: () => INITIALIZER_ACCOUNT_DISCRIMINATORS,
|
|
952
|
+
INITIALIZER_INSTRUCTION_DISCRIMINATORS: () => INITIALIZER_INSTRUCTION_DISCRIMINATORS,
|
|
953
|
+
INITIALIZER_PROGRAM_ID: () => INITIALIZER_PROGRAM_ID,
|
|
954
|
+
MAX_CALLDATA: () => MAX_CALLDATA,
|
|
955
|
+
MAX_MIGRATOR_ALLOWLIST: () => MAX_MIGRATOR_ALLOWLIST,
|
|
956
|
+
MAX_SENTINEL_ALLOWLIST: () => MAX_SENTINEL_ALLOWLIST2,
|
|
957
|
+
PHASE_ABORTED: () => PHASE_ABORTED,
|
|
958
|
+
PHASE_MIGRATED: () => PHASE_MIGRATED,
|
|
959
|
+
PHASE_TRADING: () => PHASE_TRADING,
|
|
960
|
+
SEED_CONFIG: () => SEED_CONFIG2,
|
|
961
|
+
SEED_LAUNCH: () => SEED_LAUNCH,
|
|
962
|
+
SEED_LAUNCH_AUTHORITY: () => SEED_LAUNCH_AUTHORITY,
|
|
963
|
+
SENTINEL_NO_CHANGE: () => SENTINEL_NO_CHANGE2,
|
|
964
|
+
SF_AFTER_SWAP: () => SF_AFTER_SWAP2,
|
|
965
|
+
SF_BEFORE_SWAP: () => SF_BEFORE_SWAP2,
|
|
966
|
+
createAbortLaunchInstruction: () => createAbortLaunchInstruction,
|
|
967
|
+
createCurveSwapExactInInstruction: () => createCurveSwapExactInInstruction,
|
|
968
|
+
createInitializeConfigInstruction: () => createInitializeConfigInstruction2,
|
|
969
|
+
createInitializeLaunchInstruction: () => createInitializeLaunchInstruction,
|
|
970
|
+
createMigrateLaunchInstruction: () => createMigrateLaunchInstruction,
|
|
971
|
+
createPreviewMigrationInstruction: () => createPreviewMigrationInstruction,
|
|
972
|
+
createPreviewSwapExactInInstruction: () => createPreviewSwapExactInInstruction,
|
|
973
|
+
createSetMigratorAllowlistInstruction: () => createSetMigratorAllowlistInstruction,
|
|
974
|
+
createSetSentinelAllowlistInstruction: () => createSetSentinelAllowlistInstruction,
|
|
975
|
+
decodePreviewMigrationResult: () => decodePreviewMigrationResult,
|
|
976
|
+
decodePreviewSwapExactInResult: () => decodePreviewSwapExactInResult,
|
|
977
|
+
encodeU64LE: () => encodeU64LE,
|
|
978
|
+
fetchAllLaunches: () => fetchAllLaunches,
|
|
979
|
+
fetchLaunch: () => fetchLaunch,
|
|
980
|
+
fetchLaunchesByAuthority: () => fetchLaunchesByAuthority,
|
|
981
|
+
getConfigAddress: () => getConfigAddress2,
|
|
982
|
+
getInitConfigCodec: () => getInitConfigCodec,
|
|
983
|
+
getInitConfigDecoder: () => getInitConfigDecoder,
|
|
984
|
+
getInitConfigEncoder: () => getInitConfigEncoder,
|
|
985
|
+
getInitializeConfigArgsCodec: () => getInitializeConfigArgsCodec,
|
|
986
|
+
getInitializeConfigArgsDecoder: () => getInitializeConfigArgsDecoder,
|
|
987
|
+
getInitializeConfigArgsEncoder: () => getInitializeConfigArgsEncoder,
|
|
988
|
+
getInitializeLaunchArgsCodec: () => getInitializeLaunchArgsCodec,
|
|
989
|
+
getInitializeLaunchArgsDecoder: () => getInitializeLaunchArgsDecoder,
|
|
990
|
+
getInitializeLaunchArgsEncoder: () => getInitializeLaunchArgsEncoder,
|
|
991
|
+
getLaunchAddress: () => getLaunchAddress,
|
|
992
|
+
getLaunchAuthorityAddress: () => getLaunchAuthorityAddress,
|
|
993
|
+
getLaunchCodec: () => getLaunchCodec,
|
|
994
|
+
getLaunchDecoder: () => getLaunchDecoder,
|
|
995
|
+
getLaunchEncoder: () => getLaunchEncoder,
|
|
996
|
+
getProgramDataAddress: () => getProgramDataAddress,
|
|
997
|
+
launchExists: () => launchExists,
|
|
998
|
+
launchIdFromU64: () => launchIdFromU64
|
|
999
|
+
});
|
|
1000
|
+
var INITIALIZER_PROGRAM_ID = address(
|
|
1001
|
+
"4H9w6qMqqSh6DVW7BzYxPHFvLaQP7rbRiQnPYGPajQxq"
|
|
1002
|
+
);
|
|
1003
|
+
var BPF_LOADER_UPGRADEABLE_PROGRAM_ID = address(
|
|
1004
|
+
"BPFLoaderUpgradeab1e11111111111111111111111"
|
|
1005
|
+
);
|
|
1006
|
+
var SEED_CONFIG2 = "config_v3";
|
|
1007
|
+
var SEED_LAUNCH = "launch_v3";
|
|
1008
|
+
var SEED_LAUNCH_AUTHORITY = "launch_authority_v3";
|
|
1009
|
+
var MAX_MIGRATOR_ALLOWLIST = 32;
|
|
1010
|
+
var MAX_SENTINEL_ALLOWLIST2 = 32;
|
|
1011
|
+
var MAX_CALLDATA = 256;
|
|
1012
|
+
var PHASE_TRADING = 0;
|
|
1013
|
+
var PHASE_MIGRATED = 1;
|
|
1014
|
+
var PHASE_ABORTED = 2;
|
|
1015
|
+
var DIRECTION_BUY = 0;
|
|
1016
|
+
var DIRECTION_SELL = 1;
|
|
1017
|
+
var CURVE_KIND_XYK = 0;
|
|
1018
|
+
var CURVE_PARAMS_FORMAT_XYK_V0 = 0;
|
|
1019
|
+
var SF_BEFORE_SWAP2 = 1 << 0;
|
|
1020
|
+
var SF_AFTER_SWAP2 = 1 << 1;
|
|
1021
|
+
var SENTINEL_NO_CHANGE2 = 65535;
|
|
1022
|
+
var INITIALIZER_INSTRUCTION_DISCRIMINATORS = {
|
|
1023
|
+
// SHA256("global:initialize_config")[0:8]
|
|
1024
|
+
initializeConfig: new Uint8Array([
|
|
1025
|
+
208,
|
|
1026
|
+
127,
|
|
1027
|
+
21,
|
|
1028
|
+
1,
|
|
1029
|
+
194,
|
|
1030
|
+
190,
|
|
1031
|
+
196,
|
|
1032
|
+
70
|
|
1033
|
+
]),
|
|
1034
|
+
// SHA256("global:set_migrator_allowlist")[0:8]
|
|
1035
|
+
setMigratorAllowlist: new Uint8Array([
|
|
1036
|
+
209,
|
|
1037
|
+
90,
|
|
1038
|
+
181,
|
|
1039
|
+
104,
|
|
1040
|
+
99,
|
|
1041
|
+
108,
|
|
1042
|
+
233,
|
|
1043
|
+
168
|
|
1044
|
+
]),
|
|
1045
|
+
// SHA256("global:set_sentinel_allowlist")[0:8]
|
|
1046
|
+
setSentinelAllowlist: new Uint8Array([
|
|
1047
|
+
233,
|
|
1048
|
+
72,
|
|
1049
|
+
180,
|
|
1050
|
+
246,
|
|
1051
|
+
171,
|
|
1052
|
+
117,
|
|
1053
|
+
21,
|
|
1054
|
+
50
|
|
1055
|
+
]),
|
|
1056
|
+
// SHA256("global:initialize_launch")[0:8]
|
|
1057
|
+
initializeLaunch: new Uint8Array([
|
|
1058
|
+
90,
|
|
1059
|
+
201,
|
|
1060
|
+
220,
|
|
1061
|
+
142,
|
|
1062
|
+
112,
|
|
1063
|
+
253,
|
|
1064
|
+
100,
|
|
1065
|
+
13
|
|
1066
|
+
]),
|
|
1067
|
+
// SHA256("global:curve_swap_exact_in")[0:8]
|
|
1068
|
+
curveSwapExactIn: new Uint8Array([
|
|
1069
|
+
196,
|
|
1070
|
+
247,
|
|
1071
|
+
195,
|
|
1072
|
+
126,
|
|
1073
|
+
227,
|
|
1074
|
+
27,
|
|
1075
|
+
166,
|
|
1076
|
+
93
|
|
1077
|
+
]),
|
|
1078
|
+
// SHA256("global:migrate_launch")[0:8]
|
|
1079
|
+
migrateLaunch: new Uint8Array([
|
|
1080
|
+
19,
|
|
1081
|
+
199,
|
|
1082
|
+
119,
|
|
1083
|
+
103,
|
|
1084
|
+
13,
|
|
1085
|
+
30,
|
|
1086
|
+
12,
|
|
1087
|
+
205
|
|
1088
|
+
]),
|
|
1089
|
+
// SHA256("global:abort_launch")[0:8]
|
|
1090
|
+
abortLaunch: new Uint8Array([44, 112, 192, 235, 227, 61, 179, 7]),
|
|
1091
|
+
// SHA256("global:preview_swap_exact_in")[0:8]
|
|
1092
|
+
previewSwapExactIn: new Uint8Array([
|
|
1093
|
+
50,
|
|
1094
|
+
130,
|
|
1095
|
+
31,
|
|
1096
|
+
69,
|
|
1097
|
+
147,
|
|
1098
|
+
58,
|
|
1099
|
+
222,
|
|
1100
|
+
178
|
|
1101
|
+
]),
|
|
1102
|
+
// SHA256("global:preview_migration")[0:8]
|
|
1103
|
+
previewMigration: new Uint8Array([
|
|
1104
|
+
216,
|
|
1105
|
+
180,
|
|
1106
|
+
209,
|
|
1107
|
+
112,
|
|
1108
|
+
62,
|
|
1109
|
+
16,
|
|
1110
|
+
15,
|
|
1111
|
+
63
|
|
1112
|
+
])
|
|
1113
|
+
};
|
|
1114
|
+
var INITIALIZER_ACCOUNT_DISCRIMINATORS = {
|
|
1115
|
+
// SHA256("account:InitConfig")[0:8]
|
|
1116
|
+
InitConfig: new Uint8Array([97, 166, 35, 7, 20, 2, 164, 126]),
|
|
1117
|
+
// SHA256("account:Launch")[0:8]
|
|
1118
|
+
Launch: new Uint8Array([144, 51, 51, 163, 206, 85, 213, 38])
|
|
1119
|
+
};
|
|
1120
|
+
var INIT_CONFIG_DISCRIMINATOR = new Uint8Array([
|
|
1121
|
+
97,
|
|
1122
|
+
166,
|
|
1123
|
+
35,
|
|
1124
|
+
7,
|
|
1125
|
+
20,
|
|
1126
|
+
2,
|
|
1127
|
+
164,
|
|
1128
|
+
126
|
|
1129
|
+
]);
|
|
1130
|
+
function getInitConfigEncoder() {
|
|
1131
|
+
return transformEncoder(
|
|
1132
|
+
getStructEncoder([
|
|
1133
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
1134
|
+
["admin", getAddressEncoder()],
|
|
1135
|
+
["migratorAllowlistLen", getU8Encoder()],
|
|
1136
|
+
["migratorAllowlist", getArrayEncoder(getAddressEncoder(), { size: 32 })],
|
|
1137
|
+
["sentinelAllowlistLen", getU8Encoder()],
|
|
1138
|
+
["sentinelAllowlist", getArrayEncoder(getAddressEncoder(), { size: 32 })],
|
|
1139
|
+
["bump", getU8Encoder()],
|
|
1140
|
+
["version", getU8Encoder()],
|
|
1141
|
+
["reserved", fixEncoderSize(getBytesEncoder(), 31)]
|
|
1142
|
+
]),
|
|
1143
|
+
(value) => ({ ...value, discriminator: INIT_CONFIG_DISCRIMINATOR })
|
|
1144
|
+
);
|
|
1145
|
+
}
|
|
1146
|
+
function getInitConfigDecoder() {
|
|
1147
|
+
return getStructDecoder([
|
|
1148
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
1149
|
+
["admin", getAddressDecoder()],
|
|
1150
|
+
["migratorAllowlistLen", getU8Decoder()],
|
|
1151
|
+
["migratorAllowlist", getArrayDecoder(getAddressDecoder(), { size: 32 })],
|
|
1152
|
+
["sentinelAllowlistLen", getU8Decoder()],
|
|
1153
|
+
["sentinelAllowlist", getArrayDecoder(getAddressDecoder(), { size: 32 })],
|
|
1154
|
+
["bump", getU8Decoder()],
|
|
1155
|
+
["version", getU8Decoder()],
|
|
1156
|
+
["reserved", fixDecoderSize(getBytesDecoder(), 31)]
|
|
1157
|
+
]);
|
|
1158
|
+
}
|
|
1159
|
+
function getInitConfigCodec() {
|
|
1160
|
+
return combineCodec(getInitConfigEncoder(), getInitConfigDecoder());
|
|
1161
|
+
}
|
|
1162
|
+
function getCalldataBufEncoder() {
|
|
1163
|
+
return getStructEncoder([
|
|
1164
|
+
["len", getU16Encoder()],
|
|
1165
|
+
["bytes", fixEncoderSize(getBytesEncoder(), 256)]
|
|
1166
|
+
]);
|
|
1167
|
+
}
|
|
1168
|
+
function getCalldataBufDecoder() {
|
|
1169
|
+
return getStructDecoder([
|
|
1170
|
+
["len", getU16Decoder()],
|
|
1171
|
+
["bytes", fixDecoderSize(getBytesDecoder(), 256)]
|
|
1172
|
+
]);
|
|
1173
|
+
}
|
|
1174
|
+
function getInitializeConfigArgsEncoder() {
|
|
1175
|
+
return getStructEncoder([
|
|
1176
|
+
["migratorAllowlist", getArrayEncoder(getAddressEncoder())],
|
|
1177
|
+
["sentinelAllowlist", getArrayEncoder(getAddressEncoder())]
|
|
1178
|
+
]);
|
|
1179
|
+
}
|
|
1180
|
+
function getInitializeConfigArgsDecoder() {
|
|
1181
|
+
return getStructDecoder([
|
|
1182
|
+
["migratorAllowlist", getArrayDecoder(getAddressDecoder())],
|
|
1183
|
+
["sentinelAllowlist", getArrayDecoder(getAddressDecoder())]
|
|
1184
|
+
]);
|
|
1185
|
+
}
|
|
1186
|
+
function getInitializeConfigArgsCodec() {
|
|
1187
|
+
return combineCodec(
|
|
1188
|
+
getInitializeConfigArgsEncoder(),
|
|
1189
|
+
getInitializeConfigArgsDecoder()
|
|
1190
|
+
);
|
|
1191
|
+
}
|
|
1192
|
+
function getInitializeLaunchArgsEncoder() {
|
|
1193
|
+
return getStructEncoder([
|
|
1194
|
+
["namespace", getAddressEncoder()],
|
|
1195
|
+
["launchId", fixEncoderSize(getBytesEncoder(), 32)],
|
|
1196
|
+
["baseDecimals", getU8Encoder()],
|
|
1197
|
+
["baseTotalSupply", getU64Encoder()],
|
|
1198
|
+
["baseForDistribution", getU64Encoder()],
|
|
1199
|
+
["baseForLiquidity", getU64Encoder()],
|
|
1200
|
+
["curveVirtualBase", getU64Encoder()],
|
|
1201
|
+
["curveVirtualQuote", getU64Encoder()],
|
|
1202
|
+
["curveFeeBps", getU16Encoder()],
|
|
1203
|
+
["curveKind", getU8Encoder()],
|
|
1204
|
+
["curveParams", addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())],
|
|
1205
|
+
["allowBuy", getU8Encoder()],
|
|
1206
|
+
["allowSell", getU8Encoder()],
|
|
1207
|
+
["sentinelProgram", getAddressEncoder()],
|
|
1208
|
+
["sentinelFlags", getU32Encoder()],
|
|
1209
|
+
[
|
|
1210
|
+
"sentinelCalldata",
|
|
1211
|
+
addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())
|
|
1212
|
+
],
|
|
1213
|
+
["migratorProgram", getAddressEncoder()],
|
|
1214
|
+
[
|
|
1215
|
+
"migratorInitCalldata",
|
|
1216
|
+
addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())
|
|
1217
|
+
],
|
|
1218
|
+
[
|
|
1219
|
+
"migratorMigrateCalldata",
|
|
1220
|
+
addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())
|
|
1221
|
+
],
|
|
1222
|
+
["sentinelRemainingAccountsHash", fixEncoderSize(getBytesEncoder(), 32)],
|
|
1223
|
+
["migratorRemainingAccountsHash", fixEncoderSize(getBytesEncoder(), 32)],
|
|
1224
|
+
["metadataName", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
|
|
1225
|
+
["metadataSymbol", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
|
|
1226
|
+
["metadataUri", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())]
|
|
1227
|
+
]);
|
|
1228
|
+
}
|
|
1229
|
+
function getInitializeLaunchArgsDecoder() {
|
|
1230
|
+
return getStructDecoder([
|
|
1231
|
+
["namespace", getAddressDecoder()],
|
|
1232
|
+
["launchId", fixDecoderSize(getBytesDecoder(), 32)],
|
|
1233
|
+
["baseDecimals", getU8Decoder()],
|
|
1234
|
+
["baseTotalSupply", getU64Decoder()],
|
|
1235
|
+
["baseForDistribution", getU64Decoder()],
|
|
1236
|
+
["baseForLiquidity", getU64Decoder()],
|
|
1237
|
+
["curveVirtualBase", getU64Decoder()],
|
|
1238
|
+
["curveVirtualQuote", getU64Decoder()],
|
|
1239
|
+
["curveFeeBps", getU16Decoder()],
|
|
1240
|
+
["curveKind", getU8Decoder()],
|
|
1241
|
+
["curveParams", addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())],
|
|
1242
|
+
["allowBuy", getU8Decoder()],
|
|
1243
|
+
["allowSell", getU8Decoder()],
|
|
1244
|
+
["sentinelProgram", getAddressDecoder()],
|
|
1245
|
+
["sentinelFlags", getU32Decoder()],
|
|
1246
|
+
[
|
|
1247
|
+
"sentinelCalldata",
|
|
1248
|
+
addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())
|
|
1249
|
+
],
|
|
1250
|
+
["migratorProgram", getAddressDecoder()],
|
|
1251
|
+
[
|
|
1252
|
+
"migratorInitCalldata",
|
|
1253
|
+
addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())
|
|
1254
|
+
],
|
|
1255
|
+
[
|
|
1256
|
+
"migratorMigrateCalldata",
|
|
1257
|
+
addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())
|
|
1258
|
+
],
|
|
1259
|
+
["sentinelRemainingAccountsHash", fixDecoderSize(getBytesDecoder(), 32)],
|
|
1260
|
+
["migratorRemainingAccountsHash", fixDecoderSize(getBytesDecoder(), 32)],
|
|
1261
|
+
["metadataName", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
1262
|
+
["metadataSymbol", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
1263
|
+
["metadataUri", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())]
|
|
1264
|
+
]);
|
|
1265
|
+
}
|
|
1266
|
+
function getInitializeLaunchArgsCodec() {
|
|
1267
|
+
return combineCodec(
|
|
1268
|
+
getInitializeLaunchArgsEncoder(),
|
|
1269
|
+
getInitializeLaunchArgsDecoder()
|
|
1270
|
+
);
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
// src/solana/generated/initializer/accounts/launch.ts
|
|
1274
|
+
var LAUNCH_DISCRIMINATOR = new Uint8Array([
|
|
1275
|
+
144,
|
|
1276
|
+
51,
|
|
1277
|
+
51,
|
|
1278
|
+
163,
|
|
1279
|
+
206,
|
|
1280
|
+
85,
|
|
1281
|
+
213,
|
|
1282
|
+
38
|
|
1283
|
+
]);
|
|
1284
|
+
function getLaunchEncoder() {
|
|
1285
|
+
return transformEncoder(
|
|
1286
|
+
getStructEncoder([
|
|
1287
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
1288
|
+
["authority", getAddressEncoder()],
|
|
1289
|
+
["namespace", getAddressEncoder()],
|
|
1290
|
+
["launchId", fixEncoderSize(getBytesEncoder(), 32)],
|
|
1291
|
+
["phase", getU8Encoder()],
|
|
1292
|
+
["bump", getU8Encoder()],
|
|
1293
|
+
["launchAuthorityBump", getU8Encoder()],
|
|
1294
|
+
["pad0", fixEncoderSize(getBytesEncoder(), 5)],
|
|
1295
|
+
["baseMint", getAddressEncoder()],
|
|
1296
|
+
["quoteMint", getAddressEncoder()],
|
|
1297
|
+
["baseVault", getAddressEncoder()],
|
|
1298
|
+
["quoteVault", getAddressEncoder()],
|
|
1299
|
+
["baseTotalSupply", getU64Encoder()],
|
|
1300
|
+
["baseForDistribution", getU64Encoder()],
|
|
1301
|
+
["baseForLiquidity", getU64Encoder()],
|
|
1302
|
+
["baseForCurve", getU64Encoder()],
|
|
1303
|
+
["curveVirtualBase", getU64Encoder()],
|
|
1304
|
+
["curveVirtualQuote", getU64Encoder()],
|
|
1305
|
+
["curveFeeBps", getU16Encoder()],
|
|
1306
|
+
["pad1", fixEncoderSize(getBytesEncoder(), 6)],
|
|
1307
|
+
["allowBuy", getU8Encoder()],
|
|
1308
|
+
["allowSell", getU8Encoder()],
|
|
1309
|
+
["pad2", fixEncoderSize(getBytesEncoder(), 6)],
|
|
1310
|
+
["sentinelProgram", getAddressEncoder()],
|
|
1311
|
+
["sentinelFlags", getU32Encoder()],
|
|
1312
|
+
["pad3", fixEncoderSize(getBytesEncoder(), 4)],
|
|
1313
|
+
["sentinelCalldata", getCalldataBufEncoder()],
|
|
1314
|
+
["migratorProgram", getAddressEncoder()],
|
|
1315
|
+
["migratorInitCalldata", getCalldataBufEncoder()],
|
|
1316
|
+
["migratorMigrateCalldata", getCalldataBufEncoder()],
|
|
1317
|
+
["curveKind", getU8Encoder()],
|
|
1318
|
+
["swapLock", getU8Encoder()],
|
|
1319
|
+
["pad4", fixEncoderSize(getBytesEncoder(), 6)],
|
|
1320
|
+
["curveParams", getCalldataBufEncoder()],
|
|
1321
|
+
["quoteDeposited", getU64Encoder()],
|
|
1322
|
+
["reserved", fixEncoderSize(getBytesEncoder(), 64)]
|
|
1323
|
+
]),
|
|
1324
|
+
(value) => ({ ...value, discriminator: LAUNCH_DISCRIMINATOR })
|
|
1325
|
+
);
|
|
1326
|
+
}
|
|
1327
|
+
function getLaunchDecoder() {
|
|
1328
|
+
return getStructDecoder([
|
|
1329
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
1330
|
+
["authority", getAddressDecoder()],
|
|
1331
|
+
["namespace", getAddressDecoder()],
|
|
1332
|
+
["launchId", fixDecoderSize(getBytesDecoder(), 32)],
|
|
1333
|
+
["phase", getU8Decoder()],
|
|
1334
|
+
["bump", getU8Decoder()],
|
|
1335
|
+
["launchAuthorityBump", getU8Decoder()],
|
|
1336
|
+
["pad0", fixDecoderSize(getBytesDecoder(), 5)],
|
|
1337
|
+
["baseMint", getAddressDecoder()],
|
|
1338
|
+
["quoteMint", getAddressDecoder()],
|
|
1339
|
+
["baseVault", getAddressDecoder()],
|
|
1340
|
+
["quoteVault", getAddressDecoder()],
|
|
1341
|
+
["baseTotalSupply", getU64Decoder()],
|
|
1342
|
+
["baseForDistribution", getU64Decoder()],
|
|
1343
|
+
["baseForLiquidity", getU64Decoder()],
|
|
1344
|
+
["baseForCurve", getU64Decoder()],
|
|
1345
|
+
["curveVirtualBase", getU64Decoder()],
|
|
1346
|
+
["curveVirtualQuote", getU64Decoder()],
|
|
1347
|
+
["curveFeeBps", getU16Decoder()],
|
|
1348
|
+
["pad1", fixDecoderSize(getBytesDecoder(), 6)],
|
|
1349
|
+
["allowBuy", getU8Decoder()],
|
|
1350
|
+
["allowSell", getU8Decoder()],
|
|
1351
|
+
["pad2", fixDecoderSize(getBytesDecoder(), 6)],
|
|
1352
|
+
["sentinelProgram", getAddressDecoder()],
|
|
1353
|
+
["sentinelFlags", getU32Decoder()],
|
|
1354
|
+
["pad3", fixDecoderSize(getBytesDecoder(), 4)],
|
|
1355
|
+
["sentinelCalldata", getCalldataBufDecoder()],
|
|
1356
|
+
["migratorProgram", getAddressDecoder()],
|
|
1357
|
+
["migratorInitCalldata", getCalldataBufDecoder()],
|
|
1358
|
+
["migratorMigrateCalldata", getCalldataBufDecoder()],
|
|
1359
|
+
["curveKind", getU8Decoder()],
|
|
1360
|
+
["swapLock", getU8Decoder()],
|
|
1361
|
+
["pad4", fixDecoderSize(getBytesDecoder(), 6)],
|
|
1362
|
+
["curveParams", getCalldataBufDecoder()],
|
|
1363
|
+
["quoteDeposited", getU64Decoder()],
|
|
1364
|
+
["reserved", fixDecoderSize(getBytesDecoder(), 64)]
|
|
1365
|
+
]);
|
|
1366
|
+
}
|
|
1367
|
+
function getLaunchCodec() {
|
|
1368
|
+
return combineCodec(getLaunchEncoder(), getLaunchDecoder());
|
|
1369
|
+
}
|
|
1370
|
+
var CURVE_SWAP_EXACT_IN_DISCRIMINATOR = new Uint8Array([
|
|
1371
|
+
196,
|
|
1372
|
+
247,
|
|
1373
|
+
195,
|
|
1374
|
+
126,
|
|
1375
|
+
227,
|
|
1376
|
+
27,
|
|
1377
|
+
166,
|
|
1378
|
+
93
|
|
1379
|
+
]);
|
|
1380
|
+
function getCurveSwapExactInInstructionDataEncoder() {
|
|
1381
|
+
return transformEncoder(
|
|
1382
|
+
getStructEncoder([
|
|
1383
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
1384
|
+
["amountIn", getU64Encoder()],
|
|
1385
|
+
["minAmountOut", getU64Encoder()],
|
|
1386
|
+
["direction", getU8Encoder()]
|
|
1387
|
+
]),
|
|
1388
|
+
(value) => ({ ...value, discriminator: CURVE_SWAP_EXACT_IN_DISCRIMINATOR })
|
|
1389
|
+
);
|
|
1390
|
+
}
|
|
1391
|
+
var INITIALIZE_CONFIG_DISCRIMINATOR = new Uint8Array([
|
|
1392
|
+
208,
|
|
1393
|
+
127,
|
|
1394
|
+
21,
|
|
1395
|
+
1,
|
|
1396
|
+
194,
|
|
1397
|
+
190,
|
|
1398
|
+
196,
|
|
1399
|
+
70
|
|
1400
|
+
]);
|
|
1401
|
+
function getInitializeConfigInstructionDataEncoder() {
|
|
1402
|
+
return transformEncoder(
|
|
1403
|
+
getStructEncoder([
|
|
1404
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
1405
|
+
["migratorAllowlist", getArrayEncoder(getAddressEncoder())],
|
|
1406
|
+
["sentinelAllowlist", getArrayEncoder(getAddressEncoder())]
|
|
1407
|
+
]),
|
|
1408
|
+
(value) => ({ ...value, discriminator: INITIALIZE_CONFIG_DISCRIMINATOR })
|
|
1409
|
+
);
|
|
1410
|
+
}
|
|
1411
|
+
var INITIALIZE_LAUNCH_DISCRIMINATOR = new Uint8Array([
|
|
1412
|
+
90,
|
|
1413
|
+
201,
|
|
1414
|
+
220,
|
|
1415
|
+
142,
|
|
1416
|
+
112,
|
|
1417
|
+
253,
|
|
1418
|
+
100,
|
|
1419
|
+
13
|
|
1420
|
+
]);
|
|
1421
|
+
function getInitializeLaunchInstructionDataEncoder() {
|
|
1422
|
+
return transformEncoder(
|
|
1423
|
+
getStructEncoder([
|
|
1424
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
1425
|
+
["namespace", getAddressEncoder()],
|
|
1426
|
+
["launchId", fixEncoderSize(getBytesEncoder(), 32)],
|
|
1427
|
+
["baseDecimals", getU8Encoder()],
|
|
1428
|
+
["baseTotalSupply", getU64Encoder()],
|
|
1429
|
+
["baseForDistribution", getU64Encoder()],
|
|
1430
|
+
["baseForLiquidity", getU64Encoder()],
|
|
1431
|
+
["curveVirtualBase", getU64Encoder()],
|
|
1432
|
+
["curveVirtualQuote", getU64Encoder()],
|
|
1433
|
+
["curveFeeBps", getU16Encoder()],
|
|
1434
|
+
["curveKind", getU8Encoder()],
|
|
1435
|
+
["curveParams", addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())],
|
|
1436
|
+
["allowBuy", getU8Encoder()],
|
|
1437
|
+
["allowSell", getU8Encoder()],
|
|
1438
|
+
["sentinelProgram", getAddressEncoder()],
|
|
1439
|
+
["sentinelFlags", getU32Encoder()],
|
|
1440
|
+
[
|
|
1441
|
+
"sentinelCalldata",
|
|
1442
|
+
addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())
|
|
1443
|
+
],
|
|
1444
|
+
["migratorProgram", getAddressEncoder()],
|
|
1445
|
+
[
|
|
1446
|
+
"migratorInitCalldata",
|
|
1447
|
+
addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())
|
|
1448
|
+
],
|
|
1449
|
+
[
|
|
1450
|
+
"migratorMigrateCalldata",
|
|
1451
|
+
addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())
|
|
1452
|
+
],
|
|
1453
|
+
["sentinelRemainingAccountsHash", fixEncoderSize(getBytesEncoder(), 32)],
|
|
1454
|
+
["migratorRemainingAccountsHash", fixEncoderSize(getBytesEncoder(), 32)],
|
|
1455
|
+
["metadataName", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
|
|
1456
|
+
[
|
|
1457
|
+
"metadataSymbol",
|
|
1458
|
+
addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())
|
|
1459
|
+
],
|
|
1460
|
+
["metadataUri", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())]
|
|
1461
|
+
]),
|
|
1462
|
+
(value) => ({ ...value, discriminator: INITIALIZE_LAUNCH_DISCRIMINATOR })
|
|
1463
|
+
);
|
|
1464
|
+
}
|
|
1465
|
+
var PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR = new Uint8Array([
|
|
1466
|
+
50,
|
|
1467
|
+
130,
|
|
1468
|
+
31,
|
|
1469
|
+
69,
|
|
1470
|
+
147,
|
|
1471
|
+
58,
|
|
1472
|
+
222,
|
|
1473
|
+
178
|
|
1474
|
+
]);
|
|
1475
|
+
function getPreviewSwapExactInInstructionDataEncoder() {
|
|
1476
|
+
return transformEncoder(
|
|
1477
|
+
getStructEncoder([
|
|
1478
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
1479
|
+
["amountIn", getU64Encoder()],
|
|
1480
|
+
["direction", getU8Encoder()]
|
|
1481
|
+
]),
|
|
1482
|
+
(value) => ({
|
|
1483
|
+
...value,
|
|
1484
|
+
discriminator: PREVIEW_SWAP_EXACT_IN_DISCRIMINATOR
|
|
1485
|
+
})
|
|
1486
|
+
);
|
|
1487
|
+
}
|
|
1488
|
+
var SET_MIGRATOR_ALLOWLIST_DISCRIMINATOR = new Uint8Array([
|
|
1489
|
+
209,
|
|
1490
|
+
90,
|
|
1491
|
+
181,
|
|
1492
|
+
104,
|
|
1493
|
+
99,
|
|
1494
|
+
108,
|
|
1495
|
+
233,
|
|
1496
|
+
168
|
|
1497
|
+
]);
|
|
1498
|
+
function getSetMigratorAllowlistInstructionDataEncoder() {
|
|
1499
|
+
return transformEncoder(
|
|
1500
|
+
getStructEncoder([
|
|
1501
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
1502
|
+
["allowlist", getArrayEncoder(getAddressEncoder())]
|
|
1503
|
+
]),
|
|
1504
|
+
(value) => ({
|
|
1505
|
+
...value,
|
|
1506
|
+
discriminator: SET_MIGRATOR_ALLOWLIST_DISCRIMINATOR
|
|
1507
|
+
})
|
|
1508
|
+
);
|
|
1509
|
+
}
|
|
1510
|
+
var SET_SENTINEL_ALLOWLIST_DISCRIMINATOR = new Uint8Array([
|
|
1511
|
+
233,
|
|
1512
|
+
72,
|
|
1513
|
+
180,
|
|
1514
|
+
246,
|
|
1515
|
+
171,
|
|
1516
|
+
117,
|
|
1517
|
+
21,
|
|
1518
|
+
50
|
|
1519
|
+
]);
|
|
1520
|
+
function getSetSentinelAllowlistInstructionDataEncoder() {
|
|
1521
|
+
return transformEncoder(
|
|
1522
|
+
getStructEncoder([
|
|
1523
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
1524
|
+
["allowlist", getArrayEncoder(getAddressEncoder())]
|
|
1525
|
+
]),
|
|
1526
|
+
(value) => ({
|
|
1527
|
+
...value,
|
|
1528
|
+
discriminator: SET_SENTINEL_ALLOWLIST_DISCRIMINATOR
|
|
1529
|
+
})
|
|
1530
|
+
);
|
|
1531
|
+
}
|
|
1532
|
+
if (process.env.NODE_ENV !== "production") ;
|
|
1533
|
+
var addressCodec2 = getAddressCodec();
|
|
1534
|
+
var textEncoder2 = new TextEncoder();
|
|
1535
|
+
function encodeU64LE(value) {
|
|
1536
|
+
const bytes = new Uint8Array(8);
|
|
1537
|
+
const view = new DataView(bytes.buffer);
|
|
1538
|
+
view.setBigUint64(0, value, true);
|
|
1539
|
+
return bytes;
|
|
1540
|
+
}
|
|
1541
|
+
async function getConfigAddress2(programId = INITIALIZER_PROGRAM_ID) {
|
|
1542
|
+
return getProgramDerivedAddress({
|
|
1543
|
+
programAddress: programId,
|
|
1544
|
+
seeds: [textEncoder2.encode(SEED_CONFIG2)]
|
|
1545
|
+
});
|
|
1546
|
+
}
|
|
1547
|
+
async function getProgramDataAddress(programId = INITIALIZER_PROGRAM_ID) {
|
|
1548
|
+
return getProgramDerivedAddress({
|
|
1549
|
+
programAddress: BPF_LOADER_UPGRADEABLE_PROGRAM_ID,
|
|
1550
|
+
seeds: [addressCodec2.encode(programId)]
|
|
1551
|
+
});
|
|
1552
|
+
}
|
|
1553
|
+
async function getLaunchAddress(namespace, launchId, programId = INITIALIZER_PROGRAM_ID) {
|
|
1554
|
+
if (launchId.length !== 32) {
|
|
1555
|
+
throw new Error("launchId must be 32 bytes");
|
|
1556
|
+
}
|
|
1557
|
+
return getProgramDerivedAddress({
|
|
1558
|
+
programAddress: programId,
|
|
1559
|
+
seeds: [
|
|
1560
|
+
textEncoder2.encode(SEED_LAUNCH),
|
|
1561
|
+
addressCodec2.encode(namespace),
|
|
1562
|
+
launchId
|
|
1563
|
+
]
|
|
1564
|
+
});
|
|
1565
|
+
}
|
|
1566
|
+
async function getLaunchAuthorityAddress(launch, programId = INITIALIZER_PROGRAM_ID) {
|
|
1567
|
+
return getProgramDerivedAddress({
|
|
1568
|
+
programAddress: programId,
|
|
1569
|
+
seeds: [
|
|
1570
|
+
textEncoder2.encode(SEED_LAUNCH_AUTHORITY),
|
|
1571
|
+
addressCodec2.encode(launch)
|
|
1572
|
+
]
|
|
1573
|
+
});
|
|
1574
|
+
}
|
|
1575
|
+
function launchIdFromU64(launchId) {
|
|
1576
|
+
const out = new Uint8Array(32);
|
|
1577
|
+
out.set(encodeU64LE(launchId), 0);
|
|
1578
|
+
return out;
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
// src/solana/initializer/instructions/initializeConfig.ts
|
|
1582
|
+
function isTransactionSigner2(value) {
|
|
1583
|
+
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
1584
|
+
}
|
|
1585
|
+
function createSignerAccountMeta2(value, role) {
|
|
1586
|
+
if (isTransactionSigner2(value)) {
|
|
1587
|
+
return { address: value.address, role, signer: value };
|
|
1588
|
+
}
|
|
1589
|
+
return { address: value, role };
|
|
1590
|
+
}
|
|
1591
|
+
function createInitializeConfigInstruction2(accounts, args, programId = INITIALIZER_PROGRAM_ID) {
|
|
1592
|
+
const {
|
|
1593
|
+
admin,
|
|
1594
|
+
config,
|
|
1595
|
+
programData,
|
|
1596
|
+
systemProgram = SYSTEM_PROGRAM_ID
|
|
1597
|
+
} = accounts;
|
|
1598
|
+
const keys = [
|
|
1599
|
+
createSignerAccountMeta2(admin, ACCOUNT_ROLE_WRITABLE_SIGNER),
|
|
1600
|
+
{ address: config, role: ACCOUNT_ROLE_WRITABLE },
|
|
1601
|
+
{ address: programData, role: ACCOUNT_ROLE_READONLY },
|
|
1602
|
+
{ address: systemProgram, role: ACCOUNT_ROLE_READONLY }
|
|
1603
|
+
];
|
|
1604
|
+
const data = new Uint8Array(
|
|
1605
|
+
getInitializeConfigInstructionDataEncoder().encode(args)
|
|
1606
|
+
);
|
|
1607
|
+
return { programAddress: programId, accounts: keys, data };
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
// src/solana/initializer/instructions/setMigratorAllowlist.ts
|
|
1611
|
+
function isTransactionSigner3(value) {
|
|
1612
|
+
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
1613
|
+
}
|
|
1614
|
+
function createSignerAccountMeta3(value, role) {
|
|
1615
|
+
if (isTransactionSigner3(value)) {
|
|
1616
|
+
return { address: value.address, role, signer: value };
|
|
1617
|
+
}
|
|
1618
|
+
return { address: value, role };
|
|
1619
|
+
}
|
|
1620
|
+
function createSetMigratorAllowlistInstruction(accounts, allowlist, programId = INITIALIZER_PROGRAM_ID) {
|
|
1621
|
+
const { admin, config } = accounts;
|
|
1622
|
+
const keys = [
|
|
1623
|
+
createSignerAccountMeta3(admin, ACCOUNT_ROLE_WRITABLE_SIGNER),
|
|
1624
|
+
{ address: config, role: ACCOUNT_ROLE_WRITABLE }
|
|
1625
|
+
];
|
|
1626
|
+
const data = new Uint8Array(
|
|
1627
|
+
getSetMigratorAllowlistInstructionDataEncoder().encode({ allowlist })
|
|
1628
|
+
);
|
|
1629
|
+
return { programAddress: programId, accounts: keys, data };
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1632
|
+
// src/solana/initializer/instructions/setSentinelAllowlist.ts
|
|
1633
|
+
function isTransactionSigner4(value) {
|
|
1634
|
+
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
1635
|
+
}
|
|
1636
|
+
function createSignerAccountMeta4(value, role) {
|
|
1637
|
+
if (isTransactionSigner4(value)) {
|
|
1638
|
+
return { address: value.address, role, signer: value };
|
|
1639
|
+
}
|
|
1640
|
+
return { address: value, role };
|
|
1641
|
+
}
|
|
1642
|
+
function createSetSentinelAllowlistInstruction(accounts, allowlist, programId = INITIALIZER_PROGRAM_ID) {
|
|
1643
|
+
const { admin, config } = accounts;
|
|
1644
|
+
const keys = [
|
|
1645
|
+
createSignerAccountMeta4(admin, ACCOUNT_ROLE_WRITABLE_SIGNER),
|
|
1646
|
+
{ address: config, role: ACCOUNT_ROLE_WRITABLE }
|
|
1647
|
+
];
|
|
1648
|
+
const data = new Uint8Array(
|
|
1649
|
+
getSetSentinelAllowlistInstructionDataEncoder().encode({ allowlist })
|
|
1650
|
+
);
|
|
1651
|
+
return { programAddress: programId, accounts: keys, data };
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
// src/solana/initializer/instructions/initializeLaunch.ts
|
|
1655
|
+
function isTransactionSigner5(value) {
|
|
1656
|
+
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
1657
|
+
}
|
|
1658
|
+
function createAccountMeta(value, role) {
|
|
1659
|
+
if (isTransactionSigner5(value)) {
|
|
1660
|
+
return { address: value.address, role, signer: value };
|
|
1661
|
+
}
|
|
1662
|
+
return { address: value, role };
|
|
1663
|
+
}
|
|
1664
|
+
function validateInitializeLaunchCurveParams(args) {
|
|
1665
|
+
if (args.curveKind !== CURVE_KIND_XYK) {
|
|
1666
|
+
throw new Error(
|
|
1667
|
+
`unsupported curve kind: ${args.curveKind}; only CURVE_KIND_XYK is currently enabled`
|
|
1668
|
+
);
|
|
1669
|
+
}
|
|
1670
|
+
if (args.curveParams.length !== 1 || args.curveParams[0] !== CURVE_PARAMS_FORMAT_XYK_V0) {
|
|
1671
|
+
throw new Error("xyk curve params must be [CURVE_PARAMS_FORMAT_XYK_V0]");
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
function createInitializeLaunchInstruction(accounts, args, programId = INITIALIZER_PROGRAM_ID) {
|
|
1675
|
+
validateInitializeLaunchCurveParams(args);
|
|
1676
|
+
const {
|
|
1677
|
+
config,
|
|
1678
|
+
launch,
|
|
1679
|
+
launchAuthority,
|
|
1680
|
+
baseMint,
|
|
1681
|
+
quoteMint,
|
|
1682
|
+
baseVault,
|
|
1683
|
+
quoteVault,
|
|
1684
|
+
payer,
|
|
1685
|
+
authority,
|
|
1686
|
+
migratorProgram,
|
|
1687
|
+
tokenProgram = TOKEN_PROGRAM_ID,
|
|
1688
|
+
systemProgram = SYSTEM_PROGRAM_ID,
|
|
1689
|
+
rent
|
|
1690
|
+
} = accounts;
|
|
1691
|
+
const keys = [
|
|
1692
|
+
{ address: config, role: ACCOUNT_ROLE_READONLY },
|
|
1693
|
+
{ address: launch, role: ACCOUNT_ROLE_WRITABLE },
|
|
1694
|
+
{ address: launchAuthority, role: ACCOUNT_ROLE_READONLY },
|
|
1695
|
+
createAccountMeta(baseMint, ACCOUNT_ROLE_WRITABLE_SIGNER),
|
|
1696
|
+
{ address: quoteMint, role: ACCOUNT_ROLE_READONLY },
|
|
1697
|
+
createAccountMeta(baseVault, ACCOUNT_ROLE_WRITABLE_SIGNER),
|
|
1698
|
+
createAccountMeta(quoteVault, ACCOUNT_ROLE_WRITABLE_SIGNER),
|
|
1699
|
+
createAccountMeta(payer, ACCOUNT_ROLE_WRITABLE_SIGNER)
|
|
1700
|
+
];
|
|
1701
|
+
if (authority) {
|
|
1702
|
+
keys.push(createAccountMeta(authority, ACCOUNT_ROLE_SIGNER));
|
|
1703
|
+
}
|
|
1704
|
+
if (migratorProgram) {
|
|
1705
|
+
keys.push({ address: migratorProgram, role: ACCOUNT_ROLE_READONLY });
|
|
1706
|
+
}
|
|
1707
|
+
keys.push({ address: tokenProgram, role: ACCOUNT_ROLE_READONLY });
|
|
1708
|
+
keys.push({ address: systemProgram, role: ACCOUNT_ROLE_READONLY });
|
|
1709
|
+
keys.push({ address: rent, role: ACCOUNT_ROLE_READONLY });
|
|
1710
|
+
const data = new Uint8Array(
|
|
1711
|
+
getInitializeLaunchInstructionDataEncoder().encode(args)
|
|
1712
|
+
);
|
|
1713
|
+
return {
|
|
1714
|
+
programAddress: programId,
|
|
1715
|
+
accounts: keys,
|
|
1716
|
+
data
|
|
1717
|
+
};
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
// src/solana/initializer/instructions/curveSwapExactIn.ts
|
|
1721
|
+
function isTransactionSigner6(value) {
|
|
1722
|
+
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
1723
|
+
}
|
|
1724
|
+
function createAccountMeta2(value, role) {
|
|
1725
|
+
if (isTransactionSigner6(value)) {
|
|
1726
|
+
return { address: value.address, role, signer: value };
|
|
1727
|
+
}
|
|
1728
|
+
return { address: value, role };
|
|
1729
|
+
}
|
|
1730
|
+
function createCurveSwapExactInInstruction(accounts, args, programId = INITIALIZER_PROGRAM_ID) {
|
|
1731
|
+
const {
|
|
1732
|
+
config,
|
|
1733
|
+
launch,
|
|
1734
|
+
launchAuthority,
|
|
1735
|
+
baseVault,
|
|
1736
|
+
quoteVault,
|
|
1737
|
+
userBaseAccount,
|
|
1738
|
+
userQuoteAccount,
|
|
1739
|
+
baseMint,
|
|
1740
|
+
quoteMint,
|
|
1741
|
+
user,
|
|
1742
|
+
sentinelProgram,
|
|
1743
|
+
tokenProgram = TOKEN_PROGRAM_ID
|
|
1744
|
+
} = accounts;
|
|
1745
|
+
const keys = [
|
|
1746
|
+
{ address: config, role: ACCOUNT_ROLE_READONLY },
|
|
1747
|
+
{ address: launch, role: ACCOUNT_ROLE_WRITABLE },
|
|
1748
|
+
{ address: launchAuthority, role: ACCOUNT_ROLE_READONLY },
|
|
1749
|
+
{ address: baseVault, role: ACCOUNT_ROLE_WRITABLE },
|
|
1750
|
+
{ address: quoteVault, role: ACCOUNT_ROLE_WRITABLE },
|
|
1751
|
+
{ address: userBaseAccount, role: ACCOUNT_ROLE_WRITABLE },
|
|
1752
|
+
{ address: userQuoteAccount, role: ACCOUNT_ROLE_WRITABLE },
|
|
1753
|
+
{ address: baseMint, role: ACCOUNT_ROLE_READONLY },
|
|
1754
|
+
{ address: quoteMint, role: ACCOUNT_ROLE_READONLY },
|
|
1755
|
+
createAccountMeta2(user, ACCOUNT_ROLE_SIGNER)
|
|
1756
|
+
];
|
|
1757
|
+
if (sentinelProgram) {
|
|
1758
|
+
keys.push({ address: sentinelProgram, role: ACCOUNT_ROLE_READONLY });
|
|
1759
|
+
}
|
|
1760
|
+
keys.push({ address: tokenProgram, role: ACCOUNT_ROLE_READONLY });
|
|
1761
|
+
const data = new Uint8Array(
|
|
1762
|
+
getCurveSwapExactInInstructionDataEncoder().encode(args)
|
|
1763
|
+
);
|
|
1764
|
+
return { programAddress: programId, accounts: keys, data };
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1767
|
+
// src/solana/initializer/instructions/migrateLaunch.ts
|
|
1768
|
+
function isTransactionSigner7(value) {
|
|
1769
|
+
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
1770
|
+
}
|
|
1771
|
+
function createSignerAccountMeta5(value, role) {
|
|
1772
|
+
if (isTransactionSigner7(value)) {
|
|
1773
|
+
return { address: value.address, role, signer: value };
|
|
1774
|
+
}
|
|
1775
|
+
return { address: value, role };
|
|
1776
|
+
}
|
|
1777
|
+
function createMigrateLaunchInstruction(accounts, programId = INITIALIZER_PROGRAM_ID) {
|
|
1778
|
+
const {
|
|
1779
|
+
config,
|
|
1780
|
+
launch,
|
|
1781
|
+
launchAuthority,
|
|
1782
|
+
baseMint,
|
|
1783
|
+
quoteMint,
|
|
1784
|
+
baseVault,
|
|
1785
|
+
quoteVault,
|
|
1786
|
+
migratorProgram,
|
|
1787
|
+
payer,
|
|
1788
|
+
tokenProgram = TOKEN_PROGRAM_ID,
|
|
1789
|
+
systemProgram = SYSTEM_PROGRAM_ID,
|
|
1790
|
+
rent
|
|
1791
|
+
} = accounts;
|
|
1792
|
+
const keys = [
|
|
1793
|
+
{ address: config, role: ACCOUNT_ROLE_READONLY },
|
|
1794
|
+
{ address: launch, role: ACCOUNT_ROLE_WRITABLE },
|
|
1795
|
+
{ address: launchAuthority, role: ACCOUNT_ROLE_READONLY },
|
|
1796
|
+
{ address: baseMint, role: ACCOUNT_ROLE_READONLY },
|
|
1797
|
+
{ address: quoteMint, role: ACCOUNT_ROLE_READONLY },
|
|
1798
|
+
{ address: baseVault, role: ACCOUNT_ROLE_WRITABLE },
|
|
1799
|
+
{ address: quoteVault, role: ACCOUNT_ROLE_WRITABLE },
|
|
1800
|
+
{ address: migratorProgram, role: ACCOUNT_ROLE_READONLY },
|
|
1801
|
+
createSignerAccountMeta5(payer, ACCOUNT_ROLE_WRITABLE_SIGNER),
|
|
1802
|
+
{ address: tokenProgram, role: ACCOUNT_ROLE_READONLY },
|
|
1803
|
+
{ address: systemProgram, role: ACCOUNT_ROLE_READONLY },
|
|
1804
|
+
{ address: rent, role: ACCOUNT_ROLE_READONLY }
|
|
1805
|
+
];
|
|
1806
|
+
const data = encodeInstructionData(
|
|
1807
|
+
INITIALIZER_INSTRUCTION_DISCRIMINATORS.migrateLaunch
|
|
1808
|
+
);
|
|
1809
|
+
return { programAddress: programId, accounts: keys, data };
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
// src/solana/initializer/instructions/abortLaunch.ts
|
|
1813
|
+
function isTransactionSigner8(value) {
|
|
1814
|
+
return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
|
|
1815
|
+
}
|
|
1816
|
+
function createAccountMeta3(value, role) {
|
|
1817
|
+
if (isTransactionSigner8(value)) {
|
|
1818
|
+
return { address: value.address, role, signer: value };
|
|
1819
|
+
}
|
|
1820
|
+
return { address: value, role };
|
|
1821
|
+
}
|
|
1822
|
+
function createAbortLaunchInstruction(accounts, programId = INITIALIZER_PROGRAM_ID) {
|
|
1823
|
+
const {
|
|
1824
|
+
config,
|
|
1825
|
+
launch,
|
|
1826
|
+
launchAuthority,
|
|
1827
|
+
baseVault,
|
|
1828
|
+
quoteVault,
|
|
1829
|
+
authority,
|
|
1830
|
+
authorityBaseAccount,
|
|
1831
|
+
baseMint,
|
|
1832
|
+
tokenProgram = TOKEN_PROGRAM_ID
|
|
1833
|
+
} = accounts;
|
|
1834
|
+
const keys = [
|
|
1835
|
+
{ address: config, role: ACCOUNT_ROLE_READONLY },
|
|
1836
|
+
{ address: launch, role: ACCOUNT_ROLE_WRITABLE },
|
|
1837
|
+
{ address: launchAuthority, role: ACCOUNT_ROLE_READONLY },
|
|
1838
|
+
{ address: baseVault, role: ACCOUNT_ROLE_WRITABLE },
|
|
1839
|
+
{ address: quoteVault, role: ACCOUNT_ROLE_READONLY },
|
|
1840
|
+
createAccountMeta3(authority, ACCOUNT_ROLE_SIGNER),
|
|
1841
|
+
{ address: authorityBaseAccount, role: ACCOUNT_ROLE_WRITABLE },
|
|
1842
|
+
{ address: baseMint, role: ACCOUNT_ROLE_READONLY },
|
|
1843
|
+
{ address: tokenProgram, role: ACCOUNT_ROLE_READONLY }
|
|
1844
|
+
];
|
|
1845
|
+
const data = encodeInstructionData(
|
|
1846
|
+
INITIALIZER_INSTRUCTION_DISCRIMINATORS.abortLaunch
|
|
1847
|
+
);
|
|
1848
|
+
return { programAddress: programId, accounts: keys, data };
|
|
1849
|
+
}
|
|
1850
|
+
var previewSwapExactInResultCodec = getStructCodec([
|
|
1851
|
+
["amountOut", getU64Codec()],
|
|
1852
|
+
["feePaid", getU64Codec()]
|
|
1853
|
+
]);
|
|
1854
|
+
function createPreviewSwapExactInInstruction(accounts, args, programId = INITIALIZER_PROGRAM_ID) {
|
|
1855
|
+
const { launch, baseVault, quoteVault, sentinelProgram } = accounts;
|
|
1856
|
+
const keys = [
|
|
1857
|
+
{ address: launch, role: ACCOUNT_ROLE_READONLY },
|
|
1858
|
+
{ address: baseVault, role: ACCOUNT_ROLE_READONLY },
|
|
1859
|
+
{ address: quoteVault, role: ACCOUNT_ROLE_READONLY }
|
|
1860
|
+
];
|
|
1861
|
+
const accountsList = sentinelProgram ? [...keys, { address: sentinelProgram, role: ACCOUNT_ROLE_READONLY }] : keys;
|
|
1862
|
+
const data = new Uint8Array(
|
|
1863
|
+
getPreviewSwapExactInInstructionDataEncoder().encode(args)
|
|
1864
|
+
);
|
|
1865
|
+
return { programAddress: programId, accounts: accountsList, data };
|
|
1866
|
+
}
|
|
1867
|
+
function decodePreviewSwapExactInResult(data) {
|
|
1868
|
+
return previewSwapExactInResultCodec.decode(data);
|
|
1869
|
+
}
|
|
1870
|
+
var previewMigrationResultCodec = getStructCodec([
|
|
1871
|
+
["baseVaultAmount", getU64Codec()],
|
|
1872
|
+
["quoteVaultAmount", getU64Codec()],
|
|
1873
|
+
["baseMintSupply", getU64Codec()]
|
|
1874
|
+
]);
|
|
1875
|
+
function createPreviewMigrationInstruction(accounts, programId = INITIALIZER_PROGRAM_ID) {
|
|
1876
|
+
const { launch, baseMint, baseVault, quoteVault } = accounts;
|
|
1877
|
+
const keys = [
|
|
1878
|
+
{ address: launch, role: ACCOUNT_ROLE_READONLY },
|
|
1879
|
+
{ address: baseMint, role: ACCOUNT_ROLE_READONLY },
|
|
1880
|
+
{ address: baseVault, role: ACCOUNT_ROLE_READONLY },
|
|
1881
|
+
{ address: quoteVault, role: ACCOUNT_ROLE_READONLY }
|
|
1882
|
+
];
|
|
1883
|
+
const data = encodeInstructionData(
|
|
1884
|
+
INITIALIZER_INSTRUCTION_DISCRIMINATORS.previewMigration
|
|
1885
|
+
);
|
|
1886
|
+
return { programAddress: programId, accounts: keys, data };
|
|
1887
|
+
}
|
|
1888
|
+
function decodePreviewMigrationResult(data) {
|
|
1889
|
+
return previewMigrationResultCodec.decode(data);
|
|
1890
|
+
}
|
|
1891
|
+
var addressCodec3 = getAddressCodec();
|
|
1892
|
+
function bytesToBase64(bytes) {
|
|
1893
|
+
let binary = "";
|
|
1894
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
1895
|
+
binary += String.fromCharCode(bytes[i]);
|
|
1896
|
+
}
|
|
1897
|
+
return btoa(binary);
|
|
1898
|
+
}
|
|
1899
|
+
function base64ToBytes2(base64) {
|
|
1900
|
+
const binary = atob(base64);
|
|
1901
|
+
const bytes = new Uint8Array(binary.length);
|
|
1902
|
+
for (let i = 0; i < binary.length; i++) {
|
|
1903
|
+
bytes[i] = binary.charCodeAt(i);
|
|
1904
|
+
}
|
|
1905
|
+
return bytes;
|
|
1906
|
+
}
|
|
1907
|
+
async function fetchLaunch(rpc, address3, config) {
|
|
1908
|
+
const response = await rpc.getAccountInfo(address3, {
|
|
1909
|
+
encoding: "base64",
|
|
1910
|
+
commitment: config?.commitment
|
|
1911
|
+
}).send();
|
|
1912
|
+
if (!response.value) {
|
|
1913
|
+
return null;
|
|
1914
|
+
}
|
|
1915
|
+
return getLaunchDecoder().decode(base64ToBytes2(response.value.data[0]));
|
|
1916
|
+
}
|
|
1917
|
+
async function fetchAllLaunches(rpc, config) {
|
|
1918
|
+
const programId = config?.programId ?? INITIALIZER_PROGRAM_ID;
|
|
1919
|
+
const discriminatorFilter = {
|
|
1920
|
+
memcmp: {
|
|
1921
|
+
offset: 0n,
|
|
1922
|
+
bytes: bytesToBase64(
|
|
1923
|
+
INITIALIZER_ACCOUNT_DISCRIMINATORS.Launch
|
|
1924
|
+
),
|
|
1925
|
+
encoding: "base64"
|
|
1926
|
+
}
|
|
1927
|
+
};
|
|
1928
|
+
const response = await rpc.getProgramAccounts(programId, {
|
|
1929
|
+
encoding: "base64",
|
|
1930
|
+
commitment: config?.commitment,
|
|
1931
|
+
filters: [discriminatorFilter]
|
|
1932
|
+
}).send();
|
|
1933
|
+
const accounts = Array.isArray(response) ? response : response.value;
|
|
1934
|
+
const launches = [];
|
|
1935
|
+
const decoder = getLaunchDecoder();
|
|
1936
|
+
for (const account of accounts) {
|
|
1937
|
+
try {
|
|
1938
|
+
const launch = decoder.decode(base64ToBytes2(account.account.data[0]));
|
|
1939
|
+
launches.push({ address: account.pubkey, account: launch });
|
|
1940
|
+
} catch {
|
|
1941
|
+
console.warn(`Failed to decode launch account: ${account.pubkey}`);
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
return launches;
|
|
1945
|
+
}
|
|
1946
|
+
async function fetchLaunchesByAuthority(rpc, authority, config) {
|
|
1947
|
+
const programId = config?.programId ?? INITIALIZER_PROGRAM_ID;
|
|
1948
|
+
const discriminatorFilter = {
|
|
1949
|
+
memcmp: {
|
|
1950
|
+
offset: 0n,
|
|
1951
|
+
bytes: bytesToBase64(
|
|
1952
|
+
INITIALIZER_ACCOUNT_DISCRIMINATORS.Launch
|
|
1953
|
+
),
|
|
1954
|
+
encoding: "base64"
|
|
1955
|
+
}
|
|
1956
|
+
};
|
|
1957
|
+
const authorityFilter = {
|
|
1958
|
+
memcmp: {
|
|
1959
|
+
offset: 8n,
|
|
1960
|
+
bytes: bytesToBase64(
|
|
1961
|
+
addressCodec3.encode(authority)
|
|
1962
|
+
),
|
|
1963
|
+
encoding: "base64"
|
|
1964
|
+
}
|
|
1965
|
+
};
|
|
1966
|
+
const response = await rpc.getProgramAccounts(programId, {
|
|
1967
|
+
encoding: "base64",
|
|
1968
|
+
commitment: config?.commitment,
|
|
1969
|
+
filters: [discriminatorFilter, authorityFilter]
|
|
1970
|
+
}).send();
|
|
1971
|
+
const accounts = Array.isArray(response) ? response : response.value;
|
|
1972
|
+
const launches = [];
|
|
1973
|
+
const decoder = getLaunchDecoder();
|
|
1974
|
+
for (const account of accounts) {
|
|
1975
|
+
try {
|
|
1976
|
+
const launch = decoder.decode(base64ToBytes2(account.account.data[0]));
|
|
1977
|
+
launches.push({ address: account.pubkey, account: launch });
|
|
1978
|
+
} catch {
|
|
1979
|
+
console.warn(`Failed to decode launch account: ${account.pubkey}`);
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
return launches;
|
|
1983
|
+
}
|
|
1984
|
+
async function launchExists(rpc, namespace, launchId, config) {
|
|
1985
|
+
const programId = config?.programId ?? INITIALIZER_PROGRAM_ID;
|
|
1986
|
+
const [launchAddress] = await getLaunchAddress(
|
|
1987
|
+
namespace,
|
|
1988
|
+
launchId,
|
|
1989
|
+
programId
|
|
1990
|
+
);
|
|
1991
|
+
const launch = await fetchLaunch(rpc, launchAddress, config);
|
|
1992
|
+
return launch !== null;
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1995
|
+
// src/solana/migrators/cpmmMigrator/index.ts
|
|
1996
|
+
var cpmmMigrator_exports = {};
|
|
1997
|
+
__export(cpmmMigrator_exports, {
|
|
1998
|
+
CPMM_MIGRATOR_ACCOUNT_DISCRIMINATORS: () => CPMM_MIGRATOR_ACCOUNT_DISCRIMINATORS,
|
|
1999
|
+
CPMM_MIGRATOR_INSTRUCTION_DISCRIMINATORS: () => CPMM_MIGRATOR_INSTRUCTION_DISCRIMINATORS,
|
|
2000
|
+
CPMM_MIGRATOR_PROGRAM_ID: () => CPMM_MIGRATOR_PROGRAM_ID,
|
|
2001
|
+
MAX_RECIPIENTS: () => MAX_RECIPIENTS,
|
|
2002
|
+
SEED_STATE: () => SEED_STATE,
|
|
2003
|
+
encodeMigrateCalldata: () => encodeMigrateCalldata,
|
|
2004
|
+
encodeRegisterLaunchCalldata: () => encodeRegisterLaunchCalldata,
|
|
2005
|
+
fetchCpmmMigratorState: () => fetchCpmmMigratorState,
|
|
2006
|
+
getCpmmMigratorStateAddress: () => getCpmmMigratorStateAddress,
|
|
2007
|
+
getCpmmMigratorStateCodec: () => getCpmmMigratorStateCodec,
|
|
2008
|
+
getCpmmMigratorStateDecoder: () => getCpmmMigratorStateDecoder,
|
|
2009
|
+
getCpmmMigratorStateEncoder: () => getCpmmMigratorStateEncoder,
|
|
2010
|
+
getMigrateArgsCodec: () => getMigrateArgsCodec,
|
|
2011
|
+
getMigrateArgsDecoder: () => getMigrateArgsDecoder,
|
|
2012
|
+
getMigrateArgsEncoder: () => getMigrateArgsEncoder,
|
|
2013
|
+
getRecipientCodec: () => getRecipientCodec,
|
|
2014
|
+
getRecipientDecoder: () => getRecipientDecoder,
|
|
2015
|
+
getRecipientEncoder: () => getRecipientEncoder,
|
|
2016
|
+
getRegisterLaunchArgsCodec: () => getRegisterLaunchArgsCodec,
|
|
2017
|
+
getRegisterLaunchArgsDecoder: () => getRegisterLaunchArgsDecoder,
|
|
2018
|
+
getRegisterLaunchArgsEncoder: () => getRegisterLaunchArgsEncoder
|
|
2019
|
+
});
|
|
2020
|
+
function getMigrateArgsEncoder() {
|
|
2021
|
+
return getStructEncoder([
|
|
2022
|
+
["baseForDistribution", getU64Encoder()],
|
|
2023
|
+
["baseForLiquidity", getU64Encoder()]
|
|
2024
|
+
]);
|
|
2025
|
+
}
|
|
2026
|
+
function getMigrateArgsDecoder() {
|
|
2027
|
+
return getStructDecoder([
|
|
2028
|
+
["baseForDistribution", getU64Decoder()],
|
|
2029
|
+
["baseForLiquidity", getU64Decoder()]
|
|
2030
|
+
]);
|
|
2031
|
+
}
|
|
2032
|
+
function getMigrateArgsCodec() {
|
|
2033
|
+
return combineCodec(getMigrateArgsEncoder(), getMigrateArgsDecoder());
|
|
2034
|
+
}
|
|
2035
|
+
function getRecipientEncoder() {
|
|
2036
|
+
return getStructEncoder([
|
|
2037
|
+
["wallet", getAddressEncoder()],
|
|
2038
|
+
["amount", getU64Encoder()]
|
|
2039
|
+
]);
|
|
2040
|
+
}
|
|
2041
|
+
function getRecipientDecoder() {
|
|
2042
|
+
return getStructDecoder([
|
|
2043
|
+
["wallet", getAddressDecoder()],
|
|
2044
|
+
["amount", getU64Decoder()]
|
|
2045
|
+
]);
|
|
2046
|
+
}
|
|
2047
|
+
function getRecipientCodec() {
|
|
2048
|
+
return combineCodec(getRecipientEncoder(), getRecipientDecoder());
|
|
2049
|
+
}
|
|
2050
|
+
function getRegisterLaunchArgsEncoder() {
|
|
2051
|
+
return getStructEncoder([
|
|
2052
|
+
["cpmmConfig", getAddressEncoder()],
|
|
2053
|
+
["initialSwapFeeBps", getU16Encoder()],
|
|
2054
|
+
["initialFeeSplitBps", getU16Encoder()],
|
|
2055
|
+
["recipients", getArrayEncoder(getRecipientEncoder())],
|
|
2056
|
+
["minRaiseQuote", getU64Encoder()],
|
|
2057
|
+
["minMigrationPriceQ64Opt", getOptionEncoder(getU128Encoder())]
|
|
2058
|
+
]);
|
|
2059
|
+
}
|
|
2060
|
+
function getRegisterLaunchArgsDecoder() {
|
|
2061
|
+
return getStructDecoder([
|
|
2062
|
+
["cpmmConfig", getAddressDecoder()],
|
|
2063
|
+
["initialSwapFeeBps", getU16Decoder()],
|
|
2064
|
+
["initialFeeSplitBps", getU16Decoder()],
|
|
2065
|
+
["recipients", getArrayDecoder(getRecipientDecoder())],
|
|
2066
|
+
["minRaiseQuote", getU64Decoder()],
|
|
2067
|
+
["minMigrationPriceQ64Opt", getOptionDecoder(getU128Decoder())]
|
|
2068
|
+
]);
|
|
2069
|
+
}
|
|
2070
|
+
function getRegisterLaunchArgsCodec() {
|
|
2071
|
+
return combineCodec(
|
|
2072
|
+
getRegisterLaunchArgsEncoder(),
|
|
2073
|
+
getRegisterLaunchArgsDecoder()
|
|
2074
|
+
);
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
// src/solana/generated/cpmmMigrator/accounts/cpmmMigratorState.ts
|
|
2078
|
+
var CPMM_MIGRATOR_STATE_DISCRIMINATOR = new Uint8Array([
|
|
2079
|
+
169,
|
|
2080
|
+
86,
|
|
2081
|
+
255,
|
|
2082
|
+
187,
|
|
2083
|
+
37,
|
|
2084
|
+
248,
|
|
2085
|
+
11,
|
|
2086
|
+
176
|
|
2087
|
+
]);
|
|
2088
|
+
function getCpmmMigratorStateEncoder() {
|
|
2089
|
+
return transformEncoder(
|
|
2090
|
+
getStructEncoder([
|
|
2091
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
2092
|
+
["launch", getAddressEncoder()],
|
|
2093
|
+
["admin", getAddressEncoder()],
|
|
2094
|
+
["cpmmConfig", getAddressEncoder()],
|
|
2095
|
+
["initialSwapFeeBps", getU16Encoder()],
|
|
2096
|
+
["initialFeeSplitBps", getU16Encoder()],
|
|
2097
|
+
["pad0", fixEncoderSize(getBytesEncoder(), 4)],
|
|
2098
|
+
["recipients", getArrayEncoder(getRecipientEncoder(), { size: 2 })],
|
|
2099
|
+
["minRaiseQuote", getU64Encoder()],
|
|
2100
|
+
["minMigrationPriceQ64Opt", getOptionEncoder(getU128Encoder())],
|
|
2101
|
+
["isMigrated", getBooleanEncoder()],
|
|
2102
|
+
["bump", getU8Encoder()],
|
|
2103
|
+
["reserved", fixEncoderSize(getBytesEncoder(), 14)]
|
|
2104
|
+
]),
|
|
2105
|
+
(value) => ({ ...value, discriminator: CPMM_MIGRATOR_STATE_DISCRIMINATOR })
|
|
2106
|
+
);
|
|
2107
|
+
}
|
|
2108
|
+
function getCpmmMigratorStateDecoder() {
|
|
2109
|
+
return getStructDecoder([
|
|
2110
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
2111
|
+
["launch", getAddressDecoder()],
|
|
2112
|
+
["admin", getAddressDecoder()],
|
|
2113
|
+
["cpmmConfig", getAddressDecoder()],
|
|
2114
|
+
["initialSwapFeeBps", getU16Decoder()],
|
|
2115
|
+
["initialFeeSplitBps", getU16Decoder()],
|
|
2116
|
+
["pad0", fixDecoderSize(getBytesDecoder(), 4)],
|
|
2117
|
+
["recipients", getArrayDecoder(getRecipientDecoder(), { size: 2 })],
|
|
2118
|
+
["minRaiseQuote", getU64Decoder()],
|
|
2119
|
+
["minMigrationPriceQ64Opt", getOptionDecoder(getU128Decoder())],
|
|
2120
|
+
["isMigrated", getBooleanDecoder()],
|
|
2121
|
+
["bump", getU8Decoder()],
|
|
2122
|
+
["reserved", fixDecoderSize(getBytesDecoder(), 14)]
|
|
2123
|
+
]);
|
|
2124
|
+
}
|
|
2125
|
+
function getCpmmMigratorStateCodec() {
|
|
2126
|
+
return combineCodec(
|
|
2127
|
+
getCpmmMigratorStateEncoder(),
|
|
2128
|
+
getCpmmMigratorStateDecoder()
|
|
2129
|
+
);
|
|
2130
|
+
}
|
|
2131
|
+
if (process.env.NODE_ENV !== "production") ;
|
|
2132
|
+
var CPMM_MIGRATOR_PROGRAM_ID = address(
|
|
2133
|
+
"CpmmMig1111111111111111111111111111111111111"
|
|
2134
|
+
);
|
|
2135
|
+
var SEED_STATE = "state";
|
|
2136
|
+
var MAX_RECIPIENTS = 2;
|
|
2137
|
+
var CPMM_MIGRATOR_INSTRUCTION_DISCRIMINATORS = {
|
|
2138
|
+
// SHA256("global:register_launch")[0:8]
|
|
2139
|
+
registerLaunch: new Uint8Array([
|
|
2140
|
+
114,
|
|
2141
|
+
114,
|
|
2142
|
+
67,
|
|
2143
|
+
23,
|
|
2144
|
+
41,
|
|
2145
|
+
70,
|
|
2146
|
+
0,
|
|
2147
|
+
225
|
|
2148
|
+
]),
|
|
2149
|
+
// SHA256("global:migrate")[0:8]
|
|
2150
|
+
migrate: new Uint8Array([155, 234, 231, 146, 236, 158, 162, 30])
|
|
2151
|
+
};
|
|
2152
|
+
var CPMM_MIGRATOR_ACCOUNT_DISCRIMINATORS = {
|
|
2153
|
+
// SHA256("account:CpmmMigratorState")[0:8]
|
|
2154
|
+
CpmmMigratorState: new Uint8Array([
|
|
2155
|
+
169,
|
|
2156
|
+
86,
|
|
2157
|
+
255,
|
|
2158
|
+
187,
|
|
2159
|
+
37,
|
|
2160
|
+
248,
|
|
2161
|
+
11,
|
|
2162
|
+
176
|
|
2163
|
+
])
|
|
2164
|
+
};
|
|
2165
|
+
var addressCodec4 = getAddressCodec();
|
|
2166
|
+
var textEncoder3 = new TextEncoder();
|
|
2167
|
+
async function getCpmmMigratorStateAddress(launch, programId = CPMM_MIGRATOR_PROGRAM_ID) {
|
|
2168
|
+
return getProgramDerivedAddress({
|
|
2169
|
+
programAddress: programId,
|
|
2170
|
+
seeds: [textEncoder3.encode(SEED_STATE), addressCodec4.encode(launch)]
|
|
2171
|
+
});
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
// src/solana/migrators/cpmmMigrator/client.ts
|
|
2175
|
+
function base64ToBytes3(base64) {
|
|
2176
|
+
const binary = atob(base64);
|
|
2177
|
+
const bytes = new Uint8Array(binary.length);
|
|
2178
|
+
for (let i = 0; i < binary.length; i++) {
|
|
2179
|
+
bytes[i] = binary.charCodeAt(i);
|
|
2180
|
+
}
|
|
2181
|
+
return bytes;
|
|
2182
|
+
}
|
|
2183
|
+
async function fetchCpmmMigratorState(rpc, address3) {
|
|
2184
|
+
const response = await rpc.getAccountInfo(address3, { encoding: "base64" }).send();
|
|
2185
|
+
if (!response.value) return null;
|
|
2186
|
+
return getCpmmMigratorStateDecoder().decode(
|
|
2187
|
+
base64ToBytes3(response.value.data[0])
|
|
2188
|
+
);
|
|
2189
|
+
}
|
|
2190
|
+
|
|
2191
|
+
// src/solana/migrators/cpmmMigrator/index.ts
|
|
2192
|
+
function encodeRegisterLaunchCalldata(args) {
|
|
2193
|
+
const encoded = new Uint8Array(getRegisterLaunchArgsEncoder().encode(args));
|
|
2194
|
+
return mergeBytes([
|
|
2195
|
+
CPMM_MIGRATOR_INSTRUCTION_DISCRIMINATORS.registerLaunch,
|
|
2196
|
+
encoded
|
|
2197
|
+
]);
|
|
2198
|
+
}
|
|
2199
|
+
function encodeMigrateCalldata(args) {
|
|
2200
|
+
const encoded = new Uint8Array(getMigrateArgsEncoder().encode(args));
|
|
2201
|
+
return mergeBytes([
|
|
2202
|
+
CPMM_MIGRATOR_INSTRUCTION_DISCRIMINATORS.migrate,
|
|
2203
|
+
encoded
|
|
2204
|
+
]);
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
export { CPMM_ERROR_MESSAGES, CpmmError, CpmmErrorCode, cpmmMigrator_exports as cpmmMigrator, createAddLiquidityInstruction, createClosePositionInstruction, createCollectProtocolFeesInstruction, createCreatePositionInstruction, createInitializeConfigInstruction, createInitializeOracleInstruction, createInitializePoolInstruction, createOracleConsultInstruction, createOracleUpdateInstruction, createPauseInstruction, createQuoteToNumeraireInstruction, createRemoveLiquidityInstruction, createSetFeesInstruction, createSetRouteInstruction, createSetSentinelInstruction, createSkimInstruction, createSwapExactInInstruction, createSwapInstruction, createTransferAdminInstruction, createUnpauseInstruction, curveParamsToMarketCap, decodeOracleConsultResult, decodeQuoteToNumeraireResult, fetchConfig, fetchConfigWithAddress, getErrorMessage, getMetadataAddress, initializer_exports as initializer, isCpmmError, marketCapToCurveParams, marketCapToSingleCurveParams, marketCapToTokenPrice, parseErrorFromLogs, validateMarketCapParameters };
|
|
2208
|
+
//# sourceMappingURL=index.js.map
|
|
2209
|
+
//# sourceMappingURL=index.js.map
|