@floorlaunchpad/sdk 0.0.0-stage → 0.1.0
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 +61 -0
- package/README.md +33 -2
- package/dist/adapter.d.ts +28 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +2 -0
- package/dist/adapter.js.map +1 -0
- package/dist/chain.d.ts +23 -0
- package/dist/chain.d.ts.map +1 -0
- package/dist/chain.js +25 -0
- package/dist/chain.js.map +1 -0
- package/dist/client.d.ts +26 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +43 -0
- package/dist/client.js.map +1 -0
- package/dist/dex-adapter.d.ts +228 -0
- package/dist/dex-adapter.d.ts.map +1 -0
- package/dist/dex-adapter.js +407 -0
- package/dist/dex-adapter.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/quotes.d.ts +12 -0
- package/dist/quotes.d.ts.map +1 -0
- package/dist/quotes.gen.d.ts +8 -0
- package/dist/quotes.gen.d.ts.map +1 -0
- package/dist/quotes.gen.js +2170 -0
- package/dist/quotes.gen.js.map +1 -0
- package/dist/quotes.js +24 -0
- package/dist/quotes.js.map +1 -0
- package/dist/types.d.ts +111 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +41 -4
- package/src/adapter.ts +20 -0
- package/src/chain.ts +39 -0
- package/src/client.ts +41 -0
- package/src/dex-adapter.ts +477 -0
- package/src/index.ts +6 -0
- package/src/quotes.gen.ts +2170 -0
- package/src/quotes.ts +29 -0
- package/src/types.ts +115 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
10
|
+
|
|
11
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
12
|
+
|
|
13
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
14
|
+
|
|
15
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
16
|
+
|
|
17
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
18
|
+
|
|
19
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
20
|
+
|
|
21
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
22
|
+
|
|
23
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
24
|
+
|
|
25
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
26
|
+
|
|
27
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
28
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
29
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
30
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
31
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
32
|
+
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
33
|
+
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
34
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
35
|
+
|
|
36
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
37
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
38
|
+
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
39
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
40
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
41
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
42
|
+
|
|
43
|
+
END OF TERMS AND CONDITIONS
|
|
44
|
+
|
|
45
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
46
|
+
|
|
47
|
+
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
|
48
|
+
|
|
49
|
+
Copyright [yyyy] [name of copyright owner]
|
|
50
|
+
|
|
51
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
52
|
+
you may not use this file except in compliance with the License.
|
|
53
|
+
You may obtain a copy of the License at
|
|
54
|
+
|
|
55
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
56
|
+
|
|
57
|
+
Unless required by applicable law or agreed to in writing, software
|
|
58
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
59
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
60
|
+
See the License for the specific language governing permissions and
|
|
61
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @floorlaunchpad/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
One API for FLOOR launches on every chain: chain-neutral types and `FloorClient`, which routes each call to the chain
|
|
4
|
+
adapter that serves the launch's chain. The adapters are separate packages:
|
|
5
|
+
[`@floorlaunchpad/sdk-evm`](https://github.com/gudtekdonkey/floor-sdk/tree/main/packages/sdk-evm) and
|
|
6
|
+
[`@floorlaunchpad/sdk-solana`](https://github.com/gudtekdonkey/floor-sdk/tree/main/packages/sdk-solana).
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install @floorlaunchpad/sdk @floorlaunchpad/sdk-solana @solana/kit
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { FloorClient, solanaRef } from '@floorlaunchpad/sdk';
|
|
14
|
+
|
|
15
|
+
const floor = new FloorClient([solanaAdapter /*, evmAdapter */]);
|
|
16
|
+
const { launches, cursor } = await floor.listLaunches(solanaRef('devnet'), { limit: 20 });
|
|
17
|
+
const q = await floor.quote(launches[0]!.ref, 'buy', 1_000_000_000n);
|
|
18
|
+
const tx = await floor.buildTrade({ launch: launches[0]!.ref, side: 'buy', amountIn: 1_000_000_000n, minAmountOut: (q.amountOut * 99n) / 100n, trader });
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
- `Launch`: name, symbol, decimals, supply, the quote asset, the phase (`pending`, `bonding`, `graduated`), the mode, the
|
|
22
|
+
creator and the published floor (`floorPriceX18`, whole quote per whole token × 1e18). `raw` carries the chain's own
|
|
23
|
+
decoded accounts.
|
|
24
|
+
- `Quote`: `amountIn`, `amountOut`, the trader's whole take as `fees` (or the call throws), `feesExact`, an optional
|
|
25
|
+
`refund`; `graduates` and `maxExtraNative` when the trade graduates a sale and may take native currency on top of
|
|
26
|
+
`amountIn`.
|
|
27
|
+
- `UnsignedTx`: everything one action needs, in order, for one wallet prompt.
|
|
28
|
+
- Listings are unfiltered: anyone can create a launch with any name and symbol. Identify a launch by its address.
|
|
29
|
+
|
|
30
|
+
Amounts are bigints in base units; addresses are kept verbatim (a Solana address is case-sensitive).
|
|
31
|
+
|
|
32
|
+
## Licence
|
|
33
|
+
|
|
34
|
+
Apache-2.0.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ChainRef } from './chain.js';
|
|
2
|
+
import type { Launch, LaunchRef, Quote, Side, TradeParams, UnsignedTx, Amount } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* What a chain package implements. `@floorlaunchpad/sdk-evm` and `@floorlaunchpad/sdk-solana` each export one factory
|
|
5
|
+
* that returns this. Reads are network calls; `build*` returns an unsigned transaction and never signs.
|
|
6
|
+
*/
|
|
7
|
+
export interface FloorChainAdapter {
|
|
8
|
+
/** The chains this adapter instance serves. */
|
|
9
|
+
readonly chains: readonly ChainRef[];
|
|
10
|
+
getLaunch(ref: LaunchRef): Promise<Launch>;
|
|
11
|
+
/** Paged, newest first. `cursor` is opaque and adapter-specific. */
|
|
12
|
+
listLaunches(chain: ChainRef, opts?: {
|
|
13
|
+
readonly limit?: number;
|
|
14
|
+
readonly cursor?: string;
|
|
15
|
+
}): Promise<{
|
|
16
|
+
readonly launches: readonly Launch[];
|
|
17
|
+
readonly cursor: string | null;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* `trader` is used where a venue checks the seller's own state: a Solana sell-back before graduation pays the same
|
|
21
|
+
* fixed-price amount to any seller, and `trader` is read only to check that their sale position covers `amountIn`.
|
|
22
|
+
*/
|
|
23
|
+
quote(ref: LaunchRef, side: Side, amountIn: Amount, opts?: {
|
|
24
|
+
readonly trader?: string;
|
|
25
|
+
}): Promise<Quote>;
|
|
26
|
+
buildTrade(params: TradeParams): Promise<UnsignedTx>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAElG;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,CAAC;IACrC,SAAS,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3C,oEAAoE;IACpE,YAAY,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;IAC/K;;;OAGG;IACH,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IACzG,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACtD"}
|
package/dist/adapter.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":""}
|
package/dist/chain.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chains. The same shapes and string keys the FLOOR site uses, so an id produced here is an id the
|
|
3
|
+
* site understands.
|
|
4
|
+
*/
|
|
5
|
+
export type SolanaCluster = 'mainnet' | 'devnet' | 'testnet' | 'local';
|
|
6
|
+
export type EvmRef = {
|
|
7
|
+
readonly family: 'evm';
|
|
8
|
+
readonly chainId: number;
|
|
9
|
+
};
|
|
10
|
+
export type SolanaRef = {
|
|
11
|
+
readonly family: 'solana';
|
|
12
|
+
readonly cluster: SolanaCluster;
|
|
13
|
+
};
|
|
14
|
+
export type ChainRef = EvmRef | SolanaRef;
|
|
15
|
+
/** `eip155:<chainId>` or `solana:<cluster>` (CAIP-2 style). */
|
|
16
|
+
export type ChainKey = string;
|
|
17
|
+
export declare const evmRef: (chainId: number) => EvmRef;
|
|
18
|
+
export declare const solanaRef: (cluster: SolanaCluster) => SolanaRef;
|
|
19
|
+
export declare function chainKey(ref: ChainRef): ChainKey;
|
|
20
|
+
/** A key → its ref, or `null` for anything malformed. Never coerces. */
|
|
21
|
+
export declare function parseChainKey(key: string): ChainRef | null;
|
|
22
|
+
export declare function sameRef(a: ChainRef, b: ChainRef): boolean;
|
|
23
|
+
//# sourceMappingURL=chain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;AACvE,MAAM,MAAM,MAAM,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAC1E,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAA;CAAE,CAAC;AACvF,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;AAC1C,+DAA+D;AAC/D,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAM9B,eAAO,MAAM,MAAM,GAAI,SAAS,MAAM,KAAG,MAAsC,CAAC;AAChF,eAAO,MAAM,SAAS,GAAI,SAAS,aAAa,KAAG,SAA4C,CAAC;AAEhG,wBAAgB,QAAQ,CAAC,GAAG,EAAE,QAAQ,GAAG,QAAQ,CAEhD;AAED,wEAAwE;AACxE,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAW1D;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,GAAG,OAAO,CAEzD"}
|
package/dist/chain.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const EVM_KEY = 'eip155:';
|
|
2
|
+
const SOL_KEY = 'solana:';
|
|
3
|
+
const CLUSTERS = ['mainnet', 'devnet', 'testnet', 'local'];
|
|
4
|
+
export const evmRef = (chainId) => ({ family: 'evm', chainId });
|
|
5
|
+
export const solanaRef = (cluster) => ({ family: 'solana', cluster });
|
|
6
|
+
export function chainKey(ref) {
|
|
7
|
+
return ref.family === 'evm' ? `${EVM_KEY}${ref.chainId}` : `${SOL_KEY}${ref.cluster}`;
|
|
8
|
+
}
|
|
9
|
+
/** A key → its ref, or `null` for anything malformed. Never coerces. */
|
|
10
|
+
export function parseChainKey(key) {
|
|
11
|
+
if (key.startsWith(EVM_KEY)) {
|
|
12
|
+
const raw = key.slice(EVM_KEY.length);
|
|
13
|
+
const id = Number(raw);
|
|
14
|
+
return /^[0-9]+$/.test(raw) && Number.isSafeInteger(id) && id > 0 ? evmRef(id) : null;
|
|
15
|
+
}
|
|
16
|
+
if (key.startsWith(SOL_KEY)) {
|
|
17
|
+
const c = key.slice(SOL_KEY.length);
|
|
18
|
+
return CLUSTERS.includes(c) ? solanaRef(c) : null;
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
export function sameRef(a, b) {
|
|
23
|
+
return chainKey(a) === chainKey(b);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=chain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain.js","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":"AAWA,MAAM,OAAO,GAAG,SAAS,CAAC;AAC1B,MAAM,OAAO,GAAG,SAAS,CAAC;AAC1B,MAAM,QAAQ,GAA6B,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AAErF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,OAAe,EAAU,EAAE,CAAC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CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ChainRef } from './chain.js';
|
|
2
|
+
import type { FloorChainAdapter } from './adapter.js';
|
|
3
|
+
import type { Amount, Launch, LaunchRef, Quote, Side, TradeParams, UnsignedTx } from './types.js';
|
|
4
|
+
export declare class FloorSdkError extends Error {
|
|
5
|
+
readonly code: 'no_adapter' | 'bad_params';
|
|
6
|
+
constructor(code: 'no_adapter' | 'bad_params', message: string);
|
|
7
|
+
}
|
|
8
|
+
/** One entry point over any number of chain adapters. It routes each call by the launch's chain. */
|
|
9
|
+
export declare class FloorClient {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(adapters: readonly FloorChainAdapter[]);
|
|
12
|
+
adapterFor(chain: ChainRef): FloorChainAdapter;
|
|
13
|
+
getLaunch(ref: LaunchRef): Promise<Launch>;
|
|
14
|
+
listLaunches(chain: ChainRef, opts?: {
|
|
15
|
+
limit?: number;
|
|
16
|
+
cursor?: string;
|
|
17
|
+
}): Promise<{
|
|
18
|
+
readonly launches: readonly Launch[];
|
|
19
|
+
readonly cursor: string | null;
|
|
20
|
+
}>;
|
|
21
|
+
quote(ref: LaunchRef, side: Side, amountIn: Amount, opts?: {
|
|
22
|
+
readonly trader?: string;
|
|
23
|
+
}): Promise<Quote>;
|
|
24
|
+
buildTrade(params: TradeParams): Promise<UnsignedTx>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAElG,qBAAa,aAAc,SAAQ,KAAK;IAC1B,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,YAAY;gBAAjC,IAAI,EAAE,YAAY,GAAG,YAAY,EAAE,OAAO,EAAE,MAAM;CAIxE;AAED,oGAAoG;AACpG,qBAAa,WAAW;;gBAGV,QAAQ,EAAE,SAAS,iBAAiB,EAAE;IAQlD,UAAU,CAAC,KAAK,EAAE,QAAQ,GAAG,iBAAiB;IAM9C,SAAS,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;IAC1C,YAAY,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;;;;IACxE,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,KAAK,CAAC;IAIxG,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;CAKrD"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { chainKey } from './chain.js';
|
|
2
|
+
export class FloorSdkError extends Error {
|
|
3
|
+
code;
|
|
4
|
+
constructor(code, message) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.code = code;
|
|
7
|
+
this.name = 'FloorSdkError';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/** One entry point over any number of chain adapters. It routes each call by the launch's chain. */
|
|
11
|
+
export class FloorClient {
|
|
12
|
+
#byChain = new Map();
|
|
13
|
+
constructor(adapters) {
|
|
14
|
+
for (const a of adapters)
|
|
15
|
+
for (const c of a.chains) {
|
|
16
|
+
const k = chainKey(c);
|
|
17
|
+
if (this.#byChain.has(k))
|
|
18
|
+
throw new FloorSdkError('bad_params', `two adapters serve ${k}`);
|
|
19
|
+
this.#byChain.set(k, a);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
adapterFor(chain) {
|
|
23
|
+
const a = this.#byChain.get(chainKey(chain));
|
|
24
|
+
if (!a)
|
|
25
|
+
throw new FloorSdkError('no_adapter', `no adapter serves ${chainKey(chain)}`);
|
|
26
|
+
return a;
|
|
27
|
+
}
|
|
28
|
+
getLaunch(ref) { return this.adapterFor(ref.chain).getLaunch(ref); }
|
|
29
|
+
listLaunches(chain, opts) { return this.adapterFor(chain).listLaunches(chain, opts); }
|
|
30
|
+
quote(ref, side, amountIn, opts) {
|
|
31
|
+
if (amountIn <= 0n)
|
|
32
|
+
throw new FloorSdkError('bad_params', 'amountIn must be > 0');
|
|
33
|
+
return this.adapterFor(ref.chain).quote(ref, side, amountIn, opts);
|
|
34
|
+
}
|
|
35
|
+
buildTrade(params) {
|
|
36
|
+
if (params.amountIn <= 0n)
|
|
37
|
+
throw new FloorSdkError('bad_params', 'amountIn must be > 0');
|
|
38
|
+
if (params.minAmountOut <= 0n)
|
|
39
|
+
throw new FloorSdkError('bad_params', 'minAmountOut must be > 0');
|
|
40
|
+
return this.adapterFor(params.launch.chain).buildTrade(params);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAiB,MAAM,YAAY,CAAC;AAIrD,MAAM,OAAO,aAAc,SAAQ,KAAK;IACjB;IAArB,YAAqB,IAAiC,EAAE,OAAe;QACrE,KAAK,CAAC,OAAO,CAAC,CAAC;QADI,SAAI,GAAJ,IAAI,CAA6B;QAEpD,IAAI,CAAC,IA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AAC,CAAC;QAClF,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;IACrE,CAAC;IACD,UAAU,CAAC,MAAmB;QAC5B,IAAI,MAAM,CAAC,QAAQ,IAAI,EAAE;YAAE,MAAM,IAAI,aAAa,CAAC,YAAY,EAAE,sBAAsB,CAAC,CAAC;QACzF,IAAI,MAAM,CAAC,YAAY,IAAI,EAAE;YAAE,MAAM,IAAI,aAAa,CAAC,YAAY,EAAE,0BAA0B,CAAC,CAAC;QACjG,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACjE,CAAC;CACF"}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The DEX adapter's pure mapping: FLOOR's indexed trades (the indexer's chain-wide `/events` rows) as GeckoTerminal's
|
|
3
|
+
* "Integration API Standards v0.1" events, which DEX Screener reads too. No network and no environment: every function is
|
|
4
|
+
* pure, so an indexer of its own can use the same pair model and answer the same numbers as FLOOR's `/api/dex`.
|
|
5
|
+
*
|
|
6
|
+
* - An invalid answer halts a screener's indexing, so nothing here guesses. Amounts are exact decimal strings of the raw
|
|
7
|
+
* units (`decimalize`), a price is an exact bigint ratio to `PRICE_SIG` significant digits (`ratioString`), never a
|
|
8
|
+
* float, and an event that cannot be stated exactly (a zero amount, a zero price) is dropped by `mapEvents` and
|
|
9
|
+
* counted, never served as a guess.
|
|
10
|
+
* - A pair is immutable: asset0 is always the launch token and asset1 always the quote (the native coin is the zero
|
|
11
|
+
* address, as in a v4 currency0). A swap is exactly `asset0In + asset1Out` (a sell) or `asset1In + asset0Out` (a buy).
|
|
12
|
+
* - Two pairs per launch: the sale (its id the FloorLaunch address; every sale fill) and, once graduated, the pool (its id
|
|
13
|
+
* the v4 pool id on EVM, the Carpenter pool account on Solana; every pool trade and liquidity change).
|
|
14
|
+
*/
|
|
15
|
+
/** A price's significant digits: past a uint256 sqrt's own precision is noise; under it, a rounding a reader can see. */
|
|
16
|
+
export declare const PRICE_SIG = 18;
|
|
17
|
+
/** `raw / 10^decimals`, exact: `1500000` at 6 → `1.5`; no exponent, no trailing zeros, `0` for zero. */
|
|
18
|
+
export declare function decimalize(raw: bigint, decimals: number): string;
|
|
19
|
+
/** `num / den` (both positive) to `sig` significant digits, truncated, as an exact decimal string; `null` when not positive. */
|
|
20
|
+
export declare function ratioString(num: bigint, den: bigint, sig?: number): string | null;
|
|
21
|
+
/** The token's price in its quote, decimalized, from a square-root price (currency1 per currency0, raw units): a v4
|
|
22
|
+
* `sqrtPriceX96` (`bits` 96, the default) or a Carpenter `sqrtPriceX64` (`bits` 64 — Q64.64, never through the X96 scale). */
|
|
23
|
+
export declare function priceFromSqrt(sqrtPriceX96: bigint, quoteIsCurrency1: boolean, tokenDecimals: number, quoteDecimals: number, bits?: 96 | 64): string | null;
|
|
24
|
+
/** Raw amounts in the POOL's currency order (currency0, currency1) — oriented to (token, quote) by `mapEvents` alone. */
|
|
25
|
+
export type Pair01 = readonly [bigint, bigint];
|
|
26
|
+
/**
|
|
27
|
+
* A trade's fees in the POOL's currency order, raw (GeckoTerminal's `fees0In` / `fees1In` / `fees0Out` /
|
|
28
|
+
* `fees1Out`): `in` taken from what the trader paid in before the curve, `out` from what the curve paid out.
|
|
29
|
+
*/
|
|
30
|
+
export interface Fees01 {
|
|
31
|
+
in0: bigint;
|
|
32
|
+
in1: bigint;
|
|
33
|
+
out0: bigint;
|
|
34
|
+
out1: bigint;
|
|
35
|
+
}
|
|
36
|
+
/** One pool trade off the indexer's `/events` (`swapJson` + `txIndex`), the fields this adapter reads. */
|
|
37
|
+
export interface IxSwap {
|
|
38
|
+
blockNumber: number;
|
|
39
|
+
logIndex: number;
|
|
40
|
+
txIndex: number;
|
|
41
|
+
txHash: string;
|
|
42
|
+
timestamp: number;
|
|
43
|
+
token: string;
|
|
44
|
+
side: 'buy' | 'sell';
|
|
45
|
+
quoteAmount: bigint;
|
|
46
|
+
tokenAmount: bigint;
|
|
47
|
+
quoteIsCurrency1: boolean;
|
|
48
|
+
sqrtPriceX96: bigint;
|
|
49
|
+
trader: string | null;
|
|
50
|
+
txFrom: string;
|
|
51
|
+
/** The square root's width: 96 (EVM, the default) or 64 (Carpenter's Q64.64). */
|
|
52
|
+
sqrtBits?: 96 | 64;
|
|
53
|
+
/** The POOL the trade ran on — the v4 PoolId (EVM, lower-case) or the Carpenter pool
|
|
54
|
+
* account (Solana) — held to the launch's own (`PairInfo.poolPairId`). */
|
|
55
|
+
pool?: string;
|
|
56
|
+
/** THE RESERVES after the trade, currency order, raw; `null` = unknown (left out, never 0). EVM: the in-range
|
|
57
|
+
* VIRTUAL reserves off the `Swap` log's own `liquidity` and `sqrtPriceX96` (`virtualReserves`); Solana: the pool's two
|
|
58
|
+
* VAULTS after the transaction. */
|
|
59
|
+
reserves01?: Pair01 | null;
|
|
60
|
+
/** The trade's fees, currency order; `null` = not stateable exactly (left out). */
|
|
61
|
+
fees01?: Fees01 | null;
|
|
62
|
+
}
|
|
63
|
+
/** One sale fill off the indexer's `/events` (`saleFillJson` + `txIndex`, `launch`, `token`, the running totals). */
|
|
64
|
+
export interface IxFill {
|
|
65
|
+
blockNumber: number;
|
|
66
|
+
logIndex: number;
|
|
67
|
+
txIndex: number;
|
|
68
|
+
txHash: string;
|
|
69
|
+
timestamp: number;
|
|
70
|
+
launch: string;
|
|
71
|
+
token: string;
|
|
72
|
+
side: 'buy' | 'sell';
|
|
73
|
+
quoteAmount: bigint;
|
|
74
|
+
tokenAmount: bigint;
|
|
75
|
+
trader: string;
|
|
76
|
+
soldTotal: bigint;
|
|
77
|
+
raisedTotal: bigint;
|
|
78
|
+
/** The fill's FLOOR Platform fee, raw quote — on TOP of a buy's price (taken from what the buyer paid in),
|
|
79
|
+
* OUT of a sell-back's gross (taken from what the sale paid out). `null` = not read. */
|
|
80
|
+
fee?: bigint | null;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* One POOL liquidity change (the DEX adapter's `join` / `exit`): a position opened, grown, shrunk or
|
|
84
|
+
* closed — the HOOK's own positions included (protocol liquidity is the pool's liquidity) — or a donation. Amounts are the
|
|
85
|
+
* PRINCIPAL the change moved, currency order, raw, unsigned; `null` = not stated (the event is dropped and counted).
|
|
86
|
+
*/
|
|
87
|
+
export interface IxLiquidity {
|
|
88
|
+
blockNumber: number;
|
|
89
|
+
logIndex: number;
|
|
90
|
+
txIndex: number;
|
|
91
|
+
txHash: string;
|
|
92
|
+
timestamp: number;
|
|
93
|
+
token: string;
|
|
94
|
+
pool: string;
|
|
95
|
+
kind: 'join' | 'exit';
|
|
96
|
+
amount01: Pair01 | null;
|
|
97
|
+
maker: string;
|
|
98
|
+
/** The pool's reserves after the change (`IxSwap.reserves01`' rule per family); `null` unknown. */
|
|
99
|
+
reserves01: Pair01 | null;
|
|
100
|
+
/** The pool's orientation where the row carries it (EVM); Solana's comes from `PairInfo`. */
|
|
101
|
+
quoteIsCurrency1?: boolean;
|
|
102
|
+
}
|
|
103
|
+
/** What a launch's pairs need, keyed by its token (lower-cased): present only for a launch that is shown (default-deny). */
|
|
104
|
+
export interface PairInfo {
|
|
105
|
+
/** The sale pair's id (the FloorLaunch address, as served). */
|
|
106
|
+
saleId: string;
|
|
107
|
+
/** The pool pair's id, `null` before graduation: the v4 POOL ID (EVM, lower-case 0x + 64 hex) or the Carpenter POOL
|
|
108
|
+
* account (Solana, base58). */
|
|
109
|
+
poolPairId: string | null;
|
|
110
|
+
tokenDecimals: number;
|
|
111
|
+
quoteDecimals: number;
|
|
112
|
+
saleTokens: bigint;
|
|
113
|
+
/** The pool's orientation where the swap row does not carry it (Solana: off the pool's own mints). */
|
|
114
|
+
quoteIsCurrency1?: boolean;
|
|
115
|
+
}
|
|
116
|
+
export type FeeMetadata = {
|
|
117
|
+
fees0In?: string;
|
|
118
|
+
fees1In?: string;
|
|
119
|
+
fees0Out?: string;
|
|
120
|
+
fees1Out?: string;
|
|
121
|
+
};
|
|
122
|
+
export interface DexSwapEvent {
|
|
123
|
+
block: {
|
|
124
|
+
blockNumber: number;
|
|
125
|
+
blockTimestamp: number;
|
|
126
|
+
};
|
|
127
|
+
eventType: 'swap';
|
|
128
|
+
txnId: string;
|
|
129
|
+
txnIndex: number;
|
|
130
|
+
eventIndex: number;
|
|
131
|
+
maker: string;
|
|
132
|
+
pairId: string;
|
|
133
|
+
asset0In?: string;
|
|
134
|
+
asset1In?: string;
|
|
135
|
+
asset0Out?: string;
|
|
136
|
+
asset1Out?: string;
|
|
137
|
+
priceNative: string;
|
|
138
|
+
reserves?: {
|
|
139
|
+
asset0: string;
|
|
140
|
+
asset1: string;
|
|
141
|
+
};
|
|
142
|
+
/** GeckoTerminal's per-swap fees, decimalized, each leg only where non-zero; the key only where one is. */
|
|
143
|
+
metadata?: FeeMetadata;
|
|
144
|
+
}
|
|
145
|
+
/** GeckoTerminal's `JoinExitEvent`: `amount0` the token, `amount1` the quote, decimalized. */
|
|
146
|
+
export interface DexJoinExitEvent {
|
|
147
|
+
block: {
|
|
148
|
+
blockNumber: number;
|
|
149
|
+
blockTimestamp: number;
|
|
150
|
+
};
|
|
151
|
+
eventType: 'join' | 'exit';
|
|
152
|
+
txnId: string;
|
|
153
|
+
txnIndex: number;
|
|
154
|
+
eventIndex: number;
|
|
155
|
+
maker: string;
|
|
156
|
+
pairId: string;
|
|
157
|
+
amount0: string;
|
|
158
|
+
amount1: string;
|
|
159
|
+
reserves?: {
|
|
160
|
+
asset0: string;
|
|
161
|
+
asset1: string;
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
export type DexEvent = DexSwapEvent | DexJoinExitEvent;
|
|
165
|
+
/** Is `e` exactly one of the two swap shapes, every amount positive and the price positive? */
|
|
166
|
+
export declare function isSwapShape(e: DexEvent): boolean;
|
|
167
|
+
/** Is `e` a join / exit with both amounts stated and at least one positive (a fee-only poke moves no principal)? */
|
|
168
|
+
export declare function isJoinExitShape(e: DexEvent): boolean;
|
|
169
|
+
/**
|
|
170
|
+
* A v4 / Carpenter pool's IN-RANGE VIRTUAL reserves, currency order, raw: `L / √P` and `L · √P` with √P in
|
|
171
|
+
* Q64.96 (`bits` 96) or Q64.64 (`bits` 64), rounded down — the amounts a constant-product pool of the same liquidity would
|
|
172
|
+
* hold at this price (their ratio IS the price). `null` for a zero liquidity or price (nothing to state).
|
|
173
|
+
*/
|
|
174
|
+
export declare function virtualReserves(liquidity: bigint, sqrtPrice: bigint, bits?: 96 | 64): Pair01 | null;
|
|
175
|
+
/**
|
|
176
|
+
* The events of one block range, sorted by (block, txnIndex, eventIndex). `info(token)` answers a SHOWN launch's pair info,
|
|
177
|
+
* `undefined` for one that is not shown — its events are left out (default-deny), as the grid leaves it out. An event
|
|
178
|
+
* that cannot be stated exactly is dropped and counted in `dropped`.
|
|
179
|
+
*/
|
|
180
|
+
export declare function mapEvents(swaps: readonly IxSwap[], fills: readonly IxFill[], info: (token: string) => PairInfo | undefined, key?: (id: string) => string, liquidity?: readonly IxLiquidity[]): {
|
|
181
|
+
events: DexEvent[];
|
|
182
|
+
dropped: number;
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* An EVM trade's fees, currency order: the hook's whole take (`hookFee`, its paired `HookFee` log — always the
|
|
186
|
+
* QUOTE leg: a buy's off the quote IN, a sell's off the quote OUT). The pool's own LP fee is
|
|
187
|
+
* 0 on a FLOOR pool (the hook's dynamic-fee override); a `Swap` that logs a non-zero `fee` (pips) states no exact LP amount,
|
|
188
|
+
* so its fees are `null` (left out), never a guess.
|
|
189
|
+
*/
|
|
190
|
+
export declare function evmFees(side: 'buy' | 'sell', quoteIsCurrency1: boolean, hookFee: bigint, lpFeePips: number): Fees01 | null;
|
|
191
|
+
/** The indexer's `/events` body, decoded; a row that breaks the contract throws (the whole answer is refused, never part). */
|
|
192
|
+
export declare function decodeEventsBody(body: unknown): {
|
|
193
|
+
swaps: IxSwap[];
|
|
194
|
+
fills: IxFill[];
|
|
195
|
+
liquidity: IxLiquidity[];
|
|
196
|
+
};
|
|
197
|
+
/** Split `[from, to]` into two halves (a busy range the indexer refused); `null` for a single block, which cannot split. */
|
|
198
|
+
export declare function halves(from: number, to: number): [[number, number], [number, number]] | null;
|
|
199
|
+
/**
|
|
200
|
+
* A Carpenter trade's fees, currency order, every part the `Swapped` event carries: the hook's five-part split per
|
|
201
|
+
* currency (`feeSplit0` / `feeSplit1`: skim, creator, holder, platform, team), the Carpenter Platform fee
|
|
202
|
+
* (`protocolFeeTotal` in `protocolFeeCurrency`) and the LPs' fee (`lpFeeTotal`, in the INPUT currency). A fee in the trade's
|
|
203
|
+
* input currency is `in`, in its output currency `out`. `null` where the split is not known (`feeSplitKnown` false): never a
|
|
204
|
+
* partial figure.
|
|
205
|
+
*/
|
|
206
|
+
export declare function solanaFees(r: Record<string, unknown>): Fees01 | null;
|
|
207
|
+
/**
|
|
208
|
+
* Carpenter's `GET /chains/:c/events?fromSlot&toSlot` into the
|
|
209
|
+
* SAME rows the EVM body decodes to, so one mapper states both: the slot is the block, `innerIxIndex` the event index, the
|
|
210
|
+
* signature the transaction id, every id BYTE-EXACT (base58 — never lower-cased); the swap's price is the TRADE's own,
|
|
211
|
+
* `walkSqrtPriceX64 ?? postSqrtPriceX64` (Q64.64, `sqrtBits` 64: where the trader's walk landed,
|
|
212
|
+
* before the hook's nudge moved the pool, as the EVM row's own `Swap` price is; `null` / absent walk = a swap before the
|
|
213
|
+
* upgrade, and only then `post`), its orientation the pool's own (`PairInfo.quoteIsCurrency1`, the row carries none). A range with
|
|
214
|
+
* `undecidedSwaps` above 0 is NOT final (a pool not read yet): the caller serves nothing, never a partial page.
|
|
215
|
+
* every swap carries the pool's two VAULTS after the transaction (`reserve0` /
|
|
216
|
+
* `reserve1`, `null` unknown) and its fees (`solanaFees`); `liquidity` (`LiquidityModified`: a positive delta a join, a
|
|
217
|
+
* negative an exit, a zero-delta poke left out; the principal `|amount − fees|` per currency — the event's caller delta less
|
|
218
|
+
* the fees it also paid) and `donations` (`Donated`, a join) ride beside, the maker the event's `owner` / `donor`.
|
|
219
|
+
*/
|
|
220
|
+
export declare function decodeSolanaEventsBody(body: unknown): {
|
|
221
|
+
swaps: IxSwap[];
|
|
222
|
+
fills: IxFill[];
|
|
223
|
+
liquidity: IxLiquidity[];
|
|
224
|
+
undecided: number;
|
|
225
|
+
};
|
|
226
|
+
/** Carpenter's widest range (`span` past it is its 400): the Solana `/events` walk reads windows of this many slots. */
|
|
227
|
+
export declare const SOLANA_EVENTS_SPAN = 2000;
|
|
228
|
+
//# sourceMappingURL=dex-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dex-adapter.d.ts","sourceRoot":"","sources":["../src/dex-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,yHAAyH;AACzH,eAAO,MAAM,SAAS,KAAK,CAAC;AAE5B,wGAAwG;AACxG,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAOhE;AAED,gIAAgI;AAChI,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,SAAY,GAAG,MAAM,GAAG,IAAI,CAWpF;AAED;+HAC+H;AAC/H,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,IAAI,GAAE,EAAE,GAAG,EAAO,GAAG,MAAM,GAAG,IAAI,CAW9J;AAED,yHAAyH;AACzH,MAAM,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE/C;;;GAGG;AACH,MAAM,WAAW,MAAM;IAAG,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG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