100x-sdk 1.0.1 → 1.0.2
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/package.json +1 -1
- package/src/idl/fun100x_localnet.json +268 -0
- package/src/idl/fun100x_main.json +268 -0
- package/src/modules/chain.js +33 -6
- package/src/modules/token.js +13 -0
- package/src/modules/trading.js +13 -0
package/package.json
CHANGED
|
@@ -252,6 +252,40 @@
|
|
|
252
252
|
]
|
|
253
253
|
}
|
|
254
254
|
},
|
|
255
|
+
{
|
|
256
|
+
"name": "pool_borrow_token_account",
|
|
257
|
+
"writable": true,
|
|
258
|
+
"pda": {
|
|
259
|
+
"seeds": [
|
|
260
|
+
{
|
|
261
|
+
"kind": "const",
|
|
262
|
+
"value": [
|
|
263
|
+
112,
|
|
264
|
+
111,
|
|
265
|
+
111,
|
|
266
|
+
108,
|
|
267
|
+
95,
|
|
268
|
+
98,
|
|
269
|
+
111,
|
|
270
|
+
114,
|
|
271
|
+
114,
|
|
272
|
+
111,
|
|
273
|
+
119,
|
|
274
|
+
95,
|
|
275
|
+
116,
|
|
276
|
+
111,
|
|
277
|
+
107,
|
|
278
|
+
101,
|
|
279
|
+
110
|
|
280
|
+
]
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
"kind": "account",
|
|
284
|
+
"path": "mint_account"
|
|
285
|
+
}
|
|
286
|
+
]
|
|
287
|
+
}
|
|
288
|
+
},
|
|
255
289
|
{
|
|
256
290
|
"name": "pool_sol_account",
|
|
257
291
|
"writable": true,
|
|
@@ -579,6 +613,40 @@
|
|
|
579
613
|
]
|
|
580
614
|
}
|
|
581
615
|
},
|
|
616
|
+
{
|
|
617
|
+
"name": "pool_borrow_token_account",
|
|
618
|
+
"writable": true,
|
|
619
|
+
"pda": {
|
|
620
|
+
"seeds": [
|
|
621
|
+
{
|
|
622
|
+
"kind": "const",
|
|
623
|
+
"value": [
|
|
624
|
+
112,
|
|
625
|
+
111,
|
|
626
|
+
111,
|
|
627
|
+
108,
|
|
628
|
+
95,
|
|
629
|
+
98,
|
|
630
|
+
111,
|
|
631
|
+
114,
|
|
632
|
+
114,
|
|
633
|
+
111,
|
|
634
|
+
119,
|
|
635
|
+
95,
|
|
636
|
+
116,
|
|
637
|
+
111,
|
|
638
|
+
107,
|
|
639
|
+
101,
|
|
640
|
+
110
|
|
641
|
+
]
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
"kind": "account",
|
|
645
|
+
"path": "mint_account"
|
|
646
|
+
}
|
|
647
|
+
]
|
|
648
|
+
}
|
|
649
|
+
},
|
|
582
650
|
{
|
|
583
651
|
"name": "pool_sol_account",
|
|
584
652
|
"writable": true,
|
|
@@ -791,6 +859,40 @@
|
|
|
791
859
|
]
|
|
792
860
|
}
|
|
793
861
|
},
|
|
862
|
+
{
|
|
863
|
+
"name": "pool_borrow_token_account",
|
|
864
|
+
"writable": true,
|
|
865
|
+
"pda": {
|
|
866
|
+
"seeds": [
|
|
867
|
+
{
|
|
868
|
+
"kind": "const",
|
|
869
|
+
"value": [
|
|
870
|
+
112,
|
|
871
|
+
111,
|
|
872
|
+
111,
|
|
873
|
+
108,
|
|
874
|
+
95,
|
|
875
|
+
98,
|
|
876
|
+
111,
|
|
877
|
+
114,
|
|
878
|
+
114,
|
|
879
|
+
111,
|
|
880
|
+
119,
|
|
881
|
+
95,
|
|
882
|
+
116,
|
|
883
|
+
111,
|
|
884
|
+
107,
|
|
885
|
+
101,
|
|
886
|
+
110
|
|
887
|
+
]
|
|
888
|
+
},
|
|
889
|
+
{
|
|
890
|
+
"kind": "account",
|
|
891
|
+
"path": "mint_account"
|
|
892
|
+
}
|
|
893
|
+
]
|
|
894
|
+
}
|
|
895
|
+
},
|
|
794
896
|
{
|
|
795
897
|
"name": "pool_sol_account",
|
|
796
898
|
"writable": true,
|
|
@@ -1229,6 +1331,40 @@
|
|
|
1229
1331
|
]
|
|
1230
1332
|
}
|
|
1231
1333
|
},
|
|
1334
|
+
{
|
|
1335
|
+
"name": "pool_borrow_token_account",
|
|
1336
|
+
"writable": true,
|
|
1337
|
+
"pda": {
|
|
1338
|
+
"seeds": [
|
|
1339
|
+
{
|
|
1340
|
+
"kind": "const",
|
|
1341
|
+
"value": [
|
|
1342
|
+
112,
|
|
1343
|
+
111,
|
|
1344
|
+
111,
|
|
1345
|
+
108,
|
|
1346
|
+
95,
|
|
1347
|
+
98,
|
|
1348
|
+
111,
|
|
1349
|
+
114,
|
|
1350
|
+
114,
|
|
1351
|
+
111,
|
|
1352
|
+
119,
|
|
1353
|
+
95,
|
|
1354
|
+
116,
|
|
1355
|
+
111,
|
|
1356
|
+
107,
|
|
1357
|
+
101,
|
|
1358
|
+
110
|
|
1359
|
+
]
|
|
1360
|
+
},
|
|
1361
|
+
{
|
|
1362
|
+
"kind": "account",
|
|
1363
|
+
"path": "mint_account"
|
|
1364
|
+
}
|
|
1365
|
+
]
|
|
1366
|
+
}
|
|
1367
|
+
},
|
|
1232
1368
|
{
|
|
1233
1369
|
"name": "pool_sol_account",
|
|
1234
1370
|
"writable": true,
|
|
@@ -1464,6 +1600,40 @@
|
|
|
1464
1600
|
]
|
|
1465
1601
|
}
|
|
1466
1602
|
},
|
|
1603
|
+
{
|
|
1604
|
+
"name": "pool_borrow_token_account",
|
|
1605
|
+
"writable": true,
|
|
1606
|
+
"pda": {
|
|
1607
|
+
"seeds": [
|
|
1608
|
+
{
|
|
1609
|
+
"kind": "const",
|
|
1610
|
+
"value": [
|
|
1611
|
+
112,
|
|
1612
|
+
111,
|
|
1613
|
+
111,
|
|
1614
|
+
108,
|
|
1615
|
+
95,
|
|
1616
|
+
98,
|
|
1617
|
+
111,
|
|
1618
|
+
114,
|
|
1619
|
+
114,
|
|
1620
|
+
111,
|
|
1621
|
+
119,
|
|
1622
|
+
95,
|
|
1623
|
+
116,
|
|
1624
|
+
111,
|
|
1625
|
+
107,
|
|
1626
|
+
101,
|
|
1627
|
+
110
|
|
1628
|
+
]
|
|
1629
|
+
},
|
|
1630
|
+
{
|
|
1631
|
+
"kind": "account",
|
|
1632
|
+
"path": "mint_account"
|
|
1633
|
+
}
|
|
1634
|
+
]
|
|
1635
|
+
}
|
|
1636
|
+
},
|
|
1467
1637
|
{
|
|
1468
1638
|
"name": "pool_sol_account",
|
|
1469
1639
|
"writable": true,
|
|
@@ -1676,6 +1846,40 @@
|
|
|
1676
1846
|
]
|
|
1677
1847
|
}
|
|
1678
1848
|
},
|
|
1849
|
+
{
|
|
1850
|
+
"name": "pool_borrow_token_account",
|
|
1851
|
+
"writable": true,
|
|
1852
|
+
"pda": {
|
|
1853
|
+
"seeds": [
|
|
1854
|
+
{
|
|
1855
|
+
"kind": "const",
|
|
1856
|
+
"value": [
|
|
1857
|
+
112,
|
|
1858
|
+
111,
|
|
1859
|
+
111,
|
|
1860
|
+
108,
|
|
1861
|
+
95,
|
|
1862
|
+
98,
|
|
1863
|
+
111,
|
|
1864
|
+
114,
|
|
1865
|
+
114,
|
|
1866
|
+
111,
|
|
1867
|
+
119,
|
|
1868
|
+
95,
|
|
1869
|
+
116,
|
|
1870
|
+
111,
|
|
1871
|
+
107,
|
|
1872
|
+
101,
|
|
1873
|
+
110
|
|
1874
|
+
]
|
|
1875
|
+
},
|
|
1876
|
+
{
|
|
1877
|
+
"kind": "account",
|
|
1878
|
+
"path": "mint_account"
|
|
1879
|
+
}
|
|
1880
|
+
]
|
|
1881
|
+
}
|
|
1882
|
+
},
|
|
1679
1883
|
{
|
|
1680
1884
|
"name": "pool_sol_account",
|
|
1681
1885
|
"writable": true,
|
|
@@ -2003,6 +2207,40 @@
|
|
|
2003
2207
|
]
|
|
2004
2208
|
}
|
|
2005
2209
|
},
|
|
2210
|
+
{
|
|
2211
|
+
"name": "pool_borrow_token_account",
|
|
2212
|
+
"writable": true,
|
|
2213
|
+
"pda": {
|
|
2214
|
+
"seeds": [
|
|
2215
|
+
{
|
|
2216
|
+
"kind": "const",
|
|
2217
|
+
"value": [
|
|
2218
|
+
112,
|
|
2219
|
+
111,
|
|
2220
|
+
111,
|
|
2221
|
+
108,
|
|
2222
|
+
95,
|
|
2223
|
+
98,
|
|
2224
|
+
111,
|
|
2225
|
+
114,
|
|
2226
|
+
114,
|
|
2227
|
+
111,
|
|
2228
|
+
119,
|
|
2229
|
+
95,
|
|
2230
|
+
116,
|
|
2231
|
+
111,
|
|
2232
|
+
107,
|
|
2233
|
+
101,
|
|
2234
|
+
110
|
|
2235
|
+
]
|
|
2236
|
+
},
|
|
2237
|
+
{
|
|
2238
|
+
"kind": "account",
|
|
2239
|
+
"path": "mint_account"
|
|
2240
|
+
}
|
|
2241
|
+
]
|
|
2242
|
+
}
|
|
2243
|
+
},
|
|
2006
2244
|
{
|
|
2007
2245
|
"name": "pool_sol_account",
|
|
2008
2246
|
"writable": true,
|
|
@@ -3172,6 +3410,16 @@
|
|
|
3172
3410
|
],
|
|
3173
3411
|
"type": "u64"
|
|
3174
3412
|
},
|
|
3413
|
+
{
|
|
3414
|
+
"name": "initial_borrow_token_reserve",
|
|
3415
|
+
"docs": [
|
|
3416
|
+
"Borrow pool initial funding (initial token amount minted into borrow pool at creation)",
|
|
3417
|
+
"Unlike borrow_token_reserve which changes in real time with borrow/repay,",
|
|
3418
|
+
"this field never changes after creation; used by external parties to compute",
|
|
3419
|
+
"\"borrowed out = initial funding - current available reserve\"."
|
|
3420
|
+
],
|
|
3421
|
+
"type": "u64"
|
|
3422
|
+
},
|
|
3175
3423
|
{
|
|
3176
3424
|
"name": "pool_type",
|
|
3177
3425
|
"docs": [
|
|
@@ -3298,6 +3546,18 @@
|
|
|
3298
3546
|
"name": "mint_account",
|
|
3299
3547
|
"type": "pubkey"
|
|
3300
3548
|
},
|
|
3549
|
+
{
|
|
3550
|
+
"name": "is_buy",
|
|
3551
|
+
"type": "bool"
|
|
3552
|
+
},
|
|
3553
|
+
{
|
|
3554
|
+
"name": "token_amount",
|
|
3555
|
+
"type": "u64"
|
|
3556
|
+
},
|
|
3557
|
+
{
|
|
3558
|
+
"name": "sol_amount",
|
|
3559
|
+
"type": "u64"
|
|
3560
|
+
},
|
|
3301
3561
|
{
|
|
3302
3562
|
"name": "order_id",
|
|
3303
3563
|
"type": "u64"
|
|
@@ -3640,6 +3900,10 @@
|
|
|
3640
3900
|
"name": "pool_token_account",
|
|
3641
3901
|
"type": "pubkey"
|
|
3642
3902
|
},
|
|
3903
|
+
{
|
|
3904
|
+
"name": "pool_borrow_token_account",
|
|
3905
|
+
"type": "pubkey"
|
|
3906
|
+
},
|
|
3643
3907
|
{
|
|
3644
3908
|
"name": "pool_sol_account",
|
|
3645
3909
|
"type": "pubkey"
|
|
@@ -3700,6 +3964,10 @@
|
|
|
3700
3964
|
"name": "initial_virtual_token",
|
|
3701
3965
|
"type": "u64"
|
|
3702
3966
|
},
|
|
3967
|
+
{
|
|
3968
|
+
"name": "initial_borrow_token_reserve",
|
|
3969
|
+
"type": "u64"
|
|
3970
|
+
},
|
|
3703
3971
|
{
|
|
3704
3972
|
"name": "pool_type",
|
|
3705
3973
|
"type": "u8"
|
|
@@ -252,6 +252,40 @@
|
|
|
252
252
|
]
|
|
253
253
|
}
|
|
254
254
|
},
|
|
255
|
+
{
|
|
256
|
+
"name": "pool_borrow_token_account",
|
|
257
|
+
"writable": true,
|
|
258
|
+
"pda": {
|
|
259
|
+
"seeds": [
|
|
260
|
+
{
|
|
261
|
+
"kind": "const",
|
|
262
|
+
"value": [
|
|
263
|
+
112,
|
|
264
|
+
111,
|
|
265
|
+
111,
|
|
266
|
+
108,
|
|
267
|
+
95,
|
|
268
|
+
98,
|
|
269
|
+
111,
|
|
270
|
+
114,
|
|
271
|
+
114,
|
|
272
|
+
111,
|
|
273
|
+
119,
|
|
274
|
+
95,
|
|
275
|
+
116,
|
|
276
|
+
111,
|
|
277
|
+
107,
|
|
278
|
+
101,
|
|
279
|
+
110
|
|
280
|
+
]
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
"kind": "account",
|
|
284
|
+
"path": "mint_account"
|
|
285
|
+
}
|
|
286
|
+
]
|
|
287
|
+
}
|
|
288
|
+
},
|
|
255
289
|
{
|
|
256
290
|
"name": "pool_sol_account",
|
|
257
291
|
"writable": true,
|
|
@@ -579,6 +613,40 @@
|
|
|
579
613
|
]
|
|
580
614
|
}
|
|
581
615
|
},
|
|
616
|
+
{
|
|
617
|
+
"name": "pool_borrow_token_account",
|
|
618
|
+
"writable": true,
|
|
619
|
+
"pda": {
|
|
620
|
+
"seeds": [
|
|
621
|
+
{
|
|
622
|
+
"kind": "const",
|
|
623
|
+
"value": [
|
|
624
|
+
112,
|
|
625
|
+
111,
|
|
626
|
+
111,
|
|
627
|
+
108,
|
|
628
|
+
95,
|
|
629
|
+
98,
|
|
630
|
+
111,
|
|
631
|
+
114,
|
|
632
|
+
114,
|
|
633
|
+
111,
|
|
634
|
+
119,
|
|
635
|
+
95,
|
|
636
|
+
116,
|
|
637
|
+
111,
|
|
638
|
+
107,
|
|
639
|
+
101,
|
|
640
|
+
110
|
|
641
|
+
]
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
"kind": "account",
|
|
645
|
+
"path": "mint_account"
|
|
646
|
+
}
|
|
647
|
+
]
|
|
648
|
+
}
|
|
649
|
+
},
|
|
582
650
|
{
|
|
583
651
|
"name": "pool_sol_account",
|
|
584
652
|
"writable": true,
|
|
@@ -791,6 +859,40 @@
|
|
|
791
859
|
]
|
|
792
860
|
}
|
|
793
861
|
},
|
|
862
|
+
{
|
|
863
|
+
"name": "pool_borrow_token_account",
|
|
864
|
+
"writable": true,
|
|
865
|
+
"pda": {
|
|
866
|
+
"seeds": [
|
|
867
|
+
{
|
|
868
|
+
"kind": "const",
|
|
869
|
+
"value": [
|
|
870
|
+
112,
|
|
871
|
+
111,
|
|
872
|
+
111,
|
|
873
|
+
108,
|
|
874
|
+
95,
|
|
875
|
+
98,
|
|
876
|
+
111,
|
|
877
|
+
114,
|
|
878
|
+
114,
|
|
879
|
+
111,
|
|
880
|
+
119,
|
|
881
|
+
95,
|
|
882
|
+
116,
|
|
883
|
+
111,
|
|
884
|
+
107,
|
|
885
|
+
101,
|
|
886
|
+
110
|
|
887
|
+
]
|
|
888
|
+
},
|
|
889
|
+
{
|
|
890
|
+
"kind": "account",
|
|
891
|
+
"path": "mint_account"
|
|
892
|
+
}
|
|
893
|
+
]
|
|
894
|
+
}
|
|
895
|
+
},
|
|
794
896
|
{
|
|
795
897
|
"name": "pool_sol_account",
|
|
796
898
|
"writable": true,
|
|
@@ -1229,6 +1331,40 @@
|
|
|
1229
1331
|
]
|
|
1230
1332
|
}
|
|
1231
1333
|
},
|
|
1334
|
+
{
|
|
1335
|
+
"name": "pool_borrow_token_account",
|
|
1336
|
+
"writable": true,
|
|
1337
|
+
"pda": {
|
|
1338
|
+
"seeds": [
|
|
1339
|
+
{
|
|
1340
|
+
"kind": "const",
|
|
1341
|
+
"value": [
|
|
1342
|
+
112,
|
|
1343
|
+
111,
|
|
1344
|
+
111,
|
|
1345
|
+
108,
|
|
1346
|
+
95,
|
|
1347
|
+
98,
|
|
1348
|
+
111,
|
|
1349
|
+
114,
|
|
1350
|
+
114,
|
|
1351
|
+
111,
|
|
1352
|
+
119,
|
|
1353
|
+
95,
|
|
1354
|
+
116,
|
|
1355
|
+
111,
|
|
1356
|
+
107,
|
|
1357
|
+
101,
|
|
1358
|
+
110
|
|
1359
|
+
]
|
|
1360
|
+
},
|
|
1361
|
+
{
|
|
1362
|
+
"kind": "account",
|
|
1363
|
+
"path": "mint_account"
|
|
1364
|
+
}
|
|
1365
|
+
]
|
|
1366
|
+
}
|
|
1367
|
+
},
|
|
1232
1368
|
{
|
|
1233
1369
|
"name": "pool_sol_account",
|
|
1234
1370
|
"writable": true,
|
|
@@ -1464,6 +1600,40 @@
|
|
|
1464
1600
|
]
|
|
1465
1601
|
}
|
|
1466
1602
|
},
|
|
1603
|
+
{
|
|
1604
|
+
"name": "pool_borrow_token_account",
|
|
1605
|
+
"writable": true,
|
|
1606
|
+
"pda": {
|
|
1607
|
+
"seeds": [
|
|
1608
|
+
{
|
|
1609
|
+
"kind": "const",
|
|
1610
|
+
"value": [
|
|
1611
|
+
112,
|
|
1612
|
+
111,
|
|
1613
|
+
111,
|
|
1614
|
+
108,
|
|
1615
|
+
95,
|
|
1616
|
+
98,
|
|
1617
|
+
111,
|
|
1618
|
+
114,
|
|
1619
|
+
114,
|
|
1620
|
+
111,
|
|
1621
|
+
119,
|
|
1622
|
+
95,
|
|
1623
|
+
116,
|
|
1624
|
+
111,
|
|
1625
|
+
107,
|
|
1626
|
+
101,
|
|
1627
|
+
110
|
|
1628
|
+
]
|
|
1629
|
+
},
|
|
1630
|
+
{
|
|
1631
|
+
"kind": "account",
|
|
1632
|
+
"path": "mint_account"
|
|
1633
|
+
}
|
|
1634
|
+
]
|
|
1635
|
+
}
|
|
1636
|
+
},
|
|
1467
1637
|
{
|
|
1468
1638
|
"name": "pool_sol_account",
|
|
1469
1639
|
"writable": true,
|
|
@@ -1676,6 +1846,40 @@
|
|
|
1676
1846
|
]
|
|
1677
1847
|
}
|
|
1678
1848
|
},
|
|
1849
|
+
{
|
|
1850
|
+
"name": "pool_borrow_token_account",
|
|
1851
|
+
"writable": true,
|
|
1852
|
+
"pda": {
|
|
1853
|
+
"seeds": [
|
|
1854
|
+
{
|
|
1855
|
+
"kind": "const",
|
|
1856
|
+
"value": [
|
|
1857
|
+
112,
|
|
1858
|
+
111,
|
|
1859
|
+
111,
|
|
1860
|
+
108,
|
|
1861
|
+
95,
|
|
1862
|
+
98,
|
|
1863
|
+
111,
|
|
1864
|
+
114,
|
|
1865
|
+
114,
|
|
1866
|
+
111,
|
|
1867
|
+
119,
|
|
1868
|
+
95,
|
|
1869
|
+
116,
|
|
1870
|
+
111,
|
|
1871
|
+
107,
|
|
1872
|
+
101,
|
|
1873
|
+
110
|
|
1874
|
+
]
|
|
1875
|
+
},
|
|
1876
|
+
{
|
|
1877
|
+
"kind": "account",
|
|
1878
|
+
"path": "mint_account"
|
|
1879
|
+
}
|
|
1880
|
+
]
|
|
1881
|
+
}
|
|
1882
|
+
},
|
|
1679
1883
|
{
|
|
1680
1884
|
"name": "pool_sol_account",
|
|
1681
1885
|
"writable": true,
|
|
@@ -2003,6 +2207,40 @@
|
|
|
2003
2207
|
]
|
|
2004
2208
|
}
|
|
2005
2209
|
},
|
|
2210
|
+
{
|
|
2211
|
+
"name": "pool_borrow_token_account",
|
|
2212
|
+
"writable": true,
|
|
2213
|
+
"pda": {
|
|
2214
|
+
"seeds": [
|
|
2215
|
+
{
|
|
2216
|
+
"kind": "const",
|
|
2217
|
+
"value": [
|
|
2218
|
+
112,
|
|
2219
|
+
111,
|
|
2220
|
+
111,
|
|
2221
|
+
108,
|
|
2222
|
+
95,
|
|
2223
|
+
98,
|
|
2224
|
+
111,
|
|
2225
|
+
114,
|
|
2226
|
+
114,
|
|
2227
|
+
111,
|
|
2228
|
+
119,
|
|
2229
|
+
95,
|
|
2230
|
+
116,
|
|
2231
|
+
111,
|
|
2232
|
+
107,
|
|
2233
|
+
101,
|
|
2234
|
+
110
|
|
2235
|
+
]
|
|
2236
|
+
},
|
|
2237
|
+
{
|
|
2238
|
+
"kind": "account",
|
|
2239
|
+
"path": "mint_account"
|
|
2240
|
+
}
|
|
2241
|
+
]
|
|
2242
|
+
}
|
|
2243
|
+
},
|
|
2006
2244
|
{
|
|
2007
2245
|
"name": "pool_sol_account",
|
|
2008
2246
|
"writable": true,
|
|
@@ -3172,6 +3410,16 @@
|
|
|
3172
3410
|
],
|
|
3173
3411
|
"type": "u64"
|
|
3174
3412
|
},
|
|
3413
|
+
{
|
|
3414
|
+
"name": "initial_borrow_token_reserve",
|
|
3415
|
+
"docs": [
|
|
3416
|
+
"Borrow pool initial funding (initial token amount minted into borrow pool at creation)",
|
|
3417
|
+
"Unlike borrow_token_reserve which changes in real time with borrow/repay,",
|
|
3418
|
+
"this field never changes after creation; used by external parties to compute",
|
|
3419
|
+
"\"borrowed out = initial funding - current available reserve\"."
|
|
3420
|
+
],
|
|
3421
|
+
"type": "u64"
|
|
3422
|
+
},
|
|
3175
3423
|
{
|
|
3176
3424
|
"name": "pool_type",
|
|
3177
3425
|
"docs": [
|
|
@@ -3298,6 +3546,18 @@
|
|
|
3298
3546
|
"name": "mint_account",
|
|
3299
3547
|
"type": "pubkey"
|
|
3300
3548
|
},
|
|
3549
|
+
{
|
|
3550
|
+
"name": "is_buy",
|
|
3551
|
+
"type": "bool"
|
|
3552
|
+
},
|
|
3553
|
+
{
|
|
3554
|
+
"name": "token_amount",
|
|
3555
|
+
"type": "u64"
|
|
3556
|
+
},
|
|
3557
|
+
{
|
|
3558
|
+
"name": "sol_amount",
|
|
3559
|
+
"type": "u64"
|
|
3560
|
+
},
|
|
3301
3561
|
{
|
|
3302
3562
|
"name": "order_id",
|
|
3303
3563
|
"type": "u64"
|
|
@@ -3640,6 +3900,10 @@
|
|
|
3640
3900
|
"name": "pool_token_account",
|
|
3641
3901
|
"type": "pubkey"
|
|
3642
3902
|
},
|
|
3903
|
+
{
|
|
3904
|
+
"name": "pool_borrow_token_account",
|
|
3905
|
+
"type": "pubkey"
|
|
3906
|
+
},
|
|
3643
3907
|
{
|
|
3644
3908
|
"name": "pool_sol_account",
|
|
3645
3909
|
"type": "pubkey"
|
|
@@ -3700,6 +3964,10 @@
|
|
|
3700
3964
|
"name": "initial_virtual_token",
|
|
3701
3965
|
"type": "u64"
|
|
3702
3966
|
},
|
|
3967
|
+
{
|
|
3968
|
+
"name": "initial_borrow_token_reserve",
|
|
3969
|
+
"type": "u64"
|
|
3970
|
+
},
|
|
3703
3971
|
{
|
|
3704
3972
|
"name": "pool_type",
|
|
3705
3973
|
"type": "u8"
|
package/src/modules/chain.js
CHANGED
|
@@ -68,12 +68,20 @@ class ChainModule {
|
|
|
68
68
|
* @returns {string} returns.downOrderbook - Down orderbook (long orders) PDA address
|
|
69
69
|
* @returns {string} returns.creator - Token creator address, the wallet that created this token
|
|
70
70
|
* @returns {string} returns.poolTokenAccount - Pool token account address, stores tokens in the liquidity pool
|
|
71
|
+
* @returns {string} returns.poolBorrowTokenAccount - Pool borrow token account address (PDA seed "pool_borrow_token"), stores tokens for the borrow pool
|
|
71
72
|
* @returns {string} returns.poolSolAccount - Pool SOL account address, stores native SOL in the liquidity pool
|
|
72
73
|
*
|
|
74
|
+
* **Dynamic Liquidity Pool Parameters:**
|
|
75
|
+
* @returns {bigint} returns.initialVirtualSol - Initial virtual SOL reserve (lamports), used for k value / price curve
|
|
76
|
+
* @returns {bigint} returns.initialVirtualToken - Initial virtual Token reserve (smallest unit), used for k value / price curve
|
|
77
|
+
* @returns {bigint} returns.initialBorrowTokenReserve - Borrow pool initial funding (smallest unit), never changes after creation. Borrowed out = initialBorrowTokenReserve - borrowTokenReserve
|
|
78
|
+
* @returns {number} returns.poolType - Pool type (0: basic version, 1: advanced version)
|
|
79
|
+
* @returns {number} returns.borrowPoolRatio - Borrow pool token ratio (5-30 means 5%-30%, basic version fixed at 20)
|
|
80
|
+
*
|
|
73
81
|
* **Token Supply Information:**
|
|
74
82
|
* @returns {bigint} returns.totalSupply - Total token supply (smallest unit)
|
|
75
83
|
* @returns {number} returns.decimals - Token decimal places
|
|
76
|
-
* @returns {bigint} returns.initialBorrowPool - Initial borrow pool size =
|
|
84
|
+
* @returns {bigint} returns.initialBorrowPool - Initial borrow pool size (= initialBorrowTokenReserve from chain)
|
|
77
85
|
* @returns {bigint} returns.circulatingSupply - Circulating supply = totalSupply - borrowTokenReserve
|
|
78
86
|
*
|
|
79
87
|
* **Balance Information:**
|
|
@@ -229,6 +237,15 @@ class ChainModule {
|
|
|
229
237
|
this.sdk.programId
|
|
230
238
|
);
|
|
231
239
|
|
|
240
|
+
// 借贷池专用 token 账户 PDA(合约新增,seed = "pool_borrow_token")
|
|
241
|
+
const [poolBorrowTokenAccountPDA] = PublicKey.findProgramAddressSync(
|
|
242
|
+
[
|
|
243
|
+
Buffer.from("pool_borrow_token"),
|
|
244
|
+
mintPubkey.toBuffer()
|
|
245
|
+
],
|
|
246
|
+
this.sdk.programId
|
|
247
|
+
);
|
|
248
|
+
|
|
232
249
|
const [poolSolAccountPDA] = PublicKey.findProgramAddressSync(
|
|
233
250
|
[
|
|
234
251
|
Buffer.from("pool_sol"),
|
|
@@ -241,6 +258,7 @@ class ChainModule {
|
|
|
241
258
|
let baseFeeRecipientBalance = 0;
|
|
242
259
|
let feeRecipientBalance = 0;
|
|
243
260
|
let poolTokenBalance = { value: { amount: '0' } };
|
|
261
|
+
let poolBorrowTokenBalance = { value: { amount: '0' } };
|
|
244
262
|
let poolSolBalance = 0;
|
|
245
263
|
let tokenSupply = { value: { amount: '0', decimals: 0 } };
|
|
246
264
|
|
|
@@ -249,12 +267,14 @@ class ChainModule {
|
|
|
249
267
|
baseFeeRecipientBalance,
|
|
250
268
|
feeRecipientBalance,
|
|
251
269
|
poolTokenBalance,
|
|
270
|
+
poolBorrowTokenBalance,
|
|
252
271
|
poolSolBalance,
|
|
253
272
|
tokenSupply
|
|
254
273
|
] = await Promise.all([
|
|
255
274
|
this.sdk.connection.getBalance(decodedData.baseFeeRecipient),
|
|
256
275
|
this.sdk.connection.getBalance(decodedData.feeRecipient),
|
|
257
276
|
this.sdk.connection.getTokenAccountBalance(poolTokenAccountPDA).catch(() => ({ value: { amount: '0' } })),
|
|
277
|
+
this.sdk.connection.getTokenAccountBalance(poolBorrowTokenAccountPDA).catch(() => ({ value: { amount: '0' } })),
|
|
258
278
|
this.sdk.connection.getBalance(poolSolAccountPDA),
|
|
259
279
|
this.sdk.connection.getTokenSupply(mintPubkey)
|
|
260
280
|
]);
|
|
@@ -293,6 +313,10 @@ class ChainModule {
|
|
|
293
313
|
initialVirtualSol: BigInt(decodedData.initialVirtualSol.toString()), // u64, lamports
|
|
294
314
|
initialVirtualToken: BigInt(decodedData.initialVirtualToken.toString()), // u64, 最小单位
|
|
295
315
|
|
|
316
|
+
// 借贷池初始资金(合约新增),创建后永不变
|
|
317
|
+
// 已借出量 = initialBorrowTokenReserve - borrowTokenReserve
|
|
318
|
+
initialBorrowTokenReserve: BigInt(decodedData.initialBorrowTokenReserve.toString()), // u64, 最小单位
|
|
319
|
+
|
|
296
320
|
// === 第二阶段新增字段:高级版池子参数 ===
|
|
297
321
|
poolType: decodedData.poolType, // u8, 0=普通版, 1=高级版
|
|
298
322
|
borrowPoolRatio: decodedData.borrowPoolRatio, // u8, 5-30表示5%-30%
|
|
@@ -300,7 +324,8 @@ class ChainModule {
|
|
|
300
324
|
// Token Supply 信息
|
|
301
325
|
totalSupply: BigInt(tokenSupply.value.amount),
|
|
302
326
|
decimals: tokenSupply.value.decimals,
|
|
303
|
-
|
|
327
|
+
// 借贷池初始总量,直接取链上字段(旧公式 totalSupply - initialVirtualToken 已废弃)
|
|
328
|
+
initialBorrowPool: BigInt(decodedData.initialBorrowTokenReserve.toString()),
|
|
304
329
|
circulatingSupply: BigInt(decodedData.initialVirtualToken.toString())
|
|
305
330
|
+ (BigInt(tokenSupply.value.amount) - BigInt(decodedData.initialVirtualToken.toString()) - BigInt(decodedData.borrowTokenReserve.toString())),
|
|
306
331
|
|
|
@@ -309,10 +334,12 @@ class ChainModule {
|
|
|
309
334
|
feeRecipientBalance: feeRecipientBalance, // Unit: lamports
|
|
310
335
|
|
|
311
336
|
// Pool account information
|
|
312
|
-
poolTokenAccount: poolTokenAccountPDA.toString(),
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
337
|
+
poolTokenAccount: poolTokenAccountPDA.toString(), // Pool token account address
|
|
338
|
+
poolBorrowTokenAccount: poolBorrowTokenAccountPDA.toString(), // Pool borrow token account address (新增)
|
|
339
|
+
poolSolAccount: poolSolAccountPDA.toString(), // Pool SOL account address
|
|
340
|
+
poolTokenBalance: BigInt(poolTokenBalance.value.amount), // Pool token balance
|
|
341
|
+
poolBorrowTokenBalance: BigInt(poolBorrowTokenBalance.value.amount), // Pool borrow token balance (= borrowTokenReserve, 新增)
|
|
342
|
+
poolSolBalance: poolSolBalance, // Pool SOL balance (lamports)
|
|
316
343
|
|
|
317
344
|
// Additional metadata
|
|
318
345
|
_metadata: {
|
package/src/modules/token.js
CHANGED
|
@@ -127,6 +127,15 @@ class TokenModule {
|
|
|
127
127
|
this.sdk.programId
|
|
128
128
|
);
|
|
129
129
|
|
|
130
|
+
// Calculate borrow pool token account address (pool_borrow_token)
|
|
131
|
+
const [poolBorrowTokenAccount] = PublicKey.findProgramAddressSync(
|
|
132
|
+
[
|
|
133
|
+
Buffer.from("pool_borrow_token"),
|
|
134
|
+
mint.publicKey.toBuffer(),
|
|
135
|
+
],
|
|
136
|
+
this.sdk.programId
|
|
137
|
+
);
|
|
138
|
+
|
|
130
139
|
// Calculate liquidity pool SOL account address (pool_sol)
|
|
131
140
|
const [poolSolAccount] = PublicKey.findProgramAddressSync(
|
|
132
141
|
[
|
|
@@ -166,6 +175,7 @@ class TokenModule {
|
|
|
166
175
|
console.log('Calculated account addresses:');
|
|
167
176
|
console.log(' Borrowing liquidity pool account:', curveAccount.toString());
|
|
168
177
|
console.log(' Liquidity pool token account:', poolTokenAccount.toString());
|
|
178
|
+
console.log(' Borrow pool token account:', poolBorrowTokenAccount.toString());
|
|
169
179
|
console.log(' Liquidity pool SOL account:', poolSolAccount.toString());
|
|
170
180
|
console.log(' Up orderbook:', upOrderbook.toString());
|
|
171
181
|
console.log(' Down orderbook:', downOrderbook.toString());
|
|
@@ -199,6 +209,7 @@ class TokenModule {
|
|
|
199
209
|
mintAccount: mint.publicKey,
|
|
200
210
|
curveAccount: curveAccount,
|
|
201
211
|
poolTokenAccount: poolTokenAccount,
|
|
212
|
+
poolBorrowTokenAccount: poolBorrowTokenAccount,
|
|
202
213
|
poolSolAccount: poolSolAccount,
|
|
203
214
|
upOrderbook: upOrderbook,
|
|
204
215
|
downOrderbook: downOrderbook,
|
|
@@ -225,6 +236,7 @@ class TokenModule {
|
|
|
225
236
|
mint: mint.publicKey,
|
|
226
237
|
curveAccount,
|
|
227
238
|
poolTokenAccount,
|
|
239
|
+
poolBorrowTokenAccount,
|
|
228
240
|
poolSolAccount,
|
|
229
241
|
upOrderbook,
|
|
230
242
|
downOrderbook,
|
|
@@ -388,6 +400,7 @@ class TokenModule {
|
|
|
388
400
|
mintAccount: mintPubkey,
|
|
389
401
|
curveAccount: createResult.accounts.curveAccount,
|
|
390
402
|
poolTokenAccount: createResult.accounts.poolTokenAccount,
|
|
403
|
+
poolBorrowTokenAccount: createResult.accounts.poolBorrowTokenAccount,
|
|
391
404
|
poolSolAccount: createResult.accounts.poolSolAccount,
|
|
392
405
|
upOrderbook: upOrderbook,
|
|
393
406
|
downOrderbook: downOrderbook,
|
package/src/modules/trading.js
CHANGED
|
@@ -106,6 +106,7 @@ class TradingModule {
|
|
|
106
106
|
mintAccount: mint,
|
|
107
107
|
curveAccount: accounts.curveAccount,
|
|
108
108
|
poolTokenAccount: accounts.poolTokenAccount,
|
|
109
|
+
poolBorrowTokenAccount: accounts.poolBorrowTokenAccount,
|
|
109
110
|
poolSolAccount: accounts.poolSolAccount,
|
|
110
111
|
upOrderbook: upOrderbook,
|
|
111
112
|
downOrderbook: downOrderbook,
|
|
@@ -242,6 +243,7 @@ class TradingModule {
|
|
|
242
243
|
mintAccount: mint,
|
|
243
244
|
curveAccount: accounts.curveAccount,
|
|
244
245
|
poolTokenAccount: accounts.poolTokenAccount,
|
|
246
|
+
poolBorrowTokenAccount: accounts.poolBorrowTokenAccount,
|
|
245
247
|
poolSolAccount: accounts.poolSolAccount,
|
|
246
248
|
upOrderbook: upOrderbook,
|
|
247
249
|
downOrderbook: downOrderbook,
|
|
@@ -363,6 +365,7 @@ class TradingModule {
|
|
|
363
365
|
mintAccount: mint,
|
|
364
366
|
curveAccount: accounts.curveAccount,
|
|
365
367
|
poolTokenAccount: accounts.poolTokenAccount,
|
|
368
|
+
poolBorrowTokenAccount: accounts.poolBorrowTokenAccount,
|
|
366
369
|
poolSolAccount: accounts.poolSolAccount,
|
|
367
370
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
368
371
|
systemProgram: SystemProgram.programId,
|
|
@@ -474,6 +477,7 @@ class TradingModule {
|
|
|
474
477
|
mintAccount: mint,
|
|
475
478
|
curveAccount: accounts.curveAccount,
|
|
476
479
|
poolTokenAccount: accounts.poolTokenAccount,
|
|
480
|
+
poolBorrowTokenAccount: accounts.poolBorrowTokenAccount,
|
|
477
481
|
poolSolAccount: accounts.poolSolAccount,
|
|
478
482
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
479
483
|
systemProgram: SystemProgram.programId,
|
|
@@ -617,6 +621,7 @@ class TradingModule {
|
|
|
617
621
|
mintAccount: mint,
|
|
618
622
|
curveAccount: accounts.curveAccount,
|
|
619
623
|
poolTokenAccount: accounts.poolTokenAccount,
|
|
624
|
+
poolBorrowTokenAccount: accounts.poolBorrowTokenAccount,
|
|
620
625
|
poolSolAccount: accounts.poolSolAccount,
|
|
621
626
|
userSolAccount: userSolAccountPubkey, // 开仓用户的SOL账户 / User SOL account (must be order opener)
|
|
622
627
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
@@ -766,6 +771,7 @@ class TradingModule {
|
|
|
766
771
|
mintAccount: mint,
|
|
767
772
|
curveAccount: accounts.curveAccount,
|
|
768
773
|
poolTokenAccount: accounts.poolTokenAccount,
|
|
774
|
+
poolBorrowTokenAccount: accounts.poolBorrowTokenAccount,
|
|
769
775
|
poolSolAccount: accounts.poolSolAccount,
|
|
770
776
|
userSolAccount: userSolAccountPubkey, // 开仓用户的SOL账户 / User SOL account (must be order opener)
|
|
771
777
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
@@ -827,6 +833,12 @@ class TradingModule {
|
|
|
827
833
|
this.sdk.programId
|
|
828
834
|
);
|
|
829
835
|
|
|
836
|
+
// 计算借贷池专用代币账户 PDA
|
|
837
|
+
const [poolBorrowTokenAccount] = PublicKey.findProgramAddressSync(
|
|
838
|
+
[Buffer.from('pool_borrow_token'), mintAccount.toBuffer()],
|
|
839
|
+
this.sdk.programId
|
|
840
|
+
);
|
|
841
|
+
|
|
830
842
|
// 计算池子 SOL 账户 PDA
|
|
831
843
|
const [poolSolAccount] = PublicKey.findProgramAddressSync(
|
|
832
844
|
[Buffer.from('pool_sol'), mintAccount.toBuffer()],
|
|
@@ -836,6 +848,7 @@ class TradingModule {
|
|
|
836
848
|
return {
|
|
837
849
|
curveAccount,
|
|
838
850
|
poolTokenAccount,
|
|
851
|
+
poolBorrowTokenAccount,
|
|
839
852
|
poolSolAccount
|
|
840
853
|
};
|
|
841
854
|
}
|