Repository: DefiLlama/dimension-adapters
Pull request #2527: added volume and fees adapters
Author: login: ghost
Created: 2025-03-10T22:26:42Z | Merged: 2025-03-15T14:22:07Z



Diff:
diff --git a/fees/puppyfun/index.ts b/fees/puppyfun/index.ts
new file mode 100644
index 0000000000..3c414a17ce
--- /dev/null
+++ b/fees/puppyfun/index.ts
@@ -0,0 +1,51 @@
+import { FetchOptions } from "../../adapters/types"
+import { CHAIN } from "../../helpers/chains"
+import axios from "axios"
+
+const BNB_ADDRESS = "0x0000000000000000000000000000000000000000"
+
+const apiBaseURL = "https://bd-fun-defilama-ts-backend-main.puppy.fun/lama-api"
+const feesMethod = "/fees"
+
+const maxRetriesCount = 3
+
+const fetch: any = async (options: FetchOptions) => {
+    for (let tryCount = 0; tryCount < maxRetriesCount; ++tryCount) {
+        try {
+            console.log(`Query Volume ...`)
+            const response = await axios.get(apiBaseURL + feesMethod)
+            console.log(response.data)
+
+            const fees = options.createBalances()
+            const dailyFees = options.createBalances()
+            const revenue = options.createBalances()
+            const dailyRevenue = options.createBalances()
+
+            fees.add(BNB_ADDRESS, response.data.totalFee)
+            dailyFees.add(BNB_ADDRESS, response.data.totalDailyFee)
+            // revenue == fees (no users fees)
+            revenue.add(BNB_ADDRESS, response.data.totalFee)
+            dailyFees.add(BNB_ADDRESS, response.data.totalDailyFee)
+
+            return {
+                totalFees: fees,
+                totalRevenue: revenue,
+                dailyFees,
+                dailyRevenue
+            }
+        } catch (err) {
+            console.log(`Error getting Volume`, err)
+            continue
+        }
+    }
+}
+
+export default {
+    version: 2,
+    adapter: {
+        [CHAIN.BSC]: {
+            fetch: fetch,
+            // start: "2024-12-01",
+        },
+    },
+}
diff --git a/protocols/puppyfun/index.ts b/protocols/puppyfun/index.ts
new file mode 100644
index 0000000000..78e451ebcc
--- /dev/null
+++ b/protocols/puppyfun/index.ts
@@ -0,0 +1,42 @@
+import { FetchOptions } from "../../adapters/types"
+import { CHAIN } from "../../helpers/chains"
+import axios from "axios"
+
+const BNB_ADDRESS = "0x0000000000000000000000000000000000000000"
+
+const apiBaseURL = "https://bd-fun-defilama-ts-backend-main.puppy.fun/lama-api"
+const volumeMethod = "/volume"
+
+const maxRetriesCount = 3
+
+const fetch: any = async (options: FetchOptions) => {
+    for (let tryCount = 0; tryCount < maxRetriesCount; ++tryCount) {
+        try {
+            console.log(`Query Volume ...`)
+            const response = await axios.get(apiBaseURL + volumeMethod)
+
+            const volume = options.createBalances()
+            const dailyVolume = options.createBalances()
+            volume.add(BNB_ADDRESS, response.data.volume)
+            dailyVolume.add(BNB_ADDRESS, response.data.dailyVolume)
+
+            const totalVolume = Number(response.data.volume) / 10 ** 18
+            console.log(`Got Volume: ${totalVolume} BNB`, response.data.volume)
+            console.log(`Got Daily Volume: ${Number(response.data.dailyVolume) / 10 ** 18} BNB`, response.data.dailyVolume)
+            return { totalVolume: volume, dailyVolume }
+        } catch (err) {
+            console.log(`Error getting Volume`, err)
+            continue
+        }
+    }
+}
+
+export default {
+    version: 2,
+    adapter: {
+        [CHAIN.BSC]: {
+            fetch: fetch,
+            // start: '2024-12-01'
+        },
+    },
+}


