Skip to content

Commit 173f2bc

Browse files
authored
Add support for Mayan API priced transactions (#429)
* set up mayan adapter * Add Mayan adapter and integrate event fetching and volume calculation * Refactor Mayan event fetching to use API key and improve error handling; streamline volume calculation logic * deleted pnpm lock yaml * removed old comment * Refactor Mayan event fetching to use secure API endpoint and improve error handling; update handler export for scheduled execution * added missing filters to process batch * fixed double counting txs, removed pricing from mayan's API and added correct chain assignments * Fixed mayan volume amounts * add support for mayan api pricing
1 parent 7c1a552 commit 173f2bc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/handlers/runMayan.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export const handler = async () => {
4444
token_transfer_to_address,
4545
token_address,
4646
token_amount,
47+
token_usd_amount,
4748
source_chain,
4849
destination_chain,
4950
is_deposit,
@@ -56,6 +57,10 @@ export const handler = async () => {
5657
const transactionChain = is_deposit ? destinationChain : sourceChain;
5758
const originChain = is_deposit ? sourceChain : null;
5859

60+
const tokenAmountUsd = parseFloat(token_usd_amount) ? token_usd_amount : 0;
61+
// sanity check
62+
const shouldBeUSDVolume = tokenAmountUsd > 0 && tokenAmountUsd <= 10_000_000;
63+
5964
// Only create one transaction per event, using the appropriate chain's bridge_id
6065
if (bridgeIds[transactionChain]) {
6166
transactions.push({
@@ -67,9 +72,9 @@ export const handler = async () => {
6772
tx_from: token_transfer_from_address ?? "0x",
6873
tx_to: token_transfer_to_address ?? "0x",
6974
token: token_address ?? "0x0000000000000000000000000000000000000000",
70-
amount: token_amount ?? "0",
75+
amount: shouldBeUSDVolume ? tokenAmountUsd : token_amount ?? "0",
7176
is_deposit: is_deposit,
72-
is_usd_volume: false,
77+
is_usd_volume: shouldBeUSDVolume,
7378
txs_counted_as: 1,
7479
origin_chain: originChain,
7580
});

0 commit comments

Comments
 (0)