Skip to content

Instantly share code, notes, and snippets.

import type { Address } from 'viem'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import type { FundingRateArbParams } from './open'
// Only mock external deps - logger and storage
vi.mock('@/lib/logger', () => ({
logger: { getChild: () => ({ info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() }) },
}))
vi.mock('@/lib/storage/env-storage', () => ({
import type { Address } from 'viem'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import type { StrategyPhase, StrategyState } from './strategy-store'
// Mock setup - hoisted before imports
const mockBusOn = vi.fn()
const mockStrategyStoreGetState = vi.fn()
const mockUpdateStrategy = vi.fn()
// Capture the event handlers registered with bus.on
const ETH_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
const DAI_TOKEN_ADDRESS = "0x6b175474e89094c44da98b954eedeac495271d0f"
const LUSD_TOKEN_ADDRESS = "0x5f98805A4E8be255a32880FDeC7F6728C6568bA0"
const migrateMakerVaultToLiquity = (dsa, helpers, vaultId) => {
// 1. Look up how much collateral and debt exists in the Maker vault
const vault = await helpers.getMakerResolver().getVaultById(vaultId)
const vaultCollateral = vault.ink
const vaultDebt = vault.debt
@edmulraney
edmulraney / combine-liquity-calls-example-1.js
Last active September 2, 2021 15:38
Combine Liquity function calls via Instadapp SDK
const moveLusdGainToStabilityPoolRecipe = (dsa, frontendTagAddress) => {
const spells = dsa.Spell()
const lusdGainId = 1; // ID reference to the LUSD amount that is claimed
const claimStakingGainsSpell = {
connector: "LIQUITY-A",
method: "claimStakingGains",
args: [0, lusdGainId]
export const asdf = 123
import createThunkStore from './ceate-thunk-store'
import { postUser } from './actions'
import {
POST_USER_REQUESTED,
POST_USER_SUCCEEDED,
POST_USER_FAILED,
} from './action-types'
const API_SERVICE_PATH = './api-service'
import createThunkStore from './create-thunk-store'
import { postUser } from './actions'
import {
POST_USER_REQUESTED,
POST_USER_SUCCEEDED,
POST_USER_FAILED,
} from './action-types'
describe('postUser', () => {
describe('dispatches correct actions', () => {
import createThunkStore from './create-thunk-store'
import {
POST_USER_REQUESTED,
POST_USER_SUCCEEDED,
POST_USER_FAILED,
} from './action-types'
const API_SERVICE_PATH = './api-service'
describe('postUser', () => {
@edmulraney
edmulraney / webpack.config.proxy.dev.server.js
Last active July 18, 2016 08:52
Webpack proxy server config
// some back ends don't respond correctly if origin header isn't set to target host.
devServer: {
proxy: {
"/api": {
ignorePath: true,
target: "http|https://your-api.com/api",
// secure: false, optional for https
changeOrigin: true,
},
},
//
// Copyright (c) 2014 PayPal. All rights reserved.
//
/**
* The PayPalItem class defines an optional itemization for a payment.
* @see https://developer.paypal.com/docs/api/#item-object for more details.
* @param {String} name: Name of the item. 127 characters max
* @param {Number} quantity: Number of units. 10 characters max.