@floorlaunchpad/sdk 0.3.0 → 0.3.1
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/CHANGELOG.md +30 -0
- package/README.md +9 -0
- package/dist/abi/solana.gen.js +2 -0
- package/dist/config/generated.js +121 -64
- package/dist/evm/chains.js +5 -1
- package/dist/evm/squid.js +107 -0
- package/dist/index.js +2 -0
- package/dist/indexer/client.js +1 -0
- package/dist/indexer/contract.js +11 -2
- package/dist/indexer/partners.js +5 -0
- package/dist/math/v2/trade.js +8 -8
- package/dist/solana/floor/accounts.js +3 -1
- package/dist/solana/floor/events.js +4 -0
- package/dist/solana/floor/instructions.js +13 -0
- package/dist/v2/router.js +22 -0
- package/docs/floor-line.md +66 -0
- package/examples/floor-line.html +104 -0
- package/package.json +2 -1
- package/src/abi/solana.gen.ts +2 -0
- package/src/config/generated.ts +121 -64
- package/src/config/index.ts +2 -0
- package/src/events/types.gen.ts +11 -0
- package/src/evm/chains.ts +5 -1
- package/src/evm/squid.ts +138 -0
- package/src/index.ts +2 -0
- package/src/indexer/client.ts +2 -0
- package/src/indexer/contract.ts +12 -3
- package/src/indexer/partners.ts +6 -0
- package/src/math/v2/trade.ts +8 -8
- package/src/solana/floor/accounts.ts +3 -1
- package/src/solana/floor/events.ts +4 -0
- package/src/solana/floor/instructions.ts +13 -0
- package/src/v2/router.ts +22 -0
package/src/config/generated.ts
CHANGED
|
@@ -137,7 +137,13 @@ export const CHAIN_ROWS = [
|
|
|
137
137
|
"url": "https://etherscan.io",
|
|
138
138
|
"soak": {
|
|
139
139
|
"url": "https://sepolia.etherscan.io"
|
|
140
|
-
}
|
|
140
|
+
},
|
|
141
|
+
"alt": [
|
|
142
|
+
{
|
|
143
|
+
"name": "Blockscout",
|
|
144
|
+
"url": "https://eth.blockscout.com"
|
|
145
|
+
}
|
|
146
|
+
]
|
|
141
147
|
},
|
|
142
148
|
"quotes": [
|
|
143
149
|
{
|
|
@@ -208,14 +214,16 @@ export const CHAIN_ROWS = [
|
|
|
208
214
|
"name": "Pepe",
|
|
209
215
|
"address": "0x6982508145454Ce325dDbE47a25d4ec3d2311933",
|
|
210
216
|
"decimals": 18,
|
|
211
|
-
"kind": "meme"
|
|
217
|
+
"kind": "meme",
|
|
218
|
+
"deferred": true
|
|
212
219
|
},
|
|
213
220
|
{
|
|
214
221
|
"symbol": "SHIB",
|
|
215
|
-
"name": "
|
|
222
|
+
"name": "SHIBA INU",
|
|
216
223
|
"address": "0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE",
|
|
217
224
|
"decimals": 18,
|
|
218
|
-
"kind": "meme"
|
|
225
|
+
"kind": "meme",
|
|
226
|
+
"deferred": true
|
|
219
227
|
}
|
|
220
228
|
]
|
|
221
229
|
},
|
|
@@ -239,7 +247,13 @@ export const CHAIN_ROWS = [
|
|
|
239
247
|
"url": "https://basescan.org",
|
|
240
248
|
"soak": {
|
|
241
249
|
"url": "https://sepolia.basescan.org"
|
|
242
|
-
}
|
|
250
|
+
},
|
|
251
|
+
"alt": [
|
|
252
|
+
{
|
|
253
|
+
"name": "Blockscout",
|
|
254
|
+
"url": "https://base.blockscout.com"
|
|
255
|
+
}
|
|
256
|
+
]
|
|
243
257
|
},
|
|
244
258
|
"quotes": [
|
|
245
259
|
{
|
|
@@ -418,7 +432,13 @@ export const CHAIN_ROWS = [
|
|
|
418
432
|
"url": "https://arbiscan.io",
|
|
419
433
|
"soak": {
|
|
420
434
|
"url": "https://sepolia.arbiscan.io"
|
|
421
|
-
}
|
|
435
|
+
},
|
|
436
|
+
"alt": [
|
|
437
|
+
{
|
|
438
|
+
"name": "Blockscout",
|
|
439
|
+
"url": "https://arbitrum.blockscout.com"
|
|
440
|
+
}
|
|
441
|
+
]
|
|
422
442
|
},
|
|
423
443
|
"quotes": [
|
|
424
444
|
{
|
|
@@ -460,11 +480,17 @@ export const CHAIN_ROWS = [
|
|
|
460
480
|
"rpcEnv": "FLOOR_RPC_ARC_TESTNET"
|
|
461
481
|
},
|
|
462
482
|
"explorer": {
|
|
463
|
-
"name": "
|
|
464
|
-
"url": "https://
|
|
483
|
+
"name": "Arc Etherscan",
|
|
484
|
+
"url": "https://arc.etherscan.io",
|
|
465
485
|
"soak": {
|
|
466
|
-
"url": "https://testnet.
|
|
467
|
-
}
|
|
486
|
+
"url": "https://explorer.testnet.arc.io"
|
|
487
|
+
},
|
|
488
|
+
"alt": [
|
|
489
|
+
{
|
|
490
|
+
"name": "Blockscout",
|
|
491
|
+
"url": "https://explorer.arc.io"
|
|
492
|
+
}
|
|
493
|
+
]
|
|
468
494
|
},
|
|
469
495
|
"quotes": [
|
|
470
496
|
{
|
|
@@ -492,11 +518,17 @@ export const CHAIN_ROWS = [
|
|
|
492
518
|
"rpcEnv": "FLOOR_RPC_ROBINHOOD_TESTNET"
|
|
493
519
|
},
|
|
494
520
|
"explorer": {
|
|
495
|
-
"name": "Robinhood Chain
|
|
496
|
-
"url": "https://
|
|
521
|
+
"name": "Robinhood Chain Etherscan",
|
|
522
|
+
"url": "https://robin.etherscan.io",
|
|
497
523
|
"soak": {
|
|
498
524
|
"url": "https://explorer.testnet.chain.robinhood.com"
|
|
499
|
-
}
|
|
525
|
+
},
|
|
526
|
+
"alt": [
|
|
527
|
+
{
|
|
528
|
+
"name": "Blockscout",
|
|
529
|
+
"url": "https://robinhoodchain.blockscout.com"
|
|
530
|
+
}
|
|
531
|
+
]
|
|
500
532
|
},
|
|
501
533
|
"quotes": [
|
|
502
534
|
{
|
|
@@ -515,24 +547,27 @@ export const CHAIN_ROWS = [
|
|
|
515
547
|
},
|
|
516
548
|
{
|
|
517
549
|
"symbol": "WOJAK",
|
|
518
|
-
"name": "
|
|
550
|
+
"name": "Wojak",
|
|
519
551
|
"address": "0x806ba27b5e1c4c2e989a3757a8def9fe1145ed10",
|
|
520
552
|
"decimals": 18,
|
|
521
|
-
"kind": "meme"
|
|
553
|
+
"kind": "meme",
|
|
554
|
+
"deferred": true
|
|
522
555
|
},
|
|
523
556
|
{
|
|
524
557
|
"symbol": "AI",
|
|
525
|
-
"name": "
|
|
558
|
+
"name": "Artificial Inu",
|
|
526
559
|
"address": "0x2E8c31162b855A2ffa90F6F8634643Ad6F111e18",
|
|
527
560
|
"decimals": 18,
|
|
528
|
-
"kind": "meme"
|
|
561
|
+
"kind": "meme",
|
|
562
|
+
"deferred": true
|
|
529
563
|
},
|
|
530
564
|
{
|
|
531
565
|
"symbol": "PONS",
|
|
532
|
-
"name": "
|
|
566
|
+
"name": "Pons",
|
|
533
567
|
"address": "0x39dBED3a2bd333467115dE45665cC57F813C4571",
|
|
534
568
|
"decimals": 18,
|
|
535
|
-
"kind": "meme"
|
|
569
|
+
"kind": "meme",
|
|
570
|
+
"deferred": true
|
|
536
571
|
}
|
|
537
572
|
]
|
|
538
573
|
},
|
|
@@ -555,7 +590,7 @@ export const CHAIN_ROWS = [
|
|
|
555
590
|
"name": "HyperEVMScan",
|
|
556
591
|
"url": "https://hyperevmscan.io",
|
|
557
592
|
"soak": {
|
|
558
|
-
"url": "https://testnet.
|
|
593
|
+
"url": "https://app.hyperliquid-testnet.xyz/explorer"
|
|
559
594
|
}
|
|
560
595
|
},
|
|
561
596
|
"quotes": [
|
|
@@ -589,157 +624,179 @@ export const CHAIN_ROWS = [
|
|
|
589
624
|
},
|
|
590
625
|
{
|
|
591
626
|
"symbol": "wNVDAx",
|
|
592
|
-
"name": "
|
|
627
|
+
"name": "Wrapped NVIDIA xStock",
|
|
593
628
|
"address": "0xa8ddb5cd96b5222afe198316e9a57caa642850d5",
|
|
594
629
|
"decimals": 18,
|
|
595
|
-
"kind": "stock"
|
|
630
|
+
"kind": "stock",
|
|
631
|
+
"deferred": true
|
|
596
632
|
},
|
|
597
633
|
{
|
|
598
634
|
"symbol": "wSPYx",
|
|
599
|
-
"name": "
|
|
635
|
+
"name": "Wrapped SP500 xStock",
|
|
600
636
|
"address": "0xe7e553cd128f0011777323a0b44a7b96ea1cb540",
|
|
601
637
|
"decimals": 18,
|
|
602
|
-
"kind": "stock"
|
|
638
|
+
"kind": "stock",
|
|
639
|
+
"deferred": true
|
|
603
640
|
},
|
|
604
641
|
{
|
|
605
642
|
"symbol": "wQQQx",
|
|
606
|
-
"name": "
|
|
643
|
+
"name": "Wrapped Nasdaq xStock",
|
|
607
644
|
"address": "0x4c1ae29c159838fc1b224636e28e086eb69101f7",
|
|
608
645
|
"decimals": 18,
|
|
609
|
-
"kind": "stock"
|
|
646
|
+
"kind": "stock",
|
|
647
|
+
"deferred": true
|
|
610
648
|
},
|
|
611
649
|
{
|
|
612
650
|
"symbol": "wSKHYx",
|
|
613
|
-
"name": "
|
|
651
|
+
"name": "Wrapped SK hynix xStock",
|
|
614
652
|
"address": "0x6215a58ed045d71f2561aaabe54f4c885c522998",
|
|
615
653
|
"decimals": 18,
|
|
616
|
-
"kind": "stock"
|
|
654
|
+
"kind": "stock",
|
|
655
|
+
"deferred": true
|
|
617
656
|
},
|
|
618
657
|
{
|
|
619
658
|
"symbol": "wMUx",
|
|
620
|
-
"name": "
|
|
659
|
+
"name": "Wrapped Micron Technology xStock",
|
|
621
660
|
"address": "0xe2047ee3bddb5c99ae428ab83df63f8730698e30",
|
|
622
661
|
"decimals": 18,
|
|
623
|
-
"kind": "stock"
|
|
662
|
+
"kind": "stock",
|
|
663
|
+
"deferred": true
|
|
624
664
|
},
|
|
625
665
|
{
|
|
626
666
|
"symbol": "SPCX.dw",
|
|
627
|
-
"name": "
|
|
667
|
+
"name": "Wrapped Space Exploration Technologies Corp.",
|
|
628
668
|
"address": "0x95687557c66bc799a850ba7037673528238ae763",
|
|
629
669
|
"decimals": 18,
|
|
630
|
-
"kind": "stock"
|
|
670
|
+
"kind": "stock",
|
|
671
|
+
"deferred": true
|
|
631
672
|
},
|
|
632
673
|
{
|
|
633
674
|
"symbol": "AAPLd",
|
|
634
|
-
"name": "
|
|
675
|
+
"name": "Apple",
|
|
635
676
|
"address": "0x7374dc1894fbd1bc6c42f6ebbc50b78c211a8606",
|
|
636
677
|
"decimals": 18,
|
|
637
|
-
"kind": "stock"
|
|
678
|
+
"kind": "stock",
|
|
679
|
+
"deferred": true
|
|
638
680
|
},
|
|
639
681
|
{
|
|
640
682
|
"symbol": "MSFTd",
|
|
641
|
-
"name": "
|
|
683
|
+
"name": "Microsoft",
|
|
642
684
|
"address": "0x66520d8fd614487214a25af7babf27584f59f76b",
|
|
643
685
|
"decimals": 18,
|
|
644
|
-
"kind": "stock"
|
|
686
|
+
"kind": "stock",
|
|
687
|
+
"deferred": true
|
|
645
688
|
},
|
|
646
689
|
{
|
|
647
690
|
"symbol": "GOOGLd",
|
|
648
|
-
"name": "
|
|
691
|
+
"name": "Alphabet Class A",
|
|
649
692
|
"address": "0x35eeda03e55ff217a013892e9e2e37e792b264ea",
|
|
650
693
|
"decimals": 18,
|
|
651
|
-
"kind": "stock"
|
|
694
|
+
"kind": "stock",
|
|
695
|
+
"deferred": true
|
|
652
696
|
},
|
|
653
697
|
{
|
|
654
698
|
"symbol": "METAd",
|
|
655
|
-
"name": "
|
|
699
|
+
"name": "Meta Platforms",
|
|
656
700
|
"address": "0x5a9d2deee7d8782011695623f1c453f46b2b566e",
|
|
657
701
|
"decimals": 18,
|
|
658
|
-
"kind": "stock"
|
|
702
|
+
"kind": "stock",
|
|
703
|
+
"deferred": true
|
|
659
704
|
},
|
|
660
705
|
{
|
|
661
706
|
"symbol": "AMZNd",
|
|
662
|
-
"name": "
|
|
707
|
+
"name": "Amazon",
|
|
663
708
|
"address": "0x4f2164c12d2d450a8b1d430492ef6670fe4cad8e",
|
|
664
709
|
"decimals": 18,
|
|
665
|
-
"kind": "stock"
|
|
710
|
+
"kind": "stock",
|
|
711
|
+
"deferred": true
|
|
666
712
|
},
|
|
667
713
|
{
|
|
668
714
|
"symbol": "HOODd",
|
|
669
|
-
"name": "
|
|
715
|
+
"name": "Robinhood Markets",
|
|
670
716
|
"address": "0xc304a9d52cf9165024ebc7814250ef3a5013f924",
|
|
671
717
|
"decimals": 18,
|
|
672
|
-
"kind": "stock"
|
|
718
|
+
"kind": "stock",
|
|
719
|
+
"deferred": true
|
|
673
720
|
},
|
|
674
721
|
{
|
|
675
722
|
"symbol": "CRCLd",
|
|
676
|
-
"name": "
|
|
723
|
+
"name": "Circle Internet Group",
|
|
677
724
|
"address": "0xe74aa6c4050a15790525eb11cc4562c664dc67c9",
|
|
678
725
|
"decimals": 18,
|
|
679
|
-
"kind": "stock"
|
|
726
|
+
"kind": "stock",
|
|
727
|
+
"deferred": true
|
|
680
728
|
},
|
|
681
729
|
{
|
|
682
730
|
"symbol": "MUd",
|
|
683
|
-
"name": "
|
|
731
|
+
"name": "Micron Technology",
|
|
684
732
|
"address": "0x173c83a71c1a9e254721a86b7512cd65bf92648d",
|
|
685
733
|
"decimals": 18,
|
|
686
|
-
"kind": "stock"
|
|
734
|
+
"kind": "stock",
|
|
735
|
+
"deferred": true
|
|
687
736
|
},
|
|
688
737
|
{
|
|
689
738
|
"symbol": "ORCLd",
|
|
690
|
-
"name": "
|
|
739
|
+
"name": "Oracle",
|
|
691
740
|
"address": "0xca2156522638f597ffb3705857ffdc356efabe50",
|
|
692
741
|
"decimals": 18,
|
|
693
|
-
"kind": "stock"
|
|
742
|
+
"kind": "stock",
|
|
743
|
+
"deferred": true
|
|
694
744
|
},
|
|
695
745
|
{
|
|
696
746
|
"symbol": "AVGOd",
|
|
697
|
-
"name": "
|
|
747
|
+
"name": "Broadcom",
|
|
698
748
|
"address": "0xc2785563af80c05177fff006e3b380ac5d172602",
|
|
699
749
|
"decimals": 18,
|
|
700
|
-
"kind": "stock"
|
|
750
|
+
"kind": "stock",
|
|
751
|
+
"deferred": true
|
|
701
752
|
},
|
|
702
753
|
{
|
|
703
754
|
"symbol": "SPCXd",
|
|
704
|
-
"name": "
|
|
755
|
+
"name": "SpaceX",
|
|
705
756
|
"address": "0xe8c8afdf7e80be51e91afa28b6ac44404d270b5d",
|
|
706
757
|
"decimals": 18,
|
|
707
|
-
"kind": "stock"
|
|
758
|
+
"kind": "stock",
|
|
759
|
+
"deferred": true
|
|
708
760
|
},
|
|
709
761
|
{
|
|
710
762
|
"symbol": "SPYd",
|
|
711
|
-
"name": "
|
|
763
|
+
"name": "SPDR S&P 500 ETF",
|
|
712
764
|
"address": "0xb7bf37783db41a2851b77c6917280c56312c833a",
|
|
713
765
|
"decimals": 18,
|
|
714
|
-
"kind": "stock"
|
|
766
|
+
"kind": "stock",
|
|
767
|
+
"deferred": true
|
|
715
768
|
},
|
|
716
769
|
{
|
|
717
770
|
"symbol": "QQQd",
|
|
718
|
-
"name": "
|
|
771
|
+
"name": "Invesco QQQ",
|
|
719
772
|
"address": "0x499e347174f237ad28687b947b94c0d49570d1b7",
|
|
720
773
|
"decimals": 18,
|
|
721
|
-
"kind": "stock"
|
|
774
|
+
"kind": "stock",
|
|
775
|
+
"deferred": true
|
|
722
776
|
},
|
|
723
777
|
{
|
|
724
778
|
"symbol": "GLDd",
|
|
725
|
-
"name": "
|
|
779
|
+
"name": "SPDR Gold Shares (ETF)",
|
|
726
780
|
"address": "0x08be08c37d93e689518ced744a89f113b4afaad4",
|
|
727
781
|
"decimals": 18,
|
|
728
|
-
"kind": "stock"
|
|
782
|
+
"kind": "stock",
|
|
783
|
+
"deferred": true
|
|
729
784
|
},
|
|
730
785
|
{
|
|
731
786
|
"symbol": "SLVd",
|
|
732
|
-
"name": "
|
|
787
|
+
"name": "iShares Silver Trust (ETF)",
|
|
733
788
|
"address": "0x7ef4eba0c0200957e357627ced1884d6cb63e961",
|
|
734
789
|
"decimals": 18,
|
|
735
|
-
"kind": "stock"
|
|
790
|
+
"kind": "stock",
|
|
791
|
+
"deferred": true
|
|
736
792
|
},
|
|
737
793
|
{
|
|
738
794
|
"symbol": "BNBd",
|
|
739
|
-
"name": "
|
|
795
|
+
"name": "BNB",
|
|
740
796
|
"address": "0xfd6f06d323f6cb08ee9eeb2d201e9ec0e9112c88",
|
|
741
797
|
"decimals": 18,
|
|
742
|
-
"kind": "stock"
|
|
798
|
+
"kind": "stock",
|
|
799
|
+
"deferred": true
|
|
743
800
|
}
|
|
744
801
|
]
|
|
745
802
|
}
|
package/src/config/index.ts
CHANGED
package/src/events/types.gen.ts
CHANGED
|
@@ -325,6 +325,15 @@ export interface SolTokensBurnedFields {
|
|
|
325
325
|
slot: bigint;
|
|
326
326
|
fromShareBought: bigint | null;
|
|
327
327
|
}
|
|
328
|
+
export interface SolGenesisPublicStartedFields {
|
|
329
|
+
signer: string;
|
|
330
|
+
at: bigint;
|
|
331
|
+
}
|
|
332
|
+
export interface SolGenesisEndSetFields {
|
|
333
|
+
signer: string;
|
|
334
|
+
oldEndsAt: bigint;
|
|
335
|
+
newEndsAt: bigint;
|
|
336
|
+
}
|
|
328
337
|
export interface SolLaunchCreatedV2Fields {
|
|
329
338
|
launch: string;
|
|
330
339
|
mint: string;
|
|
@@ -476,6 +485,8 @@ export type SolanaEventMap = {
|
|
|
476
485
|
GenesisListRootSet: SolGenesisListRootSetFields;
|
|
477
486
|
BurnsSynced: SolBurnsSyncedFields;
|
|
478
487
|
TokensBurned: SolTokensBurnedFields;
|
|
488
|
+
GenesisPublicStarted: SolGenesisPublicStartedFields;
|
|
489
|
+
GenesisEndSet: SolGenesisEndSetFields;
|
|
479
490
|
LaunchCreatedV2: SolLaunchCreatedV2Fields;
|
|
480
491
|
Trade: SolTradeFields;
|
|
481
492
|
HolderPositionOpened: SolHolderPositionOpenedFields;
|
package/src/evm/chains.ts
CHANGED
|
@@ -130,7 +130,11 @@ export const FLOOR_SALTS = {
|
|
|
130
130
|
routerDeployer: salt("floor-router.v2.router-deployer"),
|
|
131
131
|
} as const;
|
|
132
132
|
|
|
133
|
-
export const FLOOR_AMM_ADDRESS: string | null =
|
|
133
|
+
export const FLOOR_AMM_ADDRESS: string | null = "0xF10000bd05c2C01793C6d55F027346469683d225";
|
|
134
|
+
|
|
135
|
+
export const FLOOR_AMM_FROM_BLOCK: Readonly<Record<ChainKey, number | null>> = {
|
|
136
|
+
ethereum: 26327910, base: 53421827, bsc: 131270813, arbitrum: 520655168, arc: 29205598, robinhood: 104455459, hyperevm: null,
|
|
137
|
+
};
|
|
134
138
|
|
|
135
139
|
const cat = (...h: string[]): string => "0x" + h.map((x) => bytesToHex(hexToBytes(x)).slice(2)).join("");
|
|
136
140
|
const at = (s: string, init: string): string => create2Address({ deployer: CREATE2_FACTORY, salt: s, initCode: init });
|
package/src/evm/squid.ts
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import { bytesToHex, encodeAbi, encodeCall } from "./abi.ts";
|
|
4
|
+
|
|
5
|
+
export const SQUID_CALL = { Default: 0, FullTokenBalance: 1, FullNativeBalance: 2, CollectTokenBalance: 3 } as const;
|
|
6
|
+
|
|
7
|
+
export const SQUID_FULL = 0n;
|
|
8
|
+
|
|
9
|
+
const SOLANA_CHAINS: readonly (number | string)[] = [101, 1151111081099710, "solana", "solana-mainnet-beta"];
|
|
10
|
+
|
|
11
|
+
export type SquidHookCode = "SOLANA" | "RECIPIENT_IS_MULTICALL" | "BAD_RECIPIENT" | "NO_MINIMUM" | "NATIVE_QUOTE" | "NOT_WHOLE_UNITS" | "BAD_ADDRESS";
|
|
12
|
+
|
|
13
|
+
export class SquidHookError extends Error {
|
|
14
|
+
readonly code: SquidHookCode;
|
|
15
|
+
constructor(code: SquidHookCode, detail: string) {
|
|
16
|
+
super(`squid: ${code}: ${detail}`);
|
|
17
|
+
this.code = code;
|
|
18
|
+
this.name = "SquidHookError";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type SquidHookCall = {
|
|
23
|
+
chainType: "evm";
|
|
24
|
+
callType: number;
|
|
25
|
+
target: string;
|
|
26
|
+
value: string;
|
|
27
|
+
callData: string;
|
|
28
|
+
payload: string;
|
|
29
|
+
estimatedGas: string;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type SquidHook = {
|
|
33
|
+
provider: "FLOOR";
|
|
34
|
+
description: string;
|
|
35
|
+
calls: SquidHookCall[];
|
|
36
|
+
fundToken?: string;
|
|
37
|
+
fundAmount?: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const SQUID_TOKEN_SCALE = 10n ** 12n;
|
|
41
|
+
|
|
42
|
+
export const SQUID_GAS = { transfer: 65_000, buy: 700_000, sell: 750_000, zapBuy: 900_000, passOn: 30_000 } as const;
|
|
43
|
+
|
|
44
|
+
type Common = {
|
|
45
|
+
chainId: number | string;
|
|
46
|
+
|
|
47
|
+
multicall: string;
|
|
48
|
+
floorAmm: string;
|
|
49
|
+
launchId: bigint;
|
|
50
|
+
|
|
51
|
+
user: string;
|
|
52
|
+
deadline: bigint;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const ZERO = "0x" + "0".repeat(40);
|
|
56
|
+
const lc = (a: string, what: string): string => {
|
|
57
|
+
if (!/^0x[0-9a-fA-F]{40}$/.test(a)) throw new SquidHookError("BAD_ADDRESS", `${what} ${a}`);
|
|
58
|
+
return a.toLowerCase();
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
function checkCommon(p: Common): void {
|
|
62
|
+
if (SOLANA_CHAINS.includes(p.chainId)) throw new SquidHookError("SOLANA", `chain ${p.chainId}: hooks run on EVM chains only`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function checkUser(p: Common): string {
|
|
66
|
+
const user = lc(p.user, "user");
|
|
67
|
+
if (user === lc(p.multicall, "multicall")) throw new SquidHookError("RECIPIENT_IS_MULTICALL", "the tokens would stay on SquidMulticall");
|
|
68
|
+
if (user === ZERO || user === lc(p.floorAmm, "floorAmm")) throw new SquidHookError("BAD_RECIPIENT", user);
|
|
69
|
+
return user;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const call = (callType: number, target: string, value: bigint, callData: string, payload: string, gas: number): SquidHookCall => ({
|
|
73
|
+
chainType: "evm",
|
|
74
|
+
callType,
|
|
75
|
+
target,
|
|
76
|
+
value: value.toString(),
|
|
77
|
+
callData,
|
|
78
|
+
payload,
|
|
79
|
+
estimatedGas: String(gas),
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
export function buyHookErc20(p: Common & { quote: string; minTokensOut: bigint }): SquidHook {
|
|
83
|
+
checkCommon(p);
|
|
84
|
+
const user = checkUser(p);
|
|
85
|
+
const quote = lc(p.quote, "quote");
|
|
86
|
+
if (quote === ZERO) throw new SquidHookError("NATIVE_QUOTE", "buyFromBalance refuses a native quote: use buyHookNative");
|
|
87
|
+
if (p.minTokensOut <= 0n) throw new SquidHookError("NO_MINIMUM", "minTokensOut must be > 0");
|
|
88
|
+
const amm = lc(p.floorAmm, "floorAmm");
|
|
89
|
+
return {
|
|
90
|
+
provider: "FLOOR",
|
|
91
|
+
description: "Buy a FLOOR launch token",
|
|
92
|
+
calls: [
|
|
93
|
+
call(SQUID_CALL.FullTokenBalance, quote, 0n, bytesToHex(encodeCall("transfer(address,uint256)", [amm, SQUID_FULL])), bytesToHex(encodeAbi(["address", "uint256"], [quote, 1n])), SQUID_GAS.transfer),
|
|
94
|
+
call(SQUID_CALL.Default, amm, 0n, bytesToHex(encodeCall("buyFromBalance(uint256,uint256,address,address,uint256)", [p.launchId, p.minTokensOut, user, user, p.deadline])), "0x", SQUID_GAS.buy),
|
|
95
|
+
],
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function buyHookNative(p: Common & { zap: string; swapData: string; minQuoteIn: bigint; minTokensOut: bigint }): SquidHook {
|
|
100
|
+
checkCommon(p);
|
|
101
|
+
const user = checkUser(p);
|
|
102
|
+
if (p.minQuoteIn <= 0n || p.minTokensOut <= 0n) throw new SquidHookError("NO_MINIMUM", "minQuoteIn and minTokensOut must be > 0");
|
|
103
|
+
const zap = lc(p.zap, "zap");
|
|
104
|
+
return {
|
|
105
|
+
provider: "FLOOR",
|
|
106
|
+
description: "Buy a FLOOR launch token with the native coin",
|
|
107
|
+
calls: [
|
|
108
|
+
call(SQUID_CALL.FullNativeBalance, zap, 0n, bytesToHex(encodeCall("buyWithEth(uint256,bytes,uint256,uint256,address,uint256)", [p.launchId, p.swapData, p.minQuoteIn, p.minTokensOut, user, p.deadline])), "0x", SQUID_GAS.zapBuy),
|
|
109
|
+
call(SQUID_CALL.FullNativeBalance, user, 0n, "0x", "0x", SQUID_GAS.passOn),
|
|
110
|
+
],
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function sellHook(p: Common & { token: string; tokensIn: bigint; minQuoteOut: bigint; proceedsTo?: string }): SquidHook {
|
|
115
|
+
checkCommon(p);
|
|
116
|
+
lc(p.user, "user");
|
|
117
|
+
if (p.tokensIn <= 0n || p.tokensIn % SQUID_TOKEN_SCALE !== 0n) throw new SquidHookError("NOT_WHOLE_UNITS", `${p.tokensIn} is not a positive multiple of ${SQUID_TOKEN_SCALE}`);
|
|
118
|
+
if (p.minQuoteOut <= 0n) throw new SquidHookError("NO_MINIMUM", "minQuoteOut must be > 0");
|
|
119
|
+
const to = lc(p.proceedsTo ?? p.multicall, "proceedsTo");
|
|
120
|
+
if (to === ZERO) throw new SquidHookError("BAD_RECIPIENT", "proceedsTo");
|
|
121
|
+
const token = lc(p.token, "token");
|
|
122
|
+
const amm = lc(p.floorAmm, "floorAmm");
|
|
123
|
+
return {
|
|
124
|
+
provider: "FLOOR",
|
|
125
|
+
description: "Sell a FLOOR launch token",
|
|
126
|
+
calls: [
|
|
127
|
+
call(SQUID_CALL.Default, token, 0n, bytesToHex(encodeCall("transfer(address,uint256)", [amm, p.tokensIn])), "0x", SQUID_GAS.transfer),
|
|
128
|
+
call(SQUID_CALL.Default, amm, 0n, bytesToHex(encodeCall("sellFromBalance(uint256,uint256,address,uint256)", [p.launchId, p.minQuoteOut, to, p.deadline])), "0x", SQUID_GAS.sell),
|
|
129
|
+
],
|
|
130
|
+
fundToken: token,
|
|
131
|
+
fundAmount: p.tokensIn.toString(),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function encodeMulticallRun(calls: readonly SquidHookCall[]): string {
|
|
136
|
+
const tuples = calls.map((c) => [BigInt(c.callType), c.target, BigInt(c.value), c.callData, c.payload]);
|
|
137
|
+
return bytesToHex(encodeCall("run((uint8,address,uint256,bytes,bytes)[])", [tuples]));
|
|
138
|
+
}
|
package/src/index.ts
CHANGED
package/src/indexer/client.ts
CHANGED
|
@@ -50,6 +50,7 @@ export interface RouteArgs {
|
|
|
50
50
|
roles: W;
|
|
51
51
|
traderBoard: { window?: TraderWindow; limit?: number } | void;
|
|
52
52
|
launcherBoard: { limit?: number } | void;
|
|
53
|
+
tokenHolders: { token: string; limit?: number; offset?: number };
|
|
53
54
|
dexAsset: { id: string };
|
|
54
55
|
dexSummary: { id: string };
|
|
55
56
|
dexPair: { id: string };
|
|
@@ -104,6 +105,7 @@ export const routePath: { [N in RouteName]: (a: RouteArgs[N]) => string } = {
|
|
|
104
105
|
roles: (a) => indexerPath.roles(a.wallet),
|
|
105
106
|
traderBoard: (a) => indexerPath.traderBoard(a ?? {}),
|
|
106
107
|
launcherBoard: (a) => indexerPath.launcherBoard(a ?? {}),
|
|
108
|
+
tokenHolders: (a) => `/floor-amm/holders/${encodeURIComponent(need(a.token, "token"))}${query({ limit: a.limit, offset: a.offset })}`,
|
|
107
109
|
dexAsset: (a) => `/v2/dex/asset${query({ id: need(a.id, "id") })}`,
|
|
108
110
|
dexSummary: (a) => `/v2/dex/summary${query({ id: need(a.id, "id") })}`,
|
|
109
111
|
dexPair: (a) => `/v2/dex/pair${query({ id: need(a.id, "id") })}`,
|
package/src/indexer/contract.ts
CHANGED
|
@@ -83,7 +83,7 @@ export type Pagination =
|
|
|
83
83
|
|
|
84
84
|
| { readonly kind: "range"; readonly from: string; readonly to: string; readonly span?: { readonly interval: string; readonly max: number } };
|
|
85
85
|
|
|
86
|
-
export type PathParam = "launch" | "wallet";
|
|
86
|
+
export type PathParam = "launch" | "wallet" | "token";
|
|
87
87
|
|
|
88
88
|
export interface RouteContract<T = unknown> {
|
|
89
89
|
readonly pattern: string;
|
|
@@ -116,7 +116,7 @@ const WALLET_ERR = [...GATED, "bad_query"] as const;
|
|
|
116
116
|
type Spec<T> = Omit<RouteContract<T>, "aliases" | "mount" | "params" | "query" | "page" | "errors" | "gated" | "units" | "audience"> & Partial<RouteContract<T>>;
|
|
117
117
|
|
|
118
118
|
function site<T>(s: Spec<T> & { v2?: boolean }): RouteContract<T> {
|
|
119
|
-
const params = [...s.pattern.matchAll(/<(launch|wallet)>/g)].map((m) => m[1] as PathParam);
|
|
119
|
+
const params = [...s.pattern.matchAll(/<(launch|wallet|token)>/g)].map((m) => m[1] as PathParam);
|
|
120
120
|
const { v2, ...rest } = s;
|
|
121
121
|
const aliases = s.aliases ?? (v2 ? [s.pattern.replace(/^\/floor-amm\//, "/floor-amm/v2/")] : []);
|
|
122
122
|
return { mount: "chain", query: {}, page: NONE, errors: GATED, gated: true, units: "site", audience: "site", ...rest, params, aliases };
|
|
@@ -255,6 +255,15 @@ export const INDEXER_CONTRACT = {
|
|
|
255
255
|
traderBoard: site({ pattern: "/floor-amm/leaderboards/traders", v2: true, query: { window: WINDOW, limit: LIMIT(100, 500) }, page: limit(100, 500), errors: [...GATED, "bad_query"], body: B.TRADER_BOARD }),
|
|
256
256
|
launcherBoard: site({ pattern: "/floor-amm/leaderboards/launchers", v2: true, query: { limit: LIMIT(100, 500) }, page: limit(100, 500), errors: [...GATED, "bad_query"], body: B.LAUNCHER_BOARD }),
|
|
257
257
|
|
|
258
|
+
tokenHolders: partner({
|
|
259
|
+
pattern: "/floor-amm/holders/<token>",
|
|
260
|
+
aliases: ["/holders/<token>"],
|
|
261
|
+
params: ["token"],
|
|
262
|
+
query: { limit: LIMIT(100, 500), offset: { kind: "int", doc: "rows skipped", min: 0, default: 0 } },
|
|
263
|
+
page: { kind: "offset", limit: { default: 100, max: 500 }, total: "total" },
|
|
264
|
+
errors: [...GATED, "bad_query", "not_found"],
|
|
265
|
+
body: P.TOKEN_HOLDERS,
|
|
266
|
+
}),
|
|
258
267
|
dexAsset: partner({ pattern: "/v2/dex/asset", aliases: ["/asset"], query: { id: { kind: "string", doc: "a launch's token, or a quote", required: true } }, errors: [...GATED, "bad_query", "not_found", "not_indexed"], body: P.DEX_ASSET }),
|
|
259
268
|
dexSummary: partner({ pattern: "/v2/dex/summary", aliases: ["/summary"], query: { id: { kind: "string", doc: "the pair id", required: true } }, errors: [...GATED, "bad_query", "not_found"], body: P.DEX_SUMMARY }),
|
|
260
269
|
dexPair: partner({ pattern: "/v2/dex/pair", aliases: ["/pair"], query: { id: { kind: "string", doc: "the pair id", required: true } }, errors: [...GATED, "unknown_launch"], body: P.DEX_PAIR }),
|
|
@@ -297,7 +306,7 @@ export function matchRoute(path: string): { name: RouteName; params: Partial<Rec
|
|
|
297
306
|
const c: RouteContract = INDEXER_CONTRACT[name];
|
|
298
307
|
for (const pat of [c.pattern, ...c.aliases]) {
|
|
299
308
|
const keys: PathParam[] = [];
|
|
300
|
-
const re = new RegExp(`^${pat.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/<(launch|wallet)>/g, (_, k: PathParam) => (keys.push(k), "([^/]+)"))}$`);
|
|
309
|
+
const re = new RegExp(`^${pat.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/<(launch|wallet|token)>/g, (_, k: PathParam) => (keys.push(k), "([^/]+)"))}$`);
|
|
301
310
|
const m = re.exec(p);
|
|
302
311
|
if (m === null) continue;
|
|
303
312
|
const params: Partial<Record<PathParam, string>> = {};
|
package/src/indexer/partners.ts
CHANGED
|
@@ -21,6 +21,9 @@ export const DEX_ASSET = object({
|
|
|
21
21
|
});
|
|
22
22
|
export type DexAsset = Infer<typeof DEX_ASSET>;
|
|
23
23
|
|
|
24
|
+
export const TOKEN_HOLDERS = object({ total: int, holders: array(object({ address: str, balance: big })) });
|
|
25
|
+
export type TokenHolders = Infer<typeof TOKEN_HOLDERS>;
|
|
26
|
+
|
|
24
27
|
export const DEX_SUMMARY = object({
|
|
25
28
|
pair: str,
|
|
26
29
|
base: str,
|
|
@@ -69,6 +72,9 @@ export const CG_TICKERS = array(object({
|
|
|
69
72
|
low: nullable(decimal),
|
|
70
73
|
liquidity_in_usd: nullable(decimal),
|
|
71
74
|
liquidity_in_quote: big,
|
|
75
|
+
|
|
76
|
+
depthUp2: nullable(decimal),
|
|
77
|
+
depthDown2: nullable(decimal),
|
|
72
78
|
}));
|
|
73
79
|
export type CgTickers = Infer<typeof CG_TICKERS>;
|
|
74
80
|
|