Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update giveth adapter.js #13631

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 98 additions & 10 deletions projects/giveth/index.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
const { PublicKey } = require("@solana/web3.js");
const { sumTokens, sumTokens2 } = require("../helper/unwrapLPs");
const { sumUnknownTokens } = require("../helper/unknownTokens");
const { getConnection } = require("../helper/solana");

// Token Addresses
const GIV = "0x900db999074d9277c5da2a43f252d74366230da0";
const xdaiGIV = "0x4f4f9b8d5b4d0dc10506e5551b0513b61fd59e75";
const optimismGIV = "0x528CDc92eAB044E1E39FE43B9514bfdAB4412B98";
const polygonZKEVMGIV = "0xddAFB91475bBf6210a151FA911AC8fdA7dE46Ec2";
const solanaGIV = "3Xi3EhKjnKAk2KTChzybUSWcLW6eAgTHyotHH1U6sJE1";

// ✅ MAINNET
async function mainnetStaking(ts, block) {
const balances = {};
const tokensAndOwners = [
[GIV, "0x4B9EfAE862a1755F7CEcb021856D467E86976755"], // Mainnet LM
[GIV, "0x4B9EfAE862a1755F7CEcb021856D467E86976755"], // GIvfarm on Mainnet - Mainnet Liquidity Mining (LM)
];
await sumTokens(balances, tokensAndOwners, block);
return balances;
}

