Skip to content

Commit 75248ca

Browse files
committed
config refact and start 'reflections' section
1 parent c0908fc commit 75248ca

6 files changed

Lines changed: 117 additions & 13 deletions

File tree

.hugo_build.lock

Whitespace-only changes.

config.toml

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
# Hugo Config File
12
baseURL = "https://samelat.github.io/"
23
title = "Samelat's Blog"
34
theme = 'poison'
5+
defaultContentLanguage = 'es'
46

57
[params]
68
author = "Gaston Traberg"
79
brand_image = "/samelat.png"
8-
brand = "Samelat's"
9-
description = "Gaston Traberg blog"
10+
brand = "Samelat's Log"
11+
description = "Gaston Traberg"
1012
dark_mode = true
1113
# menu_item_separator: Separator between each menu item. HTML allowed (default: " - “)
1214
# favicon: Absolute path of your favicon.ico file (default: “/favicon.ico”)
@@ -15,41 +17,57 @@ theme = 'poison'
1517
github_url = "https://github.com/samelat"
1618
twitter_url = "https://twitter.com/_samelat"
1719

20+
# SPANISH
21+
[languages.es]
22+
weight = 1
1823

19-
defaultContentLanguage = 'es'
20-
[languages]
21-
[languages.es]
22-
weight = 1
23-
24+
# SECTIONS
2425
[[languages.es.menu.main]]
2526
identifier = "projects"
2627
name = "Proyectos"
27-
url = "/es/posts/projects/"
28+
url = "/posts/projects/"
2829
weight = 1
2930

31+
[[languages.en.menu.main]]
32+
identifier = "dvd"
33+
parent = "reflections"
34+
name = "Reflexiones libres"
35+
url = "/posts/reflections/"
36+
weight = 10
37+
38+
# ENTRADAS
3039
[[languages.es.menu.main]]
3140
identifier = "dvd"
3241
parent = "projects"
3342
name = "Damn Vulnerable DeFi"
34-
url = "/es/posts/projects/dvd/"
43+
url = "/posts/projects/dvd/"
3544
weight = 2
3645

3746
[[languages.es.menu.main]]
3847
identifier = "about"
3948
name = "Sobre mi"
40-
url = "/es/about/"
49+
url = "/about/"
4150
weight = 100
4251

52+
# ENGLISH
53+
[languages.en]
54+
weight = 2
4355

44-
[languages.en]
45-
weight = 2
46-
56+
# SECTIONS
4757
[[languages.en.menu.main]]
4858
identifier = "projects"
4959
name = "Projects"
5060
url = "/posts/projects/"
5161
weight = 1
5262

