@elmntl/vaults-v2 1.5.0 → 1.6.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.
@@ -889,7 +889,7 @@
889
889
  "type": "u32"
890
890
  },
891
891
  {
892
- "name": "exit_fee_bps",
892
+ "name": "exit_fee_dbps",
893
893
  "type": "u16"
894
894
  },
895
895
  {
@@ -1142,6 +1142,12 @@
1142
1142
  "accounts": [
1143
1143
  {
1144
1144
  "name": "owner",
1145
+ "docs": [
1146
+ "Receives the closed ticket's lamports (`close = owner` below), so it must be",
1147
+ "writable even when someone else pays the fee. Was unmarked before ele7-rwa-v1.1:",
1148
+ "worked only because every client made the owner the fee payer."
1149
+ ],
1150
+ "writable": true,
1145
1151
  "signer": true
1146
1152
  },
1147
1153
  {
@@ -1300,6 +1306,40 @@
1300
1306
  }
1301
1307
  ]
1302
1308
  },
1309
+ {
1310
+ "name": "set_vault_exit_fee",
1311
+ "docs": [
1312
+ "Admin-only: fee in TENTHS of a basis point (10 = 1 bps) on exits paid in the pool's vault token — the USDC leg of a",
1313
+ "USDC-denominated pool. Locked onto tickets at creation; legacy `withdraw` applies",
1314
+ "the current rate. The fee stays in the liquidity faucet. Cap 10%."
1315
+ ],
1316
+ "discriminator": [
1317
+ 243,
1318
+ 33,
1319
+ 212,
1320
+ 141,
1321
+ 171,
1322
+ 192,
1323
+ 93,
1324
+ 107
1325
+ ],
1326
+ "accounts": [
1327
+ {
1328
+ "name": "admin",
1329
+ "signer": true
1330
+ },
1331
+ {
1332
+ "name": "pool",
1333
+ "writable": true
1334
+ }
1335
+ ],
1336
+ "args": [
1337
+ {
1338
+ "name": "fee_dbps",
1339
+ "type": "u16"
1340
+ }
1341
+ ]
1342
+ },
1303
1343
  {
1304
1344
  "name": "transfer_to_faucet",
1305
1345
  "docs": [
@@ -1855,6 +1895,45 @@
1855
1895
  60,
1856
1896
  172
1857
1897
  ]
1898
+ },
1899
+ {
1900
+ "name": "VaultExitFeeSetEvent",
1901
+ "discriminator": [
1902
+ 121,
1903
+ 173,
1904
+ 101,
1905
+ 103,
1906
+ 255,
1907
+ 29,
1908
+ 77,
1909
+ 126
1910
+ ]
1911
+ },
1912
+ {
1913
+ "name": "VaultRedeemedEvent",
1914
+ "discriminator": [
1915
+ 2,
1916
+ 247,
1917
+ 215,
1918
+ 14,
1919
+ 36,
1920
+ 188,
1921
+ 222,
1922
+ 101
1923
+ ]
1924
+ },
1925
+ {
1926
+ "name": "VaultTicketCreatedEvent",
1927
+ "discriminator": [
1928
+ 133,
1929
+ 238,
1930
+ 236,
1931
+ 96,
1932
+ 41,
1933
+ 88,
1934
+ 238,
1935
+ 55
1936
+ ]
1858
1937
  }
1859
1938
  ],
1860
1939
  "errors": [
@@ -2238,7 +2317,7 @@
2238
2317
  "type": "u64"
2239
2318
  },
2240
2319
  {
2241
- "name": "fee_bps_locked",
2320
+ "name": "fee_dbps_locked",
2242
2321
  "type": "u16"
2243
2322
  },
2244
2323
  {
@@ -2290,7 +2369,7 @@
2290
2369
  "type": "u64"
2291
2370
  },
2292
2371
  {
2293
- "name": "fee_bps_locked",
2372
+ "name": "fee_dbps_locked",
2294
2373
  "type": "u16"
2295
2374
  },
2296
2375
  {
@@ -2794,6 +2873,17 @@
2794
2873
  ],
2795
2874
  "type": "u64"
2796
2875
  },
