Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

rebase with upstream main #3

Merged
merged 40 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
0a552d9
Add pool name to extensions
vesu-dev Oct 25, 2024
9e7c0aa
Add pool name to scripts
vesu-dev Oct 28, 2024
ceb032c
Add CreateVToken event
vesu-dev Nov 4, 2024
dbcbcd9
Push progress
vesu-dev Nov 6, 2024
ddd44ad
Push progress II
vesu-dev Nov 8, 2024
b1bb6fd
Push progress III
vesu-dev Nov 8, 2024
dae7f84
Push progress IV
vesu-dev Nov 11, 2024
2d17360
Update max steps
vesu-dev Nov 13, 2024
e65f27b
Update gas report script
vesu-dev Nov 13, 2024
6a2ef8a
Fix CI
vesu-dev Nov 13, 2024
a22b209
Merge pull request #6 from vesuxyz/feat/pool-name
vesu-dev Nov 14, 2024
c2eb1e0
Merge pull request #9 from vesuxyz/feat/v-token-event
vesu-dev Nov 14, 2024
33bf321
Merge branch 'main' into fix/inflation-fee-v3
vesu-dev Nov 14, 2024
1e45d28
Add gas report
vesu-dev Nov 14, 2024
44bdf42
Merge pull request #10 from vesuxyz/fix/inflation-fee-v3
vesu-dev Nov 14, 2024
fa72fbb
Push progress
vesu-dev Nov 19, 2024
89f05ee
Update scripts
vesu-dev Nov 20, 2024
8e0489a
Fmt
vesu-dev Nov 20, 2024
53852cb
Add test for twap
vesu-dev Nov 21, 2024
3912f54
Update debt_caps to be pair specific
vesu-dev Nov 21, 2024
ce74566
Merge pull request #11 from vesuxyz/feat/twap-oracle
vesu-dev Nov 21, 2024
b9bb782
Merge pull request #12 from vesuxyz/feat/debt-caps
vesu-dev Nov 21, 2024
8084ed9
Update deployment scripts
vesu-dev Nov 25, 2024
54ba4ad
Fmt
vesu-dev Nov 25, 2024
5bce18a
Assert return values of ERC20 calls
vesu-dev Nov 26, 2024
14944ac
Fix summary_stats address in deployment scripts
vesu-dev Nov 27, 2024
3951841
Fix deployExtensions script
vesu-dev Nov 27, 2024
bd94a63
Skip pair collateralization check if max_ltv == 0
vesu-dev Nov 29, 2024
830ab6c
Fmt
vesu-dev Nov 29, 2024
f44e4ef
Add ability to update twap params and cl aggregator address
vesu-dev Nov 30, 2024
9e20700
Merge pull request #14 from vesuxyz/feat/pair-ltv-0
vesu-dev Dec 1, 2024
4a2bdbf
Update oracle_config assertion and add tests
vesu-dev Dec 4, 2024
0f8b1c8
Add verifyPool script
vesu-dev Dec 4, 2024
5136122
Update scripts
vesu-dev Dec 4, 2024
c2bea1e
Update scripts
vesu-dev Dec 5, 2024
4db83c1
Add integration tests
vesu-dev Dec 9, 2024
78cf26d
Remove Timelock and integration tests
vesu-dev Dec 10, 2024
530f5e2
Merge branch 'main' of https://github.com/vesuxyz/vesu-v1 into feat/e…
tserg Dec 20, 2024
a54d9a7
fix ek tests
tserg Dec 20, 2024
ec0569f
remove todo; make fn sig consistent
tserg Dec 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
- name: Patch Scarb.toml
run: ./scripts/patchScarbToml.sh

- run: snforge test
- run: scarb run test
7 changes: 4 additions & 3 deletions Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ sort-module-level-items = true
[[tool.snforge.fork]]
name = "Mainnet"
url = "https://starknet-mainnet.public.blastapi.io/rpc/v0_7"
block_id.number = "652612" # "700000"
block_id.number = "652612"

