Skip to content

Commit

Permalink
sdFXS delegation [sd-gauge-less-vote-boost] (snapshot-labs#1581)
Browse files Browse the repository at this point in the history
* sdvote-balanceof-twavp-pool

* sd-gauge-less-vote-boost - add veSDT boost for MS

* add delegation

* fix merge

* fix merge

* change address

* change address

* delegation
  • Loading branch information
pierremarsotlyon1 authored Sep 16, 2024
1 parent 3746739 commit 53452df
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/strategies/sd-gauge-less-vote-boost/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"whiteListedAddress": ["0x1c0D72a330F2768dAF718DEf8A19BAb019EEAd09"],
"veSDTUserAddresses": {},
"delegation": {
"0xBf911AF95bC5FE348F468b6D6928df7E7fC278e3": "0xF930EBBd05eF8b25B1797b9b2109DDC9B0d43063"
"0xBf911AF95bC5FE348F468b6D6928df7E7fC278e3": "0x20aCB38B9268F694657EbefcD2aC9bCb8A103D2e"
},
"targetChainId": "252",
"blocksPerDay": 43200
Expand All @@ -31,7 +31,7 @@
"0x10c16c7B8b1DDCFE65990ec822DE4379dd8a86dE",
"0x034f978581617FcABB75bfBe697d2230a3285437",
"0xF930EBBd05eF8b25B1797b9b2109DDC9B0d43063",
"0xBf911AF95bC5FE348F468b6D6928df7E7fC278e3"
"0x20aCB38B9268F694657EbefcD2aC9bCb8A103D2e"
],
"snapshot": 20712893
}
Expand Down
35 changes: 25 additions & 10 deletions src/strategies/sd-gauge-less-vote-boost/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ export async function strategy(
const veSDTUserAddresses = options.veSDTUserAddresses || {};
const veSDTUserAddressesMap = {};
for (const address of Object.keys(veSDTUserAddresses)) {
veSDTUserAddressesMap[address.toLowerCase()] =
veSDTUserAddresses[address].toLowerCase();
veSDTUserAddressesMap[address.toLowerCase()] = veSDTUserAddresses[address].toLowerCase();

Check failure on line 68 in src/strategies/sd-gauge-less-vote-boost/index.ts

View workflow job for this annotation

GitHub Actions / lint / Lint

Insert `⏎·····`
}

const mainnetCalls: any[] = [[VE_SDT, 'totalSupply']];
Expand Down Expand Up @@ -170,7 +169,7 @@ export async function strategy(
responsesDestinationChain.push(callResp);
}

return Object.fromEntries(
const vp = Object.fromEntries(
Array(addresses.length)
.fill('x')
.map((_, i) => {
Expand Down Expand Up @@ -207,16 +206,32 @@ export async function strategy(
options.whiteListedAddress
);

// Check if we have a delegation, if yes, use the delegated address instead of the current address
const delegation = delegations.find(
(d) => d.source === addresses[i].toLowerCase()
);
const address = delegation ? delegation.destination : addresses[i];

// Return address and voting power
return [getAddress(address), Number(averageWorkingBalance)];
return [addresses[i], Number(averageWorkingBalance)];
})
);

// Manage delegation
for(const addr of Object.keys(vp)) {

Check failure on line 215 in src/strategies/sd-gauge-less-vote-boost/index.ts

View workflow job for this annotation

GitHub Actions / lint / Lint

Insert `·`
for(const delegation of delegations) {

Check failure on line 216 in src/strategies/sd-gauge-less-vote-boost/index.ts

View workflow job for this annotation

GitHub Actions / lint / Lint

Insert `·`
if(addr.toLowerCase() === delegation.destination.toLowerCase()) {

Check failure on line 217 in src/strategies/sd-gauge-less-vote-boost/index.ts

View workflow job for this annotation

GitHub Actions / lint / Lint

Insert `·`
let vpToAdd = 0;
for(const addrTmp of Object.keys(vp)) {

Check failure on line 219 in src/strategies/sd-gauge-less-vote-boost/index.ts

View workflow job for this annotation

GitHub Actions / lint / Lint

Insert `·`
if(addrTmp.toLowerCase() === delegation.source.toLowerCase()) {

Check failure on line 220 in src/strategies/sd-gauge-less-vote-boost/index.ts

View workflow job for this annotation

GitHub Actions / lint / Lint

Insert `·`
vpToAdd = vp[addrTmp] || 0;
break;
}
}
vp[addr] += vpToAdd;
break;
}
}
}

return Object.keys(vp).reduce((acc, addr) => {
acc[getAddress(addr)] = vp[addr];
return acc;
} , {});

Check failure on line 234 in src/strategies/sd-gauge-less-vote-boost/index.ts

View workflow job for this annotation

GitHub Actions / lint / Lint

Delete `·`
}

function getPreviousBlocks(
Expand Down

0 comments on commit 53452df

Please sign in to comment.