2876
+ {
2877
+ "name": "vault_exit_fee_dbps",
2878
+ "docs": [
2879
+ "Fee on exits paid in the pool's own vault token, in TENTHS of a basis point (10 = 1 bps; ele7-rwa-v1.2).",
2880
+ "Live pools read 0. Set by `set_vault_exit_fee`; locked onto each ticket at",
2881
+ "creation (`WithdrawalTicket.fee_dbps_locked`, payout_mint 0) and applied at",
2882
+ "`redeem_ticket`; applied at the current rate by the legacy `withdraw`.",
2883
+ "The fee stays in the liquidity faucet. Carved from the former reserved bytes."
2884
+ ],
2885
+ "type": "u16"
2886
+ },
2797
2887
  {
2798
2888
  "name": "_reserved",
2799
2889
  "docs": [
@@ -2802,7 +2892,7 @@
2802
2892
  "type": {
2803
2893
  "array": [
2804
2894
  "u8",
2805
- 24
2895
+ 22
2806
2896
  ]
2807
2897
  }
2808
2898
  }
@@ -2891,9 +2981,9 @@
2891
2981
  "type": "u32"
2892
2982
  },
2893
2983
  {
2894
- "name": "exit_fee_bps",
2984
+ "name": "exit_fee_dbps",
2895
2985
  "docs": [
2896
- "Fee on alt exits, basis points, applied on the conversion"
2986
+ "Fee on alt exits, in TENTHS of a basis point (10 = 1 bps), applied on the conversion"
2897
2987
  ],
2898
2988
  "type": "u16"
2899
2989
  },
@@ -3011,7 +3101,7 @@
3011
3101
  "type": "u64"
3012
3102
  },
3013
3103
  {
3014
- "name": "exit_fee_bps",
3104
+ "name": "exit_fee_dbps",
3015
3105
  "type": "u16"
3016
3106
  },
3017
3107
  {
@@ -3047,7 +3137,7 @@
3047
3137
  }
3048
3138
  },
3049
3139
  {
3050
- "name": "exit_fee_bps",
3140
+ "name": "exit_fee_dbps",
3051
3141
  "type": {
3052
3142
  "option": "u16"
3053
3143
  }
@@ -3437,7 +3527,7 @@
3437
3527
  }
3438
3528
  },
3439
3529
  {
3440
- "name": "exit_fee_bps",
3530
+ "name": "exit_fee_dbps",
3441
3531
  "type": {
3442
3532
  "option": "u16"
3443
3533
  }
@@ -3479,6 +3569,94 @@
3479
3569
  ]
3480
3570
  }
3481
3571
  },
