@send-fun/sdk 1.0.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 +21 -0
- package/README.md +32 -0
- package/dist/index.cjs +12808 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4406 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +4405 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +12749 -0
- package/dist/index.mjs.map +1 -0
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/package.json +72 -0
- package/src/constants.ts +38 -0
- package/src/dex/generated/accounts/globalConfig.ts +189 -0
- package/src/dex/generated/accounts/index.ts +12 -0
- package/src/dex/generated/accounts/pool.ts +244 -0
- package/src/dex/generated/accounts/rewardAccrual.ts +191 -0
- package/src/dex/generated/accounts/sendDex.accounts.ts +47 -0
- package/src/dex/generated/errors/index.ts +9 -0
- package/src/dex/generated/errors/sendDex.ts +161 -0
- package/src/dex/generated/events/anchorEventCpiDiscriminator.framing.ts +28 -0
- package/src/dex/generated/events/creatorClaimEvent.ts +119 -0
- package/src/dex/generated/events/depositQuoteEvent.ts +115 -0
- package/src/dex/generated/events/index.ts +16 -0
- package/src/dex/generated/events/poolCreateEvent.ts +128 -0
- package/src/dex/generated/events/protocolClaimEvent.ts +111 -0
- package/src/dex/generated/events/sendDex.events.ts +184 -0
- package/src/dex/generated/events/tokenCreateEvent.ts +143 -0
- package/src/dex/generated/events/tradeEvent.ts +143 -0
- package/src/dex/generated/index.ts +16 -0
- package/src/dex/generated/instructions/buyExactIn.ts +815 -0
- package/src/dex/generated/instructions/buyExactOut.ts +815 -0
- package/src/dex/generated/instructions/claimCreatorFees.ts +648 -0
- package/src/dex/generated/instructions/claimProtocolFees.ts +640 -0
- package/src/dex/generated/instructions/index.ts +15 -0
- package/src/dex/generated/instructions/sellExactIn.ts +815 -0
- package/src/dex/generated/instructions/sellExactOut.ts +815 -0
- package/src/dex/generated/instructions/sendDex.instructions.ts +173 -0
- package/src/dex/generated/pdas/eventAuthority.ts +20 -0
- package/src/dex/generated/pdas/globalConfig.ts +20 -0
- package/src/dex/generated/pdas/index.ts +14 -0
- package/src/dex/generated/pdas/lpMint.ts +36 -0
- package/src/dex/generated/pdas/pool.ts +34 -0
- package/src/dex/generated/pdas/rewardAccrual.ts +37 -0
- package/src/dex/generated/pdas/wsolRewardAccrual.ts +20 -0
- package/src/dex/generated/plugins/index.ts +9 -0
- package/src/dex/generated/plugins/sendDex.ts +282 -0
- package/src/dex/generated/programs/index.ts +9 -0
- package/src/dex/generated/programs/sendDex.ts +12 -0
- package/src/dex/generated/types/index.ts +10 -0
- package/src/dex/generated/types/poolStatus.ts +38 -0
- package/src/dex/generated/types/tradeDirection.ts +38 -0
- package/src/dex/index.ts +8 -0
- package/src/dex/trade.ts +215 -0
- package/src/index.ts +8 -0
- package/src/launchpad/create.ts +116 -0
- package/src/launchpad/generated/accounts/bondingCurve.ts +273 -0
- package/src/launchpad/generated/accounts/globalConfig.ts +211 -0
- package/src/launchpad/generated/accounts/index.ts +12 -0
- package/src/launchpad/generated/accounts/rewardAccrual.ts +191 -0
- package/src/launchpad/generated/accounts/sendLaunchpad.accounts.ts +50 -0
- package/src/launchpad/generated/errors/index.ts +9 -0
- package/src/launchpad/generated/errors/sendLaunchpad.ts +175 -0
- package/src/launchpad/generated/events/anchorEventCpiDiscriminator.framing.ts +28 -0
- package/src/launchpad/generated/events/completeEvent.ts +120 -0
- package/src/launchpad/generated/events/creatorClaimEvent.ts +122 -0
- package/src/launchpad/generated/events/index.ts +17 -0
- package/src/launchpad/generated/events/migrateEvent.ts +121 -0
- package/src/launchpad/generated/events/protocolClaimEvent.ts +114 -0
- package/src/launchpad/generated/events/recycleEvent.ts +113 -0
- package/src/launchpad/generated/events/sendLaunchpad.events.ts +207 -0
- package/src/launchpad/generated/events/tokenCreateEvent.ts +156 -0
- package/src/launchpad/generated/events/tradeEvent.ts +148 -0
- package/src/launchpad/generated/index.ts +16 -0
- package/src/launchpad/generated/instructions/buyExactIn.ts +818 -0
- package/src/launchpad/generated/instructions/buyExactOut.ts +818 -0
- package/src/launchpad/generated/instructions/claimCreatorFees.ts +651 -0
- package/src/launchpad/generated/instructions/claimProtocolFees.ts +640 -0
- package/src/launchpad/generated/instructions/createToken.ts +1150 -0
- package/src/launchpad/generated/instructions/index.ts +17 -0
- package/src/launchpad/generated/instructions/migrate.ts +840 -0
- package/src/launchpad/generated/instructions/sellExactIn.ts +818 -0
- package/src/launchpad/generated/instructions/sellExactOut.ts +818 -0
- package/src/launchpad/generated/instructions/sendLaunchpad.instructions.ts +210 -0
- package/src/launchpad/generated/pdas/bondingCurve.ts +39 -0
- package/src/launchpad/generated/pdas/eventAuthority.ts +20 -0
- package/src/launchpad/generated/pdas/globalConfig.ts +20 -0
- package/src/launchpad/generated/pdas/index.ts +14 -0
- package/src/launchpad/generated/pdas/migrationAuthority.ts +20 -0
- package/src/launchpad/generated/pdas/rewardAccrual.ts +37 -0
- package/src/launchpad/generated/pdas/wsolRewardAccrual.ts +20 -0
- package/src/launchpad/generated/plugins/index.ts +9 -0
- package/src/launchpad/generated/plugins/sendLaunchpad.ts +315 -0
- package/src/launchpad/generated/programs/index.ts +9 -0
- package/src/launchpad/generated/programs/sendLaunchpad.ts +12 -0
- package/src/launchpad/generated/types/bondingCurveStatus.ts +43 -0
- package/src/launchpad/generated/types/index.ts +10 -0
- package/src/launchpad/generated/types/tradeDirection.ts +38 -0
- package/src/launchpad/index.ts +10 -0
- package/src/launchpad/migrate.ts +54 -0
- package/src/launchpad/trade.ts +247 -0
- package/src/math/amm.ts +511 -0
- package/src/math/fee-decay.ts +49 -0
- package/src/math/fees.ts +75 -0
- package/src/math/index.ts +3 -0
- package/src/math/internal.ts +16 -0
- package/src/nexus/fee-helpers.ts +49 -0
- package/src/nexus/generated/accounts/altRegistry.ts +177 -0
- package/src/nexus/generated/accounts/creatorFeeConfig.ts +200 -0
- package/src/nexus/generated/accounts/feePreset.ts +196 -0
- package/src/nexus/generated/accounts/globalConfig.ts +188 -0
- package/src/nexus/generated/accounts/index.ts +19 -0
- package/src/nexus/generated/accounts/partnerConfig.ts +209 -0
- package/src/nexus/generated/accounts/partnerMetadata.ts +216 -0
- package/src/nexus/generated/accounts/rewardState.ts +209 -0
- package/src/nexus/generated/accounts/sendNexus.accounts.ts +85 -0
- package/src/nexus/generated/accounts/stakingConfig.ts +197 -0
- package/src/nexus/generated/accounts/userRewardDebt.ts +221 -0
- package/src/nexus/generated/accounts/userStakePosition.ts +218 -0
- package/src/nexus/generated/constants/index.ts +9 -0
- package/src/nexus/generated/constants/sendNexus.ts +13 -0
- package/src/nexus/generated/errors/index.ts +9 -0
- package/src/nexus/generated/errors/sendNexus.ts +229 -0
- package/src/nexus/generated/events/anchorEventCpiDiscriminator.framing.ts +28 -0
- package/src/nexus/generated/events/claimEvent.ts +106 -0
- package/src/nexus/generated/events/index.ts +13 -0
- package/src/nexus/generated/events/sendNexus.events.ts +121 -0
- package/src/nexus/generated/events/stakeEvent.ts +106 -0
- package/src/nexus/generated/events/unstakeEvent.ts +106 -0
- package/src/nexus/generated/index.ts +17 -0
- package/src/nexus/generated/instructions/claim.ts +740 -0
- package/src/nexus/generated/instructions/createUserRewardDebt.ts +498 -0
- package/src/nexus/generated/instructions/index.ts +14 -0
- package/src/nexus/generated/instructions/sendNexus.instructions.ts +146 -0
- package/src/nexus/generated/instructions/settle.ts +517 -0
- package/src/nexus/generated/instructions/stake.ts +615 -0
- package/src/nexus/generated/instructions/unstake.ts +593 -0
- package/src/nexus/generated/pdas/altRegistry.ts +20 -0
- package/src/nexus/generated/pdas/creatorFeeConfig.ts +39 -0
- package/src/nexus/generated/pdas/defaultFeePreset.ts +37 -0
- package/src/nexus/generated/pdas/defaultPartner.ts +40 -0
- package/src/nexus/generated/pdas/defaultPartnerMetadata.ts +42 -0
- package/src/nexus/generated/pdas/eventAuthority.ts +20 -0
- package/src/nexus/generated/pdas/feePreset.ts +39 -0
- package/src/nexus/generated/pdas/globalConfig.ts +20 -0
- package/src/nexus/generated/pdas/index.ts +22 -0
- package/src/nexus/generated/pdas/partnerConfig.ts +36 -0
- package/src/nexus/generated/pdas/partnerMetadata.ts +38 -0
- package/src/nexus/generated/pdas/rewardState.ts +36 -0
- package/src/nexus/generated/pdas/stakingConfig.ts +20 -0
- package/src/nexus/generated/pdas/userRewardDebt.ts +41 -0
- package/src/nexus/generated/pdas/userStakePosition.ts +39 -0
- package/src/nexus/generated/plugins/index.ts +9 -0
- package/src/nexus/generated/plugins/sendNexus.ts +494 -0
- package/src/nexus/generated/programs/index.ts +9 -0
- package/src/nexus/generated/programs/sendNexus.ts +12 -0
- package/src/nexus/generated/types/authPlatformEntry.ts +52 -0
- package/src/nexus/generated/types/callerType.ts +38 -0
- package/src/nexus/generated/types/dexFees.ts +64 -0
- package/src/nexus/generated/types/feeConfig.ts +73 -0
- package/src/nexus/generated/types/index.ts +13 -0
- package/src/nexus/generated/types/launchpadFees.ts +63 -0
- package/src/nexus/index.ts +9 -0
- package/src/nexus/staking.ts +581 -0
- package/src/platform.ts +19 -0
- package/src/transfer-fee.ts +216 -0
- package/src/utils/chunk.ts +21 -0
- package/src/utils/creator-hash.ts +57 -0
- package/src/utils/index.ts +9 -0
- package/src/utils/mint-info.ts +102 -0
- package/src/utils/partner.ts +5 -0
- package/src/utils/pda.ts +24 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __exportAll as t };
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@send-fun/sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Kit-native TypeScript SDK for send.fun",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"dex",
|
|
7
|
+
"launchpad",
|
|
8
|
+
"sdk",
|
|
9
|
+
"send",
|
|
10
|
+
"solana"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://send.fun",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/send-fun/sendfun-sdk-typescript/issues"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/send-fun/sendfun-sdk-typescript.git"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"src"
|
|
24
|
+
],
|
|
25
|
+
"type": "module",
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"main": "./dist/index.cjs",
|
|
28
|
+
"module": "./dist/index.mjs",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"import": {
|
|
32
|
+
"types": "./dist/index.d.mts",
|
|
33
|
+
"default": "./dist/index.mjs"
|
|
34
|
+
},
|
|
35
|
+
"require": {
|
|
36
|
+
"types": "./dist/index.d.cts",
|
|
37
|
+
"default": "./dist/index.cjs"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@solana/kit": "^6.10.0",
|
|
47
|
+
"@solana/program-client-core": "^6.10.0",
|
|
48
|
+
"@types/node": "^24.10.4",
|
|
49
|
+
"@typescript/native-preview": "7.0.0-dev.20260512.1",
|
|
50
|
+
"oxfmt": "^0.49.0",
|
|
51
|
+
"tsdown": "^0.23.0",
|
|
52
|
+
"tsx": "^4.21.0",
|
|
53
|
+
"typescript": "^6.0.3"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"@solana/kit": ">=6.10.0",
|
|
57
|
+
"@solana/program-client-core": ">=6.10.0"
|
|
58
|
+
},
|
|
59
|
+
"engines": {
|
|
60
|
+
"node": ">=20.18.0"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"build": "pnpm run clean && tsdown",
|
|
64
|
+
"clean": "rm -rf dist",
|
|
65
|
+
"dev": "tsdown --watch",
|
|
66
|
+
"format": "oxfmt --write",
|
|
67
|
+
"format:check": "oxfmt --check",
|
|
68
|
+
"test": "tsx --test 'tests/**/*.test.ts'",
|
|
69
|
+
"typecheck": "tsgo"
|
|
70
|
+
},
|
|
71
|
+
"types": "./dist/index.d.cts"
|
|
72
|
+
}
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { address } from '@solana/kit';
|
|
2
|
+
import type { Address } from '@solana/kit';
|
|
3
|
+
import { SEND_DEX_PROGRAM_ADDRESS } from './dex/generated/programs/index.js';
|
|
4
|
+
import { SEND_LAUNCHPAD_PROGRAM_ADDRESS } from './launchpad/generated/programs/index.js';
|
|
5
|
+
import { SEND_NEXUS_PROGRAM_ADDRESS } from './nexus/generated/programs/index.js';
|
|
6
|
+
|
|
7
|
+
export const TOKEN_DECIMALS = 6;
|
|
8
|
+
|
|
9
|
+
export { SEND_LAUNCHPAD_PROGRAM_ADDRESS };
|
|
10
|
+
export { SEND_DEX_PROGRAM_ADDRESS };
|
|
11
|
+
export { SEND_NEXUS_PROGRAM_ADDRESS };
|
|
12
|
+
|
|
13
|
+
export const SYSTEM_PROGRAM_ADDRESS: Address<'11111111111111111111111111111111'> =
|
|
14
|
+
address('11111111111111111111111111111111');
|
|
15
|
+
|
|
16
|
+
export const TOKEN_PROGRAM_ADDRESS: Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'> =
|
|
17
|
+
address('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA');
|
|
18
|
+
|
|
19
|
+
export const TOKEN_2022_PROGRAM_ADDRESS: Address<'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb'> =
|
|
20
|
+
address('TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb');
|
|
21
|
+
|
|
22
|
+
export const ASSOCIATED_TOKEN_PROGRAM_ADDRESS: Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'> =
|
|
23
|
+
address('ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL');
|
|
24
|
+
|
|
25
|
+
export const WSOL_MINT: Address = address(
|
|
26
|
+
'So11111111111111111111111111111111111111112',
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
export const USDC_MINT: Address = address(
|
|
30
|
+
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
export const DEFAULT_PARTNER: Address<'11111111111111111111111111111111'> =
|
|
34
|
+
SYSTEM_PROGRAM_ADDRESS;
|
|
35
|
+
|
|
36
|
+
export const PYTH_SOL_USD_PRICE_ACCOUNT: Address = address(
|
|
37
|
+
'7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE',
|
|
38
|
+
);
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
assertAccountExists,
|
|
11
|
+
assertAccountsExist,
|
|
12
|
+
combineCodec,
|
|
13
|
+
containsBytes,
|
|
14
|
+
decodeAccount,
|
|
15
|
+
fetchEncodedAccount,
|
|
16
|
+
fetchEncodedAccounts,
|
|
17
|
+
fixDecoderSize,
|
|
18
|
+
fixEncoderSize,
|
|
19
|
+
getAddressDecoder,
|
|
20
|
+
getAddressEncoder,
|
|
21
|
+
getBooleanDecoder,
|
|
22
|
+
getBooleanEncoder,
|
|
23
|
+
getBytesDecoder,
|
|
24
|
+
getBytesEncoder,
|
|
25
|
+
getStructDecoder,
|
|
26
|
+
getStructEncoder,
|
|
27
|
+
getU8Decoder,
|
|
28
|
+
getU8Encoder,
|
|
29
|
+
transformEncoder,
|
|
30
|
+
type Account,
|
|
31
|
+
type Address,
|
|
32
|
+
type EncodedAccount,
|
|
33
|
+
type FetchAccountConfig,
|
|
34
|
+
type FetchAccountsConfig,
|
|
35
|
+
type FixedSizeCodec,
|
|
36
|
+
type FixedSizeDecoder,
|
|
37
|
+
type FixedSizeEncoder,
|
|
38
|
+
type MaybeAccount,
|
|
39
|
+
type MaybeEncodedAccount,
|
|
40
|
+
type ReadonlyUint8Array,
|
|
41
|
+
} from '@solana/kit';
|
|
42
|
+
import { SEND_DEX_PROGRAM_ADDRESS } from '../programs/index.js';
|
|
43
|
+
|
|
44
|
+
export const GLOBAL_CONFIG_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
|
|
45
|
+
149, 8, 156, 202, 160, 252, 176, 217,
|
|
46
|
+
]);
|
|
47
|
+
|
|
48
|
+
export function getGlobalConfigDiscriminatorBytes(): ReadonlyUint8Array {
|
|
49
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
50
|
+
GLOBAL_CONFIG_DISCRIMINATOR,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type GlobalConfig = {
|
|
55
|
+
discriminator: ReadonlyUint8Array;
|
|
56
|
+
version: number;
|
|
57
|
+
bump: number;
|
|
58
|
+
authority: Address;
|
|
59
|
+
operator: Address;
|
|
60
|
+
createTokenDisabled: boolean;
|
|
61
|
+
reserved: ReadonlyUint8Array;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export type GlobalConfigArgs = {
|
|
65
|
+
version: number;
|
|
66
|
+
bump: number;
|
|
67
|
+
authority: Address;
|
|
68
|
+
operator: Address;
|
|
69
|
+
createTokenDisabled: boolean;
|
|
70
|
+
reserved: ReadonlyUint8Array;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/** Gets the encoder for {@link GlobalConfigArgs} account data. */
|
|
74
|
+
export function getGlobalConfigEncoder(): FixedSizeEncoder<GlobalConfigArgs> {
|
|
75
|
+
return transformEncoder(
|
|
76
|
+
getStructEncoder([
|
|
77
|
+
['discriminator', fixEncoderSize(getBytesEncoder(), 8)],
|
|
78
|
+
['version', getU8Encoder()],
|
|
79
|
+
['bump', getU8Encoder()],
|
|
80
|
+
['authority', getAddressEncoder()],
|
|
81
|
+
['operator', getAddressEncoder()],
|
|
82
|
+
['createTokenDisabled', getBooleanEncoder()],
|
|
83
|
+
['reserved', fixEncoderSize(getBytesEncoder(), 64)],
|
|
84
|
+
]),
|
|
85
|
+
(value) => ({ ...value, discriminator: GLOBAL_CONFIG_DISCRIMINATOR }),
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Gets the decoder for {@link GlobalConfig} account data. */
|
|
90
|
+
export function getGlobalConfigDecoder(): FixedSizeDecoder<GlobalConfig> {
|
|
91
|
+
return getStructDecoder([
|
|
92
|
+
['discriminator', fixDecoderSize(getBytesDecoder(), 8)],
|
|
93
|
+
['version', getU8Decoder()],
|
|
94
|
+
['bump', getU8Decoder()],
|
|
95
|
+
['authority', getAddressDecoder()],
|
|
96
|
+
['operator', getAddressDecoder()],
|
|
97
|
+
['createTokenDisabled', getBooleanDecoder()],
|
|
98
|
+
['reserved', fixDecoderSize(getBytesDecoder(), 64)],
|
|
99
|
+
]);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Gets the codec for {@link GlobalConfig} account data. */
|
|
103
|
+
export function getGlobalConfigCodec(): FixedSizeCodec<
|
|
104
|
+
GlobalConfigArgs,
|
|
105
|
+
GlobalConfig
|
|
106
|
+
> {
|
|
107
|
+
return combineCodec(getGlobalConfigEncoder(), getGlobalConfigDecoder());
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function decodeGlobalConfig<TAddress extends string = string>(
|
|
111
|
+
encodedAccount: EncodedAccount<TAddress>,
|
|
112
|
+
): Account<GlobalConfig, TAddress>;
|
|
113
|
+
export function decodeGlobalConfig<TAddress extends string = string>(
|
|
114
|
+
encodedAccount: MaybeEncodedAccount<TAddress>,
|
|
115
|
+
): MaybeAccount<GlobalConfig, TAddress>;
|
|
116
|
+
export function decodeGlobalConfig<TAddress extends string = string>(
|
|
117
|
+
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>,
|
|
118
|
+
): Account<GlobalConfig, TAddress> | MaybeAccount<GlobalConfig, TAddress> {
|
|
119
|
+
if (!('exists' in encodedAccount) || encodedAccount.exists) {
|
|
120
|
+
if (encodedAccount.programAddress !== SEND_DEX_PROGRAM_ADDRESS) {
|
|
121
|
+
const error = new Error(
|
|
122
|
+
`decodeGlobalConfig: account ${encodedAccount.address} is owned by ${encodedAccount.programAddress}, expected ${SEND_DEX_PROGRAM_ADDRESS}`,
|
|
123
|
+
);
|
|
124
|
+
error.name = 'AccountOwnerMismatchError';
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
if (
|
|
128
|
+
!containsBytes(encodedAccount.data, GLOBAL_CONFIG_DISCRIMINATOR, 0)
|
|
129
|
+
) {
|
|
130
|
+
const error = new Error(
|
|
131
|
+
`decodeGlobalConfig: account ${encodedAccount.address} does not match the GlobalConfig discriminator`,
|
|
132
|
+
);
|
|
133
|
+
error.name = 'AccountDiscriminatorMismatchError';
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return decodeAccount(
|
|
138
|
+
encodedAccount as MaybeEncodedAccount<TAddress>,
|
|
139
|
+
getGlobalConfigDecoder(),
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export async function fetchGlobalConfig<TAddress extends string = string>(
|
|
144
|
+
rpc: Parameters<typeof fetchEncodedAccount>[0],
|
|
145
|
+
address: Address<TAddress>,
|
|
146
|
+
config?: FetchAccountConfig,
|
|
147
|
+
): Promise<Account<GlobalConfig, TAddress>> {
|
|
148
|
+
const maybeAccount = await fetchMaybeGlobalConfig(rpc, address, config);
|
|
149
|
+
assertAccountExists(maybeAccount);
|
|
150
|
+
return maybeAccount;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export async function fetchMaybeGlobalConfig<TAddress extends string = string>(
|
|
154
|
+
rpc: Parameters<typeof fetchEncodedAccount>[0],
|
|
155
|
+
address: Address<TAddress>,
|
|
156
|
+
config?: FetchAccountConfig,
|
|
157
|
+
): Promise<MaybeAccount<GlobalConfig, TAddress>> {
|
|
158
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
159
|
+
return decodeGlobalConfig(maybeAccount);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export async function fetchAllGlobalConfig(
|
|
163
|
+
rpc: Parameters<typeof fetchEncodedAccounts>[0],
|
|
164
|
+
addresses: Array<Address>,
|
|
165
|
+
config?: FetchAccountsConfig,
|
|
166
|
+
): Promise<Account<GlobalConfig>[]> {
|
|
167
|
+
const maybeAccounts = await fetchAllMaybeGlobalConfig(
|
|
168
|
+
rpc,
|
|
169
|
+
addresses,
|
|
170
|
+
config,
|
|
171
|
+
);
|
|
172
|
+
assertAccountsExist(maybeAccounts);
|
|
173
|
+
return maybeAccounts;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export async function fetchAllMaybeGlobalConfig(
|
|
177
|
+
rpc: Parameters<typeof fetchEncodedAccounts>[0],
|
|
178
|
+
addresses: Array<Address>,
|
|
179
|
+
config?: FetchAccountsConfig,
|
|
180
|
+
): Promise<MaybeAccount<GlobalConfig>[]> {
|
|
181
|
+
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
|
|
182
|
+
return maybeAccounts.map((maybeAccount) =>
|
|
183
|
+
decodeGlobalConfig(maybeAccount),
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function getGlobalConfigSize(): number {
|
|
188
|
+
return 139;
|
|
189
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export * from './globalConfig.js';
|
|
10
|
+
export * from './pool.js';
|
|
11
|
+
export * from './rewardAccrual.js';
|
|
12
|
+
export * from './sendDex.accounts.js';
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
assertAccountExists,
|
|
11
|
+
assertAccountsExist,
|
|
12
|
+
combineCodec,
|
|
13
|
+
containsBytes,
|
|
14
|
+
decodeAccount,
|
|
15
|
+
fetchEncodedAccount,
|
|
16
|
+
fetchEncodedAccounts,
|
|
17
|
+
fixDecoderSize,
|
|
18
|
+
fixEncoderSize,
|
|
19
|
+
getAddressDecoder,
|
|
20
|
+
getAddressEncoder,
|
|
21
|
+
getBytesDecoder,
|
|
22
|
+
getBytesEncoder,
|
|
23
|
+
getI64Decoder,
|
|
24
|
+
getI64Encoder,
|
|
25
|
+
getStructDecoder,
|
|
26
|
+
getStructEncoder,
|
|
27
|
+
getU64Decoder,
|
|
28
|
+
getU64Encoder,
|
|
29
|
+
getU8Decoder,
|
|
30
|
+
getU8Encoder,
|
|
31
|
+
transformEncoder,
|
|
32
|
+
type Account,
|
|
33
|
+
type Address,
|
|
34
|
+
type EncodedAccount,
|
|
35
|
+
type FetchAccountConfig,
|
|
36
|
+
type FetchAccountsConfig,
|
|
37
|
+
type FixedSizeCodec,
|
|
38
|
+
type FixedSizeDecoder,
|
|
39
|
+
type FixedSizeEncoder,
|
|
40
|
+
type MaybeAccount,
|
|
41
|
+
type MaybeEncodedAccount,
|
|
42
|
+
type ReadonlyUint8Array,
|
|
43
|
+
} from '@solana/kit';
|
|
44
|
+
import { SEND_DEX_PROGRAM_ADDRESS } from '../programs/index.js';
|
|
45
|
+
import {
|
|
46
|
+
getPoolStatusDecoder,
|
|
47
|
+
getPoolStatusEncoder,
|
|
48
|
+
type PoolStatus,
|
|
49
|
+
type PoolStatusArgs,
|
|
50
|
+
} from '../types/index.js';
|
|
51
|
+
|
|
52
|
+
export const POOL_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
|
|
53
|
+
241, 154, 109, 4, 17, 177, 109, 188,
|
|
54
|
+
]);
|
|
55
|
+
|
|
56
|
+
export function getPoolDiscriminatorBytes(): ReadonlyUint8Array {
|
|
57
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(POOL_DISCRIMINATOR);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type Pool = {
|
|
61
|
+
discriminator: ReadonlyUint8Array;
|
|
62
|
+
version: number;
|
|
63
|
+
bump: number;
|
|
64
|
+
status: PoolStatus;
|
|
65
|
+
baseMint: Address;
|
|
66
|
+
baseDecimals: number;
|
|
67
|
+
quoteMint: Address;
|
|
68
|
+
quoteDecimals: number;
|
|
69
|
+
coinCreator: Address;
|
|
70
|
+
creatorFeeConfig: Address;
|
|
71
|
+
baseVault: Address;
|
|
72
|
+
quoteVault: Address;
|
|
73
|
+
lpMint: Address;
|
|
74
|
+
lpSupply: bigint;
|
|
75
|
+
baseReserves: bigint;
|
|
76
|
+
quoteReserves: bigint;
|
|
77
|
+
quoteLedger: bigint;
|
|
78
|
+
createdAt: bigint;
|
|
79
|
+
protocolOwed: bigint;
|
|
80
|
+
creatorOwed: bigint;
|
|
81
|
+
platformConfig: Address;
|
|
82
|
+
reserved: ReadonlyUint8Array;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export type PoolArgs = {
|
|
86
|
+
version: number;
|
|
87
|
+
bump: number;
|
|
88
|
+
status: PoolStatusArgs;
|
|
89
|
+
baseMint: Address;
|
|
90
|
+
baseDecimals: number;
|
|
91
|
+
quoteMint: Address;
|
|
92
|
+
quoteDecimals: number;
|
|
93
|
+
coinCreator: Address;
|
|
94
|
+
creatorFeeConfig: Address;
|
|
95
|
+
baseVault: Address;
|
|
96
|
+
quoteVault: Address;
|
|
97
|
+
lpMint: Address;
|
|
98
|
+
lpSupply: number | bigint;
|
|
99
|
+
baseReserves: number | bigint;
|
|
100
|
+
quoteReserves: number | bigint;
|
|
101
|
+
quoteLedger: number | bigint;
|
|
102
|
+
createdAt: number | bigint;
|
|
103
|
+
protocolOwed: number | bigint;
|
|
104
|
+
creatorOwed: number | bigint;
|
|
105
|
+
platformConfig: Address;
|
|
106
|
+
reserved: ReadonlyUint8Array;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/** Gets the encoder for {@link PoolArgs} account data. */
|
|
110
|
+
export function getPoolEncoder(): FixedSizeEncoder<PoolArgs> {
|
|
111
|
+
return transformEncoder(
|
|
112
|
+
getStructEncoder([
|
|
113
|
+
['discriminator', fixEncoderSize(getBytesEncoder(), 8)],
|
|
114
|
+
['version', getU8Encoder()],
|
|
115
|
+
['bump', getU8Encoder()],
|
|
116
|
+
['status', getPoolStatusEncoder()],
|
|
117
|
+
['baseMint', getAddressEncoder()],
|
|
118
|
+
['baseDecimals', getU8Encoder()],
|
|
119
|
+
['quoteMint', getAddressEncoder()],
|
|
120
|
+
['quoteDecimals', getU8Encoder()],
|
|
121
|
+
['coinCreator', getAddressEncoder()],
|
|
122
|
+
['creatorFeeConfig', getAddressEncoder()],
|
|
123
|
+
['baseVault', getAddressEncoder()],
|
|
124
|
+
['quoteVault', getAddressEncoder()],
|
|
125
|
+
['lpMint', getAddressEncoder()],
|
|
126
|
+
['lpSupply', getU64Encoder()],
|
|
127
|
+
['baseReserves', getU64Encoder()],
|
|
128
|
+
['quoteReserves', getU64Encoder()],
|
|
129
|
+
['quoteLedger', getU64Encoder()],
|
|
130
|
+
['createdAt', getI64Encoder()],
|
|
131
|
+
['protocolOwed', getU64Encoder()],
|
|
132
|
+
['creatorOwed', getU64Encoder()],
|
|
133
|
+
['platformConfig', getAddressEncoder()],
|
|
134
|
+
['reserved', fixEncoderSize(getBytesEncoder(), 64)],
|
|
135
|
+
]),
|
|
136
|
+
(value) => ({ ...value, discriminator: POOL_DISCRIMINATOR }),
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Gets the decoder for {@link Pool} account data. */
|
|
141
|
+
export function getPoolDecoder(): FixedSizeDecoder<Pool> {
|
|
142
|
+
return getStructDecoder([
|
|
143
|
+
['discriminator', fixDecoderSize(getBytesDecoder(), 8)],
|
|
144
|
+
['version', getU8Decoder()],
|
|
145
|
+
['bump', getU8Decoder()],
|
|
146
|
+
['status', getPoolStatusDecoder()],
|
|
147
|
+
['baseMint', getAddressDecoder()],
|
|
148
|
+
['baseDecimals', getU8Decoder()],
|
|
149
|
+
['quoteMint', getAddressDecoder()],
|
|
150
|
+
['quoteDecimals', getU8Decoder()],
|
|
151
|
+
['coinCreator', getAddressDecoder()],
|
|
152
|
+
['creatorFeeConfig', getAddressDecoder()],
|
|
153
|
+
['baseVault', getAddressDecoder()],
|
|
154
|
+
['quoteVault', getAddressDecoder()],
|
|
155
|
+
['lpMint', getAddressDecoder()],
|
|
156
|
+
['lpSupply', getU64Decoder()],
|
|
157
|
+
['baseReserves', getU64Decoder()],
|
|
158
|
+
['quoteReserves', getU64Decoder()],
|
|
159
|
+
['quoteLedger', getU64Decoder()],
|
|
160
|
+
['createdAt', getI64Decoder()],
|
|
161
|
+
['protocolOwed', getU64Decoder()],
|
|
162
|
+
['creatorOwed', getU64Decoder()],
|
|
163
|
+
['platformConfig', getAddressDecoder()],
|
|
164
|
+
['reserved', fixDecoderSize(getBytesDecoder(), 64)],
|
|
165
|
+
]);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** Gets the codec for {@link Pool} account data. */
|
|
169
|
+
export function getPoolCodec(): FixedSizeCodec<PoolArgs, Pool> {
|
|
170
|
+
return combineCodec(getPoolEncoder(), getPoolDecoder());
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export function decodePool<TAddress extends string = string>(
|
|
174
|
+
encodedAccount: EncodedAccount<TAddress>,
|
|
175
|
+
): Account<Pool, TAddress>;
|
|
176
|
+
export function decodePool<TAddress extends string = string>(
|
|
177
|
+
encodedAccount: MaybeEncodedAccount<TAddress>,
|
|
178
|
+
): MaybeAccount<Pool, TAddress>;
|
|
179
|
+
export function decodePool<TAddress extends string = string>(
|
|
180
|
+
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>,
|
|
181
|
+
): Account<Pool, TAddress> | MaybeAccount<Pool, TAddress> {
|
|
182
|
+
if (!('exists' in encodedAccount) || encodedAccount.exists) {
|
|
183
|
+
if (encodedAccount.programAddress !== SEND_DEX_PROGRAM_ADDRESS) {
|
|
184
|
+
const error = new Error(
|
|
185
|
+
`decodePool: account ${encodedAccount.address} is owned by ${encodedAccount.programAddress}, expected ${SEND_DEX_PROGRAM_ADDRESS}`,
|
|
186
|
+
);
|
|
187
|
+
error.name = 'AccountOwnerMismatchError';
|
|
188
|
+
throw error;
|
|
189
|
+
}
|
|
190
|
+
if (!containsBytes(encodedAccount.data, POOL_DISCRIMINATOR, 0)) {
|
|
191
|
+
const error = new Error(
|
|
192
|
+
`decodePool: account ${encodedAccount.address} does not match the Pool discriminator`,
|
|
193
|
+
);
|
|
194
|
+
error.name = 'AccountDiscriminatorMismatchError';
|
|
195
|
+
throw error;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return decodeAccount(
|
|
199
|
+
encodedAccount as MaybeEncodedAccount<TAddress>,
|
|
200
|
+
getPoolDecoder(),
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export async function fetchPool<TAddress extends string = string>(
|
|
205
|
+
rpc: Parameters<typeof fetchEncodedAccount>[0],
|
|
206
|
+
address: Address<TAddress>,
|
|
207
|
+
config?: FetchAccountConfig,
|
|
208
|
+
): Promise<Account<Pool, TAddress>> {
|
|
209
|
+
const maybeAccount = await fetchMaybePool(rpc, address, config);
|
|
210
|
+
assertAccountExists(maybeAccount);
|
|
211
|
+
return maybeAccount;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export async function fetchMaybePool<TAddress extends string = string>(
|
|
215
|
+
rpc: Parameters<typeof fetchEncodedAccount>[0],
|
|
216
|
+
address: Address<TAddress>,
|
|
217
|
+
config?: FetchAccountConfig,
|
|
218
|
+
): Promise<MaybeAccount<Pool, TAddress>> {
|
|
219
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
220
|
+
return decodePool(maybeAccount);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export async function fetchAllPool(
|
|
224
|
+
rpc: Parameters<typeof fetchEncodedAccounts>[0],
|
|
225
|
+
addresses: Array<Address>,
|
|
226
|
+
config?: FetchAccountsConfig,
|
|
227
|
+
): Promise<Account<Pool>[]> {
|
|
228
|
+
const maybeAccounts = await fetchAllMaybePool(rpc, addresses, config);
|
|
229
|
+
assertAccountsExist(maybeAccounts);
|
|
230
|
+
return maybeAccounts;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export async function fetchAllMaybePool(
|
|
234
|
+
rpc: Parameters<typeof fetchEncodedAccounts>[0],
|
|
235
|
+
addresses: Array<Address>,
|
|
236
|
+
config?: FetchAccountsConfig,
|
|
237
|
+
): Promise<MaybeAccount<Pool>[]> {
|
|
238
|
+
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
|
|
239
|
+
return maybeAccounts.map((maybeAccount) => decodePool(maybeAccount));
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export function getPoolSize(): number {
|
|
243
|
+
return 389;
|
|
244
|
+
}
|