async function mainnetPools(_, block) {
const toa = [
[GIV, "0xbeba1666c62c65e58770376de332891b09461eeb"], // GIV / DAI Unipool
[GIV, "0xc3151A58d519B94E915f66B044De3E55F77c2dd9"], // Angel Vault
[GIV, "0x7819f1532c49388106f7762328c51ee70edd134c"], // GIV / ETH Balancer
[GIV, "0x6873789a71b18efa98a8e8758a5ea456d70c178f"], // FOX/GIV - Balancer - Owned by Giveth DAO
[GIV, "0xc763b6b3d0f75167db95daa6a0a0d75dd467c4e1"], // GIV / WETH - Uniswap V3 - Owned by Giveth DAO
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, this is wrong, should have been caught in the previous PR, only staked LP token is counted as pool2, your token locked in dex belongs to dex tvl not yours

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@g1nt0ki could you clarify me which CAs we have to write down on each function please?

async functions on Adapter

  • staking[chain] - we are leaving the contracts where community do Liquidity mining in our GIVfarms on Gnosis, Optimism and Polygon ZKEVm.
async function stakingOptimism() {
  const balance = await sumUnknownTokens({
    owners: {
  • pool[chain] - we are using all the liquidity pools, owned and not owned.
async function poolOptimism() {
  const balance = await sumUnknownTokens({
    owners: [

Treasury

When you mentioned that owned liqudiity must be treasury , where we have to send a PR to add these LPs?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can update the adapter to something like this: https://github.com/DefiLlama/DefiLlama-Adapters/blob/main/projects/mobox.js

staking - for gov token staking
pool2 - for lps staked in your farm

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@g1nt0ki i left me give a littile context about how GIV token works in our farms and maybe clarify better the update of this adapter:

GIV TOKEN

Users can get GIV token on across OP, Polzkevm, Gnosis, Mainnet, solana. These are the CAs of our token across those chains:

GIV token is not a Governance token itself but it could become a governance token once users STAKE the GIV token in our GIVfarm. Currenlty, the stake is allowed on Gnosis, Optimism and Polygon ZKEVM.

GIVPOWER

When users STAKE the GIV token they get Rewards on GIV token and Voting power represented by GIVpower, the governance token. There are a relation 1:1 between GIVpower and GIVtoken. Following are the CAs of GIVpower in each chain:

Nevertherles, users can INCREASE their rewards and their Governance token when they LOCK. More time locked, more "multiplier" for their rewards and voting power (GIVpower). Users can do this in the GIVfarm and It's allowed only when they have GIV staked.

This GIVpower have 3 Main utilities:

  • GIVpower holders can use their GIVpower to "improve" the listing of the projects our donation platform: https://giveth.io/es/projects/all
  • These GIVpower "back-up" increase the oods of the donors of the project to win the raffle of our GIVbacks Program. These raflle plays each 15 days until Dec 2026.
  • Voting Power in our snapshot: https://snapshot.box/#/s:giv.eth

Liquidity Pools

Giveth have built Liquidity pools across these chains to allow the price discovery. Some of these liquidity are owned by the DAO and some are owned by the partner or community.

Liquidity Pools owned by Giveth: / i will update this in the treasury

Liquidity Pools not owned by Giveth

Copy link
Author

@wmb81321 wmb81321 Mar 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, @g1nt0ki,

For Staking Function, in the PR we have the Addreses for our Gov staking contracs, which are the following by each chain:

  • Mainnet: 0x4B9EfAE862a1755F7CEcb021856D467E86976755
  • Gnosis: 0x24F2d06446AF8D6E89fEbC205e7936a602a87b60
  • Optimis: 0x301C739CF6bfb6B47A74878BdEB13f92F13Ae5E7 / added on this PR
  • Polygon ZKEVM: 0xc790f82bf6f8709aa4a56dc11afad7af7c2a9867 / Added on this PR
  • solana: We dont have any contract for gov staking on Solana.

For Pool Function, i have to change the LPs owned by giveth fpr the LPs not owned by Giveth? I know that i have to add the owned LPs here: Adapter of treasury for Giveth.

Have in mind that all our LPs are open to participate by anyone. We have some of those liquidity pools in our last PR and i'm just adding new LPs that were not in the last PR.

[GIV, "0x7819f1532c49388106f7762328c51eE70EdD134c"], // GIV / WETH - Balancer - Not Owned
];
return sumTokens2({ tokensAndOwners: toa, block });
}

// ✅ GNOSIS (xDAI)
async function stakingXDAI() {
const balance = await sumUnknownTokens({
owners: ["0x24F2d06446AF8D6E89fEbC205e7936a602a87b60"], // GIV Garden
owners: ["0x24F2d06446AF8D6E89fEbC205e7936a602a87b60"], // GIvfarm on Gnosis
tokens: [xdaiGIV],
chain: "xdai",
});
Expand All @@ -34,26 +42,106 @@ async function stakingXDAI() {
async function poolXDAI() {
const balance = await sumUnknownTokens({
owners: [
"0x08ea9f608656A4a775EF73f5B187a2F1AE2ae10e", // GIV / HNY
"0x55FF0cef43F0DF88226E9D87D09fA036017F5586", // GIV / ETH
"0xB7189A7Ea38FA31210A79fe282AEC5736Ad5fA57", // GIV / XDAI
"0xbf945292dc5cbbc8b742083f87d502699cb27414", // GNO - Balancer - Owned By Giveth DAO
"0x85dc9beb2571298c9197ec16fafa556a85e41eae", // BRIGTH - Balancer - Owned by Giveth DAO
"0x08ea9f608656a4a775ef73f5b187a2f1ae2ae10e", // HNY - Honeyswap - Owned By Giveth DAO
"0xdccAa73705dC7457bcfb3dAFEe529B30920e3008", // GNO - Balancer - Not Owned
"0xb7189a7ea38fa31210a79fe282aec5736ad5fa57", // xDAI - Honeyswap - Not Owned
"0x75594f01da2e4231e16e67f841c307c4df2313d1", // FOX - Honeyswap - Not Owned
"0x55ff0cef43f0df88226e9d87d09fa036017f5586", // WETH - Sushiswap - Not owned
],
tokens: [xdaiGIV],
chain: "xdai",
});
return balance;
}

// ✅ OPTIMISM
async function stakingOptimism() {
const balance = await sumUnknownTokens({
owners: ["0x301C739CF6bfb6B47A74878BdEB13f92F13Ae5E7"], // GIvfarm on Optimism
tokens: [optimismGIV],
chain: "optimism",
});
return balance;
}

async function poolOptimism() {
const balance = await sumUnknownTokens({
owners: [
"0xc2ab457e31c224da284df7afda70c39523df4972", // OP - Velodrome - Owned By Giveth DAO
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LPs owned by the dao counts as treasury not tvl

"0x165E6DAD9772C8CB44015eDD5bd8b012A84bd276", // USDGLO - Uniswap V3 - Owned By Giveth DAO
"0x969e1D236289742C9D36eA1c7124cdDb84397772", // DAI - Uniswap V3 - Owned By Giveth DAO
"0xaac7d612c1f23a45967f772ea587963952cc0b80", // TEC - Velodrome - Owned By Giveth DAO
],
tokens: [optimismGIV],
chain: "optimism",
});
return balance;
}

// ✅ POLYGON ZKEVM
async function stakingPolygonZKEVM() {
const balance = await sumUnknownTokens({
owners: ["0xc790f82bf6f8709aa4a56dc11afad7af7c2a9867"], // GIVFarm on Polygon ZKEVM
tokens: [polygonZKEVMGIV],
chain: "polygon_zkevm",
});
return balance;
}

async function poolPolygonZKEVM() {
const balance = await sumUnknownTokens({
owners: [
"0x50f99d234872d99e4324bd287c50da3317cb3473", // POL - Quickswap - Owned by Owned By Giveth DAO
"0x30c99b07271d9a7143c324f04c77642262380c88", // WETH - Quickswap - Not owned
],
tokens: [polygonZKEVMGIV],
chain: "polygon_zkevm",
});
return balance;
}

// ✅ SOLANA (Proper Implementation)
async function stakingSolana() {
const connection = getConnection();
const tokenAccounts = await connection.getParsedTokenAccountsByOwner(
new PublicKey("E7yVYRW2HZVXcreRE2asLs4HmtyviGbnnTXTarj7uDjc"), // heeeeerreeeeeeeeeee
{ mint: new PublicKey(solanaGIV) }
);

let totalBalance = 0;
tokenAccounts.value.forEach((account) => {
totalBalance += Number(account.account.data.parsed.info.tokenAmount.uiAmount);
});

return { solana: totalBalance };
}

// ✅ EXPORT ALL TOGETHER (No Duplicate Exports)
module.exports = {
methodology: "Counts GIV staked in all farms",
ethereum: {
tvl: () => ({}),
tvl: mainnetPools,
staking: mainnetStaking,
pool2: mainnetPools,
},
xdai: {
tvl: () => ({}),
tvl: poolXDAI,
staking: stakingXDAI,
pool2: poolXDAI,
},
optimism: {
tvl: poolOptimism,
staking: stakingOptimism,
pool2: poolOptimism,
},
polygon_zkevm: {
tvl: poolPolygonZKEVM,
staking: stakingPolygonZKEVM,
pool2: poolPolygonZKEVM,
},
solana: {
tvl: stakingSolana,
},
};
Loading