@0dotxyz/p0-ts-sdk 2.1.1 → 2.1.3

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/dist/index.cjs CHANGED
@@ -602,8 +602,8 @@ function makeBundleTipIx(feePayer, bundleTip = 1e5) {
602
602
  return bundleTipInstruction;
603
603
  }
604
604
 
605
- // src/idl/marginfi_0.1.7.json
606
- var marginfi_0_1_7_default = {
605
+ // src/idl/marginfi_0.1.8.json
606
+ var marginfi_0_1_8_default = {
607
607
  address: "",
608
608
  metadata: {
609
609
  name: "marginfi",
@@ -653,7 +653,7 @@ var marginfi_0_1_7_default = {
653
653
  {
654
654
  name: "configure_bank_rate_limits",
655
655
  docs: [
656
- "(admin only) Configure bank-level rate limits for withdraw/borrow.",
656
+ "(admin or delegate_limit_admin) Configure bank-level rate limits for withdraw/borrow.",
657
657
  "Rate limits track net outflow in native tokens. Deposits offset withdraws.",
658
658
  "Set to 0 to disable. Hourly and daily windows are independent."
659
659
  ],
@@ -665,8 +665,7 @@ var marginfi_0_1_7_default = {
665
665
  },
666
666
  {
667
667
  name: "admin",
668
- signer: true,
669
- relations: ["group"]
668
+ signer: true
670
669
  },
671
670
  {
672
671
  name: "bank",
@@ -690,7 +689,9 @@ var marginfi_0_1_7_default = {
690
689
  },
691
690
  {
692
691
  name: "configure_deleverage_withdrawal_limit",
693
- docs: ["(group admin only) Set the daily withdrawal limit for deleverages per group."],
692
+ docs: [
693
+ "(admin or delegate_limit_admin) Set the daily withdrawal limit for deleverages per group."
694
+ ],
694
695
  discriminator: [28, 132, 205, 158, 67, 77, 177, 63],
695
696
  accounts: [
696
697
  {
@@ -699,8 +700,7 @@ var marginfi_0_1_7_default = {
699
700
  },
700
701
  {
701
702
  name: "admin",
702
- signer: true,
703
- relations: ["marginfi_group"]
703
+ signer: true
704
704
  }
705
705
  ],
706
706
  args: [
@@ -713,7 +713,7 @@ var marginfi_0_1_7_default = {
713
713
  {
714
714
  name: "configure_group_rate_limits",
715
715
  docs: [
716
- "(admin only) Configure group-level rate limits for withdraw/borrow.",
716
+ "(admin or delegate_limit_admin) Configure group-level rate limits for withdraw/borrow.",
717
717
  "Rate limits track aggregate net outflow in USD.",
718
718
  "Example: $10M = 10_000_000. Set to 0 to disable."
719
719
  ],
@@ -725,8 +725,7 @@ var marginfi_0_1_7_default = {
725
725
  },
726
726
  {
727
727
  name: "admin",
728
- signer: true,
729
- relations: ["marginfi_group"]
728
+ signer: true
730
729
  }
731
730
  ],
732
731
  args: [
@@ -754,7 +753,6 @@ var marginfi_0_1_7_default = {
754
753
  accounts: [
755
754
  {
756
755
  name: "group",
757
- writable: true,
758
756
  relations: ["marginfi_account", "bank"]
759
757
  },
760
758
  {
@@ -1342,7 +1340,6 @@ var marginfi_0_1_7_default = {
1342
1340
  accounts: [
1343
1341
  {
1344
1342
  name: "group",
1345
- writable: true,
1346
1343
  relations: ["marginfi_account", "bank"]
1347
1344
  },
1348
1345
  {
@@ -1876,6 +1873,7 @@ var marginfi_0_1_7_default = {
1876
1873
  accounts: [
1877
1874
  {
1878
1875
  name: "group",
1876
+ writable: true,
1879
1877
  relations: ["marginfi_account", "bank"]
1880
1878
  },
1881
1879
  {
@@ -1884,8 +1882,7 @@ var marginfi_0_1_7_default = {
1884
1882
  },
1885
1883
  {
1886
1884
  name: "authority",
1887
- signer: true,
1888
- relations: ["marginfi_account"]
1885
+ signer: true
1889
1886
  },
1890
1887
  {
1891
1888
  name: "bank",
@@ -2175,7 +2172,6 @@ var marginfi_0_1_7_default = {
2175
2172
  accounts: [
2176
2173
  {
2177
2174
  name: "group",
2178
- writable: true,
2179
2175
  relations: ["marginfi_account", "bank"]
2180
2176
  },
2181
2177
  {
@@ -2350,7 +2346,6 @@ var marginfi_0_1_7_default = {
2350
2346
  accounts: [
2351
2347
  {
2352
2348
  name: "group",
2353
- writable: true,
2354
2349
  relations: ["marginfi_account", "bank"]
2355
2350
  },
2356
2351
  {
@@ -2879,7 +2874,6 @@ var marginfi_0_1_7_default = {
2879
2874
  accounts: [
2880
2875
  {
2881
2876
  name: "group",
2882
- writable: true,
2883
2877
  relations: ["marginfi_account", "bank"]
2884
2878
  },
2885
2879
  {
@@ -2976,12 +2970,13 @@ var marginfi_0_1_7_default = {
2976
2970
  relations: ["bank"]
2977
2971
  },
2978
2972
  {
2979
- name: "reserve_liquidity_mint",
2973
+ name: "mint",
2980
2974
  docs: [
2981
2975
  "The liquidity token mint (e.g., USDC)",
2982
2976
  "Needs serde to get the mint decimals for transfer checked"
2983
2977
  ],
2984
- writable: true
2978
+ writable: true,
2979
+ relations: ["bank"]
2985
2980
  },
2986
2981
  {
2987
2982
  name: "reserve_liquidity_supply",
@@ -3056,7 +3051,6 @@ var marginfi_0_1_7_default = {
3056
3051
  accounts: [
3057
3052
  {
3058
3053
  name: "group",
3059
- writable: true,
3060
3054
  relations: ["marginfi_account", "bank"]
3061
3055
  },
3062
3056
  {
@@ -3128,11 +3122,26 @@ var marginfi_0_1_7_default = {
3128
3122
  ]
3129
3123
  },
3130
3124
  {
3131
- name: "lending_account_close_balance",
3125
+ name: "lending_account_clear_emissions",
3132
3126
  docs: [
3133
- "(account authority) Close a balance position with dust-level amounts. Claims outstanding",
3134
- "emissions before closing."
3127
+ "(permissionless) Zero out `emissions_outstanding` on a balance after emissions are disabled",
3128
+ "on the bank."
3135
3129
  ],
3130
+ discriminator: [239, 4, 221, 98, 45, 167, 201, 244],
3131
+ accounts: [
3132
+ {
3133
+ name: "marginfi_account",
3134
+ writable: true
3135
+ },
3136
+ {
3137
+ name: "bank"
3138
+ }
3139
+ ],
3140
+ args: []
3141
+ },
3142
+ {
3143
+ name: "lending_account_close_balance",
3144
+ docs: ["(account authority) Close a balance position with dust-level amounts."],
3136
3145
  discriminator: [245, 54, 41, 4, 243, 202, 31, 17],
3137
3146
  accounts: [
3138
3147
  {
@@ -3164,7 +3173,219 @@ var marginfi_0_1_7_default = {
3164
3173
  accounts: [
3165
3174
  {
3166
3175
  name: "group",
3176
+ relations: ["marginfi_account", "bank"]
3177
+ },
3178
+ {
3179
+ name: "marginfi_account",
3180
+ writable: true
3181
+ },
3182
+ {
3183
+ name: "authority",
3184
+ signer: true
3185
+ },
3186
+ {
3187
+ name: "bank",
3188
+ writable: true
3189
+ },
3190
+ {
3191
+ name: "signer_token_account",
3192
+ writable: true
3193
+ },
3194
+ {
3195
+ name: "liquidity_vault",
3167
3196
  writable: true,
3197
+ relations: ["bank"]
3198
+ },
3199
+ {
3200
+ name: "token_program"
3201
+ }
3202
+ ],
3203
+ args: [
3204
+ {
3205
+ name: "amount",
3206
+ type: "u64"
3207
+ },
3208
+ {
3209
+ name: "deposit_up_to_limit",
3210
+ type: {
3211
+ option: "bool"
3212
+ }
3213
+ }
3214
+ ]
3215
+ },
3216
+ {
3217
+ name: "lending_account_end_flashloan",
3218
+ docs: ["(account authority) End a flash loan and run the health check."],
3219
+ discriminator: [105, 124, 201, 106, 153, 2, 8, 156],
3220
+ accounts: [
3221
+ {
3222
+ name: "marginfi_account",
3223
+ writable: true
3224
+ },
3225
+ {
3226
+ name: "authority",
3227
+ signer: true,
3228
+ relations: ["marginfi_account"]
3229
+ }
3230
+ ],
3231
+ args: []
3232
+ },
3233
+ {
3234
+ name: "lending_account_liquidate",
3235
+ docs: [
3236
+ "(permissionless) Liquidate a lending account balance of an unhealthy marginfi account.",
3237
+ "The liquidator takes on the liability and receives discounted collateral (2.5% liquidator",
3238
+ "fee + 2.5% insurance fee).",
3239
+ "* `asset_amount` - amount of collateral to liquidate",
3240
+ "* `liquidatee_accounts` - number of remaining accounts for the liquidatee",
3241
+ "* `liquidator_accounts` - number of remaining accounts for the liquidator"
3242
+ ],
3243
+ discriminator: [214, 169, 151, 213, 251, 167, 86, 219],
3244
+ accounts: [
3245
+ {
3246
+ name: "group",
3247
+ relations: [
3248
+ "asset_bank",
3249
+ "liab_bank",
3250
+ "liquidator_marginfi_account",
3251
+ "liquidatee_marginfi_account"
3252
+ ]
3253
+ },
3254
+ {
3255
+ name: "asset_bank",
3256
+ writable: true
3257
+ },
3258
+ {
3259
+ name: "liab_bank",
3260
+ writable: true
3261
+ },
3262
+ {
3263
+ name: "liquidator_marginfi_account",
3264
+ writable: true
3265
+ },
3266
+ {
3267
+ name: "authority",
3268
+ signer: true
3269
+ },
3270
+ {
3271
+ name: "liquidatee_marginfi_account",
3272
+ writable: true
3273
+ },
3274
+ {
3275
+ name: "bank_liquidity_vault_authority",
3276
+ pda: {
3277
+ seeds: [
3278
+ {
3279
+ kind: "const",
3280
+ value: [
3281
+ 108,
3282
+ 105,
3283
+ 113,
3284
+ 117,
3285
+ 105,
3286
+ 100,
3287
+ 105,
3288
+ 116,
3289
+ 121,
3290
+ 95,
3291
+ 118,
3292
+ 97,
3293
+ 117,
3294
+ 108,
3295
+ 116,
3296
+ 95,
3297
+ 97,
3298
+ 117,
3299
+ 116,
3300
+ 104
3301
+ ]
3302
+ },
3303
+ {
3304
+ kind: "account",
3305
+ path: "liab_bank"
3306
+ }
3307
+ ]
3308
+ }
3309
+ },
3310
+ {
3311
+ name: "bank_liquidity_vault",
3312
+ writable: true,
3313
+ pda: {
3314
+ seeds: [
3315
+ {
3316
+ kind: "const",
3317
+ value: [108, 105, 113, 117, 105, 100, 105, 116, 121, 95, 118, 97, 117, 108, 116]
3318
+ },
3319
+ {
3320
+ kind: "account",
3321
+ path: "liab_bank"
3322
+ }
3323
+ ]
3324
+ }
3325
+ },
3326
+ {
3327
+ name: "bank_insurance_vault",
3328
+ writable: true,
3329
+ pda: {
3330
+ seeds: [
3331
+ {
3332
+ kind: "const",
3333
+ value: [105, 110, 115, 117, 114, 97, 110, 99, 101, 95, 118, 97, 117, 108, 116]
3334
+ },
3335
+ {
3336
+ kind: "account",
3337
+ path: "liab_bank"
3338
+ }
3339
+ ]
3340
+ }
3341
+ },
3342
+ {
3343
+ name: "token_program"
3344
+ }
3345
+ ],
3346
+ args: [
3347
+ {
3348
+ name: "asset_amount",
3349
+ type: "u64"
3350
+ },
3351
+ {
3352
+ name: "liquidatee_accounts",
3353
+ type: "u8"
3354
+ },
3355
+ {
3356
+ name: "liquidator_accounts",
3357
+ type: "u8"
3358
+ }
3359
+ ]
3360
+ },
3361
+ {
3362
+ name: "lending_account_pulse_health",
3363
+ docs: [
3364
+ "(Permissionless) Refresh the internal risk engine health cache. Useful for liquidators and",
3365
+ "other consumers that want to see the internal risk state of a user account. This cache is",
3366
+ "read-only and serves no purpose except being populated by this ix.",
3367
+ "* remaining accounts expected in the same order as borrow, etc. I.e., for each balance the",
3368
+ "user has, pass bank and oracle: <bank1, oracle1, bank2, oracle2>"
3369
+ ],
3370
+ discriminator: [186, 52, 117, 97, 34, 74, 39, 253],
3371
+ accounts: [
3372
+ {
3373
+ name: "marginfi_account",
3374
+ writable: true
3375
+ }
3376
+ ],
3377
+ args: []
3378
+ },
3379
+ {
3380
+ name: "lending_account_repay",
3381
+ docs: [
3382
+ "(account authority, or any signer during receivership) Repay borrowed assets. Accrues",
3383
+ "interest, records repayment, and transfers tokens to the bank's liquidity vault."
3384
+ ],
3385
+ discriminator: [79, 209, 172, 177, 222, 51, 173, 151],
3386
+ accounts: [
3387
+ {
3388
+ name: "group",
3168
3389
  relations: ["marginfi_account", "bank"]
3169
3390
  },
3170
3391
  {
@@ -3173,226 +3394,12 @@ var marginfi_0_1_7_default = {
3173
3394
  },
3174
3395
  {
3175
3396
  name: "authority",
3176
- signer: true
3177
- },
3178
- {
3179
- name: "bank",
3180
- writable: true
3181
- },
3182
- {
3183
- name: "signer_token_account",
3184
- writable: true
3185
- },
3186
- {
3187
- name: "liquidity_vault",
3188
- writable: true,
3189
- relations: ["bank"]
3190
- },
3191
- {
3192
- name: "token_program"
3193
- }
3194
- ],
3195
- args: [
3196
- {
3197
- name: "amount",
3198
- type: "u64"
3199
- },
3200
- {
3201
- name: "deposit_up_to_limit",
3202
- type: {
3203
- option: "bool"
3204
- }
3205
- }
3206
- ]
3207
- },
3208
- {
3209
- name: "lending_account_end_flashloan",
3210
- docs: ["(account authority) End a flash loan and run the health check."],
3211
- discriminator: [105, 124, 201, 106, 153, 2, 8, 156],
3212
- accounts: [
3213
- {
3214
- name: "marginfi_account",
3215
- writable: true
3216
- },
3217
- {
3218
- name: "authority",
3219
- signer: true,
3220
- relations: ["marginfi_account"]
3221
- }
3222
- ],
3223
- args: []
3224
- },
3225
- {
3226
- name: "lending_account_liquidate",
3227
- docs: [
3228
- "(permissionless) Liquidate a lending account balance of an unhealthy marginfi account.",
3229
- "The liquidator takes on the liability and receives discounted collateral (2.5% liquidator",
3230
- "fee + 2.5% insurance fee).",
3231
- "* `asset_amount` - amount of collateral to liquidate",
3232
- "* `liquidatee_accounts` - number of remaining accounts for the liquidatee",
3233
- "* `liquidator_accounts` - number of remaining accounts for the liquidator"
3234
- ],
3235
- discriminator: [214, 169, 151, 213, 251, 167, 86, 219],
3236
- accounts: [
3237
- {
3238
- name: "group",
3239
- relations: [
3240
- "asset_bank",
3241
- "liab_bank",
3242
- "liquidator_marginfi_account",
3243
- "liquidatee_marginfi_account"
3244
- ]
3245
- },
3246
- {
3247
- name: "asset_bank",
3248
- writable: true
3249
- },
3250
- {
3251
- name: "liab_bank",
3252
- writable: true
3253
- },
3254
- {
3255
- name: "liquidator_marginfi_account",
3256
- writable: true
3257
- },
3258
- {
3259
- name: "authority",
3260
- signer: true
3261
- },
3262
- {
3263
- name: "liquidatee_marginfi_account",
3264
- writable: true
3265
- },
3266
- {
3267
- name: "bank_liquidity_vault_authority",
3268
- pda: {
3269
- seeds: [
3270
- {
3271
- kind: "const",
3272
- value: [
3273
- 108,
3274
- 105,
3275
- 113,
3276
- 117,
3277
- 105,
3278
- 100,
3279
- 105,
3280
- 116,
3281
- 121,
3282
- 95,
3283
- 118,
3284
- 97,
3285
- 117,
3286
- 108,
3287
- 116,
3288
- 95,
3289
- 97,
3290
- 117,
3291
- 116,
3292
- 104
3293
- ]
3294
- },
3295
- {
3296
- kind: "account",
3297
- path: "liab_bank"
3298
- }
3299
- ]
3300
- }
3301
- },
3302
- {
3303
- name: "bank_liquidity_vault",
3304
- writable: true,
3305
- pda: {
3306
- seeds: [
3307
- {
3308
- kind: "const",
3309
- value: [108, 105, 113, 117, 105, 100, 105, 116, 121, 95, 118, 97, 117, 108, 116]
3310
- },
3311
- {
3312
- kind: "account",
3313
- path: "liab_bank"
3314
- }
3315
- ]
3316
- }
3317
- },
3318
- {
3319
- name: "bank_insurance_vault",
3320
- writable: true,
3321
- pda: {
3322
- seeds: [
3323
- {
3324
- kind: "const",
3325
- value: [105, 110, 115, 117, 114, 97, 110, 99, 101, 95, 118, 97, 117, 108, 116]
3326
- },
3327
- {
3328
- kind: "account",
3329
- path: "liab_bank"
3330
- }
3331
- ]
3332
- }
3333
- },
3334
- {
3335
- name: "token_program"
3336
- }
3337
- ],
3338
- args: [
3339
- {
3340
- name: "asset_amount",
3341
- type: "u64"
3342
- },
3343
- {
3344
- name: "liquidatee_accounts",
3345
- type: "u8"
3346
- },
3347
- {
3348
- name: "liquidator_accounts",
3349
- type: "u8"
3350
- }
3351
- ]
3352
- },
3353
- {
3354
- name: "lending_account_pulse_health",
3355
- docs: [
3356
- "(Permissionless) Refresh the internal risk engine health cache. Useful for liquidators and",
3357
- "other consumers that want to see the internal risk state of a user account. This cache is",
3358
- "read-only and serves no purpose except being populated by this ix.",
3359
- "* remaining accounts expected in the same order as borrow, etc. I.e., for each balance the",
3360
- "user has, pass bank and oracle: <bank1, oracle1, bank2, oracle2>"
3361
- ],
3362
- discriminator: [186, 52, 117, 97, 34, 74, 39, 253],
3363
- accounts: [
3364
- {
3365
- name: "marginfi_account",
3366
- writable: true
3367
- }
3368
- ],
3369
- args: []
3370
- },
3371
- {
3372
- name: "lending_account_repay",
3373
- docs: [
3374
- "(account authority, or any signer during receivership) Repay borrowed assets. Accrues",
3375
- "interest, records repayment, and transfers tokens to the bank's liquidity vault."
3376
- ],
3377
- discriminator: [79, 209, 172, 177, 222, 51, 173, 151],
3378
- accounts: [
3379
- {
3380
- name: "group",
3381
- writable: true,
3382
- relations: ["marginfi_account", "bank"]
3383
- },
3384
- {
3385
- name: "marginfi_account",
3386
- writable: true
3387
- },
3388
- {
3389
- name: "authority",
3390
- docs: [
3391
- "Must be marginfi_account's authority, unless in liquidation/deleverage receivership or order execution",
3392
- "",
3393
- "Note: during receivership and order execution, there are no signer checks whatsoever: any key can repay as",
3394
- "long as the invariants checked at the end of execution are met."
3395
- ],
3397
+ docs: [
3398
+ "Must be marginfi_account's authority, unless in liquidation/deleverage receivership or order execution",
3399
+ "",
3400
+ "Note: during receivership and order execution, there are no signer checks whatsoever: any key can repay as",
3401
+ "long as the invariants checked at the end of execution are met."
3402
+ ],
3396
3403
  signer: true
3397
3404
  },
3398
3405
  {
@@ -3425,24 +3432,6 @@ var marginfi_0_1_7_default = {
3425
3432
  }
3426
3433
  ]
3427
3434
  },
3428
- {
3429
- name: "lending_account_settle_emissions",
3430
- docs: [
3431
- "(permissionless) Settle unclaimed emissions into a user's balance without withdrawing."
3432
- ],
3433
- discriminator: [161, 58, 136, 174, 242, 223, 156, 176],
3434
- accounts: [
3435
- {
3436
- name: "marginfi_account",
3437
- writable: true
3438
- },
3439
- {
3440
- name: "bank",
3441
- writable: true
3442
- }
3443
- ],
3444
- args: []
3445
- },
3446
3435
  {
3447
3436
  name: "lending_account_start_flashloan",
3448
3437
  docs: [
@@ -3483,7 +3472,6 @@ var marginfi_0_1_7_default = {
3483
3472
  accounts: [
3484
3473
  {
3485
3474
  name: "group",
3486
- writable: true,
3487
3475
  relations: ["marginfi_account", "bank"]
3488
3476
  },
3489
3477
  {
@@ -3566,253 +3554,6 @@ var marginfi_0_1_7_default = {
3566
3554
  }
3567
3555
  ]
3568
3556
  },
3569
- {
3570
- name: "lending_account_withdraw_emissions",
3571
- docs: [
3572
- "(account authority) Settle and withdraw emissions rewards to a destination token account."
3573
- ],
3574
- discriminator: [234, 22, 84, 214, 118, 176, 140, 170],
3575
- accounts: [
3576
- {
3577
- name: "group",
3578
- relations: ["marginfi_account", "bank"]
3579
- },
3580
- {
3581
- name: "marginfi_account",
3582
- writable: true
3583
- },
3584
- {
3585
- name: "authority",
3586
- signer: true
3587
- },
3588
- {
3589
- name: "bank",
3590
- writable: true
3591
- },
3592
- {
3593
- name: "emissions_mint",
3594
- relations: ["bank"]
3595
- },
3596
- {
3597
- name: "emissions_auth",
3598
- pda: {
3599
- seeds: [
3600
- {
3601
- kind: "const",
3602
- value: [
3603
- 101,
3604
- 109,
3605
- 105,
3606
- 115,
3607
- 115,
3608
- 105,
3609
- 111,
3610
- 110,
3611
- 115,
3612
- 95,
3613
- 97,
3614
- 117,
3615
- 116,
3616
- 104,
3617
- 95,
3618
- 115,
3619
- 101,
3620
- 101,
3621
- 100
3622
- ]
3623
- },
3624
- {
3625
- kind: "account",
3626
- path: "bank"
3627
- },
3628
- {
3629
- kind: "account",
3630
- path: "emissions_mint"
3631
- }
3632
- ]
3633
- }
3634
- },
3635
- {
3636
- name: "emissions_vault",
3637
- writable: true,
3638
- pda: {
3639
- seeds: [
3640
- {
3641
- kind: "const",
3642
- value: [
3643
- 101,
3644
- 109,
3645
- 105,
3646
- 115,
3647
- 115,
3648
- 105,
3649
- 111,
3650
- 110,
3651
- 115,
3652
- 95,
3653
- 116,
3654
- 111,
3655
- 107,
3656
- 101,
3657
- 110,
3658
- 95,
3659
- 97,
3660
- 99,
3661
- 99,
3662
- 111,
3663
- 117,
3664
- 110,
3665
- 116,
3666
- 95,
3667
- 115,
3668
- 101,
3669
- 101,
3670
- 100
3671
- ]
3672
- },
3673
- {
3674
- kind: "account",
3675
- path: "bank"
3676
- },
3677
- {
3678
- kind: "account",
3679
- path: "emissions_mint"
3680
- }
3681
- ]
3682
- }
3683
- },
3684
- {
3685
- name: "destination_account",
3686
- writable: true
3687
- },
3688
- {
3689
- name: "token_program"
3690
- }
3691
- ],
3692
- args: []
3693
- },
3694
- {
3695
- name: "lending_account_withdraw_emissions_permissionless",
3696
- docs: [
3697
- "(permissionless) Withdraw emissions to the user's pre-configured emissions destination ATA."
3698
- ],
3699
- discriminator: [4, 174, 124, 203, 44, 49, 145, 150],
3700
- accounts: [
3701
- {
3702
- name: "group",
3703
- relations: ["marginfi_account", "bank"]
3704
- },
3705
- {
3706
- name: "marginfi_account",
3707
- writable: true
3708
- },
3709
- {
3710
- name: "bank",
3711
- writable: true
3712
- },
3713
- {
3714
- name: "emissions_mint",
3715
- relations: ["bank"]
3716
- },
3717
- {
3718
- name: "emissions_auth",
3719
- pda: {
3720
- seeds: [
3721
- {
3722
- kind: "const",
3723
- value: [
3724
- 101,
3725
- 109,
3726
- 105,
3727
- 115,
3728
- 115,
3729
- 105,
3730
- 111,
3731
- 110,
3732
- 115,
3733
- 95,
3734
- 97,
3735
- 117,
3736
- 116,
3737
- 104,
3738
- 95,
3739
- 115,
3740
- 101,
3741
- 101,
3742
- 100
3743
- ]
3744
- },
3745
- {
3746
- kind: "account",
3747
- path: "bank"
3748
- },
3749
- {
3750
- kind: "account",
3751
- path: "emissions_mint"
3752
- }
3753
- ]
3754
- }
3755
- },
3756
- {
3757
- name: "emissions_vault",
3758
- writable: true,
3759
- pda: {
3760
- seeds: [
3761
- {
3762
- kind: "const",
3763
- value: [
3764
- 101,
3765
- 109,
3766
- 105,
3767
- 115,
3768
- 115,
3769
- 105,
3770
- 111,
3771
- 110,
3772
- 115,
3773
- 95,
3774
- 116,
3775
- 111,
3776
- 107,
3777
- 101,
3778
- 110,
3779
- 95,
3780
- 97,
3781
- 99,
3782
- 99,
3783
- 111,
3784
- 117,
3785
- 110,
3786
- 116,
3787
- 95,
3788
- 115,
3789
- 101,
3790
- 101,
3791
- 100
3792
- ]
3793
- },
3794
- {
3795
- kind: "account",
3796
- path: "bank"
3797
- },
3798
- {
3799
- kind: "account",
3800
- path: "emissions_mint"
3801
- }
3802
- ]
3803
- }
3804
- },
3805
- {
3806
- name: "destination_account",
3807
- docs: ["registered on `marginfi_account`"],
3808
- writable: true
3809
- },
3810
- {
3811
- name: "token_program"
3812
- }
3813
- ],
3814
- args: []
3815
- },
3816
3557
  {
3817
3558
  name: "lending_pool_accrue_bank_interest",
3818
3559
  docs: [
@@ -6214,7 +5955,6 @@ var marginfi_0_1_7_default = {
6214
5955
  accounts: [
6215
5956
  {
6216
5957
  name: "group",
6217
- writable: true,
6218
5958
  relations: ["bank"]
6219
5959
  },
6220
5960
  {
@@ -6225,50 +5965,17 @@ var marginfi_0_1_7_default = {
6225
5965
  args: []
6226
5966
  },
6227
5967
  {
6228
- name: "lending_pool_set_fixed_oracle_price",
6229
- docs: ["(admin only)"],
6230
- discriminator: [28, 126, 127, 127, 60, 37, 211, 125],
6231
- accounts: [
6232
- {
6233
- name: "group",
6234
- relations: ["bank"]
6235
- },
6236
- {
6237
- name: "admin",
6238
- signer: true,
6239
- relations: ["group"]
6240
- },
6241
- {
6242
- name: "bank",
6243
- writable: true
6244
- }
5968
+ name: "lending_pool_reclaim_emissions_vault",
5969
+ docs: [
5970
+ "(permissionless) Reclaim all remaining tokens from the emissions vault",
5971
+ "to the global fee wallet ATA, and disable emissions on the bank."
6245
5972
  ],
6246
- args: [
6247
- {
6248
- name: "price",
6249
- type: {
6250
- defined: {
6251
- name: "WrappedI80F48"
6252
- }
6253
- }
6254
- }
6255
- ]
6256
- },
6257
- {
6258
- name: "lending_pool_setup_emissions",
6259
- docs: ["(delegate_emissions_admin only)"],
6260
- discriminator: [206, 97, 120, 172, 113, 204, 169, 70],
5973
+ discriminator: [206, 67, 186, 225, 41, 30, 95, 216],
6261
5974
  accounts: [
6262
5975
  {
6263
5976
  name: "group",
6264
5977
  relations: ["bank"]
6265
5978
  },
6266
- {
6267
- name: "delegate_emissions_admin",
6268
- writable: true,
6269
- signer: true,
6270
- relations: ["group"]
6271
- },
6272
5979
  {
6273
5980
  name: "bank",
6274
5981
  writable: true
@@ -6316,106 +6023,7 @@ var marginfi_0_1_7_default = {
6316
6023
  }
6317
6024
  },
6318
6025
  {
6319
- name: "emissions_token_account",
6320
- writable: true,
6321
- pda: {
6322
- seeds: [
6323
- {
6324
- kind: "const",
6325
- value: [
6326
- 101,
6327
- 109,
6328
- 105,
6329
- 115,
6330
- 115,
6331
- 105,
6332
- 111,
6333
- 110,
6334
- 115,
6335
- 95,
6336
- 116,
6337
- 111,
6338
- 107,
6339
- 101,
6340
- 110,
6341
- 95,
6342
- 97,
6343
- 99,
6344
- 99,
6345
- 111,
6346
- 117,
6347
- 110,
6348
- 116,
6349
- 95,
6350
- 115,
6351
- 101,
6352
- 101,
6353
- 100
6354
- ]
6355
- },
6356
- {
6357
- kind: "account",
6358
- path: "bank"
6359
- },
6360
- {
6361
- kind: "account",
6362
- path: "emissions_mint"
6363
- }
6364
- ]
6365
- }
6366
- },
6367
- {
6368
- name: "emissions_funding_account",
6369
- docs: ["NOTE: This is a TokenAccount, spl transfer will validate it.", ""],
6370
- writable: true
6371
- },
6372
- {
6373
- name: "token_program"
6374
- },
6375
- {
6376
- name: "system_program",
6377
- address: "11111111111111111111111111111111"
6378
- }
6379
- ],
6380
- args: [
6381
- {
6382
- name: "flags",
6383
- type: "u64"
6384
- },
6385
- {
6386
- name: "rate",
6387
- type: "u64"
6388
- },
6389
- {
6390
- name: "total_emissions",
6391
- type: "u64"
6392
- }
6393
- ]
6394
- },
6395
- {
6396
- name: "lending_pool_update_emissions_parameters",
6397
- docs: ["(delegate_emissions_admin only)"],
6398
- discriminator: [55, 213, 224, 168, 153, 53, 197, 40],
6399
- accounts: [
6400
- {
6401
- name: "group",
6402
- relations: ["bank"]
6403
- },
6404
- {
6405
- name: "delegate_emissions_admin",
6406
- writable: true,
6407
- signer: true,
6408
- relations: ["group"]
6409
- },
6410
- {
6411
- name: "bank",
6412
- writable: true
6413
- },
6414
- {
6415
- name: "emissions_mint"
6416
- },
6417
- {
6418
- name: "emissions_token_account",
6026
+ name: "emissions_vault",
6419
6027
  writable: true,
6420
6028
  pda: {
6421
6029
  seeds: [
@@ -6464,30 +6072,53 @@ var marginfi_0_1_7_default = {
6464
6072
  }
6465
6073
  },
6466
6074
  {
6467
- name: "emissions_funding_account",
6075
+ name: "fee_state",
6076
+ pda: {
6077
+ seeds: [
6078
+ {
6079
+ kind: "const",
6080
+ value: [102, 101, 101, 115, 116, 97, 116, 101]
6081
+ }
6082
+ ]
6083
+ }
6084
+ },
6085
+ {
6086
+ name: "destination_account",
6087
+ docs: ["emissions mint (validated in handler)."],
6468
6088
  writable: true
6469
6089
  },
6470
6090
  {
6471
6091
  name: "token_program"
6472
6092
  }
6473
6093
  ],
6474
- args: [
6094
+ args: []
6095
+ },
6096
+ {
6097
+ name: "lending_pool_set_fixed_oracle_price",
6098
+ docs: ["(admin only)"],
6099
+ discriminator: [28, 126, 127, 127, 60, 37, 211, 125],
6100
+ accounts: [
6475
6101
  {
6476
- name: "emissions_flags",
6477
- type: {
6478
- option: "u64"
6479
- }
6102
+ name: "group",
6103
+ relations: ["bank"]
6480
6104
  },
6481
6105
  {
6482
- name: "emissions_rate",
6483
- type: {
6484
- option: "u64"
6485
- }
6106
+ name: "admin",
6107
+ signer: true,
6108
+ relations: ["group"]
6486
6109
  },
6487
6110
  {
6488
- name: "additional_emissions",
6111
+ name: "bank",
6112
+ writable: true
6113
+ }
6114
+ ],
6115
+ args: [
6116
+ {
6117
+ name: "price",
6489
6118
  type: {
6490
- option: "u64"
6119
+ defined: {
6120
+ name: "WrappedI80F48"
6121
+ }
6491
6122
  }
6492
6123
  }
6493
6124
  ]
@@ -6997,7 +6628,7 @@ var marginfi_0_1_7_default = {
6997
6628
  name: "marginfi_account_keeper_close_order",
6998
6629
  docs: [
6999
6630
  "(permissionless keeper) Close an existing Order after the user account was closed, or it no",
7000
- "longer as the associated positions, or the user has executed",
6631
+ "longer has the associated positions, or the user has executed",
7001
6632
  "`marginfi_account_set_keeper_close_flags`. Keeper keeps the rent."
7002
6633
  ],
7003
6634
  discriminator: [128, 114, 71, 46, 194, 71, 186, 106],
@@ -7223,8 +6854,7 @@ var marginfi_0_1_7_default = {
7223
6854
  {
7224
6855
  name: "marginfi_account_update_emissions_destination_account",
7225
6856
  docs: [
7226
- "(account authority) Set the wallet whose canonical ATA will receive permissionless emissions",
7227
- "withdrawals."
6857
+ "(account authority) Set the wallet whose canonical ATA will receive off-chain emissions."
7228
6858
  ],
7229
6859
  discriminator: [73, 185, 162, 201, 111, 24, 116, 185],
7230
6860
  accounts: [
@@ -7234,12 +6864,11 @@ var marginfi_0_1_7_default = {
7234
6864
  },
7235
6865
  {
7236
6866
  name: "authority",
7237
- signer: true,
7238
- relations: ["marginfi_account"]
6867
+ signer: true
7239
6868
  },
7240
6869
  {
7241
6870
  name: "destination_account",
7242
- docs: ["User's earned emissions will be sent to the canonical ATA of this wallet.", ""]
6871
+ docs: ["the canonical ATA for each emissions mint."]
7243
6872
  }
7244
6873
  ],
7245
6874
  args: []
@@ -7288,6 +6917,12 @@ var marginfi_0_1_7_default = {
7288
6917
  option: "pubkey"
7289
6918
  }
7290
6919
  },
6920
+ {
6921
+ name: "new_flow_admin",
6922
+ type: {
6923
+ option: "pubkey"
6924
+ }
6925
+ },
7291
6926
  {
7292
6927
  name: "new_emissions_admin",
7293
6928
  type: {
@@ -7536,7 +7171,6 @@ var marginfi_0_1_7_default = {
7536
7171
  accounts: [
7537
7172
  {
7538
7173
  name: "group",
7539
- writable: true,
7540
7174
  relations: ["marginfi_account", "bank"]
7541
7175
  },
7542
7176
  {
@@ -7858,7 +7492,6 @@ var marginfi_0_1_7_default = {
7858
7492
  accounts: [
7859
7493
  {
7860
7494
  name: "group",
7861
- writable: true,
7862
7495
  relations: ["marginfi_account", "bank"]
7863
7496
  },
7864
7497
  {
@@ -8198,6 +7831,91 @@ var marginfi_0_1_7_default = {
8198
7831
  }
8199
7832
  ]
8200
7833
  },
7834
+ {
7835
+ name: "update_deleverage_withdrawals",
7836
+ docs: [
7837
+ "(delegate_flow_admin only) Update the deleverage daily withdraw outflow with",
7838
+ "aggregated data. The delegate flow admin aggregates",
7839
+ "`DeleverageWithdrawFlowEvent` events off-chain and calls this instruction at intervals."
7840
+ ],
7841
+ discriminator: [56, 3, 181, 118, 27, 247, 207, 227],
7842
+ accounts: [
7843
+ {
7844
+ name: "marginfi_group",
7845
+ writable: true
7846
+ },
7847
+ {
7848
+ name: "delegate_flow_admin",
7849
+ signer: true,
7850
+ relations: ["marginfi_group"]
7851
+ }
7852
+ ],
7853
+ args: [
7854
+ {
7855
+ name: "outflow_usd",
7856
+ type: "u32"
7857
+ },
7858
+ {
7859
+ name: "update_seq",
7860
+ type: "u64"
7861
+ },
7862
+ {
7863
+ name: "event_start_slot",
7864
+ type: "u64"
7865
+ },
7866
+ {
7867
+ name: "event_end_slot",
7868
+ type: "u64"
7869
+ }
7870
+ ]
7871
+ },
7872
+ {
7873
+ name: "update_group_rate_limiter",
7874
+ docs: [
7875
+ "(delegate_flow_admin only) Update the group rate limiter with aggregated",
7876
+ "inflow/outflow. The delegate flow admin aggregates",
7877
+ "`RateLimitFlowEvent` events off-chain, converts to USD, and calls this instruction at",
7878
+ "intervals to update group rate limiter state."
7879
+ ],
7880
+ discriminator: [23, 78, 60, 139, 187, 44, 129, 37],
7881
+ accounts: [
7882
+ {
7883
+ name: "marginfi_group",
7884
+ writable: true
7885
+ },
7886
+ {
7887
+ name: "delegate_flow_admin",
7888
+ signer: true,
7889
+ relations: ["marginfi_group"]
7890
+ }
7891
+ ],
7892
+ args: [
7893
+ {
7894
+ name: "outflow_usd",
7895
+ type: {
7896
+ option: "u64"
7897
+ }
7898
+ },
7899
+ {
7900
+ name: "inflow_usd",
7901
+ type: {
7902
+ option: "u64"
7903
+ }
7904
+ },
7905
+ {
7906
+ name: "update_seq",
7907
+ type: "u64"
7908
+ },
7909
+ {
7910
+ name: "event_start_slot",
7911
+ type: "u64"
7912
+ },
7913
+ {
7914
+ name: "event_end_slot",
7915
+ type: "u64"
7916
+ }
7917
+ ]
7918
+ },
8201
7919
  {
8202
7920
  name: "write_bank_metadata",
8203
7921
  docs: [
@@ -8308,6 +8026,10 @@ var marginfi_0_1_7_default = {
8308
8026
  name: "DeleverageEvent",
8309
8027
  discriminator: [161, 8, 108, 204, 209, 198, 12, 30]
8310
8028
  },
8029
+ {
8030
+ name: "DeleverageWithdrawFlowEvent",
8031
+ discriminator: [109, 90, 139, 200, 10, 204, 84, 176]
8032
+ },
8311
8033
  {
8312
8034
  name: "EditStakedSettingsEvent",
8313
8035
  discriminator: [29, 58, 155, 191, 75, 220, 145, 206]
@@ -8404,6 +8126,10 @@ var marginfi_0_1_7_default = {
8404
8126
  name: "MarginfiGroupCreateEvent",
8405
8127
  discriminator: [233, 125, 61, 14, 98, 240, 136, 253]
8406
8128
  },
8129
+ {
8130
+ name: "RateLimitFlowEvent",
8131
+ discriminator: [229, 5, 73, 200, 0, 107, 105, 109]
8132
+ },
8407
8133
  {
8408
8134
  name: "SetKeeperCloseFlagsEvent",
8409
8135
  discriminator: [193, 230, 93, 128, 117, 87, 96, 21]
@@ -9010,6 +8736,66 @@ var marginfi_0_1_7_default = {
9010
8736
  name: "InvalidRateLimitPrice",
9011
8737
  msg: "Invalid rate limit price: pass oracle or pre-crank cache"
9012
8738
  },
8739
+ {
8740
+ code: 6120,
8741
+ name: "GroupRateLimiterUpdateEmpty",
8742
+ msg: "Group rate limiter admin update must include inflow and/or outflow"
8743
+ },
8744
+ {
8745
+ code: 6121,
8746
+ name: "GroupRateLimiterUpdateInvalidSlotRange",
8747
+ msg: "Group rate limiter admin update slot range is invalid"
8748
+ },
8749
+ {
8750
+ code: 6122,
8751
+ name: "GroupRateLimiterUpdateFutureSlot",
8752
+ msg: "Group rate limiter admin update cannot reference future slots"
8753
+ },
8754
+ {
8755
+ code: 6123,
8756
+ name: "GroupRateLimiterUpdateStale",
8757
+ msg: "Group rate limiter admin update is too stale"
8758
+ },
8759
+ {
8760
+ code: 6124,
8761
+ name: "GroupRateLimiterUpdateOutOfOrderSlot",
8762
+ msg: "Group rate limiter admin update slot progression is out of order"
8763
+ },
8764
+ {
8765
+ code: 6125,
8766
+ name: "GroupRateLimiterUpdateOutOfOrderSeq",
8767
+ msg: "Group rate limiter admin update sequence is out of order"
8768
+ },
8769
+ {
8770
+ code: 6126,
8771
+ name: "DeleverageWithdrawalUpdateEmpty",
8772
+ msg: "Deleverage withdrawal admin update must include outflow"
8773
+ },
8774
+ {
8775
+ code: 6127,
8776
+ name: "DeleverageWithdrawalUpdateInvalidSlotRange",
8777
+ msg: "Deleverage withdrawal admin update slot range is invalid"
8778
+ },
8779
+ {
8780
+ code: 6128,
8781
+ name: "DeleverageWithdrawalUpdateFutureSlot",
8782
+ msg: "Deleverage withdrawal admin update cannot reference future slots"
8783
+ },
8784
+ {
8785
+ code: 6129,
8786
+ name: "DeleverageWithdrawalUpdateStale",
8787
+ msg: "Deleverage withdrawal admin update is too stale"
8788
+ },
8789
+ {
8790
+ code: 6130,
8791
+ name: "DeleverageWithdrawalUpdateOutOfOrderSlot",
8792
+ msg: "Deleverage withdrawal admin update slot progression is out of order"
8793
+ },
8794
+ {
8795
+ code: 6131,
8796
+ name: "DeleverageWithdrawalUpdateOutOfOrderSeq",
8797
+ msg: "Deleverage withdrawal admin update sequence is out of order"
8798
+ },
9013
8799
  {
9014
8800
  code: 6200,
9015
8801
  name: "WrongAssetTagForStandardInstructions",
@@ -9815,7 +9601,7 @@ var marginfi_0_1_7_default = {
9815
9601
  {
9816
9602
  name: "_pad_0",
9817
9603
  type: {
9818
- array: ["u8", 8]
9604
+ array: ["u8", 16]
9819
9605
  }
9820
9606
  },
9821
9607
  {
@@ -9933,8 +9719,10 @@ var marginfi_0_1_7_default = {
9933
9719
  "Liquidate as an additional safeguard, if the liquidation prices stored here were to be",
9934
9720
  "edited between start and end, it would completely break the risk engine. End validates that",
9935
9721
  "the lock is set, panics if not, and removes it - which prevents footguns if the cache was",
9936
- "e.g. accidently set to default. The lock is also removed when a Balance is closed with",
9937
- "repay_all or withdraw_all, since those Balances can be omitted from the risk check at End."
9722
+ "e.g. accidently set to default. The lock is also removed when a Balance is closed via",
9723
+ "withdraw_all, repay_all, or close_balance, but only when the account has",
9724
+ "ACCOUNT_IN_RECEIVERSHIP set, so that operations on unrelated accounts sharing the same",
9725
+ "bank do not interfere with an in-progress liquidation."
9938
9726
  ],
9939
9727
  type: "u8"
9940
9728
  },
@@ -10577,16 +10365,6 @@ var marginfi_0_1_7_default = {
10577
10365
  name: "RateLimitWindow"
10578
10366
  }
10579
10367
  }
10580
- },
10581
- {
10582
- name: "untracked_inflow",
10583
- docs: [
10584
- "Native token inflows pending USD conversion for group rate limiter.",
10585
- "When deposits/repays occur without a valid oracle price, the amount is",
10586
- "recorded here and later applied to the group rate limiter when a valid",
10587
- "price becomes available (e.g., during pulse_bank_price_cache or outflow operations)."
10588
- ],
10589
- type: "i64"
10590
10368
  }
10591
10369
  ]
10592
10370
  }
@@ -10615,6 +10393,41 @@ var marginfi_0_1_7_default = {
10615
10393
  ]
10616
10394
  }
10617
10395
  },
10396
+ {
10397
+ name: "DeleverageWithdrawFlowEvent",
10398
+ docs: [
10399
+ "Emitted for deleverage-only withdraw outflows.",
10400
+ "The delegate flow admin aggregates these off-chain and",
10401
+ "updates the deleverage daily withdraws via `update_deleverage_withdrawals`."
10402
+ ],
10403
+ type: {
10404
+ kind: "struct",
10405
+ fields: [
10406
+ {
10407
+ name: "group",
10408
+ type: "pubkey"
10409
+ },
10410
+ {
10411
+ name: "bank",
10412
+ type: "pubkey"
10413
+ },
10414
+ {
10415
+ name: "mint",
10416
+ type: "pubkey"
10417
+ },
10418
+ {
10419
+ name: "outflow_usd",
10420
+ docs: ["Equity-denominated outflow value in USD, rounded to integer."],
10421
+ type: "u32"
10422
+ },
10423
+ {
10424
+ name: "current_timestamp",
10425
+ docs: ["Unix timestamp when the flow was recorded"],
10426
+ type: "i64"
10427
+ }
10428
+ ]
10429
+ }
10430
+ },
10618
10431
  {
10619
10432
  name: "DriftConfigCompact",
10620
10433
  docs: [
@@ -11923,7 +11736,7 @@ var marginfi_0_1_7_default = {
11923
11736
  "(i.e. no implicit padding). This is important because `Pubkey` has alignment=1 while `u64`",
11924
11737
  "has alignment=8; using plain `repr(C)` would insert padding before the first `u64`."
11925
11738
  ],
11926
- serialization: "bytemuckunsafe",
11739
+ serialization: "bytemuck",
11927
11740
  repr: {
11928
11741
  kind: "c",
11929
11742
  packed: true
@@ -12770,12 +12583,7 @@ var marginfi_0_1_7_default = {
12770
12583
  },
12771
12584
  {
12772
12585
  name: "emissions_destination_account",
12773
- docs: [
12774
- "Set with `update_emissions_destination_account`. Emissions rewards can be withdrawn to the",
12775
- "canonical ATA of this wallet without the user's input (withdraw_emissions_permissionless).",
12776
- "If pubkey default, the user has not opted into this feature, and must claim emissions",
12777
- "manually (withdraw_emissions)."
12778
- ],
12586
+ docs: ["Wallet whose canonical ATA receives off-chain emissions distributions."],
12779
12587
  type: "pubkey"
12780
12588
  },
12781
12589
  {
@@ -13048,7 +12856,7 @@ var marginfi_0_1_7_default = {
13048
12856
  name: "emode_admin",
13049
12857
  docs: [
13050
12858
  "This admin can configure collateral ratios above (but not below) the collateral ratio of",
13051
- "certain banks , e.g. allow SOL to count as 90% collateral when borrowing an LST instead of",
12859
+ "certain banks, e.g. allow SOL to count as 90% collateral when borrowing an LST instead of",
13052
12860
  "the default rate."
13053
12861
  ],
13054
12862
  type: "pubkey"
@@ -13149,6 +12957,40 @@ var marginfi_0_1_7_default = {
13149
12957
  }
13150
12958
  }
13151
12959
  },
12960
+ {
12961
+ name: "rate_limiter_last_admin_update_slot",
12962
+ docs: ["Last slot covered by an admin group rate limiter aggregation update."],
12963
+ type: "u64"
12964
+ },
12965
+ {
12966
+ name: "rate_limiter_last_admin_update_seq",
12967
+ docs: [
12968
+ "Monotonic sequence number for admin group rate limiter updates.",
12969
+ "This is used to enforce strict ordering and prevent duplicate/replayed batches",
12970
+ "when slot ranges overlap or multiple updates happen in the same slot."
12971
+ ],
12972
+ type: "u64"
12973
+ },
12974
+ {
12975
+ name: "deleverage_withdraw_last_admin_update_slot",
12976
+ docs: ["Last slot covered by an admin deleverage withdraw-limit aggregation update."],
12977
+ type: "u64"
12978
+ },
12979
+ {
12980
+ name: "deleverage_withdraw_last_admin_update_seq",
12981
+ docs: ["Monotonic sequence number for admin deleverage withdraw-limit updates."],
12982
+ type: "u64"
12983
+ },
12984
+ {
12985
+ name: "delegate_flow_admin",
12986
+ docs: [
12987
+ "Can modify flow-control status for the group, i.e. update the withdraw caches with flow",
12988
+ "information from banks. Typically this is a hot wallet that lives in e.g. some cron job. If",
12989
+ "compromised, flow control can be effectively disabled until the admin is restored, which",
12990
+ "does not itself compromise any funds, and is merely annoying."
12991
+ ],
12992
+ type: "pubkey"
12993
+ },
13152
12994
  {
13153
12995
  name: "_padding_0",
13154
12996
  type: {
@@ -13156,7 +12998,7 @@ var marginfi_0_1_7_default = {
13156
12998
  {
13157
12999
  array: ["u64", 2]
13158
13000
  },
13159
- 6
13001
+ 2
13160
13002
  ]
13161
13003
  }
13162
13004
  },
@@ -14267,6 +14109,50 @@ var marginfi_0_1_7_default = {
14267
14109
  ]
14268
14110
  }
14269
14111
  },
14112
+ {
14113
+ name: "RateLimitFlowEvent",
14114
+ docs: [
14115
+ "Emitted when a bank-level inflow or outflow is recorded.",
14116
+ "The delegate flow admin aggregates these off-chain and",
14117
+ "updates the group rate limiter via `update_group_rate_limiter`."
14118
+ ],
14119
+ type: {
14120
+ kind: "struct",
14121
+ fields: [
14122
+ {
14123
+ name: "group",
14124
+ type: "pubkey"
14125
+ },
14126
+ {
14127
+ name: "bank",
14128
+ type: "pubkey"
14129
+ },
14130
+ {
14131
+ name: "mint",
14132
+ type: "pubkey"
14133
+ },
14134
+ {
14135
+ name: "flow_direction",
14136
+ docs: ["0 = outflow (withdraw/borrow), 1 = inflow (deposit/repay)"],
14137
+ type: "u8"
14138
+ },
14139
+ {
14140
+ name: "native_amount",
14141
+ docs: ["Amount in native tokens"],
14142
+ type: "u64"
14143
+ },
14144
+ {
14145
+ name: "mint_decimals",
14146
+ type: "u8"
14147
+ },
14148
+ {
14149
+ name: "current_timestamp",
14150
+ docs: ["Unix timestamp when the flow was recorded"],
14151
+ type: "i64"
14152
+ }
14153
+ ]
14154
+ }
14155
+ },
14270
14156
  {
14271
14157
  name: "RateLimitWindow",
14272
14158
  docs: [
@@ -14989,7 +14875,7 @@ var marginfi_0_1_7_default = {
14989
14875
  };
14990
14876
 
14991
14877
  // src/idl/index.ts
14992
- var MARGINFI_IDL = marginfi_0_1_7_default;
14878
+ var MARGINFI_IDL = marginfi_0_1_8_default;
14993
14879
  function decodeInstruction(idl, encoded) {
14994
14880
  const coder = new anchor.BorshInstructionCoder(idl);
14995
14881
  return coder.decode(encoded, "base58");
@@ -15517,7 +15403,6 @@ async function makeKaminoWithdrawIx(mfProgram, accounts, args, remainingAccounts
15517
15403
  bank,
15518
15404
  destinationTokenAccount,
15519
15405
  lendingMarket,
15520
- reserveLiquidityMint,
15521
15406
  lendingMarketAuthority,
15522
15407
  reserveLiquiditySupply,
15523
15408
  reserveCollateralMint,
@@ -15532,7 +15417,6 @@ async function makeKaminoWithdrawIx(mfProgram, accounts, args, remainingAccounts
15532
15417
  bank,
15533
15418
  destinationTokenAccount,
15534
15419
  lendingMarket,
15535
- reserveLiquidityMint,
15536
15420
  lendingMarketAuthority,
15537
15421
  reserveLiquiditySupply,
15538
15422
  reserveCollateralMint,
@@ -15577,14 +15461,11 @@ function makeLendingAccountLiquidateIx(mfiProgram, accounts, args, remainingAcco
15577
15461
  tokenProgram
15578
15462
  }).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
15579
15463
  }
15580
- function makelendingAccountWithdrawEmissionIx(mfiProgram, accounts) {
15581
- const { marginfiAccount, destinationAccount, bank, tokenProgram, ...optionalAccounts } = accounts;
15582
- return mfiProgram.methods.lendingAccountWithdrawEmissions().accounts({
15583
- marginfiAccount,
15584
- destinationAccount,
15585
- bank,
15586
- tokenProgram
15587
- }).accountsPartial(optionalAccounts).instruction();
15464
+ function makeLendingAccountClearEmissionsIx(mfiProgram, accounts) {
15465
+ return mfiProgram.methods.lendingAccountClearEmissions().accounts({
15466
+ marginfiAccount: accounts.marginfiAccount,
15467
+ bank: accounts.bank
15468
+ }).instruction();
15588
15469
  }
15589
15470
  function makePoolConfigureBankIx(mfiProgram, accounts, args) {
15590
15471
  const { bank, ...optionalAccounts } = accounts;
@@ -15684,7 +15565,7 @@ var instructions = {
15684
15565
  makeInitMarginfiAccountIx,
15685
15566
  makeInitMarginfiAccountPdaIx,
15686
15567
  makeLendingAccountLiquidateIx,
15687
- makelendingAccountWithdrawEmissionIx,
15568
+ makeLendingAccountClearEmissionsIx,
15688
15569
  makePoolAddBankIx,
15689
15570
  makePoolConfigureBankIx,
15690
15571
  makeBeginFlashLoanIx,
@@ -43944,7 +43825,7 @@ var SEED_RESERVE = "reserve";
43944
43825
  var SEED_RATE_MODEL = "rate_model";
43945
43826
  var SEED_USER_SUPPLY_POSITION = "user_supply_position";
43946
43827
  var SEED_LENDING_REWARDS_RATE_MODEL = "lending_rewards_rate_model";
43947
- function getAllDerivedJupLendAccounts(mint) {
43828
+ function getAllDerivedJupLendAccounts(mint, tokenProgram) {
43948
43829
  const [fTokenMint] = deriveJupLendFTokenMint(mint);
43949
43830
  const [lending] = deriveJupLendLending(mint, fTokenMint);
43950
43831
  const [liquidity] = deriveJupLendLiquidity();
@@ -43954,7 +43835,7 @@ function getAllDerivedJupLendAccounts(mint) {
43954
43835
  supplyTokenReservesLiquidity: deriveJupLendTokenReserve(mint)[0],
43955
43836
  lendingSupplyPositionOnLiquidity: deriveJupLendLiquiditySupplyPositionPda(mint, lending)[0],
43956
43837
  rateModel: deriveJupLendRateModel(mint)[0],
43957
- vault: deriveJupLendLiquidityVaultAta(mint, liquidity),
43838
+ vault: deriveJupLendLiquidityVaultAta(mint, liquidity, tokenProgram),
43958
43839
  liquidity,
43959
43840
  rewardsRateModel: deriveJupLendLendingRewardsRateModel(mint)[0]
43960
43841
  };
@@ -44401,7 +44282,7 @@ var DISCRIMINATORS = {
44401
44282
  LENDING_ACCOUNT_WITHDRAW: Buffer.from([36, 72, 74, 19, 210, 210, 192, 192]),
44402
44283
  LENDING_ACCOUNT_BORROW: Buffer.from([4, 126, 116, 53, 48, 5, 212, 31]),
44403
44284
  LENDING_ACCOUNT_LIQUIDATE: Buffer.from([214, 169, 151, 213, 251, 167, 86, 219]),
44404
- LENDING_ACCOUNT_WITHDRAW_EMISSIONS: Buffer.from([234, 22, 84, 214, 118, 176, 140, 170]),
44285
+ LENDING_ACCOUNT_CLEAR_EMISSIONS: Buffer.from([239, 4, 221, 98, 45, 167, 201, 244]),
44405
44286
  LENDING_POOL_ADD_BANK: Buffer.from([215, 68, 72, 78, 208, 218, 103, 182]),
44406
44287
  LENDING_POOL_CONFIGURE_BANK: Buffer.from([121, 173, 156, 40, 93, 148, 56, 237]),
44407
44288
  LENDING_ACCOUNT_START_FLASHLOAN: Buffer.from([14, 131, 33, 220, 81, 186, 180, 107]),
@@ -44488,7 +44369,7 @@ function makeWithdrawIx2(programId, accounts, args, remainingAccounts = []) {
44488
44369
  const [bankLiquidityVaultAuthority] = deriveBankLiquidityVaultAuthority(programId, accounts.bank);
44489
44370
  const [liquidityVault] = deriveBankLiquidityVault(programId, accounts.bank);
44490
44371
  const keys = [
44491
- { pubkey: accounts.group, isSigner: false, isWritable: true },
44372
+ { pubkey: accounts.group, isSigner: false, isWritable: false },
44492
44373
  { pubkey: accounts.marginfiAccount, isSigner: false, isWritable: true },
44493
44374
  { pubkey: accounts.authority, isSigner: true, isWritable: false },
44494
44375
  { pubkey: accounts.bank, isSigner: false, isWritable: true },
@@ -44644,7 +44525,7 @@ function makeKaminoWithdrawIx2(programId, accounts, args, remainingAccounts = []
44644
44525
  const liquidityVaultAuthority = deriveBankLiquidityVaultAuthority(programId, accounts.bank)[0];
44645
44526
  const liquidityVault = deriveBankLiquidityVault(programId, accounts.bank)[0];
44646
44527
  const keys = [
44647
- { pubkey: accounts.group, isSigner: false, isWritable: true },
44528
+ { pubkey: accounts.group, isSigner: false, isWritable: false },
44648
44529
  { pubkey: accounts.marginfiAccount, isSigner: false, isWritable: true },
44649
44530
  { pubkey: accounts.authority, isSigner: true, isWritable: false },
44650
44531
  { pubkey: accounts.bank, isSigner: false, isWritable: true },
@@ -44664,7 +44545,7 @@ function makeKaminoWithdrawIx2(programId, accounts, args, remainingAccounts = []
44664
44545
  },
44665
44546
  { pubkey: accounts.integrationAcc1, isSigner: false, isWritable: true },
44666
44547
  {
44667
- pubkey: accounts.reserveLiquidityMint,
44548
+ pubkey: accounts.mint,
44668
44549
  isSigner: false,
44669
44550
  isWritable: true
44670
44551
  },
@@ -44751,22 +44632,15 @@ function makeLendingAccountLiquidateIx2(programId, accounts, args, remainingAcco
44751
44632
  ]);
44752
44633
  return new web3_js.TransactionInstruction({ keys, programId, data });
44753
44634
  }
44754
- function makelendingAccountWithdrawEmissionIx2(programId, accounts) {
44635
+ function makeLendingAccountClearEmissionsIx2(programId, accounts) {
44755
44636
  const keys = [
44756
- { pubkey: accounts.group, isSigner: false, isWritable: false },
44757
44637
  { pubkey: accounts.marginfiAccount, isSigner: false, isWritable: true },
44758
- { pubkey: accounts.authority, isSigner: true, isWritable: false },
44759
- { pubkey: accounts.bank, isSigner: false, isWritable: true },
44760
- { pubkey: accounts.emissionsMint, isSigner: false, isWritable: false },
44761
- { pubkey: accounts.emissionsAuth, isSigner: false, isWritable: false },
44762
- { pubkey: accounts.emissionsVault, isSigner: false, isWritable: true },
44763
- { pubkey: accounts.destinationAccount, isSigner: false, isWritable: true },
44764
- { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false }
44638
+ { pubkey: accounts.bank, isSigner: false, isWritable: false }
44765
44639
  ];
44766
44640
  return new web3_js.TransactionInstruction({
44767
44641
  keys,
44768
44642
  programId,
44769
- data: DISCRIMINATORS.LENDING_ACCOUNT_WITHDRAW_EMISSIONS
44643
+ data: DISCRIMINATORS.LENDING_ACCOUNT_CLEAR_EMISSIONS
44770
44644
  });
44771
44645
  }
44772
44646
  function makeCloseAccountIx2(programId, accounts) {
@@ -44929,7 +44803,7 @@ function makeDriftWithdrawIx2(programId, accounts, args, remainingAccounts = [])
44929
44803
  const DRIFT_PROGRAM_ID2 = new web3_js.PublicKey("dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH");
44930
44804
  const SYSTEM_PROGRAM_ID2 = new web3_js.PublicKey("11111111111111111111111111111111");
44931
44805
  const keys = [
44932
- { pubkey: accounts.group, isSigner: false, isWritable: true },
44806
+ { pubkey: accounts.group, isSigner: false, isWritable: false },
44933
44807
  { pubkey: accounts.marginfiAccount, isSigner: false, isWritable: true },
44934
44808
  { pubkey: accounts.authority, isSigner: true, isWritable: false },
44935
44809
  { pubkey: accounts.bank, isSigner: false, isWritable: true }
@@ -45064,7 +44938,7 @@ var syncInstructions = {
45064
44938
  makeKaminoWithdrawIx: makeKaminoWithdrawIx2,
45065
44939
  makeBorrowIx: makeBorrowIx2,
45066
44940
  makeLendingAccountLiquidateIx: makeLendingAccountLiquidateIx2,
45067
- makelendingAccountWithdrawEmissionIx: makelendingAccountWithdrawEmissionIx2,
44941
+ makeLendingAccountClearEmissionsIx: makeLendingAccountClearEmissionsIx2,
45068
44942
  makePoolAddBankIx: makePoolAddBankIx2,
45069
44943
  makePoolConfigureBankIx: makePoolConfigureBankIx2,
45070
44944
  makeBeginFlashLoanIx: makeBeginFlashLoanIx2,
@@ -45356,7 +45230,7 @@ async function makeKaminoWithdrawIx3({
45356
45230
  lendingMarket,
45357
45231
  lendingMarketAuthority,
45358
45232
  integrationAcc1: bank.kaminoIntegrationAccounts.kaminoReserve,
45359
- reserveLiquidityMint: bank.mint,
45233
+ mint: bank.mint,
45360
45234
  reserveLiquiditySupply,
45361
45235
  reserveCollateralMint,
45362
45236
  reserveSourceCollateral: reserveDestinationDepositCollateral,
@@ -45380,7 +45254,7 @@ async function makeKaminoWithdrawIx3({
45380
45254
  bank: bank.address,
45381
45255
  destinationTokenAccount: userTokenAtaPk,
45382
45256
  lendingMarket,
45383
- reserveLiquidityMint: bank.mint,
45257
+ mint: bank.mint,
45384
45258
  lendingMarketAuthority,
45385
45259
  reserveLiquiditySupply,
45386
45260
  reserveCollateralMint,
@@ -45701,7 +45575,7 @@ async function makeJuplendWithdrawIx2({
45701
45575
  lendingAdmin,
45702
45576
  rateModel,
45703
45577
  vault,
45704
- liquidity} = getAllDerivedJupLendAccounts(bank.mint);
45578
+ liquidity} = getAllDerivedJupLendAccounts(bank.mint, tokenProgram);
45705
45579
  if (opts.observationBanksOverride) {
45706
45580
  remainingAccounts.push(...opts.observationBanksOverride);
45707
45581
  } else {
@@ -46324,7 +46198,7 @@ async function makeJuplendDepositIx2({
46324
46198
  if (!bank.jupLendIntegrationAccounts) {
46325
46199
  throw new Error("Bank has no JupLend integration accounts");
46326
46200
  }
46327
- const derivedAccounts = getAllDerivedJupLendAccounts(bank.mint);
46201
+ const derivedAccounts = getAllDerivedJupLendAccounts(bank.mint, tokenProgram);
46328
46202
  const {
46329
46203
  fTokenMint,
46330
46204
  lendingAdmin,
@@ -47273,37 +47147,14 @@ async function buildRepayWithCollatFlashloanTx({
47273
47147
  }
47274
47148
 
47275
47149
  // src/services/account/actions/emissions.ts
47276
- async function makeWithdrawEmissionsIx(program, marginfiAccount, banks, mintDatas, bankAddress) {
47150
+ async function makeClearEmissionsIx(program, marginfiAccount, banks, bankAddress) {
47277
47151
  const bank = banks.get(bankAddress.toBase58());
47278
47152
  if (!bank) throw Error(`Bank ${bankAddress.toBase58()} not found`);
47279
- const mintData = mintDatas.get(bankAddress.toBase58());
47280
- if (!mintData) throw Error(`Mint data for bank ${bankAddress.toBase58()} not found`);
47281
- if (!mintData.emissionTokenProgram) {
47282
- throw Error(`Emission token program not found for bank ${bankAddress.toBase58()}`);
47283
- }
47284
- let ixs = [];
47285
- const userAta = getAssociatedTokenAddressSync(
47286
- bank.emissionsMint,
47287
- marginfiAccount.authority,
47288
- true,
47289
- mintData.emissionTokenProgram
47290
- );
47291
- const createAtaIdempotentIx = createAssociatedTokenAccountIdempotentInstruction(
47292
- marginfiAccount.authority,
47293
- userAta,
47294
- marginfiAccount.authority,
47295
- bank.emissionsMint,
47296
- mintData.emissionTokenProgram
47297
- );
47298
- ixs.push(createAtaIdempotentIx);
47299
- const withdrawEmissionsIx = await instructions_default.makelendingAccountWithdrawEmissionIx(program, {
47153
+ const clearEmissionsIx = await instructions_default.makeLendingAccountClearEmissionsIx(program, {
47300
47154
  marginfiAccount: marginfiAccount.address,
47301
- destinationAccount: userAta,
47302
- bank: bank.address,
47303
- tokenProgram: mintData.emissionTokenProgram
47155
+ bank: bank.address
47304
47156
  });
47305
- ixs.push(withdrawEmissionsIx);
47306
- return { instructions: ixs, keys: [] };
47157
+ return { instructions: [clearEmissionsIx], keys: [] };
47307
47158
  }
47308
47159
  async function makeSwapCollateralTx(params) {
47309
47160
  const {
@@ -51883,15 +51734,14 @@ var MarginfiAccount = class _MarginfiAccount {
51883
51734
  *
51884
51735
  * @param program - The Marginfi program instance
51885
51736
  * @param banks - Map of all available banks
51886
- * @param mintDatas - Map of mint data for token programs
51887
- * @param bankAddress - The bank to withdraw emissions from
51737
+ * @param bankAddress - The bank to clear emissions for
51888
51738
  *
51889
- * @returns Promise resolving to InstructionsWrapper containing the withdraw emissions instructions
51739
+ * @returns Promise resolving to InstructionsWrapper containing the clear emissions instructions
51890
51740
  *
51891
- * @see {@link makeWithdrawEmissionsIx} for implementation
51741
+ * @see {@link makeClearEmissionsIx} for implementation
51892
51742
  */
51893
- async makeWithdrawEmissionsIx(program, banks, mintDatas, bankAddress) {
51894
- return makeWithdrawEmissionsIx(program, this, banks, mintDatas, bankAddress);
51743
+ async makeClearEmissionsIx(program, banks, bankAddress) {
51744
+ return makeClearEmissionsIx(program, this, banks, bankAddress);
51895
51745
  }
51896
51746
  /**
51897
51747
  * Creates an instruction to begin a flash loan.
@@ -52574,17 +52424,12 @@ var MarginfiAccountWrapper = class {
52574
52424
  });
52575
52425
  }
52576
52426
  /**
52577
- * Creates a withdraw emissions instruction with auto-injected client data.
52427
+ * Creates a clear emissions instruction with auto-injected client data.
52578
52428
  *
52579
- * @param bankAddress - Bank address to withdraw emissions from
52429
+ * @param bankAddress - Bank address to clear emissions for
52580
52430
  */
52581
- async makeWithdrawEmissionsIx(bankAddress) {
52582
- return this.account.makeWithdrawEmissionsIx(
52583
- this.client.program,
52584
- this.client.bankMap,
52585
- this.client.mintDataByBank,
52586
- bankAddress
52587
- );
52431
+ async makeClearEmissionsIx(bankAddress) {
52432
+ return this.account.makeClearEmissionsIx(this.client.program, this.client.bankMap, bankAddress);
52588
52433
  }
52589
52434
  /**
52590
52435
  * Creates a begin flash loan instruction.
@@ -53659,6 +53504,7 @@ exports.makeBeginFlashLoanIx = makeBeginFlashLoanIx3;
53659
53504
  exports.makeBorrowIx = makeBorrowIx3;
53660
53505
  exports.makeBorrowTx = makeBorrowTx;
53661
53506
  exports.makeBundleTipIx = makeBundleTipIx;
53507
+ exports.makeClearEmissionsIx = makeClearEmissionsIx;
53662
53508
  exports.makeCloseMarginfiAccountIx = makeCloseMarginfiAccountIx;
53663
53509
  exports.makeCloseMarginfiAccountTx = makeCloseMarginfiAccountTx;
53664
53510
  exports.makeCrankSwbFeedIx = makeCrankSwbFeedIx;
@@ -53702,7 +53548,6 @@ exports.makeUpdateDriftMarketIxs = makeUpdateDriftMarketIxs;
53702
53548
  exports.makeUpdateJupLendRateIxs = makeUpdateJupLendRateIxs;
53703
53549
  exports.makeUpdateSwbFeedIx = makeUpdateSwbFeedIx;
53704
53550
  exports.makeVersionedTransaction = makeVersionedTransaction;
53705
- exports.makeWithdrawEmissionsIx = makeWithdrawEmissionsIx;
53706
53551
  exports.makeWithdrawIx = makeWithdrawIx3;
53707
53552
  exports.makeWithdrawTx = makeWithdrawTx;
53708
53553
  exports.makeWrapSolIxs = makeWrapSolIxs;