-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Numoen/wallet-actions
Wallet actions
- Loading branch information
Showing
65 changed files
with
5,089 additions
and
744 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Submodule panoptic-v1-core
deleted from
0c4f90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
packages/panoptic-sdk/src/_test/bytecode/collateralTracker.ts
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const mockERC20Bytecode = | ||
"0x60e06040523480156200001157600080fd5b5060405162001252380380620012528339810160408190526200003491620001db565b8282826000620000458482620002ef565b506001620000548382620002ef565b5060ff81166080524660a0526200006a6200007a565b60c0525062000439945050505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6000604051620000ae9190620003bb565b6040805191829003822060208301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200013e57600080fd5b81516001600160401b03808211156200015b576200015b62000116565b604051601f8301601f19908116603f0116810190828211818310171562000186576200018662000116565b81604052838152602092508683858801011115620001a357600080fd5b600091505b83821015620001c75785820183015181830184015290820190620001a8565b600093810190920192909252949350505050565b600080600060608486031215620001f157600080fd5b83516001600160401b03808211156200020957600080fd5b62000217878388016200012c565b945060208601519150808211156200022e57600080fd5b506200023d868287016200012c565b925050604084015160ff811681146200025557600080fd5b809150509250925092565b600181811c908216806200027557607f821691505b6020821081036200029657634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620002ea57600081815260208120601f850160051c81016020861015620002c55750805b601f850160051c820191505b81811015620002e657828155600101620002d1565b5050505b505050565b81516001600160401b038111156200030b576200030b62000116565b62000323816200031c845462000260565b846200029c565b602080601f8311600181146200035b5760008415620003425750858301515b600019600386901b1c1916600185901b178555620002e6565b600085815260208120601f198616915b828110156200038c578886015182559484019460019091019084016200036b565b5085821015620003ab5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6000808354620003cb8162000260565b60018281168015620003e65760018114620003fc576200042d565b60ff19841687528215158302870194506200042d565b8760005260208060002060005b85811015620004245781548a82015290840190820162000409565b50505082870194505b50929695505050505050565b60805160a05160c051610de96200046960003960006104e1015260006104ac0152600061015f0152610de96000f3fe608060405234801561001057600080fd5b50600436106100ea5760003560e01c806370a082311161008c5780639dc29fac116100665780639dc29fac146101f8578063a9059cbb1461020b578063d505accf1461021e578063dd62ed3e1461023157600080fd5b806370a08231146101b05780637ecebe00146101d057806395d89b41146101f057600080fd5b806323b872dd116100c857806323b872dd14610147578063313ce5671461015a5780633644e5151461019357806340c10f191461019b57600080fd5b806306fdde03146100ef578063095ea7b31461010d57806318160ddd14610130575b600080fd5b6100f761025c565b6040516101049190610a72565b60405180910390f35b61012061011b366004610b07565b6102ea565b6040519015158152602001610104565b61013960025481565b604051908152602001610104565b610120610155366004610b31565b610364565b6101817f000000000000000000000000000000000000000000000000000000000000000081565b60405160ff9091168152602001610104565b6101396104a8565b6101ae6101a9366004610b07565b610503565b005b6101396101be366004610b6d565b60036020526000908152604090205481565b6101396101de366004610b6d565b60056020526000908152604090205481565b6100f7610511565b6101ae610206366004610b07565b61051e565b610120610219366004610b07565b610528565b6101ae61022c366004610b8f565b6105ad565b61013961023f366004610c02565b600460209081526000928352604080842090915290825290205481565b6000805461026990610c35565b80601f016020809104026020016040519081016040528092919081815260200182805461029590610c35565b80156102e25780601f106102b7576101008083540402835291602001916102e2565b820191906000526020600020905b8154815290600101906020018083116102c557829003601f168201915b505050505081565b33600081815260046020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552925280832085905551919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906103529086815260200190565b60405180910390a35060015b92915050565b73ffffffffffffffffffffffffffffffffffffffff831660009081526004602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146103f8576103c68382610cb7565b73ffffffffffffffffffffffffffffffffffffffff861660009081526004602090815260408083203384529091529020555b73ffffffffffffffffffffffffffffffffffffffff85166000908152600360205260408120805485929061042d908490610cb7565b909155505073ffffffffffffffffffffffffffffffffffffffff808516600081815260036020526040908190208054870190555190918716907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906104959087815260200190565b60405180910390a3506001949350505050565b60007f000000000000000000000000000000000000000000000000000000000000000046146104de576104d96108d1565b905090565b507f000000000000000000000000000000000000000000000000000000000000000090565b61050d828261096b565b5050565b6001805461026990610c35565b61050d82826109e4565b33600090815260036020526040812080548391908390610549908490610cb7565b909155505073ffffffffffffffffffffffffffffffffffffffff8316600081815260036020526040908190208054850190555133907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906103529086815260200190565b4284101561061c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f5045524d49545f444541444c494e455f4558504952454400000000000000000060448201526064015b60405180910390fd5b600060016106286104a8565b73ffffffffffffffffffffffffffffffffffffffff8a811660008181526005602090815260409182902080546001810190915582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98184015280840194909452938d166060840152608083018c905260a083019390935260c08083018b90528151808403909101815260e0830190915280519201919091207f190100000000000000000000000000000000000000000000000000000000000061010083015261010282019290925261012281019190915261014201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181528282528051602091820120600084529083018083525260ff871690820152606081018590526080810184905260a0016020604051602081039080840390855afa15801561077a573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff8116158015906107f557508773ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b61085b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f494e56414c49445f5349474e45520000000000000000000000000000000000006044820152606401610613565b73ffffffffffffffffffffffffffffffffffffffff90811660009081526004602090815260408083208a8516808552908352928190208990555188815291928a16917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a350505050505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60006040516109039190610cca565b6040805191829003822060208301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b806002600082825461097d9190610da0565b909155505073ffffffffffffffffffffffffffffffffffffffff82166000818152600360209081526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91015b60405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff821660009081526003602052604081208054839290610a19908490610cb7565b909155505060028054829003905560405181815260009073ffffffffffffffffffffffffffffffffffffffff8416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906020016109d8565b600060208083528351808285015260005b81811015610a9f57858101830151858201604001528201610a83565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610b0257600080fd5b919050565b60008060408385031215610b1a57600080fd5b610b2383610ade565b946020939093013593505050565b600080600060608486031215610b4657600080fd5b610b4f84610ade565b9250610b5d60208501610ade565b9150604084013590509250925092565b600060208284031215610b7f57600080fd5b610b8882610ade565b9392505050565b600080600080600080600060e0888a031215610baa57600080fd5b610bb388610ade565b9650610bc160208901610ade565b95506040880135945060608801359350608088013560ff81168114610be557600080fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215610c1557600080fd5b610c1e83610ade565b9150610c2c60208401610ade565b90509250929050565b600181811c90821680610c4957607f821691505b602082108103610c82577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8181038181111561035e5761035e610c88565b600080835481600182811c915080831680610ce657607f831692505b60208084108203610d1e577f4e487b710000000000000000000000000000000000000000000000000000000086526022600452602486fd5b818015610d325760018114610d6557610d92565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0086168952841515850289019650610d92565b60008a81526020902060005b86811015610d8a5781548b820152908501908301610d71565b505084890196505b509498975050505050505050565b8082018082111561035e5761035e610c8856fea2646970667358221220b11b12f451d302ac1575430d5233aab5c5ffbeda9357098ad5151563725bec1964736f6c63430008120033"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Test accounts | ||
export const ACCOUNTS = [ | ||
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", | ||
"0x70997970C51812dc3A010C7d01b50e0d17dc79C8", | ||
] as const; | ||
|
||
// Named accounts | ||
export const [ALICE, BOB] = ACCOUNTS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { startProxy } from "@viem/anvil"; | ||
|
||
export default async function () { | ||
return await startProxy({ | ||
port: 8545, // By default, the proxy will listen on port 8545. | ||
host: "::", // By default, the proxy will listen on all interfaces. | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { createFraction } from "reverse-mirage"; | ||
import { | ||
http, | ||
createPublicClient, | ||
createTestClient, | ||
createWalletClient, | ||
} from "viem"; | ||
import { foundry } from "viem/chains"; | ||
import type { Chain } from "viem/chains"; | ||
import type { PanopticCollateralParamters } from "../index.js"; | ||
import { ALICE } from "./constants.js"; | ||
|
||
export const pool = Number(process.env.VITEST_POOL_ID ?? 1); | ||
export const anvil = { | ||
...foundry, // We are using a mainnet fork for testing. | ||
id: foundry.id, | ||
rpcUrls: { | ||
// These rpc urls are automatically used in the transports. | ||
default: { | ||
// Note how we append the worker id to the local rpc urls. | ||
http: [`http://127.0.0.1:8545/${pool}`], | ||
webSocket: [`ws://127.0.0.1:8545/${pool}`], | ||
}, | ||
public: { | ||
// Note how we append the worker id to the local rpc urls. | ||
http: [`http://127.0.0.1:8545/${pool}`], | ||
webSocket: [`ws://127.0.0.1:8545/${pool}`], | ||
}, | ||
}, | ||
} as const satisfies Chain; | ||
|
||
export const testClient = createTestClient({ | ||
chain: anvil, | ||
mode: "anvil", | ||
transport: http(), | ||
}); | ||
|
||
export const publicClient = createPublicClient({ | ||
chain: anvil, | ||
transport: http(), | ||
}); | ||
|
||
export const walletClient = createWalletClient({ | ||
chain: anvil, | ||
transport: http(), | ||
account: ALICE, | ||
}); | ||
|
||
export const baseParameters: PanopticCollateralParamters = { | ||
type: "panopticCollateralParameters", | ||
maintenanceMarginRatio: createFraction(13_333, 10_000), | ||
commissionFee: createFraction(10, 10_000), | ||
ITMSpreadFee: createFraction(60, 10_000), | ||
sellCollateralRatio: createFraction(2_000, 10_000), | ||
buyCollateralRatio: createFraction(1_000, 10_000), | ||
targetPoolUtilization: createFraction(5_000, 10_000), | ||
saturatedPoolUtilization: createFraction(9_000, 10_000), | ||
exerciseCost: createFraction(-1_024, 10_000), | ||
}; |
Oops, something went wrong.