63+
[[languages.en.menu.main]]
64+
identifier = "dvd"
65+
parent = "reflections"
66+
name = "Free Reflections"
67+
url = "/posts/reflections/"
68+
weight = 10
69+
70+
# ENTRIES
5371
[[languages.en.menu.main]]
5472
identifier = "dvd"
5573
parent = "projects"
File renamed without changes.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
title: "Challenge #1 - Unstopabble"
3+
date: 2023-03-25T01:57:29+01:00
4+
draft: true
5+
---
6+
7+
DvD version 3.0.0
8+
9+
There’s a tokenized vault with a million DVT tokens deposited. It’s offering flash loans for free, until the grace period ends.
10+
11+
*To pass the challenge, make the vault stop offering flash loans.*
12+
13+
You start with 10 DVT tokens in balance.
14+
15+
- [See the contracts](https://github.com/tinchoabbate/damn-vulnerable-defi/tree/v3.0.0/contracts/unstoppable)
16+
- [Complete the challenge](https://github.com/tinchoabbate/damn-vulnerable-defi/blob/v3.0.0/test/unstoppable/unstoppable.challenge.js)
17+
18+
## Solution ##
19+
20+
In this challenge we have two contracts: *ReceiverUnstoppable.sol* and *UnstoppableVault.sol*. If we analyze them we will see the first one is just implementing the use of function **flashLoan()** of the second one, so, let's take a look what this function do in UnstoppableVault.sol.
21+
22+
## UnstoppableVault.sol ##
23+
24+
The function *flashLoad()* is defined as
25+
26+
```solidity
27+
function flashLoan(
28+
IERC3156FlashBorrower receiver,
29+
address _token,
30+
uint256 amount,
31+
bytes calldata data
32+
) external returns (bool) {
33+
if (amount == 0) revert InvalidAmount(0); // fail early
34+
if (address(asset) != _token) revert UnsupportedCurrency(); // enforce ERC3156 requirement
35+
uint256 balanceBefore = totalAssets();
36+
if (convertToShares(totalSupply) != balanceBefore) revert InvalidBalance(); // enforce ERC4626 requirement
37+
uint256 fee = flashFee(_token, amount);
38+
// transfer tokens out + execute callback on receiver
39+
ERC20(_token).safeTransfer(address(receiver), amount);
40+
// callback must return magic value, otherwise assume it failed
41+
if (receiver.onFlashLoan(msg.sender, address(asset), amount, fee, data) != keccak256("IERC3156FlashBorrower.onFlashLoan"))
42+
revert CallbackFailed();
43+
// pull amount + fee from receiver, then pay the fee to the recipient
44+
ERC20(_token).safeTransferFrom(address(receiver), address(this), amount + fee);
45+
ERC20(_token).safeTransfer(feeRecipient, fee);
46+
return true;
47+
}
48+
```
49+
50+
and we can re-write all this as
51+
52+
- checking load amoun is not 0
53+
- checking asset address is correct
54+
- **checking totalSuppy is equat to totalAssets**
55+
- calculate fee
56+
- transfer *amount* to receiver
57+
- call receiver's function onFlashLoad()
58+
- transfer from receiver back to the contract *amount* + *fee*
59+
- transfer fee to feeReceiver
60+
61+
Every seems good except for the revert condition checking totalSupply is equal to totalAssets(). To understand this line, lets take a look at contract ERC4626 from which this contract inherits.
62+
63+
```solidity
64+
...
65+
ERC20 public immutable asset;
66+
67+
constructor(
68+
ERC20 _asset,
69+
string memory _name,
70+
string memory _symbol
71+
) ERC20(_name, _symbol, _asset.decimals()) {
72+
asset = _asset;
73+
}
74+
...
75+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Nuestro futuro con la IA
2+
3+
Hoy comparti una imagen generada por IA con mi hermano, que es Artista Conceptual, y no pude evitar ponerme a reflexionar sobre eso. No es la primera vez que veo el trabajo de alguien siendo simplificado por la IA. La programacion por ejemplo, es algo que es bastante mas rapido y la pregunta o el planteo que uno automaticamente se hace es: Nos vamos a quedar todos sin trabajo al final?
4+
5+
Hace un tiempo lei una nota de un diario donde planteaban un futuro donde estaba todo resuelto. Las maquinas hacian todo por nosotros, todo: Se encargaban de la comida, de las politicas, de todo. La gente simplemente vivia; Que hacias en el dia a dia?, dependia de cada uno. En esa nota, imaginaban a la gente de hoy en ese contexto y como muchos se podran imaginar, la mayoria simplemente no lo toleraba (Se volvian locas, se deprimian y mas). Y con esto en mente, pensaba, nunca estuvimos como sociedad en el ocio? y la verdad es que si, es mas, lo mejor de nuestra historia surgio en momentos de ocio: Griegos, Renacimiento, por poner pocos ejemplos. Todos podian acceder a ese ocio? No, solo algunos. Entonces, el problema no esta en ocio, el problema es que como sociedad no estamos preparados para aprovecharlo. Probablemente solo algunos sepan aprovechar esa oportunidad y los que no, van a sufrir. Hay que aclarar que ocio no son vacaciones. Algunos lo podran pensar como un momento de disfrute perpetuo, pero es realmente lo que quisiera alguien? Cuando son vacaciones, buscamos disfrutar como recompensa de nuestro trabajo, pero no se si es algo que quisiesemos hacer todo el tiempo, todos los dias (aunque probablemente algunos si jjejeje).
6+
7+
El punto es que, que buena parte de la socidad no pueda aprovechar ese ocio, no es justo. La mayoria de las personas vivien en un mondo pequeño, controlado, donde los problemas que los rodean definien su sentido, su vida, y destruir ese mundo y hacerlos enfretar un mundo mas grande, donde nada es un problema es simplemente arrojarlos al vacio.
8+
9+
Educar hoy, para mi, es aprender a ver el todo, aprender a vernos como parte de un universo infinitamente complejo. Aprender que los problemas y cosas que pasan en la tierra, son insignificantes en comparacion con lo que pasa en nuestro alrededor. Esa cosmovision mas humilde, creo que, si se puede transmitir, va a ayudar a muchos a entender que la IA no representa en fin de su mundo, sino una transicion a un mundo de nuevas oportunidades, donde como individuos podemos explotar cosas que antes solo podiamos imaginar.
10+
11+
En conclusion, de a poco vamos viendo como la IA

0 commit comments

Comments
 (0)