Skip to content

Commit

Permalink
Merge pull request #2234 from tyler-tsai/feat/supplement-lisusd-fees
Browse files Browse the repository at this point in the history
feat: supplement lisusd fees
  • Loading branch information
dtmkeng authored Dec 18, 2024
2 parents b9ca776 + 2e5701d commit 1cf6653
Showing 1 changed file with 175 additions and 76 deletions.
251 changes: 175 additions & 76 deletions fees/lista-lisusd/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import BigNumber from "bignumber.js";
import { FetchOptions, SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import ADDRESSES from "../../helpers/coreAssets.json";

const treasury = "0x8d388136d578dCD791D081c6042284CED6d9B0c6";

/**
* Fetches data from Lista DAO
Expand All @@ -15,147 +12,249 @@ const treasury = "0x8d388136d578dCD791D081c6042284CED6d9B0c6";
* https://bscscan.com/address/0x34b504a5cf0ff41f8a480580533b6dda687fa3da#tokentxns
*/

const oldTreasury =
"0x0000000000000000000000008d388136d578dcd791d081c6042284ced6d9b0c6";
const newTreasury =
"0x00000000000000000000000034b504a5cf0ff41f8a480580533b6dda687fa3da";
const zeroAddress =
"0x0000000000000000000000000000000000000000000000000000000000000000";
const transferHash =
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef";
const HelioETHProvider = "0x0326c157bfF399e25dd684613aEF26DBb40D3BA4";
// const MasterVault = "0x986b40C2618fF295a49AC442c5ec40febB26CC54";
const SnBnbYieldConverterStrategy =
"0x6F28FeC449dbd2056b76ac666350Af8773E03873";
"0x0000000000000000000000006f28fec449dbd2056b76ac666350af8773e03873";
const CeETHVault = "0xA230805C28121cc97B348f8209c79BEBEa3839C0";
const HayJoin = "0x4C798F81de7736620Cd8e6510158b1fE758e22F7";

// token
const lista = "0xFceB31A79F71AC9CBDCF853519c1b12D379EdC46";
const slisBNB = "0xb0b84d294e0c75a6abe60171b70edeb2efd14a1b";
const eth = "0x2170Ed0880ac9A755fd29B2688956BD959F933F8";
const wbeth = "0xa2e3356610840701bdf5611a53974510ae27e2e1";
const bnb = "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c";
const lisUSD = "0x0782b6d8c4551B9760e74c0545a9bCD90bdc41E5";

const usdt = "0x55d398326f99059ff775485246999027b3197955";
const fetch = async (options: FetchOptions) => {
const dailyFees = options.createBalances();

const logs_claim = await options.getLogs({
target: HelioETHProvider,
eventAbi: "event Claim(address recipient, uint256 amount)",
entireLog: true,
});

// enable later
// const logs_fees_claim = await options.getLogs({
// target: MasterVault,
// eventAbi: "event FeeClaimed(address receiver, uint256 amount)",
// });

const logs_fees_harvested = await options.getLogs({
target: SnBnbYieldConverterStrategy,
eventAbi: "event Harvested(address to, uint256 amount)",
});

// CeETHVault
const eth_transfer1 = await options.getLogs({
// eth staking profit - helioETHProvider and CeETHVault
const ethStakingEthOld = await options.getLogs({
target: eth,
topics: [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
transferHash,
"0x000000000000000000000000a230805c28121cc97b348f8209c79bebea3839c0",
"0x0000000000000000000000008d388136d578dcd791d081c6042284ced6d9b0c6",
oldTreasury,
],
});

const eth_transfer2 = await options.getLogs({
const ethStakingEthNew = await options.getLogs({
target: eth,
topics: [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
transferHash,
"0x000000000000000000000000a230805c28121cc97b348f8209c79bebea3839c0",
"0x00000000000000000000000034b504a5cf0ff41f8a480580533b6dda687fa3da",
newTreasury,
],
});
const ethStakingWbethOld = await options.getLogs({
target: wbeth,
topics: [
transferHash,
"0x000000000000000000000000a230805c28121cc97b348f8209c79bebea3839c0",
oldTreasury,
],
});
const ethStakingWbethNew = await options.getLogs({
target: wbeth,
topics: [
transferHash,
"0x000000000000000000000000a230805c28121cc97b348f8209c79bebea3839c0",
newTreasury,
],
});

// BNB Liquid Staking Fee - ListaStakeManager
const bnbLiquidStakingFeeOld = await options.getLogs({
target: slisBNB,
topics: [transferHash, zeroAddress, oldTreasury],
});
const bnbLiquidStakingFeeNew = await options.getLogs({
target: slisBNB,
topics: [transferHash, zeroAddress, newTreasury],
});

// BNB provide Fee - MasterVault
// No fees charged for now

// bnb liquid staking profit - SnBnbYieldConverterStrategy
const bnbLiquidStakingProfitOld = await options.getLogs({
target: slisBNB,
topics: [transferHash, SnBnbYieldConverterStrategy, oldTreasury],
});
const bnbLiquidStakingProfitNew = await options.getLogs({
target: slisBNB,
topics: [transferHash, SnBnbYieldConverterStrategy, newTreasury],
});

// flash loan
const lisusd_transfer1 = await options.getLogs({
// borrow lisUSD interest
const borrowLisUSDInterest = await options.getLogs({
target: lisUSD,
topics: [transferHash, zeroAddress, oldTreasury],
});
const borrowLisUSDInterestNew = await options.getLogs({
target: lisUSD,
topics: [transferHash, zeroAddress, newTreasury],
});

// veLista early claim penalty
const veListaEarlyClaimPenalty = await options.getLogs({
target: lista,
topics: [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x000000000000000000000000a230805c28121cc97b348f8209c79bebea3839c0",
"0x0000000000000000000000008d388136d578dcd791d081c6042284ced6d9b0c6",
transferHash,
"0x000000000000000000000000d0c380d31db43cd291e2bbe2da2fd6dc877b87b3",
oldTreasury,
],
});
const veListaEarlyClaimPenaltyNew = await options.getLogs({
target: lista,
topics: [
transferHash,
"0x000000000000000000000000d0c380d31db43cd291e2bbe2da2fd6dc877b87b3",
newTreasury,
],
});

//liquidation profit - flash buy

const lisusd_transfer2 = await options.getLogs({
const liquidationProfit = await options.getLogs({
target: lisUSD,
topics: [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x000000000000000000000000a230805c28121cc97b348f8209c79bebea3839c0",
"0x00000000000000000000000034b504a5cf0ff41f8a480580533b6dda687fa3da",
transferHash,
"0x0000000000000000000000009ba88e6b20041750fd4e6271fea455f5d44063cb",
newTreasury,
],
});

// early exit
const logs_exit1 = await options.getLogs({
target: HayJoin,
// liquidation profit - liquidation bot
const liquidationBot = await options.getLogs({
target: lisUSD,
topics: [
"0x22d324652c93739755cf4581508b60875ebdd78c20c0cff5cf8e23452b299631",
"0x0000000000000000000000008d388136d578dcd791d081c6042284ced6d9b0c6",
transferHash,
"0x00000000000000000000000008e83a96f4da5decc0e6e9084dde049a3e84ca04",
oldTreasury,
],
});
const liquidationBotNew = await options.getLogs({
target: lisUSD,
topics: [
transferHash,
"0x00000000000000000000000008e83a96f4da5decc0e6e9084dde049a3e84ca04",
newTreasury,
],
});

const logs_exit2 = await options.getLogs({
target: HayJoin,
// PSM convert Fee
const psmConvertFee = await options.getLogs({
target: lisUSD,
topics: [
"0x22d324652c93739755cf4581508b60875ebdd78c20c0cff5cf8e23452b299631",
"0x00000000000000000000000034b504a5cf0ff41f8a480580533b6dda687fa3da",
transferHash,
"0x000000000000000000000000aa57f36dd5ef2ac471863ec46277f976f272ec0c",
newTreasury,
],
});

// claim penalty
const early_claim_penalty1 = await options.getLogs({
target: lista,
// USDT staking profit - venusAdaptor
const usdtStakingProfit = await options.getLogs({
target: usdt,
topics: [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x000000000000000000000000d0c380d31db43cd291e2bbe2da2fd6dc877b87b3",
transferHash,
"0x000000000000000000000000f76d9cfd08df91491680313b1a5b44307129cda9",
"0x0000000000000000000000008d388136d578dcd791d081c6042284ced6d9b0c6",
],
});

const early_claim_penalty2 = await options.getLogs({
// veLista Auto Compound Fee - VeListaAutoCompounder
const veListaAutoCompoundFee = await options.getLogs({
target: lista,
topics: [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x000000000000000000000000d0c380d31db43cd291e2bbe2da2fd6dc877b87b3",
"0x00000000000000000000000034b504a5cf0ff41f8a480580533b6dda687fa3da",
transferHash,
"0x0000000000000000000000009a0530a81c83d3b0dae720bf91c9254fecc3bf5e",
newTreasury,
],
});

[...early_claim_penalty1, ...early_claim_penalty2].forEach((log) => {
const amount = Number(log.data);
dailyFees.add(lista, amount);
// validaator rewards - stake ListaDAOCredit
const validatorRewards = await options.getLogs({
target: "0xC096e7781c95a2fc6fEb1efE776B570270B3965d",
topics: [
transferHash,
zeroAddress,
"0x0000000000000000000000007766a5ee8294343bf6c8dcf3aa4b6d856606703a",
],
// target: "0xc096e7781c95a2fc6feb1efe776b570270b3965d",
// eventAbi:
// "event Transfer(address indexed from, address indexed to, uint256 value)",
});

logs_claim.forEach((log) => {
// todo: 12/25 add PCS income

// new version start
[...ethStakingEthOld, ...ethStakingEthNew].forEach((log) => {
const amount = Number(log.data);
dailyFees.add(eth, amount);
});

// enable later
// logs_fees_claim.forEach((log) => {
// const amount = log.amount;
// dailyFees.add(bnb, amount);
// });

logs_fees_harvested.forEach((log) => {
const amount = log.amount;
[...ethStakingWbethOld, ...ethStakingWbethNew].forEach((log) => {
const amount = Number(log.data);
dailyFees.add(wbeth, amount);
});
[...bnbLiquidStakingFeeOld, ...bnbLiquidStakingFeeNew].forEach((log) => {
const amount = Number(log.data);
dailyFees.add(slisBNB, amount);
});

[...eth_transfer1, ...eth_transfer2].forEach((log) => {
[...bnbLiquidStakingProfitOld, ...bnbLiquidStakingProfitNew].forEach(
(log) => {
const amount = Number(log.data);

dailyFees.add(slisBNB, amount);
}
);
[...borrowLisUSDInterest, ...borrowLisUSDInterestNew].forEach((log) => {
const amount = Number(log.data);
dailyFees.add(eth, amount);

dailyFees.add(lisUSD, amount);
});
[...veListaEarlyClaimPenalty, ...veListaEarlyClaimPenaltyNew].forEach(
(log) => {
const amount = Number(log.data);

[...lisusd_transfer1, ...lisusd_transfer2].forEach((log) => {
dailyFees.add(lista, amount);
}
);
[...liquidationProfit].forEach((log) => {
const amount = Number(log.data);
dailyFees.add(lisUSD, amount);
});

[...logs_exit1, ...logs_exit2].forEach((log) => {
dailyFees.add(lisUSD, Number(log.data));
[...veListaAutoCompoundFee].forEach((log) => {
const amount = Number(log.data);
dailyFees.add(lista, amount);
});

[...liquidationBot, ...liquidationBotNew].forEach((log) => {
const amount = Number(log.data);
dailyFees.add(lisUSD, amount);
});
[...psmConvertFee].forEach((log) => {
const amount = Number(log.data);
dailyFees.add(lisUSD, amount);
});
[...usdtStakingProfit].forEach((log) => {
const amount = Number(log.data);
dailyFees.add(usdt, amount);
});
[...validatorRewards].forEach((log) => {
const amount = Number(log.data);
dailyFees.add(bnb, amount);
});

return {
Expand All @@ -169,7 +268,7 @@ const adapter: SimpleAdapter = {
adapter: {
[CHAIN.BSC]: {
fetch,
start: '2023-08-30',
start: "2023-08-30",
},
},
};
Expand Down

0 comments on commit 1cf6653

Please sign in to comment.