[tool.voyager]
singleton = { path = "singleton.cairo" }
Expand All @@ -37,7 +37,8 @@ createPosition = "scarb --profile release build && node --loader ts-node/esm ./s
deployDevnet = "scarb --profile release build && node --loader ts-node/esm ./scripts/deployDevnet.ts"
deployMainnet = "scarb --profile release build && node --loader ts-node/esm ./scripts/deployMainnet.ts"
deploySepolia = "scarb --profile release build && node --loader ts-node/esm ./scripts/deploySepolia.ts"
deployTimelock = "scarb --profile release build && node --loader ts-node/esm ./scripts/deployTimelock.ts"
deployExtensions = "scarb --profile release build && node --loader ts-node/esm ./scripts/deployExtensions.ts"
verifyPool = "scarb --profile release build && node --loader ts-node/esm ./scripts/verifyPool.ts"
checkGasReport = "scarb --profile release build && node --loader ts-node/esm ./scripts/gasReport.ts --check"
updateGasReport = "scarb --profile release build && node --loader ts-node/esm ./scripts/gasReport.ts --write"
test = "snforge test"
test = "snforge test --max-n-steps 100000000"
2 changes: 1 addition & 1 deletion Scarb.toml.template
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ deploySepolia = "scarb --profile release build && node --loader ts-node/esm ./sc
deployTimelock = "scarb --profile release build && node --loader ts-node/esm ./scripts/deployTimelock.ts"
checkGasReport = "scarb --profile release build && node --loader ts-node/esm ./scripts/gasReport.ts --check"
updateGasReport = "scarb --profile release build && node --loader ts-node/esm ./scripts/gasReport.ts --write"
test = "snforge test"
test = "snforge test --max-n-steps 10000000"
20 changes: 10 additions & 10 deletions gas-report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ Summary:
┌─────────────┬─────────────────────────┬─────────┬────────────────┬────────────────┬─────────────────┬───────────┬──────────────┬──────────────────────────────┬───────────────┬──────────────────┬─────────┐
│ (index) │ Actual fee │ Fee usd │ Fee without DA │ Gas without DA │ Computation gas │ Event gas │ Calldata gas │ Max computation per Category │ Storage diffs │ DA fee │ DA mode │
├─────────────┼─────────────────────────┼─────────┼────────────────┼────────────────┼─────────────────┼───────────┼──────────────┼──────────────────────────────┼───────────────┼──────────────────┼─────────┤
│ Create pool │ '1.452.040.000.000.000' │ 5.808124840000000000690 628 14462 'steps' 2061427200000000000 │ 'BLOB' │
│ Lend │ '111.768.000.000.000' │ 0.44715768000000000438436 │ 12 │ 2 │ 'range_check' │ 1296000000000000 │ 'BLOB' │
│ Transfer │ '102.684.000.000.000' │ 0.410725884000000000719717 │ 4 │ 2 │ 'range_check' │ 9 │ 76800000000000 │ 'BLOB' │
│ Borrow │ '146.900.000.000.000' │ 0.587618900000000000525523 │ 13 │ 2 │ 'range_check' │ 16128000000000000 │ 'BLOB' │
│ Liquidate │ '143.344.000.000.000' │ 0.573321744000000000604602 │ 13 │ 2 │ 'range_check' │ 15 │ 121600000000000 │ 'BLOB' │
│ Create pool │ '1.914.464.000.000.000' │ 7.65785846400000000016241544 31080'range_check' │ 2731856000000000000 │ 'BLOB' │
│ Lend │ '106.412.000.000.000' │ 0.425616812000000000467465 │ 12 │ 2 │ 'range_check' │ 1189600000000000 │ 'BLOB' │
│ Transfer │ '102.900.000.000.000' │ 0.411626100000000000725723 │ 4 │ 2 │ 'range_check' │ 9 │ 76800000000000 │ 'BLOB' │
│ Borrow │ '141.220.000.000.000' │ 0.564819620000000000545543 │ 13 │ 2 │ 'range_check' │ 15121600000000000 │ 'BLOB' │
│ Liquidate │ '143.668.000.000.000' │ 0.574622068000000000613611 │ 13 │ 2 │ 'range_check' │ 15 │ 121600000000000 │ 'BLOB' │
└─────────────┴─────────────────────────┴─────────┴────────────────┴────────────────┴─────────────────┴───────────┴──────────────┴──────────────────────────────┴───────────────┴──────────────────┴─────────┘
Resources:
┌─────────────┬─────────┬───────┬───────┬────────┬──────────┬──────────┬─────────────┬────────┐
│ (index) │ bitwise │ ec_op │ ecdsa │ keccak │ pedersen │ poseidon │ range_check │ steps │
├─────────────┼─────────┼───────┼───────┼────────┼──────────┼──────────┼─────────────┼────────┤
│ Create pool │ 57 │ 3 │ 0 │ 0 │ 1019 │ 1 │ 14528251057
│ Lend │ 26 │ 3 │ 0 │ 0 │ 134 │ 0 │ 1089293965
│ Transfer │ 41 │ 3 │ 0 │ 0 │ 208 │ 0 │ 17924142928
│ Borrow │ 33 │ 3 │ 0 │ 0 │ 146 │ 0 │ 13058107000
│ Liquidate │ 33 │ 3 │ 0 │ 0 │ 175 │ 0 │ 15044117441
│ Create pool │ 138 │ 3 │ 0 │ 0 │ 1772 │ 1 │ 38582580349
│ Lend │ 26 │ 3 │ 0 │ 0 │ 130 │ 0 │ 1161997475
│ Transfer │ 41 │ 3 │ 0 │ 0 │ 208 │ 0 │ 18061143356
│ Borrow │ 33 │ 3 │ 0 │ 0 │ 143 │ 0 │ 13568110481
│ Liquidate │ 33 │ 3 │ 0 │ 0 │ 175 │ 0 │ 15268119184
└─────────────┴─────────┴───────┴───────┴────────┴──────────┴──────────┴─────────────┴────────┘
26 changes: 22 additions & 4 deletions lib/config.devnet.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CairoCustomEnum } from "starknet";
import CONFIG from "vesu_changelog/configurations/config_genesis_sn_main.json" assert { type: "json" };
import { Config, EnvAssetParams, PERCENT, SCALE, toScale, toUtilizationScale } from ".";

