@whetstone-research/doppler-sdk 0.0.1-alpha.9 → 0.0.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/LICENSE +21 -0
- package/README.md +726 -25
- package/dist/DopplerSDK.d.mts +45 -7
- package/dist/DopplerSDK.d.ts +45 -7
- package/dist/DopplerSDK.js +35 -12
- package/dist/DopplerSDK.mjs +34 -11
- package/dist/abis/bytecodes.d.mts +3 -2
- package/dist/abis/bytecodes.d.ts +3 -2
- package/dist/abis/bytecodes.js +9 -6
- package/dist/abis/bytecodes.mjs +1 -2
- package/dist/abis/index.d.mts +1507 -129
- package/dist/abis/index.d.ts +1507 -129
- package/dist/abis/index.js +43 -20
- package/dist/abis/index.mjs +2 -3
- package/dist/addresses.d.mts +16 -3
- package/dist/addresses.d.ts +16 -3
- package/dist/addresses.js +13 -5
- package/dist/addresses.mjs +2 -2
- package/dist/builders/DynamicAuctionBuilder.d.mts +119 -0
- package/dist/builders/DynamicAuctionBuilder.d.ts +119 -0
- package/dist/builders/DynamicAuctionBuilder.js +29 -0
- package/dist/builders/DynamicAuctionBuilder.js.map +1 -0
- package/dist/builders/DynamicAuctionBuilder.mjs +20 -0
- package/dist/builders/DynamicAuctionBuilder.mjs.map +1 -0
- package/dist/builders/MulticurveBuilder.d.mts +132 -0
- package/dist/builders/MulticurveBuilder.d.ts +132 -0
- package/dist/builders/MulticurveBuilder.js +29 -0
- package/dist/builders/MulticurveBuilder.js.map +1 -0
- package/dist/builders/MulticurveBuilder.mjs +20 -0
- package/dist/builders/MulticurveBuilder.mjs.map +1 -0
- package/dist/builders/StaticAuctionBuilder.d.mts +124 -0
- package/dist/builders/StaticAuctionBuilder.d.ts +124 -0
- package/dist/builders/StaticAuctionBuilder.js +29 -0
- package/dist/builders/StaticAuctionBuilder.js.map +1 -0
- package/dist/builders/StaticAuctionBuilder.mjs +20 -0
- package/dist/builders/StaticAuctionBuilder.mjs.map +1 -0
- package/dist/builders/index.d.mts +8 -0
- package/dist/builders/index.d.ts +8 -0
- package/dist/builders/index.js +56 -0
- package/dist/builders/index.js.map +1 -0
- package/dist/builders/index.mjs +23 -0
- package/dist/builders/index.mjs.map +1 -0
- package/dist/builders/shared.d.mts +116 -0
- package/dist/builders/shared.d.ts +116 -0
- package/dist/builders/shared.js +39 -0
- package/dist/builders/shared.js.map +1 -0
- package/dist/builders/shared.mjs +18 -0
- package/dist/builders/shared.mjs.map +1 -0
- package/dist/builders.d.mts +8 -131
- package/dist/builders.d.ts +8 -131
- package/dist/builders.js +44 -5
- package/dist/builders.mjs +22 -3
- package/dist/chunk-3PNCB4W5.js +4 -0
- package/dist/{chunk-KRN3ROUE.js.map → chunk-3PNCB4W5.js.map} +1 -1
- package/dist/chunk-3RK7LRAA.js +282 -0
- package/dist/chunk-3RK7LRAA.js.map +1 -0
- package/dist/chunk-4HM3ERBU.js +13 -0
- package/dist/chunk-4HM3ERBU.js.map +1 -0
- package/dist/{chunk-7W72MFJO.mjs → chunk-4TROGENW.mjs} +5 -4
- package/dist/chunk-4TROGENW.mjs.map +1 -0
- package/dist/chunk-5TL5V6UX.mjs +3 -0
- package/dist/{chunk-AZLFJNTG.mjs.map → chunk-5TL5V6UX.mjs.map} +1 -1
- package/dist/chunk-64AWG57M.mjs +192 -0
- package/dist/chunk-64AWG57M.mjs.map +1 -0
- package/dist/chunk-6KWCHTK3.js +166 -0
- package/dist/chunk-6KWCHTK3.js.map +1 -0
- package/dist/chunk-6OOWOPCX.js +1708 -0
- package/dist/chunk-6OOWOPCX.js.map +1 -0
- package/dist/chunk-7BBRPWQJ.js +257 -0
- package/dist/chunk-7BBRPWQJ.js.map +1 -0
- package/dist/{chunk-AQPINKEW.mjs → chunk-AKSEBAR7.mjs} +29 -19
- package/dist/chunk-AKSEBAR7.mjs.map +1 -0
- package/dist/chunk-AS64GWBX.js +204 -0
- package/dist/chunk-AS64GWBX.js.map +1 -0
- package/dist/chunk-AULFBXM5.mjs +331 -0
- package/dist/chunk-AULFBXM5.mjs.map +1 -0
- package/dist/chunk-AW3WR2D3.mjs +238 -0
- package/dist/chunk-AW3WR2D3.mjs.map +1 -0
- package/dist/chunk-BIQQ53O2.js +45 -0
- package/dist/chunk-BIQQ53O2.js.map +1 -0
- package/dist/chunk-C6MPV3CY.js +260 -0
- package/dist/chunk-C6MPV3CY.js.map +1 -0
- package/dist/{chunk-AYPP5JEQ.mjs → chunk-CLEQO6GU.mjs} +5 -5
- package/dist/chunk-CLEQO6GU.mjs.map +1 -0
- package/dist/chunk-CVHPLURA.js +147 -0
- package/dist/chunk-CVHPLURA.js.map +1 -0
- package/dist/chunk-D2RBCFNW.mjs +130 -0
- package/dist/chunk-D2RBCFNW.mjs.map +1 -0
- package/dist/chunk-ECD4FV3A.mjs +11 -0
- package/dist/chunk-ECD4FV3A.mjs.map +1 -0
- package/dist/chunk-EDJBZPMW.mjs +255 -0
- package/dist/chunk-EDJBZPMW.mjs.map +1 -0
- package/dist/chunk-FPAI4QYW.mjs +145 -0
- package/dist/chunk-FPAI4QYW.mjs.map +1 -0
- package/dist/chunk-HM25ZMO3.js +18 -0
- package/dist/chunk-HM25ZMO3.js.map +1 -0
- package/dist/chunk-IHC6UYKK.js +4 -0
- package/dist/{chunk-DRBRT57F.js.map → chunk-IHC6UYKK.js.map} +1 -1
- package/dist/{chunk-AXA7YT2G.mjs → chunk-J5BFFL3X.mjs} +87 -47
- package/dist/chunk-J5BFFL3X.mjs.map +1 -0
- package/dist/chunk-JIKAD4YL.js +4 -0
- package/dist/{chunk-KEXKKQVW.js.map → chunk-JIKAD4YL.js.map} +1 -1
- package/dist/{chunk-EFAPDN4J.js → chunk-JWEXGALU.js} +730 -33
- package/dist/chunk-JWEXGALU.js.map +1 -0
- package/dist/{chunk-4K5GBNQV.mjs → chunk-KDT76YQE.mjs} +52 -13
- package/dist/chunk-KDT76YQE.mjs.map +1 -0
- package/dist/chunk-LMQLMMEX.js +317 -0
- package/dist/chunk-LMQLMMEX.js.map +1 -0
- package/dist/{chunk-TOMVBPNZ.js → chunk-LS4TK6SX.js} +9 -4
- package/dist/chunk-LS4TK6SX.js.map +1 -0
- package/dist/chunk-M4WMHD3X.mjs +40 -0
- package/dist/chunk-M4WMHD3X.mjs.map +1 -0
- package/dist/chunk-MCOK3UFR.mjs +280 -0
- package/dist/chunk-MCOK3UFR.mjs.map +1 -0
- package/dist/chunk-MGQSQCFG.js +176 -0
- package/dist/chunk-MGQSQCFG.js.map +1 -0
- package/dist/chunk-MKE3BUL3.mjs +3 -0
- package/dist/{chunk-CYDWEPFL.mjs.map → chunk-MKE3BUL3.mjs.map} +1 -1
- package/dist/chunk-MNJ5OYPE.mjs +17 -0
- package/dist/chunk-MNJ5OYPE.mjs.map +1 -0
- package/dist/chunk-MNXD45J7.mjs +164 -0
- package/dist/chunk-MNXD45J7.mjs.map +1 -0
- package/dist/chunk-NGDPQC5E.js +333 -0
- package/dist/chunk-NGDPQC5E.js.map +1 -0
- package/dist/chunk-NNNCVFOH.mjs +16 -0
- package/dist/chunk-NNNCVFOH.mjs.map +1 -0
- package/dist/chunk-NZ4BJ2IC.mjs +315 -0
- package/dist/chunk-NZ4BJ2IC.mjs.map +1 -0
- package/dist/chunk-OKNM7ODQ.js +29 -0
- package/dist/chunk-OKNM7ODQ.js.map +1 -0
- package/dist/{chunk-DCFHANLR.mjs → chunk-OTG75GVH.mjs} +725 -34
- package/dist/chunk-OTG75GVH.mjs.map +1 -0
- package/dist/chunk-OZ6DGBRL.mjs +25 -0
- package/dist/chunk-OZ6DGBRL.mjs.map +1 -0
- package/dist/chunk-P25HBGP5.mjs +3 -0
- package/dist/chunk-P25HBGP5.mjs.map +1 -0
- package/dist/{chunk-XG7K4R56.js → chunk-P7KLEPVI.js} +52 -12
- package/dist/chunk-P7KLEPVI.js.map +1 -0
- package/dist/{chunk-OPKQMN46.mjs → chunk-PAPXGPJB.mjs} +9 -4
- package/dist/chunk-PAPXGPJB.mjs.map +1 -0
- package/dist/chunk-PCNXJAU5.js +19 -0
- package/dist/chunk-PCNXJAU5.js.map +1 -0
- package/dist/{chunk-PMIJTXU6.js → chunk-PD6HWEMG.js} +40 -30
- package/dist/chunk-PD6HWEMG.js.map +1 -0
- package/dist/{chunk-ER42VG7H.js → chunk-PH2KXREH.js} +20 -3
- package/dist/chunk-PH2KXREH.js.map +1 -0
- package/dist/chunk-Q5ERW5ZW.mjs +107 -0
- package/dist/chunk-Q5ERW5ZW.mjs.map +1 -0
- package/dist/chunk-Q7YNBSVH.js +28 -0
- package/dist/chunk-Q7YNBSVH.js.map +1 -0
- package/dist/{chunk-T644D54P.mjs → chunk-QKO2FZGN.mjs} +16 -4
- package/dist/chunk-QKO2FZGN.mjs.map +1 -0
- package/dist/{chunk-CIRZKWLL.js → chunk-RVFSRYI5.js} +5 -3
- package/dist/chunk-RVFSRYI5.js.map +1 -0
- package/dist/{chunk-KPBCG4X2.js → chunk-RW37KJ77.js} +11 -11
- package/dist/chunk-RW37KJ77.js.map +1 -0
- package/dist/chunk-SD7BHT2F.mjs +3 -0
- package/dist/chunk-SD7BHT2F.mjs.map +1 -0
- package/dist/chunk-SP5M57BG.mjs +258 -0
- package/dist/chunk-SP5M57BG.mjs.map +1 -0
- package/dist/chunk-TKSHYEYA.mjs +1706 -0
- package/dist/chunk-TKSHYEYA.mjs.map +1 -0
- package/dist/chunk-WTS75RUC.js +4 -0
- package/dist/chunk-WTS75RUC.js.map +1 -0
- package/dist/{chunk-EIRVZJTT.js → chunk-XRPIGMA2.js} +108 -68
- package/dist/chunk-XRPIGMA2.js.map +1 -0
- package/dist/chunk-XTKSM4QE.js +132 -0
- package/dist/chunk-XTKSM4QE.js.map +1 -0
- package/dist/chunk-XUE3CIJ5.mjs +174 -0
- package/dist/chunk-XUE3CIJ5.mjs.map +1 -0
- package/dist/chunk-YYUOLM6U.js +244 -0
- package/dist/chunk-YYUOLM6U.js.map +1 -0
- package/dist/chunk-ZH44DHVR.mjs +26 -0
- package/dist/chunk-ZH44DHVR.mjs.map +1 -0
- package/dist/chunk-ZPHOOG72.js +112 -0
- package/dist/chunk-ZPHOOG72.js.map +1 -0
- package/dist/constants.d.mts +7 -2
- package/dist/constants.d.ts +7 -2
- package/dist/constants.js +57 -38
- package/dist/constants.mjs +1 -2
- package/dist/deployments.generated.d.mts +2 -0
- package/dist/deployments.generated.d.ts +2 -0
- package/dist/deployments.generated.js +12 -0
- package/dist/deployments.generated.js.map +1 -0
- package/dist/deployments.generated.mjs +3 -0
- package/dist/deployments.generated.mjs.map +1 -0
- package/dist/entities/DopplerFactory.d.mts +139 -11
- package/dist/entities/DopplerFactory.d.ts +139 -11
- package/dist/entities/DopplerFactory.js +17 -7
- package/dist/entities/DopplerFactory.mjs +16 -6
- package/dist/entities/auction/DynamicAuction.d.mts +19 -4
- package/dist/entities/auction/DynamicAuction.d.ts +19 -4
- package/dist/entities/auction/DynamicAuction.js +6 -6
- package/dist/entities/auction/DynamicAuction.mjs +5 -5
- package/dist/entities/auction/MulticurvePool.d.mts +55 -0
- package/dist/entities/auction/MulticurvePool.d.ts +55 -0
- package/dist/entities/auction/MulticurvePool.js +18 -0
- package/dist/entities/auction/MulticurvePool.js.map +1 -0
- package/dist/entities/auction/MulticurvePool.mjs +9 -0
- package/dist/entities/auction/MulticurvePool.mjs.map +1 -0
- package/dist/entities/auction/StaticAuction.d.mts +6 -3
- package/dist/entities/auction/StaticAuction.d.ts +6 -3
- package/dist/entities/auction/StaticAuction.js +6 -6
- package/dist/entities/auction/StaticAuction.mjs +5 -5
- package/dist/entities/auction/index.d.mts +3 -0
- package/dist/entities/auction/index.d.ts +3 -0
- package/dist/entities/auction/index.js +16 -9
- package/dist/entities/auction/index.mjs +10 -7
- package/dist/entities/quoter/Quoter.d.mts +44 -2
- package/dist/entities/quoter/Quoter.d.ts +44 -2
- package/dist/entities/quoter/Quoter.js +6 -6
- package/dist/entities/quoter/Quoter.mjs +5 -5
- package/dist/entities/quoter/index.d.mts +3 -0
- package/dist/entities/quoter/index.d.ts +3 -0
- package/dist/entities/quoter/index.js +6 -6
- package/dist/entities/quoter/index.mjs +5 -5
- package/dist/entities/token/derc20/Derc20.d.mts +33 -7
- package/dist/entities/token/derc20/Derc20.d.ts +33 -7
- package/dist/entities/token/derc20/Derc20.js +4 -5
- package/dist/entities/token/derc20/Derc20.mjs +3 -4
- package/dist/entities/token/derc20/index.d.mts +3 -0
- package/dist/entities/token/derc20/index.d.ts +3 -0
- package/dist/entities/token/derc20/index.js +4 -5
- package/dist/entities/token/derc20/index.mjs +3 -4
- package/dist/entities/token/eth/Eth.d.mts +7 -3
- package/dist/entities/token/eth/Eth.d.ts +7 -3
- package/dist/entities/token/eth/Eth.js +2 -3
- package/dist/entities/token/eth/Eth.mjs +1 -2
- package/dist/entities/token/eth/index.d.mts +3 -0
- package/dist/entities/token/eth/index.d.ts +3 -0
- package/dist/entities/token/eth/index.js +2 -3
- package/dist/entities/token/eth/index.mjs +1 -2
- package/dist/entities/token/index.d.mts +3 -0
- package/dist/entities/token/index.d.ts +3 -0
- package/dist/entities/token/index.js +6 -7
- package/dist/entities/token/index.mjs +4 -5
- package/dist/index.d.mts +18 -6
- package/dist/index.d.ts +18 -6
- package/dist/index.js +305 -140
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -19
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.mts +260 -22
- package/dist/types.d.ts +260 -22
- package/dist/types.js +12 -3
- package/dist/types.mjs +3 -2
- package/dist/utils/airlock.d.mts +11 -0
- package/dist/utils/airlock.d.ts +11 -0
- package/dist/utils/airlock.js +26 -0
- package/dist/utils/airlock.js.map +1 -0
- package/dist/utils/airlock.mjs +5 -0
- package/dist/utils/airlock.mjs.map +1 -0
- package/dist/utils/balanceDelta.d.mts +10 -0
- package/dist/utils/balanceDelta.d.ts +10 -0
- package/dist/utils/balanceDelta.js +12 -0
- package/dist/utils/balanceDelta.js.map +1 -0
- package/dist/utils/balanceDelta.mjs +3 -0
- package/dist/utils/balanceDelta.mjs.map +1 -0
- package/dist/utils/computeOptimalGamma.d.mts +7 -0
- package/dist/utils/computeOptimalGamma.d.ts +7 -0
- package/dist/utils/computeOptimalGamma.js +12 -0
- package/dist/utils/computeOptimalGamma.js.map +1 -0
- package/dist/utils/computeOptimalGamma.mjs +3 -0
- package/dist/utils/computeOptimalGamma.mjs.map +1 -0
- package/dist/utils/index.d.mts +11 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.js +114 -24
- package/dist/utils/index.mjs +14 -4
- package/dist/utils/isToken0Expected.d.mts +13 -0
- package/dist/utils/isToken0Expected.d.ts +13 -0
- package/dist/utils/isToken0Expected.js +12 -0
- package/dist/utils/isToken0Expected.js.map +1 -0
- package/dist/utils/isToken0Expected.mjs +3 -0
- package/dist/utils/isToken0Expected.mjs.map +1 -0
- package/dist/utils/marketCapHelpers.d.mts +309 -0
- package/dist/utils/marketCapHelpers.d.ts +309 -0
- package/dist/utils/marketCapHelpers.js +54 -0
- package/dist/utils/marketCapHelpers.js.map +1 -0
- package/dist/utils/marketCapHelpers.mjs +5 -0
- package/dist/utils/marketCapHelpers.mjs.map +1 -0
- package/dist/utils/poolKey.d.mts +17 -0
- package/dist/utils/poolKey.d.ts +17 -0
- package/dist/utils/poolKey.js +12 -0
- package/dist/utils/poolKey.js.map +1 -0
- package/dist/utils/poolKey.mjs +3 -0
- package/dist/utils/poolKey.mjs.map +1 -0
- package/dist/utils/priceHelpers.d.mts +3 -3
- package/dist/utils/priceHelpers.d.ts +3 -3
- package/dist/utils/priceHelpers.js +10 -11
- package/dist/utils/priceHelpers.mjs +2 -3
- package/dist/utils/tickMath.d.mts +8 -1
- package/dist/utils/tickMath.d.ts +8 -1
- package/dist/utils/tickMath.js +17 -14
- package/dist/utils/tickMath.mjs +1 -2
- package/dist/utils/tokenAddressMiner.d.mts +30 -0
- package/dist/utils/tokenAddressMiner.d.ts +30 -0
- package/dist/utils/tokenAddressMiner.js +14 -0
- package/dist/utils/tokenAddressMiner.js.map +1 -0
- package/dist/utils/tokenAddressMiner.mjs +5 -0
- package/dist/utils/tokenAddressMiner.mjs.map +1 -0
- package/package.json +14 -11
- package/dist/__tests__/mocks/addresses.d.mts +0 -46
- package/dist/__tests__/mocks/addresses.d.ts +0 -46
- package/dist/__tests__/mocks/addresses.js +0 -53
- package/dist/__tests__/mocks/addresses.js.map +0 -1
- package/dist/__tests__/mocks/addresses.mjs +0 -44
- package/dist/__tests__/mocks/addresses.mjs.map +0 -1
- package/dist/__tests__/mocks/clients.d.mts +0 -22
- package/dist/__tests__/mocks/clients.d.ts +0 -22
- package/dist/__tests__/mocks/clients.js +0 -17036
- package/dist/__tests__/mocks/clients.js.map +0 -1
- package/dist/__tests__/mocks/clients.mjs +0 -17032
- package/dist/__tests__/mocks/clients.mjs.map +0 -1
- package/dist/chunk-2N5JZSZ4.js +0 -14
- package/dist/chunk-2N5JZSZ4.js.map +0 -1
- package/dist/chunk-4K5GBNQV.mjs.map +0 -1
- package/dist/chunk-7F5IXZLH.js +0 -308
- package/dist/chunk-7F5IXZLH.js.map +0 -1
- package/dist/chunk-7W72MFJO.mjs.map +0 -1
- package/dist/chunk-AQPINKEW.mjs.map +0 -1
- package/dist/chunk-AXA7YT2G.mjs.map +0 -1
- package/dist/chunk-AYPP5JEQ.mjs.map +0 -1
- package/dist/chunk-AZLFJNTG.mjs +0 -3
- package/dist/chunk-CIRZKWLL.js.map +0 -1
- package/dist/chunk-CIVGL27M.mjs +0 -160
- package/dist/chunk-CIVGL27M.mjs.map +0 -1
- package/dist/chunk-CYDWEPFL.mjs +0 -3
- package/dist/chunk-DCFHANLR.mjs.map +0 -1
- package/dist/chunk-DRBRT57F.js +0 -4
- package/dist/chunk-EFAPDN4J.js.map +0 -1
- package/dist/chunk-EIRVZJTT.js.map +0 -1
- package/dist/chunk-ER42VG7H.js.map +0 -1
- package/dist/chunk-FPGJKJIR.js +0 -872
- package/dist/chunk-FPGJKJIR.js.map +0 -1
- package/dist/chunk-HRFHDSNE.js +0 -180
- package/dist/chunk-HRFHDSNE.js.map +0 -1
- package/dist/chunk-IHBIBFZK.mjs +0 -12
- package/dist/chunk-IHBIBFZK.mjs.map +0 -1
- package/dist/chunk-JIDZBQ7R.mjs +0 -870
- package/dist/chunk-JIDZBQ7R.mjs.map +0 -1
- package/dist/chunk-KEXKKQVW.js +0 -42
- package/dist/chunk-KFD6U3LQ.mjs +0 -305
- package/dist/chunk-KFD6U3LQ.mjs.map +0 -1
- package/dist/chunk-KPBCG4X2.js.map +0 -1
- package/dist/chunk-KRN3ROUE.js +0 -4
- package/dist/chunk-KT7U37XS.mjs +0 -207
- package/dist/chunk-KT7U37XS.mjs.map +0 -1
- package/dist/chunk-LOROXNH3.mjs +0 -37
- package/dist/chunk-LOROXNH3.mjs.map +0 -1
- package/dist/chunk-LZO67TYV.mjs +0 -176
- package/dist/chunk-LZO67TYV.mjs.map +0 -1
- package/dist/chunk-MZ2UBC4M.mjs +0 -80
- package/dist/chunk-MZ2UBC4M.mjs.map +0 -1
- package/dist/chunk-OPKQMN46.mjs.map +0 -1
- package/dist/chunk-PMIJTXU6.js.map +0 -1
- package/dist/chunk-T644D54P.mjs.map +0 -1
- package/dist/chunk-TOMVBPNZ.js.map +0 -1
- package/dist/chunk-UHT4QLL7.js +0 -162
- package/dist/chunk-UHT4QLL7.js.map +0 -1
- package/dist/chunk-XG7K4R56.js.map +0 -1
- package/dist/chunk-YNP2HGJZ.js +0 -82
- package/dist/chunk-YNP2HGJZ.js.map +0 -1
- package/dist/chunk-ZAIP54LX.js +0 -209
- package/dist/chunk-ZAIP54LX.js.map +0 -1
- package/dist/magic-string.es-CBLXTCZP.js +0 -1304
- package/dist/magic-string.es-CBLXTCZP.js.map +0 -1
- package/dist/magic-string.es-QHA47FSB.mjs +0 -1298
- package/dist/magic-string.es-QHA47FSB.mjs.map +0 -1
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkJWEXGALU_js = require('./chunk-JWEXGALU.js');
|
|
4
|
+
|
|
5
|
+
// src/entities/token/derc20/Derc20.ts
|
|
6
|
+
var Derc20 = class _Derc20 {
|
|
7
|
+
get rpc() {
|
|
8
|
+
return this.publicClient;
|
|
9
|
+
}
|
|
10
|
+
static splitSignature(signature) {
|
|
11
|
+
const sig = signature.toLowerCase();
|
|
12
|
+
const r = `0x${sig.slice(2, 66)}`;
|
|
13
|
+
const s = `0x${sig.slice(66, 130)}`;
|
|
14
|
+
let v = parseInt(sig.slice(130, 132), 16);
|
|
15
|
+
if (v < 27) v += 27;
|
|
16
|
+
return { v, r, s };
|
|
17
|
+
}
|
|
18
|
+
constructor(publicClient, walletClient, address) {
|
|
19
|
+
this.publicClient = publicClient;
|
|
20
|
+
this.walletClient = walletClient;
|
|
21
|
+
this.address = address;
|
|
22
|
+
}
|
|
23
|
+
/** Get the human-readable name of the token */
|
|
24
|
+
async getName() {
|
|
25
|
+
return await this.rpc.readContract({
|
|
26
|
+
address: this.address,
|
|
27
|
+
abi: chunkJWEXGALU_js.derc20Abi,
|
|
28
|
+
functionName: "name"
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/** Get the symbol/ticker of the token */
|
|
32
|
+
async getSymbol() {
|
|
33
|
+
return await this.rpc.readContract({
|
|
34
|
+
address: this.address,
|
|
35
|
+
abi: chunkJWEXGALU_js.derc20Abi,
|
|
36
|
+
functionName: "symbol"
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/** Get the number of decimals used for token divisions */
|
|
40
|
+
async getDecimals() {
|
|
41
|
+
return await this.rpc.readContract({
|
|
42
|
+
address: this.address,
|
|
43
|
+
abi: chunkJWEXGALU_js.derc20Abi,
|
|
44
|
+
functionName: "decimals"
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/** Get the token URI for the token */
|
|
48
|
+
async getTokenURI() {
|
|
49
|
+
return await this.rpc.readContract({
|
|
50
|
+
address: this.address,
|
|
51
|
+
abi: chunkJWEXGALU_js.derc20Abi,
|
|
52
|
+
functionName: "tokenURI"
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
// -------------------------
|
|
56
|
+
// Governance (Votes) reads
|
|
57
|
+
// -------------------------
|
|
58
|
+
/** Get the current delegate for an account */
|
|
59
|
+
async getDelegates(account) {
|
|
60
|
+
return await this.rpc.readContract({
|
|
61
|
+
address: this.address,
|
|
62
|
+
abi: chunkJWEXGALU_js.derc20Abi,
|
|
63
|
+
functionName: "delegates",
|
|
64
|
+
args: [account]
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/** Get current voting power for an account */
|
|
68
|
+
async getVotes(account) {
|
|
69
|
+
return await this.rpc.readContract({
|
|
70
|
+
address: this.address,
|
|
71
|
+
abi: chunkJWEXGALU_js.derc20Abi,
|
|
72
|
+
functionName: "getVotes",
|
|
73
|
+
args: [account]
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/** Get historical voting power at a given timepoint (block) */
|
|
77
|
+
async getPastVotes(account, timepoint) {
|
|
78
|
+
return await this.rpc.readContract({
|
|
79
|
+
address: this.address,
|
|
80
|
+
abi: chunkJWEXGALU_js.derc20Abi,
|
|
81
|
+
functionName: "getPastVotes",
|
|
82
|
+
args: [account, timepoint]
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get the allowance granted by an owner to a spender
|
|
87
|
+
* @param owner - The address that granted the allowance
|
|
88
|
+
* @param spender - The address that can spend the tokens
|
|
89
|
+
*/
|
|
90
|
+
async getAllowance(owner, spender) {
|
|
91
|
+
return await this.rpc.readContract({
|
|
92
|
+
address: this.address,
|
|
93
|
+
abi: chunkJWEXGALU_js.derc20Abi,
|
|
94
|
+
functionName: "allowance",
|
|
95
|
+
args: [owner, spender]
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Get the token balance of a specific account
|
|
100
|
+
* @param account - Address to check balance for
|
|
101
|
+
*/
|
|
102
|
+
async getBalanceOf(account) {
|
|
103
|
+
return await this.rpc.readContract({
|
|
104
|
+
address: this.address,
|
|
105
|
+
abi: chunkJWEXGALU_js.derc20Abi,
|
|
106
|
+
functionName: "balanceOf",
|
|
107
|
+
args: [account]
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/** Get the total supply of tokens in circulation */
|
|
111
|
+
async getTotalSupply() {
|
|
112
|
+
return await this.rpc.readContract({
|
|
113
|
+
address: this.address,
|
|
114
|
+
abi: chunkJWEXGALU_js.derc20Abi,
|
|
115
|
+
functionName: "totalSupply"
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/** Get the duration (in seconds) of the vesting period */
|
|
119
|
+
async getVestingDuration() {
|
|
120
|
+
return await this.rpc.readContract({
|
|
121
|
+
address: this.address,
|
|
122
|
+
abi: chunkJWEXGALU_js.derc20Abi,
|
|
123
|
+
functionName: "vestingDuration"
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/** Get the timestamp when vesting begins */
|
|
127
|
+
async getVestingStart() {
|
|
128
|
+
return await this.rpc.readContract({
|
|
129
|
+
address: this.address,
|
|
130
|
+
abi: chunkJWEXGALU_js.derc20Abi,
|
|
131
|
+
functionName: "vestingStart"
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/** Get the total amount of tokens allocated for vesting */
|
|
135
|
+
async getVestedTotalAmount() {
|
|
136
|
+
return await this.rpc.readContract({
|
|
137
|
+
address: this.address,
|
|
138
|
+
abi: chunkJWEXGALU_js.derc20Abi,
|
|
139
|
+
functionName: "vestedTotalAmount"
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
/** Get the amount of vested tokens available for a specific address */
|
|
143
|
+
async getAvailableVestedAmount(account) {
|
|
144
|
+
return await this.rpc.readContract({
|
|
145
|
+
address: this.address,
|
|
146
|
+
abi: chunkJWEXGALU_js.derc20Abi,
|
|
147
|
+
functionName: "computeAvailableVestedAmount",
|
|
148
|
+
args: [account]
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
/** Get the current annual mint rate in tokens per year */
|
|
152
|
+
async getYearlyMintRate() {
|
|
153
|
+
return await this.rpc.readContract({
|
|
154
|
+
address: this.address,
|
|
155
|
+
abi: chunkJWEXGALU_js.derc20Abi,
|
|
156
|
+
functionName: "yearlyMintRate"
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
/** Get the pool address for the token */
|
|
160
|
+
async getPool() {
|
|
161
|
+
return await this.rpc.readContract({
|
|
162
|
+
address: this.address,
|
|
163
|
+
abi: chunkJWEXGALU_js.derc20Abi,
|
|
164
|
+
functionName: "pool"
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/** Check if the liquidity pool is unlocked */
|
|
168
|
+
async getIsPoolUnlocked() {
|
|
169
|
+
return await this.rpc.readContract({
|
|
170
|
+
address: this.address,
|
|
171
|
+
abi: chunkJWEXGALU_js.derc20Abi,
|
|
172
|
+
functionName: "isPoolUnlocked"
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
/** Get the timestamp when token minting begins */
|
|
176
|
+
async getCurrentYearStart() {
|
|
177
|
+
return await this.rpc.readContract({
|
|
178
|
+
address: this.address,
|
|
179
|
+
abi: chunkJWEXGALU_js.derc20Abi,
|
|
180
|
+
functionName: "currentYearStart"
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
/** Get the timestamp of the last mint */
|
|
184
|
+
async getLastMintTimestamp() {
|
|
185
|
+
return await this.rpc.readContract({
|
|
186
|
+
address: this.address,
|
|
187
|
+
abi: chunkJWEXGALU_js.derc20Abi,
|
|
188
|
+
functionName: "lastMintTimestamp"
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Get detailed vesting information for a specific account
|
|
193
|
+
* @param account - Address to retrieve vesting data for
|
|
194
|
+
* @returns Object containing totalAmount and releasedAmount
|
|
195
|
+
*/
|
|
196
|
+
async getVestingData(account) {
|
|
197
|
+
const result = await this.rpc.readContract({
|
|
198
|
+
address: this.address,
|
|
199
|
+
abi: chunkJWEXGALU_js.derc20Abi,
|
|
200
|
+
functionName: "getVestingDataOf",
|
|
201
|
+
args: [account]
|
|
202
|
+
});
|
|
203
|
+
return {
|
|
204
|
+
totalAmount: result[0],
|
|
205
|
+
releasedAmount: result[1]
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
// Write methods (require wallet client)
|
|
209
|
+
/**
|
|
210
|
+
* Approve a spender to transfer tokens on behalf of the owner
|
|
211
|
+
* @param spender - Address that will be able to spend the tokens
|
|
212
|
+
* @param value - Amount of tokens to approve
|
|
213
|
+
* @returns Transaction hash
|
|
214
|
+
*/
|
|
215
|
+
async approve(spender, value, options) {
|
|
216
|
+
if (!this.walletClient) {
|
|
217
|
+
throw new Error("Wallet client required for write operations");
|
|
218
|
+
}
|
|
219
|
+
const { request } = await this.rpc.simulateContract({
|
|
220
|
+
address: this.address,
|
|
221
|
+
abi: chunkJWEXGALU_js.derc20Abi,
|
|
222
|
+
functionName: "approve",
|
|
223
|
+
args: [spender, value],
|
|
224
|
+
account: this.walletClient.account
|
|
225
|
+
});
|
|
226
|
+
return await this.walletClient.writeContract(options?.gas ? { ...request, gas: options.gas } : request);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Delegate governance votes to an address
|
|
230
|
+
*/
|
|
231
|
+
async delegate(delegatee, options) {
|
|
232
|
+
if (!this.walletClient) {
|
|
233
|
+
throw new Error("Wallet client required for write operations");
|
|
234
|
+
}
|
|
235
|
+
const { request } = await this.rpc.simulateContract({
|
|
236
|
+
address: this.address,
|
|
237
|
+
abi: chunkJWEXGALU_js.derc20Abi,
|
|
238
|
+
functionName: "delegate",
|
|
239
|
+
args: [delegatee],
|
|
240
|
+
account: this.walletClient.account
|
|
241
|
+
});
|
|
242
|
+
return await this.walletClient.writeContract(options?.gas ? { ...request, gas: options.gas } : request);
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Delegate governance votes using an EIP-712 signature (gasless path)
|
|
246
|
+
* Note: Caller signs typed data; a relayer or the caller submits the tx.
|
|
247
|
+
*/
|
|
248
|
+
async delegateBySig(delegatee, expiry, options) {
|
|
249
|
+
if (!this.walletClient) {
|
|
250
|
+
throw new Error("Wallet client required for write operations");
|
|
251
|
+
}
|
|
252
|
+
const acct = this.walletClient.account;
|
|
253
|
+
let accountAddress;
|
|
254
|
+
if (typeof acct === "string") {
|
|
255
|
+
accountAddress = acct;
|
|
256
|
+
} else if (acct && typeof acct === "object" && "address" in acct) {
|
|
257
|
+
accountAddress = acct.address;
|
|
258
|
+
} else {
|
|
259
|
+
throw new Error("Invalid wallet account");
|
|
260
|
+
}
|
|
261
|
+
const [nonce, name] = await Promise.all([
|
|
262
|
+
this.rpc.readContract({ address: this.address, abi: chunkJWEXGALU_js.derc20Abi, functionName: "nonces", args: [accountAddress] }),
|
|
263
|
+
this.getName()
|
|
264
|
+
]);
|
|
265
|
+
const chainId = this.rpc.chain?.id ?? await this.rpc.getChainId();
|
|
266
|
+
const domain = {
|
|
267
|
+
name,
|
|
268
|
+
version: "1",
|
|
269
|
+
chainId,
|
|
270
|
+
verifyingContract: this.address
|
|
271
|
+
};
|
|
272
|
+
const types = {
|
|
273
|
+
Delegation: [
|
|
274
|
+
{ name: "delegatee", type: "address" },
|
|
275
|
+
{ name: "nonce", type: "uint256" },
|
|
276
|
+
{ name: "expiry", type: "uint256" }
|
|
277
|
+
]
|
|
278
|
+
};
|
|
279
|
+
const message = { delegatee, nonce, expiry };
|
|
280
|
+
const signature = await this.walletClient.signTypedData({
|
|
281
|
+
domain,
|
|
282
|
+
types,
|
|
283
|
+
primaryType: "Delegation",
|
|
284
|
+
message,
|
|
285
|
+
account: accountAddress
|
|
286
|
+
});
|
|
287
|
+
const { v, r, s } = _Derc20.splitSignature(signature);
|
|
288
|
+
const { request } = await this.rpc.simulateContract({
|
|
289
|
+
address: this.address,
|
|
290
|
+
abi: chunkJWEXGALU_js.derc20Abi,
|
|
291
|
+
functionName: "delegateBySig",
|
|
292
|
+
args: [delegatee, nonce, expiry, v, r, s],
|
|
293
|
+
account: this.walletClient.account
|
|
294
|
+
});
|
|
295
|
+
return await this.walletClient.writeContract(options?.gas ? { ...request, gas: options.gas } : request);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Release all currently available vested tokens to the caller
|
|
299
|
+
*/
|
|
300
|
+
async release(options) {
|
|
301
|
+
if (!this.walletClient) {
|
|
302
|
+
throw new Error("Wallet client required for write operations");
|
|
303
|
+
}
|
|
304
|
+
const { request } = await this.rpc.simulateContract({
|
|
305
|
+
address: this.address,
|
|
306
|
+
abi: chunkJWEXGALU_js.derc20Abi,
|
|
307
|
+
functionName: "release",
|
|
308
|
+
args: [],
|
|
309
|
+
account: this.walletClient.account
|
|
310
|
+
});
|
|
311
|
+
return await this.walletClient.writeContract(options?.gas ? { ...request, gas: options.gas } : request);
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
exports.Derc20 = Derc20;
|
|
316
|
+
//# sourceMappingURL=chunk-LMQLMMEX.js.map
|
|
317
|
+
//# sourceMappingURL=chunk-LMQLMMEX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/entities/token/derc20/Derc20.ts"],"names":["derc20Abi"],"mappings":";;;;;AASO,IAAM,MAAA,GAAN,MAAM,OAAA,CAAO;AAAA,EAIlB,IAAY,GAAA,GAAoB;AAC9B,IAAA,OAAO,IAAA,CAAK,YAAA;AAAA,EACd;AAAA,EAEA,OAAe,eAAe,SAAA,EAA6E;AACzG,IAAA,MAAM,GAAA,GAAM,UAAU,WAAA,EAAY;AAClC,IAAA,MAAM,IAAK,CAAA,EAAA,EAAK,GAAA,CAAI,KAAA,CAAM,CAAA,EAAG,EAAE,CAAC,CAAA,CAAA;AAChC,IAAA,MAAM,IAAK,CAAA,EAAA,EAAK,GAAA,CAAI,KAAA,CAAM,EAAA,EAAI,GAAG,CAAC,CAAA,CAAA;AAClC,IAAA,IAAI,IAAI,Q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B,CAAA;AAED,IAAA,OAAO,MAAM,IAAA,CAAK,YAAA,CAAa,aAAA,CAAc,OAAA,EAAS,GAAA,GAAM,EAAE,GAAG,OAAA,EAAS,GAAA,EAAK,OAAA,CAAQ,GAAA,KAAQ,OAAO,CAAA;AAAA,EACxG;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,QAAQ,OAAA,EAAoD;AAChE,IAAA,IAAI,CAAC,KAAK,YAAA,EAAc;AACtB,MAAA,MAAM,IAAI,MAAM,6CAA6C,CAAA;AAAA,IAC/D;AAEA,IAAA,MAAM,EAAE,OAAA,EAAQ,GAAI,MAAM,IAAA,CAAK,IAAI,gBAAA,CAAiB;AAAA,MAClD,SAAS,IAAA,CAAK,OAAA;AAAA,MACd,GAAA,EAAKA,0BAAA;AAAA,MACL,YAAA,EAAc,SAAA;AAAA,MACd,MAAM,EAAC;AAAA,MACP,OAAA,EAAS,KAAK,YAAA,CAAa;AAAA,KAC5B,CAAA;AAED,IAAA,OAAO,MAAM,IAAA,CAAK,YAAA,CAAa,aAAA,CAAc,OAAA,EAAS,GAAA,GAAM,EAAE,GAAG,OAAA,EAAS,GAAA,EAAK,OAAA,CAAQ,GAAA,KAAQ,OAAO,CAAA;AAAA,EACxG;AACF","file":"chunk-LMQLMMEX.js","sourcesContent":["import { type Address, type WalletClient, type PublicClient } from 'viem'\nimport { derc20Abi } from '../../../abis'\nimport { SupportedPublicClient } from '@/types'\n\n/**\n * A class providing read and write access to a DERC20 token contract.\n * Enables querying standard ERC20 token properties along with custom vesting\n * and minting-related state information.\n */\nexport class Derc20 {\n private publicClient: SupportedPublicClient\n private walletClient?: WalletClient\n private address: Address\n private get rpc(): PublicClient {\n return this.publicClient as PublicClient\n }\n \n private static splitSignature(signature: `0x${string}`): { v: number; r: `0x${string}`; s: `0x${string}` } {\n const sig = signature.toLowerCase() as `0x${string}`\n const r = (`0x${sig.slice(2, 66)}`) as `0x${string}`\n const s = (`0x${sig.slice(66, 130)}`) as `0x${string}`\n let v = parseInt(sig.slice(130, 132), 16)\n if (v < 27) v += 27\n return { v, r, s }\n }\n \n constructor(publicClient: SupportedPublicClient, walletClient: WalletClient | undefined, address: Address) {\n this.publicClient = publicClient\n this.walletClient = walletClient\n this.address = address\n }\n \n /** Get the human-readable name of the token */\n async getName(): Promise<string> {\n return await this.rpc.readContract({\n address: this.address,\n abi: derc20Abi,\n functionName: 'name',\n })\n }\n \n /** Get the symbol/ticker of the token */\n async getSymbol(): Promise<string> {\n return await this.rpc.readContract({\n address: this.address,\n abi: derc20Abi,\n functionName: 'symbol',\n })\n }\n \n /** Get the number of decimals used for token divisions */\n async getDecimals(): Promise<number> {\n return await this.rpc.readContract({\n address: this.address,\n abi: derc20Abi,\n functionName: 'decimals',\n })\n }\n \n /** Get the token URI for the token */\n async getTokenURI(): Promise<string> {\n return await this.rpc.readContract({\n address: this.address,\n abi: derc20Abi,\n functionName: 'tokenURI',\n })\n }\n \n // -------------------------\n // Governance (Votes) reads\n // -------------------------\n \n /** Get the current delegate for an account */\n async getDelegates(account: Address): Promise<Address> {\n return await this.rpc.readContract({\n address: this.address,\n abi: derc20Abi,\n functionName: 'delegates',\n args: [account],\n })\n }\n \n /** Get current voting power for an account */\n async getVotes(account: Address): Promise<bigint> {\n return await this.rpc.readContract({\n address: this.address,\n abi: derc20Abi,\n functionName: 'getVotes',\n args: [account],\n })\n }\n \n /** Get historical voting power at a given timepoint (block) */\n async getPastVotes(account: Address, timepoint: bigint): Promise<bigint> {\n return await this.rpc.readContract({\n address: this.address,\n abi: derc20Abi,\n functionName: 'getPastVotes',\n args: [account, timepoint],\n })\n }\n \n /**\n * Get the allowance granted by an owner to a spender\n * @param owner - The address that granted the allowance\n * @param spender - The address that can spend the tokens\n */\n async getAllowance(owner: Address, spender: Address): Promise<bigint> {\n return await this.rpc.readContract({\n address: this.address,\n abi: derc20Abi,\n functionName: 'allowance',\n args: [owner, spender],\n })\n }\n \n /**\n * Get the token balance of a specific account\n * @param account - Address to check balance for\n */\n async getBalanceOf(account: Address): Promise<bigint> {\n return await this.rpc.readContract({\n address: this.address,\n abi: derc20Abi,\n functionName: 'balanceOf',\n args: [account],\n })\n }\n \n /** Get the total supply of tokens in circulation */\n async getTotalSupply(): Promise<bigint> {\n return await this.rpc.readContract({\n address: this.address,\n abi: derc20Abi,\n functionName: 'totalSupply',\n })\n }\n \n /** Get the duration (in seconds) of the vesting period */\n async getVestingDuration(): Promise<bigint> {\n return await this.rpc.readContract({\n address: this.address,\n abi: derc20Abi,\n functionName: 'vestingDuration',\n })\n }\n \n /** Get the timestamp when vesting begins */\n async getVestingStart(): Promise<bigint> {\n return await this.rpc.readContract({\n address: this.address,\n abi: derc20Abi,\n functionName: 'vestingStart',\n })\n }\n \n /** Get the total amount of tokens allocated for vesting */\n async getVestedTotalAmount(): Promise<bigint> {\n return await this.rpc.readContract({\n address: this.address,\n abi: derc20Abi,\n functionName: 'vestedTotalAmount',\n })\n }\n \n /** Get the amount of vested tokens available for a specific address */\n async getAvailableVestedAmount(account: Address): Promise<bigint> {\n return await this.rpc.readContract({\n address: this.address,\n abi: derc20Abi,\n functionName: 'computeAvailableVestedAmount',\n args: [account],\n })\n }\n \n /** Get the current annual mint rate in tokens per year */\n async getYearlyMintRate(): Promise<bigint> {\n return await this.rpc.readContract({\n address: this.address,\n abi: derc20Abi,\n functionName: 'yearlyMintRate',\n })\n }\n \n /** Get the pool address for the token */\n async getPool(): Promise<Address> {\n return await this.rpc.readContract({\n address: this.address,\n abi: derc20Abi,\n functionName: 'pool',\n })\n }\n \n /** Check if the liquidity pool is unlocked */\n async getIsPoolUnlocked(): Promise<boolean> {\n return await this.rpc.readContract({\n address: this.address,\n abi: derc20Abi,\n functionName: 'isPoolUnlocked',\n })\n }\n \n /** Get the timestamp when token minting begins */\n async getCurrentYearStart(): Promise<bigint> {\n return await this.rpc.readContract({\n address: this.address,\n abi: derc20Abi,\n functionName: 'currentYearStart',\n })\n }\n \n /** Get the timestamp of the last mint */\n async getLastMintTimestamp(): Promise<bigint> {\n return await this.rpc.readContract({\n address: this.address,\n abi: derc20Abi,\n functionName: 'lastMintTimestamp',\n })\n }\n \n /**\n * Get detailed vesting information for a specific account\n * @param account - Address to retrieve vesting data for\n * @returns Object containing totalAmount and releasedAmount\n */\n async getVestingData(account: Address): Promise<{\n totalAmount: bigint\n releasedAmount: bigint\n }> {\n const result = await this.rpc.readContract({\n address: this.address,\n abi: derc20Abi,\n functionName: 'getVestingDataOf',\n args: [account],\n })\n \n return {\n totalAmount: result[0],\n releasedAmount: result[1],\n }\n }\n \n // Write methods (require wallet client)\n \n /**\n * Approve a spender to transfer tokens on behalf of the owner\n * @param spender - Address that will be able to spend the tokens\n * @param value - Amount of tokens to approve\n * @returns Transaction hash\n */\n async approve(spender: Address, value: bigint, options?: { gas?: bigint }): Promise<`0x${string}`> {\n if (!this.walletClient) {\n throw new Error('Wallet client required for write operations')\n }\n \n const { request } = await this.rpc.simulateContract({\n address: this.address,\n abi: derc20Abi,\n functionName: 'approve',\n args: [spender, value],\n account: this.walletClient.account,\n })\n \n return await this.walletClient.writeContract(options?.gas ? { ...request, gas: options.gas } : request)\n }\n \n /**\n * Delegate governance votes to an address\n */\n async delegate(delegatee: Address, options?: { gas?: bigint }): Promise<`0x${string}`> {\n if (!this.walletClient) {\n throw new Error('Wallet client required for write operations')\n }\n \n const { request } = await this.rpc.simulateContract({\n address: this.address,\n abi: derc20Abi,\n functionName: 'delegate',\n args: [delegatee],\n account: this.walletClient.account,\n })\n \n return await this.walletClient.writeContract(options?.gas ? { ...request, gas: options.gas } : request)\n }\n \n /**\n * Delegate governance votes using an EIP-712 signature (gasless path)\n * Note: Caller signs typed data; a relayer or the caller submits the tx.\n */\n async delegateBySig(\n delegatee: Address,\n expiry: bigint,\n options?: { gas?: bigint }\n ): Promise<`0x${string}`> {\n if (!this.walletClient) {\n throw new Error('Wallet client required for write operations')\n }\n\n const acct = this.walletClient.account as unknown\n let accountAddress: Address\n if (typeof acct === 'string') {\n accountAddress = acct as Address\n } else if (acct && typeof acct === 'object' && 'address' in acct) {\n accountAddress = (acct as { address: Address }).address\n } else {\n throw new Error('Invalid wallet account')\n }\n const [nonce, name] = await Promise.all([\n this.rpc.readContract({ address: this.address, abi: derc20Abi, functionName: 'nonces', args: [accountAddress] }),\n this.getName(),\n ])\n const chainId = (this.rpc.chain?.id as number | undefined) ?? (await this.rpc.getChainId())\n\n const domain = {\n name,\n version: '1',\n chainId,\n verifyingContract: this.address,\n } as const\n\n const types = {\n Delegation: [\n { name: 'delegatee', type: 'address' },\n { name: 'nonce', type: 'uint256' },\n { name: 'expiry', type: 'uint256' },\n ],\n } as const\n\n const message = { delegatee, nonce, expiry } as const\n\n const signature = await this.walletClient.signTypedData({\n domain,\n types,\n primaryType: 'Delegation',\n message,\n account: accountAddress,\n })\n\n const { v, r, s } = Derc20.splitSignature(signature)\n\n const { request } = await this.rpc.simulateContract({\n address: this.address,\n abi: derc20Abi,\n functionName: 'delegateBySig',\n args: [delegatee, nonce, expiry, v, r, s],\n account: this.walletClient.account,\n })\n\n return await this.walletClient.writeContract(options?.gas ? { ...request, gas: options.gas } : request)\n }\n\n /**\n * Release all currently available vested tokens to the caller\n */\n async release(options?: { gas?: bigint }): Promise<`0x${string}`> {\n if (!this.walletClient) {\n throw new Error('Wallet client required for write operations')\n }\n\n const { request } = await this.rpc.simulateContract({\n address: this.address,\n abi: derc20Abi,\n functionName: 'release',\n args: [],\n account: this.walletClient.account,\n })\n\n return await this.walletClient.writeContract(options?.gas ? { ...request, gas: options.gas } : request)\n }\n}\n"]}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var viem = require('viem');
|
|
4
|
+
|
|
3
5
|
// src/entities/token/eth/Eth.ts
|
|
4
6
|
var Eth = class {
|
|
7
|
+
get rpc() {
|
|
8
|
+
return this.publicClient;
|
|
9
|
+
}
|
|
5
10
|
constructor(publicClient) {
|
|
6
11
|
this.publicClient = publicClient;
|
|
7
12
|
}
|
|
@@ -43,14 +48,14 @@ var Eth = class {
|
|
|
43
48
|
* @returns Promise resolving to the account's ETH balance in wei
|
|
44
49
|
*/
|
|
45
50
|
async getBalanceOf(account) {
|
|
46
|
-
return await this.
|
|
51
|
+
return await this.rpc.getBalance({
|
|
47
52
|
address: account
|
|
48
53
|
});
|
|
49
54
|
}
|
|
50
55
|
};
|
|
51
56
|
/** Static ETH address identifier (zero address) */
|
|
52
|
-
Eth.address =
|
|
57
|
+
Eth.address = viem.zeroAddress;
|
|
53
58
|
|
|
54
59
|
exports.Eth = Eth;
|
|
55
|
-
//# sourceMappingURL=chunk-
|
|
56
|
-
//# sourceMappingURL=chunk-
|
|
60
|
+
//# sourceMappingURL=chunk-LS4TK6SX.js.map
|
|
61
|
+
//# sourceMappingURL=chunk-LS4TK6SX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/entities/token/eth/Eth.ts"],"names":["zeroAddress"],"mappings":";;;;;AAaO,IAAM,MAAN,MAAU;AAAA,EAEf,IAAY,GAAA,GAAoB;AAC9B,IAAA,OAAO,IAAA,CAAK,YAAA;AAAA,EACd;AAAA,EAKA,YAAY,YAAA,EAAqC;AAC/C,IAAA,IAAA,CAAK,YAAA,GAAe,YAAA;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAA,GAA2B;AAC/B,IAAA,OAAO,OAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,SAAA,GAA6B;AACjC,IAAA,OAAO,KAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,WAAA,GAA+B;AACnC,IAAA,OAAO,EAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,YAAA,GAAgC;AACpC,IAAA,OAAO,MAAM,IAAA,GAAO,EAAA;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,aAAa,OAAA,EAAmC;AACpD,IAAA,OAAO,MAAM,IAAA,CAAK,GAAA,CAAI,UAAA,CAAW;AAAA,MAC/B,OAAA,EAAS;AAAA,KACV,CAAA;AAAA,EACH;AACF;AAAA;AA3Da,GAAA,CAOK,OAAA,GAAUA,gBAAA","file":"chunk-LS4TK6SX.js","sourcesContent":["import { type Address, zeroAddress, type PublicClient } from 'viem'\nimport { SupportedPublicClient } from '@/types'\n\n/**\n * A class providing read-only access to Ethereum (ETH) token information and balances.\n *\n * @remarks\n * This class implements a consistent interface with other token implementations (like DERC20)\n * but handles ETH-specific behavior such as:\n * - Hardcoded token metadata (name, symbol, decimals)\n * - Simulating unlimited allowance for ETH transfers\n * - Querying native ETH balances through viem\n */\nexport class Eth {\n private publicClient: SupportedPublicClient\n private get rpc(): PublicClient {\n return this.publicClient as PublicClient\n }\n \n /** Static ETH address identifier (zero address) */\n static readonly address = zeroAddress\n \n constructor(publicClient: SupportedPublicClient) {\n this.publicClient = publicClient\n }\n \n /**\n * Get the human-readable name of the token\n * @returns Promise resolving to \"Ether\" (hardcoded ETH name)\n */\n async getName(): Promise<string> {\n return \"Ether\"\n }\n \n /**\n * Get the ticker symbol of the token\n * @returns Promise resolving to \"ETH\" (hardcoded ETH symbol)\n */\n async getSymbol(): Promise<string> {\n return \"ETH\"\n }\n \n /**\n * Get the number of decimal places used by the token\n * @returns Promise resolving to 18 (standard ETH decimals)\n */\n async getDecimals(): Promise<number> {\n return 18\n }\n \n /**\n * Get the allowance granted to a spender (always returns maximum value)\n * @returns Promise resolving to 2^256 - 1 (simulates unlimited ETH allowance)\n *\n * @remarks\n * ETH doesn't have an allowance mechanism, so this returns max uint256 value\n * to represent unlimited approval in systems expecting ERC20-like interfaces\n */\n async getAllowance(): Promise<bigint> {\n return 2n ** 256n - 1n\n }\n \n /**\n * Get the ETH balance of a specified account\n * @param account - Address of the account to query\n * @returns Promise resolving to the account's ETH balance in wei\n */\n async getBalanceOf(account: Address): Promise<bigint> {\n return await this.rpc.getBalance({\n address: account,\n })\n }\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ADDRESSES } from './chunk-AW3WR2D3.mjs';
|
|
2
|
+
|
|
3
|
+
// src/utils/airlock.ts
|
|
4
|
+
var airlockAbi = [
|
|
5
|
+
{
|
|
6
|
+
type: "function",
|
|
7
|
+
name: "owner",
|
|
8
|
+
inputs: [],
|
|
9
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
10
|
+
stateMutability: "view"
|
|
11
|
+
}
|
|
12
|
+
];
|
|
13
|
+
var getAirlockOwner = async (publicClient) => {
|
|
14
|
+
const client = publicClient;
|
|
15
|
+
const chainId = client.chain?.id;
|
|
16
|
+
if (!chainId || !ADDRESSES[chainId]) {
|
|
17
|
+
throw new Error("Unsupported chain ID for airlock owner lookup");
|
|
18
|
+
}
|
|
19
|
+
const airlockAddress = ADDRESSES[chainId].airlock;
|
|
20
|
+
const owner = await client.readContract({
|
|
21
|
+
address: airlockAddress,
|
|
22
|
+
abi: airlockAbi,
|
|
23
|
+
functionName: "owner"
|
|
24
|
+
});
|
|
25
|
+
if (!owner) throw new Error("Airlock owner not found");
|
|
26
|
+
return owner;
|
|
27
|
+
};
|
|
28
|
+
var DEFAULT_AIRLOCK_BENEFICIARY_SHARES = BigInt(5e16);
|
|
29
|
+
var createAirlockBeneficiary = (owner, shares = DEFAULT_AIRLOCK_BENEFICIARY_SHARES) => ({
|
|
30
|
+
beneficiary: owner,
|
|
31
|
+
shares
|
|
32
|
+
});
|
|
33
|
+
var getAirlockBeneficiary = async (publicClient, shares = DEFAULT_AIRLOCK_BENEFICIARY_SHARES) => {
|
|
34
|
+
const owner = await getAirlockOwner(publicClient);
|
|
35
|
+
return createAirlockBeneficiary(owner, shares);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { DEFAULT_AIRLOCK_BENEFICIARY_SHARES, createAirlockBeneficiary, getAirlockBeneficiary, getAirlockOwner };
|
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ACA,MAAA,GAAiB,kCAAA,KACY;AAC7B,EAAA,MAAM,KAAA,GAAQ,MAAM,eAAA,CAAgB,YAAY,CAAA;AAChD,EAAA,OAAO,wBAAA,CAAyB,OAAO,MAAM,CAAA;AAC/C","file":"chunk-M4WMHD3X.mjs","sourcesContent":["import type { PublicClient, Address } from 'viem'\nimport { ADDRESSES, type SupportedChainId } from '../addresses'\nimport type { BeneficiaryData } from '../types'\n\nconst airlockAbi = [\n {\n type: 'function',\n name: 'owner',\n inputs: [],\n outputs: [{ name: '', type: 'address', internalType: 'address' }],\n stateMutability: 'view',\n },\n] as const;\n\nexport const getAirlockOwner = async (publicClient: unknown): Promise<Address> => {\n const client = publicClient as PublicClient\n const chainId = client.chain?.id as SupportedChainId | undefined\n if (!chainId || !ADDRESSES[chainId]) {\n throw new Error('Unsupported chain ID for airlock owner lookup')\n }\n\n const airlockAddress = ADDRESSES[chainId].airlock\n\n const owner = await client.readContract({\n address: airlockAddress,\n abi: airlockAbi,\n functionName: 'owner',\n })\n\n if (!owner) throw new Error('Airlock owner not found')\n return owner as Address\n}\n\n// Default airlock beneficiary shares (5% = 0.05e18 WAD)\nexport const DEFAULT_AIRLOCK_BENEFICIARY_SHARES = BigInt(5e16) // 5% in WAD\n\nexport const createAirlockBeneficiary = (\n owner: Address,\n shares: bigint = DEFAULT_AIRLOCK_BENEFICIARY_SHARES\n): BeneficiaryData => ({\n beneficiary: owner,\n shares,\n})\n\nexport const getAirlockBeneficiary = async (\n publicClient: unknown,\n shares: bigint = DEFAULT_AIRLOCK_BENEFICIARY_SHARES\n): Promise<BeneficiaryData> => {\n const owner = await getAirlockOwner(publicClient)\n return createAirlockBeneficiary(owner, shares)\n}\n"]}
|