3572
+ {
3573
+ "name": "VaultExitFeeSetEvent",
3574
+ "type": {
3575
+ "kind": "struct",
3576
+ "fields": [
3577
+ {
3578
+ "name": "pool",
3579
+ "type": "pubkey"
3580
+ },
3581
+ {
3582
+ "name": "fee_dbps",
3583
+ "type": "u16"
3584
+ }
3585
+ ]
3586
+ }
3587
+ },
3588
+ {
3589
+ "name": "VaultRedeemedEvent",
3590
+ "type": {
3591
+ "kind": "struct",
3592
+ "fields": [
3593
+ {
3594
+ "name": "pool",
3595
+ "type": "pubkey"
3596
+ },
3597
+ {
3598
+ "name": "ticket",
3599
+ "type": "pubkey"
3600
+ },
3601
+ {
3602
+ "name": "owner",
3603
+ "type": "pubkey"
3604
+ },
3605
+ {
3606
+ "name": "vault_total",
3607
+ "type": "u64"
3608
+ },
3609
+ {
3610
+ "name": "fee_dbps_locked",
3611
+ "type": "u16"
3612
+ },
3613
+ {
3614
+ "name": "fee",
3615
+ "type": "u64"
3616
+ },
3617
+ {
3618
+ "name": "net",
3619
+ "type": "u64"
3620
+ }
3621
+ ]
3622
+ }
3623
+ },
3624
+ {
3625
+ "name": "VaultTicketCreatedEvent",
3626
+ "type": {
3627
+ "kind": "struct",
3628
+ "fields": [
3629
+ {
3630
+ "name": "pool",
3631
+ "type": "pubkey"
3632
+ },
3633
+ {
3634
+ "name": "ticket",
3635
+ "type": "pubkey"
3636
+ },
3637
+ {
3638
+ "name": "owner",
3639
+ "type": "pubkey"
3640
+ },
3641
+ {
3642
+ "name": "vault_total",
3643
+ "type": "u64"
3644
+ },
3645
+ {
3646
+ "name": "fee_dbps_locked",
3647
+ "type": "u16"
3648
+ },
3649
+ {
3650
+ "name": "fee",
3651
+ "type": "u64"
3652
+ },
3653
+ {
3654
+ "name": "net",
3655
+ "type": "u64"
3656
+ }
3657
+ ]
3658
+ }
3659
+ },
3482
3660
  {
3483
3661
  "name": "WithdrawalTicket",
3484
3662
  "type": {
@@ -3543,9 +3721,9 @@
3543
3721
  "type": "u64"
3544
3722
  },
3545
3723
  {
3546
- "name": "fee_bps_locked",
3724
+ "name": "fee_dbps_locked",
3547
3725
  "docs": [
3548
- "Exit fee bps copied from PoolExt when an alt ticket was created"
3726
+ "Exit fee (tenths of a bps) locked when the ticket was created: the alt fee on alt tickets, the vault exit fee on vault tickets"
3549
3727
  ],
3550
3728
  "type": "u16"
3551
3729
  }
package/src/index.ts CHANGED
@@ -24,6 +24,9 @@ export {
24
24
  CONVERSION_SOURCE_POSTED,
25
25
  CONVERSION_SOURCE_SCOPE,
26
26
  NAV_ONE,
27
+ FEE_DENOMINATOR,
28
+ dbpsToPercent,
29
+ dbpsToBps,
27
30
  SCOPE_PROGRAM_ID,
28
31
  SCOPE_PRICES,
29
32
  SCOPE_INDEX,
@@ -510,6 +510,14 @@ export class ElementalV2Context {
510
510
  return instructions;
511
511
  }
512
512
 
513
+ /** Admin: set the fee on exits paid in the vault token, in tenths of a bps (10 = 1 bps, cap 10_000 = 10%). Locked onto tickets at creation. */
514
+ async setVaultExitFeeInstruction(pool: Pool, feeDbps: number, admin: PublicKey = this.walletAddress): Promise<TransactionInstruction> {
515
+ return await (this.program.methods as any)
516
+ .setVaultExitFee(feeDbps)
517
+ .accounts({ admin, pool: pool.address })
518
+ .instruction();
519
+ }
520
+
513
521
  /** Permissionless: sweep the alt holder to the pool's manager wallet (ops). */
514
522
  async flushAltToManagerInstruction(pool: Pool, ext: PoolExt): Promise<TransactionInstruction> {
515
523
  const managerAltAccount = getAssociatedTokenAddressSync(ext.altMintAddress, pool.data.managerWallet, true);
package/src/types.ts CHANGED
@@ -42,6 +42,8 @@ export interface PoolData {
42
42
  };
43
43
  managerWallet: PublicKey;
44
44
  minDepositAmountAlt: BN;
45
+ /** Fee on exits paid in the vault token, in TENTHS of a basis point (10 = 1 bps; ele7-rwa-v1.2). Zero on pools that predate it. */
46
+ vaultExitFeeDbps?: number;
45
47
  }
46
48
 
47
49
  // Raw position data from on-chain account
@@ -81,8 +83,8 @@ export interface WithdrawalTicketData {
81
83
  payoutMint: number;
82
84
  /** NAV (USDC per 1 RWA, 1e9-scaled) locked when an alt ticket was created; 0 otherwise. */
83
85
  navLocked: BN;
84
- /** Exit fee (bps) locked when an alt ticket was created; 0 otherwise. */
85
- feeBpsLocked: number;
86
+ /** Exit fee locked at creation, in tenths of a bps (10 = 1 bps): the alt fee on alt tickets, the vault exit fee on vault tickets. */
87
+ feeDbpsLocked: number;
86
88
  }
87
89
 
88
90
  /**
@@ -98,7 +100,7 @@ export interface PoolExtData {
98
100
  nav: BN;
99
101
  navUpdatedAt: BN;
100
102
  navMaxAge: number;
101
- exitFeeBps: number;
103
+ exitFeeDbps: number;
102
104
  altDecimals: number;
103
105
  flags: number;
104
106
  conversionSource: number;
@@ -117,6 +119,10 @@ export const CONVERSION_SOURCE_POSTED = 0;
117
119
  export const CONVERSION_SOURCE_SCOPE = 1;
118
120
  /** NAV scale: USDC per 1 RWA × 1e9 */
119
121
  export const NAV_ONE = new BN(1_000_000_000);
122
+ /** Fee unit: tenths of a basis point. fee = ceil(gross × dbps / FEE_DENOMINATOR). 10 dbps = 1 bps, 1_000 = 1%. */
123
+ export const FEE_DENOMINATOR = 100_000;
124
+ export const dbpsToPercent = (dbps: number) => dbps / 1_000;
125
+ export const dbpsToBps = (dbps: number) => dbps / 10;
120
126
 
121
127
  // Kamino Scope oracle (mainnet) — the on-chain NAV source for every RWA pool
122
128
  export const SCOPE_PROGRAM_ID = new PublicKey("HFn8GnPADiny6XqUoWE8uRPPxb29ikn4yTuPa9MF2fWJ");