Skip to content

Commit

Permalink
feat: deleverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Macket committed Oct 5, 2023
1 parent d4c6ac6 commit 0c0d59c
Show file tree
Hide file tree
Showing 5 changed files with 447 additions and 0 deletions.
248 changes: 248 additions & 0 deletions src/constants/abis/DeleverageZap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
[
{
"stateMutability": "nonpayable",
"type": "constructor",
"inputs": [
{
"name": "_controller",
"type": "address"
},
{
"name": "_collateral",
"type": "address"
},
{
"name": "_router",
"type": "address"
},
{
"name": "_routes",
"type": "address[11][]"
},
{
"name": "_route_params",
"type": "uint256[5][5][]"
},
{
"name": "_route_pools",
"type": "address[5][]"
},
{
"name": "_route_names",
"type": "string[]"
}
],
"outputs": []
},
{
"stateMutability": "view",
"type": "function",
"name": "get_stablecoins",
"inputs": [
{
"name": "collateral",
"type": "uint256"
},
{
"name": "route_idx",
"type": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "uint256"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "calculate_debt_n1",
"inputs": [
{
"name": "collateral",
"type": "uint256"
},
{
"name": "route_idx",
"type": "uint256"
},
{
"name": "user",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "int256"
}
]
},
{
"stateMutability": "nonpayable",
"type": "function",
"name": "callback_repay",
"inputs": [
{
"name": "user",
"type": "address"
},
{
"name": "stablecoins",
"type": "uint256"
},
{
"name": "collateral",
"type": "uint256"
},
{
"name": "debt",
"type": "uint256"
},
{
"name": "callback_args",
"type": "uint256[]"
}
],
"outputs": [
{
"name": "",
"type": "uint256[2]"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "CONTROLLER",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "COLLATERAL",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "ROUTER",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "routes",
"inputs": [
{
"name": "arg0",
"type": "uint256"
},
{
"name": "arg1",
"type": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "address"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "route_params",
"inputs": [
{
"name": "arg0",
"type": "uint256"
},
{
"name": "arg1",
"type": "uint256"
},
{
"name": "arg2",
"type": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "uint256"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "route_pools",
"inputs": [
{
"name": "arg0",
"type": "uint256"
},
{
"name": "arg1",
"type": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "address"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "route_names",
"inputs": [
{
"name": "arg0",
"type": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "string"
}
]
},
{
"stateMutability": "view",
"type": "function",
"name": "routes_count",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256"
}
]
}
]
7 changes: 7 additions & 0 deletions src/constants/llammas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import MonetaryPolicyABI from "../constants/abis/MonetaryPolicy.json";
import MonetaryPolicy2ABI from "../constants/abis/MonetaryPolicy2.json";
import { lowerCaseLlammasAddresses } from "./utils";


export const LLAMMAS: IDict<ILlamma> = lowerCaseLlammasAddresses({
sfrxeth: {
amm_address: '0x136e783846ef68C8Bd00a3369F787dF8d683a696',
controller_address: '0x8472A9A7632b173c8Cf3a86D3afec50c35548e76',
monetary_policy_address: '0xc684432FD6322c6D58b6bC5d28B18569aA0AD0A1',
collateral_address: '0xac3E018457B222d93114458476f3E3416Abbe38F',
leverage_zap: '0xb556FA4C4752321B3154f08DfBDFCF34847f2eac',
deleverage_zap: '0xF113929F69FAbE165A2280CaC00c5f77196Aa34C',
collateral_symbol: 'sfrxETH',
collateral_decimals: 18,
min_bands: 4,
Expand All @@ -24,6 +26,7 @@ export const LLAMMAS: IDict<ILlamma> = lowerCaseLlammasAddresses({
monetary_policy_address: '0x1E7d3bf98d3f8D8CE193236c3e0eC4b00e32DaaE',
collateral_address: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
leverage_zap: '0x293436d4e4a15FBc6cCC400c14a01735E5FC74fd',
deleverage_zap: '0x600E571106C31c4Ca1bF4177bA808E37146A4A0C',
collateral_symbol: 'wstETH',
collateral_decimals: 18,
min_bands: 4,
Expand All @@ -38,6 +41,7 @@ export const LLAMMAS: IDict<ILlamma> = lowerCaseLlammasAddresses({
monetary_policy_address: '0x1E7d3bf98d3f8D8CE193236c3e0eC4b00e32DaaE',
collateral_address: '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599',
leverage_zap: '0xA2518b71ee64E910741f5Cf480b19E8e402de4d7',
deleverage_zap: '0xb911D7e59BA82FDF477a2Ab22Ff25125072C9282',
health_calculator_zap: "0xCF61Ee62b136e3553fB545bd8fEc11fb7f830d6A",
collateral_symbol: 'WBTC',
collateral_decimals: 8,
Expand All @@ -53,6 +57,7 @@ export const LLAMMAS: IDict<ILlamma> = lowerCaseLlammasAddresses({
monetary_policy_address: '0x1E7d3bf98d3f8D8CE193236c3e0eC4b00e32DaaE',
collateral_address: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
leverage_zap: '0xd3e576B5DcDe3580420A5Ef78F3639BA9cd1B967',
deleverage_zap: '0x9bE82CdDB5c266E010C97e4B1B5B2DF53C16384d',
collateral_symbol: 'ETH',
collateral_decimals: 18,
min_bands: 4,
Expand All @@ -67,6 +72,7 @@ export const LLAMMAS: IDict<ILlamma> = lowerCaseLlammasAddresses({
monetary_policy_address: '0x1e7d3bf98d3f8d8ce193236c3e0ec4b00e32daae',
collateral_address: '0xac3e018457b222d93114458476f3e3416abbe38f',
leverage_zap: '0x43eCFfe6c6C1b9F24AeB5C180E659c2a6FCe11Bc',
deleverage_zap: '0x2bc706B83aB08d0437b8A397242C3284B5f81D74',
collateral_symbol: 'sfrxETH',
collateral_decimals: 18,
min_bands: 4,
Expand All @@ -81,6 +87,7 @@ export const LLAMMAS: IDict<ILlamma> = lowerCaseLlammasAddresses({
monetary_policy_address: '0xb8687d7dc9d8fa32fabde63e19b2dbc9bb8b2138',
collateral_address: '0x18084fba666a33d37592fa2633fd49a74dd93a88',
leverage_zap: '0xD79964C70Cb06224FdA4c48387B53E9819bcB71c',
deleverage_zap: '0xAA25a6Fa9e4dADaE0d3EE59bEA19fbcf0284830C',
collateral_symbol: 'tBTC',
collateral_decimals: 18,
min_bands: 4,
Expand Down
3 changes: 3 additions & 0 deletions src/crvusd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import controllerABI from "./constants/abis/controller.json";
import llammaABI from "./constants/abis/llamma.json";
import HealthCalculatorZapABI from "./constants/abis/HealthCalculatorZap.json";
import LeverageZapABI from "./constants/abis/LeverageZap.json";
import DeleverageZapABI from "./constants/abis/DeleverageZap.json";
import PegKeeper from "./constants/abis/PegKeeper.json";
import { LLAMMAS } from "./constants/llammas";
import { COINS } from "./constants/coins";
Expand Down Expand Up @@ -147,6 +148,7 @@ class Crvusd implements Icrvusd {
this.setContract(llamma.collateral_address, ERC20ABI);
}
this.setContract(llamma.leverage_zap, LeverageZapABI);
this.setContract(llamma.deleverage_zap, DeleverageZapABI);
if (llamma.health_calculator_zap) this.setContract(llamma.health_calculator_zap, HealthCalculatorZapABI);
}
for (const pegKeeper of this.constants.PEG_KEEPERS) {
Expand Down Expand Up @@ -206,6 +208,7 @@ class Crvusd implements Icrvusd {
monetary_policy_address,
collateral_address: is_eth ? "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" : collaterals[i],
leverage_zap: "0x0000000000000000000000000000000000000000",
deleverage_zap: "0x0000000000000000000000000000000000000000",
collateral_symbol: is_eth ? "ETH" : collateral_symbol,
collateral_decimals,
min_bands: 4,
Expand Down
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface ILlamma {
monetary_policy_address: string,
collateral_address: string,
leverage_zap: string,
deleverage_zap: string,
health_calculator_zap?: string,
collateral_symbol: string,
collateral_decimals: number,
Expand Down
Loading

0 comments on commit 0c0d59c

Please sign in to comment.