@meteora-ag/cp-amm-sdk 1.2.6 → 1.2.8
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.d.mts +1797 -970
- package/dist/index.d.ts +1797 -970
- package/dist/index.js +1589 -688
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1696 -795
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -1
package/dist/index.mjs
CHANGED
|
@@ -40,8 +40,8 @@ var __async = (__this, __arguments, generator) => {
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
// src/CpAmm.ts
|
|
43
|
-
import { Program } from "@coral-xyz/anchor";
|
|
44
|
-
import { NATIVE_MINT as NATIVE_MINT2, TOKEN_2022_PROGRAM_ID as
|
|
43
|
+
import { Program as Program2 } from "@coral-xyz/anchor";
|
|
44
|
+
import { NATIVE_MINT as NATIVE_MINT2, TOKEN_2022_PROGRAM_ID as TOKEN_2022_PROGRAM_ID3 } from "@solana/spl-token";
|
|
45
45
|
import invariant from "invariant";
|
|
46
46
|
|
|
47
47
|
// src/idl/cp_amm.json
|
|
@@ -49,7 +49,7 @@ var cp_amm_default = {
|
|
|
49
49
|
address: "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG",
|
|
50
50
|
metadata: {
|
|
51
51
|
name: "cp_amm",
|
|
52
|
-
version: "0.1.
|
|
52
|
+
version: "0.1.6",
|
|
53
53
|
spec: "0.1.0",
|
|
54
54
|
description: "Created with Anchor"
|
|
55
55
|
},
|
|
@@ -720,19 +720,19 @@ var cp_amm_default = {
|
|
|
720
720
|
}
|
|
721
721
|
},
|
|
722
722
|
{
|
|
723
|
-
name: "
|
|
723
|
+
name: "operator",
|
|
724
724
|
docs: [
|
|
725
725
|
"Claim fee operator"
|
|
726
726
|
]
|
|
727
727
|
},
|
|
728
728
|
{
|
|
729
|
-
name: "
|
|
729
|
+
name: "whitelisted_address",
|
|
730
730
|
docs: [
|
|
731
731
|
"Operator"
|
|
732
732
|
],
|
|
733
733
|
signer: true,
|
|
734
734
|
relations: [
|
|
735
|
-
"
|
|
735
|
+
"operator"
|
|
736
736
|
]
|
|
737
737
|
},
|
|
738
738
|
{
|
|
@@ -894,29 +894,35 @@ var cp_amm_default = {
|
|
|
894
894
|
]
|
|
895
895
|
},
|
|
896
896
|
{
|
|
897
|
-
name: "
|
|
897
|
+
name: "close_config",
|
|
898
898
|
discriminator: [
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
899
|
+
145,
|
|
900
|
+
9,
|
|
901
|
+
72,
|
|
902
|
+
157,
|
|
903
903
|
95,
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
904
|
+
125,
|
|
905
|
+
61,
|
|
906
|
+
85
|
|
907
907
|
],
|
|
908
908
|
accounts: [
|
|
909
909
|
{
|
|
910
|
-
name: "
|
|
910
|
+
name: "config",
|
|
911
911
|
writable: true
|
|
912
912
|
},
|
|
913
913
|
{
|
|
914
|
-
name: "
|
|
915
|
-
writable: true
|
|
914
|
+
name: "operator"
|
|
916
915
|
},
|
|
917
916
|
{
|
|
918
|
-
name: "
|
|
919
|
-
signer: true
|
|
917
|
+
name: "whitelisted_address",
|
|
918
|
+
signer: true,
|
|
919
|
+
relations: [
|
|
920
|
+
"operator"
|
|
921
|
+
]
|
|
922
|
+
},
|
|
923
|
+
{
|
|
924
|
+
name: "rent_receiver",
|
|
925
|
+
writable: true
|
|
920
926
|
},
|
|
921
927
|
{
|
|
922
928
|
name: "event_authority",
|
|
@@ -954,25 +960,24 @@ var cp_amm_default = {
|
|
|
954
960
|
args: []
|
|
955
961
|
},
|
|
956
962
|
{
|
|
957
|
-
name: "
|
|
963
|
+
name: "close_operator_account",
|
|
958
964
|
discriminator: [
|
|
959
|
-
|
|
965
|
+
171,
|
|
960
966
|
9,
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
+
213,
|
|
968
|
+
74,
|
|
969
|
+
120,
|
|
970
|
+
23,
|
|
971
|
+
3,
|
|
972
|
+
29
|
|
967
973
|
],
|
|
968
974
|
accounts: [
|
|
969
975
|
{
|
|
970
|
-
name: "
|
|
976
|
+
name: "operator",
|
|
971
977
|
writable: true
|
|
972
978
|
},
|
|
973
979
|
{
|
|
974
980
|
name: "admin",
|
|
975
|
-
writable: true,
|
|
976
981
|
signer: true
|
|
977
982
|
},
|
|
978
983
|
{
|
|
@@ -1127,9 +1132,14 @@ var cp_amm_default = {
|
|
|
1127
1132
|
writable: true
|
|
1128
1133
|
},
|
|
1129
1134
|
{
|
|
1130
|
-
name: "
|
|
1131
|
-
|
|
1132
|
-
|
|
1135
|
+
name: "operator"
|
|
1136
|
+
},
|
|
1137
|
+
{
|
|
1138
|
+
name: "whitelisted_address",
|
|
1139
|
+
signer: true,
|
|
1140
|
+
relations: [
|
|
1141
|
+
"operator"
|
|
1142
|
+
]
|
|
1133
1143
|
},
|
|
1134
1144
|
{
|
|
1135
1145
|
name: "rent_receiver",
|
|
@@ -1171,20 +1181,23 @@ var cp_amm_default = {
|
|
|
1171
1181
|
args: []
|
|
1172
1182
|
},
|
|
1173
1183
|
{
|
|
1174
|
-
name: "
|
|
1184
|
+
name: "create_config",
|
|
1185
|
+
docs: [
|
|
1186
|
+
"OPERATOR FUNCTIONS /////"
|
|
1187
|
+
],
|
|
1175
1188
|
discriminator: [
|
|
1176
|
-
|
|
1177
|
-
62,
|
|
1189
|
+
201,
|
|
1178
1190
|
207,
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1191
|
+
243,
|
|
1192
|
+
114,
|
|
1193
|
+
75,
|
|
1194
|
+
111,
|
|
1195
|
+
47,
|
|
1196
|
+
189
|
|
1184
1197
|
],
|
|
1185
1198
|
accounts: [
|
|
1186
1199
|
{
|
|
1187
|
-
name: "
|
|
1200
|
+
name: "config",
|
|
1188
1201
|
writable: true,
|
|
1189
1202
|
pda: {
|
|
1190
1203
|
seeds: [
|
|
@@ -1192,21 +1205,16 @@ var cp_amm_default = {
|
|
|
1192
1205
|
kind: "const",
|
|
1193
1206
|
value: [
|
|
1194
1207
|
99,
|
|
1195
|
-
102,
|
|
1196
|
-
95,
|
|
1197
|
-
111,
|
|
1198
|
-
112,
|
|
1199
|
-
101,
|
|
1200
|
-
114,
|
|
1201
|
-
97,
|
|
1202
|
-
116,
|
|
1203
1208
|
111,
|
|
1204
|
-
|
|
1209
|
+
110,
|
|
1210
|
+
102,
|
|
1211
|
+
105,
|
|
1212
|
+
103
|
|
1205
1213
|
]
|
|
1206
1214
|
},
|
|
1207
1215
|
{
|
|
1208
|
-
kind: "
|
|
1209
|
-
path: "
|
|
1216
|
+
kind: "arg",
|
|
1217
|
+
path: "index"
|
|
1210
1218
|
}
|
|
1211
1219
|
]
|
|
1212
1220
|
}
|
|
@@ -1215,7 +1223,14 @@ var cp_amm_default = {
|
|
|
1215
1223
|
name: "operator"
|
|
1216
1224
|
},
|
|
1217
1225
|
{
|
|
1218
|
-
name: "
|
|
1226
|
+
name: "whitelisted_address",
|
|
1227
|
+
signer: true,
|
|
1228
|
+
relations: [
|
|
1229
|
+
"operator"
|
|
1230
|
+
]
|
|
1231
|
+
},
|
|
1232
|
+
{
|
|
1233
|
+
name: "payer",
|
|
1219
1234
|
writable: true,
|
|
1220
1235
|
signer: true
|
|
1221
1236
|
},
|
|
@@ -1256,22 +1271,32 @@ var cp_amm_default = {
|
|
|
1256
1271
|
name: "program"
|
|
1257
1272
|
}
|
|
1258
1273
|
],
|
|
1259
|
-
args: [
|
|
1274
|
+
args: [
|
|
1275
|
+
{
|
|
1276
|
+
name: "index",
|
|
1277
|
+
type: "u64"
|
|
1278
|
+
},
|
|
1279
|
+
{
|
|
1280
|
+
name: "config_parameters",
|
|
1281
|
+
type: {
|
|
1282
|
+
defined: {
|
|
1283
|
+
name: "StaticConfigParameters"
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
]
|
|
1260
1288
|
},
|
|
1261
1289
|
{
|
|
1262
|
-
name: "
|
|
1263
|
-
docs: [
|
|
1264
|
-
"ADMIN FUNCTIONS /////"
|
|
1265
|
-
],
|
|
1290
|
+
name: "create_dynamic_config",
|
|
1266
1291
|
discriminator: [
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1292
|
+
81,
|
|
1293
|
+
251,
|
|
1294
|
+
122,
|
|
1295
|
+
78,
|
|
1296
|
+
66,
|
|
1297
|
+
57,
|
|
1298
|
+
208,
|
|
1299
|
+
82
|
|
1275
1300
|
],
|
|
1276
1301
|
accounts: [
|
|
1277
1302
|
{
|
|
@@ -1298,7 +1323,17 @@ var cp_amm_default = {
|
|
|
1298
1323
|
}
|
|
1299
1324
|
},
|
|
1300
1325
|
{
|
|
1301
|
-
name: "
|
|
1326
|
+
name: "operator"
|
|
1327
|
+
},
|
|
1328
|
+
{
|
|
1329
|
+
name: "whitelisted_address",
|
|
1330
|
+
signer: true,
|
|
1331
|
+
relations: [
|
|
1332
|
+
"operator"
|
|
1333
|
+
]
|
|
1334
|
+
},
|
|
1335
|
+
{
|
|
1336
|
+
name: "payer",
|
|
1302
1337
|
writable: true,
|
|
1303
1338
|
signer: true
|
|
1304
1339
|
},
|
|
@@ -1348,50 +1383,62 @@ var cp_amm_default = {
|
|
|
1348
1383
|
name: "config_parameters",
|
|
1349
1384
|
type: {
|
|
1350
1385
|
defined: {
|
|
1351
|
-
name: "
|
|
1386
|
+
name: "DynamicConfigParameters"
|
|
1352
1387
|
}
|
|
1353
1388
|
}
|
|
1354
1389
|
}
|
|
1355
1390
|
]
|
|
1356
1391
|
},
|
|
1357
1392
|
{
|
|
1358
|
-
name: "
|
|
1393
|
+
name: "create_operator_account",
|
|
1394
|
+
docs: [
|
|
1395
|
+
"ADMIN FUNCTIONS /////"
|
|
1396
|
+
],
|
|
1359
1397
|
discriminator: [
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1398
|
+
221,
|
|
1399
|
+
64,
|
|
1400
|
+
246,
|
|
1401
|
+
149,
|
|
1402
|
+
240,
|
|
1403
|
+
153,
|
|
1404
|
+
229,
|
|
1405
|
+
163
|
|
1368
1406
|
],
|
|
1369
1407
|
accounts: [
|
|
1370
1408
|
{
|
|
1371
|
-
name: "
|
|
1409
|
+
name: "operator",
|
|
1372
1410
|
writable: true,
|
|
1373
1411
|
pda: {
|
|
1374
1412
|
seeds: [
|
|
1375
1413
|
{
|
|
1376
1414
|
kind: "const",
|
|
1377
1415
|
value: [
|
|
1378
|
-
99,
|
|
1379
1416
|
111,
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1417
|
+
112,
|
|
1418
|
+
101,
|
|
1419
|
+
114,
|
|
1420
|
+
97,
|
|
1421
|
+
116,
|
|
1422
|
+
111,
|
|
1423
|
+
114
|
|
1384
1424
|
]
|
|
1385
1425
|
},
|
|
1386
1426
|
{
|
|
1387
|
-
kind: "
|
|
1388
|
-
path: "
|
|
1427
|
+
kind: "account",
|
|
1428
|
+
path: "whitelisted_address"
|
|
1389
1429
|
}
|
|
1390
1430
|
]
|
|
1391
1431
|
}
|
|
1392
1432
|
},
|
|
1433
|
+
{
|
|
1434
|
+
name: "whitelisted_address"
|
|
1435
|
+
},
|
|
1393
1436
|
{
|
|
1394
1437
|
name: "admin",
|
|
1438
|
+
signer: true
|
|
1439
|
+
},
|
|
1440
|
+
{
|
|
1441
|
+
name: "payer",
|
|
1395
1442
|
writable: true,
|
|
1396
1443
|
signer: true
|
|
1397
1444
|
},
|
|
@@ -1434,16 +1481,8 @@ var cp_amm_default = {
|
|
|
1434
1481
|
],
|
|
1435
1482
|
args: [
|
|
1436
1483
|
{
|
|
1437
|
-
name: "
|
|
1438
|
-
type: "
|
|
1439
|
-
},
|
|
1440
|
-
{
|
|
1441
|
-
name: "config_parameters",
|
|
1442
|
-
type: {
|
|
1443
|
-
defined: {
|
|
1444
|
-
name: "DynamicConfigParameters"
|
|
1445
|
-
}
|
|
1446
|
-
}
|
|
1484
|
+
name: "permission",
|
|
1485
|
+
type: "u128"
|
|
1447
1486
|
}
|
|
1448
1487
|
]
|
|
1449
1488
|
},
|
|
@@ -1643,7 +1682,17 @@ var cp_amm_default = {
|
|
|
1643
1682
|
name: "token_mint"
|
|
1644
1683
|
},
|
|
1645
1684
|
{
|
|
1646
|
-
name: "
|
|
1685
|
+
name: "operator"
|
|
1686
|
+
},
|
|
1687
|
+
{
|
|
1688
|
+
name: "whitelisted_address",
|
|
1689
|
+
signer: true,
|
|
1690
|
+
relations: [
|
|
1691
|
+
"operator"
|
|
1692
|
+
]
|
|
1693
|
+
},
|
|
1694
|
+
{
|
|
1695
|
+
name: "payer",
|
|
1647
1696
|
writable: true,
|
|
1648
1697
|
signer: true
|
|
1649
1698
|
},
|
|
@@ -1686,6 +1735,40 @@ var cp_amm_default = {
|
|
|
1686
1735
|
],
|
|
1687
1736
|
args: []
|
|
1688
1737
|
},
|
|
1738
|
+
{
|
|
1739
|
+
name: "dummy_ix",
|
|
1740
|
+
discriminator: [
|
|
1741
|
+
234,
|
|
1742
|
+
95,
|
|
1743
|
+
176,
|
|
1744
|
+
185,
|
|
1745
|
+
7,
|
|
1746
|
+
42,
|
|
1747
|
+
35,
|
|
1748
|
+
159
|
|
1749
|
+
],
|
|
1750
|
+
accounts: [
|
|
1751
|
+
{
|
|
1752
|
+
name: "pod_aligned_fee_time_scheduler"
|
|
1753
|
+
},
|
|
1754
|
+
{
|
|
1755
|
+
name: "pod_aligned_fee_rate_limiter"
|
|
1756
|
+
},
|
|
1757
|
+
{
|
|
1758
|
+
name: "pod_aligned_fee_market_cap_scheduler"
|
|
1759
|
+
}
|
|
1760
|
+
],
|
|
1761
|
+
args: [
|
|
1762
|
+
{
|
|
1763
|
+
name: "_ixs",
|
|
1764
|
+
type: {
|
|
1765
|
+
defined: {
|
|
1766
|
+
name: "DummyParams"
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
]
|
|
1771
|
+
},
|
|
1689
1772
|
{
|
|
1690
1773
|
name: "fund_reward",
|
|
1691
1774
|
discriminator: [
|
|
@@ -3247,8 +3330,14 @@ var cp_amm_default = {
|
|
|
3247
3330
|
writable: true
|
|
3248
3331
|
},
|
|
3249
3332
|
{
|
|
3250
|
-
name: "
|
|
3251
|
-
|
|
3333
|
+
name: "operator"
|
|
3334
|
+
},
|
|
3335
|
+
{
|
|
3336
|
+
name: "whitelisted_address",
|
|
3337
|
+
signer: true,
|
|
3338
|
+
relations: [
|
|
3339
|
+
"operator"
|
|
3340
|
+
]
|
|
3252
3341
|
},
|
|
3253
3342
|
{
|
|
3254
3343
|
name: "event_authority",
|
|
@@ -3628,7 +3717,7 @@ var cp_amm_default = {
|
|
|
3628
3717
|
],
|
|
3629
3718
|
args: [
|
|
3630
3719
|
{
|
|
3631
|
-
name: "
|
|
3720
|
+
name: "_params",
|
|
3632
3721
|
type: {
|
|
3633
3722
|
defined: {
|
|
3634
3723
|
name: "SwapParameters"
|
|
@@ -3769,7 +3858,7 @@ var cp_amm_default = {
|
|
|
3769
3858
|
],
|
|
3770
3859
|
args: [
|
|
3771
3860
|
{
|
|
3772
|
-
name: "
|
|
3861
|
+
name: "_params",
|
|
3773
3862
|
type: {
|
|
3774
3863
|
defined: {
|
|
3775
3864
|
name: "SwapParameters2"
|
|
@@ -3779,16 +3868,16 @@ var cp_amm_default = {
|
|
|
3779
3868
|
]
|
|
3780
3869
|
},
|
|
3781
3870
|
{
|
|
3782
|
-
name: "
|
|
3871
|
+
name: "update_pool_fees",
|
|
3783
3872
|
discriminator: [
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3873
|
+
118,
|
|
3874
|
+
217,
|
|
3875
|
+
203,
|
|
3876
|
+
179,
|
|
3877
|
+
60,
|
|
3878
|
+
8,
|
|
3879
|
+
70,
|
|
3880
|
+
89
|
|
3792
3881
|
],
|
|
3793
3882
|
accounts: [
|
|
3794
3883
|
{
|
|
@@ -3796,13 +3885,84 @@ var cp_amm_default = {
|
|
|
3796
3885
|
writable: true
|
|
3797
3886
|
},
|
|
3798
3887
|
{
|
|
3799
|
-
name: "
|
|
3800
|
-
signer: true
|
|
3888
|
+
name: "operator"
|
|
3801
3889
|
},
|
|
3802
3890
|
{
|
|
3803
|
-
name: "
|
|
3804
|
-
|
|
3805
|
-
|
|
3891
|
+
name: "whitelisted_address",
|
|
3892
|
+
signer: true,
|
|
3893
|
+
relations: [
|
|
3894
|
+
"operator"
|
|
3895
|
+
]
|
|
3896
|
+
},
|
|
3897
|
+
{
|
|
3898
|
+
name: "event_authority",
|
|
3899
|
+
pda: {
|
|
3900
|
+
seeds: [
|
|
3901
|
+
{
|
|
3902
|
+
kind: "const",
|
|
3903
|
+
value: [
|
|
3904
|
+
95,
|
|
3905
|
+
95,
|
|
3906
|
+
101,
|
|
3907
|
+
118,
|
|
3908
|
+
101,
|
|
3909
|
+
110,
|
|
3910
|
+
116,
|
|
3911
|
+
95,
|
|
3912
|
+
97,
|
|
3913
|
+
117,
|
|
3914
|
+
116,
|
|
3915
|
+
104,
|
|
3916
|
+
111,
|
|
3917
|
+
114,
|
|
3918
|
+
105,
|
|
3919
|
+
116,
|
|
3920
|
+
121
|
|
3921
|
+
]
|
|
3922
|
+
}
|
|
3923
|
+
]
|
|
3924
|
+
}
|
|
3925
|
+
},
|
|
3926
|
+
{
|
|
3927
|
+
name: "program"
|
|
3928
|
+
}
|
|
3929
|
+
],
|
|
3930
|
+
args: [
|
|
3931
|
+
{
|
|
3932
|
+
name: "params",
|
|
3933
|
+
type: {
|
|
3934
|
+
defined: {
|
|
3935
|
+
name: "UpdatePoolFeesParameters"
|
|
3936
|
+
}
|
|
3937
|
+
}
|
|
3938
|
+
}
|
|
3939
|
+
]
|
|
3940
|
+
},
|
|
3941
|
+
{
|
|
3942
|
+
name: "update_reward_duration",
|
|
3943
|
+
discriminator: [
|
|
3944
|
+
138,
|
|
3945
|
+
174,
|
|
3946
|
+
196,
|
|
3947
|
+
169,
|
|
3948
|
+
213,
|
|
3949
|
+
235,
|
|
3950
|
+
254,
|
|
3951
|
+
107
|
|
3952
|
+
],
|
|
3953
|
+
accounts: [
|
|
3954
|
+
{
|
|
3955
|
+
name: "pool",
|
|
3956
|
+
writable: true
|
|
3957
|
+
},
|
|
3958
|
+
{
|
|
3959
|
+
name: "signer",
|
|
3960
|
+
signer: true
|
|
3961
|
+
},
|
|
3962
|
+
{
|
|
3963
|
+
name: "event_authority",
|
|
3964
|
+
pda: {
|
|
3965
|
+
seeds: [
|
|
3806
3966
|
{
|
|
3807
3967
|
kind: "const",
|
|
3808
3968
|
value: [
|
|
@@ -3989,19 +4149,6 @@ var cp_amm_default = {
|
|
|
3989
4149
|
}
|
|
3990
4150
|
],
|
|
3991
4151
|
accounts: [
|
|
3992
|
-
{
|
|
3993
|
-
name: "ClaimFeeOperator",
|
|
3994
|
-
discriminator: [
|
|
3995
|
-
166,
|
|
3996
|
-
48,
|
|
3997
|
-
134,
|
|
3998
|
-
86,
|
|
3999
|
-
34,
|
|
4000
|
-
200,
|
|
4001
|
-
188,
|
|
4002
|
-
150
|
|
4003
|
-
]
|
|
4004
|
-
},
|
|
4005
4152
|
{
|
|
4006
4153
|
name: "Config",
|
|
4007
4154
|
discriminator: [
|
|
@@ -4015,6 +4162,58 @@ var cp_amm_default = {
|
|
|
4015
4162
|
130
|
|
4016
4163
|
]
|
|
4017
4164
|
},
|
|
4165
|
+
{
|
|
4166
|
+
name: "Operator",
|
|
4167
|
+
discriminator: [
|
|
4168
|
+
219,
|
|
4169
|
+
31,
|
|
4170
|
+
188,
|
|
4171
|
+
145,
|
|
4172
|
+
69,
|
|
4173
|
+
139,
|
|
4174
|
+
204,
|
|
4175
|
+
117
|
|
4176
|
+
]
|
|
4177
|
+
},
|
|
4178
|
+
{
|
|
4179
|
+
name: "PodAlignedFeeMarketCapScheduler",
|
|
4180
|
+
discriminator: [
|
|
4181
|
+
251,
|
|
4182
|
+
130,
|
|
4183
|
+
208,
|
|
4184
|
+
253,
|
|
4185
|
+
245,
|
|
4186
|
+
27,
|
|
4187
|
+
145,
|
|
4188
|
+
203
|
|
4189
|
+
]
|
|
4190
|
+
},
|
|
4191
|
+
{
|
|
4192
|
+
name: "PodAlignedFeeRateLimiter",
|
|
4193
|
+
discriminator: [
|
|
4194
|
+
160,
|
|
4195
|
+
219,
|
|
4196
|
+
8,
|
|
4197
|
+
251,
|
|
4198
|
+
179,
|
|
4199
|
+
7,
|
|
4200
|
+
16,
|
|
4201
|
+
117
|
|
4202
|
+
]
|
|
4203
|
+
},
|
|
4204
|
+
{
|
|
4205
|
+
name: "PodAlignedFeeTimeScheduler",
|
|
4206
|
+
discriminator: [
|
|
4207
|
+
239,
|
|
4208
|
+
132,
|
|
4209
|
+
138,
|
|
4210
|
+
213,
|
|
4211
|
+
67,
|
|
4212
|
+
154,
|
|
4213
|
+
130,
|
|
4214
|
+
70
|
|
4215
|
+
]
|
|
4216
|
+
},
|
|
4018
4217
|
{
|
|
4019
4218
|
name: "Pool",
|
|
4020
4219
|
discriminator: [
|
|
@@ -4069,19 +4268,6 @@ var cp_amm_default = {
|
|
|
4069
4268
|
}
|
|
4070
4269
|
],
|
|
4071
4270
|
events: [
|
|
4072
|
-
{
|
|
4073
|
-
name: "EvtAddLiquidity",
|
|
4074
|
-
discriminator: [
|
|
4075
|
-
175,
|
|
4076
|
-
242,
|
|
4077
|
-
8,
|
|
4078
|
-
157,
|
|
4079
|
-
30,
|
|
4080
|
-
247,
|
|
4081
|
-
185,
|
|
4082
|
-
169
|
|
4083
|
-
]
|
|
4084
|
-
},
|
|
4085
4271
|
{
|
|
4086
4272
|
name: "EvtClaimPartnerFee",
|
|
4087
4273
|
discriminator: [
|
|
@@ -4134,19 +4320,6 @@ var cp_amm_default = {
|
|
|
4134
4320
|
231
|
|
4135
4321
|
]
|
|
4136
4322
|
},
|
|
4137
|
-
{
|
|
4138
|
-
name: "EvtCloseClaimFeeOperator",
|
|
4139
|
-
discriminator: [
|
|
4140
|
-
111,
|
|
4141
|
-
39,
|
|
4142
|
-
37,
|
|
4143
|
-
55,
|
|
4144
|
-
110,
|
|
4145
|
-
216,
|
|
4146
|
-
194,
|
|
4147
|
-
23
|
|
4148
|
-
]
|
|
4149
|
-
},
|
|
4150
4323
|
{
|
|
4151
4324
|
name: "EvtCloseConfig",
|
|
4152
4325
|
discriminator: [
|
|
@@ -4173,19 +4346,6 @@ var cp_amm_default = {
|
|
|
4173
4346
|
178
|
|
4174
4347
|
]
|
|
4175
4348
|
},
|
|
4176
|
-
{
|
|
4177
|
-
name: "EvtCreateClaimFeeOperator",
|
|
4178
|
-
discriminator: [
|
|
4179
|
-
21,
|
|
4180
|
-
6,
|
|
4181
|
-
153,
|
|
4182
|
-
120,
|
|
4183
|
-
68,
|
|
4184
|
-
116,
|
|
4185
|
-
28,
|
|
4186
|
-
177
|
|
4187
|
-
]
|
|
4188
|
-
},
|
|
4189
4349
|
{
|
|
4190
4350
|
name: "EvtCreateConfig",
|
|
4191
4351
|
discriminator: [
|
|
@@ -4316,19 +4476,6 @@ var cp_amm_default = {
|
|
|
4316
4476
|
11
|
|
4317
4477
|
]
|
|
4318
4478
|
},
|
|
4319
|
-
{
|
|
4320
|
-
name: "EvtRemoveLiquidity",
|
|
4321
|
-
discriminator: [
|
|
4322
|
-
87,
|
|
4323
|
-
46,
|
|
4324
|
-
88,
|
|
4325
|
-
98,
|
|
4326
|
-
175,
|
|
4327
|
-
96,
|
|
4328
|
-
34,
|
|
4329
|
-
91
|
|
4330
|
-
]
|
|
4331
|
-
},
|
|
4332
4479
|
{
|
|
4333
4480
|
name: "EvtSetPoolStatus",
|
|
4334
4481
|
discriminator: [
|
|
@@ -4355,19 +4502,6 @@ var cp_amm_default = {
|
|
|
4355
4502
|
103
|
|
4356
4503
|
]
|
|
4357
4504
|
},
|
|
4358
|
-
{
|
|
4359
|
-
name: "EvtSwap",
|
|
4360
|
-
discriminator: [
|
|
4361
|
-
27,
|
|
4362
|
-
60,
|
|
4363
|
-
21,
|
|
4364
|
-
213,
|
|
4365
|
-
138,
|
|
4366
|
-
170,
|
|
4367
|
-
187,
|
|
4368
|
-
147
|
|
4369
|
-
]
|
|
4370
|
-
},
|
|
4371
4505
|
{
|
|
4372
4506
|
name: "EvtSwap2",
|
|
4373
4507
|
discriminator: [
|
|
@@ -4381,6 +4515,19 @@ var cp_amm_default = {
|
|
|
4381
4515
|
153
|
|
4382
4516
|
]
|
|
4383
4517
|
},
|
|
4518
|
+
{
|
|
4519
|
+
name: "EvtUpdatePoolFees",
|
|
4520
|
+
discriminator: [
|
|
4521
|
+
76,
|
|
4522
|
+
165,
|
|
4523
|
+
246,
|
|
4524
|
+
102,
|
|
4525
|
+
102,
|
|
4526
|
+
217,
|
|
4527
|
+
156,
|
|
4528
|
+
44
|
|
4529
|
+
]
|
|
4530
|
+
},
|
|
4384
4531
|
{
|
|
4385
4532
|
name: "EvtUpdateRewardDuration",
|
|
4386
4533
|
discriminator: [
|
|
@@ -4674,7 +4821,7 @@ var cp_amm_default = {
|
|
|
4674
4821
|
},
|
|
4675
4822
|
{
|
|
4676
4823
|
code: 6050,
|
|
4677
|
-
name: "
|
|
4824
|
+
name: "InvalidFeeTimeScheduler",
|
|
4678
4825
|
msg: "Invalid fee scheduler"
|
|
4679
4826
|
},
|
|
4680
4827
|
{
|
|
@@ -4686,6 +4833,41 @@ var cp_amm_default = {
|
|
|
4686
4833
|
code: 6052,
|
|
4687
4834
|
name: "InvalidPoolVersion",
|
|
4688
4835
|
msg: "Invalid pool version"
|
|
4836
|
+
},
|
|
4837
|
+
{
|
|
4838
|
+
code: 6053,
|
|
4839
|
+
name: "InvalidAuthority",
|
|
4840
|
+
msg: "Invalid authority to do that action"
|
|
4841
|
+
},
|
|
4842
|
+
{
|
|
4843
|
+
code: 6054,
|
|
4844
|
+
name: "InvalidPermission",
|
|
4845
|
+
msg: "Invalid permission"
|
|
4846
|
+
},
|
|
4847
|
+
{
|
|
4848
|
+
code: 6055,
|
|
4849
|
+
name: "InvalidFeeMarketCapScheduler",
|
|
4850
|
+
msg: "Invalid fee market cap scheduler"
|
|
4851
|
+
},
|
|
4852
|
+
{
|
|
4853
|
+
code: 6056,
|
|
4854
|
+
name: "CannotUpdateBaseFee",
|
|
4855
|
+
msg: "Cannot update base fee"
|
|
4856
|
+
},
|
|
4857
|
+
{
|
|
4858
|
+
code: 6057,
|
|
4859
|
+
name: "InvalidDynamicFeeParameters",
|
|
4860
|
+
msg: "Invalid dynamic fee parameters"
|
|
4861
|
+
},
|
|
4862
|
+
{
|
|
4863
|
+
code: 6058,
|
|
4864
|
+
name: "InvalidUpdatePoolFeesParameters",
|
|
4865
|
+
msg: "Invalid update pool fees parameters"
|
|
4866
|
+
},
|
|
4867
|
+
{
|
|
4868
|
+
code: 6059,
|
|
4869
|
+
name: "MissingOperatorAccount",
|
|
4870
|
+
msg: "Missing operator account"
|
|
4689
4871
|
}
|
|
4690
4872
|
],
|
|
4691
4873
|
types: [
|
|
@@ -4719,7 +4901,7 @@ var cp_amm_default = {
|
|
|
4719
4901
|
}
|
|
4720
4902
|
},
|
|
4721
4903
|
{
|
|
4722
|
-
name: "
|
|
4904
|
+
name: "BaseFeeInfo",
|
|
4723
4905
|
serialization: "bytemuck",
|
|
4724
4906
|
repr: {
|
|
4725
4907
|
kind: "c"
|
|
@@ -4728,38 +4910,13 @@ var cp_amm_default = {
|
|
|
4728
4910
|
kind: "struct",
|
|
4729
4911
|
fields: [
|
|
4730
4912
|
{
|
|
4731
|
-
name: "
|
|
4732
|
-
type: "u64"
|
|
4733
|
-
},
|
|
4734
|
-
{
|
|
4735
|
-
name: "base_fee_mode",
|
|
4736
|
-
type: "u8"
|
|
4737
|
-
},
|
|
4738
|
-
{
|
|
4739
|
-
name: "padding",
|
|
4740
|
-
type: {
|
|
4741
|
-
array: [
|
|
4742
|
-
"u8",
|
|
4743
|
-
5
|
|
4744
|
-
]
|
|
4745
|
-
}
|
|
4746
|
-
},
|
|
4747
|
-
{
|
|
4748
|
-
name: "first_factor",
|
|
4749
|
-
type: "u16"
|
|
4750
|
-
},
|
|
4751
|
-
{
|
|
4752
|
-
name: "second_factor",
|
|
4913
|
+
name: "data",
|
|
4753
4914
|
type: {
|
|
4754
4915
|
array: [
|
|
4755
4916
|
"u8",
|
|
4756
|
-
|
|
4917
|
+
32
|
|
4757
4918
|
]
|
|
4758
4919
|
}
|
|
4759
|
-
},
|
|
4760
|
-
{
|
|
4761
|
-
name: "third_factor",
|
|
4762
|
-
type: "u64"
|
|
4763
4920
|
}
|
|
4764
4921
|
]
|
|
4765
4922
|
}
|
|
@@ -4770,29 +4927,13 @@ var cp_amm_default = {
|
|
|
4770
4927
|
kind: "struct",
|
|
4771
4928
|
fields: [
|
|
4772
4929
|
{
|
|
4773
|
-
name: "
|
|
4774
|
-
type: "u64"
|
|
4775
|
-
},
|
|
4776
|
-
{
|
|
4777
|
-
name: "first_factor",
|
|
4778
|
-
type: "u16"
|
|
4779
|
-
},
|
|
4780
|
-
{
|
|
4781
|
-
name: "second_factor",
|
|
4930
|
+
name: "data",
|
|
4782
4931
|
type: {
|
|
4783
4932
|
array: [
|
|
4784
4933
|
"u8",
|
|
4785
|
-
|
|
4934
|
+
30
|
|
4786
4935
|
]
|
|
4787
4936
|
}
|
|
4788
|
-
},
|
|
4789
|
-
{
|
|
4790
|
-
name: "third_factor",
|
|
4791
|
-
type: "u64"
|
|
4792
|
-
},
|
|
4793
|
-
{
|
|
4794
|
-
name: "base_fee_mode",
|
|
4795
|
-
type: "u8"
|
|
4796
4937
|
}
|
|
4797
4938
|
]
|
|
4798
4939
|
}
|
|
@@ -4803,6 +4944,26 @@ var cp_amm_default = {
|
|
|
4803
4944
|
repr: {
|
|
4804
4945
|
kind: "c"
|
|
4805
4946
|
},
|
|
4947
|
+
type: {
|
|
4948
|
+
kind: "struct",
|
|
4949
|
+
fields: [
|
|
4950
|
+
{
|
|
4951
|
+
name: "base_fee_info",
|
|
4952
|
+
type: {
|
|
4953
|
+
defined: {
|
|
4954
|
+
name: "BaseFeeInfo"
|
|
4955
|
+
}
|
|
4956
|
+
}
|
|
4957
|
+
},
|
|
4958
|
+
{
|
|
4959
|
+
name: "padding_1",
|
|
4960
|
+
type: "u64"
|
|
4961
|
+
}
|
|
4962
|
+
]
|
|
4963
|
+
}
|
|
4964
|
+
},
|
|
4965
|
+
{
|
|
4966
|
+
name: "BorshFeeMarketCapScheduler",
|
|
4806
4967
|
type: {
|
|
4807
4968
|
kind: "struct",
|
|
4808
4969
|
fields: [
|
|
@@ -4811,70 +4972,122 @@ var cp_amm_default = {
|
|
|
4811
4972
|
type: "u64"
|
|
4812
4973
|
},
|
|
4813
4974
|
{
|
|
4814
|
-
name: "
|
|
4815
|
-
type: "
|
|
4975
|
+
name: "number_of_period",
|
|
4976
|
+
type: "u16"
|
|
4816
4977
|
},
|
|
4817
4978
|
{
|
|
4818
|
-
name: "
|
|
4819
|
-
type:
|
|
4820
|
-
array: [
|
|
4821
|
-
"u8",
|
|
4822
|
-
5
|
|
4823
|
-
]
|
|
4824
|
-
}
|
|
4979
|
+
name: "sqrt_price_step_bps",
|
|
4980
|
+
type: "u32"
|
|
4825
4981
|
},
|
|
4826
4982
|
{
|
|
4827
|
-
name: "
|
|
4828
|
-
type: "
|
|
4983
|
+
name: "scheduler_expiration_duration",
|
|
4984
|
+
type: "u32"
|
|
4985
|
+
},
|
|
4986
|
+
{
|
|
4987
|
+
name: "reduction_factor",
|
|
4988
|
+
type: "u64"
|
|
4989
|
+
},
|
|
4990
|
+
{
|
|
4991
|
+
name: "base_fee_mode",
|
|
4992
|
+
type: "u8"
|
|
4829
4993
|
},
|
|
4830
4994
|
{
|
|
4831
|
-
name: "
|
|
4995
|
+
name: "padding",
|
|
4832
4996
|
type: {
|
|
4833
4997
|
array: [
|
|
4834
4998
|
"u8",
|
|
4835
|
-
|
|
4999
|
+
3
|
|
4836
5000
|
]
|
|
4837
5001
|
}
|
|
4838
|
-
}
|
|
5002
|
+
}
|
|
5003
|
+
]
|
|
5004
|
+
}
|
|
5005
|
+
},
|
|
5006
|
+
{
|
|
5007
|
+
name: "BorshFeeRateLimiter",
|
|
5008
|
+
docs: [
|
|
5009
|
+
"we denote reference_amount = x0, cliff_fee_numerator = c, fee_increment = i",
|
|
5010
|
+
"if input_amount <= x0, then fee = input_amount * c",
|
|
5011
|
+
"",
|
|
5012
|
+
"if input_amount > x0, then input_amount = x0 + (a * x0 + b)",
|
|
5013
|
+
"if a < max_index",
|
|
5014
|
+
"then fee = x0 * c + x0 * (c + i) + .... + x0 * (c + i*a) + b * (c + i * (a+1))",
|
|
5015
|
+
"then fee = x0 * (c + c*a + i*a*(a+1)/2) + b * (c + i * (a+1))",
|
|
5016
|
+
"",
|
|
5017
|
+
"if a >= max_index",
|
|
5018
|
+
"if a = max_index + d, input_amount = x0 + max_index * x0 + (d * x0 + b)",
|
|
5019
|
+
"then fee = x0 * (c + c*max_index + i*max_index*(max_index+1)/2) + (d * x0 + b) * MAX_FEE"
|
|
5020
|
+
],
|
|
5021
|
+
type: {
|
|
5022
|
+
kind: "struct",
|
|
5023
|
+
fields: [
|
|
4839
5024
|
{
|
|
4840
|
-
name: "
|
|
5025
|
+
name: "cliff_fee_numerator",
|
|
4841
5026
|
type: "u64"
|
|
4842
5027
|
},
|
|
4843
5028
|
{
|
|
4844
|
-
name: "
|
|
5029
|
+
name: "fee_increment_bps",
|
|
5030
|
+
type: "u16"
|
|
5031
|
+
},
|
|
5032
|
+
{
|
|
5033
|
+
name: "max_limiter_duration",
|
|
5034
|
+
type: "u32"
|
|
5035
|
+
},
|
|
5036
|
+
{
|
|
5037
|
+
name: "max_fee_bps",
|
|
5038
|
+
type: "u32"
|
|
5039
|
+
},
|
|
5040
|
+
{
|
|
5041
|
+
name: "reference_amount",
|
|
4845
5042
|
type: "u64"
|
|
5043
|
+
},
|
|
5044
|
+
{
|
|
5045
|
+
name: "base_fee_mode",
|
|
5046
|
+
type: "u8"
|
|
5047
|
+
},
|
|
5048
|
+
{
|
|
5049
|
+
name: "padding",
|
|
5050
|
+
type: {
|
|
5051
|
+
array: [
|
|
5052
|
+
"u8",
|
|
5053
|
+
3
|
|
5054
|
+
]
|
|
5055
|
+
}
|
|
4846
5056
|
}
|
|
4847
5057
|
]
|
|
4848
5058
|
}
|
|
4849
5059
|
},
|
|
4850
5060
|
{
|
|
4851
|
-
name: "
|
|
4852
|
-
docs: [
|
|
4853
|
-
"Parameter that set by the protocol"
|
|
4854
|
-
],
|
|
4855
|
-
serialization: "bytemuck",
|
|
4856
|
-
repr: {
|
|
4857
|
-
kind: "c"
|
|
4858
|
-
},
|
|
5061
|
+
name: "BorshFeeTimeScheduler",
|
|
4859
5062
|
type: {
|
|
4860
5063
|
kind: "struct",
|
|
4861
5064
|
fields: [
|
|
4862
5065
|
{
|
|
4863
|
-
name: "
|
|
4864
|
-
|
|
4865
|
-
"operator"
|
|
4866
|
-
],
|
|
4867
|
-
type: "pubkey"
|
|
5066
|
+
name: "cliff_fee_numerator",
|
|
5067
|
+
type: "u64"
|
|
4868
5068
|
},
|
|
4869
5069
|
{
|
|
4870
|
-
name: "
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
5070
|
+
name: "number_of_period",
|
|
5071
|
+
type: "u16"
|
|
5072
|
+
},
|
|
5073
|
+
{
|
|
5074
|
+
name: "period_frequency",
|
|
5075
|
+
type: "u64"
|
|
5076
|
+
},
|
|
5077
|
+
{
|
|
5078
|
+
name: "reduction_factor",
|
|
5079
|
+
type: "u64"
|
|
5080
|
+
},
|
|
5081
|
+
{
|
|
5082
|
+
name: "base_fee_mode",
|
|
5083
|
+
type: "u8"
|
|
5084
|
+
},
|
|
5085
|
+
{
|
|
5086
|
+
name: "padding",
|
|
4874
5087
|
type: {
|
|
4875
5088
|
array: [
|
|
4876
5089
|
"u8",
|
|
4877
|
-
|
|
5090
|
+
3
|
|
4878
5091
|
]
|
|
4879
5092
|
}
|
|
4880
5093
|
}
|
|
@@ -4985,6 +5198,38 @@ var cp_amm_default = {
|
|
|
4985
5198
|
]
|
|
4986
5199
|
}
|
|
4987
5200
|
},
|
|
5201
|
+
{
|
|
5202
|
+
name: "DummyParams",
|
|
5203
|
+
type: {
|
|
5204
|
+
kind: "struct",
|
|
5205
|
+
fields: [
|
|
5206
|
+
{
|
|
5207
|
+
name: "borsh_fee_time_scheduler_params",
|
|
5208
|
+
type: {
|
|
5209
|
+
defined: {
|
|
5210
|
+
name: "BorshFeeTimeScheduler"
|
|
5211
|
+
}
|
|
5212
|
+
}
|
|
5213
|
+
},
|
|
5214
|
+
{
|
|
5215
|
+
name: "borsh_fee_rate_limiter_params",
|
|
5216
|
+
type: {
|
|
5217
|
+
defined: {
|
|
5218
|
+
name: "BorshFeeRateLimiter"
|
|
5219
|
+
}
|
|
5220
|
+
}
|
|
5221
|
+
},
|
|
5222
|
+
{
|
|
5223
|
+
name: "borsh_fee_market_cap_scheduler_params",
|
|
5224
|
+
type: {
|
|
5225
|
+
defined: {
|
|
5226
|
+
name: "BorshFeeMarketCapScheduler"
|
|
5227
|
+
}
|
|
5228
|
+
}
|
|
5229
|
+
}
|
|
5230
|
+
]
|
|
5231
|
+
}
|
|
5232
|
+
},
|
|
4988
5233
|
{
|
|
4989
5234
|
name: "DynamicConfigParameters",
|
|
4990
5235
|
type: {
|
|
@@ -5164,50 +5409,6 @@ var cp_amm_default = {
|
|
|
5164
5409
|
]
|
|
5165
5410
|
}
|
|
5166
5411
|
},
|
|
5167
|
-
{
|
|
5168
|
-
name: "EvtAddLiquidity",
|
|
5169
|
-
type: {
|
|
5170
|
-
kind: "struct",
|
|
5171
|
-
fields: [
|
|
5172
|
-
{
|
|
5173
|
-
name: "pool",
|
|
5174
|
-
type: "pubkey"
|
|
5175
|
-
},
|
|
5176
|
-
{
|
|
5177
|
-
name: "position",
|
|
5178
|
-
type: "pubkey"
|
|
5179
|
-
},
|
|
5180
|
-
{
|
|
5181
|
-
name: "owner",
|
|
5182
|
-
type: "pubkey"
|
|
5183
|
-
},
|
|
5184
|
-
{
|
|
5185
|
-
name: "params",
|
|
5186
|
-
type: {
|
|
5187
|
-
defined: {
|
|
5188
|
-
name: "AddLiquidityParameters"
|
|
5189
|
-
}
|
|
5190
|
-
}
|
|
5191
|
-
},
|
|
5192
|
-
{
|
|
5193
|
-
name: "token_a_amount",
|
|
5194
|
-
type: "u64"
|
|
5195
|
-
},
|
|
5196
|
-
{
|
|
5197
|
-
name: "token_b_amount",
|
|
5198
|
-
type: "u64"
|
|
5199
|
-
},
|
|
5200
|
-
{
|
|
5201
|
-
name: "total_amount_a",
|
|
5202
|
-
type: "u64"
|
|
5203
|
-
},
|
|
5204
|
-
{
|
|
5205
|
-
name: "total_amount_b",
|
|
5206
|
-
type: "u64"
|
|
5207
|
-
}
|
|
5208
|
-
]
|
|
5209
|
-
}
|
|
5210
|
-
},
|
|
5211
5412
|
{
|
|
5212
5413
|
name: "EvtClaimPartnerFee",
|
|
5213
5414
|
type: {
|
|
@@ -5308,25 +5509,6 @@ var cp_amm_default = {
|
|
|
5308
5509
|
]
|
|
5309
5510
|
}
|
|
5310
5511
|
},
|
|
5311
|
-
{
|
|
5312
|
-
name: "EvtCloseClaimFeeOperator",
|
|
5313
|
-
docs: [
|
|
5314
|
-
"Close claim fee operator"
|
|
5315
|
-
],
|
|
5316
|
-
type: {
|
|
5317
|
-
kind: "struct",
|
|
5318
|
-
fields: [
|
|
5319
|
-
{
|
|
5320
|
-
name: "claim_fee_operator",
|
|
5321
|
-
type: "pubkey"
|
|
5322
|
-
},
|
|
5323
|
-
{
|
|
5324
|
-
name: "operator",
|
|
5325
|
-
type: "pubkey"
|
|
5326
|
-
}
|
|
5327
|
-
]
|
|
5328
|
-
}
|
|
5329
|
-
},
|
|
5330
5512
|
{
|
|
5331
5513
|
name: "EvtCloseConfig",
|
|
5332
5514
|
docs: [
|
|
@@ -5376,21 +5558,6 @@ var cp_amm_default = {
|
|
|
5376
5558
|
]
|
|
5377
5559
|
}
|
|
5378
5560
|
},
|
|
5379
|
-
{
|
|
5380
|
-
name: "EvtCreateClaimFeeOperator",
|
|
5381
|
-
docs: [
|
|
5382
|
-
"Create claim fee operator"
|
|
5383
|
-
],
|
|
5384
|
-
type: {
|
|
5385
|
-
kind: "struct",
|
|
5386
|
-
fields: [
|
|
5387
|
-
{
|
|
5388
|
-
name: "operator",
|
|
5389
|
-
type: "pubkey"
|
|
5390
|
-
}
|
|
5391
|
-
]
|
|
5392
|
-
}
|
|
5393
|
-
},
|
|
5394
5561
|
{
|
|
5395
5562
|
name: "EvtCreateConfig",
|
|
5396
5563
|
docs: [
|
|
@@ -5804,42 +5971,6 @@ var cp_amm_default = {
|
|
|
5804
5971
|
]
|
|
5805
5972
|
}
|
|
5806
5973
|
},
|
|
5807
|
-
{
|
|
5808
|
-
name: "EvtRemoveLiquidity",
|
|
5809
|
-
type: {
|
|
5810
|
-
kind: "struct",
|
|
5811
|
-
fields: [
|
|
5812
|
-
{
|
|
5813
|
-
name: "pool",
|
|
5814
|
-
type: "pubkey"
|
|
5815
|
-
},
|
|
5816
|
-
{
|
|
5817
|
-
name: "position",
|
|
5818
|
-
type: "pubkey"
|
|
5819
|
-
},
|
|
5820
|
-
{
|
|
5821
|
-
name: "owner",
|
|
5822
|
-
type: "pubkey"
|
|
5823
|
-
},
|
|
5824
|
-
{
|
|
5825
|
-
name: "params",
|
|
5826
|
-
type: {
|
|
5827
|
-
defined: {
|
|
5828
|
-
name: "RemoveLiquidityParameters"
|
|
5829
|
-
}
|
|
5830
|
-
}
|
|
5831
|
-
},
|
|
5832
|
-
{
|
|
5833
|
-
name: "token_a_amount",
|
|
5834
|
-
type: "u64"
|
|
5835
|
-
},
|
|
5836
|
-
{
|
|
5837
|
-
name: "token_b_amount",
|
|
5838
|
-
type: "u64"
|
|
5839
|
-
}
|
|
5840
|
-
]
|
|
5841
|
-
}
|
|
5842
|
-
},
|
|
5843
5974
|
{
|
|
5844
5975
|
name: "EvtSetPoolStatus",
|
|
5845
5976
|
type: {
|
|
@@ -5920,50 +6051,6 @@ var cp_amm_default = {
|
|
|
5920
6051
|
]
|
|
5921
6052
|
}
|
|
5922
6053
|
},
|
|
5923
|
-
{
|
|
5924
|
-
name: "EvtSwap",
|
|
5925
|
-
type: {
|
|
5926
|
-
kind: "struct",
|
|
5927
|
-
fields: [
|
|
5928
|
-
{
|
|
5929
|
-
name: "pool",
|
|
5930
|
-
type: "pubkey"
|
|
5931
|
-
},
|
|
5932
|
-
{
|
|
5933
|
-
name: "trade_direction",
|
|
5934
|
-
type: "u8"
|
|
5935
|
-
},
|
|
5936
|
-
{
|
|
5937
|
-
name: "has_referral",
|
|
5938
|
-
type: "bool"
|
|
5939
|
-
},
|
|
5940
|
-
{
|
|
5941
|
-
name: "params",
|
|
5942
|
-
type: {
|
|
5943
|
-
defined: {
|
|
5944
|
-
name: "SwapParameters"
|
|
5945
|
-
}
|
|
5946
|
-
}
|
|
5947
|
-
},
|
|
5948
|
-
{
|
|
5949
|
-
name: "swap_result",
|
|
5950
|
-
type: {
|
|
5951
|
-
defined: {
|
|
5952
|
-
name: "SwapResult"
|
|
5953
|
-
}
|
|
5954
|
-
}
|
|
5955
|
-
},
|
|
5956
|
-
{
|
|
5957
|
-
name: "actual_amount_in",
|
|
5958
|
-
type: "u64"
|
|
5959
|
-
},
|
|
5960
|
-
{
|
|
5961
|
-
name: "current_timestamp",
|
|
5962
|
-
type: "u64"
|
|
5963
|
-
}
|
|
5964
|
-
]
|
|
5965
|
-
}
|
|
5966
|
-
},
|
|
5967
6054
|
{
|
|
5968
6055
|
name: "EvtSwap2",
|
|
5969
6056
|
type: {
|
|
@@ -6028,6 +6115,30 @@ var cp_amm_default = {
|
|
|
6028
6115
|
]
|
|
6029
6116
|
}
|
|
6030
6117
|
},
|
|
6118
|
+
{
|
|
6119
|
+
name: "EvtUpdatePoolFees",
|
|
6120
|
+
type: {
|
|
6121
|
+
kind: "struct",
|
|
6122
|
+
fields: [
|
|
6123
|
+
{
|
|
6124
|
+
name: "pool",
|
|
6125
|
+
type: "pubkey"
|
|
6126
|
+
},
|
|
6127
|
+
{
|
|
6128
|
+
name: "operator",
|
|
6129
|
+
type: "pubkey"
|
|
6130
|
+
},
|
|
6131
|
+
{
|
|
6132
|
+
name: "params",
|
|
6133
|
+
type: {
|
|
6134
|
+
defined: {
|
|
6135
|
+
name: "UpdatePoolFeesParameters"
|
|
6136
|
+
}
|
|
6137
|
+
}
|
|
6138
|
+
}
|
|
6139
|
+
]
|
|
6140
|
+
}
|
|
6141
|
+
},
|
|
6031
6142
|
{
|
|
6032
6143
|
name: "EvtUpdateRewardDuration",
|
|
6033
6144
|
type: {
|
|
@@ -6143,7 +6254,7 @@ var cp_amm_default = {
|
|
|
6143
6254
|
{
|
|
6144
6255
|
name: "sqrt_price",
|
|
6145
6256
|
docs: [
|
|
6146
|
-
"The init price of the pool as a sqrt(token_b/token_a) Q64.64 value"
|
|
6257
|
+
"The init price of the pool as a sqrt(token_b/token_a) Q64.64 value. Market cap fee scheduler minimum price will be derived from this value"
|
|
6147
6258
|
],
|
|
6148
6259
|
type: "u128"
|
|
6149
6260
|
},
|
|
@@ -6174,32 +6285,192 @@ var cp_amm_default = {
|
|
|
6174
6285
|
}
|
|
6175
6286
|
},
|
|
6176
6287
|
{
|
|
6177
|
-
name: "InitializePoolParameters",
|
|
6288
|
+
name: "InitializePoolParameters",
|
|
6289
|
+
type: {
|
|
6290
|
+
kind: "struct",
|
|
6291
|
+
fields: [
|
|
6292
|
+
{
|
|
6293
|
+
name: "liquidity",
|
|
6294
|
+
docs: [
|
|
6295
|
+
"initialize liquidity"
|
|
6296
|
+
],
|
|
6297
|
+
type: "u128"
|
|
6298
|
+
},
|
|
6299
|
+
{
|
|
6300
|
+
name: "sqrt_price",
|
|
6301
|
+
docs: [
|
|
6302
|
+
"The init price of the pool as a sqrt(token_b/token_a) Q64.64 value"
|
|
6303
|
+
],
|
|
6304
|
+
type: "u128"
|
|
6305
|
+
},
|
|
6306
|
+
{
|
|
6307
|
+
name: "activation_point",
|
|
6308
|
+
docs: [
|
|
6309
|
+
"activation point"
|
|
6310
|
+
],
|
|
6311
|
+
type: {
|
|
6312
|
+
option: "u64"
|
|
6313
|
+
}
|
|
6314
|
+
}
|
|
6315
|
+
]
|
|
6316
|
+
}
|
|
6317
|
+
},
|
|
6318
|
+
{
|
|
6319
|
+
name: "Operator",
|
|
6320
|
+
serialization: "bytemuck",
|
|
6321
|
+
repr: {
|
|
6322
|
+
kind: "c"
|
|
6323
|
+
},
|
|
6324
|
+
type: {
|
|
6325
|
+
kind: "struct",
|
|
6326
|
+
fields: [
|
|
6327
|
+
{
|
|
6328
|
+
name: "whitelisted_address",
|
|
6329
|
+
type: "pubkey"
|
|
6330
|
+
},
|
|
6331
|
+
{
|
|
6332
|
+
name: "permission",
|
|
6333
|
+
type: "u128"
|
|
6334
|
+
},
|
|
6335
|
+
{
|
|
6336
|
+
name: "padding",
|
|
6337
|
+
type: {
|
|
6338
|
+
array: [
|
|
6339
|
+
"u64",
|
|
6340
|
+
2
|
|
6341
|
+
]
|
|
6342
|
+
}
|
|
6343
|
+
}
|
|
6344
|
+
]
|
|
6345
|
+
}
|
|
6346
|
+
},
|
|
6347
|
+
{
|
|
6348
|
+
name: "PodAlignedFeeMarketCapScheduler",
|
|
6349
|
+
serialization: "bytemuck",
|
|
6350
|
+
repr: {
|
|
6351
|
+
kind: "c"
|
|
6352
|
+
},
|
|
6353
|
+
type: {
|
|
6354
|
+
kind: "struct",
|
|
6355
|
+
fields: [
|
|
6356
|
+
{
|
|
6357
|
+
name: "cliff_fee_numerator",
|
|
6358
|
+
type: "u64"
|
|
6359
|
+
},
|
|
6360
|
+
{
|
|
6361
|
+
name: "base_fee_mode",
|
|
6362
|
+
type: "u8"
|
|
6363
|
+
},
|
|
6364
|
+
{
|
|
6365
|
+
name: "padding",
|
|
6366
|
+
type: {
|
|
6367
|
+
array: [
|
|
6368
|
+
"u8",
|
|
6369
|
+
5
|
|
6370
|
+
]
|
|
6371
|
+
}
|
|
6372
|
+
},
|
|
6373
|
+
{
|
|
6374
|
+
name: "number_of_period",
|
|
6375
|
+
type: "u16"
|
|
6376
|
+
},
|
|
6377
|
+
{
|
|
6378
|
+
name: "sqrt_price_step_bps",
|
|
6379
|
+
type: "u32"
|
|
6380
|
+
},
|
|
6381
|
+
{
|
|
6382
|
+
name: "scheduler_expiration_duration",
|
|
6383
|
+
type: "u32"
|
|
6384
|
+
},
|
|
6385
|
+
{
|
|
6386
|
+
name: "reduction_factor",
|
|
6387
|
+
type: "u64"
|
|
6388
|
+
}
|
|
6389
|
+
]
|
|
6390
|
+
}
|
|
6391
|
+
},
|
|
6392
|
+
{
|
|
6393
|
+
name: "PodAlignedFeeRateLimiter",
|
|
6394
|
+
serialization: "bytemuck",
|
|
6395
|
+
repr: {
|
|
6396
|
+
kind: "c"
|
|
6397
|
+
},
|
|
6398
|
+
type: {
|
|
6399
|
+
kind: "struct",
|
|
6400
|
+
fields: [
|
|
6401
|
+
{
|
|
6402
|
+
name: "cliff_fee_numerator",
|
|
6403
|
+
type: "u64"
|
|
6404
|
+
},
|
|
6405
|
+
{
|
|
6406
|
+
name: "base_fee_mode",
|
|
6407
|
+
type: "u8"
|
|
6408
|
+
},
|
|
6409
|
+
{
|
|
6410
|
+
name: "padding",
|
|
6411
|
+
type: {
|
|
6412
|
+
array: [
|
|
6413
|
+
"u8",
|
|
6414
|
+
5
|
|
6415
|
+
]
|
|
6416
|
+
}
|
|
6417
|
+
},
|
|
6418
|
+
{
|
|
6419
|
+
name: "fee_increment_bps",
|
|
6420
|
+
type: "u16"
|
|
6421
|
+
},
|
|
6422
|
+
{
|
|
6423
|
+
name: "max_limiter_duration",
|
|
6424
|
+
type: "u32"
|
|
6425
|
+
},
|
|
6426
|
+
{
|
|
6427
|
+
name: "max_fee_bps",
|
|
6428
|
+
type: "u32"
|
|
6429
|
+
},
|
|
6430
|
+
{
|
|
6431
|
+
name: "reference_amount",
|
|
6432
|
+
type: "u64"
|
|
6433
|
+
}
|
|
6434
|
+
]
|
|
6435
|
+
}
|
|
6436
|
+
},
|
|
6437
|
+
{
|
|
6438
|
+
name: "PodAlignedFeeTimeScheduler",
|
|
6439
|
+
serialization: "bytemuck",
|
|
6440
|
+
repr: {
|
|
6441
|
+
kind: "c"
|
|
6442
|
+
},
|
|
6178
6443
|
type: {
|
|
6179
6444
|
kind: "struct",
|
|
6180
6445
|
fields: [
|
|
6181
6446
|
{
|
|
6182
|
-
name: "
|
|
6183
|
-
|
|
6184
|
-
"initialize liquidity"
|
|
6185
|
-
],
|
|
6186
|
-
type: "u128"
|
|
6447
|
+
name: "cliff_fee_numerator",
|
|
6448
|
+
type: "u64"
|
|
6187
6449
|
},
|
|
6188
6450
|
{
|
|
6189
|
-
name: "
|
|
6190
|
-
|
|
6191
|
-
"The init price of the pool as a sqrt(token_b/token_a) Q64.64 value"
|
|
6192
|
-
],
|
|
6193
|
-
type: "u128"
|
|
6451
|
+
name: "base_fee_mode",
|
|
6452
|
+
type: "u8"
|
|
6194
6453
|
},
|
|
6195
6454
|
{
|
|
6196
|
-
name: "
|
|
6197
|
-
docs: [
|
|
6198
|
-
"activation point"
|
|
6199
|
-
],
|
|
6455
|
+
name: "padding",
|
|
6200
6456
|
type: {
|
|
6201
|
-
|
|
6457
|
+
array: [
|
|
6458
|
+
"u8",
|
|
6459
|
+
5
|
|
6460
|
+
]
|
|
6202
6461
|
}
|
|
6462
|
+
},
|
|
6463
|
+
{
|
|
6464
|
+
name: "number_of_period",
|
|
6465
|
+
type: "u16"
|
|
6466
|
+
},
|
|
6467
|
+
{
|
|
6468
|
+
name: "period_frequency",
|
|
6469
|
+
type: "u64"
|
|
6470
|
+
},
|
|
6471
|
+
{
|
|
6472
|
+
name: "reduction_factor",
|
|
6473
|
+
type: "u64"
|
|
6203
6474
|
}
|
|
6204
6475
|
]
|
|
6205
6476
|
}
|
|
@@ -6367,7 +6638,7 @@ var cp_amm_default = {
|
|
|
6367
6638
|
{
|
|
6368
6639
|
name: "collect_fee_mode",
|
|
6369
6640
|
docs: [
|
|
6370
|
-
"0 is collect fee in both token, 1 only collect fee
|
|
6641
|
+
"0 is collect fee in both token, 1 only collect fee only in token b"
|
|
6371
6642
|
],
|
|
6372
6643
|
type: "u8"
|
|
6373
6644
|
},
|
|
@@ -6488,18 +6759,6 @@ var cp_amm_default = {
|
|
|
6488
6759
|
}
|
|
6489
6760
|
}
|
|
6490
6761
|
},
|
|
6491
|
-
{
|
|
6492
|
-
name: "padding",
|
|
6493
|
-
docs: [
|
|
6494
|
-
"padding"
|
|
6495
|
-
],
|
|
6496
|
-
type: {
|
|
6497
|
-
array: [
|
|
6498
|
-
"u8",
|
|
6499
|
-
3
|
|
6500
|
-
]
|
|
6501
|
-
}
|
|
6502
|
-
},
|
|
6503
6762
|
{
|
|
6504
6763
|
name: "dynamic_fee",
|
|
6505
6764
|
docs: [
|
|
@@ -6529,7 +6788,7 @@ var cp_amm_default = {
|
|
|
6529
6788
|
name: "base_fee",
|
|
6530
6789
|
type: {
|
|
6531
6790
|
defined: {
|
|
6532
|
-
name: "
|
|
6791
|
+
name: "BaseFeeInfo"
|
|
6533
6792
|
}
|
|
6534
6793
|
}
|
|
6535
6794
|
},
|
|
@@ -6651,16 +6910,8 @@ var cp_amm_default = {
|
|
|
6651
6910
|
}
|
|
6652
6911
|
},
|
|
6653
6912
|
{
|
|
6654
|
-
name: "
|
|
6655
|
-
|
|
6656
|
-
"padding"
|
|
6657
|
-
],
|
|
6658
|
-
type: {
|
|
6659
|
-
array: [
|
|
6660
|
-
"u64",
|
|
6661
|
-
2
|
|
6662
|
-
]
|
|
6663
|
-
}
|
|
6913
|
+
name: "init_sqrt_price",
|
|
6914
|
+
type: "u128"
|
|
6664
6915
|
}
|
|
6665
6916
|
]
|
|
6666
6917
|
}
|
|
@@ -7240,41 +7491,6 @@ var cp_amm_default = {
|
|
|
7240
7491
|
]
|
|
7241
7492
|
}
|
|
7242
7493
|
},
|
|
7243
|
-
{
|
|
7244
|
-
name: "SwapResult",
|
|
7245
|
-
docs: [
|
|
7246
|
-
"Encodes all results of swapping"
|
|
7247
|
-
],
|
|
7248
|
-
type: {
|
|
7249
|
-
kind: "struct",
|
|
7250
|
-
fields: [
|
|
7251
|
-
{
|
|
7252
|
-
name: "output_amount",
|
|
7253
|
-
type: "u64"
|
|
7254
|
-
},
|
|
7255
|
-
{
|
|
7256
|
-
name: "next_sqrt_price",
|
|
7257
|
-
type: "u128"
|
|
7258
|
-
},
|
|
7259
|
-
{
|
|
7260
|
-
name: "lp_fee",
|
|
7261
|
-
type: "u64"
|
|
7262
|
-
},
|
|
7263
|
-
{
|
|
7264
|
-
name: "protocol_fee",
|
|
7265
|
-
type: "u64"
|
|
7266
|
-
},
|
|
7267
|
-
{
|
|
7268
|
-
name: "partner_fee",
|
|
7269
|
-
type: "u64"
|
|
7270
|
-
},
|
|
7271
|
-
{
|
|
7272
|
-
name: "referral_fee",
|
|
7273
|
-
type: "u64"
|
|
7274
|
-
}
|
|
7275
|
-
]
|
|
7276
|
-
}
|
|
7277
|
-
},
|
|
7278
7494
|
{
|
|
7279
7495
|
name: "SwapResult2",
|
|
7280
7496
|
type: {
|
|
@@ -7353,6 +7569,41 @@ var cp_amm_default = {
|
|
|
7353
7569
|
]
|
|
7354
7570
|
}
|
|
7355
7571
|
},
|
|
7572
|
+
{
|
|
7573
|
+
name: "UpdatePoolFeesParameters",
|
|
7574
|
+
type: {
|
|
7575
|
+
kind: "struct",
|
|
7576
|
+
fields: [
|
|
7577
|
+
{
|
|
7578
|
+
name: "cliff_fee_numerator",
|
|
7579
|
+
docs: [
|
|
7580
|
+
"Base fee update mode:",
|
|
7581
|
+
"- None: skip base fee update",
|
|
7582
|
+
"- Some: update new cliff_fee_numerator if base fee is static"
|
|
7583
|
+
],
|
|
7584
|
+
type: {
|
|
7585
|
+
option: "u64"
|
|
7586
|
+
}
|
|
7587
|
+
},
|
|
7588
|
+
{
|
|
7589
|
+
name: "dynamic_fee",
|
|
7590
|
+
docs: [
|
|
7591
|
+
"Dynamic fee update mode:",
|
|
7592
|
+
"- None: skip dynamic fee update",
|
|
7593
|
+
"- Some(with default value): disable dynamic fee",
|
|
7594
|
+
"- Some(with non default value): enable dynamic fee if disabled or update dynamic fee if enabled"
|
|
7595
|
+
],
|
|
7596
|
+
type: {
|
|
7597
|
+
option: {
|
|
7598
|
+
defined: {
|
|
7599
|
+
name: "DynamicFeeParameters"
|
|
7600
|
+
}
|
|
7601
|
+
}
|
|
7602
|
+
}
|
|
7603
|
+
}
|
|
7604
|
+
]
|
|
7605
|
+
}
|
|
7606
|
+
},
|
|
7356
7607
|
{
|
|
7357
7608
|
name: "UserRewardInfo",
|
|
7358
7609
|
serialization: "bytemuck",
|
|
@@ -7479,6 +7730,94 @@ var cp_amm_default = {
|
|
|
7479
7730
|
]
|
|
7480
7731
|
}
|
|
7481
7732
|
}
|
|
7733
|
+
],
|
|
7734
|
+
constants: [
|
|
7735
|
+
{
|
|
7736
|
+
name: "BIN_STEP_BPS_DEFAULT",
|
|
7737
|
+
type: "u16",
|
|
7738
|
+
value: "1"
|
|
7739
|
+
},
|
|
7740
|
+
{
|
|
7741
|
+
name: "BIN_STEP_U128_DEFAULT_LE_BYTES",
|
|
7742
|
+
type: {
|
|
7743
|
+
array: [
|
|
7744
|
+
"u8",
|
|
7745
|
+
16
|
|
7746
|
+
]
|
|
7747
|
+
},
|
|
7748
|
+
value: "[203, 16, 199, 186, 184, 141, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0]"
|
|
7749
|
+
},
|
|
7750
|
+
{
|
|
7751
|
+
name: "CUSTOMIZABLE_POOL_PREFIX",
|
|
7752
|
+
type: "bytes",
|
|
7753
|
+
value: "[99, 112, 111, 111, 108]"
|
|
7754
|
+
},
|
|
7755
|
+
{
|
|
7756
|
+
name: "FEE_DENOMINATOR",
|
|
7757
|
+
docs: [
|
|
7758
|
+
"Default fee denominator. DO NOT simply update it as it will break logic that depends on it as default value."
|
|
7759
|
+
],
|
|
7760
|
+
type: "u64",
|
|
7761
|
+
value: "1000000000"
|
|
7762
|
+
},
|
|
7763
|
+
{
|
|
7764
|
+
name: "MAX_BASIS_POINT",
|
|
7765
|
+
docs: [
|
|
7766
|
+
"Max basis point. 100% in pct"
|
|
7767
|
+
],
|
|
7768
|
+
type: "u64",
|
|
7769
|
+
value: "10000"
|
|
7770
|
+
},
|
|
7771
|
+
{
|
|
7772
|
+
name: "MAX_SQRT_PRICE_LE_BYTES",
|
|
7773
|
+
type: {
|
|
7774
|
+
array: [
|
|
7775
|
+
"u8",
|
|
7776
|
+
16
|
|
7777
|
+
]
|
|
7778
|
+
},
|
|
7779
|
+
value: "[155, 87, 105, 78, 169, 26, 92, 132, 177, 196, 254, 255, 0, 0, 0, 0]"
|
|
7780
|
+
},
|
|
7781
|
+
{
|
|
7782
|
+
name: "MIN_SQRT_PRICE_LE_BYTES",
|
|
7783
|
+
type: {
|
|
7784
|
+
array: [
|
|
7785
|
+
"u8",
|
|
7786
|
+
16
|
|
7787
|
+
]
|
|
7788
|
+
},
|
|
7789
|
+
value: "[80, 59, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]"
|
|
7790
|
+
},
|
|
7791
|
+
{
|
|
7792
|
+
name: "POOL_AUTHORITY_PREFIX",
|
|
7793
|
+
type: "bytes",
|
|
7794
|
+
value: "[112, 111, 111, 108, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121]"
|
|
7795
|
+
},
|
|
7796
|
+
{
|
|
7797
|
+
name: "POOL_PREFIX",
|
|
7798
|
+
type: "bytes",
|
|
7799
|
+
value: "[112, 111, 111, 108]"
|
|
7800
|
+
},
|
|
7801
|
+
{
|
|
7802
|
+
name: "POSITION_NFT_ACCOUNT_PREFIX",
|
|
7803
|
+
type: "bytes",
|
|
7804
|
+
value: "[112, 111, 115, 105, 116, 105, 111, 110, 95, 110, 102, 116, 95, 97, 99, 99, 111, 117, 110, 116]"
|
|
7805
|
+
},
|
|
7806
|
+
{
|
|
7807
|
+
name: "POSITION_PREFIX",
|
|
7808
|
+
type: "bytes",
|
|
7809
|
+
value: "[112, 111, 115, 105, 116, 105, 111, 110]"
|
|
7810
|
+
},
|
|
7811
|
+
{
|
|
7812
|
+
name: "SPLIT_POSITION_DENOMINATOR",
|
|
7813
|
+
type: "u32",
|
|
7814
|
+
value: "1000000000"
|
|
7815
|
+
},
|
|
7816
|
+
{
|
|
7817
|
+
name: "TOKEN_VAULT_PREFIX",
|
|
7818
|
+
type: "bytes",
|
|
7819
|
+
value: "[116, 111, 107, 101, 110, 95, 118, 97, 117, 108, 116]"
|
|
7820
|
+
}
|
|
7482
7821
|
]
|
|
7483
7822
|
};
|
|
7484
7823
|
|
|
@@ -7501,9 +7840,11 @@ var ActivationPoint = /* @__PURE__ */ ((ActivationPoint2) => {
|
|
|
7501
7840
|
return ActivationPoint2;
|
|
7502
7841
|
})(ActivationPoint || {});
|
|
7503
7842
|
var BaseFeeMode = /* @__PURE__ */ ((BaseFeeMode3) => {
|
|
7504
|
-
BaseFeeMode3[BaseFeeMode3["
|
|
7505
|
-
BaseFeeMode3[BaseFeeMode3["
|
|
7843
|
+
BaseFeeMode3[BaseFeeMode3["FeeTimeSchedulerLinear"] = 0] = "FeeTimeSchedulerLinear";
|
|
7844
|
+
BaseFeeMode3[BaseFeeMode3["FeeTimeSchedulerExponential"] = 1] = "FeeTimeSchedulerExponential";
|
|
7506
7845
|
BaseFeeMode3[BaseFeeMode3["RateLimiter"] = 2] = "RateLimiter";
|
|
7846
|
+
BaseFeeMode3[BaseFeeMode3["FeeMarketCapSchedulerLinear"] = 3] = "FeeMarketCapSchedulerLinear";
|
|
7847
|
+
BaseFeeMode3[BaseFeeMode3["FeeMarketCapSchedulerExponential"] = 4] = "FeeMarketCapSchedulerExponential";
|
|
7507
7848
|
return BaseFeeMode3;
|
|
7508
7849
|
})(BaseFeeMode || {});
|
|
7509
7850
|
var CollectFeeMode = /* @__PURE__ */ ((CollectFeeMode3) => {
|
|
@@ -7521,10 +7862,10 @@ var ActivationType = /* @__PURE__ */ ((ActivationType3) => {
|
|
|
7521
7862
|
ActivationType3[ActivationType3["Timestamp"] = 1] = "Timestamp";
|
|
7522
7863
|
return ActivationType3;
|
|
7523
7864
|
})(ActivationType || {});
|
|
7524
|
-
var PoolVersion = /* @__PURE__ */ ((
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
return
|
|
7865
|
+
var PoolVersion = /* @__PURE__ */ ((PoolVersion4) => {
|
|
7866
|
+
PoolVersion4[PoolVersion4["V0"] = 0] = "V0";
|
|
7867
|
+
PoolVersion4[PoolVersion4["V1"] = 1] = "V1";
|
|
7868
|
+
return PoolVersion4;
|
|
7528
7869
|
})(PoolVersion || {});
|
|
7529
7870
|
var PoolStatus = /* @__PURE__ */ ((PoolStatus2) => {
|
|
7530
7871
|
PoolStatus2[PoolStatus2["Enable"] = 0] = "Enable";
|
|
@@ -7578,7 +7919,8 @@ var U16_MAX = 65535;
|
|
|
7578
7919
|
var MAX_RATE_LIMITER_DURATION_IN_SECONDS = 43200;
|
|
7579
7920
|
var MAX_RATE_LIMITER_DURATION_IN_SLOTS = 108e3;
|
|
7580
7921
|
var SPLIT_POSITION_DENOMINATOR = 1e9;
|
|
7581
|
-
var CURRENT_POOL_VERSION =
|
|
7922
|
+
var CURRENT_POOL_VERSION = 1 /* V1 */;
|
|
7923
|
+
var FEE_PADDING = Array.from(Buffer.alloc(3));
|
|
7582
7924
|
|
|
7583
7925
|
// src/pda.ts
|
|
7584
7926
|
function getFirstKey(key1, key2) {
|
|
@@ -7666,6 +8008,12 @@ function derivePositionNftAccount(positionNftMint) {
|
|
|
7666
8008
|
CP_AMM_PROGRAM_ID
|
|
7667
8009
|
)[0];
|
|
7668
8010
|
}
|
|
8011
|
+
function deriveOperatorAddress(whitelistedAddress) {
|
|
8012
|
+
return PublicKey2.findProgramAddressSync(
|
|
8013
|
+
[Buffer.from("operator"), whitelistedAddress.toBuffer()],
|
|
8014
|
+
CP_AMM_PROGRAM_ID
|
|
8015
|
+
)[0];
|
|
8016
|
+
}
|
|
7669
8017
|
|
|
7670
8018
|
// src/helpers/token.ts
|
|
7671
8019
|
import { bs58 } from "@coral-xyz/anchor/dist/cjs/utils/bytes";
|
|
@@ -8100,7 +8448,8 @@ import {
|
|
|
8100
8448
|
calculateFee,
|
|
8101
8449
|
getEpochFee,
|
|
8102
8450
|
getTransferFeeConfig,
|
|
8103
|
-
MAX_FEE_BASIS_POINTS
|
|
8451
|
+
MAX_FEE_BASIS_POINTS,
|
|
8452
|
+
TOKEN_2022_PROGRAM_ID as TOKEN_2022_PROGRAM_ID2
|
|
8104
8453
|
} from "@solana/spl-token";
|
|
8105
8454
|
function calculatePreFeeAmount(transferFee, postFeeAmount) {
|
|
8106
8455
|
if (postFeeAmount.isZero()) {
|
|
@@ -8175,6 +8524,61 @@ function calculateTransferFeeExcludedAmount(transferFeeIncludedAmount, mint, cur
|
|
|
8175
8524
|
transferFee: new BN3(transferFee.toString())
|
|
8176
8525
|
};
|
|
8177
8526
|
}
|
|
8527
|
+
function hasTransferHookExtension(connection, mint) {
|
|
8528
|
+
return __async(this, null, function* () {
|
|
8529
|
+
try {
|
|
8530
|
+
const mintAccountInfo = yield connection.getAccountInfo(mint);
|
|
8531
|
+
if (!mintAccountInfo) {
|
|
8532
|
+
return { hasTransferHook: false };
|
|
8533
|
+
}
|
|
8534
|
+
const isToken2022 = mintAccountInfo.owner.equals(TOKEN_2022_PROGRAM_ID2);
|
|
8535
|
+
if (!isToken2022) {
|
|
8536
|
+
return { hasTransferHook: false };
|
|
8537
|
+
}
|
|
8538
|
+
const parsedInfo = yield connection.getParsedAccountInfo(mint);
|
|
8539
|
+
if (parsedInfo.value && "parsed" in parsedInfo.value.data) {
|
|
8540
|
+
const parsedData = parsedInfo.value.data.parsed;
|
|
8541
|
+
if (parsedData && parsedData.info && parsedData.info.extensions) {
|
|
8542
|
+
const extensions = parsedData.info.extensions;
|
|
8543
|
+
const transferHookExtension = extensions.find(
|
|
8544
|
+
(ext) => ext.extension === "transferHook"
|
|
8545
|
+
);
|
|
8546
|
+
if (transferHookExtension && transferHookExtension.state) {
|
|
8547
|
+
return {
|
|
8548
|
+
hasTransferHook: true,
|
|
8549
|
+
transferHookState: {
|
|
8550
|
+
authority: transferHookExtension.state.authority,
|
|
8551
|
+
programId: transferHookExtension.state.programId
|
|
8552
|
+
}
|
|
8553
|
+
};
|
|
8554
|
+
}
|
|
8555
|
+
}
|
|
8556
|
+
}
|
|
8557
|
+
return { hasTransferHook: false };
|
|
8558
|
+
} catch (error) {
|
|
8559
|
+
return { hasTransferHook: false };
|
|
8560
|
+
}
|
|
8561
|
+
});
|
|
8562
|
+
}
|
|
8563
|
+
function validateNoTransferHook(connection, tokenAMint, tokenBMint) {
|
|
8564
|
+
return __async(this, null, function* () {
|
|
8565
|
+
var _a, _b;
|
|
8566
|
+
const [tokenACheck, tokenBCheck] = yield Promise.all([
|
|
8567
|
+
hasTransferHookExtension(connection, tokenAMint),
|
|
8568
|
+
hasTransferHookExtension(connection, tokenBMint)
|
|
8569
|
+
]);
|
|
8570
|
+
if (tokenACheck.hasTransferHook) {
|
|
8571
|
+
throw new Error(
|
|
8572
|
+
`Token A (${tokenAMint.toBase58()}) has a transfer hook extension. Transfer hook might prevent permissionless pool creation. Transfer hook program: ${(_a = tokenACheck.transferHookState) == null ? void 0 : _a.programId}`
|
|
8573
|
+
);
|
|
8574
|
+
}
|
|
8575
|
+
if (tokenBCheck.hasTransferHook) {
|
|
8576
|
+
throw new Error(
|
|
8577
|
+
`Token B (${tokenBMint.toBase58()}) has a transfer hook extension. Transfer hook might prevent permissionless pool creation. Transfer hook program: ${(_b = tokenBCheck.transferHookState) == null ? void 0 : _b.programId}`
|
|
8578
|
+
);
|
|
8579
|
+
}
|
|
8580
|
+
});
|
|
8581
|
+
}
|
|
8178
8582
|
|
|
8179
8583
|
// src/helpers/vestings.ts
|
|
8180
8584
|
import { BN as BN4 } from "@coral-xyz/anchor";
|
|
@@ -8218,10 +8622,10 @@ function getAvailableVestingLiquidity(vestingData, currentPoint) {
|
|
|
8218
8622
|
}
|
|
8219
8623
|
|
|
8220
8624
|
// src/helpers/validation.ts
|
|
8221
|
-
import
|
|
8625
|
+
import BN16 from "bn.js";
|
|
8222
8626
|
|
|
8223
8627
|
// src/math/poolFees/baseFee.ts
|
|
8224
|
-
import
|
|
8628
|
+
import BN11 from "bn.js";
|
|
8225
8629
|
|
|
8226
8630
|
// src/math/poolFees/rateLimiter.ts
|
|
8227
8631
|
import BN7 from "bn.js";
|
|
@@ -8420,35 +8824,27 @@ function getTotalFeeNumerator(poolFees, baseFeeNumerator, maxFeeNumerator) {
|
|
|
8420
8824
|
const totalFeeNumerator = dynamicFeeNumerator.add(baseFeeNumerator);
|
|
8421
8825
|
return BN6.min(totalFeeNumerator, maxFeeNumerator);
|
|
8422
8826
|
}
|
|
8423
|
-
function getTotalTradingFeeFromIncludedFeeAmount(poolFees, currentPoint, activationPoint, includedFeeAmount, tradeDirection, maxFeeNumerator) {
|
|
8424
|
-
const baseFeeHandler = getBaseFeeHandler(
|
|
8425
|
-
poolFees.baseFee.cliffFeeNumerator,
|
|
8426
|
-
poolFees.baseFee.firstFactor,
|
|
8427
|
-
poolFees.baseFee.secondFactor,
|
|
8428
|
-
poolFees.baseFee.thirdFactor,
|
|
8429
|
-
poolFees.baseFee.baseFeeMode
|
|
8430
|
-
);
|
|
8827
|
+
function getTotalTradingFeeFromIncludedFeeAmount(poolFees, currentPoint, activationPoint, includedFeeAmount, tradeDirection, maxFeeNumerator, initSqrtPrice, currentSqrtPrice) {
|
|
8828
|
+
const baseFeeHandler = getBaseFeeHandler(poolFees.baseFee.baseFeeInfo.data);
|
|
8431
8829
|
const baseFeeNumerator = baseFeeHandler.getBaseFeeNumeratorFromIncludedFeeAmount(
|
|
8432
8830
|
currentPoint,
|
|
8433
8831
|
activationPoint,
|
|
8434
8832
|
tradeDirection,
|
|
8435
|
-
includedFeeAmount
|
|
8833
|
+
includedFeeAmount,
|
|
8834
|
+
initSqrtPrice,
|
|
8835
|
+
currentSqrtPrice
|
|
8436
8836
|
);
|
|
8437
8837
|
return getTotalFeeNumerator(poolFees, baseFeeNumerator, maxFeeNumerator);
|
|
8438
8838
|
}
|
|
8439
|
-
function getTotalTradingFeeFromExcludedFeeAmount(poolFees, currentPoint, activationPoint, excludedFeeAmount, tradeDirection, maxFeeNumerator) {
|
|
8440
|
-
const baseFeeHandler = getBaseFeeHandler(
|
|
8441
|
-
poolFees.baseFee.cliffFeeNumerator,
|
|
8442
|
-
poolFees.baseFee.firstFactor,
|
|
8443
|
-
poolFees.baseFee.secondFactor,
|
|
8444
|
-
poolFees.baseFee.thirdFactor,
|
|
8445
|
-
poolFees.baseFee.baseFeeMode
|
|
8446
|
-
);
|
|
8839
|
+
function getTotalTradingFeeFromExcludedFeeAmount(poolFees, currentPoint, activationPoint, excludedFeeAmount, tradeDirection, maxFeeNumerator, initSqrtPrice, currentSqrtPrice) {
|
|
8840
|
+
const baseFeeHandler = getBaseFeeHandler(poolFees.baseFee.baseFeeInfo.data);
|
|
8447
8841
|
const baseFeeNumerator = baseFeeHandler.getBaseFeeNumeratorFromExcludedFeeAmount(
|
|
8448
8842
|
currentPoint,
|
|
8449
8843
|
activationPoint,
|
|
8450
8844
|
tradeDirection,
|
|
8451
|
-
excludedFeeAmount
|
|
8845
|
+
excludedFeeAmount,
|
|
8846
|
+
initSqrtPrice,
|
|
8847
|
+
currentSqrtPrice
|
|
8452
8848
|
);
|
|
8453
8849
|
return getTotalFeeNumerator(poolFees, baseFeeNumerator, maxFeeNumerator);
|
|
8454
8850
|
}
|
|
@@ -8763,31 +9159,120 @@ function getFeeNumeratorFromExcludedFeeAmount(excludedFeeAmount, referenceAmount
|
|
|
8763
9159
|
if (feeNumerator.lt(cliffFeeNumerator)) {
|
|
8764
9160
|
throw new Error("feeNumerator is less than cliffFeeNumerator");
|
|
8765
9161
|
}
|
|
8766
|
-
return feeNumerator;
|
|
8767
|
-
}
|
|
8768
|
-
|
|
8769
|
-
// src/math/poolFees/
|
|
8770
|
-
import
|
|
8771
|
-
|
|
8772
|
-
|
|
9162
|
+
return feeNumerator;
|
|
9163
|
+
}
|
|
9164
|
+
|
|
9165
|
+
// src/math/poolFees/feeTimeScheduler.ts
|
|
9166
|
+
import BN9 from "bn.js";
|
|
9167
|
+
|
|
9168
|
+
// src/math/poolFees/feeScheduler.ts
|
|
9169
|
+
import BN8 from "bn.js";
|
|
9170
|
+
function getFeeNumeratorOnLinearFeeScheduler(cliffFeeNumerator, reductionFactor, period) {
|
|
9171
|
+
const reduction = new BN8(period).mul(reductionFactor);
|
|
9172
|
+
return cliffFeeNumerator.sub(reduction);
|
|
9173
|
+
}
|
|
9174
|
+
function getFeeNumeratorOnExponentialFeeScheduler(cliffFeeNumerator, reductionFactor, period) {
|
|
9175
|
+
if (period === 0) {
|
|
9176
|
+
return cliffFeeNumerator;
|
|
9177
|
+
}
|
|
9178
|
+
const basisPointMax = new BN8(BASIS_POINT_MAX);
|
|
9179
|
+
const bps = new BN8(reductionFactor).shln(64).div(basisPointMax);
|
|
9180
|
+
const base = ONE_Q64.sub(bps);
|
|
9181
|
+
const result = pow(base, new BN8(period));
|
|
9182
|
+
return cliffFeeNumerator.mul(result).div(ONE_Q64);
|
|
9183
|
+
}
|
|
9184
|
+
function getMaxBaseFeeNumerator(cliffFeeNumerator) {
|
|
9185
|
+
return cliffFeeNumerator;
|
|
9186
|
+
}
|
|
9187
|
+
|
|
9188
|
+
// src/math/poolFees/feeTimeScheduler.ts
|
|
9189
|
+
function toPodAlignedFeeTimeScheduler(borshFeeScheduler) {
|
|
9190
|
+
return {
|
|
9191
|
+
cliffFeeNumerator: borshFeeScheduler.cliffFeeNumerator,
|
|
9192
|
+
baseFeeMode: borshFeeScheduler.baseFeeMode,
|
|
9193
|
+
padding: new Array(16).fill(0),
|
|
9194
|
+
// Assumes default/rust alignment of 16
|
|
9195
|
+
numberOfPeriod: borshFeeScheduler.numberOfPeriod,
|
|
9196
|
+
periodFrequency: borshFeeScheduler.periodFrequency,
|
|
9197
|
+
reductionFactor: borshFeeScheduler.reductionFactor
|
|
9198
|
+
};
|
|
9199
|
+
}
|
|
9200
|
+
function toBorshFeeTimeScheduler(podAlignedFeeScheduler) {
|
|
9201
|
+
return {
|
|
9202
|
+
cliffFeeNumerator: podAlignedFeeScheduler.cliffFeeNumerator,
|
|
9203
|
+
numberOfPeriod: podAlignedFeeScheduler.numberOfPeriod,
|
|
9204
|
+
periodFrequency: podAlignedFeeScheduler.periodFrequency,
|
|
9205
|
+
reductionFactor: podAlignedFeeScheduler.reductionFactor,
|
|
9206
|
+
baseFeeMode: podAlignedFeeScheduler.baseFeeMode,
|
|
9207
|
+
padding: new Array(16).fill(0)
|
|
9208
|
+
// Assumes default/rust alignment of 16
|
|
9209
|
+
};
|
|
9210
|
+
}
|
|
9211
|
+
function getFeeTimeBaseFeeNumeratorByPeriod(cliffFeeNumerator, numberOfPeriod, period, reductionFactor, feeTimeSchedulerMode) {
|
|
9212
|
+
const periodValue = BN9.min(period, new BN9(numberOfPeriod));
|
|
9213
|
+
const periodNumber = periodValue.toNumber();
|
|
9214
|
+
if (periodNumber > U16_MAX) {
|
|
9215
|
+
throw new Error("Math overflow");
|
|
9216
|
+
}
|
|
9217
|
+
switch (feeTimeSchedulerMode) {
|
|
9218
|
+
case 0 /* FeeTimeSchedulerLinear */: {
|
|
9219
|
+
const feeNumerator = getFeeNumeratorOnLinearFeeScheduler(
|
|
9220
|
+
cliffFeeNumerator,
|
|
9221
|
+
reductionFactor,
|
|
9222
|
+
periodNumber
|
|
9223
|
+
);
|
|
9224
|
+
return feeNumerator;
|
|
9225
|
+
}
|
|
9226
|
+
case 1 /* FeeTimeSchedulerExponential */: {
|
|
9227
|
+
const feeNumerator = getFeeNumeratorOnExponentialFeeScheduler(
|
|
9228
|
+
cliffFeeNumerator,
|
|
9229
|
+
reductionFactor,
|
|
9230
|
+
periodNumber
|
|
9231
|
+
);
|
|
9232
|
+
return feeNumerator;
|
|
9233
|
+
}
|
|
9234
|
+
default:
|
|
9235
|
+
throw new Error("Invalid fee time scheduler mode");
|
|
9236
|
+
}
|
|
9237
|
+
}
|
|
9238
|
+
function getFeeTimeBaseFeeNumerator(cliffFeeNumerator, numberOfPeriod, periodFrequency, reductionFactor, feeTimeSchedulerMode, currentPoint, activationPoint) {
|
|
9239
|
+
if (periodFrequency.isZero()) {
|
|
9240
|
+
return cliffFeeNumerator;
|
|
9241
|
+
}
|
|
9242
|
+
let period;
|
|
9243
|
+
if (currentPoint.lt(activationPoint)) {
|
|
9244
|
+
period = new BN9(numberOfPeriod);
|
|
9245
|
+
} else {
|
|
9246
|
+
period = currentPoint.sub(activationPoint).div(periodFrequency);
|
|
9247
|
+
if (period.gt(new BN9(numberOfPeriod))) {
|
|
9248
|
+
period = new BN9(numberOfPeriod);
|
|
9249
|
+
}
|
|
9250
|
+
}
|
|
9251
|
+
return getFeeTimeBaseFeeNumeratorByPeriod(
|
|
9252
|
+
cliffFeeNumerator,
|
|
9253
|
+
numberOfPeriod,
|
|
9254
|
+
period,
|
|
9255
|
+
reductionFactor,
|
|
9256
|
+
feeTimeSchedulerMode
|
|
9257
|
+
);
|
|
8773
9258
|
}
|
|
8774
|
-
function
|
|
8775
|
-
return
|
|
9259
|
+
function getFeeTimeMinBaseFeeNumerator(cliffFeeNumerator, numberOfPeriod, reductionFactor, feeTimeSchedulerMode) {
|
|
9260
|
+
return getFeeTimeBaseFeeNumeratorByPeriod(
|
|
8776
9261
|
cliffFeeNumerator,
|
|
8777
9262
|
numberOfPeriod,
|
|
8778
|
-
new
|
|
9263
|
+
new BN9(numberOfPeriod),
|
|
8779
9264
|
reductionFactor,
|
|
8780
|
-
|
|
9265
|
+
feeTimeSchedulerMode
|
|
8781
9266
|
);
|
|
8782
9267
|
}
|
|
8783
|
-
|
|
8784
|
-
|
|
9268
|
+
|
|
9269
|
+
// src/math/poolFees/feeMarketCapScheduler.ts
|
|
9270
|
+
import BN10 from "bn.js";
|
|
9271
|
+
function getFeeMarketCapBaseFeeNumeratorByPeriod(cliffFeeNumerator, numberOfPeriod, period, reductionFactor, feeMarketCapSchedulerMode) {
|
|
9272
|
+
const periodValue = BN10.min(period, new BN10(numberOfPeriod));
|
|
8785
9273
|
const periodNumber = periodValue.toNumber();
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
}
|
|
8789
|
-
switch (feeSchedulerMode) {
|
|
8790
|
-
case 0 /* FeeSchedulerLinear */: {
|
|
9274
|
+
switch (feeMarketCapSchedulerMode) {
|
|
9275
|
+
case 3 /* FeeMarketCapSchedulerLinear */: {
|
|
8791
9276
|
const feeNumerator = getFeeNumeratorOnLinearFeeScheduler(
|
|
8792
9277
|
cliffFeeNumerator,
|
|
8793
9278
|
reductionFactor,
|
|
@@ -8795,7 +9280,7 @@ function getBaseFeeNumeratorByPeriod(cliffFeeNumerator, numberOfPeriod, period,
|
|
|
8795
9280
|
);
|
|
8796
9281
|
return feeNumerator;
|
|
8797
9282
|
}
|
|
8798
|
-
case
|
|
9283
|
+
case 4 /* FeeMarketCapSchedulerExponential */: {
|
|
8799
9284
|
const feeNumerator = getFeeNumeratorOnExponentialFeeScheduler(
|
|
8800
9285
|
cliffFeeNumerator,
|
|
8801
9286
|
reductionFactor,
|
|
@@ -8804,42 +9289,46 @@ function getBaseFeeNumeratorByPeriod(cliffFeeNumerator, numberOfPeriod, period,
|
|
|
8804
9289
|
return feeNumerator;
|
|
8805
9290
|
}
|
|
8806
9291
|
default:
|
|
8807
|
-
throw new Error("Invalid fee scheduler mode");
|
|
8808
|
-
}
|
|
8809
|
-
}
|
|
8810
|
-
function getFeeNumeratorOnLinearFeeScheduler(cliffFeeNumerator, reductionFactor, period) {
|
|
8811
|
-
const reduction = new BN8(period).mul(reductionFactor);
|
|
8812
|
-
return cliffFeeNumerator.sub(reduction);
|
|
8813
|
-
}
|
|
8814
|
-
function getFeeNumeratorOnExponentialFeeScheduler(cliffFeeNumerator, reductionFactor, period) {
|
|
8815
|
-
if (period === 0) {
|
|
8816
|
-
return cliffFeeNumerator;
|
|
9292
|
+
throw new Error("Invalid fee market cap scheduler mode");
|
|
8817
9293
|
}
|
|
8818
|
-
const basisPointMax = new BN8(BASIS_POINT_MAX);
|
|
8819
|
-
const bps = new BN8(reductionFactor).shln(64).div(basisPointMax);
|
|
8820
|
-
const base = ONE_Q64.sub(bps);
|
|
8821
|
-
const result = pow(base, new BN8(period));
|
|
8822
|
-
return cliffFeeNumerator.mul(result).div(ONE_Q64);
|
|
8823
9294
|
}
|
|
8824
|
-
function
|
|
8825
|
-
|
|
8826
|
-
|
|
8827
|
-
|
|
9295
|
+
function getFeeMarketCapBaseFeeNumerator(cliffFeeNumerator, numberOfPeriod, sqrtPriceStepBps, schedulerExpirationDuration, reductionFactor, feeMarketCapSchedulerMode, currentPoint, activationPoint, initSqrtPrice, currentSqrtPrice) {
|
|
9296
|
+
const schedulerExpirationPoint = activationPoint.add(
|
|
9297
|
+
new BN10(schedulerExpirationDuration)
|
|
9298
|
+
);
|
|
8828
9299
|
let period;
|
|
8829
|
-
if (currentPoint.lt(activationPoint)) {
|
|
8830
|
-
period = new
|
|
9300
|
+
if (currentPoint.gt(schedulerExpirationPoint) || currentPoint.lt(activationPoint)) {
|
|
9301
|
+
period = new BN10(numberOfPeriod);
|
|
8831
9302
|
} else {
|
|
8832
|
-
|
|
8833
|
-
|
|
8834
|
-
|
|
9303
|
+
if (currentSqrtPrice.lte(initSqrtPrice)) {
|
|
9304
|
+
period = new BN10(0);
|
|
9305
|
+
} else {
|
|
9306
|
+
const maxBps = new BN10(BASIS_POINT_MAX);
|
|
9307
|
+
const stepBps = new BN10(sqrtPriceStepBps);
|
|
9308
|
+
const passedPeriod = currentSqrtPrice.sub(initSqrtPrice).mul(maxBps).div(initSqrtPrice).div(stepBps);
|
|
9309
|
+
if (passedPeriod.gt(new BN10(numberOfPeriod))) {
|
|
9310
|
+
period = new BN10(numberOfPeriod);
|
|
9311
|
+
} else {
|
|
9312
|
+
period = passedPeriod;
|
|
9313
|
+
}
|
|
8835
9314
|
}
|
|
9315
|
+
period = BN10.min(period, new BN10(numberOfPeriod));
|
|
8836
9316
|
}
|
|
8837
|
-
return
|
|
9317
|
+
return getFeeMarketCapBaseFeeNumeratorByPeriod(
|
|
8838
9318
|
cliffFeeNumerator,
|
|
8839
9319
|
numberOfPeriod,
|
|
8840
9320
|
period,
|
|
8841
9321
|
reductionFactor,
|
|
8842
|
-
|
|
9322
|
+
feeMarketCapSchedulerMode
|
|
9323
|
+
);
|
|
9324
|
+
}
|
|
9325
|
+
function getFeeMarketCapMinBaseFeeNumerator(cliffFeeNumerator, numberOfPeriod, reductionFactor, feeMarketCapSchedulerMode) {
|
|
9326
|
+
return getFeeMarketCapBaseFeeNumeratorByPeriod(
|
|
9327
|
+
cliffFeeNumerator,
|
|
9328
|
+
numberOfPeriod,
|
|
9329
|
+
new BN10(numberOfPeriod),
|
|
9330
|
+
reductionFactor,
|
|
9331
|
+
feeMarketCapSchedulerMode
|
|
8843
9332
|
);
|
|
8844
9333
|
}
|
|
8845
9334
|
|
|
@@ -8864,7 +9353,7 @@ var FeeRateLimiter = class {
|
|
|
8864
9353
|
poolVersion
|
|
8865
9354
|
);
|
|
8866
9355
|
}
|
|
8867
|
-
getBaseFeeNumeratorFromIncludedFeeAmount(currentPoint, activationPoint, tradeDirection, includedFeeAmount) {
|
|
9356
|
+
getBaseFeeNumeratorFromIncludedFeeAmount(currentPoint, activationPoint, tradeDirection, includedFeeAmount, _initSqrtPrice, _currentSqrtPrice) {
|
|
8868
9357
|
if (isRateLimiterApplied(
|
|
8869
9358
|
this.referenceAmount,
|
|
8870
9359
|
this.maxLimiterDuration,
|
|
@@ -8885,7 +9374,7 @@ var FeeRateLimiter = class {
|
|
|
8885
9374
|
return this.cliffFeeNumerator;
|
|
8886
9375
|
}
|
|
8887
9376
|
}
|
|
8888
|
-
getBaseFeeNumeratorFromExcludedFeeAmount(currentPoint, activationPoint, tradeDirection, excludedFeeAmount) {
|
|
9377
|
+
getBaseFeeNumeratorFromExcludedFeeAmount(currentPoint, activationPoint, tradeDirection, excludedFeeAmount, _initSqrtPrice, _currentSqrtPrice) {
|
|
8889
9378
|
if (isRateLimiterApplied(
|
|
8890
9379
|
this.referenceAmount,
|
|
8891
9380
|
this.maxLimiterDuration,
|
|
@@ -8906,88 +9395,178 @@ var FeeRateLimiter = class {
|
|
|
8906
9395
|
return this.cliffFeeNumerator;
|
|
8907
9396
|
}
|
|
8908
9397
|
}
|
|
9398
|
+
validateBaseFeeIsStatic(currentPoint, activationPoint) {
|
|
9399
|
+
return validateFeeRateLimiterBaseFeeIsStatic(
|
|
9400
|
+
currentPoint,
|
|
9401
|
+
activationPoint,
|
|
9402
|
+
this.maxLimiterDuration,
|
|
9403
|
+
this.referenceAmount,
|
|
9404
|
+
this.maxFeeBps,
|
|
9405
|
+
this.feeIncrementBps
|
|
9406
|
+
);
|
|
9407
|
+
}
|
|
9408
|
+
getMinBaseFeeNumerator() {
|
|
9409
|
+
return this.cliffFeeNumerator;
|
|
9410
|
+
}
|
|
8909
9411
|
};
|
|
8910
|
-
var
|
|
8911
|
-
constructor(cliffFeeNumerator, numberOfPeriod, periodFrequency, reductionFactor,
|
|
9412
|
+
var FeeTimeScheduler = class {
|
|
9413
|
+
constructor(cliffFeeNumerator, numberOfPeriod, periodFrequency, reductionFactor, feeTimeSchedulerMode) {
|
|
8912
9414
|
this.cliffFeeNumerator = cliffFeeNumerator;
|
|
8913
9415
|
this.numberOfPeriod = numberOfPeriod;
|
|
8914
9416
|
this.periodFrequency = periodFrequency;
|
|
8915
9417
|
this.reductionFactor = reductionFactor;
|
|
8916
|
-
this.
|
|
9418
|
+
this.feeTimeSchedulerMode = feeTimeSchedulerMode;
|
|
8917
9419
|
}
|
|
8918
9420
|
validate(collectFeeMode, activationType, poolVersion) {
|
|
8919
|
-
return
|
|
9421
|
+
return validateFeeTimeScheduler(
|
|
8920
9422
|
this.numberOfPeriod,
|
|
8921
9423
|
this.periodFrequency,
|
|
8922
9424
|
this.reductionFactor,
|
|
8923
9425
|
this.cliffFeeNumerator,
|
|
8924
|
-
this.
|
|
9426
|
+
this.feeTimeSchedulerMode,
|
|
8925
9427
|
poolVersion
|
|
8926
9428
|
);
|
|
8927
9429
|
}
|
|
8928
|
-
getBaseFeeNumeratorFromIncludedFeeAmount(currentPoint, activationPoint) {
|
|
8929
|
-
return
|
|
9430
|
+
getBaseFeeNumeratorFromIncludedFeeAmount(currentPoint, activationPoint, _tradeDirection, _includedFeeAmount, _initSqrtPrice, _currentSqrtPrice) {
|
|
9431
|
+
return getFeeTimeBaseFeeNumerator(
|
|
8930
9432
|
this.cliffFeeNumerator,
|
|
8931
9433
|
this.numberOfPeriod,
|
|
8932
9434
|
this.periodFrequency,
|
|
8933
9435
|
this.reductionFactor,
|
|
8934
|
-
this.
|
|
9436
|
+
this.feeTimeSchedulerMode,
|
|
8935
9437
|
currentPoint,
|
|
8936
9438
|
activationPoint
|
|
8937
9439
|
);
|
|
8938
9440
|
}
|
|
8939
|
-
getBaseFeeNumeratorFromExcludedFeeAmount(currentPoint, activationPoint) {
|
|
8940
|
-
return
|
|
9441
|
+
getBaseFeeNumeratorFromExcludedFeeAmount(currentPoint, activationPoint, _tradeDirection, _excludedFeeAmount, _initSqrtPrice, _currentSqrtPrice) {
|
|
9442
|
+
return getFeeTimeBaseFeeNumerator(
|
|
8941
9443
|
this.cliffFeeNumerator,
|
|
8942
9444
|
this.numberOfPeriod,
|
|
8943
9445
|
this.periodFrequency,
|
|
8944
9446
|
this.reductionFactor,
|
|
8945
|
-
this.
|
|
9447
|
+
this.feeTimeSchedulerMode,
|
|
8946
9448
|
currentPoint,
|
|
8947
9449
|
activationPoint
|
|
8948
9450
|
);
|
|
8949
9451
|
}
|
|
9452
|
+
validateBaseFeeIsStatic(currentPoint, activationPoint) {
|
|
9453
|
+
return validateFeeTimeSchedulerBaseFeeIsStatic(
|
|
9454
|
+
currentPoint,
|
|
9455
|
+
activationPoint,
|
|
9456
|
+
new BN11(this.numberOfPeriod),
|
|
9457
|
+
this.periodFrequency
|
|
9458
|
+
);
|
|
9459
|
+
}
|
|
9460
|
+
getMinBaseFeeNumerator() {
|
|
9461
|
+
return getFeeTimeMinBaseFeeNumerator(
|
|
9462
|
+
this.cliffFeeNumerator,
|
|
9463
|
+
this.numberOfPeriod,
|
|
9464
|
+
this.reductionFactor,
|
|
9465
|
+
this.feeTimeSchedulerMode
|
|
9466
|
+
);
|
|
9467
|
+
}
|
|
9468
|
+
};
|
|
9469
|
+
var FeeMarketCapScheduler = class {
|
|
9470
|
+
constructor(cliffFeeNumerator, numberOfPeriod, sqrtPriceStepBps, schedulerExpirationDuration, reductionFactor, feeMarketCapSchedulerMode) {
|
|
9471
|
+
this.cliffFeeNumerator = cliffFeeNumerator;
|
|
9472
|
+
this.numberOfPeriod = numberOfPeriod;
|
|
9473
|
+
this.sqrtPriceStepBps = sqrtPriceStepBps;
|
|
9474
|
+
this.schedulerExpirationDuration = schedulerExpirationDuration;
|
|
9475
|
+
this.reductionFactor = reductionFactor;
|
|
9476
|
+
this.feeMarketCapSchedulerMode = feeMarketCapSchedulerMode;
|
|
9477
|
+
}
|
|
9478
|
+
validate(_collectFeeMode, _activationType, poolVersion) {
|
|
9479
|
+
return validateFeeMarketCapScheduler(
|
|
9480
|
+
this.cliffFeeNumerator,
|
|
9481
|
+
this.numberOfPeriod,
|
|
9482
|
+
new BN11(this.sqrtPriceStepBps),
|
|
9483
|
+
this.reductionFactor,
|
|
9484
|
+
new BN11(this.schedulerExpirationDuration),
|
|
9485
|
+
this.feeMarketCapSchedulerMode,
|
|
9486
|
+
poolVersion
|
|
9487
|
+
);
|
|
9488
|
+
}
|
|
9489
|
+
getBaseFeeNumeratorFromIncludedFeeAmount(currentPoint, activationPoint, _tradeDirection, _includedFeeAmount, initSqrtPrice, currentSqrtPrice) {
|
|
9490
|
+
return getFeeMarketCapBaseFeeNumerator(
|
|
9491
|
+
this.cliffFeeNumerator,
|
|
9492
|
+
this.numberOfPeriod,
|
|
9493
|
+
this.sqrtPriceStepBps,
|
|
9494
|
+
this.schedulerExpirationDuration,
|
|
9495
|
+
this.reductionFactor,
|
|
9496
|
+
this.feeMarketCapSchedulerMode,
|
|
9497
|
+
currentPoint,
|
|
9498
|
+
activationPoint,
|
|
9499
|
+
initSqrtPrice,
|
|
9500
|
+
currentSqrtPrice
|
|
9501
|
+
);
|
|
9502
|
+
}
|
|
9503
|
+
getBaseFeeNumeratorFromExcludedFeeAmount(currentPoint, activationPoint, _tradeDirection, _excludedFeeAmount, initSqrtPrice, currentSqrtPrice) {
|
|
9504
|
+
return getFeeMarketCapBaseFeeNumerator(
|
|
9505
|
+
this.cliffFeeNumerator,
|
|
9506
|
+
this.numberOfPeriod,
|
|
9507
|
+
this.sqrtPriceStepBps,
|
|
9508
|
+
this.schedulerExpirationDuration,
|
|
9509
|
+
this.reductionFactor,
|
|
9510
|
+
this.feeMarketCapSchedulerMode,
|
|
9511
|
+
currentPoint,
|
|
9512
|
+
activationPoint,
|
|
9513
|
+
initSqrtPrice,
|
|
9514
|
+
currentSqrtPrice
|
|
9515
|
+
);
|
|
9516
|
+
}
|
|
9517
|
+
validateBaseFeeIsStatic(currentPoint, activationPoint) {
|
|
9518
|
+
return validateFeeMarketCapBaseFeeIsStatic(
|
|
9519
|
+
currentPoint,
|
|
9520
|
+
activationPoint,
|
|
9521
|
+
new BN11(this.schedulerExpirationDuration)
|
|
9522
|
+
);
|
|
9523
|
+
}
|
|
9524
|
+
getMinBaseFeeNumerator() {
|
|
9525
|
+
return getFeeMarketCapMinBaseFeeNumerator(
|
|
9526
|
+
this.cliffFeeNumerator,
|
|
9527
|
+
this.numberOfPeriod,
|
|
9528
|
+
this.reductionFactor,
|
|
9529
|
+
this.feeMarketCapSchedulerMode
|
|
9530
|
+
);
|
|
9531
|
+
}
|
|
8950
9532
|
};
|
|
8951
|
-
function getBaseFeeHandler(
|
|
9533
|
+
function getBaseFeeHandler(rawData) {
|
|
9534
|
+
const data = Buffer.from(rawData);
|
|
9535
|
+
const modeIndex = data.readUInt8(8);
|
|
9536
|
+
const baseFeeMode = modeIndex;
|
|
8952
9537
|
switch (baseFeeMode) {
|
|
8953
|
-
case 0 /*
|
|
8954
|
-
case 1 /*
|
|
8955
|
-
|
|
8956
|
-
|
|
8957
|
-
|
|
8958
|
-
|
|
8959
|
-
|
|
8960
|
-
|
|
8961
|
-
|
|
8962
|
-
"le"
|
|
8963
|
-
);
|
|
8964
|
-
const feeScheduler = new FeeScheduler(
|
|
8965
|
-
cliffFeeNumerator,
|
|
8966
|
-
firstFactor,
|
|
8967
|
-
periodFrequency,
|
|
8968
|
-
thirdFactor,
|
|
8969
|
-
baseFeeMode
|
|
9538
|
+
case 0 /* FeeTimeSchedulerLinear */:
|
|
9539
|
+
case 1 /* FeeTimeSchedulerExponential */: {
|
|
9540
|
+
const poolFees = decodePodAlignedFeeTimeScheduler(data);
|
|
9541
|
+
return new FeeTimeScheduler(
|
|
9542
|
+
poolFees.cliffFeeNumerator,
|
|
9543
|
+
poolFees.numberOfPeriod,
|
|
9544
|
+
poolFees.periodFrequency,
|
|
9545
|
+
poolFees.reductionFactor,
|
|
9546
|
+
poolFees.baseFeeMode
|
|
8970
9547
|
);
|
|
8971
|
-
return feeScheduler;
|
|
8972
9548
|
}
|
|
8973
9549
|
case 2 /* RateLimiter */: {
|
|
8974
|
-
|
|
8975
|
-
|
|
8976
|
-
|
|
8977
|
-
|
|
8978
|
-
|
|
8979
|
-
|
|
8980
|
-
|
|
8981
|
-
)
|
|
8982
|
-
|
|
8983
|
-
|
|
8984
|
-
|
|
8985
|
-
|
|
8986
|
-
|
|
8987
|
-
|
|
8988
|
-
|
|
9550
|
+
const poolFees = decodePodAlignedFeeRateLimiter(data);
|
|
9551
|
+
return new FeeRateLimiter(
|
|
9552
|
+
poolFees.cliffFeeNumerator,
|
|
9553
|
+
poolFees.feeIncrementBps,
|
|
9554
|
+
poolFees.maxFeeBps,
|
|
9555
|
+
poolFees.maxLimiterDuration,
|
|
9556
|
+
poolFees.referenceAmount
|
|
9557
|
+
);
|
|
9558
|
+
}
|
|
9559
|
+
case 3 /* FeeMarketCapSchedulerLinear */:
|
|
9560
|
+
case 4 /* FeeMarketCapSchedulerExponential */: {
|
|
9561
|
+
const poolFees = decodePodAlignedFeeMarketCapScheduler(data);
|
|
9562
|
+
return new FeeMarketCapScheduler(
|
|
9563
|
+
poolFees.cliffFeeNumerator,
|
|
9564
|
+
poolFees.numberOfPeriod,
|
|
9565
|
+
poolFees.sqrtPriceStepBps,
|
|
9566
|
+
poolFees.schedulerExpirationDuration,
|
|
9567
|
+
poolFees.reductionFactor,
|
|
9568
|
+
poolFees.baseFeeMode
|
|
8989
9569
|
);
|
|
8990
|
-
return feeRateLimiter;
|
|
8991
9570
|
}
|
|
8992
9571
|
default:
|
|
8993
9572
|
throw new Error("Invalid base fee mode");
|
|
@@ -8995,21 +9574,21 @@ function getBaseFeeHandler(cliffFeeNumerator, firstFactor, secondFactor, thirdFa
|
|
|
8995
9574
|
}
|
|
8996
9575
|
|
|
8997
9576
|
// src/math/poolFees/dynamicFee.ts
|
|
8998
|
-
import
|
|
9577
|
+
import BN12 from "bn.js";
|
|
8999
9578
|
function isDynamicFeeEnabled(dynamicFee) {
|
|
9000
9579
|
return dynamicFee.initialized !== 0;
|
|
9001
9580
|
}
|
|
9002
9581
|
function getDynamicFeeNumerator(volatilityAccumulator, binStep, variableFeeControl) {
|
|
9003
|
-
const squareVfaBin = volatilityAccumulator.mul(new
|
|
9582
|
+
const squareVfaBin = volatilityAccumulator.mul(new BN12(binStep)).pow(new BN12(2));
|
|
9004
9583
|
const vFee = variableFeeControl.mul(squareVfaBin);
|
|
9005
|
-
return vFee.add(new
|
|
9584
|
+
return vFee.add(new BN12(DYNAMIC_FEE_ROUNDING_OFFSET)).div(new BN12(DYNAMIC_FEE_SCALING_FACTOR));
|
|
9006
9585
|
}
|
|
9007
9586
|
|
|
9008
9587
|
// src/math/quote.ts
|
|
9009
|
-
import
|
|
9588
|
+
import BN14 from "bn.js";
|
|
9010
9589
|
|
|
9011
9590
|
// src/math/curve.ts
|
|
9012
|
-
import
|
|
9591
|
+
import BN13 from "bn.js";
|
|
9013
9592
|
function getNextSqrtPriceFromAmountInBRoundingDown(sqrtPrice, liquidity, amount) {
|
|
9014
9593
|
const quotient = amount.shln(SCALE_OFFSET * 2).div(liquidity);
|
|
9015
9594
|
const result = sqrtPrice.add(quotient);
|
|
@@ -9039,16 +9618,16 @@ function getNextSqrtPriceFromAmountOutARoundingUp(sqrtPrice, liquidity, amount)
|
|
|
9039
9618
|
}
|
|
9040
9619
|
const product = amount.mul(sqrtPrice);
|
|
9041
9620
|
const denominator = liquidity.sub(product);
|
|
9042
|
-
if (denominator.lte(new
|
|
9621
|
+
if (denominator.lte(new BN13(0))) {
|
|
9043
9622
|
throw new Error("MathOverflow: denominator is zero or negative");
|
|
9044
9623
|
}
|
|
9045
9624
|
return mulDiv(liquidity, sqrtPrice, denominator, 0 /* Up */);
|
|
9046
9625
|
}
|
|
9047
9626
|
function getNextSqrtPriceFromOutput(sqrtPrice, liquidity, amountOut, aForB) {
|
|
9048
|
-
if (sqrtPrice.lte(new
|
|
9627
|
+
if (sqrtPrice.lte(new BN13(0))) {
|
|
9049
9628
|
throw new Error("sqrtPrice must be greater than 0");
|
|
9050
9629
|
}
|
|
9051
|
-
if (liquidity.lte(new
|
|
9630
|
+
if (liquidity.lte(new BN13(0))) {
|
|
9052
9631
|
throw new Error("liquidity must be greater than 0");
|
|
9053
9632
|
}
|
|
9054
9633
|
if (aForB) {
|
|
@@ -9066,10 +9645,10 @@ function getNextSqrtPriceFromOutput(sqrtPrice, liquidity, amountOut, aForB) {
|
|
|
9066
9645
|
}
|
|
9067
9646
|
}
|
|
9068
9647
|
function getNextSqrtPriceFromInput(sqrtPrice, liquidity, amountIn, aForB) {
|
|
9069
|
-
if (sqrtPrice.lte(new
|
|
9648
|
+
if (sqrtPrice.lte(new BN13(0))) {
|
|
9070
9649
|
throw new Error("sqrtPrice must be greater than 0");
|
|
9071
9650
|
}
|
|
9072
|
-
if (liquidity.lte(new
|
|
9651
|
+
if (liquidity.lte(new BN13(0))) {
|
|
9073
9652
|
throw new Error("liquidity must be greater than 0");
|
|
9074
9653
|
}
|
|
9075
9654
|
if (aForB) {
|
|
@@ -9100,7 +9679,7 @@ function getDeltaAmountBUnsignedUnchecked(lowerSqrtPrice, upperSqrtPrice, liquid
|
|
|
9100
9679
|
const prod = liquidity.mul(deltaSqrtPrice);
|
|
9101
9680
|
const shift = SCALE_OFFSET * 2;
|
|
9102
9681
|
if (rounding === 0 /* Up */) {
|
|
9103
|
-
const denominator = new
|
|
9682
|
+
const denominator = new BN13(1).ushln(shift);
|
|
9104
9683
|
const result = prod.add(denominator.subn(1)).div(denominator);
|
|
9105
9684
|
return result;
|
|
9106
9685
|
} else {
|
|
@@ -9121,7 +9700,7 @@ function getDeltaAmountAUnsignedUnchecked(lowerSqrtPrice, upperSqrtPrice, liquid
|
|
|
9121
9700
|
const numerator1 = liquidity;
|
|
9122
9701
|
const numerator2 = upperSqrtPrice.sub(lowerSqrtPrice);
|
|
9123
9702
|
const denominator = lowerSqrtPrice.mul(upperSqrtPrice);
|
|
9124
|
-
if (denominator.lte(new
|
|
9703
|
+
if (denominator.lte(new BN13(0))) {
|
|
9125
9704
|
throw new Error("Denominator must be greater than zero");
|
|
9126
9705
|
}
|
|
9127
9706
|
const result = mulDiv(numerator1, numerator2, denominator, rounding);
|
|
@@ -9139,11 +9718,11 @@ function getLiquidityDeltaFromAmountB(amountB, lowerSqrtPrice, upperSqrtPrice) {
|
|
|
9139
9718
|
}
|
|
9140
9719
|
|
|
9141
9720
|
// src/math/quote.ts
|
|
9142
|
-
function getSwapResultFromExactInput(poolState, amountIn, feeMode, tradeDirection, currentPoint) {
|
|
9143
|
-
let actualProtocolFee = new
|
|
9144
|
-
let actualTradingFee = new
|
|
9145
|
-
let actualReferralFee = new
|
|
9146
|
-
let actualPartnerFee = new
|
|
9721
|
+
function getSwapResultFromExactInput(program, poolState, amountIn, feeMode, tradeDirection, currentPoint) {
|
|
9722
|
+
let actualProtocolFee = new BN14(0);
|
|
9723
|
+
let actualTradingFee = new BN14(0);
|
|
9724
|
+
let actualReferralFee = new BN14(0);
|
|
9725
|
+
let actualPartnerFee = new BN14(0);
|
|
9147
9726
|
const maxFeeNumerator = getMaxFeeNumerator(poolState.version);
|
|
9148
9727
|
const tradeFeeNumerator = getTotalTradingFeeFromIncludedFeeAmount(
|
|
9149
9728
|
poolState.poolFees,
|
|
@@ -9151,7 +9730,9 @@ function getSwapResultFromExactInput(poolState, amountIn, feeMode, tradeDirectio
|
|
|
9151
9730
|
poolState.activationPoint,
|
|
9152
9731
|
amountIn,
|
|
9153
9732
|
tradeDirection,
|
|
9154
|
-
maxFeeNumerator
|
|
9733
|
+
maxFeeNumerator,
|
|
9734
|
+
poolState.poolFees.initSqrtPrice,
|
|
9735
|
+
poolState.sqrtPrice
|
|
9155
9736
|
);
|
|
9156
9737
|
let actualAmountIn;
|
|
9157
9738
|
if (feeMode.feesOnInput) {
|
|
@@ -9225,7 +9806,7 @@ function calculateAtoBFromAmountIn(poolState, amountIn) {
|
|
|
9225
9806
|
return {
|
|
9226
9807
|
outputAmount,
|
|
9227
9808
|
nextSqrtPrice,
|
|
9228
|
-
amountLeft: new
|
|
9809
|
+
amountLeft: new BN14(0)
|
|
9229
9810
|
};
|
|
9230
9811
|
}
|
|
9231
9812
|
function calculateBtoAFromAmountIn(poolState, amountIn) {
|
|
@@ -9247,14 +9828,14 @@ function calculateBtoAFromAmountIn(poolState, amountIn) {
|
|
|
9247
9828
|
return {
|
|
9248
9829
|
outputAmount,
|
|
9249
9830
|
nextSqrtPrice,
|
|
9250
|
-
amountLeft: new
|
|
9831
|
+
amountLeft: new BN14(0)
|
|
9251
9832
|
};
|
|
9252
9833
|
}
|
|
9253
|
-
function getSwapResultFromPartialInput(poolState, amountIn, feeMode, tradeDirection, currentPoint) {
|
|
9254
|
-
let actualProtocolFee = new
|
|
9255
|
-
let actualTradingFee = new
|
|
9256
|
-
let actualReferralFee = new
|
|
9257
|
-
let actualPartnerFee = new
|
|
9834
|
+
function getSwapResultFromPartialInput(program, poolState, amountIn, feeMode, tradeDirection, currentPoint) {
|
|
9835
|
+
let actualProtocolFee = new BN14(0);
|
|
9836
|
+
let actualTradingFee = new BN14(0);
|
|
9837
|
+
let actualReferralFee = new BN14(0);
|
|
9838
|
+
let actualPartnerFee = new BN14(0);
|
|
9258
9839
|
const maxFeeNumerator = getMaxFeeNumerator(poolState.version);
|
|
9259
9840
|
const tradeFeeNumerator = getTotalTradingFeeFromIncludedFeeAmount(
|
|
9260
9841
|
poolState.poolFees,
|
|
@@ -9262,7 +9843,9 @@ function getSwapResultFromPartialInput(poolState, amountIn, feeMode, tradeDirect
|
|
|
9262
9843
|
poolState.activationPoint,
|
|
9263
9844
|
amountIn,
|
|
9264
9845
|
tradeDirection,
|
|
9265
|
-
maxFeeNumerator
|
|
9846
|
+
maxFeeNumerator,
|
|
9847
|
+
poolState.poolFees.initSqrtPrice,
|
|
9848
|
+
poolState.sqrtPrice
|
|
9266
9849
|
);
|
|
9267
9850
|
let actualAmountIn;
|
|
9268
9851
|
if (feeMode.feesOnInput) {
|
|
@@ -9295,7 +9878,7 @@ function getSwapResultFromPartialInput(poolState, amountIn, feeMode, tradeDirect
|
|
|
9295
9878
|
}
|
|
9296
9879
|
let { amountLeft, outputAmount, nextSqrtPrice } = swapAmountFromInput;
|
|
9297
9880
|
let includedFeeInputAmount;
|
|
9298
|
-
if (amountLeft.gt(new
|
|
9881
|
+
if (amountLeft.gt(new BN14(0))) {
|
|
9299
9882
|
actualAmountIn = actualAmountIn.sub(amountLeft);
|
|
9300
9883
|
if (feeMode.feesOnInput) {
|
|
9301
9884
|
const tradeFeeNumerator2 = getTotalTradingFeeFromExcludedFeeAmount(
|
|
@@ -9304,7 +9887,9 @@ function getSwapResultFromPartialInput(poolState, amountIn, feeMode, tradeDirect
|
|
|
9304
9887
|
poolState.activationPoint,
|
|
9305
9888
|
actualAmountIn,
|
|
9306
9889
|
tradeDirection,
|
|
9307
|
-
maxFeeNumerator
|
|
9890
|
+
maxFeeNumerator,
|
|
9891
|
+
poolState.poolFees.initSqrtPrice,
|
|
9892
|
+
poolState.sqrtPrice
|
|
9308
9893
|
);
|
|
9309
9894
|
const { includedFeeAmount, feeAmount } = getIncludedFeeAmount(
|
|
9310
9895
|
tradeFeeNumerator2,
|
|
@@ -9424,11 +10009,11 @@ function calculateBtoAFromPartialAmountIn(poolState, amountIn) {
|
|
|
9424
10009
|
amountLeft
|
|
9425
10010
|
};
|
|
9426
10011
|
}
|
|
9427
|
-
function getSwapResultFromExactOutput(poolState, amountOut, feeMode, tradeDirection, currentPoint) {
|
|
9428
|
-
let actualProtocolFee = new
|
|
9429
|
-
let actualTradingFee = new
|
|
9430
|
-
let actualReferralFee = new
|
|
9431
|
-
let actualPartnerFee = new
|
|
10012
|
+
function getSwapResultFromExactOutput(program, poolState, amountOut, feeMode, tradeDirection, currentPoint) {
|
|
10013
|
+
let actualProtocolFee = new BN14(0);
|
|
10014
|
+
let actualTradingFee = new BN14(0);
|
|
10015
|
+
let actualReferralFee = new BN14(0);
|
|
10016
|
+
let actualPartnerFee = new BN14(0);
|
|
9432
10017
|
const maxFeeNumerator = getMaxFeeNumerator(poolState.version);
|
|
9433
10018
|
let includedFeeAmountOut;
|
|
9434
10019
|
if (feeMode.feesOnInput) {
|
|
@@ -9440,7 +10025,9 @@ function getSwapResultFromExactOutput(poolState, amountOut, feeMode, tradeDirect
|
|
|
9440
10025
|
poolState.activationPoint,
|
|
9441
10026
|
amountOut,
|
|
9442
10027
|
tradeDirection,
|
|
9443
|
-
maxFeeNumerator
|
|
10028
|
+
maxFeeNumerator,
|
|
10029
|
+
poolState.poolFees.initSqrtPrice,
|
|
10030
|
+
poolState.sqrtPrice
|
|
9444
10031
|
);
|
|
9445
10032
|
const { includedFeeAmount, feeAmount } = getIncludedFeeAmount(
|
|
9446
10033
|
tradeFeeNumerator,
|
|
@@ -9479,7 +10066,9 @@ function getSwapResultFromExactOutput(poolState, amountOut, feeMode, tradeDirect
|
|
|
9479
10066
|
poolState.activationPoint,
|
|
9480
10067
|
inputAmount,
|
|
9481
10068
|
tradeDirection,
|
|
9482
|
-
maxFeeNumerator
|
|
10069
|
+
maxFeeNumerator,
|
|
10070
|
+
poolState.poolFees.initSqrtPrice,
|
|
10071
|
+
poolState.sqrtPrice
|
|
9483
10072
|
);
|
|
9484
10073
|
const { includedFeeAmount, feeAmount } = getIncludedFeeAmount(
|
|
9485
10074
|
tradeFeeNumerator,
|
|
@@ -9500,7 +10089,7 @@ function getSwapResultFromExactOutput(poolState, amountOut, feeMode, tradeDirect
|
|
|
9500
10089
|
includedFeeInputAmount = inputAmount;
|
|
9501
10090
|
}
|
|
9502
10091
|
return {
|
|
9503
|
-
amountLeft: new
|
|
10092
|
+
amountLeft: new BN14(0),
|
|
9504
10093
|
includedFeeInputAmount,
|
|
9505
10094
|
excludedFeeInputAmount: inputAmount,
|
|
9506
10095
|
outputAmount: amountOut,
|
|
@@ -9553,8 +10142,8 @@ function calculateBtoAFromAmountOut(poolState, amountOut) {
|
|
|
9553
10142
|
nextSqrtPrice
|
|
9554
10143
|
};
|
|
9555
10144
|
}
|
|
9556
|
-
function swapQuoteExactInput(pool, currentPoint, amountIn, slippage, aToB, hasReferral, tokenADecimal, tokenBDecimal, inputTokenInfo, outputTokenInfo) {
|
|
9557
|
-
if (amountIn.lte(new
|
|
10145
|
+
function swapQuoteExactInput(program, pool, currentPoint, amountIn, slippage, aToB, hasReferral, tokenADecimal, tokenBDecimal, inputTokenInfo, outputTokenInfo) {
|
|
10146
|
+
if (amountIn.lte(new BN14(0))) {
|
|
9558
10147
|
throw new Error("Amount in must be greater than 0");
|
|
9559
10148
|
}
|
|
9560
10149
|
if (!isSwapEnabled(pool, currentPoint)) {
|
|
@@ -9571,6 +10160,7 @@ function swapQuoteExactInput(pool, currentPoint, amountIn, slippage, aToB, hasRe
|
|
|
9571
10160
|
).amount;
|
|
9572
10161
|
}
|
|
9573
10162
|
const swapResult = getSwapResultFromExactInput(
|
|
10163
|
+
program,
|
|
9574
10164
|
pool,
|
|
9575
10165
|
actualAmountIn,
|
|
9576
10166
|
feeMode,
|
|
@@ -9603,8 +10193,8 @@ function swapQuoteExactInput(pool, currentPoint, amountIn, slippage, aToB, hasRe
|
|
|
9603
10193
|
priceImpact
|
|
9604
10194
|
});
|
|
9605
10195
|
}
|
|
9606
|
-
function swapQuoteExactOutput(pool, currentPoint, amountOut, slippage, aToB, hasReferral, tokenADecimal, tokenBDecimal, inputTokenInfo, outputTokenInfo) {
|
|
9607
|
-
if (amountOut.lte(new
|
|
10196
|
+
function swapQuoteExactOutput(program, pool, currentPoint, amountOut, slippage, aToB, hasReferral, tokenADecimal, tokenBDecimal, inputTokenInfo, outputTokenInfo) {
|
|
10197
|
+
if (amountOut.lte(new BN14(0))) {
|
|
9608
10198
|
throw new Error("Amount out must be greater than 0");
|
|
9609
10199
|
}
|
|
9610
10200
|
if (!isSwapEnabled(pool, currentPoint)) {
|
|
@@ -9621,6 +10211,7 @@ function swapQuoteExactOutput(pool, currentPoint, amountOut, slippage, aToB, has
|
|
|
9621
10211
|
).amount;
|
|
9622
10212
|
}
|
|
9623
10213
|
const swapResult = getSwapResultFromExactOutput(
|
|
10214
|
+
program,
|
|
9624
10215
|
pool,
|
|
9625
10216
|
actualAmountOut,
|
|
9626
10217
|
feeMode,
|
|
@@ -9653,8 +10244,8 @@ function swapQuoteExactOutput(pool, currentPoint, amountOut, slippage, aToB, has
|
|
|
9653
10244
|
priceImpact
|
|
9654
10245
|
});
|
|
9655
10246
|
}
|
|
9656
|
-
function swapQuotePartialInput(pool, currentPoint, amountIn, slippage, aToB, hasReferral, tokenADecimal, tokenBDecimal, inputTokenInfo, outputTokenInfo) {
|
|
9657
|
-
if (amountIn.lte(new
|
|
10247
|
+
function swapQuotePartialInput(program, pool, currentPoint, amountIn, slippage, aToB, hasReferral, tokenADecimal, tokenBDecimal, inputTokenInfo, outputTokenInfo) {
|
|
10248
|
+
if (amountIn.lte(new BN14(0))) {
|
|
9658
10249
|
throw new Error("Amount in must be greater than 0");
|
|
9659
10250
|
}
|
|
9660
10251
|
if (!isSwapEnabled(pool, currentPoint)) {
|
|
@@ -9671,6 +10262,7 @@ function swapQuotePartialInput(pool, currentPoint, amountIn, slippage, aToB, has
|
|
|
9671
10262
|
).amount;
|
|
9672
10263
|
}
|
|
9673
10264
|
const swapResult = getSwapResultFromPartialInput(
|
|
10265
|
+
program,
|
|
9674
10266
|
pool,
|
|
9675
10267
|
actualAmountIn,
|
|
9676
10268
|
feeMode,
|
|
@@ -9705,7 +10297,7 @@ function swapQuotePartialInput(pool, currentPoint, amountIn, slippage, aToB, has
|
|
|
9705
10297
|
}
|
|
9706
10298
|
|
|
9707
10299
|
// src/math/priceMath.ts
|
|
9708
|
-
import { BN as
|
|
10300
|
+
import { BN as BN15 } from "@coral-xyz/anchor";
|
|
9709
10301
|
import Decimal3 from "decimal.js";
|
|
9710
10302
|
function calculateInitSqrtPrice(tokenAAmount, tokenBAmount, minSqrtPrice, maxSqrtPrice) {
|
|
9711
10303
|
if (tokenAAmount.isZero() || tokenBAmount.isZero()) {
|
|
@@ -9728,39 +10320,79 @@ function calculateInitSqrtPrice(tokenAAmount, tokenBAmount, minSqrtPrice, maxSqr
|
|
|
9728
10320
|
const discriminant = xyMinusPa.mul(xyMinusPa).add(fourY);
|
|
9729
10321
|
const sqrtDiscriminant = discriminant.sqrt();
|
|
9730
10322
|
const result = paMinusXY.add(sqrtDiscriminant).div(new Decimal3(2)).mul(Decimal3.pow(2, 64));
|
|
9731
|
-
return new
|
|
10323
|
+
return new BN15(result.floor().toFixed());
|
|
9732
10324
|
}
|
|
9733
10325
|
|
|
9734
10326
|
// src/helpers/validation.ts
|
|
9735
|
-
function
|
|
9736
|
-
if (!periodFrequency.eq(new
|
|
9737
|
-
if (numberOfPeriod === 0 || periodFrequency.eq(new
|
|
9738
|
-
|
|
10327
|
+
function validateFeeTimeScheduler(numberOfPeriod, periodFrequency, reductionFactor, cliffFeeNumerator, baseFeeMode, poolVersion) {
|
|
10328
|
+
if (!periodFrequency.eq(new BN16(0)) || numberOfPeriod !== 0 || !reductionFactor.eq(new BN16(0))) {
|
|
10329
|
+
if (numberOfPeriod === 0 || periodFrequency.eq(new BN16(0)) || reductionFactor.eq(new BN16(0))) {
|
|
10330
|
+
throw new Error("PoolError::InvalidFeeTimeScheduler");
|
|
9739
10331
|
}
|
|
9740
10332
|
}
|
|
9741
|
-
const minFeeNumerator =
|
|
10333
|
+
const minFeeNumerator = getFeeTimeMinBaseFeeNumerator(
|
|
9742
10334
|
cliffFeeNumerator,
|
|
9743
10335
|
numberOfPeriod,
|
|
9744
10336
|
reductionFactor,
|
|
9745
10337
|
baseFeeMode
|
|
9746
10338
|
);
|
|
9747
10339
|
const maxFeeNumerator = getMaxBaseFeeNumerator(cliffFeeNumerator);
|
|
9748
|
-
validateFeeFraction(minFeeNumerator, new
|
|
9749
|
-
validateFeeFraction(maxFeeNumerator, new
|
|
9750
|
-
if (minFeeNumerator.lt(new
|
|
10340
|
+
validateFeeFraction(minFeeNumerator, new BN16(FEE_DENOMINATOR));
|
|
10341
|
+
validateFeeFraction(maxFeeNumerator, new BN16(FEE_DENOMINATOR));
|
|
10342
|
+
if (minFeeNumerator.lt(new BN16(MIN_FEE_NUMERATOR)) || maxFeeNumerator.gt(getMaxFeeNumerator(poolVersion))) {
|
|
10343
|
+
throw new Error("PoolError::ExceedMaxFeeBps");
|
|
10344
|
+
}
|
|
10345
|
+
return true;
|
|
10346
|
+
}
|
|
10347
|
+
function validateFeeTimeSchedulerBaseFeeIsStatic(currentPoint, activationPoint, numberOfPeriod, periodFrequency) {
|
|
10348
|
+
const schedulerExpirationPoint = activationPoint.add(
|
|
10349
|
+
numberOfPeriod.mul(periodFrequency)
|
|
10350
|
+
);
|
|
10351
|
+
return currentPoint.gt(schedulerExpirationPoint);
|
|
10352
|
+
}
|
|
10353
|
+
function validateFeeMarketCapScheduler(cliffFeeNumerator, numberOfPeriod, sqrtPriceStepBps, reductionFactor, schedulerExpirationDuration, feeMarketCapSchedulerMode, poolVersion) {
|
|
10354
|
+
if (reductionFactor.lte(new BN16(0))) {
|
|
10355
|
+
throw new Error("PoolError::InvalidFeeMarketCapScheduler");
|
|
10356
|
+
}
|
|
10357
|
+
if (sqrtPriceStepBps.lte(new BN16(0))) {
|
|
10358
|
+
throw new Error("PoolError::InvalidFeeMarketCapScheduler");
|
|
10359
|
+
}
|
|
10360
|
+
if (schedulerExpirationDuration.lte(new BN16(0))) {
|
|
10361
|
+
throw new Error("PoolError::InvalidFeeMarketCapScheduler");
|
|
10362
|
+
}
|
|
10363
|
+
if (numberOfPeriod <= 0) {
|
|
10364
|
+
throw new Error("PoolError::InvalidFeeMarketCapScheduler");
|
|
10365
|
+
}
|
|
10366
|
+
const minFeeNumerator = getFeeMarketCapMinBaseFeeNumerator(
|
|
10367
|
+
cliffFeeNumerator,
|
|
10368
|
+
numberOfPeriod,
|
|
10369
|
+
reductionFactor,
|
|
10370
|
+
feeMarketCapSchedulerMode
|
|
10371
|
+
);
|
|
10372
|
+
const maxFeeNumerator = cliffFeeNumerator;
|
|
10373
|
+
validateFeeFraction(minFeeNumerator, new BN16(FEE_DENOMINATOR));
|
|
10374
|
+
validateFeeFraction(maxFeeNumerator, new BN16(FEE_DENOMINATOR));
|
|
10375
|
+
const maxAllowedFeeNumerator = getMaxFeeNumerator(poolVersion);
|
|
10376
|
+
if (minFeeNumerator.lt(new BN16(MIN_FEE_NUMERATOR)) || maxFeeNumerator.gt(maxAllowedFeeNumerator)) {
|
|
9751
10377
|
throw new Error("PoolError::ExceedMaxFeeBps");
|
|
9752
10378
|
}
|
|
9753
10379
|
return true;
|
|
9754
10380
|
}
|
|
10381
|
+
function validateFeeMarketCapBaseFeeIsStatic(currentPoint, activationPoint, schedulerExpirationDuration) {
|
|
10382
|
+
const schedulerExpirationPoint = activationPoint.add(
|
|
10383
|
+
schedulerExpirationDuration
|
|
10384
|
+
);
|
|
10385
|
+
return currentPoint.gt(schedulerExpirationPoint);
|
|
10386
|
+
}
|
|
9755
10387
|
function validateFeeRateLimiter(cliffFeeNumerator, feeIncrementBps, maxFeeBps, maxLimiterDuration, referenceAmount, collectFeeMode, activationType, poolVersion) {
|
|
9756
10388
|
if (collectFeeMode !== 1 /* OnlyB */) {
|
|
9757
10389
|
return false;
|
|
9758
10390
|
}
|
|
9759
10391
|
const maxFeeNumeratorFromBps = toNumerator(
|
|
9760
|
-
new
|
|
9761
|
-
new
|
|
10392
|
+
new BN16(maxFeeBps),
|
|
10393
|
+
new BN16(FEE_DENOMINATOR)
|
|
9762
10394
|
);
|
|
9763
|
-
if (cliffFeeNumerator.lt(new
|
|
10395
|
+
if (cliffFeeNumerator.lt(new BN16(MIN_FEE_NUMERATOR)) || cliffFeeNumerator.gt(maxFeeNumeratorFromBps)) {
|
|
9764
10396
|
return false;
|
|
9765
10397
|
}
|
|
9766
10398
|
if (isZeroRateLimiter(
|
|
@@ -9779,39 +10411,53 @@ function validateFeeRateLimiter(cliffFeeNumerator, feeIncrementBps, maxFeeBps, m
|
|
|
9779
10411
|
)) {
|
|
9780
10412
|
return false;
|
|
9781
10413
|
}
|
|
9782
|
-
const maxLimiterDurationLimit = activationType === 0 /* Slot */ ? new
|
|
9783
|
-
if (new
|
|
10414
|
+
const maxLimiterDurationLimit = activationType === 0 /* Slot */ ? new BN16(MAX_RATE_LIMITER_DURATION_IN_SLOTS) : new BN16(MAX_RATE_LIMITER_DURATION_IN_SECONDS);
|
|
10415
|
+
if (new BN16(maxLimiterDuration).gt(maxLimiterDurationLimit)) {
|
|
9784
10416
|
return false;
|
|
9785
10417
|
}
|
|
9786
10418
|
const feeIncrementNumerator = toNumerator(
|
|
9787
|
-
new
|
|
9788
|
-
new
|
|
10419
|
+
new BN16(feeIncrementBps),
|
|
10420
|
+
new BN16(FEE_DENOMINATOR)
|
|
9789
10421
|
);
|
|
9790
|
-
if (feeIncrementNumerator.gte(new
|
|
10422
|
+
if (feeIncrementNumerator.gte(new BN16(FEE_DENOMINATOR))) {
|
|
9791
10423
|
return false;
|
|
9792
10424
|
}
|
|
9793
10425
|
if (maxFeeBps > getMaxFeeBps(poolVersion)) {
|
|
9794
10426
|
return false;
|
|
9795
10427
|
}
|
|
9796
10428
|
const minFeeNumerator = getFeeNumeratorFromIncludedFeeAmount(
|
|
9797
|
-
new
|
|
10429
|
+
new BN16(0),
|
|
9798
10430
|
cliffFeeNumerator,
|
|
9799
10431
|
referenceAmount,
|
|
9800
10432
|
maxFeeBps,
|
|
9801
10433
|
feeIncrementBps
|
|
9802
10434
|
);
|
|
9803
10435
|
const maxFeeNumeratorFromAmount = getFeeNumeratorFromIncludedFeeAmount(
|
|
9804
|
-
new
|
|
10436
|
+
new BN16(Number.MAX_SAFE_INTEGER),
|
|
9805
10437
|
cliffFeeNumerator,
|
|
9806
10438
|
referenceAmount,
|
|
9807
10439
|
maxFeeBps,
|
|
9808
10440
|
feeIncrementBps
|
|
9809
10441
|
);
|
|
9810
|
-
if (minFeeNumerator.lt(new
|
|
10442
|
+
if (minFeeNumerator.lt(new BN16(MIN_FEE_NUMERATOR)) || maxFeeNumeratorFromAmount.gt(getMaxFeeNumerator(poolVersion))) {
|
|
9811
10443
|
return false;
|
|
9812
10444
|
}
|
|
9813
10445
|
return true;
|
|
9814
10446
|
}
|
|
10447
|
+
function validateFeeRateLimiterBaseFeeIsStatic(currentPoint, activationPoint, maxLimiterDuration, referenceAmount, maxFeeBps, feeIncrementBps) {
|
|
10448
|
+
if (isZeroRateLimiter(
|
|
10449
|
+
referenceAmount,
|
|
10450
|
+
maxLimiterDuration,
|
|
10451
|
+
maxFeeBps,
|
|
10452
|
+
feeIncrementBps
|
|
10453
|
+
)) {
|
|
10454
|
+
return true;
|
|
10455
|
+
}
|
|
10456
|
+
const lastEffectiveRateLimiterPoint = activationPoint.add(
|
|
10457
|
+
new BN16(maxLimiterDuration)
|
|
10458
|
+
);
|
|
10459
|
+
return currentPoint.gt(lastEffectiveRateLimiterPoint);
|
|
10460
|
+
}
|
|
9815
10461
|
function validateFeeFraction(numerator, denominator) {
|
|
9816
10462
|
if (denominator.isZero() || numerator.gte(denominator)) {
|
|
9817
10463
|
throw new Error(
|
|
@@ -9822,8 +10468,126 @@ function validateFeeFraction(numerator, denominator) {
|
|
|
9822
10468
|
|
|
9823
10469
|
// src/helpers/common.ts
|
|
9824
10470
|
import { PublicKey as PublicKey6 } from "@solana/web3.js";
|
|
9825
|
-
import
|
|
10471
|
+
import BN18 from "bn.js";
|
|
9826
10472
|
import Decimal4 from "decimal.js";
|
|
10473
|
+
|
|
10474
|
+
// src/helpers/feeCodec.ts
|
|
10475
|
+
import BN17 from "bn.js";
|
|
10476
|
+
import { BorshCoder } from "@coral-xyz/anchor";
|
|
10477
|
+
var cpAmmCoder = new BorshCoder(cp_amm_default);
|
|
10478
|
+
function encodeFeeTimeSchedulerParams(cliffFeeNumerator, numberOfPeriod, periodFrequency, reductionFactor, baseFeeMode) {
|
|
10479
|
+
const feeTimeScheduler = {
|
|
10480
|
+
cliff_fee_numerator: new BN17(cliffFeeNumerator.toString()),
|
|
10481
|
+
number_of_period: numberOfPeriod,
|
|
10482
|
+
period_frequency: new BN17(periodFrequency.toString()),
|
|
10483
|
+
reduction_factor: new BN17(reductionFactor.toString()),
|
|
10484
|
+
base_fee_mode: baseFeeMode,
|
|
10485
|
+
padding: FEE_PADDING
|
|
10486
|
+
};
|
|
10487
|
+
return cpAmmCoder.types.encode("BorshFeeTimeScheduler", feeTimeScheduler);
|
|
10488
|
+
}
|
|
10489
|
+
function decodeFeeTimeSchedulerParams(data) {
|
|
10490
|
+
const decoded = cpAmmCoder.types.decode("BorshFeeTimeScheduler", data);
|
|
10491
|
+
return {
|
|
10492
|
+
cliffFeeNumerator: decoded.cliff_fee_numerator,
|
|
10493
|
+
numberOfPeriod: decoded.number_of_period,
|
|
10494
|
+
periodFrequency: decoded.period_frequency,
|
|
10495
|
+
reductionFactor: decoded.reduction_factor,
|
|
10496
|
+
baseFeeMode: decoded.base_fee_mode,
|
|
10497
|
+
padding: decoded.padding
|
|
10498
|
+
};
|
|
10499
|
+
}
|
|
10500
|
+
function decodePodAlignedFeeTimeScheduler(data) {
|
|
10501
|
+
const decoded = cpAmmCoder.types.decode("PodAlignedFeeTimeScheduler", data);
|
|
10502
|
+
return {
|
|
10503
|
+
cliffFeeNumerator: decoded.cliff_fee_numerator,
|
|
10504
|
+
numberOfPeriod: decoded.number_of_period,
|
|
10505
|
+
periodFrequency: decoded.period_frequency,
|
|
10506
|
+
reductionFactor: decoded.reduction_factor,
|
|
10507
|
+
baseFeeMode: decoded.base_fee_mode,
|
|
10508
|
+
padding: decoded.padding
|
|
10509
|
+
};
|
|
10510
|
+
}
|
|
10511
|
+
function encodeFeeMarketCapSchedulerParams(cliffFeeNumerator, numberOfPeriod, sqrtPriceStepBps, schedulerExpirationDuration, reductionFactor, baseFeeMode) {
|
|
10512
|
+
const feeMarketCapScheduler = {
|
|
10513
|
+
cliff_fee_numerator: new BN17(cliffFeeNumerator.toString()),
|
|
10514
|
+
number_of_period: numberOfPeriod,
|
|
10515
|
+
sqrt_price_step_bps: sqrtPriceStepBps,
|
|
10516
|
+
scheduler_expiration_duration: schedulerExpirationDuration,
|
|
10517
|
+
reduction_factor: new BN17(reductionFactor.toString()),
|
|
10518
|
+
base_fee_mode: baseFeeMode,
|
|
10519
|
+
padding: FEE_PADDING
|
|
10520
|
+
};
|
|
10521
|
+
return cpAmmCoder.types.encode(
|
|
10522
|
+
"BorshFeeMarketCapScheduler",
|
|
10523
|
+
feeMarketCapScheduler
|
|
10524
|
+
);
|
|
10525
|
+
}
|
|
10526
|
+
function decodeFeeMarketCapSchedulerParams(data) {
|
|
10527
|
+
const decoded = cpAmmCoder.types.decode("BorshFeeMarketCapScheduler", data);
|
|
10528
|
+
return {
|
|
10529
|
+
cliffFeeNumerator: decoded.cliff_fee_numerator,
|
|
10530
|
+
numberOfPeriod: decoded.number_of_period,
|
|
10531
|
+
sqrtPriceStepBps: decoded.sqrt_price_step_bps,
|
|
10532
|
+
schedulerExpirationDuration: decoded.scheduler_expiration_duration,
|
|
10533
|
+
reductionFactor: decoded.reduction_factor,
|
|
10534
|
+
baseFeeMode: decoded.base_fee_mode,
|
|
10535
|
+
padding: decoded.padding
|
|
10536
|
+
};
|
|
10537
|
+
}
|
|
10538
|
+
function decodePodAlignedFeeMarketCapScheduler(data) {
|
|
10539
|
+
const decoded = cpAmmCoder.types.decode(
|
|
10540
|
+
"PodAlignedFeeMarketCapScheduler",
|
|
10541
|
+
data
|
|
10542
|
+
);
|
|
10543
|
+
return {
|
|
10544
|
+
cliffFeeNumerator: decoded.cliff_fee_numerator,
|
|
10545
|
+
numberOfPeriod: decoded.number_of_period,
|
|
10546
|
+
sqrtPriceStepBps: decoded.sqrt_price_step_bps,
|
|
10547
|
+
schedulerExpirationDuration: decoded.scheduler_expiration_duration,
|
|
10548
|
+
reductionFactor: decoded.reduction_factor,
|
|
10549
|
+
baseFeeMode: decoded.base_fee_mode,
|
|
10550
|
+
padding: decoded.padding
|
|
10551
|
+
};
|
|
10552
|
+
}
|
|
10553
|
+
function encodeFeeRateLimiterParams(cliffFeeNumerator, feeIncrementBps, maxLimiterDuration, maxFeeBps, referenceAmount) {
|
|
10554
|
+
const feeRateLimiter = {
|
|
10555
|
+
cliff_fee_numerator: new BN17(cliffFeeNumerator.toString()),
|
|
10556
|
+
fee_increment_bps: feeIncrementBps,
|
|
10557
|
+
max_limiter_duration: maxLimiterDuration,
|
|
10558
|
+
max_fee_bps: maxFeeBps,
|
|
10559
|
+
reference_amount: new BN17(referenceAmount.toString()),
|
|
10560
|
+
base_fee_mode: 2 /* RateLimiter */,
|
|
10561
|
+
padding: FEE_PADDING
|
|
10562
|
+
};
|
|
10563
|
+
return cpAmmCoder.types.encode("BorshFeeRateLimiter", feeRateLimiter);
|
|
10564
|
+
}
|
|
10565
|
+
function decodeFeeRateLimiterParams(data) {
|
|
10566
|
+
const decoded = cpAmmCoder.types.decode("BorshFeeRateLimiter", data);
|
|
10567
|
+
return {
|
|
10568
|
+
cliffFeeNumerator: decoded.cliff_fee_numerator,
|
|
10569
|
+
feeIncrementBps: decoded.fee_increment_bps,
|
|
10570
|
+
maxLimiterDuration: decoded.max_limiter_duration,
|
|
10571
|
+
maxFeeBps: decoded.max_fee_bps,
|
|
10572
|
+
referenceAmount: decoded.reference_amount,
|
|
10573
|
+
baseFeeMode: decoded.base_fee_mode,
|
|
10574
|
+
padding: decoded.padding
|
|
10575
|
+
};
|
|
10576
|
+
}
|
|
10577
|
+
function decodePodAlignedFeeRateLimiter(data) {
|
|
10578
|
+
const decoded = cpAmmCoder.types.decode("PodAlignedFeeRateLimiter", data);
|
|
10579
|
+
return {
|
|
10580
|
+
cliffFeeNumerator: decoded.cliff_fee_numerator,
|
|
10581
|
+
feeIncrementBps: decoded.fee_increment_bps,
|
|
10582
|
+
maxLimiterDuration: decoded.max_limiter_duration,
|
|
10583
|
+
maxFeeBps: decoded.max_fee_bps,
|
|
10584
|
+
referenceAmount: decoded.reference_amount,
|
|
10585
|
+
baseFeeMode: decoded.base_fee_mode,
|
|
10586
|
+
padding: decoded.padding
|
|
10587
|
+
};
|
|
10588
|
+
}
|
|
10589
|
+
|
|
10590
|
+
// src/helpers/common.ts
|
|
9827
10591
|
function hasPartner(poolState) {
|
|
9828
10592
|
return !poolState.partner.equals(PublicKey6.default);
|
|
9829
10593
|
}
|
|
@@ -9831,10 +10595,10 @@ function getCurrentPoint(connection, activationType) {
|
|
|
9831
10595
|
return __async(this, null, function* () {
|
|
9832
10596
|
const currentSlot = yield connection.getSlot();
|
|
9833
10597
|
if (activationType === 0 /* Slot */) {
|
|
9834
|
-
return new
|
|
10598
|
+
return new BN18(currentSlot);
|
|
9835
10599
|
} else {
|
|
9836
10600
|
const currentTime = yield connection.getBlockTime(currentSlot);
|
|
9837
|
-
return new
|
|
10601
|
+
return new BN18(currentTime);
|
|
9838
10602
|
}
|
|
9839
10603
|
});
|
|
9840
10604
|
}
|
|
@@ -9845,7 +10609,7 @@ function convertToFeeSchedulerSecondFactor(value) {
|
|
|
9845
10609
|
return Array.from(value.toArrayLike(Buffer, "le", 8));
|
|
9846
10610
|
}
|
|
9847
10611
|
function parseFeeSchedulerSecondFactor(secondFactor) {
|
|
9848
|
-
return new
|
|
10612
|
+
return new BN18(Buffer.from(secondFactor), "le");
|
|
9849
10613
|
}
|
|
9850
10614
|
function convertToRateLimiterSecondFactor(maxLimiterDuration, maxFeeBps) {
|
|
9851
10615
|
const buffer1 = maxLimiterDuration.toArrayLike(Buffer, "le", 4);
|
|
@@ -9861,10 +10625,10 @@ function parseRateLimiterSecondFactor(secondFactor) {
|
|
|
9861
10625
|
};
|
|
9862
10626
|
}
|
|
9863
10627
|
function bpsToFeeNumerator(bps) {
|
|
9864
|
-
return new
|
|
10628
|
+
return new BN18(bps * FEE_DENOMINATOR).divn(BASIS_POINT_MAX);
|
|
9865
10629
|
}
|
|
9866
10630
|
function feeNumeratorToBps(feeNumerator) {
|
|
9867
|
-
return feeNumerator.muln(BASIS_POINT_MAX).div(new
|
|
10631
|
+
return feeNumerator.muln(BASIS_POINT_MAX).div(new BN18(FEE_DENOMINATOR)).toNumber();
|
|
9868
10632
|
}
|
|
9869
10633
|
function convertToLamports(amount, tokenDecimal) {
|
|
9870
10634
|
const valueInLamports = new Decimal4(amount).mul(
|
|
@@ -9873,19 +10637,22 @@ function convertToLamports(amount, tokenDecimal) {
|
|
|
9873
10637
|
return fromDecimalToBN(valueInLamports);
|
|
9874
10638
|
}
|
|
9875
10639
|
function fromDecimalToBN(value) {
|
|
9876
|
-
return new
|
|
10640
|
+
return new BN18(value.floor().toFixed());
|
|
9877
10641
|
}
|
|
9878
|
-
function
|
|
10642
|
+
function getFeeTimeSchedulerParams(startingBaseFeeBps, endingBaseFeeBps, baseFeeMode, numberOfPeriod, totalDuration) {
|
|
9879
10643
|
if (startingBaseFeeBps == endingBaseFeeBps) {
|
|
9880
10644
|
if (numberOfPeriod != 0 || totalDuration != 0) {
|
|
9881
10645
|
throw new Error("numberOfPeriod and totalDuration must both be zero");
|
|
9882
10646
|
}
|
|
10647
|
+
const data2 = encodeFeeTimeSchedulerParams(
|
|
10648
|
+
bpsToFeeNumerator(startingBaseFeeBps),
|
|
10649
|
+
0,
|
|
10650
|
+
new BN18(0),
|
|
10651
|
+
new BN18(0),
|
|
10652
|
+
0 /* FeeTimeSchedulerLinear */
|
|
10653
|
+
);
|
|
9883
10654
|
return {
|
|
9884
|
-
|
|
9885
|
-
firstFactor: 0,
|
|
9886
|
-
secondFactor: Array.from(new BN15(0).toArrayLike(Buffer, "le", 8)),
|
|
9887
|
-
thirdFactor: new BN15(0),
|
|
9888
|
-
baseFeeMode: 0 /* FeeSchedulerLinear */
|
|
10655
|
+
data: Array.from(data2)
|
|
9889
10656
|
};
|
|
9890
10657
|
}
|
|
9891
10658
|
if (numberOfPeriod <= 0) {
|
|
@@ -9909,23 +10676,68 @@ function getFeeSchedulerParams(startingBaseFeeBps, endingBaseFeeBps, baseFeeMode
|
|
|
9909
10676
|
}
|
|
9910
10677
|
const maxBaseFeeNumerator = bpsToFeeNumerator(startingBaseFeeBps);
|
|
9911
10678
|
const minBaseFeeNumerator = bpsToFeeNumerator(endingBaseFeeBps);
|
|
9912
|
-
const periodFrequency = new
|
|
9913
|
-
const secondFactor = convertToFeeSchedulerSecondFactor(periodFrequency);
|
|
10679
|
+
const periodFrequency = new BN18(totalDuration / numberOfPeriod);
|
|
9914
10680
|
let reductionFactor;
|
|
9915
|
-
if (baseFeeMode == 0 /*
|
|
10681
|
+
if (baseFeeMode == 0 /* FeeTimeSchedulerLinear */) {
|
|
9916
10682
|
const totalReduction = maxBaseFeeNumerator.sub(minBaseFeeNumerator);
|
|
9917
10683
|
reductionFactor = totalReduction.divn(numberOfPeriod);
|
|
9918
10684
|
} else {
|
|
9919
10685
|
const ratio = minBaseFeeNumerator.toNumber() / maxBaseFeeNumerator.toNumber();
|
|
9920
10686
|
const decayBase = Math.pow(ratio, 1 / numberOfPeriod);
|
|
9921
|
-
reductionFactor = new
|
|
10687
|
+
reductionFactor = new BN18(BASIS_POINT_MAX * (1 - decayBase));
|
|
9922
10688
|
}
|
|
10689
|
+
const data = encodeFeeTimeSchedulerParams(
|
|
10690
|
+
maxBaseFeeNumerator,
|
|
10691
|
+
numberOfPeriod,
|
|
10692
|
+
periodFrequency,
|
|
10693
|
+
reductionFactor,
|
|
10694
|
+
baseFeeMode
|
|
10695
|
+
);
|
|
9923
10696
|
return {
|
|
9924
|
-
|
|
9925
|
-
|
|
9926
|
-
|
|
9927
|
-
|
|
10697
|
+
data: Array.from(data)
|
|
10698
|
+
};
|
|
10699
|
+
}
|
|
10700
|
+
function getFeeMarketCapSchedulerParams(startingBaseFeeBps, endingBaseFeeBps, baseFeeMode, numberOfPeriod, sqrtPriceStepBps, schedulerExpirationDuration) {
|
|
10701
|
+
if (numberOfPeriod <= 0) {
|
|
10702
|
+
throw new Error("Total periods must be greater than zero");
|
|
10703
|
+
}
|
|
10704
|
+
const poolMaxFeeBps = getMaxFeeBps(CURRENT_POOL_VERSION);
|
|
10705
|
+
if (startingBaseFeeBps <= endingBaseFeeBps) {
|
|
10706
|
+
throw new Error(
|
|
10707
|
+
`startingBaseFeeBps (${startingBaseFeeBps} bps) must be greater than endingBaseFeeBps (${endingBaseFeeBps} bps)`
|
|
10708
|
+
);
|
|
10709
|
+
}
|
|
10710
|
+
if (startingBaseFeeBps > poolMaxFeeBps) {
|
|
10711
|
+
throw new Error(
|
|
10712
|
+
`startingBaseFeeBps (${startingBaseFeeBps} bps) exceeds maximum allowed value of ${poolMaxFeeBps} bps`
|
|
10713
|
+
);
|
|
10714
|
+
}
|
|
10715
|
+
if (numberOfPeriod == 0 || sqrtPriceStepBps == 0 || schedulerExpirationDuration == 0) {
|
|
10716
|
+
throw new Error(
|
|
10717
|
+
"numberOfPeriod, sqrtPriceStepBps, and schedulerExpirationDuration must be greater than zero"
|
|
10718
|
+
);
|
|
10719
|
+
}
|
|
10720
|
+
const maxBaseFeeNumerator = bpsToFeeNumerator(startingBaseFeeBps);
|
|
10721
|
+
const minBaseFeeNumerator = bpsToFeeNumerator(endingBaseFeeBps);
|
|
10722
|
+
let reductionFactor;
|
|
10723
|
+
if (baseFeeMode == 3 /* FeeMarketCapSchedulerLinear */) {
|
|
10724
|
+
const totalReduction = maxBaseFeeNumerator.sub(minBaseFeeNumerator);
|
|
10725
|
+
reductionFactor = totalReduction.divn(numberOfPeriod);
|
|
10726
|
+
} else {
|
|
10727
|
+
const ratio = minBaseFeeNumerator.toNumber() / maxBaseFeeNumerator.toNumber();
|
|
10728
|
+
const decayBase = Math.pow(ratio, 1 / numberOfPeriod);
|
|
10729
|
+
reductionFactor = new BN18(BASIS_POINT_MAX * (1 - decayBase));
|
|
10730
|
+
}
|
|
10731
|
+
const data = encodeFeeMarketCapSchedulerParams(
|
|
10732
|
+
maxBaseFeeNumerator,
|
|
10733
|
+
numberOfPeriod,
|
|
10734
|
+
sqrtPriceStepBps,
|
|
10735
|
+
schedulerExpirationDuration,
|
|
10736
|
+
reductionFactor,
|
|
9928
10737
|
baseFeeMode
|
|
10738
|
+
);
|
|
10739
|
+
return {
|
|
10740
|
+
data: Array.from(data)
|
|
9929
10741
|
};
|
|
9930
10742
|
}
|
|
9931
10743
|
function getRateLimiterParams(baseFeeBps, feeIncrementBps, referenceAmount, maxLimiterDuration, maxFeeBps, tokenBDecimal, activationType) {
|
|
@@ -9946,7 +10758,7 @@ function getRateLimiterParams(baseFeeBps, feeIncrementBps, referenceAmount, maxL
|
|
|
9946
10758
|
`Fee increment (${feeIncrementBps} bps) exceeds maximum allowed value of ${poolMaxFeeBps} bps`
|
|
9947
10759
|
);
|
|
9948
10760
|
}
|
|
9949
|
-
if (feeIncrementNumerator.gte(new
|
|
10761
|
+
if (feeIncrementNumerator.gte(new BN18(FEE_DENOMINATOR))) {
|
|
9950
10762
|
throw new Error(
|
|
9951
10763
|
"Fee increment numerator must be less than FEE_DENOMINATOR"
|
|
9952
10764
|
);
|
|
@@ -9956,12 +10768,12 @@ function getRateLimiterParams(baseFeeBps, feeIncrementBps, referenceAmount, maxL
|
|
|
9956
10768
|
`Max fee (${maxFeeBps} bps) exceeds maximum allowed value of ${poolMaxFeeBps} bps for PoolVersion V${CURRENT_POOL_VERSION}`
|
|
9957
10769
|
);
|
|
9958
10770
|
}
|
|
9959
|
-
const deltaNumerator = new
|
|
10771
|
+
const deltaNumerator = new BN18(poolMaxFeeNumerator).sub(cliffFeeNumerator);
|
|
9960
10772
|
const maxIndex = deltaNumerator.div(feeIncrementNumerator);
|
|
9961
|
-
if (maxIndex.lt(new
|
|
10773
|
+
if (maxIndex.lt(new BN18(1))) {
|
|
9962
10774
|
throw new Error("Fee increment is too large for the given base fee");
|
|
9963
10775
|
}
|
|
9964
|
-
if (cliffFeeNumerator.lt(new
|
|
10776
|
+
if (cliffFeeNumerator.lt(new BN18(MIN_FEE_NUMERATOR)) || cliffFeeNumerator.gt(new BN18(poolMaxFeeNumerator))) {
|
|
9965
10777
|
throw new Error("Base fee must be between 0.01% and 99%");
|
|
9966
10778
|
}
|
|
9967
10779
|
const maxDuration = activationType === 0 /* Slot */ ? MAX_RATE_LIMITER_DURATION_IN_SLOTS : MAX_RATE_LIMITER_DURATION_IN_SECONDS;
|
|
@@ -9974,55 +10786,83 @@ function getRateLimiterParams(baseFeeBps, feeIncrementBps, referenceAmount, maxL
|
|
|
9974
10786
|
referenceAmount,
|
|
9975
10787
|
tokenBDecimal
|
|
9976
10788
|
);
|
|
9977
|
-
const
|
|
9978
|
-
|
|
9979
|
-
|
|
10789
|
+
const data = encodeFeeRateLimiterParams(
|
|
10790
|
+
cliffFeeNumerator,
|
|
10791
|
+
feeIncrementBps,
|
|
10792
|
+
maxLimiterDuration,
|
|
10793
|
+
maxFeeBps,
|
|
10794
|
+
referenceAmountInLamports
|
|
9980
10795
|
);
|
|
9981
10796
|
return {
|
|
9982
|
-
|
|
9983
|
-
firstFactor: feeIncrementBps,
|
|
9984
|
-
secondFactor,
|
|
9985
|
-
thirdFactor: new BN15(referenceAmountInLamports),
|
|
9986
|
-
baseFeeMode: 2 /* RateLimiter */
|
|
10797
|
+
data: Array.from(data)
|
|
9987
10798
|
};
|
|
9988
10799
|
}
|
|
9989
10800
|
function getBaseFeeParams(baseFeeParams, tokenBDecimal, activationType) {
|
|
9990
|
-
|
|
9991
|
-
|
|
9992
|
-
|
|
9993
|
-
|
|
10801
|
+
switch (baseFeeParams.baseFeeMode) {
|
|
10802
|
+
case 0 /* FeeTimeSchedulerLinear */:
|
|
10803
|
+
case 1 /* FeeTimeSchedulerExponential */: {
|
|
10804
|
+
if (!baseFeeParams.feeTimeSchedulerParam) {
|
|
10805
|
+
throw new Error(
|
|
10806
|
+
"Fee scheduler parameters are required for FeeTimeScheduler mode"
|
|
10807
|
+
);
|
|
10808
|
+
}
|
|
10809
|
+
const { startingFeeBps, endingFeeBps, numberOfPeriod, totalDuration } = baseFeeParams.feeTimeSchedulerParam;
|
|
10810
|
+
return getFeeTimeSchedulerParams(
|
|
10811
|
+
startingFeeBps,
|
|
10812
|
+
endingFeeBps,
|
|
10813
|
+
baseFeeParams.baseFeeMode,
|
|
10814
|
+
numberOfPeriod,
|
|
10815
|
+
totalDuration
|
|
9994
10816
|
);
|
|
9995
10817
|
}
|
|
9996
|
-
|
|
9997
|
-
|
|
9998
|
-
|
|
9999
|
-
|
|
10000
|
-
|
|
10001
|
-
|
|
10002
|
-
|
|
10003
|
-
|
|
10004
|
-
|
|
10005
|
-
|
|
10006
|
-
|
|
10007
|
-
|
|
10008
|
-
|
|
10009
|
-
|
|
10010
|
-
|
|
10011
|
-
|
|
10012
|
-
|
|
10013
|
-
|
|
10014
|
-
|
|
10015
|
-
|
|
10818
|
+
case 2 /* RateLimiter */: {
|
|
10819
|
+
if (!baseFeeParams.rateLimiterParam) {
|
|
10820
|
+
throw new Error(
|
|
10821
|
+
"Rate limiter parameters are required for RateLimiter mode"
|
|
10822
|
+
);
|
|
10823
|
+
}
|
|
10824
|
+
const {
|
|
10825
|
+
baseFeeBps,
|
|
10826
|
+
feeIncrementBps,
|
|
10827
|
+
referenceAmount,
|
|
10828
|
+
maxLimiterDuration,
|
|
10829
|
+
maxFeeBps
|
|
10830
|
+
} = baseFeeParams.rateLimiterParam;
|
|
10831
|
+
return getRateLimiterParams(
|
|
10832
|
+
baseFeeBps,
|
|
10833
|
+
feeIncrementBps,
|
|
10834
|
+
referenceAmount,
|
|
10835
|
+
maxLimiterDuration,
|
|
10836
|
+
maxFeeBps,
|
|
10837
|
+
tokenBDecimal,
|
|
10838
|
+
activationType
|
|
10016
10839
|
);
|
|
10017
10840
|
}
|
|
10018
|
-
|
|
10019
|
-
|
|
10020
|
-
|
|
10021
|
-
|
|
10022
|
-
|
|
10023
|
-
|
|
10024
|
-
|
|
10025
|
-
|
|
10841
|
+
case 3 /* FeeMarketCapSchedulerLinear */:
|
|
10842
|
+
case 4 /* FeeMarketCapSchedulerExponential */: {
|
|
10843
|
+
if (!baseFeeParams.feeMarketCapSchedulerParam) {
|
|
10844
|
+
throw new Error(
|
|
10845
|
+
"Fee scheduler parameters are required for FeeMarketCapScheduler mode"
|
|
10846
|
+
);
|
|
10847
|
+
}
|
|
10848
|
+
const {
|
|
10849
|
+
startingFeeBps,
|
|
10850
|
+
endingFeeBps,
|
|
10851
|
+
numberOfPeriod,
|
|
10852
|
+
sqrtPriceStepBps,
|
|
10853
|
+
schedulerExpirationDuration
|
|
10854
|
+
} = baseFeeParams.feeMarketCapSchedulerParam;
|
|
10855
|
+
return getFeeMarketCapSchedulerParams(
|
|
10856
|
+
startingFeeBps,
|
|
10857
|
+
endingFeeBps,
|
|
10858
|
+
baseFeeParams.baseFeeMode,
|
|
10859
|
+
numberOfPeriod,
|
|
10860
|
+
sqrtPriceStepBps,
|
|
10861
|
+
schedulerExpirationDuration
|
|
10862
|
+
);
|
|
10863
|
+
}
|
|
10864
|
+
default:
|
|
10865
|
+
throw new Error("Invalid base fee mode");
|
|
10026
10866
|
}
|
|
10027
10867
|
}
|
|
10028
10868
|
function getDynamicFeeParams(baseFeeBps, maxPriceChangeBps = MAX_PRICE_CHANGE_BPS_DEFAULT) {
|
|
@@ -10032,15 +10872,15 @@ function getDynamicFeeParams(baseFeeBps, maxPriceChangeBps = MAX_PRICE_CHANGE_BP
|
|
|
10032
10872
|
);
|
|
10033
10873
|
}
|
|
10034
10874
|
const priceRatio = maxPriceChangeBps / BASIS_POINT_MAX + 1;
|
|
10035
|
-
const sqrtPriceRatioQ64 = new
|
|
10875
|
+
const sqrtPriceRatioQ64 = new BN18(
|
|
10036
10876
|
Decimal4.sqrt(priceRatio.toString()).mul(Decimal4.pow(2, 64)).floor().toFixed()
|
|
10037
10877
|
);
|
|
10038
10878
|
const deltaBinId = sqrtPriceRatioQ64.sub(ONE_Q64).div(BIN_STEP_BPS_U128_DEFAULT).muln(2);
|
|
10039
|
-
const maxVolatilityAccumulator = new
|
|
10040
|
-
const squareVfaBin = maxVolatilityAccumulator.mul(new
|
|
10041
|
-
const baseFeeNumerator = new
|
|
10879
|
+
const maxVolatilityAccumulator = new BN18(deltaBinId.muln(BASIS_POINT_MAX));
|
|
10880
|
+
const squareVfaBin = maxVolatilityAccumulator.mul(new BN18(BIN_STEP_BPS_DEFAULT)).pow(new BN18(2));
|
|
10881
|
+
const baseFeeNumerator = new BN18(bpsToFeeNumerator(baseFeeBps));
|
|
10042
10882
|
const maxDynamicFeeNumerator = baseFeeNumerator.muln(20).divn(100);
|
|
10043
|
-
const vFee = maxDynamicFeeNumerator.mul(new
|
|
10883
|
+
const vFee = maxDynamicFeeNumerator.mul(new BN18(1e11)).sub(new BN18(99999999999));
|
|
10044
10884
|
const variableFeeControl = vFee.div(squareVfaBin);
|
|
10045
10885
|
return {
|
|
10046
10886
|
binStep: BIN_STEP_BPS_DEFAULT,
|
|
@@ -10054,10 +10894,10 @@ function getDynamicFeeParams(baseFeeBps, maxPriceChangeBps = MAX_PRICE_CHANGE_BP
|
|
|
10054
10894
|
}
|
|
10055
10895
|
|
|
10056
10896
|
// src/CpAmm.ts
|
|
10057
|
-
import
|
|
10897
|
+
import BN19, { min as min2, max } from "bn.js";
|
|
10058
10898
|
var CpAmm = class {
|
|
10059
10899
|
constructor(connection) {
|
|
10060
|
-
this._program = new
|
|
10900
|
+
this._program = new Program2(cp_amm_default, {
|
|
10061
10901
|
connection
|
|
10062
10902
|
});
|
|
10063
10903
|
this.poolAuthority = derivePoolAuthority();
|
|
@@ -10283,7 +11123,7 @@ var CpAmm = class {
|
|
|
10283
11123
|
poolAuthority,
|
|
10284
11124
|
rentReceiver: owner,
|
|
10285
11125
|
owner,
|
|
10286
|
-
tokenProgram:
|
|
11126
|
+
tokenProgram: TOKEN_2022_PROGRAM_ID3
|
|
10287
11127
|
}).instruction();
|
|
10288
11128
|
});
|
|
10289
11129
|
}
|
|
@@ -10402,7 +11242,7 @@ var CpAmm = class {
|
|
|
10402
11242
|
payer,
|
|
10403
11243
|
pool,
|
|
10404
11244
|
position,
|
|
10405
|
-
tokenProgram:
|
|
11245
|
+
tokenProgram: TOKEN_2022_PROGRAM_ID3,
|
|
10406
11246
|
systemProgram: SystemProgram2.programId
|
|
10407
11247
|
}).instruction();
|
|
10408
11248
|
return {
|
|
@@ -10576,6 +11416,36 @@ var CpAmm = class {
|
|
|
10576
11416
|
return pools;
|
|
10577
11417
|
});
|
|
10578
11418
|
}
|
|
11419
|
+
fetchPoolFees(pool) {
|
|
11420
|
+
return __async(this, null, function* () {
|
|
11421
|
+
const poolState = yield this._program.account.pool.fetchNullable(pool);
|
|
11422
|
+
if (!poolState) {
|
|
11423
|
+
throw new Error(`Pool account: ${pool} not found`);
|
|
11424
|
+
}
|
|
11425
|
+
const data = Buffer.from(poolState.poolFees.baseFee.baseFeeInfo.data);
|
|
11426
|
+
const modeIndex = data.readUInt8(8);
|
|
11427
|
+
const baseFeeMode = modeIndex;
|
|
11428
|
+
switch (baseFeeMode) {
|
|
11429
|
+
case 0 /* FeeTimeSchedulerLinear */:
|
|
11430
|
+
case 1 /* FeeTimeSchedulerExponential */: {
|
|
11431
|
+
const poolFees = decodePodAlignedFeeTimeScheduler(data);
|
|
11432
|
+
return poolFees;
|
|
11433
|
+
}
|
|
11434
|
+
case 2 /* RateLimiter */: {
|
|
11435
|
+
const poolFees = decodePodAlignedFeeRateLimiter(data);
|
|
11436
|
+
return poolFees;
|
|
11437
|
+
}
|
|
11438
|
+
case 3 /* FeeMarketCapSchedulerLinear */:
|
|
11439
|
+
case 4 /* FeeMarketCapSchedulerExponential */: {
|
|
11440
|
+
const poolFees = decodePodAlignedFeeMarketCapScheduler(data);
|
|
11441
|
+
return poolFees;
|
|
11442
|
+
}
|
|
11443
|
+
default: {
|
|
11444
|
+
throw new Error(`Invalid base fee mode: ${baseFeeMode}`);
|
|
11445
|
+
}
|
|
11446
|
+
}
|
|
11447
|
+
});
|
|
11448
|
+
}
|
|
10579
11449
|
/**
|
|
10580
11450
|
* Fetches the Position state.
|
|
10581
11451
|
* @param position - Public key of the position.
|
|
@@ -10808,8 +11678,9 @@ var CpAmm = class {
|
|
|
10808
11678
|
} = params;
|
|
10809
11679
|
const { activationType } = poolState;
|
|
10810
11680
|
const aToB = poolState.tokenAMint.equals(inputTokenMint);
|
|
10811
|
-
const currentPoint = activationType ? new
|
|
11681
|
+
const currentPoint = activationType ? new BN19(currentTime) : new BN19(currentSlot);
|
|
10812
11682
|
const swapResult = swapQuoteExactInput(
|
|
11683
|
+
this._program,
|
|
10813
11684
|
poolState,
|
|
10814
11685
|
currentPoint,
|
|
10815
11686
|
inAmount,
|
|
@@ -10853,6 +11724,7 @@ var CpAmm = class {
|
|
|
10853
11724
|
case 0 /* ExactIn */:
|
|
10854
11725
|
if ("amountIn" in params) {
|
|
10855
11726
|
return swapQuoteExactInput(
|
|
11727
|
+
this._program,
|
|
10856
11728
|
poolState,
|
|
10857
11729
|
currentPoint,
|
|
10858
11730
|
params.amountIn,
|
|
@@ -10869,6 +11741,7 @@ var CpAmm = class {
|
|
|
10869
11741
|
case 2 /* ExactOut */:
|
|
10870
11742
|
if ("amountOut" in params) {
|
|
10871
11743
|
return swapQuoteExactOutput(
|
|
11744
|
+
this._program,
|
|
10872
11745
|
poolState,
|
|
10873
11746
|
currentPoint,
|
|
10874
11747
|
params.amountOut,
|
|
@@ -10885,6 +11758,7 @@ var CpAmm = class {
|
|
|
10885
11758
|
case 1 /* PartialFill */:
|
|
10886
11759
|
if ("amountIn" in params) {
|
|
10887
11760
|
return swapQuotePartialInput(
|
|
11761
|
+
this._program,
|
|
10888
11762
|
poolState,
|
|
10889
11763
|
currentPoint,
|
|
10890
11764
|
params.amountIn,
|
|
@@ -10952,7 +11826,7 @@ var CpAmm = class {
|
|
|
10952
11826
|
0 /* Up */
|
|
10953
11827
|
)
|
|
10954
11828
|
};
|
|
10955
|
-
const rawOutputAmount = new
|
|
11829
|
+
const rawOutputAmount = new BN19(rawAmount(liquidityDelta));
|
|
10956
11830
|
const outputAmount = outputTokenInfo ? calculateTransferFeeIncludedAmount(
|
|
10957
11831
|
rawOutputAmount,
|
|
10958
11832
|
outputTokenInfo.mint,
|
|
@@ -11059,7 +11933,7 @@ var CpAmm = class {
|
|
|
11059
11933
|
tokenAInfo,
|
|
11060
11934
|
tokenBInfo
|
|
11061
11935
|
} = params;
|
|
11062
|
-
if (tokenAAmount.eq(new
|
|
11936
|
+
if (tokenAAmount.eq(new BN19(0)) && tokenBAmount.eq(new BN19(0))) {
|
|
11063
11937
|
throw new Error("Invalid input amount");
|
|
11064
11938
|
}
|
|
11065
11939
|
const actualAmountAIn = tokenAInfo ? tokenAAmount.sub(
|
|
@@ -11175,7 +12049,7 @@ var CpAmm = class {
|
|
|
11175
12049
|
tokenBVault,
|
|
11176
12050
|
payerTokenA,
|
|
11177
12051
|
payerTokenB,
|
|
11178
|
-
token2022Program:
|
|
12052
|
+
token2022Program: TOKEN_2022_PROGRAM_ID3,
|
|
11179
12053
|
tokenAProgram,
|
|
11180
12054
|
tokenBProgram,
|
|
11181
12055
|
systemProgram: SystemProgram2.programId
|
|
@@ -11226,7 +12100,7 @@ var CpAmm = class {
|
|
|
11226
12100
|
tokenAMint,
|
|
11227
12101
|
tokenBMint,
|
|
11228
12102
|
tokenAAmount,
|
|
11229
|
-
tokenBAmount: tokenBMint.equals(NATIVE_MINT2) ? max(tokenBAmount, new
|
|
12103
|
+
tokenBAmount: tokenBMint.equals(NATIVE_MINT2) ? max(tokenBAmount, new BN19(1)) : tokenBAmount,
|
|
11230
12104
|
payer,
|
|
11231
12105
|
positionNft,
|
|
11232
12106
|
tokenAProgram,
|
|
@@ -11266,7 +12140,7 @@ var CpAmm = class {
|
|
|
11266
12140
|
tokenBVault,
|
|
11267
12141
|
payerTokenA,
|
|
11268
12142
|
payerTokenB,
|
|
11269
|
-
token2022Program:
|
|
12143
|
+
token2022Program: TOKEN_2022_PROGRAM_ID3,
|
|
11270
12144
|
tokenAProgram,
|
|
11271
12145
|
tokenBProgram,
|
|
11272
12146
|
systemProgram: SystemProgram2.programId
|
|
@@ -11361,7 +12235,7 @@ var CpAmm = class {
|
|
|
11361
12235
|
tokenBVault,
|
|
11362
12236
|
payerTokenA,
|
|
11363
12237
|
payerTokenB,
|
|
11364
|
-
token2022Program:
|
|
12238
|
+
token2022Program: TOKEN_2022_PROGRAM_ID3,
|
|
11365
12239
|
tokenAProgram,
|
|
11366
12240
|
tokenBProgram,
|
|
11367
12241
|
systemProgram: SystemProgram2.programId
|
|
@@ -11774,20 +12648,21 @@ var CpAmm = class {
|
|
|
11774
12648
|
}
|
|
11775
12649
|
let { poolState } = params;
|
|
11776
12650
|
poolState = poolState != null ? poolState : yield this.fetchPoolState(pool);
|
|
11777
|
-
const
|
|
11778
|
-
|
|
11779
|
-
|
|
12651
|
+
const data = Buffer.from(poolState.poolFees.baseFee.baseFeeInfo.data);
|
|
12652
|
+
const modeIndex = data.readUInt8(8);
|
|
12653
|
+
const baseFeeMode = modeIndex;
|
|
11780
12654
|
let rateLimiterApplied = false;
|
|
11781
|
-
if (
|
|
12655
|
+
if (baseFeeMode === 2 /* RateLimiter */) {
|
|
11782
12656
|
const currentPoint = yield getCurrentPoint(
|
|
11783
12657
|
this._program.provider.connection,
|
|
11784
12658
|
poolState.activationType
|
|
11785
12659
|
);
|
|
12660
|
+
const rateLimiterPoolFees = decodePodAlignedFeeRateLimiter(data);
|
|
11786
12661
|
rateLimiterApplied = isRateLimiterApplied(
|
|
11787
|
-
|
|
11788
|
-
maxLimiterDuration,
|
|
11789
|
-
maxFeeBps,
|
|
11790
|
-
|
|
12662
|
+
rateLimiterPoolFees.referenceAmount,
|
|
12663
|
+
rateLimiterPoolFees.maxLimiterDuration,
|
|
12664
|
+
rateLimiterPoolFees.maxFeeBps,
|
|
12665
|
+
rateLimiterPoolFees.feeIncrementBps,
|
|
11791
12666
|
currentPoint,
|
|
11792
12667
|
poolState.activationPoint,
|
|
11793
12668
|
tradeDirection
|
|
@@ -11884,20 +12759,21 @@ var CpAmm = class {
|
|
|
11884
12759
|
}
|
|
11885
12760
|
let { poolState } = params;
|
|
11886
12761
|
poolState = poolState != null ? poolState : yield this.fetchPoolState(pool);
|
|
11887
|
-
const
|
|
11888
|
-
|
|
11889
|
-
|
|
12762
|
+
const data = Buffer.from(poolState.poolFees.baseFee.baseFeeInfo.data);
|
|
12763
|
+
const modeIndex = data.readUInt8(8);
|
|
12764
|
+
const baseFeeMode = modeIndex;
|
|
11890
12765
|
let rateLimiterApplied = false;
|
|
11891
|
-
if (
|
|
12766
|
+
if (baseFeeMode === 2 /* RateLimiter */) {
|
|
11892
12767
|
const currentPoint = yield getCurrentPoint(
|
|
11893
12768
|
this._program.provider.connection,
|
|
11894
12769
|
poolState.activationType
|
|
11895
12770
|
);
|
|
12771
|
+
const rateLimiterPoolFees = decodePodAlignedFeeRateLimiter(data);
|
|
11896
12772
|
rateLimiterApplied = isRateLimiterApplied(
|
|
11897
|
-
|
|
11898
|
-
maxLimiterDuration,
|
|
11899
|
-
maxFeeBps,
|
|
11900
|
-
|
|
12773
|
+
rateLimiterPoolFees.referenceAmount,
|
|
12774
|
+
rateLimiterPoolFees.maxLimiterDuration,
|
|
12775
|
+
rateLimiterPoolFees.maxFeeBps,
|
|
12776
|
+
rateLimiterPoolFees.feeIncrementBps,
|
|
11901
12777
|
currentPoint,
|
|
11902
12778
|
poolState.activationPoint,
|
|
11903
12779
|
tradeDirection
|
|
@@ -12166,7 +13042,7 @@ var CpAmm = class {
|
|
|
12166
13042
|
);
|
|
12167
13043
|
return total.add(available);
|
|
12168
13044
|
},
|
|
12169
|
-
new
|
|
13045
|
+
new BN19(0)
|
|
12170
13046
|
);
|
|
12171
13047
|
positionBLiquidityDelta = positionBLiquidityDelta.add(
|
|
12172
13048
|
totalAvailableVestingLiquidity
|
|
@@ -12737,8 +13613,10 @@ export {
|
|
|
12737
13613
|
DYNAMIC_FEE_ROUNDING_OFFSET,
|
|
12738
13614
|
DYNAMIC_FEE_SCALING_FACTOR,
|
|
12739
13615
|
FEE_DENOMINATOR,
|
|
13616
|
+
FEE_PADDING,
|
|
13617
|
+
FeeMarketCapScheduler,
|
|
12740
13618
|
FeeRateLimiter,
|
|
12741
|
-
|
|
13619
|
+
FeeTimeScheduler,
|
|
12742
13620
|
LIQUIDITY_SCALE,
|
|
12743
13621
|
MAX,
|
|
12744
13622
|
MAX_CU_BUFFER,
|
|
@@ -12779,10 +13657,18 @@ export {
|
|
|
12779
13657
|
convertToFeeSchedulerSecondFactor,
|
|
12780
13658
|
convertToLamports,
|
|
12781
13659
|
convertToRateLimiterSecondFactor,
|
|
13660
|
+
cpAmmCoder,
|
|
12782
13661
|
decimalToQ64,
|
|
13662
|
+
decodeFeeMarketCapSchedulerParams,
|
|
13663
|
+
decodeFeeRateLimiterParams,
|
|
13664
|
+
decodeFeeTimeSchedulerParams,
|
|
13665
|
+
decodePodAlignedFeeMarketCapScheduler,
|
|
13666
|
+
decodePodAlignedFeeRateLimiter,
|
|
13667
|
+
decodePodAlignedFeeTimeScheduler,
|
|
12783
13668
|
deriveClaimFeeOperatorAddress,
|
|
12784
13669
|
deriveConfigAddress,
|
|
12785
13670
|
deriveCustomizablePoolAddress,
|
|
13671
|
+
deriveOperatorAddress,
|
|
12786
13672
|
derivePoolAddress,
|
|
12787
13673
|
derivePoolAuthority,
|
|
12788
13674
|
derivePositionAddress,
|
|
@@ -12790,6 +13676,9 @@ export {
|
|
|
12790
13676
|
deriveRewardVaultAddress,
|
|
12791
13677
|
deriveTokenBadgeAddress,
|
|
12792
13678
|
deriveTokenVaultAddress,
|
|
13679
|
+
encodeFeeMarketCapSchedulerParams,
|
|
13680
|
+
encodeFeeRateLimiterParams,
|
|
13681
|
+
encodeFeeTimeSchedulerParams,
|
|
12793
13682
|
feeNumeratorToBps,
|
|
12794
13683
|
fromDecimalToBN,
|
|
12795
13684
|
getAllPositionNftAccountByOwner,
|
|
@@ -12799,8 +13688,6 @@ export {
|
|
|
12799
13688
|
getAmountWithSlippage,
|
|
12800
13689
|
getAvailableVestingLiquidity,
|
|
12801
13690
|
getBaseFeeHandler,
|
|
12802
|
-
getBaseFeeNumerator,
|
|
12803
|
-
getBaseFeeNumeratorByPeriod,
|
|
12804
13691
|
getBaseFeeParams,
|
|
12805
13692
|
getCheckedAmounts,
|
|
12806
13693
|
getCurrentPoint,
|
|
@@ -12811,13 +13698,20 @@ export {
|
|
|
12811
13698
|
getExcludedFeeAmount,
|
|
12812
13699
|
getExcludedFeeAmountFromIncludedFeeAmount,
|
|
12813
13700
|
getFeeInPeriod,
|
|
13701
|
+
getFeeMarketCapBaseFeeNumerator,
|
|
13702
|
+
getFeeMarketCapBaseFeeNumeratorByPeriod,
|
|
13703
|
+
getFeeMarketCapMinBaseFeeNumerator,
|
|
13704
|
+
getFeeMarketCapSchedulerParams,
|
|
12814
13705
|
getFeeMode,
|
|
12815
13706
|
getFeeNumeratorFromExcludedFeeAmount,
|
|
12816
13707
|
getFeeNumeratorFromIncludedFeeAmount,
|
|
12817
13708
|
getFeeNumeratorOnExponentialFeeScheduler,
|
|
12818
13709
|
getFeeNumeratorOnLinearFeeScheduler,
|
|
12819
13710
|
getFeeOnAmount,
|
|
12820
|
-
|
|
13711
|
+
getFeeTimeBaseFeeNumerator,
|
|
13712
|
+
getFeeTimeBaseFeeNumeratorByPeriod,
|
|
13713
|
+
getFeeTimeMinBaseFeeNumerator,
|
|
13714
|
+
getFeeTimeSchedulerParams,
|
|
12821
13715
|
getFirstKey,
|
|
12822
13716
|
getIncludedFeeAmount,
|
|
12823
13717
|
getLiquidityDeltaFromAmountA,
|
|
@@ -12827,7 +13721,6 @@ export {
|
|
|
12827
13721
|
getMaxFeeBps,
|
|
12828
13722
|
getMaxFeeNumerator,
|
|
12829
13723
|
getMaxIndex,
|
|
12830
|
-
getMinBaseFeeNumerator,
|
|
12831
13724
|
getNextSqrtPriceFromAmountInARoundingUp,
|
|
12832
13725
|
getNextSqrtPriceFromAmountInBRoundingDown,
|
|
12833
13726
|
getNextSqrtPriceFromAmountOutARoundingUp,
|
|
@@ -12855,6 +13748,7 @@ export {
|
|
|
12855
13748
|
getUnClaimLpFee,
|
|
12856
13749
|
getUserRewardPending,
|
|
12857
13750
|
hasPartner,
|
|
13751
|
+
hasTransferHookExtension,
|
|
12858
13752
|
isDynamicFeeEnabled,
|
|
12859
13753
|
isNonZeroRateLimiter,
|
|
12860
13754
|
isRateLimiterApplied,
|
|
@@ -12873,11 +13767,18 @@ export {
|
|
|
12873
13767
|
swapQuoteExactInput,
|
|
12874
13768
|
swapQuoteExactOutput,
|
|
12875
13769
|
swapQuotePartialInput,
|
|
13770
|
+
toBorshFeeTimeScheduler,
|
|
12876
13771
|
toNumerator,
|
|
13772
|
+
toPodAlignedFeeTimeScheduler,
|
|
12877
13773
|
unwrapSOLInstruction,
|
|
12878
13774
|
validateFeeFraction,
|
|
13775
|
+
validateFeeMarketCapBaseFeeIsStatic,
|
|
13776
|
+
validateFeeMarketCapScheduler,
|
|
12879
13777
|
validateFeeRateLimiter,
|
|
12880
|
-
|
|
13778
|
+
validateFeeRateLimiterBaseFeeIsStatic,
|
|
13779
|
+
validateFeeTimeScheduler,
|
|
13780
|
+
validateFeeTimeSchedulerBaseFeeIsStatic,
|
|
13781
|
+
validateNoTransferHook,
|
|
12881
13782
|
vestingByPositionFilter,
|
|
12882
13783
|
wrapSOLInstruction
|
|
12883
13784
|
};
|