@strkfarm/sdk 1.0.15 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +58 -8
- package/dist/cli.mjs +53 -3
- package/dist/index.browser.global.js +1797 -7
- package/dist/index.d.ts +233 -43
- package/dist/index.js +2058 -259
- package/dist/index.mjs +2052 -257
- package/package.json +2 -2
- package/src/data/vesu-rebalance.abi.json +1473 -0
- package/src/dataTypes/bignumber.ts +4 -2
- package/src/global.ts +11 -1
- package/src/index.ts +4 -1
- package/src/interfaces/common.ts +15 -0
- package/src/modules/pricer.ts +12 -5
- package/src/strategies/index.ts +2 -1
- package/src/strategies/vesu-rebalance.ts +429 -0
- package/src/utils/index.ts +7 -4
package/dist/index.mjs
CHANGED
|
@@ -25,7 +25,13 @@ var FatalError = class extends Error {
|
|
|
25
25
|
this.name = "FatalError";
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
-
var tokens = [
|
|
28
|
+
var tokens = [{
|
|
29
|
+
name: "Starknet",
|
|
30
|
+
symbol: "STRK",
|
|
31
|
+
address: "0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",
|
|
32
|
+
decimals: 18,
|
|
33
|
+
coingeckId: "starknet"
|
|
34
|
+
}];
|
|
29
35
|
var Global = class {
|
|
30
36
|
static fatalError(message, err) {
|
|
31
37
|
logger.error(message);
|
|
@@ -38,6 +44,9 @@ var Global = class {
|
|
|
38
44
|
logger.error(`${url}: ${message}`);
|
|
39
45
|
console.error(err);
|
|
40
46
|
}
|
|
47
|
+
static getDefaultTokens() {
|
|
48
|
+
return tokens;
|
|
49
|
+
}
|
|
41
50
|
static async getTokens() {
|
|
42
51
|
if (tokens.length) return tokens;
|
|
43
52
|
const data = await axios.get("https://starknet.api.avnu.fi/v1/starknet/tokens");
|
|
@@ -79,10 +88,12 @@ var Web3Number = class _Web3Number extends BigNumber {
|
|
|
79
88
|
return this.mul(10 ** this.decimals).toFixed(0);
|
|
80
89
|
}
|
|
81
90
|
multipliedBy(value) {
|
|
82
|
-
|
|
91
|
+
let _value = Number(value).toFixed(6);
|
|
92
|
+
return new _Web3Number(this.mul(_value).toString(), this.decimals);
|
|
83
93
|
}
|
|
84
94
|
dividedBy(value) {
|
|
85
|
-
|
|
95
|
+
let _value = Number(value).toFixed(6);
|
|
96
|
+
return new _Web3Number(this.div(_value).toString(), this.decimals);
|
|
86
97
|
}
|
|
87
98
|
plus(value) {
|
|
88
99
|
return new _Web3Number(this.add(value).toString(), this.decimals);
|
|
@@ -130,6 +141,11 @@ var ContractAddr = class _ContractAddr {
|
|
|
130
141
|
|
|
131
142
|
// src/modules/pricer.ts
|
|
132
143
|
var CoinMarketCap = __require("coinmarketcap-api");
|
|
144
|
+
var PricerBase = class {
|
|
145
|
+
async getPrice(tokenSymbol) {
|
|
146
|
+
throw new Error("Method not implemented");
|
|
147
|
+
}
|
|
148
|
+
};
|
|
133
149
|
var Pricer = class {
|
|
134
150
|
constructor(config, tokens2) {
|
|
135
151
|
this.tokens = [];
|
|
@@ -188,10 +204,10 @@ var Pricer = class {
|
|
|
188
204
|
assertNotStale(timestamp, tokenName) {
|
|
189
205
|
Global.assert(!this.isStale(timestamp, tokenName), `Price of ${tokenName} is stale`);
|
|
190
206
|
}
|
|
191
|
-
async getPrice(
|
|
192
|
-
Global.assert(this.prices[
|
|
193
|
-
this.assertNotStale(this.prices[
|
|
194
|
-
return this.prices[
|
|
207
|
+
async getPrice(tokenSymbol) {
|
|
208
|
+
Global.assert(this.prices[tokenSymbol], `Price of ${tokenSymbol} not found`);
|
|
209
|
+
this.assertNotStale(this.prices[tokenSymbol].timestamp, tokenSymbol);
|
|
210
|
+
return this.prices[tokenSymbol];
|
|
195
211
|
}
|
|
196
212
|
_loadPrices(onUpdate = () => {
|
|
197
213
|
}) {
|
|
@@ -681,257 +697,1874 @@ var AutoCompounderSTRK = class {
|
|
|
681
697
|
}
|
|
682
698
|
};
|
|
683
699
|
|
|
684
|
-
// src/
|
|
685
|
-
import
|
|
686
|
-
var TelegramNotif = class {
|
|
687
|
-
constructor(token, shouldPoll) {
|
|
688
|
-
this.subscribers = [
|
|
689
|
-
// '6820228303',
|
|
690
|
-
"1505578076",
|
|
691
|
-
// '5434736198', // maaza
|
|
692
|
-
"1356705582",
|
|
693
|
-
// langs
|
|
694
|
-
"1388729514",
|
|
695
|
-
// hwashere
|
|
696
|
-
"6020162572",
|
|
697
|
-
//minato
|
|
698
|
-
"985902592"
|
|
699
|
-
];
|
|
700
|
-
this.bot = new TelegramBot(token, { polling: shouldPoll });
|
|
701
|
-
}
|
|
702
|
-
// listen to start msgs, register chatId and send registered msg
|
|
703
|
-
activateChatBot() {
|
|
704
|
-
this.bot.on("message", (msg) => {
|
|
705
|
-
const chatId = msg.chat.id;
|
|
706
|
-
let text = msg.text.toLowerCase().trim();
|
|
707
|
-
logger.verbose(`Tg: IncomingMsg: ID: ${chatId}, msg: ${text}`);
|
|
708
|
-
if (text == "start") {
|
|
709
|
-
this.bot.sendMessage(chatId, "Registered");
|
|
710
|
-
this.subscribers.push(chatId);
|
|
711
|
-
logger.verbose(`Tg: New subscriber: ${chatId}`);
|
|
712
|
-
} else {
|
|
713
|
-
this.bot.sendMessage(chatId, "Unrecognized command. Supported commands: start");
|
|
714
|
-
}
|
|
715
|
-
});
|
|
716
|
-
}
|
|
717
|
-
// send a given msg to all registered users
|
|
718
|
-
sendMessage(msg) {
|
|
719
|
-
logger.verbose(`Tg: Sending message: ${msg}`);
|
|
720
|
-
for (let chatId of this.subscribers) {
|
|
721
|
-
this.bot.sendMessage(chatId, msg).catch((err) => {
|
|
722
|
-
logger.error(`Tg: Error sending msg to ${chatId}`);
|
|
723
|
-
logger.error(`Tg: Error sending message: ${err.message}`);
|
|
724
|
-
}).then(() => {
|
|
725
|
-
logger.verbose(`Tg: Message sent to ${chatId}`);
|
|
726
|
-
});
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
};
|
|
730
|
-
|
|
731
|
-
// src/utils/store.ts
|
|
732
|
-
import fs, { readFileSync, writeFileSync } from "fs";
|
|
733
|
-
import { Account, constants } from "starknet";
|
|
734
|
-
import * as crypto2 from "crypto";
|
|
735
|
-
|
|
736
|
-
// src/utils/encrypt.ts
|
|
737
|
-
import * as crypto from "crypto";
|
|
738
|
-
var PasswordJsonCryptoUtil = class {
|
|
739
|
-
constructor() {
|
|
740
|
-
this.algorithm = "aes-256-gcm";
|
|
741
|
-
this.keyLength = 32;
|
|
742
|
-
// 256 bits
|
|
743
|
-
this.saltLength = 16;
|
|
744
|
-
// 128 bits
|
|
745
|
-
this.ivLength = 12;
|
|
746
|
-
// 96 bits for GCM
|
|
747
|
-
this.tagLength = 16;
|
|
748
|
-
// 128 bits
|
|
749
|
-
this.pbkdf2Iterations = 1e5;
|
|
750
|
-
}
|
|
751
|
-
// Number of iterations for PBKDF2
|
|
752
|
-
deriveKey(password, salt) {
|
|
753
|
-
return crypto.pbkdf2Sync(password, salt, this.pbkdf2Iterations, this.keyLength, "sha256");
|
|
754
|
-
}
|
|
755
|
-
encrypt(data, password) {
|
|
756
|
-
const jsonString = JSON.stringify(data);
|
|
757
|
-
const salt = crypto.randomBytes(this.saltLength);
|
|
758
|
-
const iv = crypto.randomBytes(this.ivLength);
|
|
759
|
-
const key = this.deriveKey(password, salt);
|
|
760
|
-
const cipher = crypto.createCipheriv(this.algorithm, key, iv, { authTagLength: this.tagLength });
|
|
761
|
-
let encrypted = cipher.update(jsonString, "utf8", "hex");
|
|
762
|
-
encrypted += cipher.final("hex");
|
|
763
|
-
const tag = cipher.getAuthTag();
|
|
764
|
-
return Buffer.concat([salt, iv, tag, Buffer.from(encrypted, "hex")]).toString("base64");
|
|
765
|
-
}
|
|
766
|
-
decrypt(encryptedData, password) {
|
|
767
|
-
const data = Buffer.from(encryptedData, "base64");
|
|
768
|
-
const salt = data.subarray(0, this.saltLength);
|
|
769
|
-
const iv = data.subarray(this.saltLength, this.saltLength + this.ivLength);
|
|
770
|
-
const tag = data.subarray(this.saltLength + this.ivLength, this.saltLength + this.ivLength + this.tagLength);
|
|
771
|
-
const encrypted = data.subarray(this.saltLength + this.ivLength + this.tagLength);
|
|
772
|
-
const key = this.deriveKey(password, salt);
|
|
773
|
-
const decipher = crypto.createDecipheriv(this.algorithm, key, iv, { authTagLength: this.tagLength });
|
|
774
|
-
decipher.setAuthTag(tag);
|
|
775
|
-
try {
|
|
776
|
-
let decrypted = decipher.update(encrypted.toString("hex"), "hex", "utf8");
|
|
777
|
-
decrypted += decipher.final("utf8");
|
|
778
|
-
return JSON.parse(decrypted);
|
|
779
|
-
} catch (error) {
|
|
780
|
-
throw new Error("Decryption failed. This could be due to an incorrect password or corrupted data.");
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
};
|
|
784
|
-
|
|
785
|
-
// src/utils/store.ts
|
|
786
|
-
function getDefaultStoreConfig(network) {
|
|
787
|
-
if (!process.env.HOME) {
|
|
788
|
-
throw new Error("StoreConfig: HOME environment variable not found");
|
|
789
|
-
}
|
|
790
|
-
return {
|
|
791
|
-
SECRET_FILE_FOLDER: `${process.env.HOME}/.starknet-store`,
|
|
792
|
-
NETWORK: network,
|
|
793
|
-
ACCOUNTS_FILE_NAME: "accounts.json",
|
|
794
|
-
PASSWORD: crypto2.randomBytes(16).toString("hex")
|
|
795
|
-
};
|
|
796
|
-
}
|
|
797
|
-
var Store = class _Store {
|
|
798
|
-
constructor(config, storeConfig) {
|
|
799
|
-
this.encryptor = new PasswordJsonCryptoUtil();
|
|
800
|
-
this.config = config;
|
|
801
|
-
const defaultStoreConfig = getDefaultStoreConfig(config.network);
|
|
802
|
-
if (!storeConfig.PASSWORD) {
|
|
803
|
-
_Store.logPassword(defaultStoreConfig.PASSWORD);
|
|
804
|
-
}
|
|
805
|
-
this.storeConfig = {
|
|
806
|
-
...defaultStoreConfig,
|
|
807
|
-
...storeConfig
|
|
808
|
-
};
|
|
809
|
-
_Store.ensureFolder(this.storeConfig.SECRET_FILE_FOLDER);
|
|
810
|
-
}
|
|
811
|
-
static logPassword(password) {
|
|
812
|
-
logger.warn(`\u26A0\uFE0F=========================================\u26A0\uFE0F`);
|
|
813
|
-
logger.warn(`Generated a random password for store`);
|
|
814
|
-
logger.warn(`\u26A0\uFE0F Password: ${password}`);
|
|
815
|
-
logger.warn(`This not stored anywhere, please you backup this password for future use`);
|
|
816
|
-
logger.warn(`\u26A0\uFE0F=========================================\u26A0\uFE0F`);
|
|
817
|
-
}
|
|
818
|
-
getAccount(accountKey, txVersion = constants.TRANSACTION_VERSION.V2) {
|
|
819
|
-
const accounts = this.loadAccounts();
|
|
820
|
-
logger.verbose(`nAccounts loaded for network: ${Object.keys(accounts).length}`);
|
|
821
|
-
const data = accounts[accountKey];
|
|
822
|
-
if (!data) {
|
|
823
|
-
throw new Error(`Account not found: ${accountKey}`);
|
|
824
|
-
}
|
|
825
|
-
logger.verbose(`Account loaded: ${accountKey} from network: ${this.config.network}`);
|
|
826
|
-
logger.verbose(`Address: ${data.address}`);
|
|
827
|
-
const acc = new Account(this.config.provider, data.address, data.pk, void 0, txVersion);
|
|
828
|
-
return acc;
|
|
829
|
-
}
|
|
830
|
-
addAccount(accountKey, address, pk) {
|
|
831
|
-
const allAccounts = this.getAllAccounts();
|
|
832
|
-
if (!allAccounts[this.config.network]) {
|
|
833
|
-
allAccounts[this.config.network] = {};
|
|
834
|
-
}
|
|
835
|
-
allAccounts[this.config.network][accountKey] = {
|
|
836
|
-
address,
|
|
837
|
-
pk
|
|
838
|
-
};
|
|
839
|
-
const encryptedData = this.encryptor.encrypt(allAccounts, this.storeConfig.PASSWORD);
|
|
840
|
-
writeFileSync(this.getAccountFilePath(), encryptedData);
|
|
841
|
-
logger.verbose(`Account added: ${accountKey} to network: ${this.config.network}`);
|
|
842
|
-
}
|
|
843
|
-
getAccountFilePath() {
|
|
844
|
-
const path = `${this.storeConfig.SECRET_FILE_FOLDER}/${this.storeConfig.ACCOUNTS_FILE_NAME}`;
|
|
845
|
-
logger.verbose(`Path: ${path}`);
|
|
846
|
-
return path;
|
|
847
|
-
}
|
|
848
|
-
getAllAccounts() {
|
|
849
|
-
const PATH = this.getAccountFilePath();
|
|
850
|
-
if (!fs.existsSync(PATH)) {
|
|
851
|
-
logger.verbose(`Accounts: files doesnt exist`);
|
|
852
|
-
return {};
|
|
853
|
-
}
|
|
854
|
-
let encryptedData = readFileSync(PATH, {
|
|
855
|
-
encoding: "utf-8"
|
|
856
|
-
});
|
|
857
|
-
let data = this.encryptor.decrypt(encryptedData, this.storeConfig.PASSWORD);
|
|
858
|
-
return data;
|
|
859
|
-
}
|
|
860
|
-
/**
|
|
861
|
-
* @description Load all accounts of the network
|
|
862
|
-
* @returns NetworkAccounts
|
|
863
|
-
*/
|
|
864
|
-
loadAccounts() {
|
|
865
|
-
const allData = this.getAllAccounts();
|
|
866
|
-
logger.verbose(`Accounts loaded for network: ${this.config.network}`);
|
|
867
|
-
if (!allData[this.config.network]) {
|
|
868
|
-
allData[this.config.network] = {};
|
|
869
|
-
}
|
|
870
|
-
return allData[this.config.network];
|
|
871
|
-
}
|
|
872
|
-
/**
|
|
873
|
-
* @description List all accountKeys of the network
|
|
874
|
-
* @returns string[]
|
|
875
|
-
*/
|
|
876
|
-
listAccounts() {
|
|
877
|
-
return Object.keys(this.loadAccounts());
|
|
878
|
-
}
|
|
879
|
-
static ensureFolder(folder) {
|
|
880
|
-
if (!fs.existsSync(folder)) {
|
|
881
|
-
fs.mkdirSync(folder, { recursive: true });
|
|
882
|
-
}
|
|
883
|
-
if (!fs.existsSync(`${folder}`)) {
|
|
884
|
-
throw new Error(`Store folder not found: ${folder}`);
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
};
|
|
700
|
+
// src/strategies/vesu-rebalance.ts
|
|
701
|
+
import { CairoCustomEnum, Contract as Contract3, num as num2, uint256 as uint2562 } from "starknet";
|
|
888
702
|
|
|
889
|
-
// src/
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
703
|
+
// src/data/vesu-rebalance.abi.json
|
|
704
|
+
var vesu_rebalance_abi_default = [
|
|
705
|
+
{
|
|
706
|
+
type: "impl",
|
|
707
|
+
name: "ExternalImpl",
|
|
708
|
+
interface_name: "strkfarm_contracts::strategies::vesu_rebalance::interface::IVesuRebal"
|
|
709
|
+
},
|
|
710
|
+
{
|
|
711
|
+
type: "enum",
|
|
712
|
+
name: "strkfarm_contracts::strategies::vesu_rebalance::interface::Feature",
|
|
713
|
+
variants: [
|
|
714
|
+
{
|
|
715
|
+
name: "DEPOSIT",
|
|
716
|
+
type: "()"
|
|
717
|
+
},
|
|
718
|
+
{
|
|
719
|
+
name: "WITHDRAW",
|
|
720
|
+
type: "()"
|
|
721
|
+
}
|
|
722
|
+
]
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
type: "struct",
|
|
726
|
+
name: "core::integer::u256",
|
|
727
|
+
members: [
|
|
728
|
+
{
|
|
729
|
+
name: "low",
|
|
730
|
+
type: "core::integer::u128"
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
name: "high",
|
|
734
|
+
type: "core::integer::u128"
|
|
735
|
+
}
|
|
736
|
+
]
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
type: "struct",
|
|
740
|
+
name: "strkfarm_contracts::strategies::vesu_rebalance::interface::Action",
|
|
741
|
+
members: [
|
|
742
|
+
{
|
|
743
|
+
name: "pool_id",
|
|
744
|
+
type: "core::felt252"
|
|
745
|
+
},
|
|
746
|
+
{
|
|
747
|
+
name: "feature",
|
|
748
|
+
type: "strkfarm_contracts::strategies::vesu_rebalance::interface::Feature"
|
|
749
|
+
},
|
|
750
|
+
{
|
|
751
|
+
name: "token",
|
|
752
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
name: "amount",
|
|
756
|
+
type: "core::integer::u256"
|
|
757
|
+
}
|
|
758
|
+
]
|
|
759
|
+
},
|
|
760
|
+
{
|
|
761
|
+
type: "struct",
|
|
762
|
+
name: "strkfarm_contracts::interfaces::IEkuboDistributor::Claim",
|
|
763
|
+
members: [
|
|
764
|
+
{
|
|
765
|
+
name: "id",
|
|
766
|
+
type: "core::integer::u64"
|
|
767
|
+
},
|
|
768
|
+
{
|
|
769
|
+
name: "claimee",
|
|
770
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
771
|
+
},
|
|
772
|
+
{
|
|
773
|
+
name: "amount",
|
|
774
|
+
type: "core::integer::u128"
|
|
775
|
+
}
|
|
776
|
+
]
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
type: "struct",
|
|
780
|
+
name: "core::array::Span::<core::felt252>",
|
|
781
|
+
members: [
|
|
782
|
+
{
|
|
783
|
+
name: "snapshot",
|
|
784
|
+
type: "@core::array::Array::<core::felt252>"
|
|
785
|
+
}
|
|
786
|
+
]
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
type: "struct",
|
|
790
|
+
name: "strkfarm_contracts::components::swap::Route",
|
|
791
|
+
members: [
|
|
792
|
+
{
|
|
793
|
+
name: "token_from",
|
|
794
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
795
|
+
},
|
|
796
|
+
{
|
|
797
|
+
name: "token_to",
|
|
798
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
799
|
+
},
|
|
800
|
+
{
|
|
801
|
+
name: "exchange_address",
|
|
802
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
803
|
+
},
|
|
804
|
+
{
|
|
805
|
+
name: "percent",
|
|
806
|
+
type: "core::integer::u128"
|
|
807
|
+
},
|
|
808
|
+
{
|
|
809
|
+
name: "additional_swap_params",
|
|
810
|
+
type: "core::array::Array::<core::felt252>"
|
|
811
|
+
}
|
|
812
|
+
]
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
type: "struct",
|
|
816
|
+
name: "strkfarm_contracts::components::swap::AvnuMultiRouteSwap",
|
|
817
|
+
members: [
|
|
818
|
+
{
|
|
819
|
+
name: "token_from_address",
|
|
820
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
821
|
+
},
|
|
822
|
+
{
|
|
823
|
+
name: "token_from_amount",
|
|
824
|
+
type: "core::integer::u256"
|
|
825
|
+
},
|
|
826
|
+
{
|
|
827
|
+
name: "token_to_address",
|
|
828
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
829
|
+
},
|
|
830
|
+
{
|
|
831
|
+
name: "token_to_amount",
|
|
832
|
+
type: "core::integer::u256"
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
name: "token_to_min_amount",
|
|
836
|
+
type: "core::integer::u256"
|
|
837
|
+
},
|
|
838
|
+
{
|
|
839
|
+
name: "beneficiary",
|
|
840
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
841
|
+
},
|
|
842
|
+
{
|
|
843
|
+
name: "integrator_fee_amount_bps",
|
|
844
|
+
type: "core::integer::u128"
|
|
845
|
+
},
|
|
846
|
+
{
|
|
847
|
+
name: "integrator_fee_recipient",
|
|
848
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
849
|
+
},
|
|
850
|
+
{
|
|
851
|
+
name: "routes",
|
|
852
|
+
type: "core::array::Array::<strkfarm_contracts::components::swap::Route>"
|
|
853
|
+
}
|
|
854
|
+
]
|
|
855
|
+
},
|
|
856
|
+
{
|
|
857
|
+
type: "struct",
|
|
858
|
+
name: "strkfarm_contracts::strategies::vesu_rebalance::interface::Settings",
|
|
859
|
+
members: [
|
|
860
|
+
{
|
|
861
|
+
name: "default_pool_index",
|
|
862
|
+
type: "core::integer::u8"
|
|
863
|
+
},
|
|
864
|
+
{
|
|
865
|
+
name: "fee_bps",
|
|
866
|
+
type: "core::integer::u32"
|
|
867
|
+
},
|
|
868
|
+
{
|
|
869
|
+
name: "fee_receiver",
|
|
870
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
871
|
+
}
|
|
872
|
+
]
|
|
873
|
+
},
|
|
874
|
+
{
|
|
875
|
+
type: "struct",
|
|
876
|
+
name: "strkfarm_contracts::strategies::vesu_rebalance::interface::PoolProps",
|
|
877
|
+
members: [
|
|
878
|
+
{
|
|
879
|
+
name: "pool_id",
|
|
880
|
+
type: "core::felt252"
|
|
881
|
+
},
|
|
882
|
+
{
|
|
883
|
+
name: "max_weight",
|
|
884
|
+
type: "core::integer::u32"
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
name: "v_token",
|
|
888
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
889
|
+
}
|
|
890
|
+
]
|
|
891
|
+
},
|
|
892
|
+
{
|
|
893
|
+
type: "interface",
|
|
894
|
+
name: "strkfarm_contracts::strategies::vesu_rebalance::interface::IVesuRebal",
|
|
895
|
+
items: [
|
|
896
|
+
{
|
|
897
|
+
type: "function",
|
|
898
|
+
name: "rebalance",
|
|
899
|
+
inputs: [
|
|
900
|
+
{
|
|
901
|
+
name: "actions",
|
|
902
|
+
type: "core::array::Array::<strkfarm_contracts::strategies::vesu_rebalance::interface::Action>"
|
|
903
|
+
}
|
|
904
|
+
],
|
|
905
|
+
outputs: [],
|
|
906
|
+
state_mutability: "external"
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
type: "function",
|
|
910
|
+
name: "rebalance_weights",
|
|
911
|
+
inputs: [
|
|
912
|
+
{
|
|
913
|
+
name: "actions",
|
|
914
|
+
type: "core::array::Array::<strkfarm_contracts::strategies::vesu_rebalance::interface::Action>"
|
|
915
|
+
}
|
|
916
|
+
],
|
|
917
|
+
outputs: [],
|
|
918
|
+
state_mutability: "external"
|
|
919
|
+
},
|
|
920
|
+
{
|
|
921
|
+
type: "function",
|
|
922
|
+
name: "emergency_withdraw",
|
|
923
|
+
inputs: [],
|
|
924
|
+
outputs: [],
|
|
925
|
+
state_mutability: "external"
|
|
926
|
+
},
|
|
927
|
+
{
|
|
928
|
+
type: "function",
|
|
929
|
+
name: "emergency_withdraw_pool",
|
|
930
|
+
inputs: [
|
|
931
|
+
{
|
|
932
|
+
name: "pool_index",
|
|
933
|
+
type: "core::integer::u32"
|
|
934
|
+
}
|
|
935
|
+
],
|
|
936
|
+
outputs: [],
|
|
937
|
+
state_mutability: "external"
|
|
938
|
+
},
|
|
939
|
+
{
|
|
940
|
+
type: "function",
|
|
941
|
+
name: "compute_yield",
|
|
942
|
+
inputs: [],
|
|
943
|
+
outputs: [
|
|
944
|
+
{
|
|
945
|
+
type: "(core::integer::u256, core::integer::u256)"
|
|
946
|
+
}
|
|
947
|
+
],
|
|
948
|
+
state_mutability: "view"
|
|
949
|
+
},
|
|
950
|
+
{
|
|
951
|
+
type: "function",
|
|
952
|
+
name: "harvest",
|
|
953
|
+
inputs: [
|
|
954
|
+
{
|
|
955
|
+
name: "rewardsContract",
|
|
956
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
957
|
+
},
|
|
958
|
+
{
|
|
959
|
+
name: "claim",
|
|
960
|
+
type: "strkfarm_contracts::interfaces::IEkuboDistributor::Claim"
|
|
961
|
+
},
|
|
962
|
+
{
|
|
963
|
+
name: "proof",
|
|
964
|
+
type: "core::array::Span::<core::felt252>"
|
|
965
|
+
},
|
|
966
|
+
{
|
|
967
|
+
name: "swapInfo",
|
|
968
|
+
type: "strkfarm_contracts::components::swap::AvnuMultiRouteSwap"
|
|
969
|
+
}
|
|
970
|
+
],
|
|
971
|
+
outputs: [],
|
|
972
|
+
state_mutability: "external"
|
|
973
|
+
},
|
|
974
|
+
{
|
|
975
|
+
type: "function",
|
|
976
|
+
name: "set_settings",
|
|
977
|
+
inputs: [
|
|
978
|
+
{
|
|
979
|
+
name: "settings",
|
|
980
|
+
type: "strkfarm_contracts::strategies::vesu_rebalance::interface::Settings"
|
|
981
|
+
}
|
|
982
|
+
],
|
|
983
|
+
outputs: [],
|
|
984
|
+
state_mutability: "external"
|
|
985
|
+
},
|
|
986
|
+
{
|
|
987
|
+
type: "function",
|
|
988
|
+
name: "set_allowed_pools",
|
|
989
|
+
inputs: [
|
|
990
|
+
{
|
|
991
|
+
name: "pools",
|
|
992
|
+
type: "core::array::Array::<strkfarm_contracts::strategies::vesu_rebalance::interface::PoolProps>"
|
|
993
|
+
}
|
|
994
|
+
],
|
|
995
|
+
outputs: [],
|
|
996
|
+
state_mutability: "external"
|
|
997
|
+
},
|
|
998
|
+
{
|
|
999
|
+
type: "function",
|
|
1000
|
+
name: "set_incentives_off",
|
|
1001
|
+
inputs: [],
|
|
1002
|
+
outputs: [],
|
|
1003
|
+
state_mutability: "external"
|
|
1004
|
+
},
|
|
1005
|
+
{
|
|
1006
|
+
type: "function",
|
|
1007
|
+
name: "get_settings",
|
|
1008
|
+
inputs: [],
|
|
1009
|
+
outputs: [
|
|
1010
|
+
{
|
|
1011
|
+
type: "strkfarm_contracts::strategies::vesu_rebalance::interface::Settings"
|
|
1012
|
+
}
|
|
1013
|
+
],
|
|
1014
|
+
state_mutability: "view"
|
|
1015
|
+
},
|
|
1016
|
+
{
|
|
1017
|
+
type: "function",
|
|
1018
|
+
name: "get_allowed_pools",
|
|
1019
|
+
inputs: [],
|
|
1020
|
+
outputs: [
|
|
1021
|
+
{
|
|
1022
|
+
type: "core::array::Array::<strkfarm_contracts::strategies::vesu_rebalance::interface::PoolProps>"
|
|
1023
|
+
}
|
|
1024
|
+
],
|
|
1025
|
+
state_mutability: "view"
|
|
1026
|
+
},
|
|
1027
|
+
{
|
|
1028
|
+
type: "function",
|
|
1029
|
+
name: "get_previous_index",
|
|
1030
|
+
inputs: [],
|
|
1031
|
+
outputs: [
|
|
1032
|
+
{
|
|
1033
|
+
type: "core::integer::u128"
|
|
1034
|
+
}
|
|
1035
|
+
],
|
|
1036
|
+
state_mutability: "view"
|
|
1037
|
+
}
|
|
1038
|
+
]
|
|
1039
|
+
},
|
|
1040
|
+
{
|
|
1041
|
+
type: "impl",
|
|
1042
|
+
name: "VesuERC4626Impl",
|
|
1043
|
+
interface_name: "strkfarm_contracts::interfaces::IERC4626::IERC4626"
|
|
1044
|
+
},
|
|
1045
|
+
{
|
|
1046
|
+
type: "interface",
|
|
1047
|
+
name: "strkfarm_contracts::interfaces::IERC4626::IERC4626",
|
|
1048
|
+
items: [
|
|
1049
|
+
{
|
|
1050
|
+
type: "function",
|
|
1051
|
+
name: "asset",
|
|
1052
|
+
inputs: [],
|
|
1053
|
+
outputs: [
|
|
1054
|
+
{
|
|
1055
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1056
|
+
}
|
|
1057
|
+
],
|
|
1058
|
+
state_mutability: "view"
|
|
1059
|
+
},
|
|
1060
|
+
{
|
|
1061
|
+
type: "function",
|
|
1062
|
+
name: "total_assets",
|
|
1063
|
+
inputs: [],
|
|
1064
|
+
outputs: [
|
|
1065
|
+
{
|
|
1066
|
+
type: "core::integer::u256"
|
|
1067
|
+
}
|
|
1068
|
+
],
|
|
1069
|
+
state_mutability: "view"
|
|
1070
|
+
},
|
|
1071
|
+
{
|
|
1072
|
+
type: "function",
|
|
1073
|
+
name: "convert_to_shares",
|
|
1074
|
+
inputs: [
|
|
1075
|
+
{
|
|
1076
|
+
name: "assets",
|
|
1077
|
+
type: "core::integer::u256"
|
|
1078
|
+
}
|
|
1079
|
+
],
|
|
1080
|
+
outputs: [
|
|
1081
|
+
{
|
|
1082
|
+
type: "core::integer::u256"
|
|
1083
|
+
}
|
|
1084
|
+
],
|
|
1085
|
+
state_mutability: "view"
|
|
1086
|
+
},
|
|
1087
|
+
{
|
|
1088
|
+
type: "function",
|
|
1089
|
+
name: "convert_to_assets",
|
|
1090
|
+
inputs: [
|
|
1091
|
+
{
|
|
1092
|
+
name: "shares",
|
|
1093
|
+
type: "core::integer::u256"
|
|
1094
|
+
}
|
|
1095
|
+
],
|
|
1096
|
+
outputs: [
|
|
1097
|
+
{
|
|
1098
|
+
type: "core::integer::u256"
|
|
1099
|
+
}
|
|
1100
|
+
],
|
|
1101
|
+
state_mutability: "view"
|
|
1102
|
+
},
|
|
1103
|
+
{
|
|
1104
|
+
type: "function",
|
|
1105
|
+
name: "max_deposit",
|
|
1106
|
+
inputs: [
|
|
1107
|
+
{
|
|
1108
|
+
name: "receiver",
|
|
1109
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1110
|
+
}
|
|
1111
|
+
],
|
|
1112
|
+
outputs: [
|
|
1113
|
+
{
|
|
1114
|
+
type: "core::integer::u256"
|
|
1115
|
+
}
|
|
1116
|
+
],
|
|
1117
|
+
state_mutability: "view"
|
|
1118
|
+
},
|
|
1119
|
+
{
|
|
1120
|
+
type: "function",
|
|
1121
|
+
name: "preview_deposit",
|
|
1122
|
+
inputs: [
|
|
1123
|
+
{
|
|
1124
|
+
name: "assets",
|
|
1125
|
+
type: "core::integer::u256"
|
|
1126
|
+
}
|
|
1127
|
+
],
|
|
1128
|
+
outputs: [
|
|
1129
|
+
{
|
|
1130
|
+
type: "core::integer::u256"
|
|
1131
|
+
}
|
|
1132
|
+
],
|
|
1133
|
+
state_mutability: "view"
|
|
1134
|
+
},
|
|
1135
|
+
{
|
|
1136
|
+
type: "function",
|
|
1137
|
+
name: "deposit",
|
|
1138
|
+
inputs: [
|
|
1139
|
+
{
|
|
1140
|
+
name: "assets",
|
|
1141
|
+
type: "core::integer::u256"
|
|
1142
|
+
},
|
|
1143
|
+
{
|
|
1144
|
+
name: "receiver",
|
|
1145
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1146
|
+
}
|
|
1147
|
+
],
|
|
1148
|
+
outputs: [
|
|
1149
|
+
{
|
|
1150
|
+
type: "core::integer::u256"
|
|
1151
|
+
}
|
|
1152
|
+
],
|
|
1153
|
+
state_mutability: "external"
|
|
1154
|
+
},
|
|
1155
|
+
{
|
|
1156
|
+
type: "function",
|
|
1157
|
+
name: "max_mint",
|
|
1158
|
+
inputs: [
|
|
1159
|
+
{
|
|
1160
|
+
name: "receiver",
|
|
1161
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1162
|
+
}
|
|
1163
|
+
],
|
|
1164
|
+
outputs: [
|
|
1165
|
+
{
|
|
1166
|
+
type: "core::integer::u256"
|
|
1167
|
+
}
|
|
1168
|
+
],
|
|
1169
|
+
state_mutability: "view"
|
|
1170
|
+
},
|
|
1171
|
+
{
|
|
1172
|
+
type: "function",
|
|
1173
|
+
name: "preview_mint",
|
|
1174
|
+
inputs: [
|
|
1175
|
+
{
|
|
1176
|
+
name: "shares",
|
|
1177
|
+
type: "core::integer::u256"
|
|
1178
|
+
}
|
|
1179
|
+
],
|
|
1180
|
+
outputs: [
|
|
1181
|
+
{
|
|
1182
|
+
type: "core::integer::u256"
|
|
1183
|
+
}
|
|
1184
|
+
],
|
|
1185
|
+
state_mutability: "view"
|
|
1186
|
+
},
|
|
1187
|
+
{
|
|
1188
|
+
type: "function",
|
|
1189
|
+
name: "mint",
|
|
1190
|
+
inputs: [
|
|
1191
|
+
{
|
|
1192
|
+
name: "shares",
|
|
1193
|
+
type: "core::integer::u256"
|
|
1194
|
+
},
|
|
1195
|
+
{
|
|
1196
|
+
name: "receiver",
|
|
1197
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1198
|
+
}
|
|
1199
|
+
],
|
|
1200
|
+
outputs: [
|
|
1201
|
+
{
|
|
1202
|
+
type: "core::integer::u256"
|
|
1203
|
+
}
|
|
1204
|
+
],
|
|
1205
|
+
state_mutability: "external"
|
|
1206
|
+
},
|
|
1207
|
+
{
|
|
1208
|
+
type: "function",
|
|
1209
|
+
name: "max_withdraw",
|
|
1210
|
+
inputs: [
|
|
1211
|
+
{
|
|
1212
|
+
name: "owner",
|
|
1213
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1214
|
+
}
|
|
1215
|
+
],
|
|
1216
|
+
outputs: [
|
|
1217
|
+
{
|
|
1218
|
+
type: "core::integer::u256"
|
|
1219
|
+
}
|
|
1220
|
+
],
|
|
1221
|
+
state_mutability: "view"
|
|
1222
|
+
},
|
|
1223
|
+
{
|
|
1224
|
+
type: "function",
|
|
1225
|
+
name: "preview_withdraw",
|
|
1226
|
+
inputs: [
|
|
1227
|
+
{
|
|
1228
|
+
name: "assets",
|
|
1229
|
+
type: "core::integer::u256"
|
|
1230
|
+
}
|
|
1231
|
+
],
|
|
1232
|
+
outputs: [
|
|
1233
|
+
{
|
|
1234
|
+
type: "core::integer::u256"
|
|
1235
|
+
}
|
|
1236
|
+
],
|
|
1237
|
+
state_mutability: "view"
|
|
1238
|
+
},
|
|
1239
|
+
{
|
|
1240
|
+
type: "function",
|
|
1241
|
+
name: "withdraw",
|
|
1242
|
+
inputs: [
|
|
1243
|
+
{
|
|
1244
|
+
name: "assets",
|
|
1245
|
+
type: "core::integer::u256"
|
|
1246
|
+
},
|
|
1247
|
+
{
|
|
1248
|
+
name: "receiver",
|
|
1249
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1250
|
+
},
|
|
1251
|
+
{
|
|
1252
|
+
name: "owner",
|
|
1253
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1254
|
+
}
|
|
1255
|
+
],
|
|
1256
|
+
outputs: [
|
|
1257
|
+
{
|
|
1258
|
+
type: "core::integer::u256"
|
|
1259
|
+
}
|
|
1260
|
+
],
|
|
1261
|
+
state_mutability: "external"
|
|
1262
|
+
},
|
|
1263
|
+
{
|
|
1264
|
+
type: "function",
|
|
1265
|
+
name: "max_redeem",
|
|
1266
|
+
inputs: [
|
|
1267
|
+
{
|
|
1268
|
+
name: "owner",
|
|
1269
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1270
|
+
}
|
|
1271
|
+
],
|
|
1272
|
+
outputs: [
|
|
1273
|
+
{
|
|
1274
|
+
type: "core::integer::u256"
|
|
1275
|
+
}
|
|
1276
|
+
],
|
|
1277
|
+
state_mutability: "view"
|
|
1278
|
+
},
|
|
1279
|
+
{
|
|
1280
|
+
type: "function",
|
|
1281
|
+
name: "preview_redeem",
|
|
1282
|
+
inputs: [
|
|
1283
|
+
{
|
|
1284
|
+
name: "shares",
|
|
1285
|
+
type: "core::integer::u256"
|
|
1286
|
+
}
|
|
1287
|
+
],
|
|
1288
|
+
outputs: [
|
|
1289
|
+
{
|
|
1290
|
+
type: "core::integer::u256"
|
|
1291
|
+
}
|
|
1292
|
+
],
|
|
1293
|
+
state_mutability: "view"
|
|
1294
|
+
},
|
|
1295
|
+
{
|
|
1296
|
+
type: "function",
|
|
1297
|
+
name: "redeem",
|
|
1298
|
+
inputs: [
|
|
1299
|
+
{
|
|
1300
|
+
name: "shares",
|
|
1301
|
+
type: "core::integer::u256"
|
|
1302
|
+
},
|
|
1303
|
+
{
|
|
1304
|
+
name: "receiver",
|
|
1305
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1306
|
+
},
|
|
1307
|
+
{
|
|
1308
|
+
name: "owner",
|
|
1309
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1310
|
+
}
|
|
1311
|
+
],
|
|
1312
|
+
outputs: [
|
|
1313
|
+
{
|
|
1314
|
+
type: "core::integer::u256"
|
|
1315
|
+
}
|
|
1316
|
+
],
|
|
1317
|
+
state_mutability: "external"
|
|
1318
|
+
}
|
|
1319
|
+
]
|
|
1320
|
+
},
|
|
1321
|
+
{
|
|
1322
|
+
type: "impl",
|
|
1323
|
+
name: "VesuERC20Impl",
|
|
1324
|
+
interface_name: "openzeppelin_token::erc20::interface::IERC20Mixin"
|
|
1325
|
+
},
|
|
1326
|
+
{
|
|
1327
|
+
type: "enum",
|
|
1328
|
+
name: "core::bool",
|
|
1329
|
+
variants: [
|
|
1330
|
+
{
|
|
1331
|
+
name: "False",
|
|
1332
|
+
type: "()"
|
|
1333
|
+
},
|
|
1334
|
+
{
|
|
1335
|
+
name: "True",
|
|
1336
|
+
type: "()"
|
|
1337
|
+
}
|
|
1338
|
+
]
|
|
1339
|
+
},
|
|
1340
|
+
{
|
|
1341
|
+
type: "struct",
|
|
1342
|
+
name: "core::byte_array::ByteArray",
|
|
1343
|
+
members: [
|
|
1344
|
+
{
|
|
1345
|
+
name: "data",
|
|
1346
|
+
type: "core::array::Array::<core::bytes_31::bytes31>"
|
|
1347
|
+
},
|
|
1348
|
+
{
|
|
1349
|
+
name: "pending_word",
|
|
1350
|
+
type: "core::felt252"
|
|
1351
|
+
},
|
|
1352
|
+
{
|
|
1353
|
+
name: "pending_word_len",
|
|
1354
|
+
type: "core::integer::u32"
|
|
1355
|
+
}
|
|
1356
|
+
]
|
|
1357
|
+
},
|
|
1358
|
+
{
|
|
1359
|
+
type: "interface",
|
|
1360
|
+
name: "openzeppelin_token::erc20::interface::IERC20Mixin",
|
|
1361
|
+
items: [
|
|
1362
|
+
{
|
|
1363
|
+
type: "function",
|
|
1364
|
+
name: "total_supply",
|
|
1365
|
+
inputs: [],
|
|
1366
|
+
outputs: [
|
|
1367
|
+
{
|
|
1368
|
+
type: "core::integer::u256"
|
|
1369
|
+
}
|
|
1370
|
+
],
|
|
1371
|
+
state_mutability: "view"
|
|
1372
|
+
},
|
|
1373
|
+
{
|
|
1374
|
+
type: "function",
|
|
1375
|
+
name: "balance_of",
|
|
1376
|
+
inputs: [
|
|
1377
|
+
{
|
|
1378
|
+
name: "account",
|
|
1379
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1380
|
+
}
|
|
1381
|
+
],
|
|
1382
|
+
outputs: [
|
|
1383
|
+
{
|
|
1384
|
+
type: "core::integer::u256"
|
|
1385
|
+
}
|
|
1386
|
+
],
|
|
1387
|
+
state_mutability: "view"
|
|
1388
|
+
},
|
|
1389
|
+
{
|
|
1390
|
+
type: "function",
|
|
1391
|
+
name: "allowance",
|
|
1392
|
+
inputs: [
|
|
1393
|
+
{
|
|
1394
|
+
name: "owner",
|
|
1395
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1396
|
+
},
|
|
1397
|
+
{
|
|
1398
|
+
name: "spender",
|
|
1399
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1400
|
+
}
|
|
1401
|
+
],
|
|
1402
|
+
outputs: [
|
|
1403
|
+
{
|
|
1404
|
+
type: "core::integer::u256"
|
|
1405
|
+
}
|
|
1406
|
+
],
|
|
1407
|
+
state_mutability: "view"
|
|
1408
|
+
},
|
|
1409
|
+
{
|
|
1410
|
+
type: "function",
|
|
1411
|
+
name: "transfer",
|
|
1412
|
+
inputs: [
|
|
1413
|
+
{
|
|
1414
|
+
name: "recipient",
|
|
1415
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1416
|
+
},
|
|
1417
|
+
{
|
|
1418
|
+
name: "amount",
|
|
1419
|
+
type: "core::integer::u256"
|
|
1420
|
+
}
|
|
1421
|
+
],
|
|
1422
|
+
outputs: [
|
|
1423
|
+
{
|
|
1424
|
+
type: "core::bool"
|
|
1425
|
+
}
|
|
1426
|
+
],
|
|
1427
|
+
state_mutability: "external"
|
|
1428
|
+
},
|
|
1429
|
+
{
|
|
1430
|
+
type: "function",
|
|
1431
|
+
name: "transfer_from",
|
|
1432
|
+
inputs: [
|
|
1433
|
+
{
|
|
1434
|
+
name: "sender",
|
|
1435
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1436
|
+
},
|
|
1437
|
+
{
|
|
1438
|
+
name: "recipient",
|
|
1439
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1440
|
+
},
|
|
1441
|
+
{
|
|
1442
|
+
name: "amount",
|
|
1443
|
+
type: "core::integer::u256"
|
|
1444
|
+
}
|
|
1445
|
+
],
|
|
1446
|
+
outputs: [
|
|
1447
|
+
{
|
|
1448
|
+
type: "core::bool"
|
|
1449
|
+
}
|
|
1450
|
+
],
|
|
1451
|
+
state_mutability: "external"
|
|
1452
|
+
},
|
|
1453
|
+
{
|
|
1454
|
+
type: "function",
|
|
1455
|
+
name: "approve",
|
|
1456
|
+
inputs: [
|
|
1457
|
+
{
|
|
1458
|
+
name: "spender",
|
|
1459
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1460
|
+
},
|
|
1461
|
+
{
|
|
1462
|
+
name: "amount",
|
|
1463
|
+
type: "core::integer::u256"
|
|
1464
|
+
}
|
|
1465
|
+
],
|
|
1466
|
+
outputs: [
|
|
1467
|
+
{
|
|
1468
|
+
type: "core::bool"
|
|
1469
|
+
}
|
|
1470
|
+
],
|
|
1471
|
+
state_mutability: "external"
|
|
1472
|
+
},
|
|
1473
|
+
{
|
|
1474
|
+
type: "function",
|
|
1475
|
+
name: "name",
|
|
1476
|
+
inputs: [],
|
|
1477
|
+
outputs: [
|
|
1478
|
+
{
|
|
1479
|
+
type: "core::byte_array::ByteArray"
|
|
1480
|
+
}
|
|
1481
|
+
],
|
|
1482
|
+
state_mutability: "view"
|
|
1483
|
+
},
|
|
1484
|
+
{
|
|
1485
|
+
type: "function",
|
|
1486
|
+
name: "symbol",
|
|
1487
|
+
inputs: [],
|
|
1488
|
+
outputs: [
|
|
1489
|
+
{
|
|
1490
|
+
type: "core::byte_array::ByteArray"
|
|
1491
|
+
}
|
|
1492
|
+
],
|
|
1493
|
+
state_mutability: "view"
|
|
1494
|
+
},
|
|
1495
|
+
{
|
|
1496
|
+
type: "function",
|
|
1497
|
+
name: "decimals",
|
|
1498
|
+
inputs: [],
|
|
1499
|
+
outputs: [
|
|
1500
|
+
{
|
|
1501
|
+
type: "core::integer::u8"
|
|
1502
|
+
}
|
|
1503
|
+
],
|
|
1504
|
+
state_mutability: "view"
|
|
1505
|
+
},
|
|
1506
|
+
{
|
|
1507
|
+
type: "function",
|
|
1508
|
+
name: "totalSupply",
|
|
1509
|
+
inputs: [],
|
|
1510
|
+
outputs: [
|
|
1511
|
+
{
|
|
1512
|
+
type: "core::integer::u256"
|
|
1513
|
+
}
|
|
1514
|
+
],
|
|
1515
|
+
state_mutability: "view"
|
|
1516
|
+
},
|
|
1517
|
+
{
|
|
1518
|
+
type: "function",
|
|
1519
|
+
name: "balanceOf",
|
|
1520
|
+
inputs: [
|
|
1521
|
+
{
|
|
1522
|
+
name: "account",
|
|
1523
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1524
|
+
}
|
|
1525
|
+
],
|
|
1526
|
+
outputs: [
|
|
1527
|
+
{
|
|
1528
|
+
type: "core::integer::u256"
|
|
1529
|
+
}
|
|
1530
|
+
],
|
|
1531
|
+
state_mutability: "view"
|
|
1532
|
+
},
|
|
1533
|
+
{
|
|
1534
|
+
type: "function",
|
|
1535
|
+
name: "transferFrom",
|
|
1536
|
+
inputs: [
|
|
1537
|
+
{
|
|
1538
|
+
name: "sender",
|
|
1539
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1540
|
+
},
|
|
1541
|
+
{
|
|
1542
|
+
name: "recipient",
|
|
1543
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1544
|
+
},
|
|
1545
|
+
{
|
|
1546
|
+
name: "amount",
|
|
1547
|
+
type: "core::integer::u256"
|
|
1548
|
+
}
|
|
1549
|
+
],
|
|
1550
|
+
outputs: [
|
|
1551
|
+
{
|
|
1552
|
+
type: "core::bool"
|
|
1553
|
+
}
|
|
1554
|
+
],
|
|
1555
|
+
state_mutability: "external"
|
|
1556
|
+
}
|
|
1557
|
+
]
|
|
1558
|
+
},
|
|
1559
|
+
{
|
|
1560
|
+
type: "impl",
|
|
1561
|
+
name: "CommonCompImpl",
|
|
1562
|
+
interface_name: "strkfarm_contracts::interfaces::common::ICommon"
|
|
1563
|
+
},
|
|
1564
|
+
{
|
|
1565
|
+
type: "interface",
|
|
1566
|
+
name: "strkfarm_contracts::interfaces::common::ICommon",
|
|
1567
|
+
items: [
|
|
1568
|
+
{
|
|
1569
|
+
type: "function",
|
|
1570
|
+
name: "upgrade",
|
|
1571
|
+
inputs: [
|
|
1572
|
+
{
|
|
1573
|
+
name: "new_class",
|
|
1574
|
+
type: "core::starknet::class_hash::ClassHash"
|
|
1575
|
+
}
|
|
1576
|
+
],
|
|
1577
|
+
outputs: [],
|
|
1578
|
+
state_mutability: "external"
|
|
1579
|
+
},
|
|
1580
|
+
{
|
|
1581
|
+
type: "function",
|
|
1582
|
+
name: "pause",
|
|
1583
|
+
inputs: [],
|
|
1584
|
+
outputs: [],
|
|
1585
|
+
state_mutability: "external"
|
|
1586
|
+
},
|
|
1587
|
+
{
|
|
1588
|
+
type: "function",
|
|
1589
|
+
name: "unpause",
|
|
1590
|
+
inputs: [],
|
|
1591
|
+
outputs: [],
|
|
1592
|
+
state_mutability: "external"
|
|
1593
|
+
},
|
|
1594
|
+
{
|
|
1595
|
+
type: "function",
|
|
1596
|
+
name: "is_paused",
|
|
1597
|
+
inputs: [],
|
|
1598
|
+
outputs: [
|
|
1599
|
+
{
|
|
1600
|
+
type: "core::bool"
|
|
1601
|
+
}
|
|
1602
|
+
],
|
|
1603
|
+
state_mutability: "view"
|
|
1604
|
+
}
|
|
1605
|
+
]
|
|
1606
|
+
},
|
|
1607
|
+
{
|
|
1608
|
+
type: "impl",
|
|
1609
|
+
name: "RewardShareImpl",
|
|
1610
|
+
interface_name: "strkfarm_contracts::components::harvester::reward_shares::IRewardShare"
|
|
1611
|
+
},
|
|
1612
|
+
{
|
|
1613
|
+
type: "struct",
|
|
1614
|
+
name: "strkfarm_contracts::components::harvester::reward_shares::UserRewardsInfo",
|
|
1615
|
+
members: [
|
|
1616
|
+
{
|
|
1617
|
+
name: "pending_round_points",
|
|
1618
|
+
type: "core::integer::u128"
|
|
1619
|
+
},
|
|
1620
|
+
{
|
|
1621
|
+
name: "shares_owned",
|
|
1622
|
+
type: "core::integer::u128"
|
|
1623
|
+
},
|
|
1624
|
+
{
|
|
1625
|
+
name: "block_number",
|
|
1626
|
+
type: "core::integer::u64"
|
|
1627
|
+
},
|
|
1628
|
+
{
|
|
1629
|
+
name: "index",
|
|
1630
|
+
type: "core::integer::u32"
|
|
1631
|
+
}
|
|
1632
|
+
]
|
|
1633
|
+
},
|
|
1634
|
+
{
|
|
1635
|
+
type: "struct",
|
|
1636
|
+
name: "strkfarm_contracts::components::harvester::reward_shares::RewardsInfo",
|
|
1637
|
+
members: [
|
|
1638
|
+
{
|
|
1639
|
+
name: "amount",
|
|
1640
|
+
type: "core::integer::u128"
|
|
1641
|
+
},
|
|
1642
|
+
{
|
|
1643
|
+
name: "shares",
|
|
1644
|
+
type: "core::integer::u128"
|
|
1645
|
+
},
|
|
1646
|
+
{
|
|
1647
|
+
name: "total_round_points",
|
|
1648
|
+
type: "core::integer::u128"
|
|
1649
|
+
},
|
|
1650
|
+
{
|
|
1651
|
+
name: "block_number",
|
|
1652
|
+
type: "core::integer::u64"
|
|
1653
|
+
}
|
|
1654
|
+
]
|
|
1655
|
+
},
|
|
1656
|
+
{
|
|
1657
|
+
type: "interface",
|
|
1658
|
+
name: "strkfarm_contracts::components::harvester::reward_shares::IRewardShare",
|
|
1659
|
+
items: [
|
|
1660
|
+
{
|
|
1661
|
+
type: "function",
|
|
1662
|
+
name: "get_user_reward_info",
|
|
1663
|
+
inputs: [
|
|
1664
|
+
{
|
|
1665
|
+
name: "user",
|
|
1666
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1667
|
+
}
|
|
1668
|
+
],
|
|
1669
|
+
outputs: [
|
|
1670
|
+
{
|
|
1671
|
+
type: "strkfarm_contracts::components::harvester::reward_shares::UserRewardsInfo"
|
|
1672
|
+
}
|
|
1673
|
+
],
|
|
1674
|
+
state_mutability: "view"
|
|
1675
|
+
},
|
|
1676
|
+
{
|
|
1677
|
+
type: "function",
|
|
1678
|
+
name: "get_rewards_info",
|
|
1679
|
+
inputs: [
|
|
1680
|
+
{
|
|
1681
|
+
name: "index",
|
|
1682
|
+
type: "core::integer::u32"
|
|
1683
|
+
}
|
|
1684
|
+
],
|
|
1685
|
+
outputs: [
|
|
1686
|
+
{
|
|
1687
|
+
type: "strkfarm_contracts::components::harvester::reward_shares::RewardsInfo"
|
|
1688
|
+
}
|
|
1689
|
+
],
|
|
1690
|
+
state_mutability: "view"
|
|
1691
|
+
},
|
|
1692
|
+
{
|
|
1693
|
+
type: "function",
|
|
1694
|
+
name: "get_total_rewards",
|
|
1695
|
+
inputs: [],
|
|
1696
|
+
outputs: [
|
|
1697
|
+
{
|
|
1698
|
+
type: "core::integer::u32"
|
|
1699
|
+
}
|
|
1700
|
+
],
|
|
1701
|
+
state_mutability: "view"
|
|
1702
|
+
},
|
|
1703
|
+
{
|
|
1704
|
+
type: "function",
|
|
1705
|
+
name: "get_total_unminted_shares",
|
|
1706
|
+
inputs: [],
|
|
1707
|
+
outputs: [
|
|
1708
|
+
{
|
|
1709
|
+
type: "core::integer::u128"
|
|
1710
|
+
}
|
|
1711
|
+
],
|
|
1712
|
+
state_mutability: "view"
|
|
1713
|
+
},
|
|
1714
|
+
{
|
|
1715
|
+
type: "function",
|
|
1716
|
+
name: "get_additional_shares",
|
|
1717
|
+
inputs: [
|
|
1718
|
+
{
|
|
1719
|
+
name: "user",
|
|
1720
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1721
|
+
}
|
|
1722
|
+
],
|
|
1723
|
+
outputs: [
|
|
1724
|
+
{
|
|
1725
|
+
type: "(core::integer::u128, core::integer::u64, core::integer::u128)"
|
|
1726
|
+
}
|
|
1727
|
+
],
|
|
1728
|
+
state_mutability: "view"
|
|
1729
|
+
}
|
|
1730
|
+
]
|
|
1731
|
+
},
|
|
1732
|
+
{
|
|
1733
|
+
type: "struct",
|
|
1734
|
+
name: "strkfarm_contracts::interfaces::IVesu::IStonDispatcher",
|
|
1735
|
+
members: [
|
|
1736
|
+
{
|
|
1737
|
+
name: "contract_address",
|
|
1738
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1739
|
+
}
|
|
1740
|
+
]
|
|
1741
|
+
},
|
|
1742
|
+
{
|
|
1743
|
+
type: "struct",
|
|
1744
|
+
name: "strkfarm_contracts::components::vesu::vesuStruct",
|
|
1745
|
+
members: [
|
|
1746
|
+
{
|
|
1747
|
+
name: "singleton",
|
|
1748
|
+
type: "strkfarm_contracts::interfaces::IVesu::IStonDispatcher"
|
|
1749
|
+
},
|
|
1750
|
+
{
|
|
1751
|
+
name: "pool_id",
|
|
1752
|
+
type: "core::felt252"
|
|
1753
|
+
},
|
|
1754
|
+
{
|
|
1755
|
+
name: "debt",
|
|
1756
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1757
|
+
},
|
|
1758
|
+
{
|
|
1759
|
+
name: "col",
|
|
1760
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1761
|
+
},
|
|
1762
|
+
{
|
|
1763
|
+
name: "oracle",
|
|
1764
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1765
|
+
}
|
|
1766
|
+
]
|
|
1767
|
+
},
|
|
1768
|
+
{
|
|
1769
|
+
type: "constructor",
|
|
1770
|
+
name: "constructor",
|
|
1771
|
+
inputs: [
|
|
1772
|
+
{
|
|
1773
|
+
name: "asset",
|
|
1774
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1775
|
+
},
|
|
1776
|
+
{
|
|
1777
|
+
name: "access_control",
|
|
1778
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1779
|
+
},
|
|
1780
|
+
{
|
|
1781
|
+
name: "allowed_pools",
|
|
1782
|
+
type: "core::array::Array::<strkfarm_contracts::strategies::vesu_rebalance::interface::PoolProps>"
|
|
1783
|
+
},
|
|
1784
|
+
{
|
|
1785
|
+
name: "settings",
|
|
1786
|
+
type: "strkfarm_contracts::strategies::vesu_rebalance::interface::Settings"
|
|
1787
|
+
},
|
|
1788
|
+
{
|
|
1789
|
+
name: "vesu_settings",
|
|
1790
|
+
type: "strkfarm_contracts::components::vesu::vesuStruct"
|
|
1791
|
+
}
|
|
1792
|
+
]
|
|
1793
|
+
},
|
|
1794
|
+
{
|
|
1795
|
+
type: "event",
|
|
1796
|
+
name: "openzeppelin_security::reentrancyguard::ReentrancyGuardComponent::Event",
|
|
1797
|
+
kind: "enum",
|
|
1798
|
+
variants: []
|
|
1799
|
+
},
|
|
1800
|
+
{
|
|
1801
|
+
type: "event",
|
|
1802
|
+
name: "strkfarm_contracts::components::erc4626::ERC4626Component::Deposit",
|
|
1803
|
+
kind: "struct",
|
|
1804
|
+
members: [
|
|
1805
|
+
{
|
|
1806
|
+
name: "sender",
|
|
1807
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
1808
|
+
kind: "key"
|
|
1809
|
+
},
|
|
1810
|
+
{
|
|
1811
|
+
name: "owner",
|
|
1812
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
1813
|
+
kind: "key"
|
|
1814
|
+
},
|
|
1815
|
+
{
|
|
1816
|
+
name: "assets",
|
|
1817
|
+
type: "core::integer::u256",
|
|
1818
|
+
kind: "data"
|
|
1819
|
+
},
|
|
1820
|
+
{
|
|
1821
|
+
name: "shares",
|
|
1822
|
+
type: "core::integer::u256",
|
|
1823
|
+
kind: "data"
|
|
1824
|
+
}
|
|
1825
|
+
]
|
|
1826
|
+
},
|
|
1827
|
+
{
|
|
1828
|
+
type: "event",
|
|
1829
|
+
name: "strkfarm_contracts::components::erc4626::ERC4626Component::Withdraw",
|
|
1830
|
+
kind: "struct",
|
|
1831
|
+
members: [
|
|
1832
|
+
{
|
|
1833
|
+
name: "sender",
|
|
1834
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
1835
|
+
kind: "key"
|
|
1836
|
+
},
|
|
1837
|
+
{
|
|
1838
|
+
name: "receiver",
|
|
1839
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
1840
|
+
kind: "key"
|
|
1841
|
+
},
|
|
1842
|
+
{
|
|
1843
|
+
name: "owner",
|
|
1844
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
1845
|
+
kind: "key"
|
|
1846
|
+
},
|
|
1847
|
+
{
|
|
1848
|
+
name: "assets",
|
|
1849
|
+
type: "core::integer::u256",
|
|
1850
|
+
kind: "data"
|
|
1851
|
+
},
|
|
1852
|
+
{
|
|
1853
|
+
name: "shares",
|
|
1854
|
+
type: "core::integer::u256",
|
|
1855
|
+
kind: "data"
|
|
1856
|
+
}
|
|
1857
|
+
]
|
|
1858
|
+
},
|
|
1859
|
+
{
|
|
1860
|
+
type: "event",
|
|
1861
|
+
name: "strkfarm_contracts::components::erc4626::ERC4626Component::Event",
|
|
1862
|
+
kind: "enum",
|
|
1863
|
+
variants: [
|
|
1864
|
+
{
|
|
1865
|
+
name: "Deposit",
|
|
1866
|
+
type: "strkfarm_contracts::components::erc4626::ERC4626Component::Deposit",
|
|
1867
|
+
kind: "nested"
|
|
1868
|
+
},
|
|
1869
|
+
{
|
|
1870
|
+
name: "Withdraw",
|
|
1871
|
+
type: "strkfarm_contracts::components::erc4626::ERC4626Component::Withdraw",
|
|
1872
|
+
kind: "nested"
|
|
1873
|
+
}
|
|
1874
|
+
]
|
|
1875
|
+
},
|
|
1876
|
+
{
|
|
1877
|
+
type: "event",
|
|
1878
|
+
name: "strkfarm_contracts::components::harvester::reward_shares::RewardShareComponent::Rewards",
|
|
1879
|
+
kind: "struct",
|
|
1880
|
+
members: [
|
|
1881
|
+
{
|
|
1882
|
+
name: "index",
|
|
1883
|
+
type: "core::integer::u32",
|
|
1884
|
+
kind: "data"
|
|
1885
|
+
},
|
|
1886
|
+
{
|
|
1887
|
+
name: "info",
|
|
1888
|
+
type: "strkfarm_contracts::components::harvester::reward_shares::RewardsInfo",
|
|
1889
|
+
kind: "data"
|
|
1890
|
+
},
|
|
1891
|
+
{
|
|
1892
|
+
name: "total_reward_shares",
|
|
1893
|
+
type: "core::integer::u128",
|
|
1894
|
+
kind: "data"
|
|
1895
|
+
},
|
|
1896
|
+
{
|
|
1897
|
+
name: "timestamp",
|
|
1898
|
+
type: "core::integer::u64",
|
|
1899
|
+
kind: "data"
|
|
1900
|
+
}
|
|
1901
|
+
]
|
|
1902
|
+
},
|
|
1903
|
+
{
|
|
1904
|
+
type: "event",
|
|
1905
|
+
name: "strkfarm_contracts::components::harvester::reward_shares::RewardShareComponent::UserRewards",
|
|
1906
|
+
kind: "struct",
|
|
1907
|
+
members: [
|
|
1908
|
+
{
|
|
1909
|
+
name: "user",
|
|
1910
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
1911
|
+
kind: "key"
|
|
1912
|
+
},
|
|
1913
|
+
{
|
|
1914
|
+
name: "info",
|
|
1915
|
+
type: "strkfarm_contracts::components::harvester::reward_shares::UserRewardsInfo",
|
|
1916
|
+
kind: "data"
|
|
1917
|
+
},
|
|
1918
|
+
{
|
|
1919
|
+
name: "total_reward_shares",
|
|
1920
|
+
type: "core::integer::u128",
|
|
1921
|
+
kind: "data"
|
|
1922
|
+
},
|
|
1923
|
+
{
|
|
1924
|
+
name: "timestamp",
|
|
1925
|
+
type: "core::integer::u64",
|
|
1926
|
+
kind: "data"
|
|
1927
|
+
}
|
|
1928
|
+
]
|
|
1929
|
+
},
|
|
1930
|
+
{
|
|
1931
|
+
type: "event",
|
|
1932
|
+
name: "strkfarm_contracts::components::harvester::reward_shares::RewardShareComponent::Event",
|
|
1933
|
+
kind: "enum",
|
|
1934
|
+
variants: [
|
|
1935
|
+
{
|
|
1936
|
+
name: "Rewards",
|
|
1937
|
+
type: "strkfarm_contracts::components::harvester::reward_shares::RewardShareComponent::Rewards",
|
|
1938
|
+
kind: "nested"
|
|
1939
|
+
},
|
|
1940
|
+
{
|
|
1941
|
+
name: "UserRewards",
|
|
1942
|
+
type: "strkfarm_contracts::components::harvester::reward_shares::RewardShareComponent::UserRewards",
|
|
1943
|
+
kind: "nested"
|
|
1944
|
+
}
|
|
1945
|
+
]
|
|
1946
|
+
},
|
|
1947
|
+
{
|
|
1948
|
+
type: "event",
|
|
1949
|
+
name: "openzeppelin_token::erc20::erc20::ERC20Component::Transfer",
|
|
1950
|
+
kind: "struct",
|
|
1951
|
+
members: [
|
|
1952
|
+
{
|
|
1953
|
+
name: "from",
|
|
1954
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
1955
|
+
kind: "key"
|
|
1956
|
+
},
|
|
1957
|
+
{
|
|
1958
|
+
name: "to",
|
|
1959
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
1960
|
+
kind: "key"
|
|
1961
|
+
},
|
|
1962
|
+
{
|
|
1963
|
+
name: "value",
|
|
1964
|
+
type: "core::integer::u256",
|
|
1965
|
+
kind: "data"
|
|
1966
|
+
}
|
|
1967
|
+
]
|
|
1968
|
+
},
|
|
1969
|
+
{
|
|
1970
|
+
type: "event",
|
|
1971
|
+
name: "openzeppelin_token::erc20::erc20::ERC20Component::Approval",
|
|
1972
|
+
kind: "struct",
|
|
1973
|
+
members: [
|
|
1974
|
+
{
|
|
1975
|
+
name: "owner",
|
|
1976
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
1977
|
+
kind: "key"
|
|
1978
|
+
},
|
|
1979
|
+
{
|
|
1980
|
+
name: "spender",
|
|
1981
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
1982
|
+
kind: "key"
|
|
1983
|
+
},
|
|
1984
|
+
{
|
|
1985
|
+
name: "value",
|
|
1986
|
+
type: "core::integer::u256",
|
|
1987
|
+
kind: "data"
|
|
1988
|
+
}
|
|
1989
|
+
]
|
|
1990
|
+
},
|
|
1991
|
+
{
|
|
1992
|
+
type: "event",
|
|
1993
|
+
name: "openzeppelin_token::erc20::erc20::ERC20Component::Event",
|
|
1994
|
+
kind: "enum",
|
|
1995
|
+
variants: [
|
|
1996
|
+
{
|
|
1997
|
+
name: "Transfer",
|
|
1998
|
+
type: "openzeppelin_token::erc20::erc20::ERC20Component::Transfer",
|
|
1999
|
+
kind: "nested"
|
|
2000
|
+
},
|
|
2001
|
+
{
|
|
2002
|
+
name: "Approval",
|
|
2003
|
+
type: "openzeppelin_token::erc20::erc20::ERC20Component::Approval",
|
|
2004
|
+
kind: "nested"
|
|
2005
|
+
}
|
|
2006
|
+
]
|
|
2007
|
+
},
|
|
2008
|
+
{
|
|
2009
|
+
type: "event",
|
|
2010
|
+
name: "openzeppelin_introspection::src5::SRC5Component::Event",
|
|
2011
|
+
kind: "enum",
|
|
2012
|
+
variants: []
|
|
2013
|
+
},
|
|
2014
|
+
{
|
|
2015
|
+
type: "event",
|
|
2016
|
+
name: "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Upgraded",
|
|
2017
|
+
kind: "struct",
|
|
2018
|
+
members: [
|
|
2019
|
+
{
|
|
2020
|
+
name: "class_hash",
|
|
2021
|
+
type: "core::starknet::class_hash::ClassHash",
|
|
2022
|
+
kind: "data"
|
|
2023
|
+
}
|
|
2024
|
+
]
|
|
2025
|
+
},
|
|
2026
|
+
{
|
|
2027
|
+
type: "event",
|
|
2028
|
+
name: "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Event",
|
|
2029
|
+
kind: "enum",
|
|
2030
|
+
variants: [
|
|
2031
|
+
{
|
|
2032
|
+
name: "Upgraded",
|
|
2033
|
+
type: "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Upgraded",
|
|
2034
|
+
kind: "nested"
|
|
2035
|
+
}
|
|
2036
|
+
]
|
|
2037
|
+
},
|
|
2038
|
+
{
|
|
2039
|
+
type: "event",
|
|
2040
|
+
name: "openzeppelin_security::pausable::PausableComponent::Paused",
|
|
2041
|
+
kind: "struct",
|
|
2042
|
+
members: [
|
|
2043
|
+
{
|
|
2044
|
+
name: "account",
|
|
2045
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
2046
|
+
kind: "data"
|
|
2047
|
+
}
|
|
2048
|
+
]
|
|
2049
|
+
},
|
|
2050
|
+
{
|
|
2051
|
+
type: "event",
|
|
2052
|
+
name: "openzeppelin_security::pausable::PausableComponent::Unpaused",
|
|
2053
|
+
kind: "struct",
|
|
2054
|
+
members: [
|
|
2055
|
+
{
|
|
2056
|
+
name: "account",
|
|
2057
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
2058
|
+
kind: "data"
|
|
2059
|
+
}
|
|
2060
|
+
]
|
|
2061
|
+
},
|
|
2062
|
+
{
|
|
2063
|
+
type: "event",
|
|
2064
|
+
name: "openzeppelin_security::pausable::PausableComponent::Event",
|
|
2065
|
+
kind: "enum",
|
|
2066
|
+
variants: [
|
|
2067
|
+
{
|
|
2068
|
+
name: "Paused",
|
|
2069
|
+
type: "openzeppelin_security::pausable::PausableComponent::Paused",
|
|
2070
|
+
kind: "nested"
|
|
2071
|
+
},
|
|
2072
|
+
{
|
|
2073
|
+
name: "Unpaused",
|
|
2074
|
+
type: "openzeppelin_security::pausable::PausableComponent::Unpaused",
|
|
2075
|
+
kind: "nested"
|
|
2076
|
+
}
|
|
2077
|
+
]
|
|
2078
|
+
},
|
|
2079
|
+
{
|
|
2080
|
+
type: "event",
|
|
2081
|
+
name: "strkfarm_contracts::components::common::CommonComp::Event",
|
|
2082
|
+
kind: "enum",
|
|
2083
|
+
variants: []
|
|
2084
|
+
},
|
|
2085
|
+
{
|
|
2086
|
+
type: "event",
|
|
2087
|
+
name: "strkfarm_contracts::strategies::vesu_rebalance::vesu_rebalance::VesuRebalance::Rebalance",
|
|
2088
|
+
kind: "struct",
|
|
2089
|
+
members: [
|
|
2090
|
+
{
|
|
2091
|
+
name: "yield_before",
|
|
2092
|
+
type: "core::integer::u128",
|
|
2093
|
+
kind: "data"
|
|
2094
|
+
},
|
|
2095
|
+
{
|
|
2096
|
+
name: "yield_after",
|
|
2097
|
+
type: "core::integer::u128",
|
|
2098
|
+
kind: "data"
|
|
2099
|
+
}
|
|
2100
|
+
]
|
|
2101
|
+
},
|
|
2102
|
+
{
|
|
2103
|
+
type: "event",
|
|
2104
|
+
name: "strkfarm_contracts::strategies::vesu_rebalance::vesu_rebalance::VesuRebalance::CollectFees",
|
|
2105
|
+
kind: "struct",
|
|
2106
|
+
members: [
|
|
2107
|
+
{
|
|
2108
|
+
name: "fee_collected",
|
|
2109
|
+
type: "core::integer::u128",
|
|
2110
|
+
kind: "data"
|
|
2111
|
+
},
|
|
2112
|
+
{
|
|
2113
|
+
name: "fee_collector",
|
|
2114
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
2115
|
+
kind: "data"
|
|
2116
|
+
}
|
|
2117
|
+
]
|
|
2118
|
+
},
|
|
2119
|
+
{
|
|
2120
|
+
type: "event",
|
|
2121
|
+
name: "strkfarm_contracts::strategies::vesu_rebalance::vesu_rebalance::VesuRebalance::Event",
|
|
2122
|
+
kind: "enum",
|
|
2123
|
+
variants: [
|
|
2124
|
+
{
|
|
2125
|
+
name: "ReentrancyGuardEvent",
|
|
2126
|
+
type: "openzeppelin_security::reentrancyguard::ReentrancyGuardComponent::Event",
|
|
2127
|
+
kind: "flat"
|
|
2128
|
+
},
|
|
2129
|
+
{
|
|
2130
|
+
name: "ERC4626Event",
|
|
2131
|
+
type: "strkfarm_contracts::components::erc4626::ERC4626Component::Event",
|
|
2132
|
+
kind: "flat"
|
|
2133
|
+
},
|
|
2134
|
+
{
|
|
2135
|
+
name: "RewardShareEvent",
|
|
2136
|
+
type: "strkfarm_contracts::components::harvester::reward_shares::RewardShareComponent::Event",
|
|
2137
|
+
kind: "flat"
|
|
2138
|
+
},
|
|
2139
|
+
{
|
|
2140
|
+
name: "ERC20Event",
|
|
2141
|
+
type: "openzeppelin_token::erc20::erc20::ERC20Component::Event",
|
|
2142
|
+
kind: "flat"
|
|
2143
|
+
},
|
|
2144
|
+
{
|
|
2145
|
+
name: "SRC5Event",
|
|
2146
|
+
type: "openzeppelin_introspection::src5::SRC5Component::Event",
|
|
2147
|
+
kind: "flat"
|
|
2148
|
+
},
|
|
2149
|
+
{
|
|
2150
|
+
name: "UpgradeableEvent",
|
|
2151
|
+
type: "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Event",
|
|
2152
|
+
kind: "flat"
|
|
2153
|
+
},
|
|
2154
|
+
{
|
|
2155
|
+
name: "PausableEvent",
|
|
2156
|
+
type: "openzeppelin_security::pausable::PausableComponent::Event",
|
|
2157
|
+
kind: "flat"
|
|
2158
|
+
},
|
|
2159
|
+
{
|
|
2160
|
+
name: "CommonCompEvent",
|
|
2161
|
+
type: "strkfarm_contracts::components::common::CommonComp::Event",
|
|
2162
|
+
kind: "flat"
|
|
2163
|
+
},
|
|
2164
|
+
{
|
|
2165
|
+
name: "Rebalance",
|
|
2166
|
+
type: "strkfarm_contracts::strategies::vesu_rebalance::vesu_rebalance::VesuRebalance::Rebalance",
|
|
2167
|
+
kind: "nested"
|
|
2168
|
+
},
|
|
2169
|
+
{
|
|
2170
|
+
name: "CollectFees",
|
|
2171
|
+
type: "strkfarm_contracts::strategies::vesu_rebalance::vesu_rebalance::VesuRebalance::CollectFees",
|
|
2172
|
+
kind: "nested"
|
|
2173
|
+
}
|
|
2174
|
+
]
|
|
2175
|
+
}
|
|
2176
|
+
];
|
|
2177
|
+
|
|
2178
|
+
// src/utils/index.ts
|
|
2179
|
+
function assert(condition, message) {
|
|
2180
|
+
if (!condition) {
|
|
2181
|
+
throw new Error(message);
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
// src/strategies/vesu-rebalance.ts
|
|
2186
|
+
import axios4 from "axios";
|
|
2187
|
+
var VesuRebalance = class _VesuRebalance {
|
|
2188
|
+
// 10000 bps = 100%
|
|
2189
|
+
/**
|
|
2190
|
+
* Creates a new VesuRebalance strategy instance.
|
|
2191
|
+
* @param config - Configuration object containing provider and other settings
|
|
2192
|
+
* @param pricer - Pricer instance for token price calculations
|
|
2193
|
+
* @param metadata - Strategy metadata including deposit tokens and address
|
|
2194
|
+
* @throws {Error} If more than one deposit token is specified
|
|
2195
|
+
*/
|
|
2196
|
+
constructor(config, pricer, metadata) {
|
|
2197
|
+
this.BASE_WEIGHT = 1e4;
|
|
2198
|
+
this.config = config;
|
|
2199
|
+
this.pricer = pricer;
|
|
2200
|
+
assert(metadata.depositTokens.length === 1, "VesuRebalance only supports 1 deposit token");
|
|
2201
|
+
this.metadata = metadata;
|
|
2202
|
+
this.address = metadata.address;
|
|
2203
|
+
this.contract = new Contract3(vesu_rebalance_abi_default, this.address.address, this.config.provider);
|
|
2204
|
+
}
|
|
2205
|
+
/**
|
|
2206
|
+
* Creates a deposit call to the strategy contract.
|
|
2207
|
+
* @param assets - Amount of assets to deposit
|
|
2208
|
+
* @param receiver - Address that will receive the strategy tokens
|
|
2209
|
+
* @returns Populated contract call for deposit
|
|
2210
|
+
*/
|
|
2211
|
+
depositCall(assets, receiver) {
|
|
2212
|
+
const assetContract = new Contract3(vesu_rebalance_abi_default, this.metadata.depositTokens[0].address, this.config.provider);
|
|
2213
|
+
const call1 = assetContract.populate("approve", [this.address.address, uint2562.bnToUint256(assets.toWei())]);
|
|
2214
|
+
const call2 = this.contract.populate("deposit", [uint2562.bnToUint256(assets.toWei()), receiver.address]);
|
|
2215
|
+
return [call1, call2];
|
|
2216
|
+
}
|
|
2217
|
+
/**
|
|
2218
|
+
* Creates a withdrawal call to the strategy contract.
|
|
2219
|
+
* @param assets - Amount of assets to withdraw
|
|
2220
|
+
* @param receiver - Address that will receive the withdrawn assets
|
|
2221
|
+
* @param owner - Address that owns the strategy tokens
|
|
2222
|
+
* @returns Populated contract call for withdrawal
|
|
2223
|
+
*/
|
|
2224
|
+
withdrawCall(assets, receiver, owner) {
|
|
2225
|
+
return [this.contract.populate("withdraw", [uint2562.bnToUint256(assets.toWei()), receiver.address, owner.address])];
|
|
2226
|
+
}
|
|
2227
|
+
/**
|
|
2228
|
+
* Returns the underlying asset token of the strategy.
|
|
2229
|
+
* @returns The deposit token supported by this strategy
|
|
2230
|
+
*/
|
|
2231
|
+
asset() {
|
|
2232
|
+
return this.metadata.depositTokens[0];
|
|
2233
|
+
}
|
|
2234
|
+
/**
|
|
2235
|
+
* Returns the number of decimals used by the strategy token.
|
|
2236
|
+
* @returns Number of decimals (same as the underlying token)
|
|
2237
|
+
*/
|
|
2238
|
+
decimals() {
|
|
2239
|
+
return this.metadata.depositTokens[0].decimals;
|
|
2240
|
+
}
|
|
2241
|
+
/**
|
|
2242
|
+
* Calculates the Total Value Locked (TVL) for a specific user.
|
|
2243
|
+
* @param user - Address of the user
|
|
2244
|
+
* @returns Object containing the amount in token units and USD value
|
|
2245
|
+
*/
|
|
2246
|
+
async getUserTVL(user) {
|
|
2247
|
+
const shares = await this.contract.balanceOf(user.address);
|
|
2248
|
+
const assets = await this.contract.convert_to_assets(uint2562.bnToUint256(shares));
|
|
2249
|
+
const amount = Web3Number.fromWei(assets.toString(), this.metadata.depositTokens[0].decimals);
|
|
2250
|
+
let price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
2251
|
+
const usdValue = Number(amount.toFixed(6)) * price.price;
|
|
2252
|
+
return {
|
|
2253
|
+
amount,
|
|
2254
|
+
usdValue
|
|
2255
|
+
};
|
|
2256
|
+
}
|
|
2257
|
+
/**
|
|
2258
|
+
* Calculates the total TVL of the strategy.
|
|
2259
|
+
* @returns Object containing the total amount in token units and USD value
|
|
2260
|
+
*/
|
|
2261
|
+
async getTVL() {
|
|
2262
|
+
const assets = await this.contract.total_assets();
|
|
2263
|
+
const amount = Web3Number.fromWei(assets.toString(), this.metadata.depositTokens[0].decimals);
|
|
2264
|
+
let price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
2265
|
+
const usdValue = Number(amount.toFixed(6)) * price.price;
|
|
2266
|
+
return {
|
|
2267
|
+
amount,
|
|
2268
|
+
usdValue
|
|
2269
|
+
};
|
|
2270
|
+
}
|
|
2271
|
+
/**
|
|
2272
|
+
* Retrieves the list of allowed pools and their detailed information from multiple sources:
|
|
2273
|
+
* 1. Contract's allowed pools
|
|
2274
|
+
* 2. Vesu positions API for current positions
|
|
2275
|
+
* 3. Vesu pools API for APY and utilization data
|
|
2276
|
+
*
|
|
2277
|
+
* @returns {Promise<{
|
|
2278
|
+
* data: Array<PoolInfoFull>,
|
|
2279
|
+
* isErrorPositionsAPI: boolean
|
|
2280
|
+
* }>} Object containing:
|
|
2281
|
+
* - data: Array of pool information including IDs, weights, amounts, APYs and utilization
|
|
2282
|
+
* - isErrorPositionsAPI: Boolean indicating if there was an error fetching position data
|
|
2283
|
+
*/
|
|
2284
|
+
async getPools() {
|
|
2285
|
+
const allowedPools = (await this.contract.get_allowed_pools()).map((p) => ({
|
|
2286
|
+
pool_id: ContractAddr.from(p.pool_id),
|
|
2287
|
+
max_weight: Number(p.max_weight) / this.BASE_WEIGHT,
|
|
2288
|
+
v_token: ContractAddr.from(p.v_token)
|
|
2289
|
+
}));
|
|
2290
|
+
let isErrorPositionsAPI = false;
|
|
2291
|
+
let vesuPositions = [];
|
|
2292
|
+
try {
|
|
2293
|
+
const res = await axios4.get(`https://api.vesu.xyz/positions?walletAddress=${this.address.address}`);
|
|
2294
|
+
const data2 = await res.data;
|
|
2295
|
+
vesuPositions = data2.data;
|
|
2296
|
+
} catch (e) {
|
|
2297
|
+
console.error(`${_VesuRebalance.name}: Error fetching pools for ${this.address.address}`, e);
|
|
2298
|
+
isErrorPositionsAPI = true;
|
|
2299
|
+
}
|
|
2300
|
+
let isErrorPoolsAPI = false;
|
|
2301
|
+
let pools = [];
|
|
2302
|
+
try {
|
|
2303
|
+
const res = await axios4.get(`https://api.vesu.xyz/pools`);
|
|
2304
|
+
const data2 = await res.data;
|
|
2305
|
+
pools = data2.data;
|
|
2306
|
+
} catch (e) {
|
|
2307
|
+
console.error(`${_VesuRebalance.name}: Error fetching pools for ${this.address.address}`, e);
|
|
2308
|
+
isErrorPoolsAPI = true;
|
|
2309
|
+
}
|
|
2310
|
+
const totalAssets = (await this.getTVL()).amount;
|
|
2311
|
+
const info = allowedPools.map(async (p) => {
|
|
2312
|
+
const vesuPosition = vesuPositions.find((d) => d.pool.id.toString() === num2.getDecimalString(p.pool_id.address.toString()));
|
|
2313
|
+
const pool = pools.find((d) => d.id == num2.getDecimalString(p.pool_id.address));
|
|
2314
|
+
const assetInfo = pool?.assets.find((d) => ContractAddr.from(this.asset().address).eqString(d.address));
|
|
2315
|
+
let vTokenContract = new Contract3(vesu_rebalance_abi_default, p.v_token.address, this.config.provider);
|
|
2316
|
+
const bal = await vTokenContract.balanceOf(this.address.address);
|
|
2317
|
+
const assets = await vTokenContract.convert_to_assets(uint2562.bnToUint256(bal.toString()));
|
|
2318
|
+
const item = {
|
|
2319
|
+
pool_id: p.pool_id,
|
|
2320
|
+
pool_name: vesuPosition?.pool.name,
|
|
2321
|
+
max_weight: p.max_weight,
|
|
2322
|
+
current_weight: isErrorPositionsAPI || !vesuPosition ? 0 : Number(Web3Number.fromWei(vesuPosition.collateral.value, this.decimals()).dividedBy(totalAssets.toString()).toFixed(6)),
|
|
2323
|
+
v_token: p.v_token,
|
|
2324
|
+
amount: Web3Number.fromWei(assets.toString(), this.decimals()),
|
|
2325
|
+
usdValue: isErrorPositionsAPI || !vesuPosition ? Web3Number.fromWei("0", this.decimals()) : Web3Number.fromWei(vesuPosition.collateral.usdPrice.value, vesuPosition.collateral.usdPrice.decimals),
|
|
2326
|
+
APY: isErrorPoolsAPI || !assetInfo ? {
|
|
2327
|
+
baseApy: 0,
|
|
2328
|
+
defiSpringApy: 0,
|
|
2329
|
+
netApy: 0
|
|
2330
|
+
} : {
|
|
2331
|
+
baseApy: Number(Web3Number.fromWei(assetInfo.stats.supplyApy.value, assetInfo.stats.supplyApy.decimals).toFixed(6)),
|
|
2332
|
+
defiSpringApy: Number(Web3Number.fromWei(assetInfo.stats.defiSpringSupplyApr.value, assetInfo.stats.defiSpringSupplyApr.decimals).toFixed(6)),
|
|
2333
|
+
netApy: 0
|
|
2334
|
+
},
|
|
2335
|
+
currentUtilization: isErrorPoolsAPI || !assetInfo ? 0 : Number(Web3Number.fromWei(assetInfo.stats.currentUtilization.value, assetInfo.stats.currentUtilization.decimals).toFixed(6)),
|
|
2336
|
+
maxUtilization: isErrorPoolsAPI || !assetInfo ? 0 : Number(Web3Number.fromWei(assetInfo.config.maxUtilization.value, assetInfo.config.maxUtilization.decimals).toFixed(6))
|
|
2337
|
+
};
|
|
2338
|
+
item.APY.netApy = item.APY.baseApy + item.APY.defiSpringApy;
|
|
2339
|
+
return item;
|
|
2340
|
+
});
|
|
2341
|
+
const data = await Promise.all(info);
|
|
2342
|
+
return {
|
|
2343
|
+
data,
|
|
2344
|
+
isErrorPositionsAPI,
|
|
2345
|
+
isErrorPoolsAPI,
|
|
2346
|
+
isError: isErrorPositionsAPI || isErrorPoolsAPI
|
|
2347
|
+
};
|
|
2348
|
+
}
|
|
2349
|
+
/**
|
|
2350
|
+
* Calculates the weighted average APY across all pools based on USD value.
|
|
2351
|
+
* @returns {Promise<number>} The weighted average APY across all pools
|
|
2352
|
+
*/
|
|
2353
|
+
async netAPY() {
|
|
2354
|
+
const { data: pools } = await this.getPools();
|
|
2355
|
+
return this.netAPYGivenPools(pools);
|
|
2356
|
+
}
|
|
2357
|
+
/**
|
|
2358
|
+
* Calculates the weighted average APY across all pools based on USD value.
|
|
2359
|
+
* @returns {Promise<number>} The weighted average APY across all pools
|
|
2360
|
+
*/
|
|
2361
|
+
netAPYGivenPools(pools) {
|
|
2362
|
+
const weightedApy = pools.reduce((acc, curr) => {
|
|
2363
|
+
const weight = curr.current_weight;
|
|
2364
|
+
return acc + curr.APY.netApy * weight;
|
|
2365
|
+
}, 0);
|
|
2366
|
+
return weightedApy;
|
|
2367
|
+
}
|
|
2368
|
+
/**
|
|
2369
|
+
* Calculates optimal position changes to maximize APY while respecting max weights.
|
|
2370
|
+
* The algorithm:
|
|
2371
|
+
* 1. Sorts pools by APY (highest first)
|
|
2372
|
+
* 2. Calculates target amounts based on max weights
|
|
2373
|
+
* 3. For each pool that needs more funds:
|
|
2374
|
+
* - Takes funds from lowest APY pools that are over their target
|
|
2375
|
+
* 4. Validates that total assets remain constant
|
|
2376
|
+
*
|
|
2377
|
+
* @returns {Promise<{
|
|
2378
|
+
* changes: Change[],
|
|
2379
|
+
* finalPools: PoolInfoFull[],
|
|
2380
|
+
* isAnyPoolOverMaxWeight: boolean
|
|
2381
|
+
* }>} Object containing:
|
|
2382
|
+
* - changes: Array of position changes
|
|
2383
|
+
* - finalPools: Array of pool information after rebalance
|
|
2384
|
+
* @throws Error if rebalance is not possible while maintaining constraints
|
|
2385
|
+
*/
|
|
2386
|
+
async getRebalancedPositions() {
|
|
2387
|
+
const { data: pools } = await this.getPools();
|
|
2388
|
+
const totalAssets = (await this.getTVL()).amount;
|
|
2389
|
+
if (totalAssets.eq(0)) return {
|
|
2390
|
+
changes: [],
|
|
2391
|
+
finalPools: []
|
|
2392
|
+
};
|
|
2393
|
+
const sumPools = pools.reduce((acc, curr) => acc.plus(curr.amount.toString()), Web3Number.fromWei("0", this.decimals()));
|
|
2394
|
+
assert(sumPools.lte(totalAssets), "Sum of pools.amount must be less than or equal to totalAssets");
|
|
2395
|
+
const sortedPools = [...pools].sort((a, b) => b.APY.netApy - a.APY.netApy);
|
|
2396
|
+
const targetAmounts = {};
|
|
2397
|
+
let remainingAssets = totalAssets;
|
|
2398
|
+
let isAnyPoolOverMaxWeight = false;
|
|
2399
|
+
for (const pool of sortedPools) {
|
|
2400
|
+
const maxAmount = totalAssets.multipliedBy(pool.max_weight * 0.9);
|
|
2401
|
+
const targetAmount = remainingAssets.gte(maxAmount) ? maxAmount : remainingAssets;
|
|
2402
|
+
targetAmounts[pool.pool_id.address.toString()] = targetAmount;
|
|
2403
|
+
remainingAssets = remainingAssets.minus(targetAmount.toString());
|
|
2404
|
+
if (pool.current_weight > pool.max_weight) {
|
|
2405
|
+
isAnyPoolOverMaxWeight = true;
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
assert(remainingAssets.lt(1e-5), "Remaining assets must be 0");
|
|
2409
|
+
const changes = sortedPools.map((pool) => {
|
|
2410
|
+
const target = targetAmounts[pool.pool_id.address.toString()] || Web3Number.fromWei("0", this.decimals());
|
|
2411
|
+
const change = Web3Number.fromWei(target.minus(pool.amount.toString()).toWei(), this.decimals());
|
|
2412
|
+
return {
|
|
2413
|
+
pool_id: pool.pool_id,
|
|
2414
|
+
changeAmt: change,
|
|
2415
|
+
finalAmt: target,
|
|
2416
|
+
isDeposit: change.gt(0)
|
|
2417
|
+
};
|
|
2418
|
+
});
|
|
2419
|
+
const sumChanges = changes.reduce((sum, c) => sum.plus(c.changeAmt.toString()), Web3Number.fromWei("0", this.decimals()));
|
|
2420
|
+
const sumFinal = changes.reduce((sum, c) => sum.plus(c.finalAmt.toString()), Web3Number.fromWei("0", this.decimals()));
|
|
2421
|
+
const hasChanges = changes.some((c) => !c.changeAmt.eq(0));
|
|
2422
|
+
if (!sumChanges.eq(0)) throw new Error("Sum of changes must be zero");
|
|
2423
|
+
if (!sumFinal.eq(totalAssets)) throw new Error("Sum of final amounts must equal total assets");
|
|
2424
|
+
if (!hasChanges) throw new Error("No changes required");
|
|
2425
|
+
const finalPools = pools.map((p) => {
|
|
2426
|
+
const target = targetAmounts[p.pool_id.address.toString()] || Web3Number.fromWei("0", this.decimals());
|
|
2427
|
+
return {
|
|
2428
|
+
...p,
|
|
2429
|
+
amount: target,
|
|
2430
|
+
usdValue: Web3Number.fromWei("0", this.decimals())
|
|
2431
|
+
};
|
|
2432
|
+
});
|
|
2433
|
+
return {
|
|
2434
|
+
changes,
|
|
2435
|
+
finalPools,
|
|
2436
|
+
isAnyPoolOverMaxWeight
|
|
2437
|
+
};
|
|
2438
|
+
}
|
|
2439
|
+
/**
|
|
2440
|
+
* Creates a rebalance Call object for the strategy contract
|
|
2441
|
+
* @param pools - Array of pool information including IDs, weights, amounts, APYs and utilization
|
|
2442
|
+
* @returns Populated contract call for rebalance
|
|
2443
|
+
*/
|
|
2444
|
+
async getRebalanceCall(pools, isOverWeightAdjustment) {
|
|
2445
|
+
const actions = [];
|
|
2446
|
+
pools.sort((a, b) => b.isDeposit ? -1 : 1);
|
|
2447
|
+
console.log("pools", pools);
|
|
2448
|
+
pools.forEach((p) => {
|
|
2449
|
+
if (p.changeAmt.eq(0)) return null;
|
|
2450
|
+
actions.push({
|
|
2451
|
+
pool_id: p.pool_id.address,
|
|
2452
|
+
feature: new CairoCustomEnum(p.isDeposit ? { DEPOSIT: {} } : { WITHDRAW: {} }),
|
|
2453
|
+
token: this.asset().address,
|
|
2454
|
+
amount: uint2562.bnToUint256(p.changeAmt.multipliedBy(p.isDeposit ? 1 : -1).toWei())
|
|
2455
|
+
});
|
|
2456
|
+
});
|
|
2457
|
+
if (actions.length === 0) return null;
|
|
2458
|
+
if (isOverWeightAdjustment) {
|
|
2459
|
+
return this.contract.populate("rebalance_weights", [actions]);
|
|
2460
|
+
}
|
|
2461
|
+
return this.contract.populate("rebalance", [actions]);
|
|
2462
|
+
}
|
|
2463
|
+
};
|
|
2464
|
+
var _description = "Automatically diversify {{TOKEN}} holdings into different Vesu pools while reducing risk and maximizing yield. Defi spring STRK Rewards are auto-compounded as well.";
|
|
2465
|
+
var _protocol = { name: "Vesu", logo: "https://static-assets-8zct.onrender.com/integrations/vesu/logo.png" };
|
|
2466
|
+
var VesuRebalanceStrategies = [{
|
|
2467
|
+
name: "Vesu STRK",
|
|
2468
|
+
description: _description.replace("{{TOKEN}}", "STRK"),
|
|
2469
|
+
address: ContractAddr.from("0xeeb729d554ae486387147b13a9c8871bc7991d454e8b5ff570d4bf94de71e1"),
|
|
2470
|
+
type: "ERC4626",
|
|
2471
|
+
depositTokens: [Global.getDefaultTokens().find((t) => t.symbol === "STRK")],
|
|
2472
|
+
protocols: [_protocol]
|
|
2473
|
+
}];
|
|
2474
|
+
|
|
2475
|
+
// src/notifs/telegram.ts
|
|
2476
|
+
import TelegramBot from "node-telegram-bot-api";
|
|
2477
|
+
var TelegramNotif = class {
|
|
2478
|
+
constructor(token, shouldPoll) {
|
|
2479
|
+
this.subscribers = [
|
|
2480
|
+
// '6820228303',
|
|
2481
|
+
"1505578076",
|
|
2482
|
+
// '5434736198', // maaza
|
|
2483
|
+
"1356705582",
|
|
2484
|
+
// langs
|
|
2485
|
+
"1388729514",
|
|
2486
|
+
// hwashere
|
|
2487
|
+
"6020162572",
|
|
2488
|
+
//minato
|
|
2489
|
+
"985902592"
|
|
2490
|
+
];
|
|
2491
|
+
this.bot = new TelegramBot(token, { polling: shouldPoll });
|
|
2492
|
+
}
|
|
2493
|
+
// listen to start msgs, register chatId and send registered msg
|
|
2494
|
+
activateChatBot() {
|
|
2495
|
+
this.bot.on("message", (msg) => {
|
|
2496
|
+
const chatId = msg.chat.id;
|
|
2497
|
+
let text = msg.text.toLowerCase().trim();
|
|
2498
|
+
logger.verbose(`Tg: IncomingMsg: ID: ${chatId}, msg: ${text}`);
|
|
2499
|
+
if (text == "start") {
|
|
2500
|
+
this.bot.sendMessage(chatId, "Registered");
|
|
2501
|
+
this.subscribers.push(chatId);
|
|
2502
|
+
logger.verbose(`Tg: New subscriber: ${chatId}`);
|
|
2503
|
+
} else {
|
|
2504
|
+
this.bot.sendMessage(chatId, "Unrecognized command. Supported commands: start");
|
|
2505
|
+
}
|
|
2506
|
+
});
|
|
2507
|
+
}
|
|
2508
|
+
// send a given msg to all registered users
|
|
2509
|
+
sendMessage(msg) {
|
|
2510
|
+
logger.verbose(`Tg: Sending message: ${msg}`);
|
|
2511
|
+
for (let chatId of this.subscribers) {
|
|
2512
|
+
this.bot.sendMessage(chatId, msg).catch((err) => {
|
|
2513
|
+
logger.error(`Tg: Error sending msg to ${chatId}`);
|
|
2514
|
+
logger.error(`Tg: Error sending message: ${err.message}`);
|
|
2515
|
+
}).then(() => {
|
|
2516
|
+
logger.verbose(`Tg: Message sent to ${chatId}`);
|
|
2517
|
+
});
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
};
|
|
2521
|
+
|
|
2522
|
+
// src/node/pricer-redis.ts
|
|
2523
|
+
import { createClient } from "redis";
|
|
2524
|
+
var PricerRedis = class extends Pricer {
|
|
2525
|
+
constructor(config, tokens2) {
|
|
2526
|
+
super(config, tokens2);
|
|
2527
|
+
this.redisClient = null;
|
|
2528
|
+
}
|
|
2529
|
+
/** Reads prices from Pricer._loadPrices and uses a callback to set prices in redis */
|
|
2530
|
+
async startWithRedis(redisUrl) {
|
|
2531
|
+
await this.initRedis(redisUrl);
|
|
2532
|
+
logger.info(`Starting Pricer with Redis`);
|
|
2533
|
+
this._loadPrices(this._setRedisPrices.bind(this));
|
|
2534
|
+
setInterval(() => {
|
|
2535
|
+
this._loadPrices(this._setRedisPrices.bind(this));
|
|
2536
|
+
}, 3e4);
|
|
2537
|
+
}
|
|
2538
|
+
async close() {
|
|
2539
|
+
if (this.redisClient) {
|
|
2540
|
+
await this.redisClient.disconnect();
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2543
|
+
async initRedis(redisUrl) {
|
|
2544
|
+
logger.info(`Initialising Redis Client`);
|
|
2545
|
+
this.redisClient = await createClient({
|
|
2546
|
+
url: redisUrl
|
|
2547
|
+
});
|
|
2548
|
+
this.redisClient.on("error", (err) => console.log("Redis Client Error", err)).connect();
|
|
2549
|
+
logger.info(`Redis Client Initialised`);
|
|
2550
|
+
}
|
|
2551
|
+
/** sets current local price in redis */
|
|
2552
|
+
_setRedisPrices(tokenSymbol) {
|
|
2553
|
+
if (!this.redisClient) {
|
|
2554
|
+
throw new FatalError(`Redis client not initialised`);
|
|
2555
|
+
}
|
|
2556
|
+
this.redisClient.set(`Price:${tokenSymbol}`, JSON.stringify(this.prices[tokenSymbol])).catch((err) => {
|
|
2557
|
+
logger.warn(`Error setting price in redis for ${tokenSymbol}`);
|
|
2558
|
+
});
|
|
2559
|
+
}
|
|
2560
|
+
/** Returns price from redis */
|
|
2561
|
+
async getPrice(tokenSymbol) {
|
|
2562
|
+
const STALE_TIME = 6e4;
|
|
2563
|
+
if (!this.redisClient) {
|
|
2564
|
+
throw new FatalError(`Redis client not initialised`);
|
|
2565
|
+
}
|
|
2566
|
+
const data = await this.redisClient.get(`Price:${tokenSymbol}`);
|
|
2567
|
+
if (!data) {
|
|
935
2568
|
throw new FatalError(`Redis:Price of ${tokenSymbol} not found`);
|
|
936
2569
|
}
|
|
937
2570
|
logger.verbose(`Redis:Price of ${tokenSymbol} is ${data}`);
|
|
@@ -942,6 +2575,164 @@ var PricerRedis = class extends Pricer {
|
|
|
942
2575
|
return priceInfo;
|
|
943
2576
|
}
|
|
944
2577
|
};
|
|
2578
|
+
|
|
2579
|
+
// src/utils/store.ts
|
|
2580
|
+
import fs, { readFileSync, writeFileSync } from "fs";
|
|
2581
|
+
import { Account, constants } from "starknet";
|
|
2582
|
+
import * as crypto2 from "crypto";
|
|
2583
|
+
|
|
2584
|
+
// src/utils/encrypt.ts
|
|
2585
|
+
import * as crypto from "crypto";
|
|
2586
|
+
var PasswordJsonCryptoUtil = class {
|
|
2587
|
+
constructor() {
|
|
2588
|
+
this.algorithm = "aes-256-gcm";
|
|
2589
|
+
this.keyLength = 32;
|
|
2590
|
+
// 256 bits
|
|
2591
|
+
this.saltLength = 16;
|
|
2592
|
+
// 128 bits
|
|
2593
|
+
this.ivLength = 12;
|
|
2594
|
+
// 96 bits for GCM
|
|
2595
|
+
this.tagLength = 16;
|
|
2596
|
+
// 128 bits
|
|
2597
|
+
this.pbkdf2Iterations = 1e5;
|
|
2598
|
+
}
|
|
2599
|
+
// Number of iterations for PBKDF2
|
|
2600
|
+
deriveKey(password, salt) {
|
|
2601
|
+
return crypto.pbkdf2Sync(password, salt, this.pbkdf2Iterations, this.keyLength, "sha256");
|
|
2602
|
+
}
|
|
2603
|
+
encrypt(data, password) {
|
|
2604
|
+
const jsonString = JSON.stringify(data);
|
|
2605
|
+
const salt = crypto.randomBytes(this.saltLength);
|
|
2606
|
+
const iv = crypto.randomBytes(this.ivLength);
|
|
2607
|
+
const key = this.deriveKey(password, salt);
|
|
2608
|
+
const cipher = crypto.createCipheriv(this.algorithm, key, iv, { authTagLength: this.tagLength });
|
|
2609
|
+
let encrypted = cipher.update(jsonString, "utf8", "hex");
|
|
2610
|
+
encrypted += cipher.final("hex");
|
|
2611
|
+
const tag = cipher.getAuthTag();
|
|
2612
|
+
return Buffer.concat([salt, iv, tag, Buffer.from(encrypted, "hex")]).toString("base64");
|
|
2613
|
+
}
|
|
2614
|
+
decrypt(encryptedData, password) {
|
|
2615
|
+
const data = Buffer.from(encryptedData, "base64");
|
|
2616
|
+
const salt = data.subarray(0, this.saltLength);
|
|
2617
|
+
const iv = data.subarray(this.saltLength, this.saltLength + this.ivLength);
|
|
2618
|
+
const tag = data.subarray(this.saltLength + this.ivLength, this.saltLength + this.ivLength + this.tagLength);
|
|
2619
|
+
const encrypted = data.subarray(this.saltLength + this.ivLength + this.tagLength);
|
|
2620
|
+
const key = this.deriveKey(password, salt);
|
|
2621
|
+
const decipher = crypto.createDecipheriv(this.algorithm, key, iv, { authTagLength: this.tagLength });
|
|
2622
|
+
decipher.setAuthTag(tag);
|
|
2623
|
+
try {
|
|
2624
|
+
let decrypted = decipher.update(encrypted.toString("hex"), "hex", "utf8");
|
|
2625
|
+
decrypted += decipher.final("utf8");
|
|
2626
|
+
return JSON.parse(decrypted);
|
|
2627
|
+
} catch (error) {
|
|
2628
|
+
throw new Error("Decryption failed. This could be due to an incorrect password or corrupted data.");
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
};
|
|
2632
|
+
|
|
2633
|
+
// src/utils/store.ts
|
|
2634
|
+
function getDefaultStoreConfig(network) {
|
|
2635
|
+
if (!process.env.HOME) {
|
|
2636
|
+
throw new Error("StoreConfig: HOME environment variable not found");
|
|
2637
|
+
}
|
|
2638
|
+
return {
|
|
2639
|
+
SECRET_FILE_FOLDER: `${process.env.HOME}/.starknet-store`,
|
|
2640
|
+
NETWORK: network,
|
|
2641
|
+
ACCOUNTS_FILE_NAME: "accounts.json",
|
|
2642
|
+
PASSWORD: crypto2.randomBytes(16).toString("hex")
|
|
2643
|
+
};
|
|
2644
|
+
}
|
|
2645
|
+
var Store = class _Store {
|
|
2646
|
+
constructor(config, storeConfig) {
|
|
2647
|
+
this.encryptor = new PasswordJsonCryptoUtil();
|
|
2648
|
+
this.config = config;
|
|
2649
|
+
const defaultStoreConfig = getDefaultStoreConfig(config.network);
|
|
2650
|
+
if (!storeConfig.PASSWORD) {
|
|
2651
|
+
_Store.logPassword(defaultStoreConfig.PASSWORD);
|
|
2652
|
+
}
|
|
2653
|
+
this.storeConfig = {
|
|
2654
|
+
...defaultStoreConfig,
|
|
2655
|
+
...storeConfig
|
|
2656
|
+
};
|
|
2657
|
+
_Store.ensureFolder(this.storeConfig.SECRET_FILE_FOLDER);
|
|
2658
|
+
}
|
|
2659
|
+
static logPassword(password) {
|
|
2660
|
+
logger.warn(`\u26A0\uFE0F=========================================\u26A0\uFE0F`);
|
|
2661
|
+
logger.warn(`Generated a random password for store`);
|
|
2662
|
+
logger.warn(`\u26A0\uFE0F Password: ${password}`);
|
|
2663
|
+
logger.warn(`This not stored anywhere, please you backup this password for future use`);
|
|
2664
|
+
logger.warn(`\u26A0\uFE0F=========================================\u26A0\uFE0F`);
|
|
2665
|
+
}
|
|
2666
|
+
getAccount(accountKey, txVersion = constants.TRANSACTION_VERSION.V2) {
|
|
2667
|
+
const accounts = this.loadAccounts();
|
|
2668
|
+
logger.verbose(`nAccounts loaded for network: ${Object.keys(accounts).length}`);
|
|
2669
|
+
const data = accounts[accountKey];
|
|
2670
|
+
if (!data) {
|
|
2671
|
+
throw new Error(`Account not found: ${accountKey}`);
|
|
2672
|
+
}
|
|
2673
|
+
logger.verbose(`Account loaded: ${accountKey} from network: ${this.config.network}`);
|
|
2674
|
+
logger.verbose(`Address: ${data.address}`);
|
|
2675
|
+
const acc = new Account(this.config.provider, data.address, data.pk, void 0, txVersion);
|
|
2676
|
+
return acc;
|
|
2677
|
+
}
|
|
2678
|
+
addAccount(accountKey, address, pk) {
|
|
2679
|
+
const allAccounts = this.getAllAccounts();
|
|
2680
|
+
if (!allAccounts[this.config.network]) {
|
|
2681
|
+
allAccounts[this.config.network] = {};
|
|
2682
|
+
}
|
|
2683
|
+
allAccounts[this.config.network][accountKey] = {
|
|
2684
|
+
address,
|
|
2685
|
+
pk
|
|
2686
|
+
};
|
|
2687
|
+
const encryptedData = this.encryptor.encrypt(allAccounts, this.storeConfig.PASSWORD);
|
|
2688
|
+
writeFileSync(this.getAccountFilePath(), encryptedData);
|
|
2689
|
+
logger.verbose(`Account added: ${accountKey} to network: ${this.config.network}`);
|
|
2690
|
+
}
|
|
2691
|
+
getAccountFilePath() {
|
|
2692
|
+
const path = `${this.storeConfig.SECRET_FILE_FOLDER}/${this.storeConfig.ACCOUNTS_FILE_NAME}`;
|
|
2693
|
+
logger.verbose(`Path: ${path}`);
|
|
2694
|
+
return path;
|
|
2695
|
+
}
|
|
2696
|
+
getAllAccounts() {
|
|
2697
|
+
const PATH = this.getAccountFilePath();
|
|
2698
|
+
if (!fs.existsSync(PATH)) {
|
|
2699
|
+
logger.verbose(`Accounts: files doesnt exist`);
|
|
2700
|
+
return {};
|
|
2701
|
+
}
|
|
2702
|
+
let encryptedData = readFileSync(PATH, {
|
|
2703
|
+
encoding: "utf-8"
|
|
2704
|
+
});
|
|
2705
|
+
let data = this.encryptor.decrypt(encryptedData, this.storeConfig.PASSWORD);
|
|
2706
|
+
return data;
|
|
2707
|
+
}
|
|
2708
|
+
/**
|
|
2709
|
+
* @description Load all accounts of the network
|
|
2710
|
+
* @returns NetworkAccounts
|
|
2711
|
+
*/
|
|
2712
|
+
loadAccounts() {
|
|
2713
|
+
const allData = this.getAllAccounts();
|
|
2714
|
+
logger.verbose(`Accounts loaded for network: ${this.config.network}`);
|
|
2715
|
+
if (!allData[this.config.network]) {
|
|
2716
|
+
allData[this.config.network] = {};
|
|
2717
|
+
}
|
|
2718
|
+
return allData[this.config.network];
|
|
2719
|
+
}
|
|
2720
|
+
/**
|
|
2721
|
+
* @description List all accountKeys of the network
|
|
2722
|
+
* @returns string[]
|
|
2723
|
+
*/
|
|
2724
|
+
listAccounts() {
|
|
2725
|
+
return Object.keys(this.loadAccounts());
|
|
2726
|
+
}
|
|
2727
|
+
static ensureFolder(folder) {
|
|
2728
|
+
if (!fs.existsSync(folder)) {
|
|
2729
|
+
fs.mkdirSync(folder, { recursive: true });
|
|
2730
|
+
}
|
|
2731
|
+
if (!fs.existsSync(`${folder}`)) {
|
|
2732
|
+
throw new Error(`Store folder not found: ${folder}`);
|
|
2733
|
+
}
|
|
2734
|
+
}
|
|
2735
|
+
};
|
|
945
2736
|
export {
|
|
946
2737
|
AutoCompounderSTRK,
|
|
947
2738
|
ContractAddr,
|
|
@@ -954,11 +2745,15 @@ export {
|
|
|
954
2745
|
PasswordJsonCryptoUtil,
|
|
955
2746
|
Pragma,
|
|
956
2747
|
Pricer,
|
|
2748
|
+
PricerBase,
|
|
957
2749
|
PricerRedis,
|
|
958
2750
|
Store,
|
|
959
2751
|
TelegramNotif,
|
|
2752
|
+
VesuRebalance,
|
|
2753
|
+
VesuRebalanceStrategies,
|
|
960
2754
|
Web3Number,
|
|
961
2755
|
ZkLend,
|
|
2756
|
+
assert,
|
|
962
2757
|
getDefaultStoreConfig,
|
|
963
2758
|
getMainnetConfig,
|
|
964
2759
|
logger
|