Gelato๐Ÿฆ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์Šค๋งˆํŠธ ๊ณ„์•ฝ ์‹คํ–‰์„ ์ž๋™ํ™”ํ•˜๋Š” ๋ฐฉ๋ฒ•

10856 ๋‹จ์–ด defiblockchainautomationtooling
์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ ์ž‘์„ฑํ•ด ๋ณธ ์ ์ด ์žˆ๋‹ค๋ฉด ์Šค๋งˆํŠธ ๊ณ„์•ฝ์ด ํŠน์ • ์กฐ๊ฑด ํ•˜์—์„œ ์ž์ฒด์ ์œผ๋กœ ํŠน์ • ๊ธฐ๋Šฅ์„ ์‹คํ–‰ํ•˜๋„๋ก ํ•˜๋Š” ๊ฒƒ์ด ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค๋Š” ๊ฒƒ์„ ์•Œ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ด๋”๋ฆฌ์›€ ๊ฐ€๊ฒฉ์ด ์˜ค๋ฅด๋ฉด ๋งค๋„ ์ฃผ๋ฌธ์„ ํ•ฉ๋‹ˆ๋‹ค. ์ด๋ฅผ ๋‹ฌ์„ฑํ•˜๋ ค๋ฉด ์˜จ์ฒด์ธ ํ™œ๋™์„ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜๋Š” ์ž์ฒด ๋ด‡์„ ๊ตฌ์ถ•ํ•œ ๋‹ค์Œ ํŠธ๋žœ์žญ์…˜์„ ๋ณด๋‚ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ์ด๋Ÿฌํ•œ ๊ธฐ๋Šฅ์„ ์ˆ˜ํ–‰ํ•˜๋Š” ๋ด‡์„ ๊ตฌ์ถ•ํ•˜๋ ค๋ฉด ๋Œ€์‹  ์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ ์ตœ์ ํ™”ํ•˜๊ฑฐ๋‚˜ ๊ทธ๋Š˜์ง„ ์ง€ํ•˜์‹ค์—์„œ ์‚ฐ์ฑ…์„ ๋‚˜๊ฐ€๋Š” ๋ฐ ํ• ๋‹นํ•  ์ˆ˜ ์žˆ๋Š” ๋งŽ์€ ์ž‘์—…๊ณผ ๊ฐœ๋ฐœ์ž ๋ฆฌ์†Œ์Šค๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ๐Ÿ™Š ๊ทธ ์™ธ์—๋„ ๋ด‡์„ ์‹คํ–‰ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์„œ๋ฒ„์—์„œ ๋งค์ผ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜์‹ญ์‹œ์˜คโ€ฆ ๊ทธ ๋ชจ๋“  ์žฌ๋ฏธ์žˆ๋Š” ๊ฒƒ๋“ค.

๊ทธ๋ž˜์„œ ์—ฌ๊ธฐ์— ํ•ด๊ฒฐ์ฑ…์ด ์žˆ์Šต๋‹ˆ๋‹ค โ€” ์‹คํŒจ์˜ ์ค‘์‹ฌ์ ์ด ๋˜๊ธฐ ์‰ฌ์šด ๊ธฐ๋ณธ ์ธํ”„๋ผ๋ฅผ ์‹คํ–‰ํ•  ํ•„์š” ์—†์ด ๋ฉ‹์ง„ ์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ ๊ตฌ์ถ•ํ•˜๋Š” ๋ฐ ๊ณ„์† ์ง‘์ค‘ํ•˜์‹ญ์‹œ์˜ค. Gelato์ด(๊ฐ€) ๋‹น์‹ ์„ ์œ„ํ•ด ์ผํ•˜๊ฒŒ ํ•˜์‹ญ์‹œ์˜ค.

๐Ÿƒโ€โ™‚๏ธ ์ถœ๋ฐœ



์ด๋ฏธ ์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ ๋ฐฐํฌํ–ˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  Gelato๊ฐ€ ํŠน์ • ์‹œ๊ฐ„์— ์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ ํ˜ธ์ถœํ•˜๊ธฐ๋ฅผ ์›ํ•ฉ๋‹ˆ๋‹ค. Gelato์—๊ฒŒ ์•Œ๋ ค์ค„ ๋ฆฌ์กธ๋ฒ„ ์ปจํŠธ๋ž™ํŠธ๋ฅผ ๋ฐฐํฌํ•˜๊ธฐ๋งŒ ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

