Skip to content

Commit 5941258

Browse files
authored
Merge pull request #42 from idan-orbs/overnight
Fixed Overnight strategy
2 parents 6468f86 + 03723e3 commit 5941258

3 files changed

Lines changed: 17 additions & 17 deletions

File tree

_test/test-overnight.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async function testPayout(network, fromBlock, toBlock) {
3131

3232
}
3333

34-
async function testStrategy(network, strategyName, fromBlock, toBlock) {
34+
async function testStrategy(network, fromBlock, toBlock) {
3535

3636
const providerUrl = require("./dev-keys.json")[`web3${network}`]
3737

@@ -52,7 +52,7 @@ async function testStrategy(network, strategyName, fromBlock, toBlock) {
5252
const form = await strategyNotification.onSubscribeForm({});
5353

5454
const subscription = {
55-
strategy: strategyName,
55+
strategy: form.find(o => o.id === 'strategy').values[0].value,
5656
};
5757

5858
console.log(form);
@@ -74,11 +74,11 @@ async function main() {
7474
console.log(await testPayout("optimism", 106155876, 106155878));
7575
// console.log(await testPayout("zksync", 730251, 730253));
7676

77-
console.log(await testStrategy("polygon", "Balancer USDC", 44512809, 44512809));
78-
console.log(await testStrategy("arbitrum", "Sushiswap USDC/USDT", 110392139, 110392141));
79-
console.log(await testStrategy("bsc", "Thena USDC/USDT", 29875608, 29875608));
80-
console.log(await testStrategy("optimism", "Pika v4", 106777666, 106777666));
81-
// console.log(await testStrategy("zksync", "Nexon USDC", 2279899, 2279899));
77+
console.log(await testStrategy("polygon", 44512809, 44512809));
78+
console.log(await testStrategy("arbitrum", 110392139, 110392141));
79+
console.log(await testStrategy("bsc", 29875608, 29875608));
80+
console.log(await testStrategy("optimism", 106777666, 106777666));
81+
// console.log(await testStrategy("zksync", 2279899, 2279899));
8282
}
8383

8484

overnight/project.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"category": "defi",
44
"website": "https://overnight.fi",
55
"logo": "logo.png",
6-
"background": "#418aca",
7-
"foreground": "#ffffff",
6+
"background": "#15141D",
7+
"foreground": "#28A0F0",
88
"network": "arbitrum",
99
"dev": true
1010
}

overnight/strategy-base.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ class StrategyBase {
1515

1616
async _getStrategies() {
1717
const result = await (await fetch(`https://api.overnight.fi/${this.network}/usd+/dict/strategies`)).json();
18-
return result.reduce((acc, curr) => {
19-
acc[curr.fullName] = curr.address;
20-
return acc;
21-
}, {});
18+
return result.map(
19+
x => {return {value: x.address, label: x.fullName}}
20+
)
2221
}
2322

2423
/**
@@ -38,15 +37,15 @@ class StrategyBase {
3837
id: "strategy",
3938
label: "Strategy",
4039
description: "Select a strategy you wish to get alerts for",
41-
values: Object.keys(this.strategies)
40+
values: this.strategies
4241
}
4342
];
4443
}
4544

4645
async onBlocks(args) {
4746
const notifications = [];
4847

49-
const selectedStrategy = args.subscription["strategy"]
48+
const selectedStrategyAddress = args.subscription["strategy"];
5049

5150
const events = await this.portMgrContract.getPastEvents("StrategyWeightUpdated", {
5251
fromBlock: args.fromBlock,
@@ -55,10 +54,11 @@ class StrategyBase {
5554

5655
if (events.length > 0) {
5756
for (const event of events) {
58-
if (event.returnValues.strategy === this.strategies[selectedStrategy]) {
57+
if (event.returnValues.strategy === selectedStrategyAddress) {
58+
const selectedStrategyName = this.strategies.find(s => s.value === selectedStrategyAddress).label
5959
notifications.push({
6060
uniqueId: `${event.transactionHash}${event.returnValues.strategy}`,
61-
notification: `Strategy '${selectedStrategy}' has been updated (${this.network.charAt(0).toUpperCase() + this.network.slice(1)})`
61+
notification: `Strategy '${selectedStrategyName}' has been updated (${this.network.charAt(0).toUpperCase() + this.network.slice(1)})`
6262
})
6363
}
6464
}

0 commit comments

Comments
 (0)