tbc-tx-parser 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/README.md +214 -0
- package/dist/adapters/partial-sha256.d.ts +2 -0
- package/dist/adapters/partial-sha256.d.ts.map +1 -0
- package/dist/adapters/partial-sha256.js +5 -0
- package/dist/adapters/partial-sha256.js.map +1 -0
- package/dist/adapters/tbc-lib.d.ts +4 -0
- package/dist/adapters/tbc-lib.d.ts.map +1 -0
- package/dist/adapters/tbc-lib.js +4 -0
- package/dist/adapters/tbc-lib.js.map +1 -0
- package/dist/constants/chain.d.ts +4 -0
- package/dist/constants/chain.d.ts.map +1 -0
- package/dist/constants/chain.js +7 -0
- package/dist/constants/chain.js.map +1 -0
- package/dist/core/chain.d.ts +10 -0
- package/dist/core/chain.d.ts.map +1 -0
- package/dist/core/chain.js +41 -0
- package/dist/core/chain.js.map +1 -0
- package/dist/core/input-utxos.d.ts +3 -0
- package/dist/core/input-utxos.d.ts.map +1 -0
- package/dist/core/input-utxos.js +69 -0
- package/dist/core/input-utxos.js.map +1 -0
- package/dist/core/public-chain-compression.d.ts +4 -0
- package/dist/core/public-chain-compression.d.ts.map +1 -0
- package/dist/core/public-chain-compression.js +87 -0
- package/dist/core/public-chain-compression.js.map +1 -0
- package/dist/core/public-script.d.ts +4 -0
- package/dist/core/public-script.d.ts.map +1 -0
- package/dist/core/public-script.js +94 -0
- package/dist/core/public-script.js.map +1 -0
- package/dist/decode-tx-raw.d.ts +3 -0
- package/dist/decode-tx-raw.d.ts.map +1 -0
- package/dist/decode-tx-raw.js +350 -0
- package/dist/decode-tx-raw.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/protocols/ft/index.d.ts +7 -0
- package/dist/protocols/ft/index.d.ts.map +1 -0
- package/dist/protocols/ft/index.js +393 -0
- package/dist/protocols/ft/index.js.map +1 -0
- package/dist/protocols/index.d.ts +5 -0
- package/dist/protocols/index.d.ts.map +1 -0
- package/dist/protocols/index.js +61 -0
- package/dist/protocols/index.js.map +1 -0
- package/dist/protocols/nft/index.d.ts +8 -0
- package/dist/protocols/nft/index.d.ts.map +1 -0
- package/dist/protocols/nft/index.js +335 -0
- package/dist/protocols/nft/index.js.map +1 -0
- package/dist/protocols/nft/media.js.map +1 -0
- package/dist/protocols/order-book/actions.d.ts +7 -0
- package/dist/protocols/order-book/actions.d.ts.map +1 -0
- package/dist/protocols/order-book/actions.js +102 -0
- package/dist/protocols/order-book/actions.js.map +1 -0
- package/dist/protocols/order-book/facts.d.ts +7 -0
- package/dist/protocols/order-book/facts.d.ts.map +1 -0
- package/dist/protocols/order-book/facts.js +81 -0
- package/dist/protocols/order-book/facts.js.map +1 -0
- package/dist/protocols/order-book/identity.d.ts +3 -0
- package/dist/protocols/order-book/identity.d.ts.map +1 -0
- package/dist/protocols/order-book/identity.js +46 -0
- package/dist/protocols/order-book/identity.js.map +1 -0
- package/dist/protocols/order-book/index.d.ts +12 -0
- package/dist/protocols/order-book/index.d.ts.map +1 -0
- package/dist/protocols/order-book/index.js +34 -0
- package/dist/protocols/order-book/index.js.map +1 -0
- package/dist/protocols/order-book/settlement.d.ts +10 -0
- package/dist/protocols/order-book/settlement.d.ts.map +1 -0
- package/dist/protocols/order-book/settlement.js +318 -0
- package/dist/protocols/order-book/settlement.js.map +1 -0
- package/dist/protocols/order-book/types.d.ts +101 -0
- package/dist/protocols/order-book/types.d.ts.map +1 -0
- package/dist/protocols/order-book/types.js +2 -0
- package/dist/protocols/order-book/types.js.map +1 -0
- package/dist/protocols/piggy-bank/index.d.ts +7 -0
- package/dist/protocols/piggy-bank/index.d.ts.map +1 -0
- package/dist/protocols/piggy-bank/index.js +91 -0
- package/dist/protocols/piggy-bank/index.js.map +1 -0
- package/dist/protocols/pool-nft/actions.d.ts +15 -0
- package/dist/protocols/pool-nft/actions.d.ts.map +1 -0
- package/dist/protocols/pool-nft/actions.js +90 -0
- package/dist/protocols/pool-nft/actions.js.map +1 -0
- package/dist/protocols/pool-nft/amounts.d.ts +10 -0
- package/dist/protocols/pool-nft/amounts.d.ts.map +1 -0
- package/dist/protocols/pool-nft/amounts.js +45 -0
- package/dist/protocols/pool-nft/amounts.js.map +1 -0
- package/dist/protocols/pool-nft/constants.d.ts +15 -0
- package/dist/protocols/pool-nft/constants.d.ts.map +1 -0
- package/dist/protocols/pool-nft/constants.js +27 -0
- package/dist/protocols/pool-nft/constants.js.map +1 -0
- package/dist/protocols/pool-nft/facts.d.ts +11 -0
- package/dist/protocols/pool-nft/facts.d.ts.map +1 -0
- package/dist/protocols/pool-nft/facts.js +113 -0
- package/dist/protocols/pool-nft/facts.js.map +1 -0
- package/dist/protocols/pool-nft/fees.d.ts +14 -0
- package/dist/protocols/pool-nft/fees.d.ts.map +1 -0
- package/dist/protocols/pool-nft/fees.js +161 -0
- package/dist/protocols/pool-nft/fees.js.map +1 -0
- package/dist/protocols/pool-nft/index.d.ts +4 -0
- package/dist/protocols/pool-nft/index.d.ts.map +1 -0
- package/dist/protocols/pool-nft/index.js +19 -0
- package/dist/protocols/pool-nft/index.js.map +1 -0
- package/dist/protocols/pool-nft/movements.d.ts +5 -0
- package/dist/protocols/pool-nft/movements.d.ts.map +1 -0
- package/dist/protocols/pool-nft/movements.js +804 -0
- package/dist/protocols/pool-nft/movements.js.map +1 -0
- package/dist/protocols/pool-nft/selectors.d.ts +40 -0
- package/dist/protocols/pool-nft/selectors.d.ts.map +1 -0
- package/dist/protocols/pool-nft/selectors.js +173 -0
- package/dist/protocols/pool-nft/selectors.js.map +1 -0
- package/dist/protocols/pool-nft/types.d.ts +34 -0
- package/dist/protocols/pool-nft/types.d.ts.map +1 -0
- package/dist/protocols/pool-nft/types.js +2 -0
- package/dist/protocols/pool-nft/types.js.map +1 -0
- package/dist/protocols/tbc/index.d.ts +3 -0
- package/dist/protocols/tbc/index.d.ts.map +1 -0
- package/dist/protocols/tbc/index.js +21 -0
- package/dist/protocols/tbc/index.js.map +1 -0
- package/dist/protocols/types.d.ts +15 -0
- package/dist/protocols/types.d.ts.map +1 -0
- package/dist/protocols/types.js +2 -0
- package/dist/protocols/types.js.map +1 -0
- package/dist/result/index.d.ts +7 -0
- package/dist/result/index.d.ts.map +1 -0
- package/dist/result/index.js +869 -0
- package/dist/result/index.js.map +1 -0
- package/dist/result/semantic.d.ts +6 -0
- package/dist/result/semantic.d.ts.map +1 -0
- package/dist/result/semantic.js +950 -0
- package/dist/result/semantic.js.map +1 -0
- package/dist/script-parser/contracts.d.ts +7 -0
- package/dist/script-parser/contracts.d.ts.map +1 -0
- package/dist/script-parser/contracts.js +104 -0
- package/dist/script-parser/contracts.js.map +1 -0
- package/dist/script-parser/op-return.d.ts +8 -0
- package/dist/script-parser/op-return.d.ts.map +1 -0
- package/dist/script-parser/op-return.js +315 -0
- package/dist/script-parser/op-return.js.map +1 -0
- package/dist/script-parser/origin.d.ts +6 -0
- package/dist/script-parser/origin.d.ts.map +1 -0
- package/dist/script-parser/origin.js +68 -0
- package/dist/script-parser/origin.js.map +1 -0
- package/dist/script-parser.d.ts +3 -0
- package/dist/script-parser.d.ts.map +1 -0
- package/dist/script-parser.js +183 -0
- package/dist/script-parser.js.map +1 -0
- package/dist/types/protocol.d.ts +175 -0
- package/dist/types/protocol.d.ts.map +1 -0
- package/dist/types/protocol.js +2 -0
- package/dist/types/protocol.js.map +1 -0
- package/dist/types/result.d.ts +167 -0
- package/dist/types/result.d.ts.map +1 -0
- package/dist/types/result.js +2 -0
- package/dist/types/result.js.map +1 -0
- package/dist/types/script.d.ts +180 -0
- package/dist/types/script.d.ts.map +1 -0
- package/dist/types/script.js +9 -0
- package/dist/types/script.js.map +1 -0
- package/dist/types/semantic.d.ts +94 -0
- package/dist/types/semantic.d.ts.map +1 -0
- package/dist/types/semantic.js +2 -0
- package/dist/types/semantic.js.map +1 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/asm-converter.d.ts +7 -0
- package/dist/utils/asm-converter.d.ts.map +1 -0
- package/dist/utils/asm-converter.js +105 -0
- package/dist/utils/asm-converter.js.map +1 -0
- package/dist/utils/binary.d.ts +3 -0
- package/dist/utils/binary.d.ts.map +1 -0
- package/dist/utils/binary.js +17 -0
- package/dist/utils/binary.js.map +1 -0
- package/dist/utils/multi-sig.d.ts +9 -0
- package/dist/utils/multi-sig.d.ts.map +1 -0
- package/dist/utils/multi-sig.js +125 -0
- package/dist/utils/multi-sig.js.map +1 -0
- package/dist/utils/token-amount.d.ts +3 -0
- package/dist/utils/token-amount.d.ts.map +1 -0
- package/dist/utils/token-amount.js +37 -0
- package/dist/utils/token-amount.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
const FINAL_SEQUENCE = 0xffffffff;
|
|
2
|
+
export const piggyBankProtocolDecoder = {
|
|
3
|
+
id: 'PiggyBank',
|
|
4
|
+
analyze({ inputs, outputs }) {
|
|
5
|
+
// A PiggyBank output is a freeze candidate; a PiggyBank input prevout is an unfreeze candidate.
|
|
6
|
+
const hasFreezeOutput = outputs.some((output) => Boolean(output.script.data?.piggyBank));
|
|
7
|
+
const hasUnfreezeInput = inputs.some((input) => Boolean(input.prevout?.script.data?.piggyBank));
|
|
8
|
+
if (!hasFreezeOutput && !hasUnfreezeInput) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
id: this.id,
|
|
13
|
+
transactionType: hasUnfreezeInput ? 'PiggyBank unfreeze' : 'PiggyBank freeze',
|
|
14
|
+
priority: 95,
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
export function collectPiggyBankMovements(inputs, outputs, locktime) {
|
|
19
|
+
const unfreezeInputs = inputs.filter((input) => Boolean(input.prevout?.script.data?.piggyBank));
|
|
20
|
+
// Detect unfreeze first; only one PiggyBank input is supported and sequence, locktime, and release output must verify.
|
|
21
|
+
if (unfreezeInputs.length) {
|
|
22
|
+
if (unfreezeInputs.length !== 1) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
const unfreezeCandidates = unfreezeInputs
|
|
26
|
+
.map((input) => {
|
|
27
|
+
const piggyBank = input.prevout?.script.data?.piggyBank;
|
|
28
|
+
if (!piggyBank || input.prevout?.satoshis === undefined) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
if (input.sequence === FINAL_SEQUENCE || locktime < piggyBank.lockTime) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
input,
|
|
36
|
+
piggyBank,
|
|
37
|
+
satoshis: input.prevout.satoshis,
|
|
38
|
+
};
|
|
39
|
+
})
|
|
40
|
+
.filter((candidate) => Boolean(candidate));
|
|
41
|
+
if (unfreezeCandidates.length !== 1) {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
const { input, piggyBank, satoshis } = unfreezeCandidates[0];
|
|
45
|
+
const receiverOutputs = outputs.filter((output) => output.address === piggyBank.address && output.satoshis > 0);
|
|
46
|
+
if (receiverOutputs.length !== 1) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
const receiverOutput = receiverOutputs[0];
|
|
50
|
+
return [
|
|
51
|
+
{
|
|
52
|
+
action: 'unfreeze',
|
|
53
|
+
inputIndex: input.index,
|
|
54
|
+
address: piggyBank.address,
|
|
55
|
+
receiver: receiverOutput.address,
|
|
56
|
+
satoshis,
|
|
57
|
+
releasedSatoshis: receiverOutput.satoshis,
|
|
58
|
+
releaseOutputIndex: receiverOutput.index,
|
|
59
|
+
lockTime: piggyBank.lockTime,
|
|
60
|
+
lockTimeType: piggyBank.lockTimeType,
|
|
61
|
+
unlockHeight: locktime || undefined,
|
|
62
|
+
},
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
// Collect new freeze movements from outputs only when no unfreeze input is present.
|
|
66
|
+
return outputs
|
|
67
|
+
.map((output) => {
|
|
68
|
+
const piggyBank = output.script.data?.piggyBank;
|
|
69
|
+
if (!piggyBank || output.satoshis <= 0) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
action: 'freeze',
|
|
74
|
+
outputIndex: output.index,
|
|
75
|
+
address: piggyBank.address,
|
|
76
|
+
receiver: piggyBank.address,
|
|
77
|
+
satoshis: output.satoshis,
|
|
78
|
+
lockTime: piggyBank.lockTime,
|
|
79
|
+
lockTimeType: piggyBank.lockTimeType,
|
|
80
|
+
};
|
|
81
|
+
})
|
|
82
|
+
.filter((movement) => Boolean(movement));
|
|
83
|
+
}
|
|
84
|
+
export function inferPiggyBankTransactionType(movements) {
|
|
85
|
+
const firstMovement = movements[0];
|
|
86
|
+
if (!firstMovement) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
return firstMovement.action === 'unfreeze' ? 'PiggyBank unfreeze' : 'PiggyBank freeze';
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/protocols/piggy-bank/index.ts"],"names":[],"mappings":"AAIA,MAAM,cAAc,GAAG,UAAU,CAAC;AAQlC,MAAM,CAAC,MAAM,wBAAwB,GAAoB;IACvD,EAAE,EAAE,WAAW;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE;QACzB,gGAAgG;QAChG,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;QACzF,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,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AO;YACL,MAAM,EAAE,QAAQ;YAChB,WAAW,EAAE,MAAM,CAAC,KAAK;YACzB,OAAO,EAAE,SAAS,CAAC,OAAO;YAC1B,QAAQ,EAAE,SAAS,CAAC,OAAO;YAC3B,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,QAAQ,EAAE,SAAS,CAAC,QAAQ;YAC5B,YAAY,EAAE,SAAS,CAAC,YAAY;SACrC,CAAC;IACJ,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,QAAQ,EAAiC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,SAA8B;IAC1E,MAAM,aAAa,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IACnC,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,aAAa,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,kBAAkB,CAAC;AACzF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PoolNftAction, PoolNftActionMatch, PoolNftConfidence } from './types.js';
|
|
2
|
+
export declare function createPoolNftActionMatch(action: PoolNftAction, reasons: string[], confidence?: PoolNftConfidence): PoolNftActionMatch;
|
|
3
|
+
export declare function downgradePoolNftMatch(match: PoolNftActionMatch, reason: string): PoolNftActionMatch;
|
|
4
|
+
export declare function actionRequiresExistingPoolState(action: PoolNftAction): action is "increaseLiquidity" | "consumeLiquidity" | "swapTbcToFt" | "swapFtToTbc" | "mergeFtInPool";
|
|
5
|
+
export declare function actionRequiresFtContractMatch(action: PoolNftAction): action is "init" | "increaseLiquidity" | "consumeLiquidity" | "swapTbcToFt" | "swapFtToTbc" | "mergeFtInPool";
|
|
6
|
+
export declare function actionRequiresLiquidityAmountMatch(action: PoolNftAction): action is "init" | "increaseLiquidity";
|
|
7
|
+
export declare function actionRequiresLpTokenIdentityMatch(action: PoolNftAction): action is "init" | "increaseLiquidity" | "consumeLiquidity";
|
|
8
|
+
export declare function actionRequiresTbcReserveIncrease(action: PoolNftAction): action is "increaseLiquidity" | "swapTbcToFt";
|
|
9
|
+
export declare function actionRequiresTbcReserveDecrease(action: PoolNftAction): action is "consumeLiquidity" | "swapFtToTbc";
|
|
10
|
+
export declare function actionRequiresFtAReserveIncrease(action: PoolNftAction): action is "increaseLiquidity" | "swapFtToTbc";
|
|
11
|
+
export declare function actionRequiresFtAReserveDecrease(action: PoolNftAction): action is "consumeLiquidity" | "swapTbcToFt";
|
|
12
|
+
export declare function actionRequiresLpReserveIncrease(action: PoolNftAction): action is "increaseLiquidity";
|
|
13
|
+
export declare function actionRequiresLpReserveDecrease(action: PoolNftAction): action is "consumeLiquidity";
|
|
14
|
+
export declare function poolNftTransactionType(action: PoolNftAction): "PoolNFT create" | "PoolNFT init" | "PoolNFT increase liquidity" | "PoolNFT consume liquidity" | "PoolNFT swap TBC to FT" | "PoolNFT swap FT to TBC" | "PoolNFT merge FT in pool" | "PoolNFT LP merge" | "PoolNFT LP burn" | "PoolNFT transaction";
|
|
15
|
+
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../src/protocols/pool-nft/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,MAAM,EAAE,EACjB,UAAU,GAAE,iBAA2B,GACtC,kBAAkB,CAMpB;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAmBnG;AAED,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,aAAa,wGAMpE;AAED,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,aAAa,iHAOlE;AAED,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,aAAa,0CAEvE;AAED,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,aAAa,+DAEvE;AAED,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,aAAa,iDAErE;AAED,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,aAAa,gDAErE;AAED,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,aAAa,iDAErE;AAED,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,aAAa,gDAErE;AAED,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,aAAa,iCAEpE;AAED,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,aAAa,gCAEpE;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,aAAa,sPAuB3D"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export function createPoolNftActionMatch(action, reasons, confidence = 'exact') {
|
|
2
|
+
return {
|
|
3
|
+
action,
|
|
4
|
+
confidence,
|
|
5
|
+
reasons,
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export function downgradePoolNftMatch(match, reason) {
|
|
9
|
+
if (match.confidence === 'heuristic') {
|
|
10
|
+
return {
|
|
11
|
+
...match,
|
|
12
|
+
reasons: [
|
|
13
|
+
...match.reasons,
|
|
14
|
+
reason,
|
|
15
|
+
],
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
...match,
|
|
20
|
+
confidence: 'heuristic',
|
|
21
|
+
reasons: [
|
|
22
|
+
...match.reasons,
|
|
23
|
+
reason,
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function actionRequiresExistingPoolState(action) {
|
|
28
|
+
return action === 'consumeLiquidity' ||
|
|
29
|
+
action === 'increaseLiquidity' ||
|
|
30
|
+
action === 'swapTbcToFt' ||
|
|
31
|
+
action === 'swapFtToTbc' ||
|
|
32
|
+
action === 'mergeFtInPool';
|
|
33
|
+
}
|
|
34
|
+
export function actionRequiresFtContractMatch(action) {
|
|
35
|
+
return action === 'init' ||
|
|
36
|
+
action === 'increaseLiquidity' ||
|
|
37
|
+
action === 'consumeLiquidity' ||
|
|
38
|
+
action === 'swapTbcToFt' ||
|
|
39
|
+
action === 'swapFtToTbc' ||
|
|
40
|
+
action === 'mergeFtInPool';
|
|
41
|
+
}
|
|
42
|
+
export function actionRequiresLiquidityAmountMatch(action) {
|
|
43
|
+
return action === 'init' || action === 'increaseLiquidity';
|
|
44
|
+
}
|
|
45
|
+
export function actionRequiresLpTokenIdentityMatch(action) {
|
|
46
|
+
return action === 'init' || action === 'increaseLiquidity' || action === 'consumeLiquidity';
|
|
47
|
+
}
|
|
48
|
+
export function actionRequiresTbcReserveIncrease(action) {
|
|
49
|
+
return action === 'increaseLiquidity' || action === 'swapTbcToFt';
|
|
50
|
+
}
|
|
51
|
+
export function actionRequiresTbcReserveDecrease(action) {
|
|
52
|
+
return action === 'consumeLiquidity' || action === 'swapFtToTbc';
|
|
53
|
+
}
|
|
54
|
+
export function actionRequiresFtAReserveIncrease(action) {
|
|
55
|
+
return action === 'increaseLiquidity' || action === 'swapFtToTbc';
|
|
56
|
+
}
|
|
57
|
+
export function actionRequiresFtAReserveDecrease(action) {
|
|
58
|
+
return action === 'consumeLiquidity' || action === 'swapTbcToFt';
|
|
59
|
+
}
|
|
60
|
+
export function actionRequiresLpReserveIncrease(action) {
|
|
61
|
+
return action === 'increaseLiquidity';
|
|
62
|
+
}
|
|
63
|
+
export function actionRequiresLpReserveDecrease(action) {
|
|
64
|
+
return action === 'consumeLiquidity';
|
|
65
|
+
}
|
|
66
|
+
export function poolNftTransactionType(action) {
|
|
67
|
+
switch (action) {
|
|
68
|
+
case 'create':
|
|
69
|
+
return 'PoolNFT create';
|
|
70
|
+
case 'init':
|
|
71
|
+
return 'PoolNFT init';
|
|
72
|
+
case 'increaseLiquidity':
|
|
73
|
+
return 'PoolNFT increase liquidity';
|
|
74
|
+
case 'consumeLiquidity':
|
|
75
|
+
return 'PoolNFT consume liquidity';
|
|
76
|
+
case 'swapTbcToFt':
|
|
77
|
+
return 'PoolNFT swap TBC to FT';
|
|
78
|
+
case 'swapFtToTbc':
|
|
79
|
+
return 'PoolNFT swap FT to TBC';
|
|
80
|
+
case 'mergeFtInPool':
|
|
81
|
+
return 'PoolNFT merge FT in pool';
|
|
82
|
+
case 'mergeFtLp':
|
|
83
|
+
return 'PoolNFT LP merge';
|
|
84
|
+
case 'burnFtLp':
|
|
85
|
+
return 'PoolNFT LP burn';
|
|
86
|
+
default:
|
|
87
|
+
return 'PoolNFT transaction';
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../../src/protocols/pool-nft/actions.ts"],"names":[],"mappings":"AAMA,MAAM,UAAU,wBAAwB,CACtC,MAAqB,EACrB,OAAiB,EACjB,aAAgC,OAAO;IAEvC,OAAO;QACL,MAAM;QACN,UAAU;QACV,OAAO;KACR,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,KAAyB,EAAE,MAAc;IAC7E,IAAI,KAAK,CAAC,UAAU,KAAK,WAAW,EAAE,CAAC;QACrC,OAAO;YACL,GAAG,KAAK;YACR,OAAO,EAAE;gBACP,GAAG,KAAK,CAAC,OAAO;gBAChB,MAAM;aACP;SACF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,GAAG,KAAK;QACR,UAAU,EAAE,WAAW;QACvB,OAAO,EAAE;YACP,GAAG,KAAK,CAAC,OAAO;YAChB,MAAM;SACP;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,MAAqB;IACnE,OAAO,MAAM,KAAK,kBAAkB;QAClC,MAAM,KAAK,mBAAmB;QAC9B,MAAM,KAAK,aAAa;QACxB,MAAM,KAAK,aAAa;QACx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X,OAAO,gBAAgB,CAAC;QAC1B,KAAK,MAAM;YACT,OAAO,cAAc,CAAC;QACxB,KAAK,mBAAmB;YACtB,OAAO,4BAA4B,CAAC;QACtC,KAAK,kBAAkB;YACrB,OAAO,2BAA2B,CAAC;QACrC,KAAK,aAAa;YAChB,OAAO,wBAAwB,CAAC;QAClC,KAAK,aAAa;YAChB,OAAO,wBAAwB,CAAC;QAClC,KAAK,eAAe;YAClB,OAAO,0BAA0B,CAAC;QACpC,KAAK,WAAW;YACd,OAAO,kBAAkB,CAAC;QAC5B,KAAK,UAAU;YACb,OAAO,iBAAiB,CAAC;QAC3B;YACE,OAAO,qBAAqB,CAAC;IACjC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PoolNftFacts } from './types.js';
|
|
2
|
+
export declare function parsePoolNftRawAmount(rawAmount: string | undefined): bigint | undefined;
|
|
3
|
+
export declare function poolNftFtADelta(facts: PoolNftFacts): bigint | undefined;
|
|
4
|
+
export declare function poolNftLpDelta(facts: PoolNftFacts): bigint | undefined;
|
|
5
|
+
export declare function poolNftTbcDelta(facts: PoolNftFacts): number | undefined;
|
|
6
|
+
export declare function poolNftAbsoluteRawAmount(amount: bigint): bigint;
|
|
7
|
+
export declare function poolNftRawDeltaString(delta: bigint | undefined): string | undefined;
|
|
8
|
+
export declare function poolNftSatoshisMatchWithRounding(expected: number, actual: number, tolerance?: number): boolean;
|
|
9
|
+
export declare function poolNftBigIntSatoshisMatchWithRounding(expected: bigint, actual: bigint): boolean;
|
|
10
|
+
//# sourceMappingURL=amounts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amounts.d.ts","sourceRoot":"","sources":["../../../src/protocols/pool-nft/amounts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,sBAMlE;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,sBAQlD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,YAAY,sBAQjD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,sBAQlD;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,UAEtD;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,sBAE9D;AAED,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,SAAS,SAA2C,WAGrD;AAED,wBAAgB,sCAAsC,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,WAGtF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { POOL_NFT_TBC_ROUNDING_TOLERANCE_SATOSHIS } from './constants.js';
|
|
2
|
+
export function parsePoolNftRawAmount(rawAmount) {
|
|
3
|
+
if (!rawAmount || !/^\d+$/u.test(rawAmount)) {
|
|
4
|
+
return undefined;
|
|
5
|
+
}
|
|
6
|
+
return BigInt(rawAmount);
|
|
7
|
+
}
|
|
8
|
+
export function poolNftFtADelta(facts) {
|
|
9
|
+
const previousFtAAmount = parsePoolNftRawAmount(facts.poolInputs[0]?.tape?.ftAAmountRaw);
|
|
10
|
+
const currentFtAAmount = parsePoolNftRawAmount(facts.tape?.ftAAmountRaw);
|
|
11
|
+
if (previousFtAAmount === undefined || currentFtAAmount === undefined) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
return currentFtAAmount - previousFtAAmount;
|
|
15
|
+
}
|
|
16
|
+
export function poolNftLpDelta(facts) {
|
|
17
|
+
const previousFtLpAmount = parsePoolNftRawAmount(facts.poolInputs[0]?.tape?.ftLpAmountRaw);
|
|
18
|
+
const currentFtLpAmount = parsePoolNftRawAmount(facts.tape?.ftLpAmountRaw);
|
|
19
|
+
if (previousFtLpAmount === undefined || currentFtLpAmount === undefined) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
return currentFtLpAmount - previousFtLpAmount;
|
|
23
|
+
}
|
|
24
|
+
export function poolNftTbcDelta(facts) {
|
|
25
|
+
const previousTbcSatoshis = facts.poolInputs[0]?.tape?.tbcSatoshis;
|
|
26
|
+
const currentTbcSatoshis = facts.tape?.tbcSatoshis;
|
|
27
|
+
if (previousTbcSatoshis === undefined || currentTbcSatoshis === undefined) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
return currentTbcSatoshis - previousTbcSatoshis;
|
|
31
|
+
}
|
|
32
|
+
export function poolNftAbsoluteRawAmount(amount) {
|
|
33
|
+
return amount < 0n ? -amount : amount;
|
|
34
|
+
}
|
|
35
|
+
export function poolNftRawDeltaString(delta) {
|
|
36
|
+
return delta === undefined ? undefined : poolNftAbsoluteRawAmount(delta).toString();
|
|
37
|
+
}
|
|
38
|
+
export function poolNftSatoshisMatchWithRounding(expected, actual, tolerance = POOL_NFT_TBC_ROUNDING_TOLERANCE_SATOSHIS) {
|
|
39
|
+
return Math.abs(expected - actual) <= tolerance;
|
|
40
|
+
}
|
|
41
|
+
export function poolNftBigIntSatoshisMatchWithRounding(expected, actual) {
|
|
42
|
+
const delta = expected > actual ? expected - actual : actual - expected;
|
|
43
|
+
return delta <= BigInt(POOL_NFT_TBC_ROUNDING_TOLERANCE_SATOSHIS);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=amounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amounts.js","sourceRoot":"","sources":["../../../src/protocols/pool-nft/amounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wCAAwC,EAAE,MAAM,gBAAgB,CAAC;AAG1E,MAAM,UAAU,qBAAqB,CAAC,SAA6B;IACjE,IAAI,CAAC,SAAS,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5C,OAAO,SAAS,CAAC;IACnB,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c;IACrD,OAAO,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,KAAyB;IAC7D,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC;AACtF,CAAC;AAED,MAAM,UAAU,gCAAgC,CAC9C,QAAgB,EAChB,MAAc,EACd,SAAS,GAAG,wCAAwC;IAEpD,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,SAAS,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,sCAAsC,CAAC,QAAgB,EAAE,MAAc;IACrF,MAAM,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,QAAQ,CAAC;IACxE,OAAO,KAAK,IAAI,MAAM,CAAC,wCAAwC,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const POOL_NFT_BURN_ADDRESSES: Set<string>;
|
|
2
|
+
export declare const POOL_NFT_SERVICE_FEE_ADDRESSES: Record<number, string>;
|
|
3
|
+
export declare const POOL_NFT_SERVICE_FEE_DENOMINATOR = 10000n;
|
|
4
|
+
export declare const POOL_NFT_VISIBLE_SERVICE_FEE_THRESHOLD = 10n;
|
|
5
|
+
export declare const POOL_NFT_TBC_ROUNDING_TOLERANCE_SATOSHIS = 1;
|
|
6
|
+
export declare const POOL_NFT_CONSUME_TBC_ROUNDING_TOLERANCE_SATOSHIS = 5;
|
|
7
|
+
export declare const FT_A_CODE_MARKER_HEX = "32436f6465";
|
|
8
|
+
export declare const FT_LP_CODE_MARKER_HEX = "02436f6465";
|
|
9
|
+
export declare const FT_V1_CODE_LENGTH = 1564;
|
|
10
|
+
export declare const FT_V1_PARTIAL_HASH_OFFSET = 1536;
|
|
11
|
+
export declare const FT_V2_CODE_LENGTH = 1884;
|
|
12
|
+
export declare const FT_V2_PARTIAL_HASH_OFFSET = 1856;
|
|
13
|
+
export declare const COIN_CODE_LENGTH = 2012;
|
|
14
|
+
export declare const COIN_PARTIAL_HASH_OFFSET = 1984;
|
|
15
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/protocols/pool-nft/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,aAGlC,CAAC;AAGH,eAAO,MAAM,8BAA8B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAMjE,CAAC;AAEF,eAAO,MAAM,gCAAgC,SAAU,CAAC;AACxD,eAAO,MAAM,sCAAsC,MAAM,CAAC;AAE1D,eAAO,MAAM,wCAAwC,IAAI,CAAC;AAE1D,eAAO,MAAM,gDAAgD,IAAI,CAAC;AAElE,eAAO,MAAM,oBAAoB,eAAe,CAAC;AACjD,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAClD,eAAO,MAAM,iBAAiB,OAAO,CAAC;AACtC,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAC9C,eAAO,MAAM,iBAAiB,OAAO,CAAC;AACtC,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAC9C,eAAO,MAAM,gBAAgB,OAAO,CAAC;AACrC,eAAO,MAAM,wBAAwB,OAAO,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const POOL_NFT_BURN_ADDRESSES = new Set([
|
|
2
|
+
'1BitcoinEaterAddressDontSendf59kuE',
|
|
3
|
+
'mrEqurom3cKudH7FaDrF3j1DJePLcjAU3m',
|
|
4
|
+
]);
|
|
5
|
+
// PoolNFT 2.0 contracts use a fixed service-fee receiver selected by lpPlan.
|
|
6
|
+
export const POOL_NFT_SERVICE_FEE_ADDRESSES = {
|
|
7
|
+
1: '13oCEJaqyyiC8iRrfup6PDL2GKZ3xQrsZL',
|
|
8
|
+
2: '1Fa6Uy64Ub4qNdB896zX2pNMx4a8zMhtCy',
|
|
9
|
+
3: '125fTLNsraQxTYqT4EeQNF2ggzcqicveKL',
|
|
10
|
+
4: '19DetoaaohQkjFVJ6oGXd83xhZYQSbpE1g',
|
|
11
|
+
5: '15EKrhuD8Yf3SfhjAgbizYqfnBbKh9ZMZ7',
|
|
12
|
+
};
|
|
13
|
+
export const POOL_NFT_SERVICE_FEE_DENOMINATOR = 10000n;
|
|
14
|
+
export const POOL_NFT_VISIBLE_SERVICE_FEE_THRESHOLD = 10n;
|
|
15
|
+
// PoolNFT consume-liquidity TBC payouts may differ by one satoshi because of integer division.
|
|
16
|
+
export const POOL_NFT_TBC_ROUNDING_TOLERANCE_SATOSHIS = 1;
|
|
17
|
+
// Real consumeLiquidity transactions without a separate fee output may have a combined SDK rounding difference above one satoshi.
|
|
18
|
+
export const POOL_NFT_CONSUME_TBC_ROUNDING_TOLERANCE_SATOSHIS = 5;
|
|
19
|
+
export const FT_A_CODE_MARKER_HEX = '32436f6465';
|
|
20
|
+
export const FT_LP_CODE_MARKER_HEX = '02436f6465';
|
|
21
|
+
export const FT_V1_CODE_LENGTH = 1564;
|
|
22
|
+
export const FT_V1_PARTIAL_HASH_OFFSET = 1536;
|
|
23
|
+
export const FT_V2_CODE_LENGTH = 1884;
|
|
24
|
+
export const FT_V2_PARTIAL_HASH_OFFSET = 1856;
|
|
25
|
+
export const COIN_CODE_LENGTH = 2012;
|
|
26
|
+
export const COIN_PARTIAL_HASH_OFFSET = 1984;
|
|
27
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/protocols/pool-nft/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC;IAC7C,oCAAoC;IACpC,oCAAoC;CACrC,CAAC,CAAC;AAEH,6EAA6E;AAC7E,MAAM,CAAC,MAAM,8BAA8B,GAA2B;IACpE,CAAC,EAAE,oCAAoC;IACvC,CAAC,EAAE,oCAAoC;IACvC,CAAC,EAAE,oCAAoC;IACvC,CAAC,EAAE,oCAAoC;IACvC,CAAC,EAAE,oCAAoC;CACxC,CAAC;AAEF,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAO,CAAC;AACxD,MAAM,CAAC,MAAM,sCAAsC,GAAG,GAAG,CAAC;AAC1D,+FAA+F;AAC/F,MAAM,CAAC,MAAM,wCAAwC,GAAG,CAAC,CAAC;AAC1D,kIAAkI;AAClI,MAAM,CAAC,MAAM,gDAAgD,GAAG,CAAC,CAAC;AAElE,MAAM,CAAC,MAAM,oBAAoB,GAAG,YAAY,CAAC;AACjD,MAAM,CAAC,MAAM,qBAAqB,GAAG,YAAY,CAAC;AAClD,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AACtC,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAC9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AACtC,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAC9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AACrC,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DecodedInput, DecodedOutput, ScriptDetail } from '../../types.js';
|
|
2
|
+
import type { FungibleTokenMovement } from '../../types/protocol.js';
|
|
3
|
+
import type { PoolNftFacts, PoolNftTapeData } from './types.js';
|
|
4
|
+
export declare function isPoolNftBurnReceiver(receiver: string | undefined): boolean;
|
|
5
|
+
export declare function allPoolNftAmountsAreZero(tape: NonNullable<ScriptDetail['data']>['poolNft']): boolean;
|
|
6
|
+
export declare function formatPoolNftFtAmount(rawAmount: string | undefined, decimal: number | undefined): string | undefined;
|
|
7
|
+
export declare function poolNftScriptLockHash(scriptHex: string | undefined): string | undefined;
|
|
8
|
+
export declare function inputPoolNftTape(input: DecodedInput): PoolNftTapeData | undefined;
|
|
9
|
+
export declare function collectPoolNftFacts(inputs: DecodedInput[], outputs: DecodedOutput[], ftMovements: FungibleTokenMovement[], tapeOutput?: DecodedOutput): PoolNftFacts;
|
|
10
|
+
export declare function hasPoolStateCarrier(facts: PoolNftFacts): boolean;
|
|
11
|
+
//# sourceMappingURL=facts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"facts.d.ts","sourceRoot":"","sources":["../../../src/protocols/pool-nft/facts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,YAAY,EACb,MAAM,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAGrE,OAAO,KAAK,EACV,YAAY,EAEZ,eAAe,EAChB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,WAEjE;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,WAE1F;AAED,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,sBAU/F;AAED,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,sBAQlE;AASD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,YAAY,GAAG,eAAe,GAAG,SAAS,CAkBjF;AAmCD,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,YAAY,EAAE,EACtB,OAAO,EAAE,aAAa,EAAE,EACxB,WAAW,EAAE,qBAAqB,EAAE,EACpC,UAAU,CAAC,EAAE,aAAa,GACzB,YAAY,CA4Bd;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,YAAY,WAUtD"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { tbc } from '../../adapters/tbc-lib.js';
|
|
2
|
+
import { ScriptType } from '../../types.js';
|
|
3
|
+
import { formatTokenRawAmount } from '../../utils/token-amount.js';
|
|
4
|
+
import { POOL_NFT_BURN_ADDRESSES } from './constants.js';
|
|
5
|
+
export function isPoolNftBurnReceiver(receiver) {
|
|
6
|
+
return receiver !== undefined && POOL_NFT_BURN_ADDRESSES.has(receiver);
|
|
7
|
+
}
|
|
8
|
+
export function allPoolNftAmountsAreZero(tape) {
|
|
9
|
+
return tape?.ftLpAmountRaw === '0' && tape.ftAAmountRaw === '0' && tape.tbcSatoshis === 0;
|
|
10
|
+
}
|
|
11
|
+
export function formatPoolNftFtAmount(rawAmount, decimal) {
|
|
12
|
+
if (!rawAmount || decimal === undefined) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
return formatTokenRawAmount(rawAmount, decimal);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function poolNftScriptLockHash(scriptHex) {
|
|
23
|
+
if (!scriptHex || scriptHex.length % 2 !== 0) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
return tbc.crypto.Hash.sha256ripemd160(tbc.crypto.Hash.sha256(Buffer.from(scriptHex, 'hex'))).toString('hex');
|
|
27
|
+
}
|
|
28
|
+
function isPlainSpendScript(script) {
|
|
29
|
+
return script.type === ScriptType.P2PKH ||
|
|
30
|
+
script.type === ScriptType.P2PK ||
|
|
31
|
+
script.type === ScriptType.P2SH ||
|
|
32
|
+
script.type === ScriptType.MULTISIG;
|
|
33
|
+
}
|
|
34
|
+
export function inputPoolNftTape(input) {
|
|
35
|
+
const directTape = input.prevout?.script.data?.poolNft;
|
|
36
|
+
if (directTape) {
|
|
37
|
+
return directTape;
|
|
38
|
+
}
|
|
39
|
+
const prevout = input.prevout;
|
|
40
|
+
const associatedTape = prevout?.associatedTape;
|
|
41
|
+
if (!prevout ||
|
|
42
|
+
!associatedTape ||
|
|
43
|
+
associatedTape.outputIndex !== input.vout + 1 ||
|
|
44
|
+
isPlainSpendScript(prevout.script)) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
return associatedTape.script.data?.poolNft;
|
|
48
|
+
}
|
|
49
|
+
function inputPoolStateRef(input) {
|
|
50
|
+
const tape = inputPoolNftTape(input);
|
|
51
|
+
if (!input.prevout || !tape) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
inputIndex: input.index,
|
|
56
|
+
contractId: input.prevout.contractId,
|
|
57
|
+
satoshis: input.prevout.satoshis,
|
|
58
|
+
address: input.prevout.address,
|
|
59
|
+
hash: input.prevout.hash ?? input.prevout.script.data?.hash ?? poolNftScriptLockHash(input.prevout.script.hex),
|
|
60
|
+
script: input.prevout.script,
|
|
61
|
+
tape,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function outputPoolStateRef(output) {
|
|
65
|
+
const tape = output.script.data?.poolNft;
|
|
66
|
+
if (!tape) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
outputIndex: output.index,
|
|
71
|
+
satoshis: output.satoshis,
|
|
72
|
+
address: output.address,
|
|
73
|
+
hash: output.script.data?.hash ?? poolNftScriptLockHash(output.script.hex),
|
|
74
|
+
script: output.script,
|
|
75
|
+
tape,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export function collectPoolNftFacts(inputs, outputs, ftMovements, tapeOutput) {
|
|
79
|
+
const tape = tapeOutput?.script.data?.poolNft;
|
|
80
|
+
const relatedFtMovements = tapeOutput
|
|
81
|
+
? ftMovements.filter((movement) => movement.outputIndex > tapeOutput.index)
|
|
82
|
+
: [];
|
|
83
|
+
const userInputs = inputs.filter((input) => !inputPoolNftTape(input));
|
|
84
|
+
return {
|
|
85
|
+
outputs,
|
|
86
|
+
tapeOutput,
|
|
87
|
+
tape,
|
|
88
|
+
poolOutput: tapeOutput ? outputs.find((candidate) => candidate.index === tapeOutput.index - 1) : undefined,
|
|
89
|
+
poolInputs: inputs
|
|
90
|
+
.map(inputPoolStateRef)
|
|
91
|
+
.filter((state) => Boolean(state)),
|
|
92
|
+
poolOutputs: outputs
|
|
93
|
+
.map(outputPoolStateRef)
|
|
94
|
+
.filter((state) => Boolean(state)),
|
|
95
|
+
userInputs,
|
|
96
|
+
relatedFtMovements,
|
|
97
|
+
burnMovements: relatedFtMovements.filter((movement) => isPoolNftBurnReceiver(movement.receiver)),
|
|
98
|
+
tbcOutputsAfterTape: tapeOutput
|
|
99
|
+
? outputs.filter((output) => output.index > tapeOutput.index && output.satoshis > 500 && Boolean(output.address))
|
|
100
|
+
: [],
|
|
101
|
+
tbcFeeCandidateOutputsAfterTape: tapeOutput
|
|
102
|
+
? outputs.filter((output) => output.index > tapeOutput.index && output.satoshis > 0 && Boolean(output.address))
|
|
103
|
+
: [],
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
export function hasPoolStateCarrier(facts) {
|
|
107
|
+
if (facts.poolOutput?.scriptKind !== 'contract' || facts.tapeOutput === undefined) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
const candidateCarriersBeforeTape = facts.outputs.filter((output) => output.index < facts.tapeOutput.index && output.scriptKind === 'contract');
|
|
111
|
+
return candidateCarriersBeforeTape.length === 1;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=facts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"facts.js","sourceRoot":"","sources":["../../../src/protocols/pool-nft/facts.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,gBA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AAE,CAClE,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC,UAAW,CAAC,KAAK,IAAI,MAAM,CAAC,UAAU,KAAK,UAAU,CAC3E,CAAC;IAEF,OAAO,2BAA2B,CAAC,MAAM,KAAK,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PoolNftActionMatch, PoolNftFacts } from './types.js';
|
|
2
|
+
export declare function poolNftFeeSatoshis(action: PoolNftActionMatch['action'], facts: PoolNftFacts): number;
|
|
3
|
+
export declare function poolNftServiceFeeQuote(baseSatoshis: bigint, facts: PoolNftFacts): {
|
|
4
|
+
totalFee: bigint;
|
|
5
|
+
lpFee: bigint;
|
|
6
|
+
visibleFee: bigint;
|
|
7
|
+
} | undefined;
|
|
8
|
+
export declare function poolNftGrossTbcInFromNetDelta(netDelta: bigint, facts: PoolNftFacts): bigint | undefined;
|
|
9
|
+
export declare function poolNftFeeSatoshisBigInt(action: PoolNftActionMatch['action'], facts: PoolNftFacts): bigint;
|
|
10
|
+
export declare function poolNftVisibleTbcOutSatoshis(action: PoolNftActionMatch['action'], facts: PoolNftFacts): number | undefined;
|
|
11
|
+
export declare function withSwapServiceFeeFormulaConfidence(match: PoolNftActionMatch, facts: PoolNftFacts): PoolNftActionMatch;
|
|
12
|
+
export declare function hasTbcOutPayoutOrFeeMismatch(action: 'swapFtToTbc' | 'consumeLiquidity', facts: PoolNftFacts): boolean;
|
|
13
|
+
export declare function hasTbcPayoutOrFeeRelationMismatch(action: PoolNftActionMatch['action'], facts: PoolNftFacts): boolean;
|
|
14
|
+
//# sourceMappingURL=fees.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fees.d.ts","sourceRoot":"","sources":["../../../src/protocols/pool-nft/fees.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAkBnE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,YAAY,UAE3F;AAYD,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY;;;;cAqB/E;AAED,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,sBAoBlF;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,kBAAkB,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,YAAY,UAEjG;AAED,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,kBAAkB,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,YAAY,sBAOrG;AAED,wBAAgB,mCAAmC,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,YAAY,GAAG,kBAAkB,CAgDtH;AAiCD,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,aAAa,GAAG,kBAAkB,EAAE,KAAK,EAAE,YAAY,WAuB3G;AAMD,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,kBAAkB,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,YAAY,WAc1G"}
|