@glamsystems/glam-sdk 0.1.32 → 0.1.34

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/index.cjs.js CHANGED
@@ -15306,7 +15306,11 @@ const STAKE_POOLS_MAP = new Map(STAKE_POOLS.map((p)=>[
15306
15306
  p.mint,
15307
15307
  p
15308
15308
  ]));
15309
- const ASSETS_MAINNET = new Map([
15309
+ /**
15310
+ * Asset-Oracle mapping supported by the protocol. This map is a mirror of onchain mapping stored in `global_config` https://solscan.io/account/6avract7PxKqoq6hdmpAgGKgJWoJWdiXPPzzFZ62Hck6
15311
+ *
15312
+ * Note that we use functional prices for LSTs, and the oracle pubkey of a LST asset is the pool state.
15313
+ */ const ASSETS_MAINNET = new Map([
15310
15314
  [
15311
15315
  // SOL
15312
15316
  "So11111111111111111111111111111111111111112",
@@ -15356,7 +15360,7 @@ const ASSETS_MAINNET = new Map([
15356
15360
  }
15357
15361
  ],
15358
15362
  [
15359
- // USDC
15363
+ // USD Coin - USDC
15360
15364
  "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
15361
15365
  {
15362
15366
  decimals: 6,
@@ -15364,7 +15368,7 @@ const ASSETS_MAINNET = new Map([
15364
15368
  }
15365
15369
  ],
15366
15370
  [
15367
- // USDT
15371
+ // USDT - USDT
15368
15372
  "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
15369
15373
  {
15370
15374
  decimals: 6,
@@ -15372,7 +15376,7 @@ const ASSETS_MAINNET = new Map([
15372
15376
  }
15373
15377
  ],
15374
15378
  [
15375
- // USDY
15379
+ // Ondo US Dollar Yield - USDY
15376
15380
  "A1KLoBrKBde8Ty9qtNQUtq3C2ortoC3u7twggz7sEto6",
15377
15381
  {
15378
15382
  decimals: 6,
@@ -15380,7 +15384,7 @@ const ASSETS_MAINNET = new Map([
15380
15384
  }
15381
15385
  ],
15382
15386
  [
15383
- // USDG
15387
+ // Global Dollar - USDG
15384
15388
  "2u1tszSeqZ3qBWF3uNGPFc8TzMk2tdiwknnRMWGWjGWH",
15385
15389
  {
15386
15390
  decimals: 6,
@@ -15389,7 +15393,7 @@ const ASSETS_MAINNET = new Map([
15389
15393
  }
15390
15394
  ],
15391
15395
  [
15392
- // PYUSD
15396
+ // PayPal USD - PYUSD
15393
15397
  "2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo",
15394
15398
  {
15395
15399
  decimals: 6,
@@ -15421,41 +15425,6 @@ const ASSETS_MAINNET = new Map([
15421
15425
  oracle: new web3_js.PublicKey("7pT9mxKXyvfaZKeKy1oe2oV2K1RFtF7tPEJHUY3h2vVV")
15422
15426
  }
15423
15427
  ],
15424
- [
15425
- // mSOL
15426
- "mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So",
15427
- {
15428
- decimals: 9,
15429
- oracle: new web3_js.PublicKey("8szGkuLTAux9XMgZ2vtY39jVSowEcpBfFfD8hXSEqdGC")
15430
- }
15431
- ],
15432
- [
15433
- // jitoSOL
15434
- "J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn",
15435
- {
15436
- decimals: 9,
15437
- oracle: new web3_js.PublicKey("Jito4APyf642JPZPx3hGc6WWJ8zPKtRbRs4P815Awbb"),
15438
- isLst: true
15439
- }
15440
- ],
15441
- [
15442
- // bonkSOL
15443
- "BonK1YhkXEGLZzwtcvRTip3gAL9nCeQD7ppZBLXhtTs",
15444
- {
15445
- decimals: 9,
15446
- oracle: new web3_js.PublicKey("ArAQfbzsdotoKB5jJcZa3ajQrrPcWr2YQoDAEAiFxJAC"),
15447
- isLst: true
15448
- }
15449
- ],
15450
- [
15451
- // dSOL
15452
- "Dso1bDeDjCQxTrWHqUUi63oBvV7Mdm6WaobLbQ7gnPQ",
15453
- {
15454
- decimals: 9,
15455
- oracle: new web3_js.PublicKey("9mhGNSPArRMHpLDMSmxAvuoizBqtBGqYdT8WGuqgxNdn"),
15456
- isLst: true
15457
- }
15458
- ],
15459
15428
  [
15460
15429
  // GOOGLx
15461
15430
  "XsCPL9dNWBMvFtTmwcCA5v3xWPSMEBCszbQdiLLq6aN",
@@ -15495,8 +15464,265 @@ const ASSETS_MAINNET = new Map([
15495
15464
  programId: splToken.TOKEN_2022_PROGRAM_ID,
15496
15465
  aggIndex: 341
15497
15466
  }
15467
+ ],
15468
+ [
15469
+ // Bonk - Bonk
15470
+ "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
15471
+ {
15472
+ decimals: 6,
15473
+ oracle: new web3_js.PublicKey("BERaNi6cpEresbq6HC1EQGaB1H1UjvEo4NGnmYSSJof4")
15474
+ }
15475
+ ],
15476
+ [
15477
+ // Raydium - RAY
15478
+ "4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R",
15479
+ {
15480
+ decimals: 6,
15481
+ oracle: new web3_js.PublicKey("6VXU2P9BJkuPkfA7FJVonBtAo1c2pGnHoV9rxsdZKZyb")
15482
+ }
15483
+ ],
15484
+ [
15485
+ // Helium Network Token - HNT
15486
+ "hntyVP6YFm1Hg25TN9WGLqM12b8TQmcknKrdu1oxWux",
15487
+ {
15488
+ decimals: 8,
15489
+ oracle: new web3_js.PublicKey("AEPgc6qUTCT8AwdckPcGbJXtcM9bj8mGYAyHE4BscJtm")
15490
+ }
15491
+ ],
15492
+ [
15493
+ // Kamino - KMNO
15494
+ "KMNo3nJsBXfcpJTVhZcXLW7RmTwTt4GVFE7suUBo9sS",
15495
+ {
15496
+ decimals: 6,
15497
+ oracle: new web3_js.PublicKey("6ua3DK1sHoYyNi15dsxy6RYwUcZPDDXfyChzaRMaheQF")
15498
+ }
15499
+ ],
15500
+ [
15501
+ // Tensor - TNSR
15502
+ "TNSRxcUxoT9xBG3de7PiJyTDYu7kskLqcpddxnEJAS6",
15503
+ {
15504
+ decimals: 9,
15505
+ oracle: new web3_js.PublicKey("EX6r1GdfsgcUsY6cQ6YsToV4RGsb4HKpjrkokK2DrmsS")
15506
+ }
15507
+ ],
15508
+ [
15509
+ // JITO - JTO
15510
+ "jtojtomepa8beP8AuQc6eXt5FriJwfFMwQx2v2f9mCL",
15511
+ {
15512
+ decimals: 9,
15513
+ oracle: new web3_js.PublicKey("CGCz4mB8NsDddCq6BZToRUDUuktzsAfpKYh6ATgyyCGF")
15514
+ }
15515
+ ],
15516
+ [
15517
+ // Drift - DRIFT
15518
+ "DriFtupJYLTosbwoN8koMbEYSx54aFAVLddWsbksjwg7",
15519
+ {
15520
+ decimals: 6,
15521
+ oracle: new web3_js.PublicKey("5VJou4ufN2vE11zyZUaLsKLTXhyzCTgiq6QDsts2YnnD")
15522
+ }
15523
+ ],
15524
+ [
15525
+ // Render Token - RENDER
15526
+ "rndrizKT3MK1iimdxRdWabcF7Zg7AR5T4nud4EkHBof",
15527
+ {
15528
+ decimals: 8,
15529
+ oracle: new web3_js.PublicKey("97EqsAGbTnShB7oYWAFFCVVAx8PWXgDYDhcpm99izNQ4")
15530
+ }
15531
+ ],
15532
+ [
15533
+ // Wormhole Token - W
15534
+ "85VBFQZC9TZkfaptBWjvUw7YbZjy52A6mjtPGjstQAmQ",
15535
+ {
15536
+ decimals: 6,
15537
+ oracle: new web3_js.PublicKey("CsFUXiA5dM4eCKjVBBy8tXhXzDkDRNoYjU5rjpHyfNEZ")
15538
+ }
15539
+ ],
15540
+ [
15541
+ // Pyth Network - PYTH
15542
+ "HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3",
15543
+ {
15544
+ decimals: 6,
15545
+ oracle: new web3_js.PublicKey("6Sfx8ZAt6xaEgMXTahR6GrT7oYB6nFBMoVyCmMyHmeJV")
15546
+ }
15547
+ ],
15548
+ [
15549
+ // dogwifhat - $WIF
15550
+ "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",
15551
+ {
15552
+ decimals: 6,
15553
+ oracle: new web3_js.PublicKey("4QXWStoyEErTZFVsvKrvxuNa6QT8zpeA8jddZunSGvYE")
15554
+ }
15555
+ ],
15556
+ [
15557
+ // Infinity - INF
15558
+ "5oVNBeEEQvYi1cX3ir8Dx5n1P7pdxydbGF2X4TxVusJm",
15559
+ {
15560
+ decimals: 9,
15561
+ oracle: new web3_js.PublicKey("B7RUYg2zF6UdUSHv2RmpnriPVJccYWojgFydNS1NY5F8")
15562
+ }
15563
+ ],
15564
+ [
15565
+ // BlazeStake Staked SOL (bSOL) - bSOL
15566
+ "bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1",
15567
+ {
15568
+ decimals: 9,
15569
+ oracle: new web3_js.PublicKey("BmDWPMsytWmYkh9n6o7m79eVshVYf2B5GVaqQ2EWKnGH")
15570
+ }
15571
+ ],
15572
+ [
15573
+ // Popcat - POPCAT
15574
+ "7GCihgDB8fe6KNjn2MYtkzZcRjQy3t9GHdC8uHYmW2hr",
15575
+ {
15576
+ decimals: 9,
15577
+ oracle: new web3_js.PublicKey("C5fiAmQyjdfDR4EGepZqnEL3fJwMBav5yoAk6XyKMF6u")
15578
+ }
15579
+ ],
15580
+ [
15581
+ // Cloud - CLOUD
15582
+ "CLoUDKc4Ane7HeQcPpE3YHnznRxhMimJ4MyaUqyHFzAu",
15583
+ {
15584
+ decimals: 9,
15585
+ oracle: new web3_js.PublicKey("9Ennia27iT83kNAk3JtRKxSMzuCzsVtT4MzuxpE7anME")
15586
+ }
15587
+ ],
15588
+ [
15589
+ // Binance Staked SOL - BNSOL
15590
+ "BNso1VUJnh4zcfpZa6986Ea66P6TCp59hvtNJ8b1X85",
15591
+ {
15592
+ decimals: 9,
15593
+ oracle: new web3_js.PublicKey("8DmXTfhhtb9kTcpTVfb6Ygx8WhZ8wexGqcpxfn23zooe")
15594
+ }
15595
+ ],
15596
+ [
15597
+ // MOTHER IGGY - MOTHER
15598
+ "3S8qX1MsMqRbiwKg2cQyx7nis1oHMgaCuc9c4VfvVdPN",
15599
+ {
15600
+ decimals: 6,
15601
+ oracle: new web3_js.PublicKey("469WQgfJ6AJ3eJ8FUcdhiZawf7yNChA3hseTSyhFatHZ")
15602
+ }
15603
+ ],
15604
+ [
15605
+ // Magic Eden - ME
15606
+ "MEFNBXixkEbait3xn9bkm8WsJzXtVsaJEn4c8Sam21u",
15607
+ {
15608
+ decimals: 6,
15609
+ oracle: new web3_js.PublicKey("BboTg1yT114FQkqT6MM3P3G3CcCktuM2RePgU8Gr3K4A")
15610
+ }
15611
+ ],
15612
+ [
15613
+ // META - META
15614
+ "METADDFL6wWMWEoKTFJwcThTbUmtarRJZjRpzUvkxhr",
15615
+ {
15616
+ decimals: 9,
15617
+ oracle: new web3_js.PublicKey("DwYF1yveo8XTF1oqfsqykj332rjSxAd7bR6Gu6i4iUET")
15618
+ }
15619
+ ],
15620
+ [
15621
+ // Pudgy Penguins - PENGU
15622
+ "2zMMhcVQEXDtdE6vsFS7S7D5oUodfJHE8vd1gnBouauv",
15623
+ {
15624
+ decimals: 6,
15625
+ oracle: new web3_js.PublicKey("4A3KroGPjZxPAeBNF287V3NyRwV2q8iBi1vX7kHxTCh7")
15626
+ }
15627
+ ],
15628
+ [
15629
+ // ai16z - ai16z
15630
+ "HeLp6NuQkmYB4pYWo2zYs22mESHXPQYzXbB8n4V98jwC",
15631
+ {
15632
+ decimals: 9,
15633
+ oracle: new web3_js.PublicKey("3BGheQVvYtBNpBKSUXSTjpyKQc3dh8iiwT91Aiq7KYCU"),
15634
+ programId: splToken.TOKEN_2022_PROGRAM_ID
15635
+ }
15636
+ ],
15637
+ [
15638
+ // OFFICIAL TRUMP - TRUMP
15639
+ "6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN",
15640
+ {
15641
+ decimals: 6,
15642
+ oracle: new web3_js.PublicKey("FPQjZYvHRGy51guJ77p7n9u9b8eo1ktKRc2D2g5Vysth")
15643
+ }
15644
+ ],
15645
+ [
15646
+ // Melania Meme - MELANIA
15647
+ "FUAfBo2jgks6gB4Z4LfZkqSZgzNucisEHqnNebaRxM1P",
15648
+ {
15649
+ decimals: 6,
15650
+ oracle: new web3_js.PublicKey("3RgNWYYcZCKf5uZfriK8ASUbGQErhH6YbpdvZQ7ZKDCf")
15651
+ }
15652
+ ],
15653
+ [
15654
+ // AUSD - AUSD
15655
+ "AUSD1jCcCyPLybk1YnvPWsHQSrZ46dxwoMniN4N2UEB9",
15656
+ {
15657
+ decimals: 6,
15658
+ oracle: new web3_js.PublicKey("8FZhpiM8n3mpgvENWLcEvHsKB1bBhYBAyL4Ypr4gptLZ"),
15659
+ programId: splToken.TOKEN_2022_PROGRAM_ID
15660
+ }
15661
+ ],
15662
+ [
15663
+ // zBTC - zBTC
15664
+ "zBTCug3er3tLyffELcvDNrKkCymbPWysGcWihESYfLg",
15665
+ {
15666
+ decimals: 8,
15667
+ oracle: new web3_js.PublicKey("CN9QvvbGQzMnN8vJaSek2so4vFnTqgJDFrdJB8Y4tQfB")
15668
+ }
15669
+ ],
15670
+ [
15671
+ // Fartcoin - Fartcoin
15672
+ "9BB6NFEcjBCtnNLFko2FqVQBq8HHM13kCyYcdQbgpump",
15673
+ {
15674
+ decimals: 6,
15675
+ oracle: new web3_js.PublicKey("2sZomfWMDuQLcFak3nuharXorHrZ3hK8iaML6ZGSHtso")
15676
+ }
15677
+ ],
15678
+ [
15679
+ // ZEUS - ZEUS
15680
+ "ZEUS1aR7aX8DFFJf5QjWj2ftDDdNTroMNGo8YoQm3Gq",
15681
+ {
15682
+ decimals: 6,
15683
+ oracle: new web3_js.PublicKey("8cH72H3vqYPArV9QvkYJkwzTdsdNPPgVPrusz9sMmgNN")
15684
+ }
15685
+ ],
15686
+ [
15687
+ // Pump - PUMP
15688
+ "pumpCmXqMfrsAkQ5r49WcJnRayYRqmXz6ae8H7H9Dfn",
15689
+ {
15690
+ decimals: 6,
15691
+ oracle: new web3_js.PublicKey("5r8RWTaRiMgr9Lph3FTUE3sGb1vymhpCrm83Bovjfcps"),
15692
+ programId: splToken.TOKEN_2022_PROGRAM_ID
15693
+ }
15694
+ ],
15695
+ [
15696
+ // EURC - EURC
15697
+ "HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr",
15698
+ {
15699
+ decimals: 6,
15700
+ oracle: new web3_js.PublicKey("BkdSPLmw4W6twrJjAePw2bJAwDTBtxJ9t6LvNHfcBKg1")
15701
+ }
15702
+ ],
15703
+ [
15704
+ // DeFi Development Corp Staked SOL - dfdvSOL
15705
+ "sctmB7GPi5L2Q5G9tUSzXvhZ4YiDMEGcRov9KfArQpx",
15706
+ {
15707
+ decimals: 9,
15708
+ oracle: new web3_js.PublicKey("EUQQD2fNN7h7su5TbWpUnf22zeGtF3RjEX2hgX2YPfLd")
15709
+ }
15710
+ ],
15711
+ [
15712
+ // Syrup USDC - syrupUSDC
15713
+ "AvZZF1YaZDziPY2RCK4oJrRVrbN3mTD9NL24hPeaZeUj",
15714
+ {
15715
+ decimals: 6,
15716
+ oracle: new web3_js.PublicKey("GqqkoqHU5pqgTvL88xSCipH9txbPETyzvAvybQ3zRpzw")
15717
+ }
15498
15718
  ]
15499
15719
  ]);
15720
+ STAKE_POOLS.forEach((p)=>{
15721
+ ASSETS_MAINNET.set(p.mint, {
15722
+ decimals: p.decimals,
15723
+ oracle: new web3_js.PublicKey(p.poolState)
15724
+ });
15725
+ });
15500
15726
  const ASSETS_TESTS = new Map([]);
15501
15727
  const SOL_ORACLE = ASSETS_MAINNET.get("So11111111111111111111111111111111111111112").oracle;
15502
15728
  const USDC_ORACLE = ASSETS_MAINNET.get("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v").oracle;
@@ -20485,7 +20711,6 @@ class KaminoLendingClient {
20485
20711
  const vault = this.base.vaultPda;
20486
20712
  const userMetadata = this.getUserMetadataPda(vault);
20487
20713
  const lookupTable = new web3_js.PublicKey(0); // FIXME: create lookup table
20488
- // @ts-ignore
20489
20714
  const tx = await this.base.program.methods.kaminoLendingInitUserMetadata(lookupTable).accounts({
20490
20715
  glamState: this.base.statePda,
20491
20716
  glamSigner,
@@ -20532,7 +20757,7 @@ class KaminoLendingClient {
20532
20757
  obligationFarm = this.getObligationFarmState(obligation, depositReserve.farmCollateral);
20533
20758
  const obligationFarmAccount = await this.base.provider.connection.getAccountInfo(obligationFarm);
20534
20759
  if (!obligationFarmAccount) {
20535
- preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(0) // TODO: What does mode do?
20760
+ preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(0) // 0 - collateral farm
20536
20761
  .accounts({
20537
20762
  glamState: this.base.statePda,
20538
20763
  glamSigner,
@@ -20570,7 +20795,8 @@ class KaminoLendingClient {
20570
20795
  postInstructions.push(...ixs); // farms must be refreshed after deposit
20571
20796
  }
20572
20797
  // If deposit asset is WSOL, wrap SOL first in case vault doesn't have enough wSOL
20573
- const userSourceLiquidity = this.base.getVaultAta(asset);
20798
+ const { tokenProgram } = await this.base.fetchMintAndTokenProgram(asset);
20799
+ const userSourceLiquidity = this.base.getVaultAta(asset, tokenProgram);
20574
20800
  if (asset.equals(WSOL)) {
20575
20801
  const wrapSolIxs = await this.base.maybeWrapSol(amount);
20576
20802
  preInstructions.unshift(...wrapSolIxs);
@@ -20585,7 +20811,6 @@ class KaminoLendingClient {
20585
20811
  postInstructions.push(closeIx);
20586
20812
  }
20587
20813
  }
20588
- // @ts-ignore
20589
20814
  const tx = await this.base.program.methods.kaminoLendingDepositReserveLiquidityAndObligationCollateralV2(amount).accounts({
20590
20815
  glamState: this.base.statePda,
20591
20816
  glamSigner,
@@ -20600,7 +20825,7 @@ class KaminoLendingClient {
20600
20825
  userSourceLiquidity,
20601
20826
  placeholderUserDestinationCollateral: KAMINO_LENDING_PROGRAM,
20602
20827
  collateralTokenProgram: splToken.TOKEN_PROGRAM_ID,
20603
- liquidityTokenProgram: splToken.TOKEN_PROGRAM_ID,
20828
+ liquidityTokenProgram: tokenProgram,
20604
20829
  instructionSysvarAccount: web3_js.SYSVAR_INSTRUCTIONS_PUBKEY,
20605
20830
  obligationFarmUserState: obligationFarm,
20606
20831
  reserveFarmState: depositReserve.farmCollateral,
@@ -20622,7 +20847,7 @@ class KaminoLendingClient {
20622
20847
  obligationFarm = this.getObligationFarmState(obligation, withdrawReserve.farmCollateral);
20623
20848
  const obligationFarmAccount = await this.base.provider.connection.getAccountInfo(obligationFarm);
20624
20849
  if (!obligationFarmAccount) {
20625
- preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(0) // TODO: What does mode do?
20850
+ preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(0) // 0 - collateral farm
20626
20851
  .accounts({
20627
20852
  glamState: this.base.statePda,
20628
20853
  glamSigner,
@@ -20660,8 +20885,9 @@ class KaminoLendingClient {
20660
20885
  postInstructions.push(...ixs); // farms must be refreshed after withdraw
20661
20886
  }
20662
20887
  // Create asset ATA in case it doesn't exist. Add it to the beginning of preInstructions
20663
- const userDestinationLiquidity = this.base.getVaultAta(asset);
20664
- const createAtaIx = splToken.createAssociatedTokenAccountIdempotentInstruction(glamSigner, userDestinationLiquidity, vault, asset);
20888
+ const { tokenProgram } = await this.base.fetchMintAndTokenProgram(asset);
20889
+ const userDestinationLiquidity = this.base.getVaultAta(asset, tokenProgram);
20890
+ const createAtaIx = splToken.createAssociatedTokenAccountIdempotentInstruction(glamSigner, userDestinationLiquidity, vault, asset, tokenProgram);
20665
20891
  preInstructions.unshift(createAtaIx);
20666
20892
  const withdrawIx = await this.base.program.methods.kaminoLendingWithdrawObligationCollateralAndRedeemReserveCollateralV2(amount).accounts({
20667
20893
  glamState: this.base.statePda,
@@ -20677,12 +20903,18 @@ class KaminoLendingClient {
20677
20903
  userDestinationLiquidity,
20678
20904
  placeholderUserDestinationCollateral: null,
20679
20905
  collateralTokenProgram: splToken.TOKEN_PROGRAM_ID,
20680
- liquidityTokenProgram: splToken.TOKEN_PROGRAM_ID,
20906
+ liquidityTokenProgram: tokenProgram,
20681
20907
  instructionSysvarAccount: web3_js.SYSVAR_INSTRUCTIONS_PUBKEY,
20682
20908
  obligationFarmUserState: obligationFarm,
20683
20909
  reserveFarmState: withdrawReserve.farmCollateral,
20684
20910
  farmsProgram: KAMINO_FARM_PROGRAM
20685
- }).instruction();
20911
+ }).remainingAccounts([
20912
+ {
20913
+ pubkey: web3_js.SystemProgram.programId,
20914
+ isSigner: false,
20915
+ isWritable: false
20916
+ }
20917
+ ]).instruction();
20686
20918
  // The final instructions in the tx:
20687
20919
  // - refreshReserve * N
20688
20920
  // - refreshObligation
@@ -20706,7 +20938,7 @@ class KaminoLendingClient {
20706
20938
  obligationFarm = this.getObligationFarmState(obligation, borrowReserve.farmDebt);
20707
20939
  const obligationFarmAccount = await this.base.provider.connection.getAccountInfo(obligationFarm);
20708
20940
  if (!obligationFarmAccount) {
20709
- preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(0) // TODO: What does mode do?
20941
+ preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(1) // 1 - debt farm
20710
20942
  .accounts({
20711
20943
  glamState: this.base.statePda,
20712
20944
  glamSigner,
@@ -20746,8 +20978,9 @@ class KaminoLendingClient {
20746
20978
  postInstructions.push(...ixs); // farms must be refreshed after deposit
20747
20979
  }
20748
20980
  */ // Create asset ATA in case it doesn't exist. Add it to the beginning of preInstructions
20749
- const userDestinationLiquidity = this.base.getVaultAta(asset);
20750
- const createAtaIx = splToken.createAssociatedTokenAccountIdempotentInstruction(glamSigner, userDestinationLiquidity, vault, asset);
20981
+ const { tokenProgram } = await this.base.fetchMintAndTokenProgram(asset);
20982
+ const userDestinationLiquidity = this.base.getVaultAta(asset, tokenProgram);
20983
+ const createAtaIx = splToken.createAssociatedTokenAccountIdempotentInstruction(glamSigner, userDestinationLiquidity, vault, asset, tokenProgram);
20751
20984
  preInstructions.unshift(createAtaIx);
20752
20985
  const borrowIx = await this.base.program.methods.kaminoLendingBorrowObligationLiquidityV2(amount).accounts({
20753
20986
  glamState: this.base.statePda,
@@ -20762,7 +20995,7 @@ class KaminoLendingClient {
20762
20995
  userDestinationLiquidity,
20763
20996
  referrerTokenState: null,
20764
20997
  instructionSysvarAccount: web3_js.SYSVAR_INSTRUCTIONS_PUBKEY,
20765
- tokenProgram: splToken.TOKEN_PROGRAM_ID,
20998
+ tokenProgram,
20766
20999
  obligationFarmUserState: obligationFarm,
20767
21000
  reserveFarmState: borrowReserve.farmDebt,
20768
21001
  farmsProgram: KAMINO_FARM_PROGRAM
@@ -20788,7 +21021,7 @@ class KaminoLendingClient {
20788
21021
  obligationFarm = this.getObligationFarmState(obligation, repayReserve.farmDebt);
20789
21022
  const obligationFarmAccount = await this.base.provider.connection.getAccountInfo(obligationFarm);
20790
21023
  if (!obligationFarmAccount) {
20791
- preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(0) // TODO: What does mode do?
21024
+ preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(1) // 1 - debt farm
20792
21025
  .accounts({
20793
21026
  glamState: this.base.statePda,
20794
21027
  glamSigner,
@@ -20818,6 +21051,7 @@ class KaminoLendingClient {
20818
21051
  obligation,
20819
21052
  reserves: reservesInUse
20820
21053
  }));
21054
+ const { tokenProgram } = await this.base.fetchMintAndTokenProgram(asset);
20821
21055
  const repayIx = await this.base.program.methods.kaminoLendingRepayObligationLiquidityV2(amount).accounts({
20822
21056
  glamState: this.base.statePda,
20823
21057
  glamSigner,
@@ -20827,9 +21061,9 @@ class KaminoLendingClient {
20827
21061
  repayReserve: repayReserve.address,
20828
21062
  reserveLiquidityMint: asset,
20829
21063
  reserveDestinationLiquidity: repayReserve.liquiditySupplyVault,
20830
- userSourceLiquidity: this.base.getVaultAta(asset),
21064
+ userSourceLiquidity: this.base.getVaultAta(asset, tokenProgram),
20831
21065
  instructionSysvarAccount: web3_js.SYSVAR_INSTRUCTIONS_PUBKEY,
20832
- tokenProgram: splToken.TOKEN_PROGRAM_ID,
21066
+ tokenProgram,
20833
21067
  obligationFarmUserState: obligationFarm,
20834
21068
  reserveFarmState: repayReserve.farmDebt,
20835
21069
  farmsProgram: KAMINO_FARM_PROGRAM
package/index.esm.js CHANGED
@@ -15286,7 +15286,11 @@ const STAKE_POOLS_MAP = new Map(STAKE_POOLS.map((p)=>[
15286
15286
  p.mint,
15287
15287
  p
15288
15288
  ]));
15289
- const ASSETS_MAINNET = new Map([
15289
+ /**
15290
+ * Asset-Oracle mapping supported by the protocol. This map is a mirror of onchain mapping stored in `global_config` https://solscan.io/account/6avract7PxKqoq6hdmpAgGKgJWoJWdiXPPzzFZ62Hck6
15291
+ *
15292
+ * Note that we use functional prices for LSTs, and the oracle pubkey of a LST asset is the pool state.
15293
+ */ const ASSETS_MAINNET = new Map([
15290
15294
  [
15291
15295
  // SOL
15292
15296
  "So11111111111111111111111111111111111111112",
@@ -15336,7 +15340,7 @@ const ASSETS_MAINNET = new Map([
15336
15340
  }
15337
15341
  ],
15338
15342
  [
15339
- // USDC
15343
+ // USD Coin - USDC
15340
15344
  "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
15341
15345
  {
15342
15346
  decimals: 6,
@@ -15344,7 +15348,7 @@ const ASSETS_MAINNET = new Map([
15344
15348
  }
15345
15349
  ],
15346
15350
  [
15347
- // USDT
15351
+ // USDT - USDT
15348
15352
  "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
15349
15353
  {
15350
15354
  decimals: 6,
@@ -15352,7 +15356,7 @@ const ASSETS_MAINNET = new Map([
15352
15356
  }
15353
15357
  ],
15354
15358
  [
15355
- // USDY
15359
+ // Ondo US Dollar Yield - USDY
15356
15360
  "A1KLoBrKBde8Ty9qtNQUtq3C2ortoC3u7twggz7sEto6",
15357
15361
  {
15358
15362
  decimals: 6,
@@ -15360,7 +15364,7 @@ const ASSETS_MAINNET = new Map([
15360
15364
  }
15361
15365
  ],
15362
15366
  [
15363
- // USDG
15367
+ // Global Dollar - USDG
15364
15368
  "2u1tszSeqZ3qBWF3uNGPFc8TzMk2tdiwknnRMWGWjGWH",
15365
15369
  {
15366
15370
  decimals: 6,
@@ -15369,7 +15373,7 @@ const ASSETS_MAINNET = new Map([
15369
15373
  }
15370
15374
  ],
15371
15375
  [
15372
- // PYUSD
15376
+ // PayPal USD - PYUSD
15373
15377
  "2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo",
15374
15378
  {
15375
15379
  decimals: 6,
@@ -15401,41 +15405,6 @@ const ASSETS_MAINNET = new Map([
15401
15405
  oracle: new PublicKey("7pT9mxKXyvfaZKeKy1oe2oV2K1RFtF7tPEJHUY3h2vVV")
15402
15406
  }
15403
15407
  ],
15404
- [
15405
- // mSOL
15406
- "mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So",
15407
- {
15408
- decimals: 9,
15409
- oracle: new PublicKey("8szGkuLTAux9XMgZ2vtY39jVSowEcpBfFfD8hXSEqdGC")
15410
- }
15411
- ],
15412
- [
15413
- // jitoSOL
15414
- "J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn",
15415
- {
15416
- decimals: 9,
15417
- oracle: new PublicKey("Jito4APyf642JPZPx3hGc6WWJ8zPKtRbRs4P815Awbb"),
15418
- isLst: true
15419
- }
15420
- ],
15421
- [
15422
- // bonkSOL
15423
- "BonK1YhkXEGLZzwtcvRTip3gAL9nCeQD7ppZBLXhtTs",
15424
- {
15425
- decimals: 9,
15426
- oracle: new PublicKey("ArAQfbzsdotoKB5jJcZa3ajQrrPcWr2YQoDAEAiFxJAC"),
15427
- isLst: true
15428
- }
15429
- ],
15430
- [
15431
- // dSOL
15432
- "Dso1bDeDjCQxTrWHqUUi63oBvV7Mdm6WaobLbQ7gnPQ",
15433
- {
15434
- decimals: 9,
15435
- oracle: new PublicKey("9mhGNSPArRMHpLDMSmxAvuoizBqtBGqYdT8WGuqgxNdn"),
15436
- isLst: true
15437
- }
15438
- ],
15439
15408
  [
15440
15409
  // GOOGLx
15441
15410
  "XsCPL9dNWBMvFtTmwcCA5v3xWPSMEBCszbQdiLLq6aN",
@@ -15475,8 +15444,265 @@ const ASSETS_MAINNET = new Map([
15475
15444
  programId: TOKEN_2022_PROGRAM_ID,
15476
15445
  aggIndex: 341
15477
15446
  }
15447
+ ],
15448
+ [
15449
+ // Bonk - Bonk
15450
+ "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
15451
+ {
15452
+ decimals: 6,
15453
+ oracle: new PublicKey("BERaNi6cpEresbq6HC1EQGaB1H1UjvEo4NGnmYSSJof4")
15454
+ }
15455
+ ],
15456
+ [
15457
+ // Raydium - RAY
15458
+ "4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R",
15459
+ {
15460
+ decimals: 6,
15461
+ oracle: new PublicKey("6VXU2P9BJkuPkfA7FJVonBtAo1c2pGnHoV9rxsdZKZyb")
15462
+ }
15463
+ ],
15464
+ [
15465
+ // Helium Network Token - HNT
15466
+ "hntyVP6YFm1Hg25TN9WGLqM12b8TQmcknKrdu1oxWux",
15467
+ {
15468
+ decimals: 8,
15469
+ oracle: new PublicKey("AEPgc6qUTCT8AwdckPcGbJXtcM9bj8mGYAyHE4BscJtm")
15470
+ }
15471
+ ],
15472
+ [
15473
+ // Kamino - KMNO
15474
+ "KMNo3nJsBXfcpJTVhZcXLW7RmTwTt4GVFE7suUBo9sS",
15475
+ {
15476
+ decimals: 6,
15477
+ oracle: new PublicKey("6ua3DK1sHoYyNi15dsxy6RYwUcZPDDXfyChzaRMaheQF")
15478
+ }
15479
+ ],
15480
+ [
15481
+ // Tensor - TNSR
15482
+ "TNSRxcUxoT9xBG3de7PiJyTDYu7kskLqcpddxnEJAS6",
15483
+ {
15484
+ decimals: 9,
15485
+ oracle: new PublicKey("EX6r1GdfsgcUsY6cQ6YsToV4RGsb4HKpjrkokK2DrmsS")
15486
+ }
15487
+ ],
15488
+ [
15489
+ // JITO - JTO
15490
+ "jtojtomepa8beP8AuQc6eXt5FriJwfFMwQx2v2f9mCL",
15491
+ {
15492
+ decimals: 9,
15493
+ oracle: new PublicKey("CGCz4mB8NsDddCq6BZToRUDUuktzsAfpKYh6ATgyyCGF")
15494
+ }
15495
+ ],
15496
+ [
15497
+ // Drift - DRIFT
15498
+ "DriFtupJYLTosbwoN8koMbEYSx54aFAVLddWsbksjwg7",
15499
+ {
15500
+ decimals: 6,
15501
+ oracle: new PublicKey("5VJou4ufN2vE11zyZUaLsKLTXhyzCTgiq6QDsts2YnnD")
15502
+ }
15503
+ ],
15504
+ [
15505
+ // Render Token - RENDER
15506
+ "rndrizKT3MK1iimdxRdWabcF7Zg7AR5T4nud4EkHBof",
15507
+ {
15508
+ decimals: 8,
15509
+ oracle: new PublicKey("97EqsAGbTnShB7oYWAFFCVVAx8PWXgDYDhcpm99izNQ4")
15510
+ }
15511
+ ],
15512
+ [
15513
+ // Wormhole Token - W
15514
+ "85VBFQZC9TZkfaptBWjvUw7YbZjy52A6mjtPGjstQAmQ",
15515
+ {
15516
+ decimals: 6,
15517
+ oracle: new PublicKey("CsFUXiA5dM4eCKjVBBy8tXhXzDkDRNoYjU5rjpHyfNEZ")
15518
+ }
15519
+ ],
15520
+ [
15521
+ // Pyth Network - PYTH
15522
+ "HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3",
15523
+ {
15524
+ decimals: 6,
15525
+ oracle: new PublicKey("6Sfx8ZAt6xaEgMXTahR6GrT7oYB6nFBMoVyCmMyHmeJV")
15526
+ }
15527
+ ],
15528
+ [
15529
+ // dogwifhat - $WIF
15530
+ "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",
15531
+ {
15532
+ decimals: 6,
15533
+ oracle: new PublicKey("4QXWStoyEErTZFVsvKrvxuNa6QT8zpeA8jddZunSGvYE")
15534
+ }
15535
+ ],
15536
+ [
15537
+ // Infinity - INF
15538
+ "5oVNBeEEQvYi1cX3ir8Dx5n1P7pdxydbGF2X4TxVusJm",
15539
+ {
15540
+ decimals: 9,
15541
+ oracle: new PublicKey("B7RUYg2zF6UdUSHv2RmpnriPVJccYWojgFydNS1NY5F8")
15542
+ }
15543
+ ],
15544
+ [
15545
+ // BlazeStake Staked SOL (bSOL) - bSOL
15546
+ "bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1",
15547
+ {
15548
+ decimals: 9,
15549
+ oracle: new PublicKey("BmDWPMsytWmYkh9n6o7m79eVshVYf2B5GVaqQ2EWKnGH")
15550
+ }
15551
+ ],
15552
+ [
15553
+ // Popcat - POPCAT
15554
+ "7GCihgDB8fe6KNjn2MYtkzZcRjQy3t9GHdC8uHYmW2hr",
15555
+ {
15556
+ decimals: 9,
15557
+ oracle: new PublicKey("C5fiAmQyjdfDR4EGepZqnEL3fJwMBav5yoAk6XyKMF6u")
15558
+ }
15559
+ ],
15560
+ [
15561
+ // Cloud - CLOUD
15562
+ "CLoUDKc4Ane7HeQcPpE3YHnznRxhMimJ4MyaUqyHFzAu",
15563
+ {
15564
+ decimals: 9,
15565
+ oracle: new PublicKey("9Ennia27iT83kNAk3JtRKxSMzuCzsVtT4MzuxpE7anME")
15566
+ }
15567
+ ],
15568
+ [
15569
+ // Binance Staked SOL - BNSOL
15570
+ "BNso1VUJnh4zcfpZa6986Ea66P6TCp59hvtNJ8b1X85",
15571
+ {
15572
+ decimals: 9,
15573
+ oracle: new PublicKey("8DmXTfhhtb9kTcpTVfb6Ygx8WhZ8wexGqcpxfn23zooe")
15574
+ }
15575
+ ],
15576
+ [
15577
+ // MOTHER IGGY - MOTHER
15578
+ "3S8qX1MsMqRbiwKg2cQyx7nis1oHMgaCuc9c4VfvVdPN",
15579
+ {
15580
+ decimals: 6,
15581
+ oracle: new PublicKey("469WQgfJ6AJ3eJ8FUcdhiZawf7yNChA3hseTSyhFatHZ")
15582
+ }
15583
+ ],
15584
+ [
15585
+ // Magic Eden - ME
15586
+ "MEFNBXixkEbait3xn9bkm8WsJzXtVsaJEn4c8Sam21u",
15587
+ {
15588
+ decimals: 6,
15589
+ oracle: new PublicKey("BboTg1yT114FQkqT6MM3P3G3CcCktuM2RePgU8Gr3K4A")
15590
+ }
15591
+ ],
15592
+ [
15593
+ // META - META
15594
+ "METADDFL6wWMWEoKTFJwcThTbUmtarRJZjRpzUvkxhr",
15595
+ {
15596
+ decimals: 9,
15597
+ oracle: new PublicKey("DwYF1yveo8XTF1oqfsqykj332rjSxAd7bR6Gu6i4iUET")
15598
+ }
15599
+ ],
15600
+ [
15601
+ // Pudgy Penguins - PENGU
15602
+ "2zMMhcVQEXDtdE6vsFS7S7D5oUodfJHE8vd1gnBouauv",
15603
+ {
15604
+ decimals: 6,
15605
+ oracle: new PublicKey("4A3KroGPjZxPAeBNF287V3NyRwV2q8iBi1vX7kHxTCh7")
15606
+ }
15607
+ ],
15608
+ [
15609
+ // ai16z - ai16z
15610
+ "HeLp6NuQkmYB4pYWo2zYs22mESHXPQYzXbB8n4V98jwC",
15611
+ {
15612
+ decimals: 9,
15613
+ oracle: new PublicKey("3BGheQVvYtBNpBKSUXSTjpyKQc3dh8iiwT91Aiq7KYCU"),
15614
+ programId: TOKEN_2022_PROGRAM_ID
15615
+ }
15616
+ ],
15617
+ [
15618
+ // OFFICIAL TRUMP - TRUMP
15619
+ "6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN",
15620
+ {
15621
+ decimals: 6,
15622
+ oracle: new PublicKey("FPQjZYvHRGy51guJ77p7n9u9b8eo1ktKRc2D2g5Vysth")
15623
+ }
15624
+ ],
15625
+ [
15626
+ // Melania Meme - MELANIA
15627
+ "FUAfBo2jgks6gB4Z4LfZkqSZgzNucisEHqnNebaRxM1P",
15628
+ {
15629
+ decimals: 6,
15630
+ oracle: new PublicKey("3RgNWYYcZCKf5uZfriK8ASUbGQErhH6YbpdvZQ7ZKDCf")
15631
+ }
15632
+ ],
15633
+ [
15634
+ // AUSD - AUSD
15635
+ "AUSD1jCcCyPLybk1YnvPWsHQSrZ46dxwoMniN4N2UEB9",
15636
+ {
15637
+ decimals: 6,
15638
+ oracle: new PublicKey("8FZhpiM8n3mpgvENWLcEvHsKB1bBhYBAyL4Ypr4gptLZ"),
15639
+ programId: TOKEN_2022_PROGRAM_ID
15640
+ }
15641
+ ],
15642
+ [
15643
+ // zBTC - zBTC
15644
+ "zBTCug3er3tLyffELcvDNrKkCymbPWysGcWihESYfLg",
15645
+ {
15646
+ decimals: 8,
15647
+ oracle: new PublicKey("CN9QvvbGQzMnN8vJaSek2so4vFnTqgJDFrdJB8Y4tQfB")
15648
+ }
15649
+ ],
15650
+ [
15651
+ // Fartcoin - Fartcoin
15652
+ "9BB6NFEcjBCtnNLFko2FqVQBq8HHM13kCyYcdQbgpump",
15653
+ {
15654
+ decimals: 6,
15655
+ oracle: new PublicKey("2sZomfWMDuQLcFak3nuharXorHrZ3hK8iaML6ZGSHtso")
15656
+ }
15657
+ ],
15658
+ [
15659
+ // ZEUS - ZEUS
15660
+ "ZEUS1aR7aX8DFFJf5QjWj2ftDDdNTroMNGo8YoQm3Gq",
15661
+ {
15662
+ decimals: 6,
15663
+ oracle: new PublicKey("8cH72H3vqYPArV9QvkYJkwzTdsdNPPgVPrusz9sMmgNN")
15664
+ }
15665
+ ],
15666
+ [
15667
+ // Pump - PUMP
15668
+ "pumpCmXqMfrsAkQ5r49WcJnRayYRqmXz6ae8H7H9Dfn",
15669
+ {
15670
+ decimals: 6,
15671
+ oracle: new PublicKey("5r8RWTaRiMgr9Lph3FTUE3sGb1vymhpCrm83Bovjfcps"),
15672
+ programId: TOKEN_2022_PROGRAM_ID
15673
+ }
15674
+ ],
15675
+ [
15676
+ // EURC - EURC
15677
+ "HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr",
15678
+ {
15679
+ decimals: 6,
15680
+ oracle: new PublicKey("BkdSPLmw4W6twrJjAePw2bJAwDTBtxJ9t6LvNHfcBKg1")
15681
+ }
15682
+ ],
15683
+ [
15684
+ // DeFi Development Corp Staked SOL - dfdvSOL
15685
+ "sctmB7GPi5L2Q5G9tUSzXvhZ4YiDMEGcRov9KfArQpx",
15686
+ {
15687
+ decimals: 9,
15688
+ oracle: new PublicKey("EUQQD2fNN7h7su5TbWpUnf22zeGtF3RjEX2hgX2YPfLd")
15689
+ }
15690
+ ],
15691
+ [
15692
+ // Syrup USDC - syrupUSDC
15693
+ "AvZZF1YaZDziPY2RCK4oJrRVrbN3mTD9NL24hPeaZeUj",
15694
+ {
15695
+ decimals: 6,
15696
+ oracle: new PublicKey("GqqkoqHU5pqgTvL88xSCipH9txbPETyzvAvybQ3zRpzw")
15697
+ }
15478
15698
  ]
15479
15699
  ]);
15700
+ STAKE_POOLS.forEach((p)=>{
15701
+ ASSETS_MAINNET.set(p.mint, {
15702
+ decimals: p.decimals,
15703
+ oracle: new PublicKey(p.poolState)
15704
+ });
15705
+ });
15480
15706
  const ASSETS_TESTS = new Map([]);
15481
15707
  const SOL_ORACLE = ASSETS_MAINNET.get("So11111111111111111111111111111111111111112").oracle;
15482
15708
  const USDC_ORACLE = ASSETS_MAINNET.get("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v").oracle;
@@ -20465,7 +20691,6 @@ class KaminoLendingClient {
20465
20691
  const vault = this.base.vaultPda;
20466
20692
  const userMetadata = this.getUserMetadataPda(vault);
20467
20693
  const lookupTable = new PublicKey(0); // FIXME: create lookup table
20468
- // @ts-ignore
20469
20694
  const tx = await this.base.program.methods.kaminoLendingInitUserMetadata(lookupTable).accounts({
20470
20695
  glamState: this.base.statePda,
20471
20696
  glamSigner,
@@ -20512,7 +20737,7 @@ class KaminoLendingClient {
20512
20737
  obligationFarm = this.getObligationFarmState(obligation, depositReserve.farmCollateral);
20513
20738
  const obligationFarmAccount = await this.base.provider.connection.getAccountInfo(obligationFarm);
20514
20739
  if (!obligationFarmAccount) {
20515
- preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(0) // TODO: What does mode do?
20740
+ preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(0) // 0 - collateral farm
20516
20741
  .accounts({
20517
20742
  glamState: this.base.statePda,
20518
20743
  glamSigner,
@@ -20550,7 +20775,8 @@ class KaminoLendingClient {
20550
20775
  postInstructions.push(...ixs); // farms must be refreshed after deposit
20551
20776
  }
20552
20777
  // If deposit asset is WSOL, wrap SOL first in case vault doesn't have enough wSOL
20553
- const userSourceLiquidity = this.base.getVaultAta(asset);
20778
+ const { tokenProgram } = await this.base.fetchMintAndTokenProgram(asset);
20779
+ const userSourceLiquidity = this.base.getVaultAta(asset, tokenProgram);
20554
20780
  if (asset.equals(WSOL)) {
20555
20781
  const wrapSolIxs = await this.base.maybeWrapSol(amount);
20556
20782
  preInstructions.unshift(...wrapSolIxs);
@@ -20565,7 +20791,6 @@ class KaminoLendingClient {
20565
20791
  postInstructions.push(closeIx);
20566
20792
  }
20567
20793
  }
20568
- // @ts-ignore
20569
20794
  const tx = await this.base.program.methods.kaminoLendingDepositReserveLiquidityAndObligationCollateralV2(amount).accounts({
20570
20795
  glamState: this.base.statePda,
20571
20796
  glamSigner,
@@ -20580,7 +20805,7 @@ class KaminoLendingClient {
20580
20805
  userSourceLiquidity,
20581
20806
  placeholderUserDestinationCollateral: KAMINO_LENDING_PROGRAM,
20582
20807
  collateralTokenProgram: TOKEN_PROGRAM_ID,
20583
- liquidityTokenProgram: TOKEN_PROGRAM_ID,
20808
+ liquidityTokenProgram: tokenProgram,
20584
20809
  instructionSysvarAccount: SYSVAR_INSTRUCTIONS_PUBKEY,
20585
20810
  obligationFarmUserState: obligationFarm,
20586
20811
  reserveFarmState: depositReserve.farmCollateral,
@@ -20602,7 +20827,7 @@ class KaminoLendingClient {
20602
20827
  obligationFarm = this.getObligationFarmState(obligation, withdrawReserve.farmCollateral);
20603
20828
  const obligationFarmAccount = await this.base.provider.connection.getAccountInfo(obligationFarm);
20604
20829
  if (!obligationFarmAccount) {
20605
- preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(0) // TODO: What does mode do?
20830
+ preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(0) // 0 - collateral farm
20606
20831
  .accounts({
20607
20832
  glamState: this.base.statePda,
20608
20833
  glamSigner,
@@ -20640,8 +20865,9 @@ class KaminoLendingClient {
20640
20865
  postInstructions.push(...ixs); // farms must be refreshed after withdraw
20641
20866
  }
20642
20867
  // Create asset ATA in case it doesn't exist. Add it to the beginning of preInstructions
20643
- const userDestinationLiquidity = this.base.getVaultAta(asset);
20644
- const createAtaIx = createAssociatedTokenAccountIdempotentInstruction(glamSigner, userDestinationLiquidity, vault, asset);
20868
+ const { tokenProgram } = await this.base.fetchMintAndTokenProgram(asset);
20869
+ const userDestinationLiquidity = this.base.getVaultAta(asset, tokenProgram);
20870
+ const createAtaIx = createAssociatedTokenAccountIdempotentInstruction(glamSigner, userDestinationLiquidity, vault, asset, tokenProgram);
20645
20871
  preInstructions.unshift(createAtaIx);
20646
20872
  const withdrawIx = await this.base.program.methods.kaminoLendingWithdrawObligationCollateralAndRedeemReserveCollateralV2(amount).accounts({
20647
20873
  glamState: this.base.statePda,
@@ -20657,12 +20883,18 @@ class KaminoLendingClient {
20657
20883
  userDestinationLiquidity,
20658
20884
  placeholderUserDestinationCollateral: null,
20659
20885
  collateralTokenProgram: TOKEN_PROGRAM_ID,
20660
- liquidityTokenProgram: TOKEN_PROGRAM_ID,
20886
+ liquidityTokenProgram: tokenProgram,
20661
20887
  instructionSysvarAccount: SYSVAR_INSTRUCTIONS_PUBKEY,
20662
20888
  obligationFarmUserState: obligationFarm,
20663
20889
  reserveFarmState: withdrawReserve.farmCollateral,
20664
20890
  farmsProgram: KAMINO_FARM_PROGRAM
20665
- }).instruction();
20891
+ }).remainingAccounts([
20892
+ {
20893
+ pubkey: SystemProgram.programId,
20894
+ isSigner: false,
20895
+ isWritable: false
20896
+ }
20897
+ ]).instruction();
20666
20898
  // The final instructions in the tx:
20667
20899
  // - refreshReserve * N
20668
20900
  // - refreshObligation
@@ -20686,7 +20918,7 @@ class KaminoLendingClient {
20686
20918
  obligationFarm = this.getObligationFarmState(obligation, borrowReserve.farmDebt);
20687
20919
  const obligationFarmAccount = await this.base.provider.connection.getAccountInfo(obligationFarm);
20688
20920
  if (!obligationFarmAccount) {
20689
- preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(0) // TODO: What does mode do?
20921
+ preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(1) // 1 - debt farm
20690
20922
  .accounts({
20691
20923
  glamState: this.base.statePda,
20692
20924
  glamSigner,
@@ -20726,8 +20958,9 @@ class KaminoLendingClient {
20726
20958
  postInstructions.push(...ixs); // farms must be refreshed after deposit
20727
20959
  }
20728
20960
  */ // Create asset ATA in case it doesn't exist. Add it to the beginning of preInstructions
20729
- const userDestinationLiquidity = this.base.getVaultAta(asset);
20730
- const createAtaIx = createAssociatedTokenAccountIdempotentInstruction(glamSigner, userDestinationLiquidity, vault, asset);
20961
+ const { tokenProgram } = await this.base.fetchMintAndTokenProgram(asset);
20962
+ const userDestinationLiquidity = this.base.getVaultAta(asset, tokenProgram);
20963
+ const createAtaIx = createAssociatedTokenAccountIdempotentInstruction(glamSigner, userDestinationLiquidity, vault, asset, tokenProgram);
20731
20964
  preInstructions.unshift(createAtaIx);
20732
20965
  const borrowIx = await this.base.program.methods.kaminoLendingBorrowObligationLiquidityV2(amount).accounts({
20733
20966
  glamState: this.base.statePda,
@@ -20742,7 +20975,7 @@ class KaminoLendingClient {
20742
20975
  userDestinationLiquidity,
20743
20976
  referrerTokenState: null,
20744
20977
  instructionSysvarAccount: SYSVAR_INSTRUCTIONS_PUBKEY,
20745
- tokenProgram: TOKEN_PROGRAM_ID,
20978
+ tokenProgram,
20746
20979
  obligationFarmUserState: obligationFarm,
20747
20980
  reserveFarmState: borrowReserve.farmDebt,
20748
20981
  farmsProgram: KAMINO_FARM_PROGRAM
@@ -20768,7 +21001,7 @@ class KaminoLendingClient {
20768
21001
  obligationFarm = this.getObligationFarmState(obligation, repayReserve.farmDebt);
20769
21002
  const obligationFarmAccount = await this.base.provider.connection.getAccountInfo(obligationFarm);
20770
21003
  if (!obligationFarmAccount) {
20771
- preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(0) // TODO: What does mode do?
21004
+ preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(1) // 1 - debt farm
20772
21005
  .accounts({
20773
21006
  glamState: this.base.statePda,
20774
21007
  glamSigner,
@@ -20798,6 +21031,7 @@ class KaminoLendingClient {
20798
21031
  obligation,
20799
21032
  reserves: reservesInUse
20800
21033
  }));
21034
+ const { tokenProgram } = await this.base.fetchMintAndTokenProgram(asset);
20801
21035
  const repayIx = await this.base.program.methods.kaminoLendingRepayObligationLiquidityV2(amount).accounts({
20802
21036
  glamState: this.base.statePda,
20803
21037
  glamSigner,
@@ -20807,9 +21041,9 @@ class KaminoLendingClient {
20807
21041
  repayReserve: repayReserve.address,
20808
21042
  reserveLiquidityMint: asset,
20809
21043
  reserveDestinationLiquidity: repayReserve.liquiditySupplyVault,
20810
- userSourceLiquidity: this.base.getVaultAta(asset),
21044
+ userSourceLiquidity: this.base.getVaultAta(asset, tokenProgram),
20811
21045
  instructionSysvarAccount: SYSVAR_INSTRUCTIONS_PUBKEY,
20812
- tokenProgram: TOKEN_PROGRAM_ID,
21046
+ tokenProgram,
20813
21047
  obligationFarmUserState: obligationFarm,
20814
21048
  reserveFarmState: repayReserve.farmDebt,
20815
21049
  farmsProgram: KAMINO_FARM_PROGRAM
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glamsystems/glam-sdk",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
4
4
  "description": "TypeScript SDK for the GLAM Protocol",
5
5
  "main": "./index.cjs.js",
6
6
  "module": "./index.esm.js",
@@ -24,9 +24,13 @@ export interface AssetMeta {
24
24
  decimals: number;
25
25
  oracle: PublicKey;
26
26
  programId?: PublicKey;
27
- isLst?: boolean;
28
27
  aggIndex?: number;
29
28
  }
29
+ /**
30
+ * Asset-Oracle mapping supported by the protocol. This map is a mirror of onchain mapping stored in `global_config` https://solscan.io/account/6avract7PxKqoq6hdmpAgGKgJWoJWdiXPPzzFZ62Hck6
31
+ *
32
+ * Note that we use functional prices for LSTs, and the oracle pubkey of a LST asset is the pool state.
33
+ */
30
34
  export declare const ASSETS_MAINNET: Map<string, AssetMeta>;
31
35
  export declare const ASSETS_TESTS: Map<string, AssetMeta>;
32
36
  export declare const SOL_ORACLE: PublicKey;