Skip to content

Instantly share code, notes, and snippets.

View allquantor's full-sized avatar
:shipit:
.

Ivan Morozov allquantor

:shipit:
.
View GitHub Profile
<!doctype html><pre id=o>loading…</pre><script type=module>
import { ethers } from 'https://esm.sh/ethers@6.11.1';
const provider = new ethers.JsonRpcProvider('https://ethereum-rpc.publicnode.com');
const RAY = 1e27, SECS = 365*24*3600, apy = r => (Math.pow(r, SECS) - 1) * 100;
/* 1) stETH 7-day SMA APR (already in %) */
const st = fetch('https://eth-api.lido.fi/v1/protocol/steth/apr/sma')
.then(r => r.json())
.then(j => +(
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DeFi Yields</title>
</head>
<body>
<pre id="output"></pre>
<script>
fetch('https://yields.llama.fi/pools')
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/**
* @title Distribution
* @notice Single-vault staking contract for USDS that routes deposits through an ERC-4626 vault to earn
* yield, periodically bridges the generated yield ("overplus") to the AO distribution wallet,
* and offers emergency mechanisms governed by clearly documented roles.
*
* Emergency procedures
import { ethers } from 'ethers';
import * as sdk from '@redstone-finance/sdk';
import { PriceUpdate } from './types';
export async function fetchDAIPrice(): Promise<PriceUpdate> {
const ticker = 'DAI';
try {
const oracleStateWithSigners = await sdk.getOracleRegistryState();
const dataPackagesResponse = await sdk.requestDataPackages({

The Stake-Vault project is a two-tier system that funnels SOL deposits into Jito’s SPL Stake-Pool, keeps the liquid-staking yield inside the vault, and lets a designated authority periodically skim rewards or pro-actively eject user deposits.

Key moving parts:
• On-chain Anchor program (programs/stake-vault): owns all state and enforces rules.
• Off-chain TypeScript client (app/…) & Mocha tests (tests/…): drive transactions, derive PDAs, and fork mainnet for realistic tests. ->> NOT PART OF THE AUDIT
• Utility script (fanout.ts): optional; redistributes harvested JITO tokens to a hard-coded member list. ->> NOT PART OF THE AUDIT
Complexities & critical calculations:

  1. Pool-token ↔ SOL math mirrors SPL-Stake-Pool’s dynamic exchange rate. Functions calc_pool_tokens_for_deposit_with_fees, calc_pool_tokens_required_for_withdrawal, and calc_lamports_for_token_withdrawal_with_fees must stay bit-exact or withdrawals revert (TokenMismatch, InsufficientSolReceived).
  2. Rounding & gr

🔄 Batch Transfers

Batch transfers (identified by Action = "Batch-Transfer") enable you to distribute tokens to many receivers in one go—eliminating the need for multiple transfer messages and credit notices. Tokens created with Coin Maker come with built-in Batch Transfer functionality by default.


✨ How It Works

  • Message Payload:
    Batch transfers specify the receivers directly in the payload (msg.Data), not via a regular message Tag.
----------------------------------------------------------------------
-- REBALANCING ENGINE – single-file Lua module
-- Author: GPT-assistant | License: MIT
--
-- Core idea:
-- * Input : table 'portfolio' (array of asset rows)
-- table 'params' (index methodology settings)
-- * Output : table 'trades' (what to buy/sell, side-pockets, etc.)
--
-- Each asset row looks like:
---@diagnostic disable: duplicate-set-field
require("test.setup")()
local json = require "json"
_G.VerboseTests = 0
_G.printVerb = function(level)
level = level or 2
return function(...)
if _G.VerboseTests >= level then print(table.unpack({ ... })) end
---@diagnostic disable: duplicate-set-field
require("test.setup")()
local json = require "json"
_G.VerboseTests = 0
_G.printVerb = function(level)
level = level or 2
return function(...)
if _G.VerboseTests >= level then print(table.unpack({ ... })) end
---@diagnostic disable: duplicate-set-field
require("test.setup")()
local json = require "json"
_G.VerboseTests = 0
_G.printVerb = function(level)
level = level or 2
return function(...)
if _G.VerboseTests >= level then print(table.unpack({ ... })) end