Expand Down Expand Up @@ -27,7 +28,7 @@ const env = CONFIG.asset_parameters.map(
asset.token.symbol,
BigInt(asset.token.decimals),
toScale(10000),
asset.oracle.pragma_key,
asset.pragma.pragma_key,
price(asset.token.symbol),
asset.token.is_legacy,
BigInt(asset.fee_rate),
Expand All @@ -41,8 +42,12 @@ export const config: Config = {
name: "devnet",
protocol: {
singleton: "0x0",
extension: "0x0",
oracle: "0x0",
extensionPO: "0x0",
extensionCL: "0x0",
pragma: {
oracle: "0x0",
summary_stats: "0x0",
},
},
env,
pools: {
Expand All @@ -51,6 +56,7 @@ export const config: Config = {
description: "",
type: "",
params: {
pool_name: "Genesis Pool",
asset_params: CONFIG.asset_parameters.map((asset: any) => ({
asset: "0x0",
floor: toScale(asset.floor),
Expand Down Expand Up @@ -84,9 +90,12 @@ export const config: Config = {
target_rate_percent: toScale(asset.target_rate_percent),
})),
pragma_oracle_params: CONFIG.asset_parameters.map((asset: any) => ({
pragma_key: asset.oracle.pragma_key,
pragma_key: asset.pragma.pragma_key,
timeout: 0n,
number_of_sources: 0n,
start_time_offset: 0n, // BigInt(asset.pragma.start_time_offset),
time_window: 0n, // BigInt(asset.pragma.time_window),
aggregation_mode: new CairoCustomEnum({ Median: {} }), // new CairoCustomEnum({ [(asset.pragma.aggregation_mode == 0) ? "Median" : "Error"]: {} })
})),
liquidation_params: CONFIG.pair_parameters.map((pair: any) => {
const collateral_asset_index = CONFIG.asset_parameters.findIndex(
Expand All @@ -97,6 +106,15 @@ export const config: Config = {
);
return { collateral_asset_index, debt_asset_index, liquidation_factor: toScale(pair.liquidation_discount) };
}),
debt_caps_params: CONFIG.pair_parameters.map((pair: any) => {
const collateral_asset_index = CONFIG.asset_parameters.findIndex(
(asset: any) => asset.asset_name === pair.collateral_asset_name,
);
const debt_asset_index = CONFIG.asset_parameters.findIndex(
(asset: any) => asset.asset_name === pair.debt_asset_name,
);
return { collateral_asset_index, debt_asset_index, debt_cap: toScale(pair.debt_cap) };
}),
shutdown_params: {
recovery_period: BigInt(CONFIG.pool_parameters.recovery_period),
subscription_period: BigInt(CONFIG.pool_parameters.subscription_period),
Expand Down
52 changes: 38 additions & 14 deletions lib/config.mainnet.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import fs from "fs";
import { CairoCustomEnum } from "starknet";
import CONFIG from "vesu_changelog/configurations/config_genesis_sn_main.json" assert { type: "json" };
import { Config, EnvAssetParams, PERCENT, SCALE, toScale, toUtilizationScale } from ".";
// import CONFIG from "vesu_changelog/configurations/config_re7_usdc_sn_main.json" assert { type: "json" };
// import CONFIG from "vesu_changelog/configurations/config_re7_xstrk_sn_main.json" assert { type: "json" };
// import CONFIG from "vesu_changelog/configurations/config_re7_sstrk_sn_main.json" assert { type: "json" };
import { Config, EnvAssetParams, SCALE, toScale, toUtilizationScale } from ".";

let DEPLOYMENT: any = {};
try {
DEPLOYMENT = JSON.parse(fs.readFileSync(`deployment-....json`, "utf-8"));
} catch (error) {}
import DEPLOYMENT from "vesu_changelog/deployments/deployment_sn_main.json" assert { type: "json" };

const env = CONFIG.asset_parameters.map(
(asset: any) =>
Expand All @@ -14,10 +14,10 @@ const env = CONFIG.asset_parameters.map(
asset.token.symbol,
BigInt(asset.token.decimals),
0n,
asset.oracle.pragma_key,
asset.pragma.pragma_key,
0n,
asset.token.is_legacy,
BigInt(asset.fee_rate),
toScale(asset.fee_rate),
asset.v_token.v_token_name,
asset.v_token.v_token_symbol,
asset.token.address,
Expand All @@ -28,16 +28,25 @@ export const config: Config = {
name: "mainnet",
protocol: {
singleton: DEPLOYMENT.singleton || "0x0",
extension: DEPLOYMENT.extension || "0x0",
oracle: DEPLOYMENT.oracle || CONFIG.asset_parameters[0].oracle.address,
extensionPO: DEPLOYMENT.extensionPO || "0x0",
extensionCL: DEPLOYMENT.extensionCL || "0x0",
pragma: {
oracle: DEPLOYMENT.pragma.oracle || CONFIG.asset_parameters[0].pragma.oracle || "0x0",
summary_stats: DEPLOYMENT.pragma.summary_stats || CONFIG.asset_parameters[0].pragma.summary_stats || "0x0",
},
},
env,
pools: {
"genesis-pool": {
id: 1n,
// id: 2198503327643286920898110335698706244522220458610657370981979460625005526824n, // Genesis Pool
// id: 3592370751539490711610556844458488648008775713878064059760995781404350938653n, // Re7 USDC
// id: 2345856225134458665876812536882617294246962319062565703131100435311373119841n, // Re7 xSTRK
// id: 1301140954640322725373945719229815062445705809076381949099585786202465661889n, // Re7 sSTRK
description: "",
type: "",
params: {
pool_name: "Genesis Pool",
asset_params: CONFIG.asset_parameters.map((asset: any) => ({
asset: asset.token.address,
floor: toScale(asset.floor),
Expand Down Expand Up @@ -71,9 +80,15 @@ export const config: Config = {
target_rate_percent: toScale(asset.target_rate_percent),
})),
pragma_oracle_params: CONFIG.asset_parameters.map((asset: any) => ({
pragma_key: asset.oracle.pragma_key,
timeout: BigInt(asset.oracle.timeout),
number_of_sources: BigInt(asset.oracle.number_of_sources),
pragma_key: asset.pragma.pragma_key,
timeout: BigInt(asset.pragma.timeout),
number_of_sources: BigInt(asset.pragma.number_of_sources),
start_time_offset: BigInt(asset.pragma.start_time_offset),
time_window: BigInt(asset.pragma.time_window),
aggregation_mode:
asset.pragma.aggregation_mode == "median" || asset.pragma.aggregation_mode == "Median"
? new CairoCustomEnum({ Median: {}, Mean: undefined, Error: undefined })
: new CairoCustomEnum({ Median: undefined, Mean: {}, Error: undefined }),
})),
liquidation_params: CONFIG.pair_parameters.map((pair: any) => {
const collateral_asset_index = CONFIG.asset_parameters.findIndex(
Expand All @@ -84,6 +99,15 @@ export const config: Config = {
);
return { collateral_asset_index, debt_asset_index, liquidation_factor: toScale(pair.liquidation_discount) };
}),
debt_caps_params: CONFIG.pair_parameters.map((pair: any) => {
const collateral_asset_index = CONFIG.asset_parameters.findIndex(
(asset: any) => asset.asset_name === pair.collateral_asset_name,
);
const debt_asset_index = CONFIG.asset_parameters.findIndex(
(asset: any) => asset.asset_name === pair.debt_asset_name,
);
return { collateral_asset_index, debt_asset_index, debt_cap: toScale(pair.debt_cap) };
}),
shutdown_params: {
recovery_period: BigInt(CONFIG.pool_parameters.recovery_period),
subscription_period: BigInt(CONFIG.pool_parameters.subscription_period),
Expand All @@ -94,7 +118,7 @@ export const config: Config = {
const debt_asset_index = CONFIG.asset_parameters.findIndex(
(asset: any) => asset.asset_name === pair.debt_asset_name,
);
return { collateral_asset_index, debt_asset_index, max_ltv: 90n * PERCENT };
return { collateral_asset_index, debt_asset_index, max_ltv: toScale(pair.shutdown_ltv) };
}),
},
fee_params: { fee_recipient: CONFIG.pool_parameters.fee_recipient },
Expand Down
Loading
Loading