"์ด๋ด ์ด ๊ธฐ๋Šฅ์„ ๋งค์‹œ๊ฐ„ ์—ฌ๊ธฐ๋กœ ๋ถˆ๋Ÿฌ์ค˜"

๋‹ค์Œ์€ Gelato์—์„œ ํ˜ธ์ถœํ•˜๋ ค๋Š” ํ•จ์ˆ˜buy()์˜ ์˜ˆ์ž…๋‹ˆ๋‹ค. ์ด ๊ธฐ๋Šฅ์€ Uniswap V2๋ฅผ ํ†ตํ•ด ETH๋ฅผ ๊ตฌ๋งคํ•ฉ๋‹ˆ๋‹ค.

uint256 public lastBought;

function buy(
    uint256 amountIn,
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
  ) external {
    require(block.timestamp >= lastBought + 1 hours);
    IERC20(path[0]).approve(address(router), amountIn);
    router.swapExactTokensForETH(
           amountIn, 
           amountOutMin, 
           path, 
           to,     
           deadline
    );
    lastBought = block.timestamp;
  }


๋‹ค์Œ์€ ํ™•์ธ์ž ๊ณ„์•ฝ์˜ ์˜ˆ์ž…๋‹ˆ๋‹ค. checker()๋Š” lastBought๊ฐ€ ํ•œ ์‹œ๊ฐ„ ์ด์ƒ ์ง€๋‚œ ๊ฒฝ์šฐ true๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋ฉด Gelato๊ฐ€ ์œ„์—์„œ ์–ธ๊ธ‰ํ•œ buy() ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜๋ผ๋Š” ๋ฉ”์‹œ์ง€๊ฐ€ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.

contract Resolver {
  address public immutable owner;
  ISwap public immutable swap;
  address WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
  address USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
constructor(address _swap) public {
    owner = msg.sender;
    swap = ISwap(_swap);
  }
function checker()
    external
    view
    returns (bool canExec, bytes memory execPayload)
  {
    address[] memory path = new address[](2);
    path[0] = USDT;
    path[1] = WETH;
    uint256 deadline = block.timestamp + 10 minutes;
    uint256 lastBought = swap.lastBought();
    if (lastBought >= 1 hours) {
       bytes4 selector =                                                        
       bytes4(keccak256(
           "buy(uint256,uint256,address[],address,uint256"));
       execPayload = abi.encodeWithSelector(
         selector,
         1000 ether,
         0,
         path,
         owner,
         deadline
       );
     canExec = true;
     return (canExec, execPayload);
    }
  }
}


Gelato๋Š” ๋ชจ๋“  ๋ธ”๋ก์—์„œ ์ด๋ฅผ ์˜คํ”„์ฒด์ธchecker()์ด๋ผ๊ณ  ๋ถ€๋ฆ…๋‹ˆ๋‹ค. canExec๊ฐ€ true๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋ฉด ์ง‘ํ–‰์ž๋Š” execPayload์™€ ํ•จ๊ป˜ ํŠธ๋žœ์žญ์…˜์„ ๋ณด๋ƒ…๋‹ˆ๋‹ค.

ํ™•์ธ์ž ๊ณ„์•ฝ ์ž‘์„ฑ ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ docs์„ ์ฐธ์กฐํ•˜์‹ญ์‹œ์˜ค.

๐Ÿ‘ทโ€โ™‚๏ธ ์ž‘์—… ๋งŒ๋“ค๊ธฐ



ํ™•์ธ์ž ๊ณ„์•ฝ์„ ๋ฐฐํฌํ•˜๋ฉด ์ด๋ฏธ ์ ˆ๋ฐ˜์€ ์™„๋ฃŒ๋œ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ด์ œ ์ž‘์—…์„ ์ œ์ถœํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. Gelato๋Š” PokeMe UI๋กœ ์ž‘์—… ์ œ์ถœ์„ ๋งค์šฐ ์‰ฝ๊ฒŒ ๋งŒ๋“ญ๋‹ˆ๋‹ค.

1. ํฌ์ผ“๋ชฌ์Šคํ„ฐ ํ™ˆํŽ˜์ด์ง€ ๋ฐฉ๋ฌธ