Reviews:
user: login: dtmkeng
state: CHANGES_REQUESTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-11T06:00:42Z
state: COMMENTED
author_association: NONE
submitted_at: 2025-03-11T07:36:25Z
state: COMMENTED
author_association: NONE
submitted_at: 2025-03-11T07:36:44Z
user: login: dtmkeng
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-11T07:39:17Z
state: COMMENTED
author_association: NONE
submitted_at: 2025-03-11T07:41:05Z
state: COMMENTED
author_association: NONE
submitted_at: 2025-03-11T07:42:17Z
user: login: dtmkeng
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-11T07:44:01Z
user: login: NikolaiNikolaevichBoyko
state: APPROVED
author_association: NONE
submitted_at: 2025-03-17T06:12:12Z

Review comments:
diff_hunk: @@ -0,0 +1,39 @@
+import { FetchOptions } from "../../adapters/types"
+import { CHAIN } from "../../helpers/chains"
+import axios from "axios"
+
+const BNB_ADDRESS = "0x0000000000000000000000000000000000000000"
+
+const apiBaseURL = "https://bd-fun-defilama-ts-backend-main.puppy.fun/lama-api"
+const volumeMethod = "/volume"
+
+const maxRetriesCount = 3
+
+const fetch: any = async (options: FetchOptions) => {
+    for (let tryCount = 0; tryCount < maxRetriesCount; ++tryCount) {
+        try {
+            console.log(`Query Volume ...`)
+            const response = await axios.get(apiBaseURL + volumeMethod)
+
+            const volume = options.createBalances()
+            volume.add(BNB_ADDRESS, response.data.volume)
+
+            const totalVolume = Number(response.data.volume) / 10 ** 18
+            console.log(`Got Volume: ${totalVolume} BNB`, response.data.volume)
+            return { totalVolume: volume }
path: protocols/puppyfun/index.ts
user: login: dtmkeng
body: could you return dailyVolume ?
created_at: 2025-03-11T06:00:06Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,44 @@
+import { FetchOptions } from "../../adapters/types"
+import { CHAIN } from "../../helpers/chains"
+import axios from "axios"
+
+const BNB_ADDRESS = "0x0000000000000000000000000000000000000000"
+
+const apiBaseURL = "https://bd-fun-defilama-ts-backend-main.puppy.fun/lama-api"
+const feesMethod = "/fees"
+
+const maxRetriesCount = 3
+
+const fetch: any = async (options: FetchOptions) => {
+    for (let tryCount = 0; tryCount < maxRetriesCount; ++tryCount) {
+        try {
+            console.log(`Query Volume ...`)
+            const response = await axios.get(apiBaseURL + feesMethod)
+            console.log(response.data)
+
+            const fees = options.createBalances()
+            const revenue = options.createBalances()
+            fees.add(BNB_ADDRESS, response.data.totalFee)
+            // revenue == fees (no users fees)
+            revenue.add(BNB_ADDRESS, response.data.totalFee)
+
+            return {
+                totalFees: fees,
path: fees/puppyfun/index.ts
user: login: dtmkeng
body: could you add dailyFees and dailyRevenue
created_at: 2025-03-11T06:00:36Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,39 @@
+import { FetchOptions } from "../../adapters/types"
+import { CHAIN } from "../../helpers/chains"
+import axios from "axios"
+
+const BNB_ADDRESS = "0x0000000000000000000000000000000000000000"
+
+const apiBaseURL = "https://bd-fun-defilama-ts-backend-main.puppy.fun/lama-api"
+const volumeMethod = "/volume"
+
+const maxRetriesCount = 3
+
+const fetch: any = async (options: FetchOptions) => {
+    for (let tryCount = 0; tryCount < maxRetriesCount; ++tryCount) {
+        try {
+            console.log(`Query Volume ...`)
+            const response = await axios.get(apiBaseURL + volumeMethod)
+
+            const volume = options.createBalances()
+            volume.add(BNB_ADDRESS, response.data.volume)
+
+            const totalVolume = Number(response.data.volume) / 10 ** 18
+            console.log(`Got Volume: ${totalVolume} BNB`, response.data.volume)
+            return { totalVolume: volume }
path: protocols/puppyfun/index.ts
body: our backend exporter service is designed to return total volume only (for now) if it is necessary we will add such metric (can DeFi Lama display daily volume  or fees based on the difference between "today volume" and "yesterday volume")?
created_at: 2025-03-11T07:36:25Z
author_association: NONE
diff_hunk: @@ -0,0 +1,44 @@
+import { FetchOptions } from "../../adapters/types"
+import { CHAIN } from "../../helpers/chains"
+import axios from "axios"
+
+const BNB_ADDRESS = "0x0000000000000000000000000000000000000000"
+
+const apiBaseURL = "https://bd-fun-defilama-ts-backend-main.puppy.fun/lama-api"
+const feesMethod = "/fees"
+
+const maxRetriesCount = 3
+
+const fetch: any = async (options: FetchOptions) => {
+    for (let tryCount = 0; tryCount < maxRetriesCount; ++tryCount) {
+        try {
+            console.log(`Query Volume ...`)
+            const response = await axios.get(apiBaseURL + feesMethod)
+            console.log(response.data)
+
+            const fees = options.createBalances()
+            const revenue = options.createBalances()
+            fees.add(BNB_ADDRESS, response.data.totalFee)
+            // revenue == fees (no users fees)
+            revenue.add(BNB_ADDRESS, response.data.totalFee)
+
+            return {
+                totalFees: fees,
path: fees/puppyfun/index.ts
body: our backend exporter service is designed to return total volume only (for now) if it is necessary we will add such metric (can DeFi Lama display daily volume or fees based on the difference between "today fees" and "yesterday fees")?
created_at: 2025-03-11T07:36:44Z
author_association: NONE
diff_hunk: @@ -0,0 +1,39 @@
+import { FetchOptions } from "../../adapters/types"
+import { CHAIN } from "../../helpers/chains"
+import axios from "axios"
+
+const BNB_ADDRESS = "0x0000000000000000000000000000000000000000"
+
+const apiBaseURL = "https://bd-fun-defilama-ts-backend-main.puppy.fun/lama-api"
+const volumeMethod = "/volume"
+
+const maxRetriesCount = 3
+
+const fetch: any = async (options: FetchOptions) => {
+    for (let tryCount = 0; tryCount < maxRetriesCount; ++tryCount) {
+        try {
+            console.log(`Query Volume ...`)
+            const response = await axios.get(apiBaseURL + volumeMethod)
+
+            const volume = options.createBalances()
+            volume.add(BNB_ADDRESS, response.data.volume)
+
+            const totalVolume = Number(response.data.volume) / 10 ** 18
+            console.log(`Got Volume: ${totalVolume} BNB`, response.data.volume)
+            return { totalVolume: volume }
path: protocols/puppyfun/index.ts
user: login: dtmkeng
body: can you cal from your api ? llama can't 
created_at: 2025-03-11T07:39:17Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,44 @@
+import { FetchOptions } from "../../adapters/types"
+import { CHAIN } from "../../helpers/chains"
+import axios from "axios"
+
+const BNB_ADDRESS = "0x0000000000000000000000000000000000000000"
+
+const apiBaseURL = "https://bd-fun-defilama-ts-backend-main.puppy.fun/lama-api"
+const feesMethod = "/fees"
+
+const maxRetriesCount = 3
+
+const fetch: any = async (options: FetchOptions) => {
+    for (let tryCount = 0; tryCount < maxRetriesCount; ++tryCount) {
+        try {
+            console.log(`Query Volume ...`)
+            const response = await axios.get(apiBaseURL + feesMethod)
+            console.log(response.data)
+
+            const fees = options.createBalances()
+            const revenue = options.createBalances()
+            fees.add(BNB_ADDRESS, response.data.totalFee)
+            // revenue == fees (no users fees)
+            revenue.add(BNB_ADDRESS, response.data.totalFee)
+
+            return {
+                totalFees: fees,
path: fees/puppyfun/index.ts
body: In case we add daily volume in our collector service, do we have to provide "daily fees" for all previous days (since our contracts had been deployed)? or can we start collecting those metrics from "today"?
created_at: 2025-03-11T07:41:05Z
author_association: NONE
diff_hunk: @@ -0,0 +1,39 @@
+import { FetchOptions } from "../../adapters/types"
+import { CHAIN } from "../../helpers/chains"
+import axios from "axios"
+
+const BNB_ADDRESS = "0x0000000000000000000000000000000000000000"
+
+const apiBaseURL = "https://bd-fun-defilama-ts-backend-main.puppy.fun/lama-api"
+const volumeMethod = "/volume"
+
+const maxRetriesCount = 3
+
+const fetch: any = async (options: FetchOptions) => {
+    for (let tryCount = 0; tryCount < maxRetriesCount; ++tryCount) {
+        try {
+            console.log(`Query Volume ...`)
+            const response = await axios.get(apiBaseURL + volumeMethod)
+
+            const volume = options.createBalances()
+            volume.add(BNB_ADDRESS, response.data.volume)
+
+            const totalVolume = Number(response.data.volume) / 10 ** 18
+            console.log(`Got Volume: ${totalVolume} BNB`, response.data.volume)
+            return { totalVolume: volume }
path: protocols/puppyfun/index.ts
body: Okay, it will require a day / two to add & test
created_at: 2025-03-11T07:42:17Z
author_association: NONE
diff_hunk: @@ -0,0 +1,44 @@
+import { FetchOptions } from "../../adapters/types"
+import { CHAIN } from "../../helpers/chains"
+import axios from "axios"
+
+const BNB_ADDRESS = "0x0000000000000000000000000000000000000000"
+
+const apiBaseURL = "https://bd-fun-defilama-ts-backend-main.puppy.fun/lama-api"
+const feesMethod = "/fees"
+
+const maxRetriesCount = 3
+
+const fetch: any = async (options: FetchOptions) => {
+    for (let tryCount = 0; tryCount < maxRetriesCount; ++tryCount) {
+        try {
+            console.log(`Query Volume ...`)
+            const response = await axios.get(apiBaseURL + feesMethod)
+            console.log(response.data)
+
+            const fees = options.createBalances()
+            const revenue = options.createBalances()
+            fees.add(BNB_ADDRESS, response.data.totalFee)
+            // revenue == fees (no users fees)
+            revenue.add(BNB_ADDRESS, response.data.totalFee)
+
+            return {
+                totalFees: fees,
path: fees/puppyfun/index.ts
user: login: dtmkeng
body: yes example we track dailyFees dexs from event logs when user swap 
created_at: 2025-03-11T07:44:00Z
author_association: CONTRIBUTOR

PR comments:
user: login: ghost
created_at: 2025-03-10T22:27:17Z
body: Volume and Fees adapters for PuppyFun protocol
author_association: NONE
user: login: llamabutler
created_at: 2025-03-11T03:44:06Z
body: The puppyfun adapter exports:
        
 
 
    > adapters@1.0.0 test
    > ts-node --transpile-only cli/testAdapter.ts fees puppyfun
    
    🦙 Running PUPPYFUN adapter 🦙
    ---------------------------------------------------
    Start Date:	Mon, 10 Mar 2025 01:13:59 GMT
    End Date:	Tue, 11 Mar 2025 01:13:59 GMT
    ---------------------------------------------------
    
    Query Volume ...
    {
      swapFee: '24905011159526067777',
      migrationFee: '12101050000000000000',
      totalFee: '37006061159526067777'
    }
    BSC 👇
    Backfill start time not defined
    Total fees: 19.83 k
    Total revenue: 19.83 k
    End timestamp: 1741655638 (2025-03-11T01:13:58.000Z)
    
    
    
    
    
author_association: NONE
user: login: llamabutler
created_at: 2025-03-11T03:44:13Z
body: The puppyfun adapter exports:
        
 
 
    > adapters@1.0.0 test
    > ts-node --transpile-only cli/testAdapter.ts protocols puppyfun
    
    🦙 Running PUPPYFUN adapter 🦙
    ---------------------------------------------------
    Start Date:	Mon, 10 Mar 2025 01:14:08 GMT
    End Date:	Tue, 11 Mar 2025 01:14:08 GMT
    ---------------------------------------------------
    
    Query Volume ...
    Got Volume: 2490.501115952607 BNB 2490501115952607007936
    BSC 👇
    Backfill start time not defined
    Total volume: 1.33 M
    End timestamp: 1741655647 (2025-03-11T01:14:07.000Z)
    
    
    
    
    
author_association: NONE
user: login: llamabutler
created_at: 2025-03-11T03:44:59Z
body: The puppyfun adapter exports:
        
 
 
    > adapters@1.0.0 test
    > ts-node --transpile-only cli/testAdapter.ts fees puppyfun
    
    🦙 Running PUPPYFUN adapter 🦙
    ---------------------------------------------------
    Start Date:	Mon, 10 Mar 2025 01:14:50 GMT
    End Date:	Tue, 11 Mar 2025 01:14:50 GMT
    ---------------------------------------------------
    
    Query Volume ...
    {
      swapFee: '24905011159526067777',
      migrationFee: '12101050000000000000',
      totalFee: '37006061159526067777'
    }
    BSC 👇
    Backfill start time not defined
    Total fees: 19.83 k
    Total revenue: 19.83 k
    End timestamp: 1741655689 (2025-03-11T01:14:49.000Z)
    
    
    
    
    
author_association: NONE
user: login: llamabutler
created_at: 2025-03-11T03:45:06Z
body: The puppyfun adapter exports:
        
 
 
    > adapters@1.0.0 test
    > ts-node --transpile-only cli/testAdapter.ts protocols puppyfun
    
    🦙 Running PUPPYFUN adapter 🦙
    ---------------------------------------------------
    Start Date:	Mon, 10 Mar 2025 01:15:01 GMT
    End Date:	Tue, 11 Mar 2025 01:15:01 GMT
    ---------------------------------------------------
    
    Query Volume ...
    Got Volume: 2490.501115952607 BNB 2490501115952607007936
    BSC 👇
    Backfill start time not defined
    Total volume: 1.33 M
    End timestamp: 1741655700 (2025-03-11T01:15:00.000Z)
    
    
    
    
    
author_association: NONE
user: login: ghost
created_at: 2025-03-13T19:12:31Z
body: Hello! Please check the code below, added daily fees, daily revenue, daily volume metrics
author_association: NONE
user: login: llamabutler
created_at: 2025-03-14T06:14:41Z
body: The puppyfun adapter exports:
        
 
 
    > adapters@1.0.0 test
    > ts-node --transpile-only cli/testAdapter.ts fees puppyfun
    
    🦙 Running PUPPYFUN adapter 🦙
    ---------------------------------------------------
    Start Date:	Thu, 13 Mar 2025 03:44:31 GMT
    End Date:	Fri, 14 Mar 2025 03:44:31 GMT
    ---------------------------------------------------
    
    Query Volume ...
    {
      swapFee: '24907282929668913599',
      migrationFee: '12101050000000000000',
      creationFee: '5980000000000000000',
      totalFee: '42988332929668913599',
      dailySwapFee: '224999820127418',
      dailyMigrationFee: '0',
      dailyCreationFee: '0',
      dailyTotalFee: '224999820127418'
    }
    BSC 👇
    Backfill start time not defined
    Total fees: 24.99 k
    Total revenue: 24.99 k
    Daily fees: 0
    Daily revenue: 0
    End timestamp: 1741923870 (2025-03-14T03:44:30.000Z)
    
    
    
    
    
author_association: NONE
user: login: llamabutler
created_at: 2025-03-14T06:14:48Z
body: The puppyfun adapter exports:
        
 
 
    > adapters@1.0.0 test
    > ts-node --transpile-only cli/testAdapter.ts protocols puppyfun
    
    🦙 Running PUPPYFUN adapter 🦙
    ---------------------------------------------------
    Start Date:	Thu, 13 Mar 2025 03:44:42 GMT
    End Date:	Fri, 14 Mar 2025 03:44:42 GMT
    ---------------------------------------------------
    
    Query Volume ...
    Got Volume: 2490.728292966892 BNB 2490728292966891590218
    Got Daily Volume: 0.022499982012741834 BNB 22499982012741830
    BSC 👇
    Backfill start time not defined
    Total volume: 1.45 M
    Daily volume: 13
    End timestamp: 1741923881 (2025-03-14T03:44:41.000Z)
    
    
    
    
    
author_association: NONE