์—ฌ๊ธฐ์—์„œ ํ˜„์žฌ ์ž‘์—…๊ณผ ์ž”์•ก์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

2. ์ž‘์—… ์ œ์ถœ์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.





์—ฌ๊ธฐ์— ์ˆ˜๋™์œผ๋กœ ์ฑ„์›Œ์•ผ ํ•˜๋Š” ๋‘ ๊ฐœ์˜ ํ•„๋“œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ์‹คํ–‰ ์ฃผ์†Œ โ€” Gelato๊ฐ€ ํ˜ธ์ถœํ•  ํ•จ์ˆ˜์˜ ์ฃผ์†Œ์ž…๋‹ˆ๋‹ค.
  • ํ•ด์„๊ธฐ ์ฃผ์†Œ โ€” ์ด์ „์— ๋ฐฐํฌ๋œ ํ•ด์„๊ธฐ์˜ ์ฃผ์†Œ์ž…๋‹ˆ๋‹ค.



  • ์‹คํ–‰ ์ฃผ์†Œ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ์„ ํƒํ•  ์ˆ˜ ์žˆ๋Š” ํ•จ์ˆ˜ ๋ชฉ๋ก์ด ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค.

    3. Gelato๊ฐ€ ํ˜ธ์ถœํ•  ๊ธฐ๋Šฅ์„ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.



    Etherscan/Polygonscan์—์„œ ๊ณ„์•ฝ์„ ํ™•์ธํ–ˆ๋Š”์ง€ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค. ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด ํ™•์ธํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹คmanually.



    ๋ฆฌ์กธ๋ฒ„ ์ฃผ์†Œ์—๋„ ๋™์ผํ•˜๊ฒŒ ์ ์šฉ๋ฉ๋‹ˆ๋‹ค.
  • ๋ด‡์ด ์‹คํ–‰๋˜์–ด์•ผ ํ•˜๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด Gelato๊ฐ€ ์˜คํ”„์ฒด์ธ์„ ํ˜ธ์ถœํ•  ๊ธฐ๋Šฅ์„ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.
  • ๊ณผ์ œ๋ฅผ ์ œ์ถœํ•˜์„ธ์š”!



  • dashboard ์—์„œ ์ œ์ถœํ•œ ๋ชจ๋“  ์ž‘์—…์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.



    ์ž‘์—…์„ ํด๋ฆญํ•˜๋ฉด ์ž์„ธํ•œ ๋‚ด์šฉ๊ณผ ์ž‘์—…์˜ ๋ชจ๋“  ์ด์ „ ์‹คํ–‰์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    ๐Ÿค‘ ์˜ˆ๊ธˆ ์ž๊ธˆ



    ์ž‘์—…์„ ์ œ์ถœํ•œ ํ›„ ๋งˆ์ง€๋ง‰ ๋‹จ๊ณ„๋Š” ํŠธ๋žœ์žญ์…˜ ์‹คํ–‰์— ๋Œ€ํ•ด ์ง‘ํ–‰์ž์—๊ฒŒ ์ง€๋ถˆํ•˜๋Š” ๋ฐ ์‚ฌ์šฉํ•  ์ผ๋ถ€ ์ž๊ธˆ์„ ์˜ˆ์น˜ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.



    ์Šค๋งˆํŠธ ๊ณ„์•ฝ์˜ ๋„คํŠธ์›Œํฌ์— ๋”ฐ๋ผ ์ผ๋ถ€ ETH ๋˜๋Š” MATIC์„ ์˜ˆ์น˜ํ•˜์‹ญ์‹œ์˜ค.



    ๊ทธ๋Ÿฌ๋ฉด ์ž”์•ก์ด ๋Œ€์‹œ๋ณด๋“œ์— ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค.

    ๐ŸŽŠ ๋ชจ๋‘ ์™„๋ฃŒ



    ์ค€๋น„๊ฐ€ ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค! Gelato๋Š” ์ด์ œ ์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜๊ณ  ์ง€์ •๋œ ์กฐ๊ฑด์ด ์ถฉ์กฑ๋˜๋ฉด ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค!

    Gelato PokeMe๋Š” Ethereum ๋ฉ”์ธ๋„ท, Ropsten ๋ฐ Polygon์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    ๋‹ค์Œ์€ contract addresses์ž…๋‹ˆ๋‹ค!

    ์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